@sparkvault/sdk-mobile 8.0.5 → 9.0.0

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.
Files changed (46) hide show
  1. package/README.md +84 -115
  2. package/dist/app-sdk/content-conflict.d.ts +54 -0
  3. package/dist/app-sdk/content-conflict.js +57 -0
  4. package/dist/app-sdk/content-conflict.js.map +1 -0
  5. package/dist/app-sdk/email-address.d.ts +28 -0
  6. package/dist/app-sdk/email-address.js +8 -1
  7. package/dist/app-sdk/email-address.js.map +1 -1
  8. package/dist/app-sdk/ids.d.ts +14 -0
  9. package/dist/app-sdk/ids.js +24 -4
  10. package/dist/app-sdk/ids.js.map +1 -1
  11. package/dist/app-sdk/platform-domains.d.ts +22 -5
  12. package/dist/app-sdk/platform-domains.js +28 -9
  13. package/dist/app-sdk/platform-domains.js.map +1 -1
  14. package/dist/app-sdk/upload-publication.d.ts +20 -6
  15. package/dist/app-sdk/upload-publication.js +20 -6
  16. package/dist/app-sdk/upload-publication.js.map +1 -1
  17. package/dist/config.d.ts +6 -4
  18. package/dist/config.js.map +1 -1
  19. package/dist/errors.d.ts +8 -6
  20. package/dist/errors.js +8 -6
  21. package/dist/errors.js.map +1 -1
  22. package/dist/ingots.js +8 -4
  23. package/dist/ingots.js.map +1 -1
  24. package/dist/notify.d.ts +15 -11
  25. package/dist/notify.js +6 -4
  26. package/dist/notify.js.map +1 -1
  27. package/dist/notify.test-d.d.ts +12 -7
  28. package/dist/notify.test-d.js +12 -7
  29. package/dist/notify.test-d.js.map +1 -1
  30. package/dist/tus.d.ts +19 -16
  31. package/dist/tus.js +26 -22
  32. package/dist/tus.js.map +1 -1
  33. package/dist/types.d.ts +25 -12
  34. package/package.json +1 -1
  35. package/src/app-sdk/content-conflict.js +61 -0
  36. package/src/app-sdk/email-address.js +9 -1
  37. package/src/app-sdk/ids.js +28 -4
  38. package/src/app-sdk/platform-domains.js +30 -9
  39. package/src/app-sdk/upload-publication.js +21 -6
  40. package/src/config.ts +6 -4
  41. package/src/errors.ts +8 -6
  42. package/src/ingots.ts +10 -4
  43. package/src/notify.test-d.ts +16 -10
  44. package/src/notify.ts +15 -11
  45. package/src/tus.ts +38 -32
  46. package/src/types.ts +25 -12
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SparkVault Mobile SDK
2
2
 
3
- Mobile SDK for SparkVault Identity, vault, folder, and ingot workflows.
3
+ `@sparkvault/sdk-mobile` is SparkVault's SDK for React Native and Expo apps: Identity login with a native sign-in dialog, the SparkVault Core session, and vault, folder and encrypted ingot workflows over Forge.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,40 +8,54 @@ Mobile SDK for SparkVault Identity, vault, folder, and ingot workflows.
8
8
  npm install @sparkvault/sdk-mobile
9
9
  ```
10
10
 
11
+ - Runtime dependency: `tweetnacl` (Ed25519 verification of Identity tokens). Peers: `react` and `react-native`, for the dialog (`@sparkvault/sdk-mobile/identity-dialog`).
12
+
11
13
  ## Create a Client
12
14
 
13
15
  ```typescript
14
16
  import * as FileSystem from 'expo-file-system/legacy';
15
- import { createSparkVaultMobileClient } from '@sparkvault/sdk-mobile';
17
+ import { createSparkVaultMobileClient, SparkVaultTimeoutError } from '@sparkvault/sdk-mobile';
18
+
19
+ function abortError(): Error {
20
+ const error = new Error('Download cancelled');
21
+ error.name = 'AbortError';
22
+ return error;
23
+ }
16
24
 
17
25
  export const sparkVault = createSparkVaultMobileClient({
18
- tokenStorage,
19
- apiBaseUrl: 'https://api.sparkvault.com/v1',
20
- identityBaseUrl: 'https://auth.sparkvault.com',
26
+ tokenStorage, // your TokenStorageAdapter over the OS keystore
21
27
  identityAccountId: 'acc_00000000000000000000000000000000',
22
- userAgent: 'SparkVault/1.0.0 (Mobile)',
23
- fetch: xhrFetch,
28
+ userAgent: 'MyApp/1.0.0 (Mobile)',
24
29
  fileReader: {
25
30
  readAsBase64: (fileUri, { position, length }) =>
26
- FileSystem.readAsStringAsync(fileUri, {
27
- encoding: 'base64',
28
- position,
29
- length,
30
- }),
31
+ FileSystem.readAsStringAsync(fileUri, { encoding: 'base64', position, length }),
31
32
  },
32
33
  fileDownloader: {
34
+ // The contract: an abort rejects with an Error named AbortError, a timeout
35
+ // with SparkVaultTimeoutError, and the response's status is reported.
33
36
  download: async (url, fileUri, options) => {
34
- const resumable = FileSystem.createDownloadResumable(
35
- url,
36
- fileUri,
37
- {},
38
- progress => options?.onProgress?.({
37
+ if (options?.abortSignal?.aborted) throw abortError();
38
+ const resumable = FileSystem.createDownloadResumable(url, fileUri, {}, (progress) =>
39
+ options?.onProgress?.({
39
40
  bytesWritten: progress.totalBytesWritten,
40
41
  bytesTotal: progress.totalBytesExpectedToWrite || undefined,
41
42
  })
42
43
  );
43
- const result = await resumable.downloadAsync();
44
- return result ? { uri: result.uri, status: result.status, headers: result.headers } : null;
44
+ let timedOut = false;
45
+ const stop = () => { resumable.pauseAsync().catch(() => undefined); };
46
+ const timer = options?.timeoutMs
47
+ ? setTimeout(() => { timedOut = true; stop(); }, options.timeoutMs)
48
+ : undefined;
49
+ options?.abortSignal?.addEventListener('abort', stop, { once: true });
50
+ try {
51
+ const result = await resumable.downloadAsync();
52
+ if (timedOut) throw new SparkVaultTimeoutError('Download timed out');
53
+ if (options?.abortSignal?.aborted) throw abortError();
54
+ return result ? { uri: result.uri, status: result.status, headers: result.headers } : null;
55
+ } finally {
56
+ clearTimeout(timer);
57
+ options?.abortSignal?.removeEventListener('abort', stop);
58
+ }
45
59
  },
46
60
  getInfo: async (fileUri) => {
47
61
  const info = await FileSystem.getInfoAsync(fileUri);
@@ -52,41 +66,39 @@ export const sparkVault = createSparkVaultMobileClient({
52
66
  });
53
67
  ```
54
68
 
55
- ### Dependency contract
69
+ | Adapter | Needed for | Without it |
70
+ |---------|------------|------------|
71
+ | `tokenStorage` | Every client | `createSparkVaultMobileClient` throws |
72
+ | `identityAccountId` | Every client (a SparkVault account id, `acc_…`) | `createSparkVaultMobileClient` throws |
73
+ | `fetch` | Optional | The runtime's `fetch`; a request throws when there is none |
74
+ | `fileReader` | `ingots.uploadFromUri`, `replaceFromUri`, `resumeUpload` | The call throws before any request to Forge; `uploadFromUri` and `replaceFromUri` have already staged the upload on the server |
75
+ | `fileDownloader` | `ingots.downloadToFile` | `downloadToFile` throws before any request |
76
+ | `backgroundTransfer`, `backgroundUploader` | Optional: uploads with `transport: 'background'` | Those uploads stream over XHR |
77
+ | `isOnline` / `onOnline` | Optional; both or neither (one alone throws at construction) | An upload request that gets no answer offline spends its retries |
78
+ | `logger` | Optional | A no-op logger |
56
79
 
57
- The SDK depends on `tweetnacl` for Ed25519 Identity JWT verification and declares `react`/`react-native` as peer dependencies for the optional native Identity dialog. Platform behavior stays behind adapters so the SDK is portable across React Native runtimes.
58
-
59
- | Adapter | Required | Default if omitted |
60
- |---------|----------|--------------------|
61
- | `tokenStorage` | Yes | Throws at client construction |
62
- | `identityAccountId` | Yes (a SparkVault account id, `acc_…`, by the platform's resource-id grammar) | Throws at client construction |
63
- | `fetch` | No | Falls back to `globalThis.fetch`; throws if neither exists |
64
- | `fileReader` | Only for `ingots.uploadFromUri` | Throws on first upload-from-URI call |
65
- | `fileDownloader` | Only for `ingots.downloadToFile` | Throws on first file-download call |
66
- | `logger` | No | No-op logger |
80
+ - `apiBaseUrl` includes `/v1` (default `https://api.sparkvault.com/v1`). Every option, its default and the adapter contract: [Expo Setup](https://sparkvault.com/api/docs/sdk-mobile/#expo-setup).
67
81
 
68
82
  ## Modules
69
83
 
70
- - `products.identity`: Identity Product config, OTP/passkey login, JWKS/JWT verification, second-factor submission, and post-login backup/recommendation flows.
71
- - `account`: First-party Core session — Identity-token exchange, signup completion, profile, and account APIs.
72
- - `vaults`: Vault CRUD, unseal, ending one session (`endSession`) or every session (`seal`), sharing, access retention, and upload portal/widget settings.
73
- - `folders`: Folder CRUD, lookup by path (`findByPath`), breadcrumbs, folder moves, and ingot moves.
74
- - `ingots`: List/search/get, URI streaming upload/replace, rename/delete/move, sharing, read-only audit logs, SDK-managed file downloads, and the discrete `createUpload` (Forge upload URL + token) / `createDownloadLink` primitives.
75
- - `health`: Root API availability checks.
76
- - `sparks`: SparkSync ephemeral secrets — list/get/create/delete (a link spark, `contentType` `text/uri-list`, is created and listed with its x.sv link, `link_url`, and a read answers the name its payload saves under, `download_filename`) and SparkLink sharing (`share`/`getShare`/`unshare`, and `resendInvite` for an invite-only link's invitation).
77
- - `entropy`: HSM-backed entropy generation (`generate`, `generateBytes`), and `drawFirstParty` for the signed-in app's own working values (`POST /v1/entropy/first-party`: a SparkVault session's draw, never plan- or bandwidth-gated or recorded as the account's usage).
78
- - `notify`: The signed-in user's metadata-only notifications inbox (`getInbox`, `getUnreadCount`, `markState`, `markAllState`, `markAllRead`) and Expo device push registration (`registerDevice`, `unregisterDeviceToken`, `unregisterDevice`).
79
- - `billing`: Subscription status and usage, and native in-app purchase receipt validation.
80
- - `users`: Account member management — list, invite, remove, and resend an invite.
84
+ | Module | What it does | Reference |
85
+ |--------|--------------|-----------|
86
+ | `products.identity` | Identity config, one-time-code sign-in, token verification, the passkey APIs, the post-login steps | [Native Identity Login](https://sparkvault.com/api/docs/sdk-mobile/#use-case-login) |
87
+ | `account` | The SparkVault member session, and the member's own profile and account | [Member Sessions](https://sparkvault.com/api/docs/sdk-mobile/#member-sessions) |
88
+ | `users` | The organization's members, for an admin | [Modules](https://sparkvault.com/api/docs/sdk-mobile/#modules) |
89
+ | `vaults` | Vault lifecycle, unseal and seal, sharing, upload settings | [Vault Management](https://sparkvault.com/api/docs/sdk-mobile/#use-case-vault) |
90
+ | `folders` | Folders within a vault, lookup by path (`findByPath`), and ingot moves | [Modules](https://sparkvault.com/api/docs/sdk-mobile/#modules) |
91
+ | `ingots` | Encrypted file upload, replace and download over Forge, listing, sharing, access logs | [Upload, Download, Replace](https://sparkvault.com/api/docs/sdk-mobile/#use-case-transfer) |
92
+ | `sparks` | Read-once secrets and their SparkLinks: a link spark (`contentType` `text/uri-list`) is created and listed with its x.sv link (`link_url`), and a read answers the name its payload saves under (`download_filename`) | [Modules](https://sparkvault.com/api/docs/sdk-mobile/#modules) |
93
+ | `entropy` | Server-generated random values | [Modules](https://sparkvault.com/api/docs/sdk-mobile/#modules) |
94
+ | `notify` | SparkVault's own inbox and Expo push, for a person signed in to SparkVault itself | [Modules](https://sparkvault.com/api/docs/sdk-mobile/#modules) |
95
+ | `billing` | The subscription, and in-app purchase validation | [Modules](https://sparkvault.com/api/docs/sdk-mobile/#modules) |
96
+ | `health` | API availability | [Health Checks](https://sparkvault.com/api/docs/sdk-mobile/#health-checks) |
97
+
98
+ `products.identity` and `health` need no session. Every other module acts as a signed-in SparkVault member, but for the two `account` calls that start the session (`exchangeIdentityToken`, `completeSignup`). Every method's signature: the package's types (`dist/index.d.ts`).
81
99
 
82
100
  ## Identity Dialog
83
101
 
84
- `SparkVaultIdentityDialog` is the mobile equivalent of the web SDK Identity popup. It fetches Identity Product config, derives email/phone input from enabled delivery methods, offers the enabled one-time-code methods (`otp_email`, `otp_sms`, `otp_voice`), applies configured branding and light/dark mode, and returns the raw signed Identity JWT plus JWKS metadata. Input reads as a phone number only when it has no `@` and holds phone characters only, so an email that starts with a digit (`2024user@gmail.com`) signs in by email; while email is enabled the field keeps the email keyboard. Configured branding drives the header: a logo replaces the company name and is drawn at its own proportions; without one (or if it fails to load) the header shows the company lettermark and name. The optional `title` heads the identity step ("Sign in" when omitted), so a host whose dialog also starts new accounts can say so, for example "Sign in or create an account".
85
-
86
- Sign-in is code-only. The native passkey ceremony does not work in the mobile app, so the dialog never offers `passkey` even when the tenant has it enabled; `products.identity` still exposes the passkey APIs for a host that drives the ceremony itself.
87
-
88
- The identity field takes focus as the dialog opens and the keyboard's Go sends the code. It stays editable through the send, dropping what is typed meanwhile, so the keyboard carries straight on to the code field. The code field then takes focus with the `one-time-code` content type (the platform's code AutoFill) and verifies the moment its sixth digit lands, once per code; a refused code empties it and gives it focus back. "Use a different email" (or phone number) returns to the identity field. Each opening starts idle, even while the host is still handling an earlier opening's `onSuccess`.
89
-
90
102
  ```tsx
91
103
  import { SparkVaultIdentityDialog } from '@sparkvault/sdk-mobile/identity-dialog';
92
104
 
@@ -95,25 +107,21 @@ import { SparkVaultIdentityDialog } from '@sparkvault/sdk-mobile/identity-dialog
95
107
  visible={visible}
96
108
  onCancel={() => setVisible(false)}
97
109
  onSuccess={async (result) => {
110
+ // A device-side check; your backend verifies the token again before trusting it.
98
111
  await sparkVault.products.identity.verifyIdentityToken(result.token, { jwks: result.jwks });
99
- const session = await sparkVault.account.exchangeIdentityToken(result.token);
100
- // Continue only after local verification and Core exchange succeed.
112
+ await signInWithYourBackend(result.token); // your own auth endpoint
113
+ setVisible(false);
101
114
  }}
102
115
  />;
103
116
  ```
104
117
 
105
- Client-side JWT verification is an app integrity gate. Third-party backends must still verify the token server-side with the JWKS endpoint and key product records by the returned `svid` (`sub` is also the SVID for managed Identity tokens).
106
-
107
- `exchangeIdentityToken()` is for SparkVault Core mobile sessions. Third-party mobile apps that use SparkVault Identity as their login provider should either verify the Identity JWT server-side and issue their own app session keyed by `svid`, or use the OIDC authorization-code flow with PKCE. Native apps must keep refresh tokens in OS secure storage; browser-only `HttpOnly` cookie guidance applies to web/BFF deployments.
118
+ - Sign-in is one-time code only (`otp_email`, `otp_sms`, `otp_voice`): the dialog never offers `passkey`, even when the account enables it.
119
+ - A person with two-factor authentication on cannot finish in the dialog: `verifyOtp` throws the challenge (`statusCode` 401, `data: { second_factor_required, ticket, methods }`), which the dialog shows as an error and passes to `onError`. Collect the code and call `products.identity.submitSecondFactor({ ticket, code })`.
120
+ - Your backend verifies the token itself (its signature, `iss`, `aud`, `exp`, and `token_purpose` `identity_verification`), keys records by its `svid` and issues your app's session: the device-side check is an app integrity gate, never proof to your server.
121
+ - `account.exchangeIdentityToken` turns a sign-in into a SparkVault member session, as SparkVault's own app does: the API takes only a token SparkVault's own Identity account issued, and refuses any other with 401 `AUTHENTICATION_ERROR`.
122
+ - The dialog's behavior and `verifyIdentityToken`'s checks: [Native Identity Login](https://sparkvault.com/api/docs/sdk-mobile/#use-case-login); the member session: [SparkVault Member Sessions](https://sparkvault.com/api/docs/sdk-mobile/#member-sessions).
108
123
 
109
- ## Health Check
110
-
111
- ```typescript
112
- const status = await sparkVault.health.check();
113
- const online = await sparkVault.health.isOnline();
114
- ```
115
-
116
- ## Ingot Upload
124
+ ## Ingot Upload and Download
117
125
 
118
126
  ```typescript
119
127
  const session = await sparkVault.vaults.unseal(vaultId, { vmk });
@@ -128,66 +136,27 @@ await sparkVault.ingots.uploadFromUri({
128
136
  onProgress: (uploaded, total) => console.log(uploaded / total),
129
137
  });
130
138
 
131
- let attemptedUploadId: string | undefined;
132
- await sparkVault.ingots.replaceFromUri({
133
- vaultId,
134
- ingotId,
135
- vat: session.vat,
136
- fileUri,
137
- fileSize,
138
- contentType: 'application/pdf', // optional; omitted, Core keeps the ingot's stored type
139
- expectedContentVersion, // the content_version the replacement was built from
140
- onSessionCreated: (upload) => { attemptedUploadId = upload.uploadId; },
141
- });
142
- ```
143
-
144
- A read-modify-write passes `expectedContentVersion` (the `content_version` the
145
- replacement was built from, `null` for content stored without one); Core
146
- refuses a stale one with a 412. The next replace names the publication this one
147
- produced, the session's `uploadId` (Forge acknowledges the final chunk only once the
148
- upload published); the result's `content_version` is what the read after the
149
- transfer found, which a later writer's publication can already have replaced. A replace sends `name` only to rename the
150
- ingot: omitted, Core keeps the stored name, so a rename made elsewhere stands,
151
- and the result's `name` is the name the ingot is stored under. Omitted,
152
- `contentType` keeps the ingot's stored type too, and Core reads one from the
153
- name by its extension only when the stored type is `application/octet-stream`
154
- or unparsable.
155
-
156
- `onSessionCreated` hands over the Forge session once it exists, with its
157
- `uploadId`: the `content_version` the ingot reads once that upload publishes.
158
- An upload that fails with its last answer lost (the final PATCH's, or the read
159
- after it) may still have published; the ingot's `content_version` reading the
160
- `uploadId` says it did.
161
-
162
- A cancel (`abortSignal`, with the default `abortBehavior` `terminate`) gives
163
- the upload up: Forge drops its chunks, and `uploadFromUri` ends the upload
164
- with the file its create made. An upload given up any other way ends the same
165
- way through `endUpload({ vaultId, vat, upload })`, given the placement
166
- `onIngotCreated` hands over (or `createUpload`'s result), which names the
167
- upload the create staged (`uploadId`): Core deletes the ingot only while it is
168
- still that upload's unfinished file, and the call resolves `deleted` (the file
169
- is gone) or `kept` (this end deleted nothing: the upload published it, a later
170
- upload took it over, or the create did not make it), and a read by id shows it
171
- as it is.
172
-
173
- Uploads use Forge with tus v1.0.0 and read file chunks through the configured
174
- `fileReader` adapter. Generated content should be staged to a file URI first so
175
- all uploads use the same streaming path.
176
-
177
- ## Ingot Download
178
-
179
- ```typescript
180
- const result = await sparkVault.ingots.downloadToFile({
139
+ const downloaded = await sparkVault.ingots.downloadToFile({
181
140
  vaultId,
182
141
  ingotId,
183
142
  vat: session.vat,
184
143
  fileUri: cacheFileUri,
185
144
  expectedSizeBytes,
186
- onProgress: (downloaded, total) => console.log(downloaded / total),
145
+ onProgress: (written, total) => console.log(written / total),
187
146
  });
188
147
  ```
189
148
 
190
- Downloads use the configured `fileDownloader` adapter for one canonical
191
- streaming path across every supported file size. Production adapters should
192
- honor `abortSignal` and `timeoutMs`, and should throw on transport failure
193
- instead of writing an error response as a successful file.
149
+ - Uploads use Forge's tus v1.0.0: chunks sent over XHR are read through `fileReader`, while the background adapters (`backgroundTransfer`, `backgroundUploader`) read the file at `fileUri` themselves. Stage generated content to a file URI first, so every upload takes the same streaming path. Downloads stream through `fileDownloader` for every file size.
150
+ - A cancel (`abortSignal`, with the default `abortBehavior` `terminate`) gives the upload up: Forge drops its chunks, and `uploadFromUri` ends the upload with the file its create made. An upload given up any other way ends the same way through `endUpload({ vaultId, vat, upload })`, given the placement `onIngotCreated` hands over (or `createUpload`'s result), which names the upload the create staged (`uploadId`): Core deletes the ingot only while it is still that upload's unfinished file, and the call resolves `deleted` (the file is gone) or `kept` (this end deleted nothing: the upload published it, a later upload took it over, or the create did not make it).
151
+ - `downloadToFile` deletes the file when it refuses an answer or a cancel lands during an attempt, but leaves what the adapter wrote when the adapter rejects (a transport failure, a timeout): once `downloadToFile` rejects, delete what is left at `fileUri`.
152
+ - Transfers: [Upload, Download, Replace](https://sparkvault.com/api/docs/sdk-mobile/#use-case-transfer); the error classes: [Errors](https://sparkvault.com/api/docs/sdk-mobile/#errors). Resume, cancellation, the retry budget and the download rules: in the monorepo, `docs/SDK.md` → Mobile Vault and Ingot Transfer.
153
+
154
+ ## Links
155
+
156
+ - [Mobile SDK reference](https://sparkvault.com/api/docs/sdk-mobile/)
157
+ - [npm package](https://www.npmjs.com/package/@sparkvault/sdk-mobile)
158
+ - In the `Spark-Vault/platform` monorepo: the design, `docs/SDK.md` → Mobile SDK; the release, `.github/workflows/deploy-sdk-mobile.yml` (`docs/INFRASTRUCTURE.md` → GitHub Actions Workflows).
159
+
160
+ ## License
161
+
162
+ Proprietary (`package.json` `license`: `PROPRIETARY`).
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The content conflict a Core error answer names, or null when it is not one.
3
+ *
4
+ * @param {{ statusCode?: number, details?: { reason?: unknown } }} error - An
5
+ * error as parsed from a Core response (status plus the body's `details`)
6
+ * @returns {string|null} One of CONTENT_CONFLICT_REASONS, or null
7
+ */
8
+ export function contentConflictReason(error: {
9
+ statusCode?: number;
10
+ details?: {
11
+ reason?: unknown;
12
+ };
13
+ }): string | null;
14
+ /**
15
+ * Why Core refused a change to a file or a folder with 409 CONFLICT: the
16
+ * `details.reason` each such refusal carries, and the one reading of it
17
+ * clients share. One status and one code answer all of them, so the reason is
18
+ * what tells them apart. A refusal's message is prose for a person, and Core
19
+ * logs it, so it names no file or folder: no client reads one.
20
+ *
21
+ * NAME_HELD the destination already holds the name: a file's
22
+ * folder, or a folder's parent. A create its policy
23
+ * refused over the file holding the name describes
24
+ * that file beside it (`ingot_id`, `status`,
25
+ * `size_bytes`)
26
+ * CHANGED_CONCURRENTLY another request changed the file or folder first (a
27
+ * rename, a move, an upload landing, a race for the
28
+ * same name): read it again and retry
29
+ * DESTINATION_CHANGED another request moved the folder a move targets
30
+ * FOLDER_DELETING a folder the change places content into, moves
31
+ * content out of, or changes is being deleted:
32
+ * `folder_id` names it and `role` the part it plays
33
+ * (FOLDER_DELETING_ROLES)
34
+ *
35
+ * Core imports these constants to stamp them, and every client that branches
36
+ * on them imports the same ones. Browser-safe: no imports.
37
+ */
38
+ export const CONTENT_CONFLICT_REASONS: Readonly<{
39
+ NAME_HELD: "NAME_HELD";
40
+ CHANGED_CONCURRENTLY: "CHANGED_CONCURRENTLY";
41
+ DESTINATION_CHANGED: "DESTINATION_CHANGED";
42
+ FOLDER_DELETING: "FOLDER_DELETING";
43
+ }>;
44
+ /**
45
+ * The part a folder being deleted plays in the change it refuses
46
+ * (`details.role` of FOLDER_DELETING): `target`, the folder the change places
47
+ * content into, or one that folder lies inside; `source`, the folder a move
48
+ * takes content out of; `folder`, the folder the change is to.
49
+ */
50
+ export const FOLDER_DELETING_ROLES: Readonly<{
51
+ TARGET: "target";
52
+ SOURCE: "source";
53
+ FOLDER: "folder";
54
+ }>;
@@ -0,0 +1,57 @@
1
+ // GENERATED FILE — do not edit by hand.
2
+ // Source of truth: packages/app-sdk/src/content-conflict.js
3
+ // Regenerate with: pnpm --filter @sparkvault/sdk-mobile build
4
+ /**
5
+ * Why Core refused a change to a file or a folder with 409 CONFLICT: the
6
+ * `details.reason` each such refusal carries, and the one reading of it
7
+ * clients share. One status and one code answer all of them, so the reason is
8
+ * what tells them apart. A refusal's message is prose for a person, and Core
9
+ * logs it, so it names no file or folder: no client reads one.
10
+ *
11
+ * NAME_HELD the destination already holds the name: a file's
12
+ * folder, or a folder's parent. A create its policy
13
+ * refused over the file holding the name describes
14
+ * that file beside it (`ingot_id`, `status`,
15
+ * `size_bytes`)
16
+ * CHANGED_CONCURRENTLY another request changed the file or folder first (a
17
+ * rename, a move, an upload landing, a race for the
18
+ * same name): read it again and retry
19
+ * DESTINATION_CHANGED another request moved the folder a move targets
20
+ * FOLDER_DELETING a folder the change places content into, moves
21
+ * content out of, or changes is being deleted:
22
+ * `folder_id` names it and `role` the part it plays
23
+ * (FOLDER_DELETING_ROLES)
24
+ *
25
+ * Core imports these constants to stamp them, and every client that branches
26
+ * on them imports the same ones. Browser-safe: no imports.
27
+ */
28
+ export const CONTENT_CONFLICT_REASONS = Object.freeze({
29
+ NAME_HELD: 'NAME_HELD',
30
+ CHANGED_CONCURRENTLY: 'CHANGED_CONCURRENTLY',
31
+ DESTINATION_CHANGED: 'DESTINATION_CHANGED',
32
+ FOLDER_DELETING: 'FOLDER_DELETING'
33
+ });
34
+ /**
35
+ * The part a folder being deleted plays in the change it refuses
36
+ * (`details.role` of FOLDER_DELETING): `target`, the folder the change places
37
+ * content into, or one that folder lies inside; `source`, the folder a move
38
+ * takes content out of; `folder`, the folder the change is to.
39
+ */
40
+ export const FOLDER_DELETING_ROLES = Object.freeze({
41
+ TARGET: 'target',
42
+ SOURCE: 'source',
43
+ FOLDER: 'folder'
44
+ });
45
+ const REASONS = new Set(Object.values(CONTENT_CONFLICT_REASONS));
46
+ /**
47
+ * The content conflict a Core error answer names, or null when it is not one.
48
+ *
49
+ * @param {{ statusCode?: number, details?: { reason?: unknown } }} error - An
50
+ * error as parsed from a Core response (status plus the body's `details`)
51
+ * @returns {string|null} One of CONTENT_CONFLICT_REASONS, or null
52
+ */
53
+ export function contentConflictReason(error) {
54
+ const reason = error?.details?.reason;
55
+ return error?.statusCode === 409 && typeof reason === 'string' && REASONS.has(reason) ? reason : null;
56
+ }
57
+ //# sourceMappingURL=content-conflict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-conflict.js","sourceRoot":"","sources":["../../src/app-sdk/content-conflict.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,4DAA4D;AAC5D,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,SAAS,EAAE,WAAW;IACtB,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;IAC1C,eAAe,EAAE,iBAAiB;CACnC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAK;IACzC,MAAM,MAAM,GAAG,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC;IACtC,OAAO,KAAK,EAAE,UAAU,KAAK,GAAG,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACxG,CAAC"}
@@ -22,6 +22,34 @@ export function emailAddressProblem(value: any): string | null;
22
22
  * @returns {boolean}
23
23
  */
24
24
  export function isValidEmailAddress(value: any): boolean;
25
+ /**
26
+ * The one email-address grammar: the addresses SparkVault can deliver to, so
27
+ * the only ones a front door may accept. A door that took an address the
28
+ * email transport then refuses answers its caller with a success while the
29
+ * recipient gets nothing (a Notify send, a SparkLink invite, a share), so the
30
+ * accepting doors and the transport ask this one question.
31
+ *
32
+ * An address is read in its canonical form (trimmed, lowercased) and is valid
33
+ * when it has an RFC 5322 dot-atom-text local part in ASCII, exactly one `@`,
34
+ * a domain of at least two labels of letters, digits and inner hyphens, and
35
+ * fits the RFC 5321 lengths (address 320, local part 64, domain 255).
36
+ *
37
+ * The canonical form is also the one every stored email key is spelled in:
38
+ * Identity's directory normalizes an email identifier through
39
+ * canonicalEmailAddress, and Core keys its account and login-claim rows and
40
+ * compares a signed-in address through it, so one spelling of an address
41
+ * finds every row another spelling wrote.
42
+ *
43
+ * Pure and import-free, so every runtime that decides deliverability loads it
44
+ * alike.
45
+ */
46
+ /**
47
+ * The characters an RFC 5322 dot-atom local part holds, in its canonical
48
+ * (lowercase) form, as the body of a character class: the one set the
49
+ * grammar below accepts and the log mask (./pii-mask.js) reads an address in
50
+ * text by.
51
+ */
52
+ export const EMAIL_LOCAL_PART_CHARACTERS: "a-z0-9.!#$%&'*+/=?^_`{|}~-";
25
53
  /** RFC 5321 length limits, in characters. */
26
54
  export const EMAIL_ADDRESS_LIMITS: Readonly<{
27
55
  ADDRESS: 320;
@@ -22,7 +22,14 @@
22
22
  * Pure and import-free, so every runtime that decides deliverability loads it
23
23
  * alike.
24
24
  */
25
- const LOCAL_PART = /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/;
25
+ /**
26
+ * The characters an RFC 5322 dot-atom local part holds, in its canonical
27
+ * (lowercase) form, as the body of a character class: the one set the
28
+ * grammar below accepts and the log mask (./pii-mask.js) reads an address in
29
+ * text by.
30
+ */
31
+ export const EMAIL_LOCAL_PART_CHARACTERS = "a-z0-9.!#$%&'*+/=?^_`{|}~-";
32
+ const LOCAL_PART = new RegExp(`^[${EMAIL_LOCAL_PART_CHARACTERS}]+$`);
26
33
  const DOMAIN_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
27
34
  /** RFC 5321 length limits, in characters. */
28
35
  export const EMAIL_ADDRESS_LIMITS = Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"email-address.js","sourceRoot":"","sources":["../../src/app-sdk/email-address.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,yDAAyD;AACzD,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,UAAU,GAAG,iCAAiC,CAAC;AACrD,MAAM,YAAY,GAAG,wCAAwC,CAAC;AAE9D,6CAA6C;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CA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oB,CAAC,OAAO;QAAE,OAAO,sBAAsB,CAAC,QAAQ,CAAC;IAC1F,IAAI,SAAS,CAAC,MAAM,GAAG,oBAAoB,CAAC,UAAU;QAAE,OAAO,sBAAsB,CAAC,mBAAmB,CAAC;IAC1G,IAAI,MAAM,CAAC,MAAM,GAAG,oBAAoB,CAAC,MAAM;QAAE,OAAO,sBAAsB,CAAC,eAAe,CAAC;IAC/F,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAK;IACvC,OAAO,mBAAmB,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AAC7C,CAAC"}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * The pattern an id of the given kind matches, as a regular-expression source
3
+ * string: its prefix, '_' and a body of the path-safe alphabet. A JSON Schema
4
+ * reads it as `pattern`, with `maxLength: RESOURCE_ID_MAX_LENGTH`.
5
+ *
6
+ * @param {string} kind - A key of RESOURCE_ID_PREFIXES
7
+ * @returns {string}
8
+ * @throws {TypeError} for a kind the grammar does not name: a misspelled kind
9
+ * would otherwise refuse every id without saying why
10
+ */
11
+ export function resourceIdPattern(kind: string): string;
1
12
  /**
2
13
  * Whether a value is an id of the given kind.
3
14
  *
@@ -31,6 +42,9 @@ export function isResourceId(value: unknown): boolean;
31
42
  *
32
43
  * - `isResourceIdOf(kind, value)`: an id of that kind.
33
44
  * - `isResourceId(value)`: an id of any kind, for a check that takes several.
45
+ * - `resourceIdPattern(kind)`: the same grammar as a regular-expression
46
+ * source, for a JSON Schema `pattern` beside `maxLength:
47
+ * RESOURCE_ID_MAX_LENGTH`, so a route schema and a check never disagree.
34
48
  *
35
49
  * Browser-safe and import-free: sdk-js bundles it, sdk-mobile mirrors it, and
36
50
  * the apps, the console and the mobile app import it.
@@ -17,6 +17,9 @@
17
17
  *
18
18
  * - `isResourceIdOf(kind, value)`: an id of that kind.
19
19
  * - `isResourceId(value)`: an id of any kind, for a check that takes several.
20
+ * - `resourceIdPattern(kind)`: the same grammar as a regular-expression
21
+ * source, for a JSON Schema `pattern` beside `maxLength:
22
+ * RESOURCE_ID_MAX_LENGTH`, so a route schema and a check never disagree.
20
23
  *
21
24
  * Browser-safe and import-free: sdk-js bundles it, sdk-mobile mirrors it, and
22
25
  * the apps, the console and the mobile app import it.
@@ -46,7 +49,26 @@ export const RESOURCE_ID_PREFIXES = Object.freeze({
46
49
  });
47
50
  /** The longest id, prefix included. */
48
51
  export const RESOURCE_ID_MAX_LENGTH = 128;
49
- const ID_BODY = /^[A-Za-z0-9_-]+$/;
52
+ /** The body every id carries after its prefix's underscore: the path-safe alphabet. */
53
+ const ID_BODY_SOURCE = '[A-Za-z0-9_-]+';
54
+ /**
55
+ * The pattern an id of the given kind matches, as a regular-expression source
56
+ * string: its prefix, '_' and a body of the path-safe alphabet. A JSON Schema
57
+ * reads it as `pattern`, with `maxLength: RESOURCE_ID_MAX_LENGTH`.
58
+ *
59
+ * @param {string} kind - A key of RESOURCE_ID_PREFIXES
60
+ * @returns {string}
61
+ * @throws {TypeError} for a kind the grammar does not name: a misspelled kind
62
+ * would otherwise refuse every id without saying why
63
+ */
64
+ export function resourceIdPattern(kind) {
65
+ if (!Object.hasOwn(RESOURCE_ID_PREFIXES, kind)) {
66
+ throw new TypeError(`No resource kind '${kind}'`);
67
+ }
68
+ return `^${RESOURCE_ID_PREFIXES[kind]}_${ID_BODY_SOURCE}$`;
69
+ }
70
+ /** Each kind's pattern, compiled once. */
71
+ const ID_PATTERNS = Object.freeze(Object.fromEntries(Object.keys(RESOURCE_ID_PREFIXES).map((kind) => [kind, new RegExp(resourceIdPattern(kind))])));
50
72
  /**
51
73
  * Whether a value is an id of the given kind.
52
74
  *
@@ -60,11 +82,9 @@ export function isResourceIdOf(kind, value) {
60
82
  if (!Object.hasOwn(RESOURCE_ID_PREFIXES, kind)) {
61
83
  throw new TypeError(`No resource kind '${kind}'`);
62
84
  }
63
- const prefix = `${RESOURCE_ID_PREFIXES[kind]}_`;
64
85
  return typeof value === 'string'
65
86
  && value.length <= RESOURCE_ID_MAX_LENGTH
66
- && value.startsWith(prefix)
67
- && ID_BODY.test(value.slice(prefix.length));
87
+ && ID_PATTERNS[kind].test(value);
68
88
  }
69
89
  const KINDS = Object.freeze(Object.keys(RESOURCE_ID_PREFIXES));
70
90
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/app-sdk/ids.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,+CAA+C;AAC/C,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IAChD,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,KAAK;IAClB,oBAAoB,EAAE,OAAO;IAC7B,qBAAqB,EAAE,OAAO;IAC9B,qBAAqB,EAAE,OAAO;IAC9B,kBAAkB,EAAE,OAAO;IAC3B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,MAAM;IACnB,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,KAAK;CACb,CAAC,CAAC;AAEH,uCAAuC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,IAAI,EAAE,KAAK;IACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,SAAS,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,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAK;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -1,10 +1,11 @@
1
1
  export function isSparkVaultOwnedHostname(hostname: any): boolean;
2
2
  /**
3
3
  * Whether a domain is SparkVault's, so no organization may claim it as its
4
- * own: every host the platform owns, and the help-desk domain with its whole
5
- * subtree. The help-desk domain is every custom help-desk domain's CNAME
6
- * target and the hosts under it are SparkVault's tenants', yet none of them
7
- * is trusted as a platform host.
4
+ * own: every host the platform owns, and each product mail domain with its
5
+ * whole subtree. The hosts under a product mail domain are SparkVault's
6
+ * tenants' addresses, and the help-desk domain is also every custom
7
+ * help-desk domain's CNAME target, yet none of them is trusted as a platform
8
+ * host.
8
9
  */
9
10
  export function isSparkVaultReservedDomain(hostname: any): boolean;
10
11
  export function sparkVaultPlatformSvOrigins(): string[];
@@ -15,7 +16,7 @@ export function sparkVaultWebSocketOrigins(): string[];
15
16
  * Keep platform domain decisions centralized: CSP, redirect safety, custom
16
17
  * domain reservation, and Identity postMessage trust all read this registry.
17
18
  * Trust follows the hosts the platform owns (isSparkVaultOwnedHostname);
18
- * reservation covers those and the help-desk domain's subtree
19
+ * reservation covers those and each product mail domain's subtree
19
20
  * (isSparkVaultReservedDomain), whose hosts are SparkVault's to hand out but
20
21
  * never trusted.
21
22
  */
@@ -42,6 +43,22 @@ export const SPARKVAULT_FILES_HOST: "files.sv";
42
43
  * trusted the way a platform host is (isSparkVaultOwnedHostname).
43
44
  */
44
45
  export const SPARKVAULT_HELP_DESK_DOMAIN: "help.sv";
46
+ /**
47
+ * Notify's mail domain: each organization's Notify mail goes from a host under
48
+ * it, as its help desk's goes from one under the help-desk domain. On the web
49
+ * its apex and www redirect to the Notify product page (the send.sv Worker,
50
+ * infra/cloudflare/send). Like the help-desk domain, its whole subtree is
51
+ * reserved and none of its hosts is owned.
52
+ */
53
+ export const SPARKVAULT_NOTIFY_SEND_DOMAIN: "send.sv";
54
+ /**
55
+ * The product mail domains: one SES identity each, under which every
56
+ * organization's address for that product is its own host
57
+ * (@sparkvault/app-sdk/mail-products). Every name in each one's subtree is
58
+ * reserved, so no organization claims another's address host as its own
59
+ * domain, and none is owned.
60
+ */
61
+ export const SPARKVAULT_PRODUCT_MAIL_DOMAINS: readonly string[];
45
62
  export const SPARKVAULT_PLATFORM_SV_HOSTS: readonly string[];
46
63
  /** The SparkVault console. */
47
64
  export const SPARKVAULT_APP_HOST: "app.sparkvault.com";