@sparkvault/sdk-mobile 8.0.6 → 9.0.1

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/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`).
@@ -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;IACx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C,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,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";
@@ -7,7 +7,7 @@
7
7
  * Keep platform domain decisions centralized: CSP, redirect safety, custom
8
8
  * domain reservation, and Identity postMessage trust all read this registry.
9
9
  * Trust follows the hosts the platform owns (isSparkVaultOwnedHostname);
10
- * reservation covers those and the help-desk domain's subtree
10
+ * reservation covers those and each product mail domain's subtree
11
11
  * (isSparkVaultReservedDomain), whose hosts are SparkVault's to hand out but
12
12
  * never trusted.
13
13
  */
@@ -34,12 +34,30 @@ export const SPARKVAULT_FILES_HOST = 'files.sv';
34
34
  * trusted the way a platform host is (isSparkVaultOwnedHostname).
35
35
  */
36
36
  export const SPARKVAULT_HELP_DESK_DOMAIN = 'help.sv';
37
+ /**
38
+ * Notify's mail domain: each organization's Notify mail goes from a host under
39
+ * it, as its help desk's goes from one under the help-desk domain. On the web
40
+ * its apex and www redirect to the Notify product page (the send.sv Worker,
41
+ * infra/cloudflare/send). Like the help-desk domain, its whole subtree is
42
+ * reserved and none of its hosts is owned.
43
+ */
44
+ export const SPARKVAULT_NOTIFY_SEND_DOMAIN = 'send.sv';
45
+ /**
46
+ * The product mail domains: one SES identity each, under which every
47
+ * organization's address for that product is its own host
48
+ * (@sparkvault/app-sdk/mail-products). Every name in each one's subtree is
49
+ * reserved, so no organization claims another's address host as its own
50
+ * domain, and none is owned.
51
+ */
52
+ export const SPARKVAULT_PRODUCT_MAIL_DOMAINS = Object.freeze([
53
+ SPARKVAULT_HELP_DESK_DOMAIN,
54
+ SPARKVAULT_NOTIFY_SEND_DOMAIN
55
+ ]);
37
56
  export const SPARKVAULT_PLATFORM_SV_HOSTS = Object.freeze([
38
57
  SPARKVAULT_AUTH_HOST,
39
58
  SPARKVAULT_LINKS_HOST,
40
59
  SPARKVAULT_FILES_HOST,
41
60
  'file.sv',
42
- 'send.sv',
43
61
  'spark.sv',
44
62
  'by.sv',
45
63
  'at.sv',
@@ -78,22 +96,23 @@ function isSparkVaultRootOrSubdomain(hostname) {
78
96
  function isSparkVaultPlatformSvHost(hostname) {
79
97
  return SPARKVAULT_PLATFORM_SV_HOSTS.includes(normalizeHostname(hostname));
80
98
  }
81
- function isSparkVaultHelpDeskDomainOrSubdomain(hostname) {
99
+ function isProductMailDomainOrSubdomain(hostname) {
82
100
  const normalized = normalizeHostname(hostname);
83
- return normalized === SPARKVAULT_HELP_DESK_DOMAIN || normalized.endsWith(`.${SPARKVAULT_HELP_DESK_DOMAIN}`);
101
+ return SPARKVAULT_PRODUCT_MAIL_DOMAINS.some((domain) => normalized === domain || normalized.endsWith(`.${domain}`));
84
102
  }
85
103
  export function isSparkVaultOwnedHostname(hostname) {
86
104
  return isSparkVaultRootOrSubdomain(hostname) || isSparkVaultPlatformSvHost(hostname);
87
105
  }
88
106
  /**
89
107
  * Whether a domain is SparkVault's, so no organization may claim it as its
90
- * own: every host the platform owns, and the help-desk domain with its whole
91
- * subtree. The help-desk domain is every custom help-desk domain's CNAME
92
- * target and the hosts under it are SparkVault's tenants', yet none of them
93
- * is trusted as a platform host.
108
+ * own: every host the platform owns, and each product mail domain with its
109
+ * whole subtree. The hosts under a product mail domain are SparkVault's
110
+ * tenants' addresses, and the help-desk domain is also every custom
111
+ * help-desk domain's CNAME target, yet none of them is trusted as a platform
112
+ * host.
94
113
  */
95
114
  export function isSparkVaultReservedDomain(hostname) {
96
- return isSparkVaultOwnedHostname(hostname) || isSparkVaultHelpDeskDomainOrSubdomain(hostname);
115
+ return isSparkVaultOwnedHostname(hostname) || isProductMailDomainOrSubdomain(hostname);
97
116
  }
98
117
  export function sparkVaultPlatformSvOrigins() {
99
118
  return SPARKVAULT_PLATFORM_SV_HOSTS.map((host) => `https://${host}`);
@@ -1 +1 @@
1
- {"version":3,"file":"platform-domains.js","sourceRoot":"","sources":["../../src/app-sdk/platform-domains.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,4DAA4D;AAC5D,8DAA8D;AAE9D;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEvD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAE9D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE5C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC;AAErD,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC;IACxD,oBAAoB;IACpB,qBAAqB;IACrB,qBAAqB;IACrB,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AAEH,8BAA8B;AAC9B,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAExD,sFAAsF;AACtF,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAE5D,MAAM,0BAA0B,GAAG,MAAM,C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AAC,CAAC;AACpG,CAAC;AAED,SAAS,0BAA0B,CAAC,QAAQ;IAC1C,OAAO,4BAA4B,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,8BAA8B,CAAC,QAAQ;IAC9C,MAAM,UAAU,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO,+BAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,KAAK,MAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC;AACtH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,QAAQ;IAChD,OAAO,2BAA2B,CAAC,QAAQ,CAAC,IAAI,0BAA0B,CAAC,QAAQ,CAAC,CAAC;AACvF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAAQ;IACjD,OAAO,yBAAyB,CAAC,QAAQ,CAAC,IAAI,8BAA8B,CAAC,QAAQ,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO,4BAA4B,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC"}
@@ -71,12 +71,13 @@ export function uploadTransferReference(istk: string): string;
71
71
  export function uploadTokenRevocationReason(record: Object | null | undefined): string | null;
72
72
  /**
73
73
  * The upload publication contract between Forge and Core's activation, and
74
- * the facts of a transfer token both services spell: its shape, the
75
- * publication it is bound to (a content version, and the one an ingot row
76
- * names), Core's revocation of an upload's token, and the refusals of Core's
77
- * a transfer's answer names (the header, and the lock of a vault scheduled
78
- * for deletion). Every client ends an upload it gives up by one rule here
79
- * too: the upload id its delete is conditioned on (givenUpUploadId).
74
+ * the facts of a transfer both services spell: its token's shape and the
75
+ * publication the token is bound to (a content version, and the one an ingot
76
+ * row names), its charge's ledger reference and category, Core's revocation
77
+ * of an upload's token, and the refusals of Core's a transfer's answer names
78
+ * (the header, and the lock of a vault scheduled for deletion). Every client
79
+ * ends an upload it gives up by one rule here too: the upload id its delete is
80
+ * conditioned on (givenUpUploadId).
80
81
  *
81
82
  * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
82
83
  * and on the final state it hands Core's activation (POST
@@ -116,6 +117,19 @@ export const ISTK_PATTERN: RegExp;
116
117
  * be unique to the token, never the whole bearer credential.
117
118
  */
118
119
  export const TRANSFER_REFERENCE_ISTK_CHARS: 24;
120
+ /**
121
+ * The usage-ledger category, and type, of a Forge transfer's charge, by
122
+ * direction. Every charge of one upload (Core's activation, Core's charge of
123
+ * an upload that never publishes, Forge's cancel) lands under the one
124
+ * reference uploadTransferReference names, so each spells its category from
125
+ * here, and the console counts both directions as the bandwidth the ledger
126
+ * measures. Each day's usage summary is keyed by category, so a category's
127
+ * spelling is the key its rows sum under.
128
+ */
129
+ export const TRANSFER_CHARGE_CATEGORIES: Readonly<{
130
+ UPLOAD: "Ingot Transfer - Forge Encryption";
131
+ DOWNLOAD: "Ingot Transfer - Forge Decryption";
132
+ }>;
119
133
  /**
120
134
  * The codes Core's activation refuses an upload with, which Forge's refusal
121
135
  * map reads (the status is Core's):
@@ -3,12 +3,13 @@
3
3
  // Regenerate with: pnpm --filter @sparkvault/sdk-mobile build
4
4
  /**
5
5
  * The upload publication contract between Forge and Core's activation, and
6
- * the facts of a transfer token both services spell: its shape, the
7
- * publication it is bound to (a content version, and the one an ingot row
8
- * names), Core's revocation of an upload's token, and the refusals of Core's
9
- * a transfer's answer names (the header, and the lock of a vault scheduled
10
- * for deletion). Every client ends an upload it gives up by one rule here
11
- * too: the upload id its delete is conditioned on (givenUpUploadId).
6
+ * the facts of a transfer both services spell: its token's shape and the
7
+ * publication the token is bound to (a content version, and the one an ingot
8
+ * row names), its charge's ledger reference and category, Core's revocation
9
+ * of an upload's token, and the refusals of Core's a transfer's answer names
10
+ * (the header, and the lock of a vault scheduled for deletion). Every client
11
+ * ends an upload it gives up by one rule here too: the upload id its delete is
12
+ * conditioned on (givenUpUploadId).
12
13
  *
13
14
  * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
14
15
  * and on the final state it hands Core's activation (POST
@@ -117,6 +118,19 @@ export function uploadTransferReference(istk) {
117
118
  }
118
119
  return `forge_ingot_transfer_upload_${istk.slice(0, TRANSFER_REFERENCE_ISTK_CHARS)}`;
119
120
  }
121
+ /**
122
+ * The usage-ledger category, and type, of a Forge transfer's charge, by
123
+ * direction. Every charge of one upload (Core's activation, Core's charge of
124
+ * an upload that never publishes, Forge's cancel) lands under the one
125
+ * reference uploadTransferReference names, so each spells its category from
126
+ * here, and the console counts both directions as the bandwidth the ledger
127
+ * measures. Each day's usage summary is keyed by category, so a category's
128
+ * spelling is the key its rows sum under.
129
+ */
130
+ export const TRANSFER_CHARGE_CATEGORIES = Object.freeze({
131
+ UPLOAD: 'Ingot Transfer - Forge Encryption',
132
+ DOWNLOAD: 'Ingot Transfer - Forge Decryption'
133
+ });
120
134
  /**
121
135
  * The codes Core's activation refuses an upload with, which Forge's refusal
122
136
  * map reads (the status is Core's):
@@ -1 +1 @@
1
- {"version":3,"file":"upload-publication.js","sourceRoot":"","sources":["../../src/app-sdk/upload-publication.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,8DAA8D;AAC9D,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAA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AC;QACrB,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB;QACzD,aAAa,EAAE,eAAe;KAC/B,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAM;IAChD,IAAI,MAAM,EAAE,MAAM,KAAK,uBAAuB,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACnE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,4GAA4G,CAAC;AAE/G;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC"}
package/dist/config.d.ts CHANGED
@@ -30,10 +30,12 @@ export interface SparkVaultMobileConfig {
30
30
  */
31
31
  backgroundTransfer?: MobileBackgroundTransfer;
32
32
  /**
33
- * Background-URLSession whole-file PATCH adapter, the fallback when no
34
- * `backgroundTransfer` engine is configured. Used only by uploads that ask
35
- * for it (`transport: 'background'`) and fit one chunk; every other
36
- * upload, and every upload when this is unset, streams over XHR.
33
+ * Whole-file PATCH adapter (one request, no progress, no abort; see
34
+ * MobileBackgroundUploader on backing it with a background session), the
35
+ * fallback when no `backgroundTransfer` engine is configured. Used only by
36
+ * uploads that ask for it (`transport: 'background'`) and fit one chunk;
37
+ * every other upload, and every upload when this is unset, streams over
38
+ * XHR.
37
39
  */
38
40
  backgroundUploader?: MobileBackgroundUploader;
39
41
  /**