@jskit-ai/agent-docs 0.1.397 → 0.1.398
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/guide/agent/app-extras/assistant-conversation.md +1 -2
- package/guide/agent/app-extras/assistant.md +171 -20
- package/guide/agent/app-extras/mobile-capacitor.md +110 -4
- package/guide/agent/app-extras/push-notifications.md +149 -0
- package/guide/agent/app-extras/realtime.md +11 -0
- package/guide/agent/app-setup/authentication.md +93 -1
- package/guide/agent/framework/client-features.md +65 -0
- package/guide/agent/framework/test-pass.md +3 -1
- package/guide/agent/framework/typed-features.md +12 -0
- package/guide/agent/index.md +1 -0
- package/guide/agent/recipes/file-uploads-and-images.md +24 -1
- package/guide/agent/recipes/installable-app.md +76 -82
- package/guide/agent/recipes/payments-and-subscriptions.md +30 -1
- package/package.json +1 -1
- package/patterns/feature-package/example/booking-engine/package.json +1 -1
- package/patterns/minimal-foundation/example/config/public.js +9 -1
- package/patterns/minimal-foundation/example/package.json +3 -3
- package/patterns/shell-foundation/example/config/public.js +9 -1
- package/patterns/shell-foundation/example/package.json +4 -4
- package/patterns/shell-foundation/example/packages/main/package.json +1 -1
- package/reference/autogen/PATTERN_INDEX.md +106 -40
- package/reference/autogen/README.md +4 -0
- package/reference/autogen/packages/assistant-core.md +4 -2
- package/reference/autogen/packages/assistant-runtime.md +14 -3
- package/reference/autogen/packages/auth-core.md +33 -0
- package/reference/autogen/packages/auth-provider-local-core.md +35 -2
- package/reference/autogen/packages/auth-provider-local-db-core.md +4 -0
- package/reference/autogen/packages/auth-web.md +42 -5
- package/reference/autogen/packages/http-runtime.md +9 -1
- package/reference/autogen/packages/http-web.md +36 -0
- package/reference/autogen/packages/mobile-capacitor.md +121 -5
- package/reference/autogen/packages/payments-core.md +2 -0
- package/reference/autogen/packages/push-core.md +128 -0
- package/reference/autogen/packages/push-web.md +99 -0
- package/reference/autogen/packages/realtime.md +6 -3
- package/reference/autogen/packages/store-purchases-core.md +113 -0
- package/reference/autogen/packages/store-purchases-web.md +55 -0
- package/reference/autogen/packages/uploads-image-web.md +2 -1
- package/reference/autogen/packages/uploads-runtime.md +21 -1
- package/reference/autogen/tooling/jskit-catalog.md +23 -1
- package/reference/autogen/tooling/jskit-release.md +4 -1
- package/skills/jskit/references/client-features.md +65 -0
- package/skills/jskit/references/pattern-index.md +106 -40
- package/skills/jskit/references/patterns/app/minimal-foundation/example/config/public.js +9 -1
- package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +3 -3
- package/skills/jskit/references/patterns/app/shell-foundation/example/config/public.js +9 -1
- package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +4 -4
- package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
- package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
- package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
- package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
- package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +5 -5
- package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +3 -3
- package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/mobile/android-app-actions/PATTERN.md +78 -0
- package/skills/jskit/references/patterns/mobile/android-app-actions/example/android/app/src/main/java/com/example/app/SummaryWidget.kt +33 -0
- package/skills/jskit/references/patterns/mobile/android-app-actions/example/android/app/src/main/res/layout/summary_widget.xml +17 -0
- package/skills/jskit/references/patterns/mobile/android-app-actions/example/android/app/src/main/res/xml/shortcuts.xml +16 -0
- package/skills/jskit/references/patterns/mobile/android-app-actions/example/android/app/src/main/res/xml/summary_widget_info.xml +8 -0
- package/skills/jskit/references/patterns/mobile/android-application/PATTERN.md +45 -2
- package/skills/jskit/references/patterns/mobile/android-application/example/android/app/src/main/AndroidManifest.xml +65 -0
- package/skills/jskit/references/patterns/mobile/android-application/example/src/placement.js +19 -0
- package/skills/jskit/references/patterns/mobile/ios-app-intents/PATTERN.md +55 -0
- package/skills/jskit/references/patterns/mobile/ios-app-intents/example/ios/App/App/Intents/ExampleShortcuts.swift +9 -0
- package/skills/jskit/references/patterns/mobile/ios-app-intents/example/ios/App/App/Intents/UnreadCountIntent.swift +33 -0
- package/skills/jskit/references/patterns/mobile/ios-application/PATTERN.md +169 -0
- package/skills/jskit/references/patterns/mobile/ios-application/example/capacitor.config.json +10 -0
- package/skills/jskit/references/patterns/mobile/ios-application/example/ios/App/App/App.entitlements +12 -0
- package/skills/jskit/references/patterns/mobile/ios-application/example/ios/App/App/App.swift +20 -0
- package/skills/jskit/references/patterns/mobile/ios-application/example/ios/App/App/Info.plist +63 -0
- package/skills/jskit/references/patterns/mobile/ios-application/example/package.json +15 -0
- package/skills/jskit/references/patterns/mobile/ios-application/example/src/placement.js +19 -0
- package/skills/jskit/references/patterns/mobile/ios-live-activity/PATTERN.md +73 -0
- package/skills/jskit/references/patterns/mobile/ios-live-activity/example/ios/App/LiveActivities/LiveActivitiesBundle.swift +13 -0
- package/skills/jskit/references/patterns/mobile/ios-live-activity/example/src/deliveryActivity.js +33 -0
- package/skills/jskit/references/patterns/mobile/ios-share-extension/PATTERN.md +83 -0
- package/skills/jskit/references/patterns/mobile/ios-share-extension/example/ios/App/ShareExtension/Info.plist +31 -0
- package/skills/jskit/references/patterns/mobile/ios-share-extension/example/ios/App/ShareExtension/ShareExtension.entitlements +10 -0
- package/skills/jskit/references/patterns/mobile/ios-share-extension/example/ios/App/ShareExtension/ShareViewController.swift +94 -0
- package/skills/jskit/references/patterns/mobile/ios-widget/PATTERN.md +66 -0
- package/skills/jskit/references/patterns/mobile/ios-widget/example/ios/App/SummaryWidget/SummaryWidget.swift +64 -0
- package/skills/jskit/references/patterns/mobile/ios-widget/example/src/widgetSummary.js +10 -0
- package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -3
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +6 -6
- package/skills/jskit/references/test-pass.md +3 -1
- package/skills/jskit/references/typed-features.md +12 -0
|
@@ -111,7 +111,7 @@ defaults, per minute: `login`, `register`, `registerConfirm`,
|
|
|
111
111
|
`loginOtpRequest`, `loginOtpVerify` and `emailChangeConfirm` 10;
|
|
112
112
|
`registerConfirmationResend`, `passwordForgot` and `emailChange` 5;
|
|
113
113
|
`oauthStart`, `oauthComplete`, `passSignIn`, `passwordRecovery` and `passwordReset` 20;
|
|
114
|
-
`devLoginAs` 30. Change one in the application's server configuration;
|
|
114
|
+
`devLoginAs` and `appSessionRefresh` 30; `sessionTicket` and `sessionLink` 60. Change one in the application's server configuration;
|
|
115
115
|
`false` removes it:
|
|
116
116
|
|
|
117
117
|
```js
|
|
@@ -1038,6 +1038,98 @@ sign-in methods section offers both.
|
|
|
1038
1038
|
With `@jskit-ai/auth-provider-local-db-core`, run `npm run db:migrate` to create
|
|
1039
1039
|
the `auth_local_identities` and `auth_local_oauth_attempts` tables.
|
|
1040
1040
|
|
|
1041
|
+
## Sessions in a phone app (local auth)
|
|
1042
|
+
|
|
1043
|
+
A Capacitor app's screens load from the app itself (`capacitor://localhost`
|
|
1044
|
+
on iOS, `https://localhost` on Android), not from the server's site, so its
|
|
1045
|
+
requests carry no cookies. It keeps its own session instead, and the server
|
|
1046
|
+
accepts both kinds:
|
|
1047
|
+
|
|
1048
|
+
- **What makes a request an app's:** `x-jskit-client: app`, from one of the
|
|
1049
|
+
app origins: Capacitor's two, plus the comma-separated `AUTH_APP_ORIGINS`.
|
|
1050
|
+
Any other origin is refused (403, `auth.app.originRefused`). An app's
|
|
1051
|
+
request takes no CSRF token, since it sends no cookie, and is signed in only
|
|
1052
|
+
by its access token in `Authorization: Bearer`. CORS answers the app origins
|
|
1053
|
+
alone, never with credentials.
|
|
1054
|
+
- **Signing in:** a sign-in from an app answers its tokens in the body,
|
|
1055
|
+
`appSession: { accessToken, refreshToken, expiresIn }`, instead of setting
|
|
1056
|
+
cookies. The access token lives 15 minutes, as a browser's does.
|
|
1057
|
+
- **Refreshing:** `POST /api/session/app/refresh { refreshToken }` answers
|
|
1058
|
+
new tokens. The refresh token rotates on every use; a spent one presented
|
|
1059
|
+
again means a copy is in other hands, so the whole session is revoked.
|
|
1060
|
+
- **Signing out:** `POST /api/session/app/revoke { refreshToken }` ends the
|
|
1061
|
+
session. `auth-web`'s sign-out does it, then forgets the tokens.
|
|
1062
|
+
|
|
1063
|
+
Streams, sockets, images, downloads and frames sign in with a single-use
|
|
1064
|
+
ticket (`POST /api/session/ticket`) or a signed link (`POST
|
|
1065
|
+
/api/session/link`), on the web and in an app alike; `client-features.md`'s
|
|
1066
|
+
"Streams, sockets and signed links" shows the helpers. Signed links are signed
|
|
1067
|
+
with `AUTH_LINK_SECRET`; staging and production without it sign none (503,
|
|
1068
|
+
`auth.link.unconfigured`), and development and tests make a key per process.
|
|
1069
|
+
A frame's signed link to `/api/session/frame?to=<path>` starts the frame's own
|
|
1070
|
+
session (a `frame` session, in `SameSite=None; Secure; Partitioned` cookies,
|
|
1071
|
+
lasting no longer than the session that asked), then redirects to `path`.
|
|
1072
|
+
|
|
1073
|
+
On the phone, `auth-web` does this for every HTTP client on the page (through
|
|
1074
|
+
`http-runtime`'s `configureAppCredentials`): the access token stays in memory,
|
|
1075
|
+
the refresh token goes to the Keychain (iOS) or the Keystore (Android) through
|
|
1076
|
+
`@capgo/capacitor-native-biometric` (^9), which the app installs, and a refused
|
|
1077
|
+
request refreshes once and goes again. With
|
|
1078
|
+
`config.mobile.auth.biometricUnlock: true`, the stored token is itself behind
|
|
1079
|
+
Face ID, Touch ID or the Android biometric prompt; a cancelled prompt shows the
|
|
1080
|
+
sign-in screen and keeps the session. A web page is unchanged: cookies and
|
|
1081
|
+
CSRF, as below.
|
|
1082
|
+
|
|
1083
|
+
## Sign in with Apple and sign-in on the phone (local auth)
|
|
1084
|
+
|
|
1085
|
+
**Sign in with Apple** sits beside Google, Microsoft and GitHub, first in the
|
|
1086
|
+
list, and an app in the App Store that offers another social sign-in must offer
|
|
1087
|
+
it too (App Store guideline 4.8). Four settings turn it on, together:
|
|
1088
|
+
|
|
1089
|
+
- `AUTH_APPLE_CLIENT_ID`: the Services ID;
|
|
1090
|
+
- `AUTH_APPLE_TEAM_ID`;
|
|
1091
|
+
- `AUTH_APPLE_KEY_ID`;
|
|
1092
|
+
- `AUTH_APPLE_PRIVATE_KEY`: the `.p8` key's text, whose line breaks may be
|
|
1093
|
+
written `\n`.
|
|
1094
|
+
|
|
1095
|
+
Some but not all of them stops startup. Local auth signs a fresh ES256 client
|
|
1096
|
+
secret for each token request, so no secret expires. Register two addresses
|
|
1097
|
+
with Apple:
|
|
1098
|
+
|
|
1099
|
+
- `<APP_PUBLIC_URL>/api/oauth/apple/callback` as the return URL. Apple answers
|
|
1100
|
+
there by `form_post`, and the route sends the browser on to `/auth/login`,
|
|
1101
|
+
which completes the sign-in as for any provider.
|
|
1102
|
+
- `<APP_PUBLIC_URL>/api/oauth/apple/notifications` for server-to-server
|
|
1103
|
+
notifications. When the person stops using Sign in with Apple for the app,
|
|
1104
|
+
their sessions end; when they delete their Apple account, Apple is also
|
|
1105
|
+
unlinked.
|
|
1106
|
+
|
|
1107
|
+
Apple shares the person's name only on the first sign-in, and local auth keeps
|
|
1108
|
+
it then. A private relay address (`@privaterelay.appleid.com`) is the
|
|
1109
|
+
account's email.
|
|
1110
|
+
|
|
1111
|
+
**Inside a phone app**, sign-in never uses the browser's cookies:
|
|
1112
|
+
|
|
1113
|
+
- **Apple and Google** sign in from the phone's own sheet when the app
|
|
1114
|
+
installs `@capgo/capacitor-social-login@^9.0.0`, initialized from
|
|
1115
|
+
`config.mobile.auth.socialLogin`. The app asks
|
|
1116
|
+
`POST /api/session/app/native-nonce` for a nonce, the sheet signs in with it,
|
|
1117
|
+
and `POST /api/session/app/native-sign-in` checks the sheet's identity token:
|
|
1118
|
+
Apple's or Google's keys, the issuer, the token's age, the nonce (Apple may
|
|
1119
|
+
send its SHA-256) and the audience. Allowed audiences are
|
|
1120
|
+
`AUTH_APPLE_CLIENT_ID` plus the bundle ids in `AUTH_APPLE_APP_AUDIENCES`, and
|
|
1121
|
+
`AUTH_GOOGLE_CLIENT_ID` plus the ids in `AUTH_GOOGLE_APP_AUDIENCES`. The
|
|
1122
|
+
sheet only collects; the server decides who signed in. A nonce works once,
|
|
1123
|
+
within ten minutes.
|
|
1124
|
+
- **Every other provider** starts in JSON from the app: the start route answers
|
|
1125
|
+
the provider's address and an attempt key, which the app holds instead of a
|
|
1126
|
+
cookie. The provider opens in the system browser, its return opens the app
|
|
1127
|
+
again through the app's links (`config.mobile.auth.appLinkDomains`), and the
|
|
1128
|
+
completion sends the key back. An attempt completes once.
|
|
1129
|
+
|
|
1130
|
+
Either way the answer carries the app's tokens, as in
|
|
1131
|
+
[Sessions in a phone app](#sessions-in-a-phone-app-local-auth).
|
|
1132
|
+
|
|
1041
1133
|
## Browser boundary
|
|
1042
1134
|
|
|
1043
1135
|
`@jskit-ai/auth-web` owns the normal auth views, guard runtime, sign-out flow,
|
|
@@ -616,6 +616,71 @@ watch(() => query.data.value, (payload) => { form.prompt = payload.prompt; });
|
|
|
616
616
|
|
|
617
617
|
## Helpers and sizes
|
|
618
618
|
|
|
619
|
+
### Server paths
|
|
620
|
+
|
|
621
|
+
**Every call and address on the app's own server goes through `http-web`: its
|
|
622
|
+
HTTP client for requests, and `serverUrl(path)` for anything else that names a
|
|
623
|
+
server path (a link, an image, a download).** On the web `serverUrl` returns the
|
|
624
|
+
path as it is; inside a Capacitor app, whose screens load from the app itself,
|
|
625
|
+
it joins the path to `config.mobile.apiBaseUrl`. It refuses a relative path and
|
|
626
|
+
another site's address.
|
|
627
|
+
|
|
628
|
+
Why: a bundled app's page is not on the server's site, so a bare `"/api/..."`
|
|
629
|
+
reaches nothing there, and only one resolver knows where the server is.
|
|
630
|
+
|
|
631
|
+
```js
|
|
632
|
+
// good
|
|
633
|
+
import { serverUrl } from "@jskit-ai/http-web/client";
|
|
634
|
+
const href = serverUrl(`/api/invoices/${id}/pdf`);
|
|
635
|
+
|
|
636
|
+
// bad: works on the web, reaches nothing inside the app
|
|
637
|
+
const href = `/api/invoices/${id}/pdf`;
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
### Streams, sockets and signed links
|
|
641
|
+
|
|
642
|
+
**What cannot send the page's credentials signs in another way, through
|
|
643
|
+
`http-web`: `openEventStream(path)` and `openWebSocket(path)` for a stream,
|
|
644
|
+
`signedUrl(path, { ttl })` for an address, and `frameUrl(path)` for a frame.**
|
|
645
|
+
An `EventSource`, a `WebSocket`, an `<img>`, a download and an `<iframe>` send
|
|
646
|
+
no `Authorization` header, and inside a Capacitor app no cookie either.
|
|
647
|
+
|
|
648
|
+
- `openEventStream(path)` and `openWebSocket(path)` ask `POST
|
|
649
|
+
/api/session/ticket` for a ticket (purpose `events` or `socket`: single use,
|
|
650
|
+
30 seconds, carrying the page's credentials, an app's token or the browser's
|
|
651
|
+
cookies), connect to `serverUrl(path)` with it in `jskit_ticket`, and keep
|
|
652
|
+
the connection open: a dropped one reconnects with a fresh ticket after a
|
|
653
|
+
delay that doubles up to 30 seconds, at once when the page comes back (an
|
|
654
|
+
app's resume, a tab shown again, the network back). Each answers `on(event,
|
|
655
|
+
handler)`, whose listeners stay across reconnections and which returns the
|
|
656
|
+
function that stops, `connection` (the open one, or null), and `close()`;
|
|
657
|
+
the socket's `send(data)` answers false while it reconnects. Signed out, a
|
|
658
|
+
stream goes without a ticket, as a public one does. Tickets live in the
|
|
659
|
+
server's process, so a deployment of several servers routes a stream to the
|
|
660
|
+
server that issued its ticket (sticky routing).
|
|
661
|
+
- `signedUrl(path, { ttl })` asks `POST /api/session/link` for a link to that
|
|
662
|
+
server path, signed (HMAC) for this session and user: 5 minutes, at most an
|
|
663
|
+
hour (`ttl` in seconds). It opens that path alone, by GET, and only while the
|
|
664
|
+
session lives; the server checks it before the route's own authorization.
|
|
665
|
+
- `frameUrl(path)` is the signed link for a frame showing one of the server's
|
|
666
|
+
pages: it starts the frame's own session, in cookies a frame inside another
|
|
667
|
+
site's page keeps (`SameSite=None`, `Secure`, `Partitioned`), lasting no
|
|
668
|
+
longer than the session that asked, then goes on to `path`.
|
|
669
|
+
|
|
670
|
+
Why: a token in an address is in every log that keeps the address; a ticket is
|
|
671
|
+
spent the moment it is used, and a signed link opens one path for minutes.
|
|
672
|
+
|
|
673
|
+
```js
|
|
674
|
+
// good
|
|
675
|
+
import { openEventStream, signedUrl } from "@jskit-ai/http-web/client";
|
|
676
|
+
const stream = openEventStream(`/api/imports/${id}/events`);
|
|
677
|
+
const stop = stream.on("message", (event) => progress.push(JSON.parse(event.data)));
|
|
678
|
+
const src = await signedUrl(`/api/photos/${id}`);
|
|
679
|
+
|
|
680
|
+
// bad: signs in on the web only, and its retry never gets a new ticket
|
|
681
|
+
const source = new EventSource(`/api/imports/${id}/events`);
|
|
682
|
+
```
|
|
683
|
+
|
|
619
684
|
### One helper per package
|
|
620
685
|
|
|
621
686
|
**A pure helper exists once in a package and is imported; one the kernel owns
|
|
@@ -51,7 +51,9 @@ The rules it applies are in [Typed features](/guide/framework/typed-features),
|
|
|
51
51
|
states once.
|
|
52
52
|
- `jskit test --list` prints the files a run takes and their total, and runs
|
|
53
53
|
nothing: the total matches the test files under `tests/`, or a file is named
|
|
54
|
-
so that node's default pattern leaves it out.
|
|
54
|
+
so that node's default pattern leaves it out. `npm run verify --list [files]`
|
|
55
|
+
does the same for the whole Verification
|
|
56
|
+
([A check runs once per tree](/guide/framework/typed-features#a-check-runs-once-per-tree)).
|
|
55
57
|
- `jskit test` starts by saying how many files it runs at a time and where that
|
|
56
58
|
number came from (the host's `V64_TEST_CONCURRENCY`, else half the CPUs), and
|
|
57
59
|
ends with its 10 slowest files and tests; each file's time is kept in
|
|
@@ -1500,6 +1500,18 @@ that is interrupted, or a tree or input that changed while it ran. Words after
|
|
|
1500
1500
|
such a run checks part of the suite, so it neither reads nor writes a pass. A
|
|
1501
1501
|
fresh `npm ci` empties the records; each machine keeps its own.
|
|
1502
1502
|
|
|
1503
|
+
`npm run verify --list [files]` (or `jskit verify --list [files]`) runs
|
|
1504
|
+
nothing, not even the JSKIT check: it prints the files `npm run verify --
|
|
1505
|
+
[files]` would run, one per line, then `Total: <n> file(s)`, as
|
|
1506
|
+
`jskit test --list` does, so a host can see that a check of named files runs
|
|
1507
|
+
exactly them before sending it anywhere. It lists the part the files go to,
|
|
1508
|
+
the last that runs, as in a run: a `jskit test …` part as `jskit test --list`
|
|
1509
|
+
does (a script that runs a glob lists the glob's files beside the named ones),
|
|
1510
|
+
a `playwright test` part with Playwright's own `--list`. The parts before it
|
|
1511
|
+
(lint, checks) take no files and are not listed. It exits 2, saying why, for an
|
|
1512
|
+
option among the files, a file that part doesn't take, or that part being one
|
|
1513
|
+
that can't list its files (any other script), which it never runs.
|
|
1514
|
+
|
|
1503
1515
|
A CI run installs everything afresh, so its record is an artifact GitHub keeps,
|
|
1504
1516
|
named for the project's tree and the commits of the other repositories the run
|
|
1505
1517
|
checks out. `jskit verify-pass` is the run's first step: it names the pass,
|
package/guide/agent/index.md
CHANGED
|
@@ -75,6 +75,7 @@ apply or adapt. It does not prescribe an agent host or project orchestrator.
|
|
|
75
75
|
|
|
76
76
|
- [Mobile Capacitor](/guide/app-extras/mobile-capacitor)
|
|
77
77
|
- [Realtime](/guide/app-extras/realtime)
|
|
78
|
+
- [Push Notifications](/guide/app-extras/push-notifications)
|
|
78
79
|
- [Assistant](/guide/app-extras/assistant)
|
|
79
80
|
- [Embeddable assistant conversations](/guide/app-extras/assistant-conversation)
|
|
80
81
|
- [Voice conversations](/guide/app-extras/assistant-voice)
|
|
@@ -98,6 +98,28 @@ one:
|
|
|
98
98
|
- **Client, documents:** a file input whose `FormData` goes through the app's
|
|
99
99
|
JSKIT HTTP client, which sends a `FormData` body as it is; the list of
|
|
100
100
|
attachments is an ordinary `useList()` or CRUD list.
|
|
101
|
+
- **Inside a phone app** (an app built with
|
|
102
|
+
[Mobile Capacitor](/guide/app-extras/mobile-capacitor)), the same fields take
|
|
103
|
+
files from the phone's own sources. `@jskit-ai/uploads-runtime`'s
|
|
104
|
+
`UploadsNativeSourceProvider` gives the page its `uploads.nativeSource`:
|
|
105
|
+
the camera and the system photo picker (`@capacitor/camera`, no full library
|
|
106
|
+
permission), document scanning (`@capgo/capacitor-document-scanner`) and the
|
|
107
|
+
document picker (`@capgo/capacitor-file-picker`), each present only when the
|
|
108
|
+
app installed its plugin (^9). An image field's runtime answers them as
|
|
109
|
+
`nativeSources` (`"camera"`, `"photos"`, `"scan"`, `"files"`); offer a button
|
|
110
|
+
for each that calls `pickFrom(source)`, which adds the chosen files to the
|
|
111
|
+
same Uppy, so its type, size and count checks, the editor and the upload are
|
|
112
|
+
the web's. A document field calls `getNativeSource().pick(source, { accept,
|
|
113
|
+
multiple })` and puts the `File` objects it answers into its `FormData`.
|
|
114
|
+
The app's `Info.plist` names why it uses the camera
|
|
115
|
+
(`NSCameraUsageDescription`). Uploads go through JSKIT's HTTP client, so they
|
|
116
|
+
carry the app's session.
|
|
117
|
+
- **Shared into the app:** with `@capgo/capacitor-share-target`, what another
|
|
118
|
+
app shares (Android's `SEND` intent; on iOS, the
|
|
119
|
+
[share extension pattern](/patterns/mobile/ios-share-extension)) waits in
|
|
120
|
+
`mobile-capacitor`'s share inbox (`client.mobile-share-in`), which opens the
|
|
121
|
+
app's page at `config.mobile.shareIn.path`. That page calls `takeShared()`
|
|
122
|
+
once and hands `files` to its upload field.
|
|
101
123
|
- **Refusals** carry their field error from `buildUploadFieldError`, shown
|
|
102
124
|
beside the control; a lost connection is reported through JSKIT's request
|
|
103
125
|
recovery.
|
|
@@ -122,4 +144,5 @@ and never against a real bucket: tests use `JSKIT_STORAGE_DRIVER=memory`.
|
|
|
122
144
|
|
|
123
145
|
- The bucket and its access key for staging and production when the app runs
|
|
124
146
|
on more than one server.
|
|
125
|
-
- Uploading real photos from their own phones
|
|
147
|
+
- Uploading real photos from their own phones: the camera, the photo picker,
|
|
148
|
+
a scan, the document picker, and sharing a photo and a PDF into the app.
|
|
@@ -118,9 +118,12 @@ changes.
|
|
|
118
118
|
|
|
119
119
|
## Technical details
|
|
120
120
|
|
|
121
|
-
JSKIT has no installable-app
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
JSKIT has no installable-app package. Push notifications come from
|
|
122
|
+
`@jskit-ai/push-core` and `@jskit-ai/push-web`
|
|
123
|
+
([Push notifications](/guide/app-extras/push-notifications)): the device
|
|
124
|
+
registry, the keys, sending, the settings section and JSKIT's service worker.
|
|
125
|
+
Everything else below that this page does not name as JSKIT's is the app's own
|
|
126
|
+
code, built on the JSKIT owners it links.
|
|
124
127
|
|
|
125
128
|
### 1. Manifest and icons
|
|
126
129
|
|
|
@@ -150,8 +153,12 @@ JSKIT owners it links.
|
|
|
150
153
|
|
|
151
154
|
### 2. Service worker (`/sw.js`, scope `/`, `Service-Worker-Allowed: /`)
|
|
152
155
|
|
|
153
|
-
-
|
|
154
|
-
|
|
156
|
+
- The site has one service worker. Push comes from JSKIT's, `/jskit-sw.js`
|
|
157
|
+
(served by `push-web`), which shows notifications and caches nothing. This
|
|
158
|
+
app's own worker, for its offline page and cached build files, is written by
|
|
159
|
+
hand in `public/sw.js`, loads JSKIT's first with
|
|
160
|
+
`importScripts("/jskit-sw.js")`, and is the one registered:
|
|
161
|
+
`config.push.serviceWorker: "/sw.js"`. It follows the rules in
|
|
155
162
|
[Development modules and service-worker caching](/guide/app-setup/initial-scaffolding#development-modules-and-service-worker-caching).
|
|
156
163
|
Register it only from a production build. The server sends `/sw.js` with
|
|
157
164
|
`Service-Worker-Allowed: /` and without long caching.
|
|
@@ -173,8 +180,9 @@ JSKIT owners it links.
|
|
|
173
180
|
installed, JSKIT's own client update offer still asks the person to reload
|
|
174
181
|
when a new build is served
|
|
175
182
|
([Client updates](/guide/app-extras/realtime#client-updates)).
|
|
176
|
-
- A notification click
|
|
177
|
-
|
|
183
|
+
- A notification click opens **only the app's own pages**, never another site
|
|
184
|
+
or scheme: JSKIT's worker does it, focus-existing first (it focuses an open
|
|
185
|
+
window of the app and tells it the page, or opens one).
|
|
178
186
|
- Browser tests that intercept scripts with `page.route` run with Playwright's
|
|
179
187
|
`test.use({ serviceWorkers: "block" })`, because the worker answers built
|
|
180
188
|
files itself.
|
|
@@ -220,33 +228,31 @@ JSKIT owners it links.
|
|
|
220
228
|
|
|
221
229
|
### 5. Push notifications (server)
|
|
222
230
|
|
|
223
|
-
- **
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
`
|
|
227
|
-
(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
- **Packages:** install `@jskit-ai/push-core` and `@jskit-ai/push-web` and run
|
|
232
|
+
`npm run db:migrate`. `push-core` owns the device registry
|
|
233
|
+
(`push_devices`, at most 20 a person, the oldest going) and each person's
|
|
234
|
+
settings (`push_settings`: kinds switched off, show text, quiet hours and
|
|
235
|
+
time zone), and sends with `push.send()`. Never write these tables, the
|
|
236
|
+
VAPID handling or the endpoint checks again in the app.
|
|
237
|
+
- **Keys:** `PUSH_VAPID_PUBLIC_KEY`, `PUSH_VAPID_PRIVATE_KEY` and
|
|
238
|
+
`PUSH_VAPID_SUBJECT`, generated once with `npx web-push generate-vapid-keys`,
|
|
239
|
+
named in the project's environment contract and `.env.example` without
|
|
240
|
+
values, and kept as each deployment's own secrets. Without them web push is
|
|
241
|
+
off and Settings says so.
|
|
242
|
+
- **The app's kinds:** `config.push.kinds` lists **results**, **waiting** and
|
|
243
|
+
**messages** with their labels; each is a `kind` of `push.send()`, which
|
|
244
|
+
skips a person who switched it off or is in their quiet hours.
|
|
245
|
+
- **Queue (the app's own):** `push_queue`: workspace (or the scope unread is
|
|
246
|
+
counted in), user, chat, kind, message, send_after, claimed_at. One table
|
|
247
|
+
resource (`defineTableResource`), owned by one feature, created by an
|
|
248
|
+
add-only Knex migration
|
|
235
249
|
([Data access, Layer 1](/guide/framework/data-access#layer-1-the-table-resource)).
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
last sent, failures. At most 20 a person, the oldest going.
|
|
241
|
-
- `push_settings`: user, per-kind switches, show_text, quiet_from and
|
|
242
|
-
quiet_to, time_zone. One row a person who changed theirs.
|
|
243
|
-
- `push_queue`: workspace (or the scope unread is counted in), user, chat,
|
|
244
|
-
kind, message, send_after, claimed_at.
|
|
245
|
-
- **Queueing:** beside the code that marks messages unread, insert one queue
|
|
246
|
-
row per person the message concerns: the other person in a one-person or
|
|
247
|
-
direct chat, the mentioned people and the person the background work was for
|
|
248
|
-
in a room, never the author, never anyone who muted the chat. One
|
|
250
|
+
Beside the code that marks messages unread, insert one queue row per person
|
|
251
|
+
the message concerns: the other person in a one-person or direct chat, the
|
|
252
|
+
mentioned people and the person the background work was for in a room,
|
|
253
|
+
never the author, never anyone who muted the chat. One
|
|
249
254
|
`createMany(rows, options)` per write, not one insert per person.
|
|
255
|
+
`send_after` is 15 seconds later.
|
|
250
256
|
- **Sweep:** a feature with a `systemScope` whose `boot()` starts the timer
|
|
251
257
|
(`setInterval(runOnce, 5000).unref()`) and whose `shutdown()` stops it and
|
|
252
258
|
awaits a run in progress; tests call `runOnce()` itself. JSKIT ships no
|
|
@@ -256,11 +262,11 @@ JSKIT owners it links.
|
|
|
256
262
|
holds ([Layer 4: locks](/guide/framework/data-access#layer-4-locks)), batch
|
|
257
263
|
after batch until a batch comes back short (at most about 20 batches): one
|
|
258
264
|
batch of 100 a tick falls minutes behind a burst of 250. Per row: skip it if
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
pairs, never a capped cross-product narrowed in code
|
|
265
|
+
the message is read by now. Fold a person's rows for one chat into one
|
|
266
|
+
notification about the newest message at the most pressing kind. Claim exact
|
|
267
|
+
(person, chat) pairs, never a capped cross-product narrowed in code
|
|
263
268
|
([Narrow in the query](/guide/framework/data-access#narrow-in-the-query)).
|
|
269
|
+
Then one `push.send()` per folded notification.
|
|
264
270
|
- **Queue rows carry their workspace id** to the sweep. A sweep that reads it
|
|
265
271
|
as `undefined` sends nothing at all, and a test stand-in that reads ids
|
|
266
272
|
differently from the real table resource hides it: test on the real handle on
|
|
@@ -268,41 +274,26 @@ JSKIT owners it links.
|
|
|
268
274
|
([Doubles use documented seams](/guide/framework/typed-features#doubles-use-documented-seams)).
|
|
269
275
|
- A direct message's title is **the other person's** name, both ways round;
|
|
270
276
|
test it with both orders of the two people's ids.
|
|
271
|
-
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
`
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
- **Sign-out forgets this browser's device:** a signed-in
|
|
292
|
-
`POST /api/push/devices/forget { endpoint }` (a locked delete by address
|
|
293
|
-
and person), then unsubscribe in the browser, waiting at most 3 s.
|
|
294
|
-
Otherwise the next person on a shared browser gets the last person's
|
|
295
|
-
notifications. JSKIT has no step before sign-out: the app's own
|
|
296
|
-
`src/views/auth/SignOutView.vue` (from the
|
|
297
|
-
[auth surface pattern](/patterns/auth/auth-surface)) runs both steps first
|
|
298
|
-
and renders `DefaultSignOutView`, which signs out as it mounts, only after
|
|
299
|
-
them. While they run it shows a pending card ("Signing you out"); offline
|
|
300
|
-
it says so and **Try again** retries both steps.
|
|
301
|
-
- **Routes**, `auth: "required"`, each running an action on the caller's own
|
|
302
|
-
rows: get settings, devices and the public key; put settings; add device;
|
|
303
|
-
delete device; forget device. Test them through `app.inject` signed out
|
|
304
|
-
(401), without CSRF (403), as another member (404) and with malformed input
|
|
305
|
-
(400) ([Security pass](/guide/framework/security-pass#try-each-refusal)).
|
|
277
|
+
- What `push.send()` gets: the chat's title, the kind, the short text (which
|
|
278
|
+
`push-core` leaves out for a person who hides text), the chat's URL, the
|
|
279
|
+
unread count as `badge` (counted per person **and workspace**, matching what
|
|
280
|
+
the open app shows), and `group: "chat-<id>"`, so a newer one replaces the
|
|
281
|
+
last.
|
|
282
|
+
- What `push-core` does for every send: a few statements whatever the number of
|
|
283
|
+
devices; ten devices at a time; a 404 or 410 forgets the device, and so do 5
|
|
284
|
+
consecutive failures; outside production it logs with `logSideEffect()` as a
|
|
285
|
+
"push notification" instead of sending.
|
|
286
|
+
- **What `push-core` refuses, which the app's tests still try:** a browser
|
|
287
|
+
endpoint that is not a known push service's (400; localhost, metadata IPs and
|
|
288
|
+
internal hosts included); another person's browser subscription without its
|
|
289
|
+
own keys (409); a body that is not a JSON object (400); a signed-out call
|
|
290
|
+
(401), one without CSRF (403) and another member's device (404)
|
|
291
|
+
([Security pass](/guide/framework/security-pass#try-each-refusal)).
|
|
292
|
+
- **Sign-out forgets this browser's device:** `push-web` adds the step to every
|
|
293
|
+
sign-out (`addSignOutStep` in `@jskit-ai/auth-web`): it forgets the device on
|
|
294
|
+
the server while the session holds, then unsubscribes in the browser, waiting
|
|
295
|
+
at most 3 s. A failure stops the sign-out: `DefaultSignOutView` shows its
|
|
296
|
+
error ("offline", in the app's words) with **Try again**, which retries.
|
|
306
297
|
|
|
307
298
|
### 6. Sharing in
|
|
308
299
|
|
|
@@ -320,16 +311,18 @@ JSKIT owners it links.
|
|
|
320
311
|
|
|
321
312
|
### 7. Settings and permission (client)
|
|
322
313
|
|
|
323
|
-
- A **Notifications**
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
314
|
+
- A **Notifications** section in the account settings: place `push-web`'s
|
|
315
|
+
`push.web.settings.section` at `account-settings:sections` with
|
|
316
|
+
`value: "push"`
|
|
317
|
+
([Push notifications](/guide/app-extras/push-notifications#the-client)). It
|
|
318
|
+
shows Material skeleton rows while it loads, **Try again** on failure, this
|
|
319
|
+
device on or off, the kinds, text shown or not, quiet hours and the devices.
|
|
320
|
+
Add a **Send a test notification** button beside it that shows one on the
|
|
321
|
+
device itself through the worker, everywhere.
|
|
322
|
+
- Permission is asked only by `usePushClient().enable()`, from those controls
|
|
323
|
+
or the one-time offer. Explain a refusal. `push-web` replaces a browser's old
|
|
324
|
+
subscription when the server's key changed, instead of reusing it. When the
|
|
325
|
+
push service doesn't answer, say why, in the same words in both places.
|
|
333
326
|
- Text comes through `useJskitText()` and the app's message keys
|
|
334
327
|
([Translation](/guide/framework/translation)).
|
|
335
328
|
|
|
@@ -358,7 +351,8 @@ real push service. Each fix is seen failing first.
|
|
|
358
351
|
- **Server tests** (`jskit test`, on `TEST_DB_NAME`): own rows only; folding
|
|
359
352
|
per chat; the 15-second read check; quiet hours across midnight in the
|
|
360
353
|
person's zone; muted chats; kinds switched off; 410 forgets a device;
|
|
361
|
-
production-only sending (
|
|
354
|
+
production-only sending (`push.send()` with `APP_ENV: "production"` and a
|
|
355
|
+
stubbed `fetch`);
|
|
362
356
|
the endpoint allow-list and device takeover refusals; sign-out forget; the
|
|
363
357
|
direct-message title both ways round. Query counts must be **equal** at two
|
|
364
358
|
sizes with `expectFlatQueries()` from `@jskit-ai/resource-runtime/test`
|
|
@@ -31,7 +31,8 @@ takes real money."
|
|
|
31
31
|
Then say: "There are other options if you want to discuss." They are Paddle
|
|
32
32
|
instead of Stripe (Paddle sells as the merchant of record and handles sales
|
|
33
33
|
tax), prepaid top-ups that add credit to a balance, usage credits debited per
|
|
34
|
-
operation, and in-app purchases in
|
|
34
|
+
operation, and in-app purchases in the App Store and Google Play for an app built
|
|
35
|
+
with Mobile Capacitor, which grant into the same plans and credits (below).
|
|
35
36
|
|
|
36
37
|
## Product decisions (defaults)
|
|
37
38
|
|
|
@@ -129,6 +130,31 @@ one:
|
|
|
129
130
|
- **Top-ups**, when chosen: `topUps` in the configuration, `PaymentTopUp`, and
|
|
130
131
|
`checkout.topUp` and `checkout.confirmTopUp` with the app's own
|
|
131
132
|
`credit` function, as the README's "Prepaid top-ups" shows.
|
|
133
|
+
- **Store apps**, when chosen: the web keeps paying through its provider, and
|
|
134
|
+
the iPhone and Android apps pay through the stores, as Apple and Google
|
|
135
|
+
require for digital goods. `@jskit-ai/store-purchases-core` (server) and
|
|
136
|
+
`@jskit-ai/store-purchases-web` (in the app, over `@capgo/native-purchases`)
|
|
137
|
+
grant into the same `payments-core` accounts, so a subject has one balance
|
|
138
|
+
and one access check whatever it bought through:
|
|
139
|
+
- Declare each store product at `extensions.storePurchases` beside
|
|
140
|
+
`extensions.payments`, with the same grant as its web counterpart (a plan,
|
|
141
|
+
or a number of credits), whatever its store price; the store keeps 15–30%,
|
|
142
|
+
which the store price covers, never the grant.
|
|
143
|
+
- Provide `store-purchases.billing` with the payment service and
|
|
144
|
+
configuration, the products document, `merchantScope(environment)` and the
|
|
145
|
+
same `authorize` as the web checkout (`action: "checkout"` before a
|
|
146
|
+
purchase, `"reconcile"` for importing reports).
|
|
147
|
+
- A purchase counts only once the store's own server confirms it, carrying a
|
|
148
|
+
purchase intent this server issued for that product and account. It is
|
|
149
|
+
recorded once in the money ledger and granted once.
|
|
150
|
+
- A store refund takes the grant back even when it was spent: the balance
|
|
151
|
+
goes negative (`payments.revokeGrant`), later grants pay it off first, and
|
|
152
|
+
every debit is refused meanwhile. Decide what else the app does on
|
|
153
|
+
`storePurchases.refunded` (block spending, tell the person, contact them).
|
|
154
|
+
- Reconcile the ledger monthly with the stores' financial reports
|
|
155
|
+
(`jskit store-purchases reconcile`), as the package's
|
|
156
|
+
`docs/reconciliation.md` shows; `docs/sandbox-and-test-tracks.md` sets up
|
|
157
|
+
the stores' test environments.
|
|
132
158
|
|
|
133
159
|
## Proof
|
|
134
160
|
|
|
@@ -154,3 +180,6 @@ and never against Stripe itself.
|
|
|
154
180
|
signing secret, the customer portal's settings, and tax registration.
|
|
155
181
|
- One real test-mode payment end to end on a deployed staging app, then the
|
|
156
182
|
live keys in production only.
|
|
183
|
+
- Store apps: the App Store Connect and Play Console products, keys and
|
|
184
|
+
notification addresses, sandbox and license testers, and a sandbox purchase,
|
|
185
|
+
restore and refund on real phones.
|
package/package.json
CHANGED
|
@@ -17,7 +17,8 @@ config.mobile = {
|
|
|
17
17
|
auth: {
|
|
18
18
|
callbackPath: "/auth/login",
|
|
19
19
|
customScheme: "",
|
|
20
|
-
appLinkDomains: []
|
|
20
|
+
appLinkDomains: [],
|
|
21
|
+
biometricUnlock: false
|
|
21
22
|
},
|
|
22
23
|
android: {
|
|
23
24
|
packageName: "",
|
|
@@ -25,6 +26,13 @@ config.mobile = {
|
|
|
25
26
|
targetSdk: 37,
|
|
26
27
|
versionCode: 1,
|
|
27
28
|
versionName: "1.0.0"
|
|
29
|
+
},
|
|
30
|
+
ios: {
|
|
31
|
+
bundleId: "",
|
|
32
|
+
appStoreId: "",
|
|
33
|
+
deploymentTarget: "16.0",
|
|
34
|
+
version: "1.0.0",
|
|
35
|
+
build: 1
|
|
28
36
|
}
|
|
29
37
|
};
|
|
30
38
|
config.surfaceDefinitions = {};
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@local/main": "0.1.0",
|
|
36
36
|
"@fastify/static": "^10.1.3",
|
|
37
|
-
"@jskit-ai/kernel": "0.2.
|
|
37
|
+
"@jskit-ai/kernel": "0.2.41",
|
|
38
38
|
"@jskit-ai/material-web": "0.1.20",
|
|
39
39
|
"@tanstack/vue-query": "^5.101.0",
|
|
40
40
|
"fastify": "^5.12.7",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"vue": "^3.5.44",
|
|
45
45
|
"vue-router": "^5.3.1",
|
|
46
46
|
"vuetify": "^4.3.0",
|
|
47
|
-
"@jskit-ai/http-runtime": "0.2.
|
|
47
|
+
"@jskit-ai/http-runtime": "0.2.42",
|
|
48
48
|
"@fastify/fast-json-stringify-compiler": "^5.1.0",
|
|
49
49
|
"@vue/devtools-api": "^8.2.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@jskit-ai/config-eslint": "0.1.257",
|
|
53
|
-
"@jskit-ai/jskit-catalog": "0.2.
|
|
53
|
+
"@jskit-ai/jskit-catalog": "0.2.150",
|
|
54
54
|
"@playwright/test": "1.61.1",
|
|
55
55
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
56
56
|
"eslint": "^10.8.0",
|
|
@@ -17,7 +17,8 @@ config.mobile = {
|
|
|
17
17
|
auth: {
|
|
18
18
|
callbackPath: "/auth/login",
|
|
19
19
|
customScheme: "",
|
|
20
|
-
appLinkDomains: []
|
|
20
|
+
appLinkDomains: [],
|
|
21
|
+
biometricUnlock: false
|
|
21
22
|
},
|
|
22
23
|
android: {
|
|
23
24
|
packageName: "",
|
|
@@ -25,6 +26,13 @@ config.mobile = {
|
|
|
25
26
|
targetSdk: 37,
|
|
26
27
|
versionCode: 1,
|
|
27
28
|
versionName: "1.0.0"
|
|
29
|
+
},
|
|
30
|
+
ios: {
|
|
31
|
+
bundleId: "",
|
|
32
|
+
appStoreId: "",
|
|
33
|
+
deploymentTarget: "16.0",
|
|
34
|
+
version: "1.0.0",
|
|
35
|
+
build: 1
|
|
28
36
|
}
|
|
29
37
|
};
|
|
30
38
|
config.surfaceDefinitions = {};
|