Compare commits

..
232 Commits
Author SHA1 Message Date
KernelDeimos e8dc220981 This is 2.1.0 I decided 2024-04-15 15:37:13 -04:00
KernelDeimos 1c2b05d8f6 Fix phoenix for auto ports 2024-04-15 15:34:58 -04:00
KernelDeimos f3495f3098 Fix xterm.css not loading 2024-04-15 14:46:16 -04:00
KernelDeimos 081b093e7e Add missing asset for xterm, fix SDK url 2024-04-15 14:43:15 -04:00
KernelDeimos 4d30753958 Fix more phoenix dev issues 2024-04-15 14:25:40 -04:00
KernelDeimos c72e0cb0e0 Fix phoenix watcher 2024-04-15 14:08:50 -04:00
KernelDeimos 25f8dbf120 Add postinstall for phoenix 2024-04-15 14:02:49 -04:00
KernelDeimos 2717444c29 Oops 2024-04-15 12:17:09 -04:00
KernelDeimos b21755b5a3 Fix casualty of phoenix due to Docker naming conventions 2024-04-15 12:12:28 -04:00
KernelDeimos 37ff97b52f Thanks minify 2024-04-15 03:59:39 -04:00
Eric Dubé b897598fac Merge pull request #282 from HeyPuter/eric/task-manager
Add a task manager
2024-04-15 03:53:51 -04:00
Eric Dubé 95cb92abed Remove outdated information 2024-04-15 03:50:46 -04:00
KernelDeimos 5730dc642a Add process ending and i18n 2024-04-15 03:37:04 -04:00
KernelDeimos 7c2a3b4612 Portal shows up as 'app' 2024-04-15 02:12:39 -04:00
Nariman Jelveh dbf796d698 Update index.js 2024-04-14 21:27:25 -07:00
Nariman Jelveh 7f739a53f8 Merge pull request #281 from HeyPuter/change-email-feature
Change email feature
2024-04-14 21:10:57 -07:00
Nariman Jelveh 2dbde52338 live-update email address after change 2024-04-14 21:09:41 -07:00
KernelDeimos 61f1caa122 Add type column 2024-04-14 23:58:14 -04:00
Nariman Jelveh 695d7b8654 Update UIDesktop.js 2024-04-14 20:53:31 -07:00
KernelDeimos 6e7fd2ca95 Add polling 2024-04-14 23:52:53 -04:00
KernelDeimos 79bfcf226b Integrate ProcessService with task manager 2024-04-14 23:52:53 -04:00
KernelDeimos 9d9e091a7a Add process management 2024-04-14 23:52:53 -04:00
KernelDeimos be1bb6bc06 Improve task manager style 2024-04-14 23:52:53 -04:00
KernelDeimos d39bb412f3 Begin work on task manager 2024-04-14 23:52:53 -04:00
KernelDeimos e71b586fe5 Invalidate cached user when the user's email address is changed 2024-04-14 23:50:39 -04:00
KernelDeimos 2fcac12340 Fixg 2024-04-14 23:24:47 -04:00
KernelDeimos 0847395c92 Socket 2024-04-14 23:10:23 -04:00
Nariman Jelveh 49c3df2328 allow child windows to center relative to parent window 2024-04-14 20:04:27 -07:00
KernelDeimos 58192cacb3 Try again 2024-04-14 23:00:07 -04:00
KernelDeimos b81284e2c6 Pass the RIGHT token to email 2024-04-14 22:49:51 -04:00
KernelDeimos 5b39e39e1f Use jwt for email change confirmation 2024-04-14 22:44:04 -04:00
KernelDeimos b944217410 Fix 2024-04-14 22:29:54 -04:00
KernelDeimos dca7304be9 Remove requirement of auth from email confirm 2024-04-14 22:23:42 -04:00
Nariman Jelveh 61a4b10adf add i18n text 2024-04-14 19:14:33 -07:00
KernelDeimos 231878266c Fix 2024-04-14 22:08:31 -04:00
KernelDeimos 51bf8fdde6 Fix 2024-04-14 21:41:08 -04:00
KernelDeimos 18134629d2 Move 2024-04-14 21:37:12 -04:00
KernelDeimos f6b737e45d Add confirmation email for email change 2024-04-14 21:33:15 -04:00
KernelDeimos 3b7be8a719 Add delete-own-user 2024-04-14 21:32:43 -04:00
Nariman Jelveh aae1d194c7 wip 2024-04-14 17:43:20 -07:00
KernelDeimos ef0da306a8 Fix change_email 2024-04-14 20:35:34 -04:00
Nariman Jelveh bfaaa914f1 wip 2024-04-14 17:30:22 -07:00
Nariman Jelveh 2f101c4a39 close #271 2024-04-14 17:10:46 -07:00
Nariman Jelveh 765eb43568 Disable manual arrangement in Explore 2024-04-14 12:50:28 -07:00
Nariman Jelveh aa61e005e5 Merge pull request #279 from hasanbeder/main
Translated Turkish language file
2024-04-14 09:53:59 -07:00
Nariman Jelveh 5b2e2b037b Update tr.js 2024-04-14 09:50:21 -07:00
Nariman Jelveh bcfd685826 Update translations.js 2024-04-14 09:48:43 -07:00
hasanbeder 6679318207 Translated Turkish language file
This commit includes the Turkish language file with the translations. 🇹🇷
2024-04-14 13:12:56 +03:00
Nariman Jelveh 255e80d077 Make Puter.js verbosity optional via debug flag. 2024-04-13 17:31:29 -07:00
KernelDeimos 965d99d137 Fix socket auth 2024-04-13 17:19:12 -04:00
Nariman Jelveh 3b65523da9 separate refresh_item_container into a module 2024-04-13 13:41:15 -07:00
Nariman Jelveh 3cfee32ae0 Update helpers.js 2024-04-13 12:28:28 -07:00
Eric Dubé 497c633b8a Merge pull request #227 from MohamedElashri/main
Add requirements for multi-platform docker build to the CI
2024-04-13 14:58:45 -04:00
KernelDeimos df45e22813 Make node-pty not required 2024-04-13 13:56:57 -04:00
KernelDeimos 199b68a964 Highlight current session 2024-04-13 02:30:48 -04:00
Nariman Jelveh 8db8ec3574 Update Apps.js 2024-04-12 22:04:28 -07:00
KernelDeimos 4a36670417 Update README.md files for monorepo'd projects 2024-04-12 23:54:41 -04:00
KernelDeimos 77ac503bfc Edit phoenix README.md 2024-04-12 23:49:43 -04:00
Nariman Jelveh be55e447bb fix issue with two session managers on top of each other 2024-04-12 20:43:15 -07:00
KernelDeimos 00e9f922c0 Fix target version 2024-04-12 23:16:49 -04:00
KernelDeimos 361e51060a Update apps 2024-04-12 22:03:40 -04:00
Eric Dubé fbbc73308e Merge pull request #274 from HeyPuter/eric/builtin-apps
Move terminal and phoenix into main repo
2024-04-12 21:54:47 -04:00
KernelDeimos a31e4c19cb Update package-lock.json 2024-04-12 21:51:49 -04:00
Nariman Jelveh b69a85f10e Merge pull request #273 from Hiya-its-Aya/dark-mode
White text for themes
2024-04-12 18:30:15 -07:00
KernelDeimos d919b1f312 Register terminal and phoenix builtins 2024-04-12 20:56:16 -04:00
KernelDeimos cb81579c53 Copy over phoenix 2024-04-12 20:53:44 -04:00
KernelDeimos 0306a395a2 Copy over terminal 2024-04-12 20:53:32 -04:00
KernelDeimos 5fbbfb4c18 Enable background and builtin apps 2024-04-12 20:52:57 -04:00
Aya Moosa b725c4c7b4 removed commented code causing translation error 2024-04-12 14:39:46 -07:00
Aya Moosa 24e3ec89f3 added white text to brodacast 2024-04-12 14:28:15 -07:00
Aya Moosa f8d3fdbefb merge 2024-04-12 14:16:26 -07:00
Nariman Jelveh 352f1bc23e Update README.md to add link to fridge running Puter. 2024-04-12 13:59:59 -07:00
Nariman Jelveh 413cb79683 Merge pull request #269 from secondtruth/patch/translation-de
Update German translation
2024-04-12 13:26:35 -07:00
Christian Neff d06f856e46 Update German translation 2024-04-12 22:00:42 +02:00
KernelDeimos 09c3cc6db1 Fix error when session not found 2024-04-12 01:22:33 -04:00
Eric Dubé eb96dd952b Merge pull request #267 from HeyPuter/eric/session-fixes
session management fixes
2024-04-12 00:29:26 -04:00
KernelDeimos 1da3a769c4 Use localstorage instead of cookie for list-sessions 2024-04-12 00:19:07 -04:00
KernelDeimos 356a3284fa Fix mysql incompatibility 2024-04-12 00:10:56 -04:00
KernelDeimos 0eedcf567e Apply some fixes 2024-04-11 23:48:17 -04:00
KernelDeimos f4f58dbfb9 Fix destructuring 2024-04-11 23:28:40 -04:00
Eric Dubé 8135e076c2 Merge pull request #266 from HeyPuter/eric/session-updates
session management
2024-04-11 22:04:07 -04:00
Eric Dubé 22b3415866 Merge pull request #265 from HeyPuter/eric/puter-dot-js
puter.js
2024-04-11 21:59:46 -04:00
KernelDeimos 5effca4bbc Add missing i18n key 2024-04-11 21:57:26 -04:00
KernelDeimos aa14541e50 Update package-lock.json for npm ci 2024-04-11 21:54:50 -04:00
KernelDeimos 13525c85a0 -dot- 2024-04-11 21:46:43 -04:00
KernelDeimos 2f6f7e39bb Add timestamp 2024-04-11 21:41:19 -04:00
KernelDeimos 2d76025c9c Send cookie on token upgrade 2024-04-11 21:40:10 -04:00
KernelDeimos bb9edc4f65 Add automatic token migration 2024-04-11 21:33:44 -04:00
KernelDeimos afcd821f50 Update README.md 2024-04-11 19:40:50 -04:00
KernelDeimos b8e66cada9 Add puter.js 2024-04-11 19:07:00 -04:00
KernelDeimos fc5025a2a8 Simplify PuterVersionService 2024-04-11 14:37:34 -04:00
KernelDeimos e3d238f897 Do not use git to get version number 2024-04-11 13:57:40 -04:00
Nariman Jelveh 9ab3e3ccd8 Merge pull request #244 from HeyPuter/eric/host-storage
Display storage use of host/puter separately
2024-04-11 10:14:45 -07:00
Nariman Jelveh 7abf5faa3c fix missing translations 2024-04-11 10:13:52 -07:00
Nariman Jelveh 4052c7995c Merge pull request #260 from AtkinsSJ/fix-silly-mistakes
Fix permission check for closeApp message
2024-04-11 09:48:02 -07:00
Sam Atkins 776b6831f3 Fix permission check for closeApp message
Firstly, I was missing an `async` here, which somehow still worked for
me then, but produced errors for me when I tried it today.

Then, actually await the promise.

Finally, actually check the target's parent is us, and not just that it
has the attribute!

I don't know what was going on in my head that day. 🤦‍♂️
2024-04-11 17:21:23 +01:00
Nariman Jelveh a2d231dc23 Merge pull request #259 from PeterDaveHelloKitchen/zhtw
Add a simple Traditional Chinese translation
2024-04-11 09:02:20 -07:00
Peter Dave Hello 1aeedd8696 Add a simple Traditional Chinese translation 2024-04-11 20:03:13 +08:00
KernelDeimos 09bf422686 Add session manager ui 2024-04-11 00:29:39 -04:00
KernelDeimos 18b3e06fe8 Add session listing and revocation 2024-04-10 23:00:37 -04:00
KernelDeimos e436693d3e Improve session mgmt (part 1) 2024-04-10 21:54:16 -04:00
KernelDeimos eb66848aee Update database version when creating a new one 2024-04-10 12:25:44 -04:00
KernelDeimos 0eded34c8c Add indented logs and fix a bug 2024-04-10 12:22:21 -04:00
KernelDeimos 367c18bfc5 Add endpoint to list permissions 2024-04-10 12:16:08 -04:00
Eric Dubé 92dc0a7671 Merge pull request #255 from AtkinsSJ/appconnection-close
Notify apps when a child app closes, and let them close their children manually
2024-04-09 21:31:48 -04:00
Eric Dubé 8e553b4ee0 Merge pull request #252 from AtkinsSJ/broadcasts
Add a message broadcasting system
2024-04-09 21:29:46 -04:00
Sam Atkins 21c64e827b Add closeApp message
Sending a 'closeApp' message allows an app to close a target app, if it
has permission to do so. Currently, permission is granted if the
requesting app is the parent of the target app, or has godmode set.
2024-04-09 16:09:12 +01:00
Sam Atkins c69a0abfa9 Extract a window_for_app_instance() helper function 2024-04-09 15:55:14 +01:00
Sam Atkins cce6531d45 Notify parents/children when an app closes
Send an appClosed message with the instance ID of the app that was
closed. This will be picked up by Puter.js's AppConnection and reported
as a 'close' event.

To make this work, a `data-parent_instance_id` attribute is set on child
app windows. This is very similar to the `data-parent_uuid` attribute,
which tracks parent windows instead of parent app instances. (Dialogs
have a parent window, but are not apps, so don't have a parent app
instance.) The difference is subtle, and we may want to combine these in
the future, but currently closing an app will close any child windows,
which is not behaviour we want for child apps.
2024-04-09 15:55:14 +01:00
Sam Atkins 84a31b3520 Broadcast when the language changes
This is left open to future additions, by naming it 'locale', and having
the language just be an object field.

Side note, maybe we should have a LocaleService for this?
2024-04-09 10:44:51 +01:00
Sam Atkins 59cdb6e8c6 Broadcast when theme changes 2024-04-09 10:44:51 +01:00
Sam Atkins 068e620249 Add a message broadcasting service
A broadcast is a message sent to every running app that uses Puter.js.
Broadcasts have a name and a data payload, and are sent as a 'broadcast'
message.

Send a broadcast using:
`globalThis.services.get('broadcast').sendBroadcast(...)`

When doing so, you have the option to keep the broadcast message around,
so that it can be sent to any newly-launched apps. Sending another
broadcast with the same name will overwrite the previous one, so you
don't have to worry about flooding a new app with duplicates.
2024-04-09 10:44:51 +01:00
Aya Moosa 80aa87023e working white text, not perfect with all colors 2024-04-08 22:01:00 -07:00
Aya Moosa 626d63c91d working white text, not perfect with all colors 2024-04-08 22:00:12 -07:00
Aya Moosa 5bf0411015 got white text working, restets when other silders are used 2024-04-08 21:24:24 -07:00
Aya Moosa b2fcb8d104 started light text for color 2024-04-08 15:59:12 -07:00
KernelDeimos 79f98795c7 Fix version checker using later javascript features 2024-04-08 17:05:47 -04:00
Eric Dubé 24ad365047 Merge pull request #253 from AtkinsSJ/bad-config-login-error
Add an error message when login fails because of domain misconfiguration
2024-04-08 12:23:31 -04:00
Eric Dubé 72286fd642 Merge pull request #249 from AtkinsSJ/service-copyrights
Add some missing copyright notices
2024-04-08 12:22:15 -04:00
Mohamed Elashri a0f46c326a Add build stage and remove linux/arm/v7 2024-04-08 17:12:26 +02:00
Sam Atkins b1f2750cdb Add an error message when login fails because of domain misconfiguration
Previously, we just output whatever err.responseText was. However, that
has some downsides:

- If there's no responseText (as for when we can't find the domain) then
  the user gets a blank message.
- If it's a 404 error, the responseText includes the full HTML for
  Puter's 404 page, which we don't want to dump in the error box! This
  is unlikely to happen in practice, but was easy enough to cater for.

So, add a nicer message in those cases.

The misconfiguration message is taken from here:
https://github.com/HeyPuter/puter/issues/185#issuecomment-2037977592

Resolves #235.
2024-04-08 15:49:00 +01:00
Sam Atkins 8aee3f8174 Add some missing copyright notices 2024-04-08 11:10:39 +01:00
Nariman Jelveh ea61799b3d Merge pull request #240 from HeyPuter/eric/gui-personalization
Puter Theme Color Setting
2024-04-07 14:35:24 -07:00
KernelDeimos b1e6e0c25a Fix i18n 2024-04-07 17:27:09 -04:00
KernelDeimos f7916cfa74 Add option to reset colors 2024-04-07 17:19:47 -04:00
KernelDeimos 3f37ef2fad Fix i18n 2024-04-07 16:18:59 -04:00
KernelDeimos 3297940bab Improve dialog 2024-04-07 04:53:49 -04:00
KernelDeimos 821d33b8d8 Make opacity differences match prod 2024-04-07 04:39:08 -04:00
KernelDeimos 72129ca16f Make defaults consistent with original 2024-04-07 03:21:32 -04:00
KernelDeimos 12fa88b149 Save color settings 2024-04-07 03:15:45 -04:00
KernelDeimos c83069bd03 Add i18n items 2024-04-07 02:53:33 -04:00
KernelDeimos 5661605884 Add ui colors to settings window 2024-04-07 02:53:05 -04:00
KernelDeimos d1bbbb8e93 Use CSS variables 2024-04-07 02:34:04 -04:00
KernelDeimos 178f851684 Fix previous fix 2024-04-07 00:28:23 -04:00
KernelDeimos cb4b8c5914 Add minor fixes 2024-04-07 00:06:11 -04:00
KernelDeimos 8018a607a8 Add CSS 2024-04-07 00:05:54 -04:00
KernelDeimos dc5a7ca431 Display storage use of host/puter separately 2024-04-06 23:26:18 -04:00
Eric Dubé 95d33eab94 Merge pull request #238 from AtkinsSJ/app-ipc
Implement support for launching child apps, and IPC between a parent and its children
2024-04-06 07:51:17 -04:00
Sam Atkins 725cbf2e20 Add support for launching child apps
Calling `puter.ui.launchApp()` now treats the new app as a child of the
one that launched it.

A child app is given a `puter.parent_instance_id` URL param, containing
its parent's instance ID.

Previously, `launchApp()` would resolve as soon as the app was launched.
This commit changes that, so that it is notified after the child app
sends its READY event to Puter. This means that as soon as `launchApp()`
has completed, the child app is ready to receive messages. The downside
is that launching an app that does not include Puter.js will now not
cause a notification, so `await puter.ui.launchApp()` will not resolve
in that case.
2024-04-06 12:27:36 +01:00
KernelDeimos 674cebd9e1 Add Linux support to HostDiskUsageService 2024-04-06 05:33:46 -04:00
Eric Dubé 0dd66463df Merge pull request #241 from vineeth-vk11/#233
Implementing HostDiskUsageService removing diskusage dependency
2024-04-06 05:29:21 -04:00
KernelDeimos beeeb7bcbf Tiny fix 2024-04-06 05:08:38 -04:00
vineethvk11 bf4bc214b2 Implementing HostDiskUsageService removing diskusage dependency 2024-04-06 13:03:09 +05:30
KernelDeimos b99534ebdf Add WIP color sliders 2024-04-06 02:35:06 -04:00
Eric Dubé c6fb75c65f Merge pull request #231 from HeyPuter/eric/user-to-user-permissions
User-to-User Permission Granting
2024-04-05 23:11:32 -04:00
KernelDeimos 38e8b19b50 Cleanup 2024-04-05 23:05:20 -04:00
KernelDeimos 90ce840234 Add revoke-user-user endpoint 2024-04-05 23:01:50 -04:00
KernelDeimos fc6eda392b Allow granting user-to-user permissions 2024-04-05 22:11:36 -04:00
KernelDeimos 343edbff51 Use weak CORS policy for experimental_no_subdomain 2024-04-05 16:51:57 -04:00
KernelDeimos fe88880486 Add experimental_no_subdomain flag 2024-04-05 16:21:19 -04:00
KernelDeimos 1c2e4968e2 Remove console log 2024-04-05 14:38:50 -04:00
KernelDeimos f9b375a39b Fix case when main domain is a subdomain 2024-04-05 14:38:33 -04:00
KernelDeimos eb18e74e88 Add error when someone forgets npm install 2024-04-05 14:09:34 -04:00
Eric Dubé 487553a00c Merge pull request #237 from eltociear/patch-2
Update download.js
2024-04-05 13:32:05 -04:00
Sam Atkins c78927d5db Add messageToApp message
This lets apps communicate with each other, via Puter.

We probably want to limit this in some way, but for now, all apps are
allowed to send messages to any other apps.

The message is:
- `targetAppInstanceID`: The instance ID to send the message to
- `targetAppOrigin`: targetOrigin passed to postMessage(), in case we
  want to restrict which URL can receive the message
- `contents`: The message to send to the target
2024-04-05 16:38:12 +01:00
Ikko Eltociear Ashimine 26e9822344 Update download.js
minor fix
2024-04-06 00:22:22 +09:00
KernelDeimos 207fa139d4 Add user-to-user permissions table 2024-04-05 03:23:31 -04:00
Eric Dubé e2236d43fd Merge pull request #234 from vineeth-vk11/#80
fixing issues in copy while overwriting
2024-04-05 03:21:22 -04:00
vineethvk11 6006767a9f fixing issues in copy while overwriting 2024-04-05 09:11:39 +05:30
KernelDeimos 35abf9a6bc Stop printing default password in logs 2024-04-04 22:17:00 -04:00
KernelDeimos c3a4223bbf Add service to check EOL date of node 2024-04-04 22:10:56 -04:00
KernelDeimos 4a2fa5a29f Friendly node version errors 2024-04-04 21:39:32 -04:00
Mohamed Elashri 17ae6668b4 Add linux/arm/v7 again
We need to test if this is what causes the problem of the GitHub action getting stuck or `linux/arm/v6`
2024-04-05 01:10:47 +00:00
Mohamed Elashri 06a31fd67b Fix typo in arm64 namespace 2024-04-05 00:59:05 +00:00
Mohamed Elashri 1a13ef6921 remove linux/arm/v7,linux/arm/v6 emporarily 2024-04-05 00:55:44 +00:00
KernelDeimos 17a323298c Make dismiss command print what was dismissed 2024-04-04 20:46:03 -04:00
KernelDeimos 27c99fd90a Use OR IGNORE when sqlite 2024-04-04 20:02:35 -04:00
KernelDeimos 6c7175c109 NOOP legacy share fetch 2024-04-04 19:26:29 -04:00
KernelDeimos cdd9dbf748 Add quick doc about https 2024-04-04 19:08:45 -04:00
Eric Dubé 1b72b80241 Merge branch 'main' into main 2024-04-04 18:43:39 -04:00
Eric Dubé be53a9472a Update docker-image.yaml 2024-04-04 18:39:53 -04:00
Mohamed Elashri accdec3af4 handle linking to python binary gracefully 2024-04-04 21:51:39 +00:00
Mohamed Elashri 95b6dbd140 Add python3 to use node-gyp to allow native cross platform build
python3 would be required by node-gyp to natively build node add-on. This is required if we build for multi-platform
2024-04-04 21:47:29 +00:00
KernelDeimos 08838c989e Fix fragmented if..else seq (fix app tokens) 2024-04-04 17:44:54 -04:00
Mohamed Elashri 74bff84226 Remove unpopular archs
For now, we need to stick to the most used archs for resources and build time reasons.
2024-04-04 21:35:22 +00:00
Mohamed Elashri b1a3124fcc Add requirements for multi-platform docker build to the CI 2024-04-04 22:58:00 +02:00
Eric Dubé 3e1c7eb434 Merge pull request #223 from vineeth-vk11/#211
removing storage limit for self hosters
2024-04-04 16:12:31 -04:00
KernelDeimos 2125367683 Avoid predicate.values not iterable error 2024-04-04 14:20:30 -04:00
KernelDeimos 809e33b053 Remove unused code 2024-04-04 14:18:34 -04:00
KernelDeimos 0efe163591 Update README.md 2024-04-04 13:56:33 -04:00
Eric Dubé e8935f5582 Add many platforms arbitrarily
Related to #214; added additional architectures which may or may not work. I'd rather someone find out it doesn't work then for them to be blocked from even trying.
2024-04-04 13:47:24 -04:00
vineethvk11 0da9e1fab3 removing storage limit for self hosters 2024-04-04 22:31:37 +05:30
Eric Dubé 802370eb9d Fix heading level 2024-04-04 02:14:36 -04:00
KernelDeimos 4e722b47b5 Document pub_port, which wasn't documented before 2024-04-03 22:11:52 -04:00
KernelDeimos b055c5cdad Fix change_username 2024-04-03 22:06:06 -04:00
KernelDeimos b7a1f21e31 Fix puter sites errors 2024-04-03 22:05:33 -04:00
KernelDeimos a04cac60e6 Fix db migration error in SQLES 2024-04-03 17:38:42 -04:00
KernelDeimos 274b69d017 Fix /file and /setItem 2024-04-03 17:21:25 -04:00
Nariman Jelveh 5fab338ba1 Merge pull request #219 from HeyPuter/eric/2024-04-02/display-directory-load-error
Display error in directory when readdir fails
2024-04-02 15:44:44 -07:00
KernelDeimos 6cd77384a5 Update default text for explorer-error-message 2024-04-02 16:50:22 -04:00
KernelDeimos 5290d78e20 Display error in directory when readdir fails 2024-04-02 16:46:34 -04:00
Eric Dubé 2ce02db1b5 Update issue templates 2024-04-02 05:03:39 -04:00
Eric Dubé fff46a6b63 Update issue templates 2024-04-02 04:54:33 -04:00
KernelDeimos 369037e269 Fix incorrect asset urls 2024-04-02 04:19:22 -04:00
KernelDeimos 6f7264b60b Fix logout for invalid sessions 2024-04-02 04:19:12 -04:00
KernelDeimos 9881fecacd Fix error caused by fixing kv 2024-04-02 03:40:58 -04:00
KernelDeimos cf9338c35f Document different configuration locations 2024-04-02 02:14:59 -04:00
KernelDeimos a9947ad97f Update README.md 2024-04-02 02:09:36 -04:00
Eric Dubé ac2e3e2873 Merge pull request #212 from shuguet/main
fix: Fix permission errors when running Docker. Update Docker Compose & Docker instructions
2024-04-02 02:02:46 -04:00
Sylvain Huguet 8f4eb5627b Update instructions & docker-compose to reflect production paths 2024-04-02 07:45:14 +02:00
Sylvain Huguet e4bd62b84c Fix README instructions following path changes 2024-04-02 07:34:55 +02:00
Sylvain Huguet 0e033348f0 Fix permission errors when running Docker. Update Docker Compose & Docker instructions 2024-04-02 07:26:44 +02:00
KernelDeimos 0651aab1be Fix DBKVStore value format 2024-04-02 00:47:14 -04:00
KernelDeimos f8a7f1c1f9 Update README.md 2024-04-02 00:33:02 -04:00
KernelDeimos c90931d004 Fix docker-compose.yml 2024-04-02 00:25:29 -04:00
KernelDeimos a973f66092 Only load from source in dev environment 2024-04-01 22:26:09 -04:00
KernelDeimos 5d81ff4cbe Fix dev console bar when columns has small value 2024-04-01 22:01:34 -04:00
KernelDeimos 7442b48157 Fix undefined instead of null in db query 2024-04-01 19:41:16 -04:00
KernelDeimos 59003a9ab9 Make dev-console use in WebServerService optional 2024-04-01 19:40:59 -04:00
KernelDeimos 40c2e3f442 Add April-1st-appropriate commit message guidelines 2024-04-01 19:33:11 -04:00
KernelDeimos 65b61fc90d Remove unused variable 2024-04-01 17:24:48 -04:00
KernelDeimos 05c6cd6c3d Separate default user into SelfhostedModule 2024-04-01 17:24:07 -04:00
Eric Dubé 15fcc5680f Merge pull request #195 from shuguet/main
feat: Add support for running Puter self-hosted using the automatically built Docker image
2024-04-01 15:06:23 -04:00
Eric Dubé fdd9f30c39 Merge branch 'main' into main 2024-04-01 15:06:16 -04:00
Nariman Jelveh 0049c9ef00 Merge pull request #205 from AtkinsSJ/fix-i18n-typo
Fix issues with translation keys, and check these in CI
2024-04-01 11:18:43 -07:00
Nariman Jelveh f097f2e10a Merge pull request #164 from vineeth-vk11/#141
removing html inside translation strings
2024-04-01 11:03:55 -07:00
Nariman Jelveh 4009f4f331 Merge branch 'main' into #141 2024-04-01 11:02:37 -07:00
Sam Atkins 8f8b7f0fbf Check that all uses of i18n() use keys that exist
If code uses `i18n('foo')` and 'foo' is not in the dictionary for the en
translation, then this script will now report it as an error. This has
already helped catch a few mistakes.
2024-04-01 12:12:31 +01:00
Sam Atkins 29b3b4ecba Add or correct missing i18n keys
'save_account_to_publish' isn't used anywhere, so I assume that
'save_account_to_publish_website' is supposed to use that.
2024-04-01 12:10:31 +01:00
Sam Atkins b111e05ef7 Fix typo in 'change_always_open_with' i18n key 2024-04-01 12:00:58 +01:00
Sam Atkins c2f73c37c5 Correct capitalisation of i18n() keys
Found by searching for `i18n\(\'[^\']*[A-Z]+[^\']*\'\)`
2024-04-01 11:26:07 +01:00
KernelDeimos 92b3f4ff76 Default user random pass, sqlite query patches 2024-04-01 01:23:53 -04:00
KernelDeimos 1cdda3dda8 Document default user 2024-03-31 22:47:13 -04:00
KernelDeimos a8a03d3f87 Add some config documentation 2024-03-31 22:42:11 -04:00
KernelDeimos 5eebc9a5de Update ports for repo docker 2024-03-31 21:48:42 -04:00
Sylvain Huguet cc648be854 Re-enable healthchecks, adjusted intervals & start-time 2024-04-01 02:07:44 +02:00
Sylvain Huguet 483e2835c4 Disable healthcheck in Dockerfile as well 2024-03-31 11:34:03 +02:00
Sylvain Huguet daa90286d3 Update README instruction to run either with pure Docker, or with Docker Compose 2024-03-31 11:30:12 +02:00
Sylvain Huguet 5e1d6a7db3 Disable healthcheck until we know the proper URL to call/check 2024-03-31 11:19:35 +02:00
Sylvain Huguet ab4f222e92 Add support for self-hosting in Docker 2024-03-31 11:18:03 +02:00
vineeth kumar 5da46a15fb Merge branch 'main' into #141 2024-03-31 13:02:11 +05:30
vineethvk11 9438355a36 removing html inside translation strings 2024-03-31 12:53:53 +05:30
386 changed files with 43027 additions and 817 deletions

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
.dockerignore
Dockerfile
node_modules
puter
+24
View File
@@ -0,0 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Issue Description**
**Steps to Reproduce**
**Expected & Actual Behavior**
**Addition Information or Screenshots (if applicable)**
**Tooling**
- [ ] Development (`npm run start`)
- [ ] Docker (via `docker run`)
- [ ] Docker (via `docker-compose`)
**Puter version (if accessible)**
> Click the profile button on the top-right, then "Settings". The version number will be printed at the bottom
+10
View File
@@ -0,0 +1,10 @@
---
name: Driver Request
about: Request a driver on Puter
title: ''
labels: ''
assignees: ''
---
> Drivers are services that apps on Puter can use. For example, drivers support many of the features in the [Puter SDK](https://docs.puter.com/). If you're not sure if what you're suggesting is a driver, you should use the "Feature Request" template instead.
+10
View File
@@ -0,0 +1,10 @@
---
name: Feature request
about: Suggest an idea for Puter
title: ''
labels: idea
assignees: ''
---
@@ -0,0 +1,10 @@
---
name: Idea for Improvement
about: An enhancement for an existing feature on Puter
title: ''
labels: enhancement
assignees: ''
---
+7
View File
@@ -40,6 +40,12 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about)
# to extract tags and labels that will be applied to the specified image.
@@ -73,6 +79,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
+2 -1
View File
@@ -8,4 +8,5 @@ dist/
.vscode/
.env
# this is for jetbrain IDEs
.idea/
.idea/
/puter
+22
View File
@@ -57,6 +57,28 @@ See [doc/contributors/index.md](./doc/contributors/index.md) for more informatio
<br>
## Commit Messages
Use the imperative, as is the convention in the Linux kernel:
- correct: `Improve performance of readdir`
- incorrect: `Improved readdir`
- incorrect: `Improving readdir`
We have the following exceptions to this rule:
- If the commit message is in _past tense_, it's a shorthand for the following:
- `Apply changes that would be applied after one had <past tense message>`
- If the commit message is in _present tense_, it's shorthand for the following:
- `Apply changes that would be applied after <present-tense message>`
For example, the following are correct:
- `Improved readdir`
- interpret this as: `Apply changes that would be applied after one had improved readdir`
- `Improving readdir`
- interpret this as: `Apply changes that would be applied after improving readdir`
<br>
## Code Review
Once you've submitted your pull request, the project maintainers will review your changes. We may suggest some changes or improvements. This is a normal part of the process, and your contributions are greatly appreciated!
+36 -13
View File
@@ -1,30 +1,53 @@
# Build stage
FROM node:21-alpine AS build
# Install build dependencies
RUN apk add --no-cache git python3 make g++ \
&& ln -sf /usr/bin/python3 /usr/bin/python
# Set up working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install node modules
RUN npm cache clean --force \
&& npm ci
# Copy the rest of the source files
COPY . .
# Run the build command if necessary
RUN npm run build
# Production stage
FROM node:21-alpine
# Set labels
LABEL repo="https://github.com/HeyPuter/puter"
LABEL license="AGPL-3.0,https://github.com/HeyPuter/puter/blob/master/LICENSE.txt"
LABEL version="v1.2.40-beta"
LABEL version="1.2.46-beta-1"
# Debugging
RUN apk add --no-cache bash # useful for debugging
# Install git (required by Puter to check version)
RUN apk add --no-cache git
# Setup working directory
# Set up working directory
RUN mkdir -p /opt/puter/app
WORKDIR /opt/puter/app
# Add source files
# NOTE: This might change (https://github.com/HeyPuter/puter/discussions/32)
COPY . .
# Copy built artifacts and necessary files from the build stage
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
COPY package*.json ./
# Set permissions
RUN chown -R node:node /opt/puter/app
USER node
# Install node modules
RUN npm cache clean --force \
&& npm install
EXPOSE 4100
EXPOSE 4000
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://puter.localhost:4100/test || exit 1
CMD [ "npm", "start" ]
CMD ["npm", "start"]
+67 -2
View File
@@ -29,6 +29,10 @@ Puter is an advanced, open-source internet operating system designed to be featu
## Getting Started
After reading this section, please proceed to **Self-Hosting** and **Configuration** below.
Read these instructions carefully or you may see errors due to
an invalid setup.
### Local Development
```bash
@@ -44,19 +48,79 @@ This will launch Puter at http://localhost:4000 (or the next available port).
### Using Docker
**note:** it is **not** necessary to run this within a clone of this repository. For contributors, it is recommended to use the [Local Development](#local-development) instructions.
```bash
git clone https://github.com/HeyPuter/puter
cd puter
mkdir puter && cd puter && mkdir -p puter/config puter/data && sudo chown -R 1000:1000 puter && docker run --rm -p 4100:4100 -v `pwd`/puter/config:/etc/puter -v `pwd`/puter/data:/var/puter ghcr.io/heyputer/puter
```
### Using Docker Compose
**note:** it is **not** necessary to run this within a clone of this repository. For contributors, it is recommended to use the [Local Development](#local-development) instructions.
```bash
mkdir -p puter/config puter/data
sudo chown -R 1000:1000 puter
wget https://raw.githubusercontent.com/HeyPuter/puter/main/docker-compose.yml
docker compose up
```
<br/>
See [Configuration](#configuration) for next steps.
<br/>
## ⚠️ Self-Hosting ⚠️
The self-hosted version of Puter is currently in alpha stage and should not be used in production yet. It is under active development and may contain bugs, other issues. Please exercise caution and use it for testing and evaluation purposes only.
<br/>
## Configuration
Running the server will generate a configuration file in one of these locations:
- `config/config.json` when [Using Docker](#using-docker)
- `volatile/config/config.json` in [Local Development](#local-development)
- `/etc/puter/config.json` on a server (or within a Docker container)
### Domain Name
To access Puter on your device, you can simply go to the address printed in
the server console (usually `puter.localhost:4100`).
To access Puter from another device, a domain name must be configured, as well as
an `api` subdomain. For example, `example.local` might be the domain name pointing
to the IP address of the server running puter, and `api.example.com` must point to
this address as well. This domain must be specified in the configuration file
(usually `volatile/config/config.json`) as well.
See [domain configuration](./doc/self-hosters/domains.md) for more information.
### Configure the Port
- You can specify a custom port by setting `http_port` to a desired value
- If you're using a reverse-proxy such as nginx or cloudflare, you should
also set `pub_port` to the public (external) port (usually `443`)
- If you have HTTPS enabled on your reverse-proxy, ensure that
`protocol` in config.json is set accordingly
### Default User
By default, Puter will create a user called `default_user`.
This user will have a randomly generated password, which will be printed
in the development console.
A warning will persist in the dev console until this user's
password is changed. Please login to this user and change the password as
your first step.
<br/>
## License
This repository is licensed under AGPL3. However, our SDK (puter.js) is also available under Apache 2.0, as indicated by the license file in that section (packages/puter-dot-js) of this repository.
<br/>
## FAQ
### ❓ What's the use case for Puter?
@@ -90,6 +154,7 @@ Puter interacts directly with the DOM and jQuery provides an elegant yet powerfu
- [Minecraft](https://twitter.com/HeyPuter/status/1771957571496092036) | [video](https://www.youtube.com/watch?v=GIowZUXkg5g)
- [PlayStation 4](https://twitter.com/HeyPuter/status/1767978053014270059)
- [Skyworth TV](https://twitter.com/ericalexdube/status/1767983049277411564)
- [A Fridge!](https://twitter.com/HeyPuter/status/1778890003797745842)
- [Oculus Quest 2](https://twitter.com/HeyPuter/status/1768664081756754012)
- [Tesla Model S](https://twitter.com/HeyPuter/status/1767971178864587057)
- [Tesla Model Y](https://twitter.com/HeyPuter/status/1772858333751636310)
+72
View File
@@ -0,0 +1,72 @@
# Configurating Domains for Self-Hosted Puter
## Local Network Configuration
### Prerequisite Conditions
Ensure the hosting device has a static IP address to prevent potential connectivity issues due to IP changes. This setup will enable seamless access to Puter and its services across your local network.
### Using Hosts Files
The hosts file is a straightforward way to map domain names to IP addresses on individual devices. It's simple to set up but requires manual changes on each device that needs access to the domains.
#### Windows
1. Open Notepad as an administrator.
2. Open the file located at `C:\Windows\System32\drivers\etc\hosts`.
3. Add lines for your domain and subdomain with the server's IP address, in the
following format:
```
192.168.1.10 puter.local
192.168.1.10 api.puter.local
```
#### For macOS and Linux:
1. Open a terminal.
2. Edit the hosts file with a text editor, e.g., `sudo nano /etc/hosts`.
3. Add lines for your domain and subdomain with the server's IP address, in the
following format:
```
192.168.1.10 puter.local
192.168.1.10 api.puter.local
```
4. Save and exit the editor.
### Using Router Configuration
Some routers allow you to add custom DNS rules, letting you configure domain names network-wide without touching each device.
1. Access your router’s admin interface (usually through a web browser).
2. Look for DNS or DHCP settings.
3. Add custom DNS mappings for `puter.local` and `api.puter.local` to the hosting device's IP address.
4. Save the changes and reboot the router if necessary.
This method's availability and steps may vary depending on your router's model and firmware.
### Using Local DNS
Setting up a local DNS server on your network allows for flexible and scalable domain name resolution. This method works across all devices automatically once they're configured to use the DNS server.
#### Options for DNS Software:
- **Pi-hole**: Acts as both an ad-blocker and a DNS server. Ideal for easy setup and maintenance.
- **BIND9**: Offers comprehensive DNS server capabilities for complex setups.
- **Dnsmasq**: Lightweight and suitable for smaller networks or those new to running a DNS server.
**contributors note:** feel free to add any software you're aware of
which might help with this to the list. Also, feel free to add instructions here for specific software; our goal is for Puter to be easy to setup with tools you're already familiar with.
#### General Steps:
1. Choose and install DNS server software on a device within your network.
2. Configure the DNS server to resolve `puter.local` and `api.puter.local` to the IP address of your Puter hosting device.
3. Update your router’s DHCP settings to distribute the DNS server's IP address to all devices on the network.
By setting up a local DNS server, you gain the most flexibility and control over your network's domain name resolution, ensuring that all devices can access Puter and its API without manual configuration.
## Production Configuration
Please note the self-hosting feature is still in alpha and a public production
deployment is not recommended at this time. However, if you wish to host
publically you can do so following the same steps you normally would to configure
a domain name and ensuring the `api` subdomain points to the server as well.
+23 -5
View File
@@ -1,7 +1,25 @@
version: '3'
---
version: "3.8"
services:
app:
build: ./
puter:
container_name: puter
image: ghcr.io/heyputer/puter:latest
pull_policy: always
# build: ./
restart: unless-stopped
ports:
- 4000:4000
- '4100:4100'
environment:
# TZ: Europe/Paris
# CONFIG_PATH: /etc/puter
PUID: 1000
PGID: 1000
volumes:
- ./puter/config:/etc/puter
- ./puter/data:/var/puter
healthcheck:
test: wget --no-verbose --tries=1 --spider http://puter.localhost:4100/test || exit 1
interval: 30s
timeout: 3s
retries: 3
start_period: 30s
+1035 -18
View File
File diff suppressed because it is too large. Load diff
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "puter.com",
"version": "1.0.0",
"version": "2.1.0",
"author": "Puter Technologies Inc.",
"license": "AGPL-3.0-only",
"description": "Desktop environment in the browser!",
@@ -26,7 +26,8 @@
"start=gui": "nodemon --exec \"node dev-server.js\" ",
"start": "node run-selfhosted.js",
"build": "node ./build.js",
"check-translations": "node tools/check-translations.js"
"check-translations": "node tools/check-translations.js",
"postinstall": "cd packages/phoenix && cd packages/contextlink && npm install && cd - && cd packages/strataparse && npm install && cd - && cd packages/pty && npm install"
},
"workspaces": [
"packages/*"
+3 -1
View File
@@ -18,8 +18,9 @@
*/
const CoreModule = require("./src/CoreModule.js");
const { Kernel } = require("./src/Kernel.js");
const LocalDiskStorageModule = require("./src/LocalDiskStorageModule.js");
const DatabaseModule = require("./src/DatabaseModule.js");
const LocalDiskStorageModule = require("./src/LocalDiskStorageModule.js");
const SelfhostedModule = require("./src/SelfhostedModule.js");
const PuterDriversModule = require("./src/PuterDriversModule.js");
const { testlaunch } = require("./src/index.js");
const BaseService = require("./src/services/BaseService.js");
@@ -44,4 +45,5 @@ module.exports = {
DatabaseModule,
PuterDriversModule,
LocalDiskStorageModule,
SelfhostedModule,
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@heyputer/backend",
"version": "1.0.0",
"version": "2.1.0",
"description": "Backend/Kernel for Puter",
"main": "exports.js",
"scripts": {
+7 -5
View File
@@ -43,6 +43,11 @@ module.exports = CoreModule;
const install = async ({ services, app }) => {
const config = require('./config');
// /!\ IMPORTANT /!\
// For new services, put the import immediate above the
// call to services.registerService. We'll clean this up
// in a future PR.
const { LogService } = require('./services/runtime-analysis/LogService');
const { PagerService } = require('./services/runtime-analysis/PagerService');
const { AlarmService } = require('./services/runtime-analysis/AlarmService');
@@ -182,9 +187,8 @@ const install = async ({ services, app }) => {
const { EventService } = require('./services/EventService');
services.registerService('event', EventService);
const DefaultUserService = require('./services/DefaultUserService');
services.registerService('__default-user', DefaultUserService);
const { PuterVersionService } = require('./services/PuterVersionService');
services.registerService('puter-version', PuterVersionService);
}
const install_legacy = async ({ services }) => {
@@ -195,7 +199,6 @@ const install_legacy = async ({ services }) => {
const PerformanceMonitor = require('./monitor/PerformanceMonitor');
const { OperationTraceService } = require('./services/OperationTraceService');
const { WSPushService } = require('./services/WSPushService');
const { PuterVersionService } = require('./services/PuterVersionService');
const { ReferralCodeService } = require('./services/ReferralCodeService');
const { Emailservice } = require('./services/EmailService');
const { ClientOperationService } = require('./services/ClientOperationService');
@@ -210,7 +213,6 @@ const install_legacy = async ({ services }) => {
services.registerService('filesystem', FilesystemService);
services.registerService('operationTrace', OperationTraceService);
services.registerService('__event-push-ws', WSPushService);
services.registerService('puter-version', PuterVersionService);
services.registerService('referral-code', ReferralCodeService);
services.registerService('email', Emailservice);
services.registerService('file-cache', FileCacheService);
+1 -4
View File
@@ -95,11 +95,8 @@ class Kernel extends AdvancedBase {
root_context.arun(async () => {
await this._install_modules();
});
(async () => {
await this._boot_services();
})();
});
// Error.stackTraceLimit = Infinity;
@@ -23,6 +23,9 @@ class LocalDiskStorageModule extends AdvancedBase {
const services = context.get('services');
const LocalDiskStorageService = require("./services/LocalDiskStorageService");
services.registerService('local-disk-storage', LocalDiskStorageService);
const HostDiskUsageService = require('./services/HostDiskUsageService');
services.registerService('host-disk-usage', HostDiskUsageService);
}
}
+66
View File
@@ -0,0 +1,66 @@
const { AdvancedBase } = require("puter-js-common");
const config = require("./config");
class SelfhostedModule extends AdvancedBase {
async install (context) {
const services = context.get('services');
const DefaultUserService = require('./services/DefaultUserService');
services.registerService('__default-user', DefaultUserService);
const ComplainAboutVersionsService = require('./services/ComplainAboutVersionsService');
services.registerService('complain-about-versions', ComplainAboutVersionsService);
const DevWatcherService = require('./services/DevWatcherService');
const path_ = require('path');
services.registerService('__dev-watcher', DevWatcherService, {
root: path_.resolve(__dirname, '../../../'),
commands: [
{
name: 'puter.js:webpack-watch',
directory: 'packages/puter-js',
command: 'npm',
args: ['run', 'start-webpack'],
},
{
name: 'terminal:rollup-watch',
directory: 'packages/terminal',
command: 'npx',
args: ['rollup', '-c', 'rollup.config.js', '--watch'],
env: {
PUTER_JS_URL: ({ global_config: config }) => config.origin + '/sdk/puter.dev.js',
}
},
{
name: 'phoenix:rollup-watch',
directory: 'packages/phoenix',
command: 'npx',
args: ['rollup', '-c', 'rollup.config.js', '--watch'],
env: {
PUTER_JS_URL: ({ global_config: config }) => config.origin + '/sdk/puter.dev.js',
}
},
],
});
const ServeStaticFilesService = require("./services/ServceStaticFilesService");
services.registerService('__serve-puterjs', ServeStaticFilesService, {
directories: [
{
prefix: '/sdk',
path: path_.resolve(__dirname, '../../../packages/puter-js/dist'),
},
{
prefix: '/builtin/terminal',
path: path_.resolve(__dirname, '../../../packages/terminal/dist'),
},
{
prefix: '/builtin/phoenix',
path: path_.resolve(__dirname, '../../../packages/phoenix/dist'),
},
],
});
}
}
module.exports = SelfhostedModule;
+1 -1
View File
@@ -109,7 +109,7 @@ class Sequence {
async run (values) {
// Initialize scope
values = values || this.thisArg?.values || {};
Object.assign(this.scope_, values);
Object.assign(this.scope_, values); // TODO: can this be __proto__?
// Run sequence
for ( ; this.i < this.steps.length ; this.i++ ) {
+12 -1
View File
@@ -53,6 +53,11 @@ config.max_subdomains_per_user = 2000;
config.storage_capacity = 1*1024*1024*1024;
config.static_hosting_domain = '-static.puter.local';
// Storage limiting is set to false by default
// Storage available on the mountpoint/drive puter is running is the storage available
config.is_storage_limited = false;
config.available_device_storage = null;
config.thumb_width = 80;
config.thumb_height = 80;
config.app_max_icon_size = 5*1024*1024;
@@ -92,6 +97,10 @@ if (config.server_id) {
config.contact_email = 'hey@' + config.domain;
// TODO: default value will be changed to false in a future release;
// details to follow in a future announcement.
config.legacy_token_migrate = true;
module.exports = config;
// NEW_CONFIG_LOADING
@@ -100,7 +109,9 @@ const computed_defaults = {
pub_port: config => config.http_port,
origin: config => config.protocol + '://' + config.domain +
(config.pub_port !== 80 && config.pub_port !== 443 ? ':' + config.pub_port : ''),
api_base_url: config => config.protocol + '://api.' + config.domain +
api_base_url: config => config.experimental_no_subdomain
? config.origin
: config.protocol + '://api.' + config.domain +
(config.pub_port !== 80 && config.pub_port !== 443 ? ':' + config.pub_port : ''),
social_card: config => `${config.origin}/assets/img/screenshot.png`,
};
@@ -387,21 +387,9 @@ module.exports = class FSNodeContext {
* @deprecated sharing will use user-to-user permissions
*/
async fetchShares (force) {
if ( this.entry.permissions && ! force ) return;
const db = this.services.get('database').get(DB_READ, 'filesystem');
let shares = await db.read(
`SELECT share.id as share_id, user.* FROM share
INNER JOIN user ON share.recipient_user_id = user.id
WHERE share.fsentry_id = ?`,
[this.entry.id]
);
const shares_tidy = [];
for ( const share of shares ) {
shares_tidy.push({uid: share.share_id, username: share.username, email: share.email});
}
this.entry.permissions = shares_tidy;
// NOOP: this was for legacy sharing functionality;
// this is being re-implemented with permissions
return;
}
/**
@@ -34,8 +34,10 @@ const APIError = require('../api/APIError.js');
const { LLMkdir } = require('./ll_operations/ll_mkdir.js');
const { LLCWrite, LLOWrite } = require('./ll_operations/ll_write.js');
const { LLCopy } = require('./ll_operations/ll_copy.js');
const { PermissionUtil, PermissionRewriter } = require('../services/auth/PermissionService.js');
const { PermissionUtil, PermissionRewriter, PermissionImplicator } = require('../services/auth/PermissionService.js');
const { DB_WRITE } = require("../services/database/consts");
const { UserActorType } = require('../services/auth/Actor');
const { get_user } = require('../helpers');
class FilesystemService extends AdvancedBase {
static MODULES = {
@@ -131,6 +133,39 @@ class FilesystemService extends AdvancedBase {
return `fs:${uid}:${rest.join(':')}`;
},
}));
svc_permission.register_implicator(PermissionImplicator.create({
matcher: permission => {
return permission.startsWith('fs:');
},
checker: async (actor, permission) => {
debugger;
if ( !(actor.type instanceof UserActorType) ) {
return undefined;
}
const [_, uid] = PermissionUtil.split(permission);
const node = await this.node(new NodeUIDSelector(uid));
if ( ! await node.exists() ) {
return undefined;
}
const owner_id = await node.get('user_id');
// These conditions should never happen
if ( ! owner_id || ! actor.type.user.id ) {
throw new Error(
'something unexpected happened'
);
}
if ( owner_id === actor.type.user.id ) {
return {};
}
return undefined;
},
}));
}
/**
@@ -23,6 +23,7 @@ const { NodePathSelector, RootNodeSelector } = require("../node/selectors");
const { HLFilesystemOperation } = require("./definitions");
const { MkTree } = require("./hl_mkdir");
const { HLRemove } = require("./hl_remove");
const config = require("../../config");
class HLCopy extends HLFilesystemOperation {
static DESCRIPTION = `
@@ -141,7 +142,7 @@ class HLCopy extends HLFilesystemOperation {
let deset_usage = await sizeService.get_usage(dest_user.id);
const size = await source.fetchSize(values.user);
let capacity = (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage
let capacity = config.is_storage_limited ? (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage : config.available_device_storage
if(capacity - deset_usage - size < 0){
throw APIError.create('storage_limit_reached');
}
@@ -162,6 +163,7 @@ class HLCopy extends HLFilesystemOperation {
throw APIError('cannot_copy_item_into_itself');
}
let overwritten;
if ( await dest.exists() ) {
// condition: no overwrite behaviour specified
if ( ! values.overwrite && ! values.dedupe_name ) {
@@ -188,12 +190,13 @@ class HLCopy extends HLFilesystemOperation {
dest = await parent.getChild(target_name);
}
else if ( values.overwrite ) {
if ( ! await chkperm(dest.entry, options.user.id, 'rm') ) {
if ( ! await chkperm(dest.entry, values.user.id, 'rm') ) {
throw APIError.create('forbidden');
}
// TODO: This will be LLRemove
// TODO: what to do with parent_operation?
overwritten = await dest.getSafeEntry();
const hl_remove = new HLRemove();
await hl_remove.run({
target: dest,
@@ -212,7 +215,10 @@ class HLCopy extends HLFilesystemOperation {
await this.copied.awaitStableEntry();
const response = await this.copied.getSafeEntry({ thumbnail: true });
return response;
return {
copied : response,
overwritten
};
}
}
@@ -24,6 +24,7 @@ const { HLFilesystemOperation } = require("./definitions");
const { MkTree } = require("./hl_mkdir");
const { HLRemove } = require("./hl_remove");
const { TYPE_DIRECTORY } = require("../FSNodeContext");
const config = require("../../config");
class HLMove extends HLFilesystemOperation {
static MODULES = {
@@ -105,7 +106,7 @@ class HLMove extends HLFilesystemOperation {
dest_user = source_user;
await source.fetchSize();
const item_size = source.entry.size;
let capacity = (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage
let capacity = config.is_storage_limited ? (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage : config.available_device_storage;
if(capacity - await df(dest_user.id) - item_size < 0){
throw APIError.create('storage_limit_reached');
}
@@ -45,7 +45,7 @@ class HLStat extends HLFilesystemOperation {
const svc_acl = context.get('services').get('acl');
const actor = context.get('actor');
if ( ! await svc_acl.check(actor, subject, 'read') ) {
throw await svc_acl.get_safe_acl_error(actor, subject.entry, 'read');
throw await svc_acl.get_safe_acl_error(actor, subject, 'read');
}
// check permission
@@ -61,8 +61,8 @@ class WriteCommonTrait {
const { file, user } = this.values;
const usage = await sizeService.get_usage(user.id);
let capacity = user.free_storage == undefined
? config.storage_capacity : user.free_storage;
let capacity = config.is_storage_limited ? user.free_storage == undefined
? config.storage_capacity : user.free_storage : config.available_device_storage;
if( capacity - usage - file.size < 0 ) {
throw APIError.create('storage_limit_reached');
}
+9 -20
View File
@@ -1128,6 +1128,7 @@ async function deleteUser(user_id){
}
function subdomain(req){
if ( config.experimental_no_subdomain ) return 'api';
return req.hostname.slice(0, -1 * (config.domain.length + 1));
}
@@ -1154,34 +1155,22 @@ async function jwt_auth(req){
token = token.replace('Bearer ', '')
try{
const jwt = require('jsonwebtoken');
const decoded = jwt.verify(token, config.jwt_secret)
const svc_auth = Context.get('services').get('auth');
const actor = await svc_auth.authenticate_from_token(token);
if ( decoded.type ) {
// This is usually not the correct way to throw an APIError;
// this is a workaround for the existing error handling in auth,
// which is well tested, stable, and legacy (no sense in refactoring)
if ( ! actor.type?.constructor?.name === 'UserActorType' ) {
throw({
message: APIError.create('token_unsupported')
.serialize(),
});
}
/** @type BaseDatabaseAccessService */
const db = services.get('database').get(DB_READ, 'filesystem');
// in the vast majority of cases looking up a user should succeed unless the request is invalid (rare case),
// that's why we first hit up the read replica and if not successful we try the master DB
let user = await db.requireRead('SELECT * FROM `user` WHERE `uuid` = ? LIMIT 1', [decoded.uuid]);
// unsuccessful
if(!user[0])
throw('');
// successful
else {
return {user: user[0], token: token};
}
return {
user: actor.type.user,
token: token,
};
}catch(e){
console.log('ERROR', e);
throw(e.message);
}
}
+11 -20
View File
@@ -17,35 +17,26 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
"use strict"
const APIError = require('../api/APIError');
const {jwt_auth} = require('../helpers');
const { UserActorType } = require('../services/auth/Actor');
const { DB_WRITE } = require('../services/database/consts');
const { Context } = require('../util/context');
const auth2 = require('./auth2');
const auth = async (req, res, next)=>{
let auth2_ok = false;
try{
let auth_res = await jwt_auth(req);
// Delegate to new middleware
await auth2(req, res, () => { auth2_ok = true; });
if ( ! auth2_ok ) return;
// is account suspended?
if(auth_res.user.suspended)
return res.status(401).send({error: 'Account suspended'});
// successful auth
req.user = auth_res.user;
req.token = auth_res.token;
// let's add it to the context too
try {
const x = Context.get();
x.set('user', req.user);
} catch (e) {
console.error(e);
// Everything using the old reference to the auth middleware
// should only allow session tokens
if ( ! (req.actor.type instanceof UserActorType) ) {
throw APIError.create('forbidden');
}
// record as daily active users
const db = req.services.get('database').get(DB_WRITE, 'auth');
db.write('UPDATE `user` SET `last_activity_ts` = now() WHERE id=? LIMIT 1', [req.user.id]);
// go to next
next();
}
// auth failed
+38
View File
@@ -18,8 +18,24 @@
*/
const APIError = require("../api/APIError");
const config = require("../config");
const { UserActorType } = require("../services/auth/Actor");
const { LegacyTokenError } = require("../services/auth/AuthService");
const { Context } = require("../util/context");
// The "/whoami" endpoint is a special case where we want to allow
// a legacy token to be used for authentication. The "/whoami"
// endpoint will then return a new token for further requests.
//
const is_whoami = (req) => {
if ( ! config.legacy_token_migrate ) return;
if ( req.path !== '/whoami' ) return;
// const subdomain = req.subdomains[res.subdomains.length - 1];
// if ( subdomain !== 'api' ) return;
return true;
}
// TODO: Allow auth middleware to be used without requiring
// authentication. This will allow us to use the auth middleware
// in endpoints that do not require authentication, but can
@@ -47,8 +63,10 @@ const auth2 = async (req, res, next) => {
if(!token) {
APIError.create('token_missing').write(res);
return;
} else if (typeof token !== 'string') {
APIError.create('token_auth_failed').write(res);
return;
} else {
token = token.replace('Bearer ', '')
}
@@ -70,6 +88,26 @@ const auth2 = async (req, res, next) => {
e.write(res);
return;
}
if ( e instanceof LegacyTokenError && is_whoami(req) ) {
const new_info = await svc_auth.check_session(token, {
req,
from_upgrade: true,
})
context.set('actor', new_info.actor);
context.set('user', new_info.user);
req.new_token = new_info.token;
req.token = new_info.token;
req.user = new_info.user;
req.actor = new_info.actor;
res.cookie(config.cookie_name, new_info.token, {
sameSite: 'none',
secure: true,
httpOnly: true,
});
next();
return;
}
const re = APIError.create('token_auth_failed');
re.write(res);
return;
@@ -187,7 +187,10 @@ class AppES extends BaseES {
const subdomain = await entity.get('subdomain');
const user = Context.get('user');
let subdomain_res = await this.db.write(
`INSERT IGNORE INTO subdomains
`INSERT ${this.db.case({
mysql: 'IGNORE',
sqlite: 'OR IGNORE',
})} INTO subdomains
(subdomain, user_id, root_dir_id, uuid) VALUES
( ?, ?, ?, ?)`,
[
@@ -94,7 +94,7 @@ class SQLES extends BaseES {
}
const values = [];
if ( predicate ) values.push(...predicate.values);
if ( predicate ) values.push(...(predicate.values || []));
if ( this.debug ) {
this.log.info('-> SQL STMT', { stmt, values });
@@ -219,7 +219,7 @@ class SQLES extends BaseES {
console.log('SQL STMT', stmt);
console.log('SQL VALS', execute_vals);
const res = await db.write(
const res = await this.db.write(
stmt, execute_vals
);
+1
View File
@@ -51,6 +51,7 @@ module.exports = {
maxlen: 7000,
},
maximize_on_start: 'flag',
background: 'flag',
subdomain: {
type: 'string',
transient: true,
+2
View File
@@ -296,6 +296,8 @@ router.all('*', async function(req, res, next) {
const APP_ORIGIN = config.origin;
const API_ORIGIN = config.api_base_url;
return res.send(generate_puter_page_html({
env: config.env,
app_origin: APP_ORIGIN,
api_origin: API_ORIGIN,
+2
View File
@@ -72,6 +72,7 @@ router.get('/apps', auth, express.json({limit: '50mb'}), async (req, res, next)=
icon: apps_res[i].icon,
index_url: apps_res[i].index_url,
godmode: apps_res[i].godmode,
background: apps_res[i].background,
maximize_on_start: apps_res[i].maximize_on_start,
filetype_associations: filetype_associations,
...stats,
@@ -111,6 +112,7 @@ router.get('/apps/:name', auth, express.json({limit: '50mb'}), async (req, res,
title: app.title,
icon: app.icon,
godmode: app.godmode,
background: app.background,
maximize_on_start: app.maximize_on_start,
index_url: app.index_url,
};
@@ -0,0 +1,43 @@
const eggspress = require("../../api/eggspress");
const { deleteUser, invalidate_cached_user } = require("../../helpers");
const config = require("../../config");
module.exports = eggspress("/delete-own-user", {
subdomain: "api",
auth: true,
allowedMethods: ["POST"],
}, async (req, res, next) => {
const bcrypt = require('bcrypt');
const validate_request = async () => {
const user = req.user;
// `user` should always have a value, but this is checked
// any way in case the auth middleware is broken.
if ( ! user ) return false;
// temporary users don't require password verification
if ( ! user.email && ! user.password ) {
return true;
}
if ( ! req.body.password ) return false;
if ( ! user || ! user.password ) return false;
if ( ! await bcrypt.compare(req.body.password, req.user.password) ) {
return false;
}
return true;
}
if ( ! await validate_request() ) {
return res.status(400).send({ success: false });
}
res.clearCookie(config.cookie_name);
await deleteUser(req.user.id);
invalidate_cached_user(req.user);
return res.send({ success: true });
});
@@ -0,0 +1,30 @@
const APIError = require("../../api/APIError");
const eggspress = require("../../api/eggspress");
const { UserActorType } = require("../../services/auth/Actor");
const { Context } = require("../../util/context");
module.exports = eggspress('/auth/grant-user-user', {
subdomain: 'api',
auth2: true,
allowedMethods: ['POST'],
}, async (req, res, next) => {
const x = Context.get();
const svc_permission = x.get('services').get('permission');
// Only users can grant user-user permissions
const actor = Context.get('actor');
if ( ! (actor.type instanceof UserActorType) ) {
throw APIError.create('forbidden');
}
if ( ! req.body.target_username ) {
throw APIError.create('field_missing', null, { key: 'target_username' });
}
await svc_permission.grant_user_user_permission(
actor, req.body.target_username, req.body.permission,
req.body.extra || {}, req.body.meta || {}
);
res.json({});
});
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const eggspress = require("../../api/eggspress");
const { get_app } = require("../../helpers");
const { get_app, get_user } = require("../../helpers");
const { UserActorType } = require("../../services/auth/Actor");
const { DB_READ } = require("../../services/database/consts");
const { Context } = require("../../util/context");
@@ -38,29 +38,73 @@ module.exports = eggspress('/auth/list-permissions', {
const db = x.get('services').get('database').get(DB_READ, 'permissions');
const permissions = [];
const permissions = {};
const rows = await db.read(
'SELECT * FROM `user_to_app_permissions` WHERE user_id=?',
[ actor.type.user.id ]
);
{
permissions.myself_to_app = [];
for ( const row of rows ) {
const app = await get_app({ id: row.app_id });
const rows = await db.read(
'SELECT * FROM `user_to_app_permissions` WHERE user_id=?',
[ actor.type.user.id ]
);
delete app.id;
delete app.approved_for_listing;
delete app.approved_for_opening_items;
delete app.godmode;
delete app.owner_user_id;
for ( const row of rows ) {
const app = await get_app({ id: row.app_id });
const permission = {
app,
permission: row.permission,
extra: row.extra
};
delete app.id;
delete app.approved_for_listing;
delete app.approved_for_opening_items;
delete app.godmode;
delete app.owner_user_id;
permissions.push(permission);
const permission = {
app,
permission: row.permission,
extra: row.extra
};
permissions.myself_to_app.push(permission);
}
}
{
permissions.myself_to_user = [];
const rows = await db.read(
'SELECT * FROM `user_to_user_permissions` WHERE issuer_user_id=?',
[ actor.type.user.id ]
);
for ( const row of rows ) {
const user = await get_user({ id: row.holder_user_id });
const permission = {
user: user.username,
permission: row.permission,
extra: row.extra
};
permissions.myself_to_user.push(permission);
}
}
{
permissions.user_to_myself = [];
const rows = await db.read(
'SELECT * FROM `user_to_user_permissions` WHERE holder_user_id=?',
[ actor.type.user.id ]
);
for ( const row of rows ) {
const user = await get_user({ id: row.issuer_user_id });
const permission = {
user: user.username,
permission: row.permission,
extra: row.extra
};
permissions.user_to_myself.push(permission);
}
}
res.json(permissions);
@@ -0,0 +1,23 @@
const eggspress = require("../../api/eggspress");
const { UserActorType } = require("../../services/auth/Actor");
const { Context } = require("../../util/context");
module.exports = eggspress('/auth/list-sessions', {
subdomain: 'api',
auth2: true,
allowedMethods: ['GET'],
}, async (req, res, next) => {
const x = Context.get();
const svc_auth = x.get('services').get('auth');
// Only users can list their own sessions
// apps, access tokens, etc should NEVER access this
const actor = x.get('actor');
if ( ! (actor.type instanceof UserActorType) ) {
throw APIError.create('forbidden');
}
const sessions = await svc_auth.list_sessions(actor);
res.json(sessions);
});
@@ -0,0 +1,33 @@
const APIError = require("../../api/APIError");
const eggspress = require("../../api/eggspress");
const { UserActorType } = require("../../services/auth/Actor");
const { Context } = require("../../util/context");
module.exports = eggspress('/auth/revoke-session', {
subdomain: 'api',
auth2: true,
allowedMethods: ['POST'],
}, async (req, res, next) => {
const x = Context.get();
const svc_auth = x.get('services').get('auth');
// Only users can list their own sessions
// apps, access tokens, etc should NEVER access this
const actor = x.get('actor');
if ( ! (actor.type instanceof UserActorType) ) {
throw APIError.create('forbidden');
}
// Ensure valid UUID
if ( ! req.body.uuid || typeof req.body.uuid !== 'string' ) {
throw APIError.create('field_invalid', null, {
key: 'uuid',
expected: 'string'
});
}
const sessions = await svc_auth.revoke_session(
actor, req.body.uuid);
res.json({ sessions });
});
@@ -0,0 +1,31 @@
const APIError = require("../../api/APIError");
const eggspress = require("../../api/eggspress");
const { UserActorType } = require("../../services/auth/Actor");
const { Context } = require("../../util/context");
module.exports = eggspress('/auth/revoke-user-user', {
subdomain: 'api',
auth2: true,
allowedMethods: ['POST'],
}, async (req, res, next) => {
const x = Context.get();
const svc_permission = x.get('services').get('permission');
// Only users can grant user-user permissions
const actor = Context.get('actor');
if ( ! (actor.type instanceof UserActorType) ) {
throw APIError.create('forbidden');
}
if ( ! req.body.target_username ) {
throw APIError.create('field_missing', null, { key: 'target_username' });
}
await svc_permission.revoke_user_user_permission(
actor, req.body.target_username, req.body.permission,
req.body.meta || {}
);
res.json({});
});
+36 -14
View File
@@ -23,6 +23,11 @@ const eggspress = require('../api/eggspress.js');
const APIError = require('../api/APIError.js');
const { DB_READ, DB_WRITE } = require('../services/database/consts.js');
const config = require('../config.js');
const jwt = require('jsonwebtoken');
const { invalidate_cached_user_by_id } = require('../helpers.js');
const CHANGE_EMAIL_START = eggspress('/change_email/start', {
subdomain: 'api',
auth: true,
@@ -47,7 +52,6 @@ const CHANGE_EMAIL_START = eggspress('/change_email/start', {
}
// check if email is already in use
const svc_mysql = req.services.get('mysql');
const db = req.services.get('database').get(DB_WRITE, 'auth');
const rows = await db.read(
'SELECT COUNT(*) AS `count` FROM `user` WHERE `email` = ?',
@@ -59,32 +63,42 @@ const CHANGE_EMAIL_START = eggspress('/change_email/start', {
// generate confirmation token
const token = crypto.randomBytes(4).toString('hex');
const jwt_token = jwt.sign({
user_id: user.id,
token,
}, config.jwt_secret, { expiresIn: '24h' });
// send confirmation email
const svc_email = req.services.get('email');
await svc_email.send_email({ email: new_email }, 'email_change_request', {
confirm_url: `${config.origin}/change_email/confirm?token=${jwt_token}`,
username: user.username,
});
// update user
await db.write(
'UPDATE `user` SET `unconfirmed_change_email` = ?, `change_email_confirm_token` = ? WHERE `id` = ?',
[new_email, token, user.id]
);
res.send({ success: true });
});
const CHANGE_EMAIL_CONFIRM = eggspress('/change_email/confirm', {
subdomain: 'api',
auth: true,
verified: true,
allowedMethods: ['POST'],
allowedMethods: ['GET'],
}, async (req, res, next) => {
const user = req.user;
const token = req.body.token;
const jwt_token = req.query.token;
if ( ! token ) {
if ( ! jwt_token ) {
throw APIError.create('field_missing', null, { key: 'token' });
}
const svc_mysql = req.services.get('mysql');
const dbrr = svc_mysql.get(DB_MODE_READ, 'change-email-confirm');
const [rows] = await dbrr.promise().query(
const { token, user_id } = jwt.verify(jwt_token, config.jwt_secret);
const db = req.services.get('database').get(DB_WRITE, 'auth');
const rows = await db.read(
'SELECT `unconfirmed_change_email` FROM `user` WHERE `id` = ? AND `change_email_confirm_token` = ?',
[user.id, token]
[user_id, token]
);
if ( rows.length === 0 ) {
throw APIError.create('token_invalid');
@@ -92,11 +106,19 @@ const CHANGE_EMAIL_CONFIRM = eggspress('/change_email/confirm', {
const new_email = rows[0].unconfirmed_change_email;
const db = req.services.get('database').get(DB_WRITE, 'auth');
await db.write(
'UPDATE `user` SET `email` = ?, `unconfirmed_change_email` = NULL, `change_email_confirm_token` = NULL WHERE `id` = ?',
[new_email, user.id]
[new_email, user_id]
);
invalidate_cached_user_by_id(user_id);
let socketio = require('../socketio.js').getio();
if(socketio){
socketio.to(user_id).emit('user.email_changed', {})
}
const h = `<p style="text-align:center; color:green;">Your email has been successfully confirmed.</p>`;
return res.send(h);
});
module.exports = app => {
@@ -59,7 +59,11 @@ module.exports = eggspress('/change_username', {
// Has the user already changed their username twice this month?
const rows = await db.read(
'SELECT COUNT(*) AS `count` FROM `user_update_audit` ' +
'WHERE `user_id`=? AND `reason`=? AND `created_at` > DATE_SUB(NOW(), INTERVAL 1 MONTH)',
'WHERE `user_id`=? AND `reason`=? AND ' +
db.case({
mysql: '`created_at` > DATE_SUB(NOW(), INTERVAL 1 MONTH)',
sqlite: "`created_at` > datetime('now', '-1 month')",
}),
[ req.user.id, 'change_username' ]
);
+6 -5
View File
@@ -21,8 +21,9 @@ const express = require('express');
const router = express.Router();
const auth = require('../middleware/auth.js');
const config = require('../config');
const { DB_WRITE } = require('../services/database/consts.js');
// -----------------------------------------------------------------------//
// -----------------------------------------------------------------------//
// POST /delete-site
// -----------------------------------------------------------------------//
router.post('/delete-site', auth, express.json(), async (req, res, next)=>{
@@ -40,12 +41,12 @@ router.post('/delete-site', auth, express.json(), async (req, res, next)=>{
// modules
const {} = require('../helpers');
const db = require('../db/mysql.js')
const db = req.services.get('database').get(DB_WRITE, 'subdomains:legacy');
await db.promise().execute(
`DELETE FROM subdomains WHERE user_id = ? AND uuid = ?`,
await db.write(
`DELETE FROM subdomains WHERE user_id = ? AND uuid = ?`,
[req.user.id, req.body.site_uuid]
);
);
res.send({});
})
+8 -2
View File
@@ -22,6 +22,8 @@ const config = require('../config.js');
const router = new express.Router();
const auth = require('../middleware/auth.js');
// TODO: Why is this both a POST and a GET?
// -----------------------------------------------------------------------//
// POST /df
// -----------------------------------------------------------------------//
@@ -35,11 +37,13 @@ router.post('/df', auth, express.json(), async (req, response, next)=>{
return response.status(400).send({code: 'account_is_not_verified', message: 'Account is not verified'});
const {df} = require('../helpers');
const svc_hostDiskUsage = req.services.get('host-disk-usage', { optional: true });
try{
// auth
response.send({
used: parseInt(await df(req.user.id)),
capacity: (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage,
capacity: config.is_storage_limited ? (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage : config.available_device_storage,
...(svc_hostDiskUsage ? svc_hostDiskUsage.get_extra() : {}),
});
}catch(e){
console.log(e)
@@ -60,11 +64,13 @@ router.get('/df', auth, express.json(), async (req, response, next)=>{
return response.status(400).send({code: 'account_is_not_verified', message: 'Account is not verified'});
const {df} = require('../helpers');
const svc_hostDiskUsage = req.services.get('host-disk-usage', { optional: true });
try{
// auth
response.send({
used: parseInt(await df(req.user.id)),
capacity: (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage,
capacity: config.is_storage_limited ? (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage : config.available_device_storage,
...(svc_hostDiskUsage ? svc_hostDiskUsage.get_extra() : {}),
});
}catch(e){
console.log(e)
+19 -14
View File
@@ -19,9 +19,9 @@
"use strict"
const express = require('express');
const router = new express.Router();
const config = require('../config');
const {validate_signature_auth, get_url_from_req, get_descendants, id2path, get_user, sign_file} = require('../helpers');
const { DB_WRITE } = require('../services/database/consts');
const { Context } = require('../util/context');
// -----------------------------------------------------------------------//
// GET /file
@@ -40,6 +40,10 @@ router.get('/file', async (req, res, next)=>{
return res.status(403).send(e);
}
const log = req.services.get('log-service').create('/file');
const errors = req.services.get('error-service').create(log);
// modules
const db = req.services.get('database').get(DB_WRITE, 'filesystem');
const mime = require('mime-types')
@@ -113,13 +117,17 @@ router.get('/file', async (req, res, next)=>{
// stream data from S3
try{
let stream = await storage.create_read_stream({
key: fsentry[0].uuid,
let stream = await storage.create_read_stream(fsentry[0].uuid, {
bucket: fsentry[0].bucket,
bucket_region: fsentry[0].bucket_region,
});
return stream.pipe(res);
}catch(e){
errors.report('read from storage', {
source: e,
trace: true,
alarm: true,
});
return res.type('application/json').status(500).send({message: 'There was an internal problem reading the file.'});
}
}
@@ -167,25 +175,22 @@ router.get('/file', async (req, res, next)=>{
// HTTP Status 206 for Partial Content
res.writeHead(206, headers);
// init S3
const s3 = new AWS.S3({
accessKeyId: config.s3_access_key,
secretAccessKey: config.s3_secret_key,
region: fsentry[0].bucket_region,
});
try{
let stream = await storage.create_read_stream({
key: fsentry[0].uuid,
const storage = Context.get('storage');
let stream = await storage.create_read_stream(fsentry[0].uuid, {
bucket: fsentry[0].bucket,
bucket_region: fsentry[0].bucket_region,
});
return stream.pipe(res);
}catch(e){
console.log(e)
errors.report('read from storage', {
source: e,
trace: true,
alarm: true,
});
return res.type('application/json').status(500).send({message: 'There was an internal problem reading the file.'});
}
}
})
module.exports = router
module.exports = router
@@ -101,6 +101,7 @@ router.get('/get-launch-apps', auth, express.json(), async (req, res, next)=>{
'plushie-connect',
'hex-frvr',
'spider-solitaire',
'test',
]
// Prepare each app for returning to user by only returning the necessary fields
@@ -56,32 +56,6 @@ router.post('/setItem', auth, express.json(), async (req, res, next)=>{
else if(req.body.app && !await app_exists({uid: req.body.app}))
return res.status(400).send('`app` does not exist');
// hash key for faster search in DB
const murmurhash = require('murmurhash')
const key_hash = murmurhash.v3(req.body.key);
// database connection
const db = require('../../db/mysql.js');
// insert into DB (in case the row isn't migrated yet)
await db.promise().execute(
`INSERT INTO kv
(user_id, app, kkey_hash, kkey, value)
VALUES
(?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
value = ?`,
[
req.user.id,
// 0 is reserved for global system variables
req.body.app ?? 'global',
key_hash,
String(req.body.key),
String(req.body.value),
String(req.body.value),
]
)
// insert into KV 1
const actor = req.body.app
? await Actor.create(AppUnderUserActorType, {
+2 -1
View File
@@ -89,7 +89,8 @@ router.post('/login', express.json(), body_parser_error_handler, async (req, res
return res.status(400).send('Incorrect password.')
// check password
if(await bcrypt.compare(req.body.password, user.password)){
const token = await jwt.sign({uuid: user.uuid}, config.jwt_secret)
const svc_auth = req.services.get('auth');
const { token } = await svc_auth.create_session_token(user, { req });
//set cookie
// res.cookie(config.cookie_name, token);
res.cookie(config.cookie_name, token, {
+18 -5
View File
@@ -52,6 +52,7 @@ module.exports = eggspress(['/signup'], {
const validator = require('validator')
let uuid_user;
const svc_auth = Context.get('services').get('auth');
const svc_authAudit = Context.get('services').get('auth-audit');
svc_authAudit.record({
requester: Context.get('requester'),
@@ -67,9 +68,16 @@ module.exports = eggspress(['/signup'], {
// check if user is already logged in
if ( req.body.is_temp && req.cookies[config.cookie_name] ) {
const token = req.cookies[config.cookie_name];
const decoded = await jwt.verify(token, config.jwt_secret);
const user = await get_user({ uuid: decoded.uuid });
const { user, token } = await svc_auth.check_session(
req.cookies[config.cookie_name]
);
res.cookie(config.cookie_name, token, {
sameSite: 'none',
secure: true,
httpOnly: true,
});
// const decoded = await jwt.verify(token, config.jwt_secret);
// const user = await get_user({ uuid: decoded.uuid });
if ( user ) {
return res.send({
token: token,
@@ -233,17 +241,22 @@ module.exports = eggspress(['/signup'], {
db.write('UPDATE `user` SET `last_activity_ts` = now() WHERE id=? LIMIT 1', [pseudo_user.id]);
invalidate_cached_user_by_id(pseudo_user.id);
}
// create token for login
const token = await jwt.sign({uuid: user_uuid}, config.jwt_secret);
// user id
// todo if pseudo user, assign directly no need to do another DB lookup
const user_id = (pseudo_user === undefined) ? insert_res.insertId : pseudo_user.id;
const [user] = await db.read(
'SELECT * FROM `user` WHERE `id` = ? LIMIT 1',
[user_id]
);
// create token for login
const { token } = await svc_auth.create_session_token(user, {
req,
});
// jwt.sign({uuid: user_uuid}, config.jwt_secret);
//-------------------------------------------------------------
// email confirmation
//-------------------------------------------------------------
+15 -2
View File
@@ -54,6 +54,7 @@ const WHOAMI_GET = eggspress('/whoami', {
is_temp: (req.user.password === null && req.user.email === null),
taskbar_items: await get_taskbar_items(req.user),
referral_code: req.user.referral_code,
...(req.new_token ? { token: req.token } : {})
};
if ( ! is_user ) {
@@ -65,6 +66,7 @@ const WHOAMI_GET = eggspress('/whoami', {
delete details.desktop_bg_color;
delete details.desktop_bg_fit;
delete details.taskbar_items;
delete details.token;
}
res.send(details);
@@ -76,8 +78,19 @@ const WHOAMI_GET = eggspress('/whoami', {
const WHOAMI_POST = new express.Router();
WHOAMI_POST.post('/whoami', auth, fs, express.json(), async (req, response, next)=>{
// check subdomain
if(require('../helpers').subdomain(req) !== 'api')
next();
if(require('../helpers').subdomain(req) !== 'api') {
return;
}
const actor = Context.get('actor');
if ( ! actor ) {
throw Error('actor not found in context');
}
const is_user = actor.type instanceof UserActorType;
if ( ! is_user ) {
throw Error('actor is not a user');
}
let desktop_items = [];
@@ -507,7 +507,6 @@ module.exports = eggspress('/writeFile', {
else{
// modules
const {uuid2fsentry, id2path} = require('../helpers')
const write = require('../filesystem/operations/write.js');
const _path = require('path');
// Check if files were uploaded
@@ -0,0 +1,87 @@
const { BaseService } = require("../../exports");
const { surrounding_box } = require("../fun/dev-console-ui-utils");
class ComplainAboutVersionsService extends BaseService {
static DESCRIPTION = `
This service doesn't mandate a specific version of node.js,
but it will complain (create a sticky notification in the
dev console) if you're using something that's past EOL.
This is mostly just for fun, because it feels cool when the
system calls people out for using old versions of node.
That said, maybe one day we'll come across some nuanced error
that only happens an a recently EOL'd node version.
`;
static MODULES = {
axios: require('axios'),
}
async _init () {
const eol_data = await this.get_eol_data_();
const [major] = process.versions.node.split('.');
const current_version_data = eol_data.find(
({ cycle }) => cycle === major
);
if ( ! current_version_data ) {
this.log.warn(
`failed to check ${current_version} in the EOL database`
);
return;
}
const eol_date = new Date(current_version_data.eol);
const cur_date_obj = new Date();
if ( cur_date_obj < eol_date ) {
this.log.info('node.js version looks good');
return;
}
let timeago = (() => {
let years = cur_date_obj.getFullYear() - eol_date.getFullYear();
let months = cur_date_obj.getMonth() - eol_date.getMonth();
let days = cur_date_obj.getDate() - eol_date.getDate();
let str = '';
while ( years > 0 ) {
years -= 1;
months += 12;
}
if ( months > 0 ) {
str += `at least ${months} month${months > 1 ? 's' : ''}`;
} else {
str += `a few days`;
}
return str;
})();
const widget_lines = [];
widget_lines.push(
`Node.js version ${major} is past EOL by ${timeago};`,
`Everything should work, but you should still upgrade.`,
);
surrounding_box('31;1', widget_lines);
const svc_devConsole = this.services.get('dev-console');
svc_devConsole.add_widget(() => widget_lines);
}
async get_eol_data_ () {
const require = this.require;
const axios = require('axios');
const url = 'https://endoflife.date/api/nodejs.json'
let data;
try {
({ data } = await axios.get(url));
return data;
} catch (e) {
this.log.error(e);
return [];
}
}
}
module.exports = ComplainAboutVersionsService;
@@ -1,10 +1,11 @@
const { surrounding_box } = require("../fun/dev-console-ui-utils");
const { get_user, generate_system_fsentries } = require("../helpers");
const { get_user, generate_system_fsentries, invalidate_cached_user } = require("../helpers");
const { Context } = require("../util/context");
const { asyncSafeSetInterval } = require("../util/promise");
const BaseService = require("./BaseService");
const { Actor, UserActorType } = require("./auth/Actor");
const { DB_WRITE } = require("./database/consts");
const DEFAULT_PASSWORD = 'changeme';
const USERNAME = 'default_user';
class DefaultUserService extends BaseService {
@@ -16,13 +17,17 @@ class DefaultUserService extends BaseService {
}
async ['__on_ready.webserver'] () {
// check if a user named `default-user` exists
let user = await get_user({ username: USERNAME });
let user = await get_user({ username: USERNAME, cached: false });
if ( ! user ) user = await this.create_default_user_();
// check if user named `default-user` is using default password
const require = this.require;
const tmp_password = await this.get_tmp_password_(user);
const bcrypt = require('bcrypt');
const is_default_password = await bcrypt.compare(DEFAULT_PASSWORD, user.password);
const is_default_password = await bcrypt.compare(
tmp_password,
user.password
);
if ( ! is_default_password ) return;
// show console widget
@@ -30,23 +35,26 @@ class DefaultUserService extends BaseService {
const lines = [
`Your default user has been created!`,
`\x1B[31;1musername:\x1B[0m ${USERNAME}`,
`\x1B[32;1mpassword:\x1B[0m ${DEFAULT_PASSWORD}`,
`\x1B[32;1mpassword:\x1B[0m ${tmp_password}`,
`(change the password to remove this message)`
];
surrounding_box('31;1', lines);
return lines;
};
this.start_poll_();
this.start_poll_({ tmp_password, user });
const svc_devConsole = this.services.get('dev-console');
svc_devConsole.add_widget(this.default_user_widget);
}
start_poll_ () {
start_poll_ ({ tmp_password, user }) {
const interval = 1000 * 3; // 3 seconds
const poll_interval = asyncSafeSetInterval(async () => {
const user = await get_user({ username: USERNAME });
const require = this.require;
const bcrypt = require('bcrypt');
const is_default_password = await bcrypt.compare(DEFAULT_PASSWORD, user.password);
const is_default_password = await bcrypt.compare(
tmp_password,
user.password
);
if ( ! is_default_password ) {
const svc_devConsole = this.services.get('dev-console');
svc_devConsole.remove_widget(this.default_user_widget);
@@ -56,25 +64,52 @@ class DefaultUserService extends BaseService {
}, interval);
}
async create_default_user_ () {
const require = this.require;
const bcrypt = require('bcrypt');
const db = this.services.get('database').get(DB_WRITE, 'default-user');
await db.write(
`
INSERT INTO user (uuid, username, password, free_storage)
VALUES (?, ?, ?, ?)
INSERT INTO user (uuid, username, free_storage)
VALUES (?, ?, ?)
`,
[
this.modules.uuidv4(),
USERNAME,
await bcrypt.hash(DEFAULT_PASSWORD, 8),
1024 * 1024 * 1024 * 10, // 10 GB
],
);
const user = await get_user({ username: USERNAME });
const tmp_password = await this.get_tmp_password_(user);
const bcrypt = require('bcrypt');
const password_hashed = await bcrypt.hash(tmp_password, 8);
await db.write(
`UPDATE user SET password = ? WHERE id = ?`,
[
password_hashed,
user.id,
],
);
user.password = password_hashed;
await generate_system_fsentries(user);
invalidate_cached_user(user);
await new Promise(rslv => setTimeout(rslv, 2000));
return user;
}
async get_tmp_password_ (user) {
const actor = await Actor.create(UserActorType, { user });
return await Context.get().sub({ actor }).arun(async () => {
const svc_driver = this.services.get('driver');
const driver_response = await svc_driver.call(
'puter-kvstore', 'get', { key: 'tmp_password' });
if ( driver_response.result ) return driver_response.result;
const tmp_password = require('crypto').randomBytes(4).toString('hex');
await svc_driver.call(
'puter-kvstore', 'set', {
key: 'tmp_password',
value: tmp_password });
return tmp_password;
});
}
}
module.exports = DefaultUserService;
@@ -179,6 +179,11 @@ class DevConsoleService extends BaseService {
generateSeparator(text) {
text = text || '[ Dev Console ]';
const totalWidth = process.stdout.columns;
if ( totalWidth <= text.length+1 ) {
return '═'.repeat(totalWidth < 0 ? 0 : totalWidth);
}
const paddingSize = (totalWidth - text.length) / 2;
// Construct the separator
@@ -0,0 +1,111 @@
const BaseService = require("./BaseService");
class ProxyLogger {
constructor (log) {
this.log = log;
}
attach (stream) {
let buffer = '';
stream.on('data', (chunk) => {
buffer += chunk.toString();
let lineEndIndex = buffer.indexOf('\n');
while (lineEndIndex !== -1) {
const line = buffer.substring(0, lineEndIndex);
this.log(line);
buffer = buffer.substring(lineEndIndex + 1);
lineEndIndex = buffer.indexOf('\n');
}
});
stream.on('end', () => {
if (buffer.length) {
this.log(buffer);
}
});
}
}
/**
* @description
* This service is used to run webpack watchers.
*/
class DevWatcherService extends BaseService {
static MODULES = {
path: require('path'),
spawn: require('child_process').spawn,
};
_construct () {
this.instances = [];
}
async _init (args) {
this.args = args;
process.on('exit', () => {
this.exit_all_();
})
}
// Oh geez we need to wait for the web server to initialize
// so that `config.origin` has the actual port in it if the
// port is set to `auto` - you have no idea how confusing
// this was to debug the first time, like Ahhhhhh!!
// but hey at least we have this convenient event listener.
async ['__on_ready.webserver'] () {
const { root, commands } = this.args;
for ( const entry of commands ) {
const { directory } = entry;
const fullpath = this.modules.path.join(
root, directory);
this.start_({ ...entry, fullpath });
}
}
log_ (name, isErr, line) {
let txt = `[${name}:`;
txt += isErr
? `\x1B[31;1merr\x1B[0m`
: `\x1B[32;1mout\x1B[0m`;
txt += '] ' + line;
this.log.info(txt);
}
async start_ ({ name, fullpath, command, args, env }) {
this.log.info(`Starting ${name} in ${fullpath}`);
const env_processed = { ...(env ?? {}) };
for ( const k in env_processed ) {
if ( typeof env_processed[k] !== 'function' ) continue;
env_processed[k] = env_processed[k]({
global_config: this.global_config
});
}
const proc = this.modules.spawn(command, args, {
shell: true,
env: {
...process.env,
...env_processed,
},
cwd: fullpath,
});
this.instances.push({
name, proc,
});
const out = new ProxyLogger((line) => this.log_(name, false, line));
out.attach(proc.stdout);
const err = new ProxyLogger((line) => this.log_(name, true, line));
err.attach(proc.stderr);
proc.on('exit', () => {
this.log.info(`[${name}:exit] Process exited (${proc.exitCode})`);
this.instances = this.instances.filter((inst) => inst.proc !== proc);
})
}
async exit_all_ () {
for ( const { proc } of this.instances ) {
proc.kill();
}
}
};
module.exports = DevWatcherService;
@@ -50,6 +50,19 @@ Exciting news! <a href="https://puter.com/app/{{app_name}}">{{app_title}}</a> is
<p>Best,<br />
The Puter Team
</p>
`,
},
'email_change_request': {
subject: '\u{1f4dd} Confirm your email change',
html: `
<p>Hi there,</p>
<p>
We received a request to link this email to the user "{{username}}" on Puter. If you made this request, please click the link below to confirm the change. If you did not make this request, please ignore this email.
</p>
<p>
<a href="{{confirm_url}}">Confirm email change</a>
</p>
`,
},
@@ -0,0 +1,110 @@
const { BaseService } = require("../../exports");
const { execSync } = require('child_process');
const config = require("../config");
class HostDiskUsageService extends BaseService {
static DESCRIPTION = `
This service is responsible for identifying the mountpoint/drive
on which the current process working directory is running, and then checking the
disk usage of that mountpoint/drive.
`;
async _init() {
const current_platform = process.platform;
// Setting the available space to a large number for unhandled platforms
var free_space = 1e+14;
if (current_platform == "darwin") {
const mountpoint = this.get_darwin_mountpoint(process.cwd());
free_space = this.get_disk_capacity_darwin(mountpoint);
} else if (current_platform == "linux") {
const mountpoint = this.get_linux_mountpint(process.cwd());
free_space = this.get_disk_capacity_linux(mountpoint);
} else if (current_platform == "win32") {
this.log.warn('HostDiskUsageService: Windows is not supported yet');
// TODO: Implement for windows systems
}
console.log('free_space:', free_space);
config.available_device_storage = free_space;
}
// TODO: TTL cache this value
get_host_usage () {
const current_platform = process.platform;
let disk_use = 0;
if (current_platform == "darwin") {
const mountpoint = this.get_darwin_mountpoint(process.cwd());
disk_use = this.get_disk_use_darwin(mountpoint);
} else if (current_platform == "linux") {
const mountpoint = this.get_linux_mountpint(process.cwd());
disk_use = this.get_disk_use_linux(mountpoint);
} else if (current_platform == "win32") {
this.log.warn('HostDiskUsageService: Windows is not supported yet');
// TODO: Implement for windows systems
}
return disk_use;
}
// Called by the /df endpoint
get_extra () {
return {
host_used: this.get_host_usage(),
};
}
// Get the mountpoint/drive of the current working directory in mac os
get_darwin_mountpoint(directory) {
return execSync(`df -P "${directory}" | awk 'NR==2 {print $6}'`, { encoding: 'utf-8' }).trim();
}
// Get the mountpoint/drive of the current working directory in linux
get_linux_mountpint(directory) {
return execSync(`df -P "${directory}" | awk 'NR==2 {print $6}'`, { encoding: 'utf-8' }).trim();
// TODO: Implement for linux systems
}
// Get the drive of the current working directory in windows
get_windows_drive(directory) {
// TODO: Implement for windows systems
}
// Get the free space on the mountpoint/drive in mac os
get_disk_capacity_darwin(mountpoint) {
const disk_info = execSync(`df -P "${mountpoint}" | awk 'NR==2 {print $2}'`, { encoding: 'utf-8' }).trim().split(' ');
return parseInt(disk_info) * 512;
}
// Get the free space on the mountpoint/drive in linux
get_disk_capacity_linux(mountpoint) {
const disk_info = execSync(`df -P "${mountpoint}" | awk 'NR==2 {print $2}'`, { encoding: 'utf-8' }).trim().split(' ');
return parseInt(disk_info) * 1024;
}
// Get the free space on the drive in windows
get_disk_capacity_windows(drive) {
// TODO: Implement for windows systems
}
// Get the free space on the mountpoint/drive in mac os
get_disk_use_darwin(mountpoint) {
const disk_info = execSync(`df -P "${mountpoint}" | awk 'NR==2 {print $4}'`, { encoding: 'utf-8' }).trim().split(' ');
return parseInt(disk_info) * 512;
}
// Get the free space on the mountpoint/drive in linux
get_disk_use_linux(mountpoint) {
const disk_info = execSync(`df -P "${mountpoint}" | awk 'NR==2 {print $4}'`, { encoding: 'utf-8' }).trim().split(' ');
return parseInt(disk_info) * 1024;
}
// Get the free space on the drive in windows
get_disk_use_windows(drive) {
// TODO: Implement for windows systems
}
}
module.exports = HostDiskUsageService;
@@ -22,7 +22,6 @@ class PuterAPIService extends BaseService {
async ['__on_install.routes'] () {
const { app } = this.services.get('web-server');
app.use(require('../routers/version'))
app.use(require('../routers/apps'))
app.use(require('../routers/query/app'))
app.use(require('../routers/change_username'))
@@ -30,10 +29,15 @@ class PuterAPIService extends BaseService {
app.use(require('../routers/auth/get-user-app-token'))
app.use(require('../routers/auth/grant-user-app'))
app.use(require('../routers/auth/revoke-user-app'))
app.use(require('../routers/auth/grant-user-user'));
app.use(require('../routers/auth/revoke-user-user'));
app.use(require('../routers/auth/list-permissions'))
app.use(require('../routers/auth/list-sessions'))
app.use(require('../routers/auth/revoke-session'))
app.use(require('../routers/auth/check-app'))
app.use(require('../routers/auth/app-uid-from-origin'))
app.use(require('../routers/auth/create-access-token'))
app.use(require('../routers/auth/delete-own-user'))
app.use(require('../routers/drivers/call'))
app.use(require('../routers/drivers/list-interfaces'))
app.use(require('../routers/drivers/usage'))
@@ -33,7 +33,7 @@ class PuterSiteService extends BaseService {
root_dir_id: this.config.devtest_directory,
};
}
const rows = await this.read(
const rows = await this.db.read(
`SELECT * FROM subdomains WHERE subdomain = ? LIMIT 1`,
[subdomain]
);
@@ -16,74 +16,26 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const { AdvancedBase } = require("puter-js-common");
const { NodeUIDSelector } = require("../filesystem/node/selectors");
const { get_user } = require("../helpers");
const { TeePromise } = require("../util/promise");
const { StreamBuffer } = require("../util/streamutil");
const BaseService = require("./BaseService");
class PuterVersionService extends AdvancedBase {
static MODULES = {
_path: require('path'),
fs: require('fs'),
_exec: require('child_process').execSync,
axios: require('axios'),
class PuterVersionService extends BaseService {
async _init () {
this.boot_time = Date.now();
}
constructor ({ services, config }) {
super();
this.fs = services.get('filesystem');
this.config = config;
this._init({ config });
this.ready_ = new TeePromise();
}
async _init ({ config }) {
// this.node = await this.fs.node(new NodeUIDSelector(config.puter_hosted_data.puter_versions));
// this.user = await get_user({ username: 'puter' });
// await this._poll_versions({ config });
// setInterval(async () => {
// await this._poll_versions({ config });
// }, 60 * 1000);
}
// not used anymore - this was for getting version numbers from a file hosted on puter
async _poll_versions ({ config }) {
const resp = await this.modules.axios.get(
config.puter_hosted_data.puter_versions
);
this.versions_ = resp.data.versions;
this.ready_.resolve();
async ['__on_install.routes'] () {
const { app } = this.services.get('web-server');
app.use(require('../routers/version'));
}
get_version () {
let git_version;
let deploy_timestamp;
if ( this.config.env === 'dev' ) {
// get commit hash from git
git_version = this.modules._exec('git describe --tags', {
cwd: this.modules._path.join(__dirname, '../../'),
encoding: 'utf8',
}).trim();
deploy_timestamp = Date.now();
} else {
// get git version from file
const path = this.modules._path.join(__dirname, '../../git_version');
git_version = this.modules.fs.readFileSync(path, 'utf8').trim();
deploy_timestamp = Number.parseInt((this.modules.fs.readFileSync(
this.modules._path.join(__dirname, '../../deploy_timestamp'),
'utf8'
)).trim());
}
const version = process.env.npm_package_version ||
require('../../package.json').version;
return {
version: git_version,
environment: this.config.env,
location: this.config.server_id,
deploy_timestamp,
version,
environment: this.global_config.env,
location: this.global_config.server_id,
deploy_timestamp: this.boot_time,
};
}
}
@@ -0,0 +1,17 @@
const BaseService = require("./BaseService");
class ServeStaticFilesService extends BaseService {
async _init (args) {
this.directories = args.directories;
}
async ['__on_install.routes'] () {
const { app } = this.services.get('web-server');
for ( const { prefix, path } of this.directories ) {
app.use(prefix, require('express').static(path));
}
}
}
module.exports = ServeStaticFilesService;
@@ -25,14 +25,14 @@ class ServeGUIService extends BaseService {
async ['__on_install.routes-gui'] () {
const { app } = this.services.get('web-server');
// is this a puter.site domain?
require('../routers/hosting/puter-site')(app);
// Router for all other cases
app.use(require('../routers/_default'))
// Static files
app.use(express.static(_path.join(__dirname, '../../public')))
// is this a puter.site domain?
require('../routers/hosting/puter-site')(app);
}
}
@@ -128,8 +128,8 @@ class WebServerService extends BaseService {
return lines;
};
{
const svc_devConsole = this.services.get('dev-console');
svc_devConsole.add_widget(this.startup_widget);
const svc_devConsole = this.services.get('dev-console', { optional: true });
if ( svc_devConsole ) svc_devConsole.add_widget(this.startup_widget);
}
this.print_puter_logo_();
@@ -291,7 +291,10 @@ class WebServerService extends BaseService {
res.setHeader('Access-Control-Allow-Origin', origin ?? '*');
}
// Website(s) to allow to connect
if ( req.subdomains[0] === 'api' ) {
if (
config.experimental_no_subdomain ||
req.subdomains[req.subdomains.length-1] === 'api'
) {
res.setHeader('Access-Control-Allow-Origin', origin ?? '*');
res.setHeader('Access-Control-Allow-Credentials', 'true');
}
@@ -329,9 +332,13 @@ class WebServerService extends BaseService {
{
id: 'dismiss',
description: 'Dismiss the startup message',
handler: async () => {
const svc_devConsole = this.services.get('dev-console');
svc_devConsole.remove_widget(this.startup_widget);
handler: async (_, log) => {
if ( ! this.startup_widget ) return;
const svc_devConsole = this.services.get('dev-console', { optional: true });
if ( svc_devConsole ) svc_devConsole.remove_widget(this.startup_widget);
const lines = this.startup_widget();
for ( const line of lines ) log.log(line);
this.startup_widget = null;
}
}
]);
@@ -25,13 +25,16 @@ const { AppUnderUserActorType, UserActorType, Actor, SystemActorType, AccessToke
class ACLService extends BaseService {
async check (actor, resource, mode) {
const result = await this._check_fsNode(actor, resource, mode);
if ( this.verbose ) console.log('LOGGING ACL CHECK', {
actor, mode,
// trace: (new Error()).stack,
result,
const ld = (Context.get('logdent') ?? 0) + 1;
return await Context.get().sub({ logdent: ld }).arun(async () => {
const result = await this._check_fsNode(actor, resource, mode);
if ( this.verbose ) console.log('LOGGING ACL CHECK', {
actor, mode,
// trace: (new Error()).stack,
result,
});
return result;
});
return result;
}
async _check_fsNode (actor, fsNode, mode) {
@@ -76,35 +79,6 @@ class ACLService extends BaseService {
}
}
// Hard rule: if actor is owner, allow
if ( actor.type instanceof UserActorType ) {
const owner = await fsNode.get('user_id');
if ( this.verbose ) {
const user = await get_user({ id: owner });
this.log.info(
`user ${user.username} is ` +
(owner == actor.type.user.id ? '' : 'not ') +
'owner of ' + await fsNode.get('path'), {
actor_user_id: actor.type.user.id,
fsnode_user_id: owner,
}
);
}
if ( owner == actor.type.user.id ) {
return true;
}
}
// For these actors, deny if the user component is not the owner
// -> user
// -> app-under-user
if ( ! (actor.type instanceof AccessTokenActorType) ) {
const owner = await fsNode.get('user_id');
if ( owner != actor.type.user.id ) {
return false;
}
}
// app-under-user only works if the user also has permission
if ( actor.type instanceof AppUnderUserActorType ) {
const user_actor = new Actor({
@@ -146,6 +120,7 @@ class ACLService extends BaseService {
return APIError.create('forbidden');
}
// TODO: DRY: Also in FilesystemService
_higher_modes (mode) {
// If you want to X, you can do so with any of [...Y]
if ( mode === 'see' ) return ['see', 'list', 'read', 'write'];
@@ -25,6 +25,8 @@ const { DB_WRITE } = require("../database/consts");
const APP_ORIGIN_UUID_NAMESPACE = '33de3768-8ee0-43e9-9e73-db192b97a5d8';
const LegacyTokenError = class extends Error {};
class AuthService extends BaseService {
static MODULES = {
jwt: require('jsonwebtoken'),
@@ -34,6 +36,8 @@ class AuthService extends BaseService {
async _init () {
this.db = await this.services.get('database').get(DB_WRITE, 'auth');
this.sessions = {};
}
async authenticate_from_token (token) {
@@ -43,6 +47,7 @@ class AuthService extends BaseService {
);
if ( ! decoded.hasOwnProperty('type') ) {
throw new LegacyTokenError();
const user = await this.db.requireRead(
"SELECT * FROM `user` WHERE `uuid` = ? LIMIT 1",
[decoded.uuid],
@@ -66,6 +71,26 @@ class AuthService extends BaseService {
});
}
if ( decoded.type === 'session' ) {
const session = await this.get_session_(decoded.uuid);
if ( ! session ) {
throw APIError.create('token_auth_failed');
}
const user = await get_user({ uuid: decoded.user_uid });
const actor_type = new UserActorType({
user,
session: session.uuid,
});
return new Actor({
user_uid: decoded.user_uid,
type: actor_type,
});
}
if ( decoded.type === 'app-under-user' ) {
const user = await get_user({ uuid: decoded.user_uid });
if ( ! user ) {
@@ -149,6 +174,146 @@ class AuthService extends BaseService {
return token;
}
async create_session_ (user, meta = {}) {
this.log.info(`CREATING SESSION`);
if ( meta.req ) {
const req = meta.req;
delete meta.req;
const ip = this.global_config.fowarded
? req.headers['x-forwarded-for'] ||
req.connection.remoteAddress
: req.connection.remoteAddress
;
meta.ip = ip;
meta.server = this.global_config.server_id;
if ( req.headers['user-agent'] ) {
meta.user_agent = req.headers['user-agent'];
}
if ( req.headers['referer'] ) {
meta.referer = req.headers['referer'];
}
if ( req.headers['origin'] ) {
const origin = this._origin_from_url(req.headers['origin']);
if ( origin ) {
meta.origin = origin;
}
}
if ( req.headers['host'] ) {
const host = this._origin_from_url(req.headers['host']);
if ( host ) {
meta.host = host;
}
}
}
meta.created = new Date().toISOString();
meta.created_unix = Math.floor(Date.now() / 1000);
const uuid = this.modules.uuidv4();
await this.db.write(
'INSERT INTO `sessions` ' +
'(`uuid`, `user_id`, `meta`) ' +
'VALUES (?, ?, ?)',
[uuid, user.id, JSON.stringify(meta)],
);
const session = { uuid, user_uid: user.uuid, meta };
this.sessions[uuid] = session;
return session;
}
async get_session_ (uuid) {
this.log.info(`USING SESSION`);
if ( this.sessions[uuid] ) {
return this.sessions[uuid];
}
const [session] = await this.db.read(
"SELECT * FROM `sessions` WHERE `uuid` = ? LIMIT 1",
[uuid],
);
if ( ! session ) return;
session.meta = this.db.case({
mysql: () => session.meta,
otherwise: () => JSON.parse(session.meta ?? "{}")
})();
return session;
}
async create_session_token (user, meta) {
const session = await this.create_session_(user, meta);
const token = this.modules.jwt.sign({
type: 'session',
version: '0.0.0',
uuid: session.uuid,
meta: session.meta,
user_uid: user.uuid,
}, this.global_config.jwt_secret);
return { session, token };
}
async check_session (cur_token, meta) {
const decoded = this.modules.jwt.verify(
cur_token, this.global_config.jwt_secret
);
console.log('\x1B[36;1mDECODED SESSION', decoded);
if ( decoded.type && decoded.type !== 'session' ) {
return {};
}
const is_legacy = ! decoded.type;
const user = await get_user({ uuid:
is_legacy ? decoded.uuid : decoded.user_uid
});
if ( ! user ) {
return {};
}
if ( ! is_legacy ) {
// Ensure session exists
const session = await this.get_session_(decoded.uuid);
if ( ! session ) {
return {};
}
// Return the session
return { user, token: cur_token };
}
this.log.info(`UPGRADING SESSION`);
// Upgrade legacy token
// TODO: phase this out
const { session, token } = await this.create_session_token(user, meta);
const actor_type = new UserActorType({
user,
session,
});
const actor = new Actor({
user_uid: user.uuid,
type: actor_type,
});
return { actor, user, token };
}
async create_access_token (authorizer, permissions) {
const jwt_obj = {};
const authorizer_obj = {};
@@ -206,6 +371,35 @@ class AuthService extends BaseService {
return jwt;
}
async list_sessions (actor) {
// We won't take the cached sessions here because it's
// possible the user has sessions on other servers
const sessions = await this.db.read(
'SELECT uuid, meta FROM `sessions` WHERE `user_id` = ?',
[actor.type.user.id],
);
sessions.forEach(session => {
session.meta = this.db.case({
mysql: () => session.meta,
otherwise: () => JSON.parse(session.meta ?? "{}")
})();
if ( session.uuid === actor.type.session ) {
session.current = true;
}
});
return sessions;
}
async revoke_session (actor, uuid) {
delete this.sessions[uuid];
await this.db.write(
`DELETE FROM sessions WHERE uuid = ? AND user_id = ?`,
[uuid, actor.type.user.id]
);
}
async get_user_app_token_from_origin (origin) {
origin = this._origin_from_url(origin);
const app_uid = await this._app_uid_from_origin(origin);
@@ -264,4 +458,5 @@ class AuthService extends BaseService {
module.exports = {
AuthService,
LegacyTokenError,
};
@@ -17,6 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const { get_user, get_app } = require("../../helpers");
const { Context } = require("../../util/context");
const BaseService = require("../BaseService");
const { DB_WRITE } = require("../database/consts");
const { UserActorType, Actor, AppUnderUserActorType, AccessTokenActorType } = require("./Actor");
@@ -84,6 +85,10 @@ const implicit_user_app_permissions = [
},
];
const implicit_user_permissions = {
'driver': {},
};
class PermissionRewriter {
static create ({ id, matcher, rewriter }) {
return new PermissionRewriter({ id, matcher, rewriter });
@@ -104,6 +109,32 @@ class PermissionRewriter {
}
}
class PermissionImplicator {
static create ({ id, matcher, checker }) {
return new PermissionImplicator({ id, matcher, checker });
}
constructor ({ id, matcher, checker }) {
this.id = id;
this.matcher = matcher;
this.checker = checker;
}
matches (permission) {
return this.matcher(permission);
}
/**
* Check if the permission is implied by this implicator
* @param {Actor} actor
* @param {string} permission
* @returns
*/
async check (actor, permission) {
return await this.checker(actor, permission);
}
}
class PermissionUtil {
static unescape_permission_component (component) {
let unescaped_str = '';
@@ -142,6 +173,7 @@ class PermissionService extends BaseService {
this._register_commands(this.services.get('commands'));
this._permission_rewriters = [];
this._permission_implicators = [];
}
async _rewrite_permission (permission) {
@@ -152,8 +184,16 @@ class PermissionService extends BaseService {
return permission;
}
async check () {
const ld = (Context.get('logdent') ?? 0) + 1;
return await Context.get().sub({ logdent: ld }).arun(async () => {
const res = await this.check__(...arguments);
// this.log.noticeme('RETURN ' + res);
return res;
});
}
async check (actor, permission) {
async check__ (actor, permission) {
permission = await this._rewrite_permission(permission);
this.log.info(`checking permission ${permission} for actor ${actor.uid}`, {
@@ -162,30 +202,87 @@ class PermissionService extends BaseService {
});
// For now we're only checking driver permissions, and users have all of them
if ( actor.type instanceof UserActorType ) {
return {};
return await this.check_user_permission(actor, permission);
}
if ( actor.type instanceof AccessTokenActorType ) {
// Authorizer must have permission
const authorizer_permission = await this.check(authorizer, permission);
if ( ! authorizer_permission ) return false;
return await this.check_access_token_permission(
actor.type.authorizer, actor.type.token, permission
);
}
// Prevent undefined behaviour
if ( ! (actor.type instanceof AppUnderUserActorType) ) {
throw new Error('actor must be an app under a user');
if ( actor.type instanceof AppUnderUserActorType ) {
// NEXT:
const app_uid = actor.type.app.uid;
const user_actor = actor.get_related_actor(UserActorType);
const user_has_permission = await this.check_user_permission(user_actor, permission);
if ( ! user_has_permission ) return undefined;
return await this.check_user_app_permission(actor, app_uid, permission);
}
// Now it's an app under a user
const app_uid = actor.type.app.uid;
return await this.check_user_app_permission(actor, app_uid, permission);
throw new Error('unrecognized actor type');
}
// TODO: context meta for cycle detection
async check_user_permission (actor, permission) {
permission = await this._rewrite_permission(permission);
const parent_perms = this.get_parent_permissions(permission);
// Check implicit permissions
for ( const parent_perm of parent_perms ) {
if ( implicit_user_permissions[parent_perm] ) {
return implicit_user_permissions[parent_perm];
}
}
for ( const implicator of this._permission_implicators ) {
if ( ! implicator.matches(permission) ) continue;
const implied = await implicator.check(actor, permission);
if ( implied ) return implied;
}
// Check permissions granted by other users
let sql_perm = parent_perms.map((perm) =>
`\`permission\` = ?`).join(' OR ');
if ( parent_perms.length > 1 ) sql_perm = '(' + sql_perm + ')';
// SELECT permission
const rows = await this.db.read(
'SELECT * FROM `user_to_user_permissions` ' +
'WHERE `holder_user_id` = ? AND ' +
sql_perm,
[
actor.type.user.id,
...parent_perms,
]
);
// Return the first matching permission where the
// issuer also has the permission granted
for ( const row of rows ) {
const issuer_actor = new Actor({
type: new UserActorType({
user: await get_user({ id: row.issuer_user_id }),
}),
});
const issuer_perm = await this.check(issuer_actor, row.permission);
if ( ! issuer_perm ) continue;
return row.extra;
}
return undefined;
}
async check_access_token_permission (authorizer, token, permission) {
// Authorizer must have permission
const authorizer_permission = await this.check(authorizer, permission);
if ( ! authorizer_permission ) return false;
const rows = await this.db.read(
'SELECT * FROM `access_token_permissions` ' +
'WHERE `token_uid` = ? AND `permission` = ?',
@@ -208,18 +305,7 @@ class PermissionService extends BaseService {
if ( ! app ) app = await get_app({ name: app_uid });
const app_id = app.id;
const parent_perms = [];
{
// We don't use PermissionUtil.split here because it unescapes
// components; we want to keep the components escaped for matching.
const parts = permission.split(':');
// Add sub-permissions
for ( let i = 1 ; i < parts.length ; i++ ) {
parent_perms.push(parts.slice(0, i + 1).join(':'));
}
}
parent_perms.reverse();
const parent_perms = this.get_parent_permissions(permission);
for ( const permission of parent_perms ) {
// Check hardcoded permissions
@@ -394,6 +480,107 @@ class PermissionService extends BaseService {
);
}
async grant_user_user_permission (actor, username, permission, extra = {}, meta) {
permission = await this._rewrite_permission(permission);
const user = await get_user({ username });
if ( ! user ) {
throw new Error('user not found');
}
// Don't allow granting permissions to yourself
if ( user.id === actor.type.user.id ) {
throw new Error('cannot grant permissions to yourself');
}
// UPSERT permission
await this.db.write(
'INSERT INTO `user_to_user_permissions` (`holder_user_id`, `issuer_user_id`, `permission`, `extra`) ' +
'VALUES (?, ?, ?, ?) ' +
this.db.case({
mysql: 'ON DUPLICATE KEY UPDATE `extra` = ?',
otherwise: 'ON CONFLICT(`holder_user_id`, `issuer_user_id`, `permission`) DO UPDATE SET `extra` = ?',
}),
[
user.id,
actor.type.user.id,
permission,
JSON.stringify(extra),
JSON.stringify(extra),
]
);
// INSERT audit table
await this.db.write(
'INSERT INTO `audit_user_to_user_permissions` (' +
'`holder_user_id`, `holder_user_id_keep`, `issuer_user_id`, `issuer_user_id_keep`, ' +
'`permission`, `action`, `reason`) ' +
'VALUES (?, ?, ?, ?, ?, ?, ?)',
[
user.id,
user.id,
actor.type.user.id,
actor.type.user.id,
permission,
'grant',
meta?.reason || 'granted via PermissionService',
]
);
}
async revoke_user_user_permission (actor, username, permission, meta) {
permission = await this._rewrite_permission(permission);
const user = await get_user({ username });
if ( ! user ) {
throw new Error('user not found');
}
// DELETE permission
await this.db.write(
'DELETE FROM `user_to_user_permissions` ' +
'WHERE `holder_user_id` = ? AND `issuer_user_id` = ? AND `permission` = ?',
[
user.id,
actor.type.user.id,
permission,
]
);
// INSERT audit table
await this.db.write(
'INSERT INTO `audit_user_to_user_permissions` (' +
'`holder_user_id`, `holder_user_id_keep`, `issuer_user_id`, `issuer_user_id_keep`, ' +
'`permission`, `action`, `reason`) ' +
'VALUES (?, ?, ?, ?, ?, ?, ?)',
[
user.id,
user.id,
actor.type.user.id,
actor.type.user.id,
permission,
'revoke',
meta?.reason || 'revoked via PermissionService',
]
);
}
get_parent_permissions (permission) {
const parent_perms = [];
{
// We don't use PermissionUtil.split here because it unescapes
// components; we want to keep the components escaped for matching.
const parts = permission.split(':');
// Add sub-permissions
for ( let i = 0 ; i < parts.length ; i++ ) {
parent_perms.push(parts.slice(0, i + 1).join(':'));
}
}
parent_perms.reverse();
return parent_perms;
}
register_rewriter (translator) {
if ( ! (translator instanceof PermissionRewriter) ) {
throw new Error('translator must be a PermissionRewriter');
@@ -402,6 +589,14 @@ class PermissionService extends BaseService {
this._permission_rewriters.push(translator);
}
register_implicator (implicator) {
if ( ! (implicator instanceof PermissionImplicator) ) {
throw new Error('implicator must be a PermissionImplicator');
}
this._permission_implicators.push(implicator);
}
_register_commands (commands) {
commands.registerCommands('perms', [
{
@@ -425,6 +620,7 @@ class PermissionService extends BaseService {
module.exports = {
PermissionRewriter,
PermissionImplicator,
PermissionUtil,
PermissionService,
};
@@ -16,6 +16,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const { es_import_promise } = require("../../fun/dev-console-ui-utils");
const { surrounding_box } = require("../../fun/dev-console-ui-utils");
const { BaseDatabaseAccessService } = require("./BaseDatabaseAccessService");
class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
@@ -39,24 +41,85 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
this.db = new Database(this.config.path);
// Database upgrade logic
const TARGET_VERSION = 4;
if ( do_setup ) {
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
const sql_files = [
'0001_create-tables.sql',
'0002_add-default-apps.sql',
'0003_user-permissions.sql',
'0004_sessions.sql',
'0005_background-apps.sql',
'0006_update-apps.sql',
].map(p => path_.join(__dirname, 'sqlite_setup', p));
const fs = require('fs');
for ( const filename of sql_files ) {
const basename = path_.basename(filename);
this.log.noticeme(`applying ${basename}`);
const contents = fs.readFileSync(filename, 'utf8');
this.db.exec(contents);
}
await this.db.exec(`PRAGMA user_version = ${TARGET_VERSION};`);
}
// Create the tables if they don't exist.
const check =
`SELECT name FROM sqlite_master WHERE type='table' AND name='fsentries'`;
const rows = await this.db.prepare(check).all();
if ( rows.length === 0 ) {
throw new Error('it works');
const [{ user_version }] = await this._read('PRAGMA user_version');
this.log.info('database version: ' + user_version);
const upgrade_files = [];
if ( user_version <= 0 ) {
upgrade_files.push('0003_user-permissions.sql');
}
if ( user_version <= 1 ) {
upgrade_files.push('0004_sessions.sql');
}
if ( user_version <= 2 ) {
upgrade_files.push('0005_background-apps.sql');
}
if ( user_version <= 3 ) {
upgrade_files.push('0006_update-apps.sql');
}
if ( upgrade_files.length > 0 ) {
this.log.noticeme(`Database out of date: ${this.config.path}`);
this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`);
this.log.noticeme(`${upgrade_files.length} .sql files to apply`);
const sql_files = upgrade_files.map(
p => path_.join(__dirname, 'sqlite_setup', p)
);
const fs = require('fs');
for ( const filename of sql_files ) {
const basename = path_.basename(filename);
this.log.noticeme(`applying ${basename}`);
const contents = fs.readFileSync(filename, 'utf8');
this.db.exec(contents);
}
// Update version number
await this.db.exec(`PRAGMA user_version = ${TARGET_VERSION};`);
// Add sticky notification
this.database_update_notice = () => {
const lines = [
`Database has been updated!`,
`Current version: ${TARGET_VERSION}`,
`Type sqlite:dismiss to dismiss this message`,
];
surrounding_box('33;1', lines);
return lines;
};
(async () => {
await es_import_promise;
const svc_devConsole = this.services.get('dev-console');
svc_devConsole.add_widget(this.database_update_notice);
})();
}
}
@@ -148,6 +211,19 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
}
}
},
{
id: 'dismiss',
description: 'dismiss the database update notice',
handler: async (_, log) => {
const svc_devConsole = this.services.get('dev-console');
if ( ! svc_devConsole ) return;
if ( ! this.database_update_notice ) return;
svc_devConsole.remove_widget(this.database_update_notice);
const lines = this.database_update_notice();
for ( const line of lines ) log.log(line);
this.database_update_notice = null;
}
}
])
}
}
@@ -0,0 +1,31 @@
CREATE TABLE `user_to_user_permissions` (
"issuer_user_id" INTEGER NOT NULL,
"holder_user_id" INTEGER NOT NULL,
"permission" TEXT NOT NULL,
"extra" JSON DEFAULT NULL,
FOREIGN KEY("issuer_user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY("holder_user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY ("issuer_user_id", "holder_user_id", "permission")
);
CREATE TABLE "audit_user_to_user_permissions" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"issuer_user_id" INTEGER NOT NULL,
"issuer_user_id_keep" INTEGER DEFAULT NULL,
"holder_user_id" INTEGER NOT NULL,
"holder_user_id_keep" INTEGER DEFAULT NULL,
"permission" TEXT NOT NULL,
"extra" JSON DEFAULT NULL,
"action" TEXT DEFAULT NULL,
"reason" TEXT DEFAULT NULL,
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY("issuer_user_id") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY("holder_user_id") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
@@ -0,0 +1,7 @@
CREATE TABLE `sessions` (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"user_id" INTEGER NOT NULL,
"uuid" TEXT NOT NULL,
"meta" JSON DEFAULT NULL,
FOREIGN KEY("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
@@ -0,0 +1 @@
ALTER TABLE apps ADD COLUMN "background" BOOLEAN DEFAULT 0;
@@ -0,0 +1,5 @@
UPDATE `apps` SET `index_url` = 'https://builtins.namespaces.puter.com/terminal' WHERE `name` = 'terminal';
INSERT INTO `apps` (`uid`, `owner_user_id`, `name`, `title`, `description`, `godmode`, `background`, `maximize_on_start`, `index_url`, `approved_for_listing`, `approved_for_opening_items`, `approved_for_incentive_program`, `timestamp`, `last_review`, `tags`, `app_owner`) VALUES (
'129e4bfb-4c8a-47e0-bec2-0279c21ace06', 1,
'phoenix','Phoenix Shell','',0,1,1,'https://builtins.namespaces.puter.com/phoenix',1,0,0,'2022-08-16 01:28:47',NULL,'productivity',NULL);
@@ -55,7 +55,7 @@ class DBKVStore extends BaseImplementation {
[ user.id, key_hash ]
);
return kv[0] ? { key: kv[0].key, value: kv[0].value } : null;
return kv[0]?.value ?? null;
},
set: async function ({ key, value }) {
const actor = this.context.get('actor');
@@ -84,15 +84,28 @@ class DBKVStore extends BaseImplementation {
const db = this.services.get('database').get(DB_WRITE, 'kvstore');
const key_hash = this.modules.murmurhash.v3(key);
await db.write(
`INSERT INTO kv
(user_id, app, kkey_hash, kkey, value)
VALUES
(?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
value = ?`,
[ user.id, app?.uid ?? 'global', key_hash, key, value, value ]
);
try {
await db.write(
`INSERT INTO kv (user_id, app, kkey_hash, kkey, value)
VALUES (?, ?, ?, ?, ?) ` +
db.case({
mysql: 'ON DUPLICATE KEY UPDATE value = ?',
sqlite: ' ',
// sqlite: 'ON CONFLICT(user_id, app, kkey_hash) DO UPDATE SET value = ?',
}),
[
user.id, app?.uid ?? 'global', key_hash, key, value,
...db.case({ mysql: [value], otherwise: [] }),
]
);
} catch (e) {
// if ( e.code !== 'SQLITE_ERROR' && e.code !== 'SQLITE_CONSTRAINT_PRIMARYKEY' ) throw e;
// The "ON CONFLICT" clause isn't currently working.
await db.write(
`UPDATE kv SET value = ? WHERE user_id=? AND app=? AND kkey_hash=?`,
[ value, user.id, app?.uid ?? 'global', key_hash ]
);
}
return true;
},
@@ -159,7 +159,11 @@ class DevLogger {
log_lvl, crumbs, message, fields, objects,
);
}
this.log(stringify_log_entry({
const ld = Context.get('logdent', { allow_fallback: true })
const prefix = globalThis.dev_console_indent_on
? Array(ld ?? 0).fill(' ').join('')
: '';
this.log(prefix + stringify_log_entry({
log_lvl, crumbs, message, fields, objects,
}));
}
@@ -34,18 +34,48 @@ class MonthlyUsageService extends BaseService {
const maybe_app_id = actor.type.app?.id;
if ( this.db.case({ sqlite: true, otherwise: false }) ) {
return;
}
const vals =
[
year, month, key, actor.type.user.id, maybe_app_id, JSON.stringify(extra),
...this.db.case({ mysql: [JSON.stringify(extra)], otherwise: [] }),
]
console.log('VALS', vals);
// UPSERT increment count
await this.db.write(
'INSERT INTO `service_usage_monthly` (`year`, `month`, `key`, `count`, `user_id`, `app_id`, `extra`) ' +
'VALUES (?, ?, ?, 1, ?, ?, ?) ' +
'ON DUPLICATE KEY UPDATE `count` = `count` + 1',
[
year, month, key,
actor.type.user?.id || null,
maybe_app_id || null,
JSON.stringify(extra)
]
);
try {
await this.db.write(
'INSERT INTO `service_usage_monthly` (`year`, `month`, `key`, `count`, `user_id`, `app_id`, `extra`) ' +
'VALUES (?, ?, ?, 1, ?, ?, ?) ' +
this.db.case({
mysql: 'ON DUPLICATE KEY UPDATE `count` = `count` + 1, `extra` = ?',
sqlite: ' ',
// sqlite: 'ON CONFLICT(`year`, `month`, `key`, `user_id`, `app_id`) ' +
// 'DO UPDATE SET `count` = `count` + 1 AND `extra` = ?',
}),
[
year, month, key, actor.type.user.id, maybe_app_id ?? null, JSON.stringify(extra),
...this.db.case({ mysql: [JSON.stringify(extra)], otherwise: [] }),
]
);
} catch (e) {
// if ( e.code !== 'SQLITE_ERROR' && e.code !== 'SQLITE_CONSTRAINT_PRIMARYKEY' ) throw e;
// The "ON CONFLICT" clause isn't currently working.
await this.db.write(
'UPDATE `service_usage_monthly` ' +
'SET `count` = `count` + 1, `extra` = ? ' +
'WHERE `year` = ? AND `month` = ? AND `key` = ? ' +
'AND `user_id` = ? AND `app_id` = ?',
[
JSON.stringify(extra),
year, month, key, actor.type.user.id, maybe_app_id,
]
);
}
}
async check (actor, specifiers) {
+29 -23
View File
@@ -21,6 +21,8 @@ const path_ = require('path');
const fs_ = require('fs');
const generate_puter_page_html = ({
env,
manifest,
gui_path,
@@ -49,6 +51,10 @@ const generate_puter_page_html = ({
gui_origin: app_origin,
};
const asset_dir = env === 'dev'
? '/src' : '/dist' ;
// const asset_dir = '/dist';
return `<!DOCTYPE html>
<html lang="en">
@@ -64,7 +70,7 @@ const generate_puter_page_html = ({
<meta property="og:type" content="website">
<meta property="og:title" content="${e(title)}">
<meta property="og:description" content="${e((short_description).replace(/\n/g, " "))}">
<meta property="og:image" content="/dist/images/screenshot.png">
<meta property="og:image" content="${asset_dir}/images/screenshot.png">
<!-- Twitter meta tags -->
<meta name="twitter:card" content="summary_large_image">
@@ -72,33 +78,33 @@ const generate_puter_page_html = ({
<meta property="twitter:url" content="${app_origin}">
<meta name="twitter:title" content="${e(title)}">
<meta name="twitter:description" content="${e((short_description).replace(/\n/g, " "))}">
<meta name="twitter:image" content="/dist/images/screenshot.png">
<meta name="twitter:image" content="${asset_dir}/images/screenshot.png">
<!-- favicons -->
<link rel="apple-touch-icon" sizes="57x57" href="/dist/favicons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/dist/favicons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/dist/favicons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/dist/favicons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/dist/favicons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/dist/favicons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/dist/favicons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/dist/favicons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/dist/favicons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/dist/favicons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/dist/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/dist/favicons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/dist/favicons/favicon-16x16.png">
<link rel="manifest" href="/dist/manifest.json">
<link rel="apple-touch-icon" sizes="57x57" href="${asset_dir}/favicons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="${asset_dir}/favicons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="${asset_dir}/favicons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="${asset_dir}/favicons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="${asset_dir}/favicons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="${asset_dir}/favicons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="${asset_dir}/favicons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="${asset_dir}/favicons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="${asset_dir}/favicons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="${asset_dir}/favicons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="${asset_dir}/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="${asset_dir}/favicons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="${asset_dir}/favicons/favicon-16x16.png">
<link rel="manifest" href="${asset_dir}/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/dist/favicons/ms-icon-144x144.png">
<meta name="msapplication-TileImage" content="${asset_dir}/favicons/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<!-- Preload images when applicable -->
<link rel="preload" as="image" href="/dist/images/wallpaper.webp">
<link rel="preload" as="image" href="${asset_dir}/images/wallpaper.webp">
<!-- Files from JSON (may be empty) -->
${
(manifest?.css_paths
((env == 'dev' && manifest?.css_paths)
? manifest.css_paths.map(path => `<link rel="stylesheet" href="${path}">\n`)
: []).join('')
}
@@ -108,7 +114,7 @@ const generate_puter_page_html = ({
<body>
<script>window.puter_gui_enabled = true;</script>
${
(manifest?.lib_paths
((env == 'dev' && manifest?.lib_paths)
? manifest.lib_paths.map(path => `<script type="text/javascript" src="${path}"></script>\n`)
: []).join('')
}
@@ -117,7 +123,7 @@ const generate_puter_page_html = ({
window.icons = {};
${(() => {
if ( ! manifest ) return '';
if ( !(env == 'dev' && manifest) ) return '';
const html = [];
fs_.readdirSync(path_.join(gui_path, 'src/icons')).forEach(file => {
// skip dotfiles
@@ -138,12 +144,12 @@ const generate_puter_page_html = ({
</script>
${
(manifest?.js_paths
((env == 'dev' && manifest?.js_paths)
? manifest.js_paths.map(path => `<script type="module" src="${path}"></script>\n`)
: []).join('')
}
<!-- Load the GUI script -->
<script ${ manifest.index ? ' type="module"' : ''} src="${manifest?.index ?? '/dist/gui.js'}"></script>
<script ${ env == 'dev' ? ' type="module"' : ''} src="${(env == 'dev' && manifest?.index) || '/dist/gui.js'}"></script>
<!-- Initialize GUI when document is loaded -->
<script>
window.addEventListener('load', function() {
+19
View File
@@ -0,0 +1,19 @@
let memoized_common_template_vars_ = null;
const get_common_template_vars = () => {
const path_ = require('path');
if ( memoized_common_template_vars_ !== null ) {
return memoized_common_template_vars_;
}
const code_root = path_.resolve(__dirname, '../../');
memoized_common_template_vars_ = {
code_root,
};
return memoized_common_template_vars_;
}
module.exports = {
get_common_template_vars,
};
+4
View File
@@ -0,0 +1,4 @@
node_modules/
dist/
release/
*.tar
+661
View File
@@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
+54
View File
@@ -0,0 +1,54 @@
<h2 align="center">Phoenix</h2>
<h3 align="center">Puter's pure-javascript shell</h3>
<h3 align="center"><img alt="" src="./doc/readme-gif.gif"></h3>
<hr>
`phoenix` is a pure-javascript shell built for [puter.com](https://puter.com).
Following the spirit of open-source initiatives we've seen like
[SerenityOS](https://serenityos.org/),
we've built much of the shell's functionality from scratch.
Some interesting portions of this shell include:
- A shell parser which produces a Concrete-Syntax-Tree
- Pipeline constructs built on top of the [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
- Platform support for Puter
The shell is a work in progress. The following improvements are considered in-scope:
- Anything specified in [POSIX.1-2017 Chapter 2](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html)
- UX improvements over traditional shells
> examples include: readline syntax highlighting, hex view for binary streams
- Platform support, so `phoenix` can run in more environments
## Running Phoenix
### In a Browser
You can use the [terminal on Puter](https://puter.com/app/terminal), including self-hosted installations.
### Running in Node
Under node.js Phoenix acts as a shell for your operating system.
This is a work-in-progress and lots of things are not working
yet. If you'd like to try it out you can run `src/main_cli.js`.
Check [this issue](https://github.com/HeyPuter/phoenix/issues/14)
for updated information on our progress.
## Testing
You can find our tests in the [test/](./test) directory.
Testing is done with [mocha](https://www.npmjs.com/package/mocha).
Make sure it's installed, then run:
```sh
npm test
```
## What's on the Roadmap?
We're looking to continue improving the shell and broaden its usefulness.
Here are a few ideas we have for the future:
- local machine platform support
> See [this issue](https://github.com/HeyPuter/phoenix/issues/14)
- further support for the POSIX Command Language
> Check our list of [missing features](doc/missing-posix.md)
+20
View File
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="xterm.css">
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="style.css">
<script src="__SDK_URL__"></script>
<script src="config.js"></script>
<script src="bundle.js"></script>
<script>
document.addEventListener('DOMContentLoaded', async () => {
main_shell();
});
</script>
</head>
</html>
+23
View File
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2024 Puter Technologies Inc.
*
* This file is part of Phoenix Shell.
*
* Phoenix Shell is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
globalThis.__CONFIG__ = {
"origin": "https://puter.local:8080",
"shell.href": "https://puter.local:8081",
"sdk_url": "http://puter.localhost:4100/sdk/puter.js",
};
+23
View File
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2024 Puter Technologies Inc.
*
* This file is part of Phoenix Shell.
*
* Phoenix Shell is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
globalThis.__CONFIG__ = {
origin: location.origin,
'shell.href': location.origin + '/puter-shell/',
sdk_url: 'https://puter.com/puter.js/v2',
};
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,77 @@
## keyboard modifier translation
Encoding of modifier keys in `xterm` is done following this
table:
encoded | keys pressed
--------|---------------------------
2 | Shift
3 | Alt
4 | Shift + Alt
5 | Control
6 | Shift + Control
7 | Alt + Control
8 | Shift + Alt + Control
9 | Meta
10 | Meta + Shift
11 | Meta + Alt
12 | Meta + Alt + Shift
13 | Meta + Ctrl
14 | Meta + Ctrl + Shift
15 | Meta + Ctrl + Alt
16 | Meta + Ctrl + Alt + Shift
This script was used to convert between more useful bit flags
and the xterm encodings of the modifiers:
```javascript
const modifier_keys = ['shift', 'ctrl', 'alt', 'meta'];
const MODIFIER = {};
for ( let i=0 ; i < modifier_keys.length ; i++ ) {
MODIFIER[modifier_keys[i].toUpperCase()] = 1 << i;
}
const pc_modifier_list = [
MODIFIER.SHIFT,
MODIFIER.ALT,
MODIFIER.CTRL,
MODIFIER.META
];
const PC_STYLE_MODIFIER_MAP = {};
(() => {
let i = 2;
for ( const mod of pc_modifier_list ) {
const new_entries = { [i++]: mod };
for ( const key in PC_STYLE_MODIFIER_MAP ) {
new_entries[i++] = mod | PC_STYLE_MODIFIER_MAP[key];
}
for ( const key in new_entries ) {
PC_STYLE_MODIFIER_MAP[key] = new_entries[key];
}
}
})();
for ( const k in PC_STYLE_MODIFIER_MAP ) {
console.log(`${k} :: ${print(PC_STYLE_MODIFIER_MAP[k])}`);
}
```
However, it was eventually determined that the PC-style function
keys, although this is not documented, really do represent bit
flags if you simply subtract 1.
For example, this situation doesn't look like it can be explained
using bit flags:
- **shift** is `2`
- **ctrl** is `5`, and has two `1` bits
- **shift** + **ctrl** is `6`
- flags don't explain this: `2 | 5 = 7`
But after subtracting `1` from each value:
- **shift** is `1`
- **ctrl** is `4`
- **shift** + **ctrl** is `5`
- flags work correctly: `1 | 4 = 5`
This is true for all examples.
@@ -0,0 +1,59 @@
## method `readline` from `BetterReader`
This method was meant to be a low-level line reader that simply
terminates at the first line feed character and returns the
input.
This might be useful for non-visible inputs like passwords, but
for visible inputs it is not practical unless the output stream
provided is decorated with something that can filter undesired
input characters that would move the terminal cursor.
It's especially not useful for a prompt with history, since the
up arrow should clear the input buffer and replace it with something
else.
Where this may shine is in a benchmark. The approach here doesn't
explicitly iterate over every byte, so assuming methods like
`.indexOf` and `.subarray` on TypedArray values are efficient this
would be faster than the implementation which is now used.
```javascript
async readLine (options) {
options = options ?? {};
let stringSoFar = '';
let lineFeedFound = false;
while ( ! lineFeedFound ) {
let chunk = await this.getChunk_();
const iLF = chunk.indexOf(CHAR_LF);
// do we have a line feed character?
if ( iLF >= 0 ) {
lineFeedFound = true;
// defer the rest of the chunk until next read
if ( iLF !== chunk.length - 1 ) {
this.chunks_.push(chunk.subarray(iLF + 1))
}
// (note): LF is not included in return value or next read
chunk = chunk.subarray(0, iLF);
}
if ( options.stream ) {
options.stream.write(chunk);
if ( lineFeedFound ) {
options.stream.write(new Uint8Array([CHAR_LF]));
}
}
const text = new TextDecoder().decode(chunk);
stringSoFar += text;
}
return stringSoFar;
}
```
+16
View File
@@ -0,0 +1,16 @@
Copyright (C) 2024 Puter Technologies Inc.
This file is part of Phoenix Shell.
Phoenix Shell is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
+23
View File
@@ -0,0 +1,23 @@
# Missing POSIX Functionality
### References
- [POSIX.1-2017 Chapter 2: Shell Command Language](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html)
### Shell Command Language features known to be missing from `phoenix`
- Parameter expansion
> This is support for `$variables`, and this is **highest priority**.
- Compound commands
> This is `if`, `case`, `while`, `for`, etc
- Arithmetic expansion
- Alias substitution
### How to Contribute
- Check the [README.md file](../README.md) for contributor guidelines.
- Additional features will require updates to
[the parser](phoenix/src/ansi-shell/parsing).
Right now there are repeated concerns between
`buildParserFirstHalf` and `buildParserSecondHalf` which need to
be factored out.
+55
View File
@@ -0,0 +1,55 @@
# Puter Terminal Parser
## The `strataparse` package
The `strataparse` package makes it possible to build parser in distinct
layers that we call "strata" (each one called a "stratum"). Rather then
distinguish between a "lexer" and "parser", we can instead have an
arbitrary number of layers that use different approaches to processing
or parsing.
Each stratum implements the method `next (api)`. The `api` object is
provided by strataparse as the bridge between which the strata
interact. Typically, it's used to call `api.delegate` to get a reference
to the lower-level parser. Terminal strata like `StringPStratumImpl`, don't
do this. The `next` method returns the next value in an object of the
form `{ done: true/false, value: ... }`, matching the typical interface
for iterators within this source code. When `done` is true, `value`
can be a message (such as an error) indicating why parsing halted.
## PuterShellParser
At the time of writing this, the PuterShellParser class builds a parser
with 4 strata, listed here from bottom up:
### buildParserFirstHalf (the "lexer half")
[source code](../src/ansi-shell/parsing/buildParserFirstHalf.js)
- A "FirstRecognized" strata which behaves like a lexer. It converts
characters like `|` to AST nodes like `{ $: 'op.pipe' }`.
AST nodes use the key `$` to identify the type and can have other
arbitrary values.
- A "MergeWhitespace" strata which is provided by `strataparse`.
It converts whitespace to a `{ $: 'whitespace' }` AST node, and
adds a property called `$cst` to all nodes from the delegate
(the "lexer") as well as these whitespace nodes. This effectively
transforms the AST nodes from before into CST nodes, providing
information about whitespace, line numbers, and column numbers
in a way subsequent layers can digest.
(note that these will still be referred to as "AST nodes throughout
this documentation).
[source code](../src/ansi-shell/parsing/buildParserSecondHalf.js)
### buildParserSecondHalf (the "parser half")
- "ReducePrimitives" creates higher-level AST nodes from some of the
AST nodes provided by the "previous"(lower/"lexer half") step.
At the time of writing it's specifically just to deal with strings,
reducing multiple `{ $: 'string.segment' }` and `{ $: 'string.escape }`
nodes into a `{ $: 'string' }` node.
- "ShellConstructs" creates higher-level nodes to model the behaviour
of the shell. For example, a sequence of tokens including
`{ $: 'op.pipe' }` nodes will be composed into a new `{ $: 'pipeline' }`
node. The pipeline node contains an array called `components` which
contains the tokens in between pipe operators.
Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2024 Puter Technologies Inc.
*
* This file is part of Phoenix Shell.
*
* Phoenix Shell is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Here for safe-keeping - wasn't correct for shell tokens but
// it will be needed later for variable assignments
export class SymbolParserImpl {
static meta = {
inputs: 'bytes',
outputs: 'node'
}
static data = {
rexp0: /[A-Za-z_]/,
rexpN: /[A-Za-z0-9_]/,
}
parse (lexer) {
let { done, value } = lexer.look();
if ( done ) return;
const { rexp0, rexpN } = this.constructor.data;
value = String.fromCharCode(value);
if ( ! rexp0.test(value) ) return;
let text = '' + value;
lexer.next();
for ( ;; ) {
({ done, value } = lexer.look());
if ( done ) break;
value = String.fromCharCode(value);
if ( ! rexpN.test(value) ) break;
text += value;
lexer.next();
}
return { $: 'symbol', text };
}
}
@@ -0,0 +1,26 @@
{
"ignore": ["**/!(*.js|*.css)"],
"license": "doc/license_header.txt",
"licenseFormats": {
"js": {
"prepend": "/*",
"append": " */",
"eachLine": {
"prepend": " * "
}
},
"dotfile|^Dockerfile": {
"eachLine": {
"prepend": "# "
}
},
"css": {
"prepend": "/*",
"append": " */",
"eachLine": {
"prepend": " * "
}
}
},
"trailingWhitespace": "TRIM"
}
+1892
View File
File diff suppressed because it is too large. Load diff
+41
View File
@@ -0,0 +1,41 @@
{
"name": "dev-ansi-terminal",
"version": "0.0.0",
"description": "ANSI Terminal for Puter",
"main": "exports.js",
"scripts": {
"test": "mocha ./test"
},
"author": "Puter Technologies Inc.",
"license": "AGPL-3.0-only",
"type": "module",
"devDependencies": {
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
"mocha": "^10.2.0",
"rollup": "^3.21.4",
"rollup-plugin-copy": "^3.4.0"
},
"dependencies": {
"@pkgjs/parseargs": "^0.11.0",
"capture-console": "^1.0.2",
"chronokinesis": "^6.0.0",
"cli-columns": "^4.0.0",
"columnify": "^1.6.0",
"fs-mode-to-string": "^0.0.2",
"json-query": "^2.2.2",
"path-browserify": "^1.0.1",
"sinon": "^17.0.1",
"xterm": "^5.1.0",
"xterm-addon-fit": "^0.7.0"
},
"optionalDependencies": {
"node-pty": "^1.0.0"
},
"workspaces": [
"packages/pty",
"packages/strataparse",
"packages/contextlink"
]
}
@@ -0,0 +1 @@
node_modules/
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2024 Puter Technologies Inc.
*
* This file is part of Phoenix Shell.
*
* Phoenix Shell is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export class Context {
constructor (values) {
for ( const k in values ) this[k] = values[k];
}
sub (newValues) {
if ( newValues === undefined ) newValues = {};
const sub = Object.create(this);
const alreadyApplied = {};
for ( const k in sub ) {
if ( sub[k] instanceof Context ) {
const newValuesForK =
newValues.hasOwnProperty(k)
? newValues[k] : undefined;
sub[k] = sub[k].sub(newValuesForK);
alreadyApplied[k] = true;
}
}
for ( const k in newValues ) {
if ( alreadyApplied[k] ) continue;
sub[k] = newValues[k];
}
return sub;
}
}
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2024 Puter Technologies Inc.
*
* This file is part of Phoenix Shell.
*
* Phoenix Shell is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export { Context } from "./context.js";
+916
View File
@@ -0,0 +1,916 @@
{
"name": "dev-contextlink",
"version": "0.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dev-contextlink",
"version": "0.0.0",
"license": "UNLICENSED",
"devDependencies": {
"mocha": "^10.2.0"
}
},
"node_modules/ansi-colors": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
"integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
"dev": true,
"dependencies": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
},
"node_modules/binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"dependencies": {
"fill-range": "^7.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"node_modules/camelcase": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",
"integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chalk/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/chokidar": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"dev": true,
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"dev": true,
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^7.0.0"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dev": true,
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/debug/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"node_modules/decamelize": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz",
"integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/diff": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz",
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
"dev": true,
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true
},
"node_modules/escalade": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/find-up": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
"integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
"dev": true,
"dependencies": {
"locate-path": "^6.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/flat": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz",
"integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==",
"dev": true,
"bin": {
"flat": "cli.js"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"dev": true
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
"dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": "*"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/glob/node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/glob/node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true,
"bin": {
"he": "bin/he"
}
},
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
"dev": true,
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
},
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true,
"dependencies": {
"binary-extensions": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/is-glob": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dev": true,
"dependencies": {
"is-extglob": "^2.1.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/is-plain-obj": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
"integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/is-unicode-supported": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz",
"integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
"integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
"dev": true,
"dependencies": {
"p-locate": "^5.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/log-symbols": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
"integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==",
"dev": true,
"dependencies": {
"chalk": "^4.1.0",
"is-unicode-supported": "^0.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/minimatch": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
"integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
"dev": true,
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=10"
}
},
"node_modules/mocha": {
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz",
"integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==",
"dev": true,
"dependencies": {
"ansi-colors": "4.1.1",
"browser-stdout": "1.3.1",
"chokidar": "3.5.3",
"debug": "4.3.4",
"diff": "5.0.0",
"escape-string-regexp": "4.0.0",
"find-up": "5.0.0",
"glob": "7.2.0",
"he": "1.2.0",
"js-yaml": "4.1.0",
"log-symbols": "4.1.0",
"minimatch": "5.0.1",
"ms": "2.1.3",
"nanoid": "3.3.3",
"serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1",
"supports-color": "8.1.1",
"workerpool": "6.2.1",
"yargs": "16.2.0",
"yargs-parser": "20.2.4",
"yargs-unparser": "2.0.0"
},
"bin": {
"_mocha": "bin/_mocha",
"mocha": "bin/mocha.js"
},
"engines": {
"node": ">= 14.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/mochajs"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"dev": true
},
"node_modules/nanoid": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz",
"integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==",
"dev": true,
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"dev": true,
"dependencies": {
"wrappy": "1"
}
},
"node_modules/p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
"dev": true,
"dependencies": {
"yocto-queue": "^0.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
"integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
"dev": true,
"dependencies": {
"p-limit": "^3.0.2"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
"dev": true,
"dependencies": {
"safe-buffer": "^5.1.0"
}
},
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dev": true,
"dependencies": {
"picomatch": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/serialize-javascript": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz",
"integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==",
"dev": true,
"dependencies": {
"randombytes": "^2.1.0"
}
},
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true,
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/workerpool": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz",
"integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==",
"dev": true
},
"node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true
},
"node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true,
"engines": {
"node": ">=10"
}
},
"node_modules/yargs": {
"version": "16.2.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
"integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
"dev": true,
"dependencies": {
"cliui": "^7.0.2",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.0",
"y18n": "^5.0.5",
"yargs-parser": "^20.2.2"
},
"engines": {
"node": ">=10"
}
},
"node_modules/yargs-parser": {
"version": "20.2.4",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz",
"integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==",
"dev": true,
"engines": {
"node": ">=10"
}
},
"node_modules/yargs-unparser": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz",
"integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==",
"dev": true,
"dependencies": {
"camelcase": "^6.0.0",
"decamelize": "^4.0.0",
"flat": "^5.0.2",
"is-plain-obj": "^2.1.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
"dev": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
}
}
}
@@ -0,0 +1,18 @@
{
"name": "contextlink",
"version": "0.0.0",
"main": "entry.js",
"type": "module",
"scripts": {
"test": "npx mocha"
},
"author": "Puter Technologies Inc.",
"license": "AGPL-3.0-only",
"devDependencies": {
"mocha": "^10.2.0"
},
"directories": {
"test": "test"
},
"description": ""
}
Loaded 100 of 386 files, more files were not shown because too many files have changed in this diff. Show more