@sparkvault/sdk-js 19.0.1 → 19.1.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.
Files changed (133) hide show
  1. package/README.md +26 -4
  2. package/dist/npm/chunks/index-C97091lF.mjs +12959 -0
  3. package/dist/npm/chunks/index-C97091lF.mjs.map +1 -0
  4. package/dist/npm/chunks/index-D_p_8VO7.cjs +13024 -0
  5. package/dist/npm/chunks/index-D_p_8VO7.cjs.map +1 -0
  6. package/dist/npm/identity.cjs +23 -0
  7. package/dist/npm/identity.cjs.map +1 -0
  8. package/dist/npm/identity.mjs +12 -0
  9. package/dist/npm/identity.mjs.map +1 -0
  10. package/dist/{index.cjs → npm/index.cjs} +802 -13759
  11. package/dist/npm/index.cjs.map +1 -0
  12. package/dist/{index.mjs → npm/index.mjs} +203 -13159
  13. package/dist/npm/index.mjs.map +1 -0
  14. package/dist/sparkvault-identity.js +2 -0
  15. package/dist/sparkvault-identity.js.map +1 -0
  16. package/dist/sparkvault.js +1 -1
  17. package/dist/sparkvault.js.map +1 -1
  18. package/dist/types/identity.d.ts +8 -0
  19. package/dist/{index.d.ts → types/index.d.ts} +4 -790
  20. package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
  21. package/package.json +20 -9
  22. package/dist/api-base.d.ts +0 -116
  23. package/dist/auto-init.d.ts +0 -32
  24. package/dist/config.d.ts +0 -79
  25. package/dist/entropy/index.d.ts +0 -35
  26. package/dist/entropy/types.d.ts +0 -32
  27. package/dist/errors.d.ts +0 -146
  28. package/dist/folders/index.d.ts +0 -102
  29. package/dist/folders/types.d.ts +0 -91
  30. package/dist/health.d.ts +0 -18
  31. package/dist/http.d.ts +0 -46
  32. package/dist/index.cjs.map +0 -1
  33. package/dist/index.mjs.map +0 -1
  34. package/dist/ingots/fetch-download.d.ts +0 -78
  35. package/dist/ingots/history.d.ts +0 -4
  36. package/dist/ingots/index.d.ts +0 -388
  37. package/dist/ingots/revision.d.ts +0 -4
  38. package/dist/ingots/types.d.ts +0 -556
  39. package/dist/logger.d.ts +0 -32
  40. package/dist/notify/index.d.ts +0 -154
  41. package/dist/notify/types.d.ts +0 -232
  42. package/dist/products/help-desk/client.d.ts +0 -198
  43. package/dist/products/help-desk/desk-id.d.ts +0 -2
  44. package/dist/products/help-desk/form-draft.d.ts +0 -37
  45. package/dist/products/help-desk/form-types.d.ts +0 -123
  46. package/dist/products/help-desk/form.d.ts +0 -83
  47. package/dist/products/help-desk/index.d.ts +0 -47
  48. package/dist/products/help-desk/kb-client.d.ts +0 -48
  49. package/dist/products/help-desk/kb-types.d.ts +0 -59
  50. package/dist/products/help-desk/modal.d.ts +0 -8
  51. package/dist/products/help-desk/styles.d.ts +0 -9
  52. package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
  53. package/dist/products/help-desk/support-analytics.d.ts +0 -3
  54. package/dist/products/help-desk/support-brand.d.ts +0 -49
  55. package/dist/products/help-desk/support-controller.d.ts +0 -4
  56. package/dist/products/help-desk/support-history.d.ts +0 -38
  57. package/dist/products/help-desk/support-launcher.d.ts +0 -12
  58. package/dist/products/help-desk/support-styles.d.ts +0 -14
  59. package/dist/products/help-desk/support-types.d.ts +0 -66
  60. package/dist/products/help-desk/support-view.d.ts +0 -173
  61. package/dist/products/help-desk/types.d.ts +0 -285
  62. package/dist/products/help-desk/widget-identity.d.ts +0 -32
  63. package/dist/products/identity/api.d.ts +0 -237
  64. package/dist/products/identity/container.d.ts +0 -44
  65. package/dist/products/identity/dialog-launcher.d.ts +0 -133
  66. package/dist/products/identity/federation-flow.d.ts +0 -31
  67. package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
  68. package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
  69. package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
  70. package/dist/products/identity/index.d.ts +0 -296
  71. package/dist/products/identity/inline-container.d.ts +0 -53
  72. package/dist/products/identity/methods.d.ts +0 -19
  73. package/dist/products/identity/modal.d.ts +0 -51
  74. package/dist/products/identity/pending-signin.d.ts +0 -102
  75. package/dist/products/identity/popup-launcher.d.ts +0 -73
  76. package/dist/products/identity/renderer.d.ts +0 -525
  77. package/dist/products/identity/state.d.ts +0 -84
  78. package/dist/products/identity/styles.d.ts +0 -31
  79. package/dist/products/identity/types.d.ts +0 -561
  80. package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
  81. package/dist/products/identity/utils.d.ts +0 -85
  82. package/dist/products/identity/views/backup-verify.d.ts +0 -42
  83. package/dist/products/identity/views/base.d.ts +0 -51
  84. package/dist/products/identity/views/error.d.ts +0 -65
  85. package/dist/products/identity/views/icons.d.ts +0 -41
  86. package/dist/products/identity/views/identity-input.d.ts +0 -80
  87. package/dist/products/identity/views/index.d.ts +0 -20
  88. package/dist/products/identity/views/loading.d.ts +0 -23
  89. package/dist/products/identity/views/method-button.d.ts +0 -14
  90. package/dist/products/identity/views/method-select.d.ts +0 -42
  91. package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
  92. package/dist/products/identity/views/otp-verify.d.ts +0 -58
  93. package/dist/products/identity/views/passkey-auto.d.ts +0 -22
  94. package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
  95. package/dist/products/identity/views/passkey.d.ts +0 -38
  96. package/dist/products/identity/views/product-not-configured.d.ts +0 -21
  97. package/dist/products/identity/views/service-unavailable.d.ts +0 -21
  98. package/dist/products/identity/views/sms-consent.d.ts +0 -16
  99. package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
  100. package/dist/products/identity/views/two-factor.d.ts +0 -37
  101. package/dist/products/index.d.ts +0 -51
  102. package/dist/products/messaging/index.d.ts +0 -38
  103. package/dist/products/messaging/types.d.ts +0 -162
  104. package/dist/products/notify/index.d.ts +0 -436
  105. package/dist/products/notify/project-types.d.ts +0 -44
  106. package/dist/products/notify/projects.d.ts +0 -15
  107. package/dist/products/notify/types.d.ts +0 -1327
  108. package/dist/products/structured-ingots/index.d.ts +0 -31
  109. package/dist/products/structured-ingots/types-client.d.ts +0 -19
  110. package/dist/products/structured-ingots/types.d.ts +0 -293
  111. package/dist/products/structured-ingots/validation.d.ts +0 -25
  112. package/dist/request-path.d.ts +0 -44
  113. package/dist/sparks/index.d.ts +0 -91
  114. package/dist/sparks/types.d.ts +0 -304
  115. package/dist/ui/chrome.d.ts +0 -16
  116. package/dist/ui/ds-tokens.d.ts +0 -59
  117. package/dist/ui/inline-shell.d.ts +0 -19
  118. package/dist/ui/live-region.d.ts +0 -15
  119. package/dist/ui/modal-shell.d.ts +0 -67
  120. package/dist/ui/target.d.ts +0 -6
  121. package/dist/utils/dom.d.ts +0 -26
  122. package/dist/vault-session.d.ts +0 -2
  123. package/dist/vaults/index.d.ts +0 -254
  124. package/dist/vaults/types.d.ts +0 -368
  125. package/dist/vaults/upload/api.d.ts +0 -310
  126. package/dist/vaults/upload/chrome.d.ts +0 -21
  127. package/dist/vaults/upload/container.d.ts +0 -37
  128. package/dist/vaults/upload/index.d.ts +0 -76
  129. package/dist/vaults/upload/inline-container.d.ts +0 -41
  130. package/dist/vaults/upload/modal.d.ts +0 -55
  131. package/dist/vaults/upload/renderer.d.ts +0 -150
  132. package/dist/vaults/upload/styles.d.ts +0 -14
  133. package/dist/vaults/upload/types.d.ts +0 -220
@@ -1,310 +0,0 @@
1
- /**
2
- * Upload API
3
- *
4
- * API client for vault upload operations.
5
- */
6
- import { type ResolvedConfig } from '../../config';
7
- import { type TransferOutcome, type TransferVerdict } from '@sparkvault/app-sdk/transfer-retry';
8
- import { SparkVaultApi } from '../../api-base';
9
- import { SparkVaultError } from '../../errors';
10
- import type { VaultUploadConfig, VaultUploadInfoResponse } from './types';
11
- /**
12
- * Error class for upload API errors. Inherits `code` and `statusCode` from
13
- * SparkVaultError, with no duplicate `httpStatus` field.
14
- *
15
- * A failed transfer request also carries what the transfer policy
16
- * (`@sparkvault/app-sdk/transfer-retry`) makes of its answer, read where the
17
- * answer arrived: its `verdict` and its `Upload-Offset` (`serverOffset`),
18
- * beside the `Retry-After` every SDK error carries (`retryAfterMs`). They are
19
- * the retry loop's bookkeeping, so they ride on the instance, never in
20
- * `details`. Every other failure (a cancel, a refused URL, a protocol
21
- * violation) is `refused`: nothing retries it.
22
- */
23
- export declare class UploadApiError extends SparkVaultError {
24
- readonly verdict: TransferVerdict;
25
- readonly serverOffset: number | null;
26
- constructor(message: string, code: string, statusCode: number, details?: Record<string, unknown>, outcome?: TransferOutcome);
27
- }
28
- /** The widget's upload configuration, read from a vault's upload info answer. */
29
- export declare function mapVaultUploadInfo(wire: VaultUploadInfoResponse): VaultUploadConfig;
30
- /**
31
- * The error a request that stages an upload throws, from the error Core's
32
- * answer made: its final refusal of the upload as `upload_refused`
33
- * ({@link stagingRefusal}), any other error as it is.
34
- */
35
- export declare function stagingRefusalOf(error: unknown): unknown;
36
- /**
37
- * Refuse a transfer where the browser's XMLHttpRequest is missing (a server
38
- * process: Node has fetch and no XMLHttpRequest): a chunk's upload progress
39
- * needs it. A flow that stages its upload with Core first checks this before
40
- * the staging request, so a run that cannot transfer stages nothing.
41
- */
42
- export declare function assertBrowserTransfer(): void;
43
- /**
44
- * Whether a transfer failed once the server held every byte of its upload,
45
- * short of the upload's own end: `upload_received_publishing`, and any other
46
- * failure of the receipt that confirms publication (one refused, or one that
47
- * went unanswered), never a gone session, Core's refusal or a cancel. The
48
- * server publishes such an upload, or ends it, on its own, so its caller
49
- * neither sends it again nor gives it up (`ingots.endUpload`).
50
- */
51
- export declare function isReceivedUploadFailure(error: unknown): boolean;
52
- export declare class UploadApi extends SparkVaultApi {
53
- private readonly config;
54
- /**
55
- * Vault upload info by vault id, memoized for the life of this client.
56
- *
57
- * The client is built once with the SDK and the map dies with the page, so
58
- * the memo cannot outlive the page it decorates, which is why there is no
59
- * TTL and no invalidation API to get wrong. It deliberately survives
60
- * `resetSession()`, alongside the other long-lived per-client state.
61
- */
62
- private readonly vaultInfoMemo;
63
- constructor(config: ResolvedConfig);
64
- /**
65
- * The shared transport's errors. It raises a request that got no answer (a
66
- * dropped connection, a timeout) with status 0, which the transfer policy
67
- * retries, a cancel aside; a refused API call it raises with its status is
68
- * Core's verdict, never a transfer's, so of the policy's reading it carries
69
- * only the floor Core named (`retryAfterMs`), for whoever acts on the
70
- * refusal, and Core's final refusal of the upload a call stages is that
71
- * upload's `upload_refused` ({@link stagingRefusal}).
72
- */
73
- protected makeError(message: string, code: string, statusCode: number, details?: Record<string, unknown>, retryAfterMs?: number | null): UploadApiError;
74
- /**
75
- * Issue a request to a Core route and unwrap the standard `{ data, meta }`
76
- * envelope.
77
- */
78
- private request;
79
- /**
80
- * The vault id an upload route names, refused before any request when it is
81
- * not a SparkVault resource id: the id comes from the host page's widget
82
- * options, and a value carrying '/' or a dot-segment must never re-target
83
- * the request.
84
- */
85
- private requireVaultId;
86
- /**
87
- * Get vault upload info (public endpoint), fetched at most once per vault.
88
- *
89
- * Every widget interaction (`upload()`, `pop()`, `render()`, and each click
90
- * an `attach()` handler serves) starts by asking for this, and the answer is
91
- * pure display and geometry: the vault's name, its branding, and the size it
92
- * advertises. It authorizes nothing. The server re-validates the vault, its
93
- * upload source, the request origin, and the file size on the POST that
94
- * actually creates the upload, and that re-validation is the correctness
95
- * backstop for this whole flow: a memoized answer can never widen what an
96
- * upload is allowed to do, and the backstop must stay in place.
97
- *
98
- * Only a successful answer is kept: a rejection evicts its entry so the next
99
- * open retries against the server, and an entry whose request was aborted by
100
- * a closing widget is never handed to the widget that replaces it.
101
- */
102
- getVaultUploadInfo(vaultId: string): Promise<VaultUploadConfig>;
103
- private fetchVaultUploadInfo;
104
- /**
105
- * Initiate an upload to get Forge URL and ingot ID.
106
- */
107
- initiateUpload(vaultId: string, filename: string, sizeBytes: number, contentType: string, token?: string, folder?: string): Promise<{
108
- forgeUrl: string;
109
- ingotId: string;
110
- requestId: string | null;
111
- }>;
112
- /**
113
- * Upload a file to Forge over the TUS resumable protocol (v1.0.0).
114
- *
115
- * The single canonical browser transfer path: the upload widget and the
116
- * authenticated `ingots.upload` flow both go through here (one canonical
117
- * transfer path). Creates the session, PATCHes chunks sized exactly by the
118
- * server's `X-Chunk-Size` (Forge fixes the geometry at 50MB, which keeps
119
- * every request under CDN body caps such as Cloudflare's 100MB), validates
120
- * every server-reported offset, and honors the session abort signal plus
121
- * per-request timeouts.
122
- *
123
- * Every answer is read through the transfer policy
124
- * (`@sparkvault/app-sdk/transfer-retry`) and every retry spends one budget
125
- * ({@link TusTransfer}). A chunk that fails in transit is resent only from
126
- * an offset the server just named: a 409's own `Upload-Offset` at once,
127
- * otherwise a HEAD after the backoff ({@link offsetAfterFailure}); a session
128
- * the server no longer holds throws `session_gone`, which only a new upload
129
- * recovers from (any code of Core's the server named rides
130
- * `details.coreCode`); an upload Core refused (a full storage pool, a later
131
- * upload that replaced it, its vault scheduled for deletion, whose 409 names
132
- * Core's code) throws `upload_refused` in Core's words at once, which no new
133
- * upload recovers from. While the browser is offline, the loop
134
- * waits for the network instead of spending attempts.
135
- *
136
- * Resolves only once the server has confirmed finalization
137
- * ({@link confirmServerFinalized}), so a caller that gets a resolved promise
138
- * is always looking at a published ingot; a publication the server still
139
- * defers at the idle limit throws `upload_received_publishing`. The
140
- * session's URL goes to `onSessionCreated` once Forge opens it, before the
141
- * first byte, so the caller can continue the upload in it
142
- * ({@link resumeUploadToForge}) whatever becomes of this transfer.
143
- */
144
- uploadFileToForge(file: File | Blob, forgeUrl: string, onProgress?: (bytesUploaded: number, bytesTotal: number) => void, onSessionCreated?: (sessionUrl: string) => void): Promise<void>;
145
- /**
146
- * Continue an upload in the session {@link uploadFileToForge} opened for
147
- * `file` (the session URL its `onSessionCreated` handed over), through the same
148
- * transfer: Forge is asked where the session stands (a HEAD, retried under
149
- * the transfer policy as any request of the upload is), only the bytes it
150
- * lacks are sent, and the upload resolves on the same receipt, so a
151
- * resolved promise is a published ingot. A session at its full offset sends
152
- * no byte and only takes the receipt: this is how a caller learns what
153
- * became of an upload whose publication was still deferred
154
- * (`upload_received_publishing`). It throws as an upload does: `session_gone`
155
- * once Forge no longer holds the session (cancelled, expired, or ended when
156
- * Core refused its publication), `upload_refused` for a refusal Core
157
- * decided, `upload_received_publishing` again for a publication still
158
- * deferred at the idle limit. A session URL that is not an upload session
159
- * on an allowed transfer host is refused (`invalid_forge_url`), and one
160
- * whose upload is not this file's length (`session_mismatch`), before any
161
- * byte is sent.
162
- */
163
- resumeUploadToForge(file: File | Blob, sessionUrl: string, onProgress?: (bytesUploaded: number, bytesTotal: number) => void): Promise<void>;
164
- /**
165
- * Send `file` into its session from `offset` (0 for a session just opened,
166
- * the server's own offset for a resumed one) until the receipt confirms
167
- * publication: the one loop every transfer runs.
168
- */
169
- private sendFile;
170
- /**
171
- * Where the upload stands after a failed chunk PATCH, in the server's words:
172
- * a 409's own `Upload-Offset` at once, otherwise the session's HEAD after
173
- * the backoff. The failed chunk may have landed with its answer lost, and a
174
- * PATCH at the client's stale offset is refused, so no chunk is ever sent
175
- * again at an offset the server did not just name. The blip that killed the
176
- * PATCH is also the likeliest thing to kill the HEAD moments later, so the
177
- * HEAD is retried the same way, out of the same budget.
178
- */
179
- private offsetAfterFailure;
180
- /**
181
- * Continue from the offset a 409 named, at once and without a HEAD: the
182
- * server just said where the session stands. Past what this client sent,
183
- * the server holds more than it knew, which is progress; anywhere else the
184
- * answer contradicts the request, so it spends the budget like any failure
185
- * and repeating it ends the upload.
186
- */
187
- private resyncedOffset;
188
- /**
189
- * Wait out the backoff of a failed or deferred request to the upload's
190
- * session ({@link waitToRetry}, keyed by the session URL), or throw: a gone
191
- * session as `session_gone`, an answer no retry follows as it is, and the
192
- * last failure, or the deferral, once the budget is spent.
193
- */
194
- private backOff;
195
- /**
196
- * Confirm the server finalized a fully received upload: the one receipt
197
- * every transfer ends on.
198
- *
199
- * The server persists the session's final offset BEFORE it finalizes, so a
200
- * HEAD offset proves receipt and never publication: it can equal the file
201
- * size while finalization failed or is still running, and reporting that as
202
- * success would hand the user a stored file whose ingot was never published.
203
- * The zero-length PATCH at the final offset is the server's finalization
204
- * re-drive: it short-circuits to 204 on an already-finalized session, and
205
- * on a received-but-unfinalized one it answers only after publication.
206
- *
207
- * While another request finalizes the receipt answers 409 with
208
- * `Retry-After`, polled again after the policy's backoff as a failure; while
209
- * the publication is deferred it answers 503 with `Retry-After`, a deferral
210
- * the receipt is polled through without spending a failure, each ask after
211
- * a longer backoff, until the idle limit throws
212
- * `upload_received_publishing`: every byte is on the server, which finishes
213
- * the publication on its own. A 503 naming no `Retry-After` is no deferral
214
- * of Forge's, so it is polled as a failure. A 400 is the server's verdict
215
- * and fails immediately, as does the refusal Core decided
216
- * (`upload_refused`, a 409 naming Core's code among them); a 409 naming an
217
- * earlier offset means bytes are missing, and the upload continues from
218
- * there.
219
- */
220
- private confirmServerFinalized;
221
- /**
222
- * Where a session a resume continues stands, from its HEAD: the bytes it
223
- * holds, the length of the upload it was opened for, and its chunk size
224
- * (Forge echoes `X-Chunk-Size` on a HEAD as on the create). A HEAD that
225
- * fails is asked again under the upload's budget as any request of it is;
226
- * a session the server no longer holds throws `session_gone`, and a refusal
227
- * Core decided its `upload_refused`.
228
- */
229
- private readSessionStanding;
230
- /**
231
- * Read the offset a failed chunk should resume from, from the session's
232
- * HEAD. At the full offset it proves receipt only, published or not, so the
233
- * loop then takes the receipt.
234
- */
235
- private readResumeOffset;
236
- /**
237
- * Judge an offset the server named for the upload to resume from (a HEAD's,
238
- * or a 409's `Upload-Offset`): the one place a server-reported resume point
239
- * is judged.
240
- *
241
- * Forge commits a chunk before it answers, so a PATCH that died in transit
242
- * may have landed in full or not at all (never in part: the chunk object
243
- * is written atomically before the offset advances); only the session's own
244
- * persisted offset knows which, and the client's arithmetic is worthless
245
- * here.
246
- *
247
- * Two contracts disqualify an answer (`resumeOffsetProblem`). TUS sanity: an
248
- * offset past the declared total would end the loop early and report a
249
- * partial upload as complete, the same trap {@link patchChunk} guards
250
- * against on a PATCH's own offset. Forge chunk granularity: a session
251
- * advances only in whole committed chunks, so an offset that is neither
252
- * chunk-aligned nor the file end is a corrupt session, and resuming from it
253
- * would send a short non-final chunk Forge rejects anyway.
254
- */
255
- private checkResumeOffset;
256
- /**
257
- * Create the TUS upload session. Forge reads only `Tus-Resumable`,
258
- * `Upload-Length`, and `X-ISTK` on create, and returns the session URL in
259
- * `Location` (possibly relative) plus its chunk size in `X-Chunk-Size`.
260
- *
261
- * A create the transfer policy calls RETRY (no answer, 408, 425, 429, a 5xx)
262
- * is sent again under the upload's budget: Forge refuses such a create
263
- * before it claims the token, or hands the claim back on a transient
264
- * key-service failure (503 + `Retry-After`), so the same ISTK opens the
265
- * session on a later attempt. Every other answer is final, a 401 included:
266
- * the token was already used, by an earlier attempt whose answer was lost,
267
- * and no `Location` survives to continue that session from. No session URL
268
- * exists yet to spread the retries by, and the ISTK never feeds one, so
269
- * they spread by a key of the endpoint (`transferJitterKey`).
270
- */
271
- private createTusSession;
272
- /**
273
- * PATCH one chunk with XMLHttpRequest (fetch exposes no upload progress).
274
- * Resolves with the server-confirmed offset for the next iteration; a
275
- * failure carries the transfer policy's verdict on its answer, read here.
276
- *
277
- * The server's `Upload-Offset` is validated, never trusted: it must be a
278
- * whole number that strictly advances past this chunk's start (this client
279
- * never sends an empty chunk, so a non-advancing 2xx would loop forever)
280
- * and never exceeds the file size (an inflated offset would skip real
281
- * chunks and report a partial upload as success).
282
- *
283
- * Bytes leaving are a sign of life: they restart the transfer's idle clock
284
- * (never its failure count, which only the server's confirmation resets), so
285
- * a slow chunk is never counted as idle time.
286
- */
287
- private patchChunk;
288
- /**
289
- * Read the server's persisted upload offset via a TUS HEAD request: the one
290
- * place the client asks Forge where a session really stands.
291
- *
292
- * @param check - Which caller this read serves; shapes the failure copy.
293
- */
294
- private headUploadOffset;
295
- /**
296
- * Issue one bodyless TUS request: the single transport behind every
297
- * non-chunk call this client makes (session create, resume HEAD,
298
- * finalization PATCH).
299
- *
300
- * Uses the raw response rather than the JSON envelope helper: TUS responses
301
- * carry an empty body and surface state in headers. Runs through the one SDK
302
- * transport (session close signal, deadline, failure classification) and
303
- * resolves only on a 2xx, with the transfer policy's reading of it, so no
304
- * caller has to re-check `response.ok`; a non-2xx throws carrying the
305
- * policy's verdict on its answer.
306
- *
307
- * @param check - Which caller this request serves; shapes the failure copy.
308
- */
309
- private tusRequest;
310
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Upload Widget Chrome
3
- *
4
- * DOM builders for the upload dialog's branded chrome: the brand header and
5
- * the Triple Zero-Trust security sidebar. The "Secured by SparkVault" footer
6
- * is the SDK's shared one (ui/chrome.ts).
7
- */
8
- import type { UploadBranding } from './types';
9
- export interface BrandHeaderOptions {
10
- branding: UploadBranding;
11
- /** Pick the dark-mode logo variant when available. */
12
- isDarkMode: boolean;
13
- /** id for the title node (logo screen-reader text or company name): the dialog's aria-labelledby target. */
14
- titleId: string;
15
- /** Wired to the close (×) button's click. */
16
- onClose: () => void;
17
- }
18
- /** Build the dialog's branded header, with its close button. */
19
- export declare function createBrandHeader(options: BrandHeaderOptions): HTMLDivElement;
20
- /** Build the Triple Zero-Trust security sidebar shown during dark states. */
21
- export declare function createSecuritySidebar(branding: UploadBranding): HTMLDivElement;
@@ -1,37 +0,0 @@
1
- /**
2
- * Upload Container Interface
3
- *
4
- * Abstract interface for upload UI containers.
5
- * Allows switching between modal (popup) and inline rendering modes
6
- * while reusing all view logic, state management, and handlers.
7
- */
8
- import type { UploadBranding } from './types';
9
- /**
10
- * Container interface that both ModalContainer and InlineContainer implement.
11
- * The renderer interacts with containers through this interface.
12
- */
13
- export interface UploadContainer {
14
- /**
15
- * Create the container with loading state.
16
- * Called immediately when upload flow starts.
17
- */
18
- createLoading(options: {
19
- backdropBlur?: boolean;
20
- }, onClose: () => void): void;
21
- /**
22
- * Update branding after vault config loads.
23
- */
24
- updateBranding(branding: UploadBranding): void;
25
- /**
26
- * Get the body element where views are rendered.
27
- */
28
- getBody(): HTMLDivElement | null;
29
- /**
30
- * Check if the container is currently active.
31
- */
32
- isOpen(): boolean;
33
- /**
34
- * Destroy the container and clean up event listeners.
35
- */
36
- destroy(): void;
37
- }
@@ -1,76 +0,0 @@
1
- /**
2
- * Vault Upload Module
3
- *
4
- * Embedded upload widget for vaults with public upload enabled.
5
- *
6
- * @example Dialog mode (immediate)
7
- * const result = await sv.vaults.upload({ vaultId: 'vlt_abc123' });
8
- *
9
- * @example Dialog mode (attached to clicks)
10
- * sv.vaults.upload.attach('.upload-btn', { vaultId: 'vlt_abc123' });
11
- *
12
- * @example Inline mode
13
- * const result = await sv.vaults.upload({
14
- * vaultId: 'vlt_abc123',
15
- * target: '#upload-container'
16
- * });
17
- */
18
- import type { ResolvedConfig } from '../../config';
19
- import type { UploadOptions, UploadAttachOptions, UploadResult } from './types';
20
- export declare class VaultUploadModule {
21
- private readonly config;
22
- private readonly api;
23
- private renderer;
24
- constructor(config: ResolvedConfig);
25
- /**
26
- * Upload a file to a vault.
27
- *
28
- * - Without `target`: Opens a dialog (modal)
29
- * - With `target`: Renders inline into the specified element
30
- *
31
- * @example Dialog mode
32
- * const result = await sv.vaults.upload({ vaultId: 'vlt_abc123' });
33
- * console.log('Uploaded:', result.ingotId);
34
- *
35
- * @example Inline mode
36
- * const result = await sv.vaults.upload({
37
- * vaultId: 'vlt_abc123',
38
- * target: '#upload-container'
39
- * });
40
- */
41
- upload(options: UploadOptions): Promise<UploadResult>;
42
- /**
43
- * Attach upload functionality to element clicks.
44
- * When any matching element is clicked, opens the upload dialog.
45
- *
46
- * @param selector - CSS selector for elements to attach to
47
- * @param options - Upload options including vaultId and callbacks
48
- * @returns Cleanup function to remove event listeners
49
- *
50
- * @example
51
- * const cleanup = sv.vaults.upload.attach('.upload-btn', {
52
- * vaultId: 'vlt_abc123',
53
- * onSuccess: (result) => console.log('Uploaded:', result.ingotId)
54
- * });
55
- *
56
- * // Later, remove listeners
57
- * cleanup();
58
- */
59
- attach(selector: string, options: UploadAttachOptions): () => void;
60
- /**
61
- * Close the upload dialog/inline UI if open.
62
- *
63
- * Programmatic close follows the cancel contract: the host's onCancel
64
- * fires and the pending upload promise rejects with UserCancelledError.
65
- */
66
- close(): void;
67
- /**
68
- * The inline container for an embedded upload.
69
- */
70
- private createInlineContainer;
71
- /** Open the upload widget as a popup. Equivalent to `upload(options)`. */
72
- pop(options: UploadOptions): Promise<UploadResult>;
73
- /** Render the upload widget inline. Equivalent to `upload({ ...options, target })`. */
74
- render(options: UploadOptions): Promise<UploadResult>;
75
- }
76
- export type { UploadOptions, UploadAttachOptions, UploadResult, UploadProgress, VaultUploadConfig, UploadBranding, } from './types';
@@ -1,41 +0,0 @@
1
- /**
2
- * Inline Upload Container
3
- *
4
- * Renders upload UI inline within a target element, in the SDK's shared
5
- * inline shell. Unlike UploadModalContainer, which opens a dialog, this embeds
6
- * directly into the customer's page where render() was called. The upload and
7
- * ceremony states run in a dialog of their own (the renderer's hybrid mode),
8
- * so the inline surface has no dark mode or sidebar.
9
- *
10
- * Implements the UploadContainer interface for use with UploadRenderer.
11
- */
12
- import type { UploadContainer } from './container';
13
- import type { UploadBranding } from './types';
14
- export declare class UploadInlineContainer implements UploadContainer {
15
- private readonly targetElement;
16
- private shell;
17
- constructor(targetElement: HTMLElement);
18
- /**
19
- * Create the inline container with loading state. An embedded widget has no
20
- * close affordance of its own, so the close callback is not wired.
21
- */
22
- createLoading(_options: {
23
- backdropBlur?: boolean;
24
- }, _onClose: () => void): void;
25
- /**
26
- * Branding shows only in the dialog chrome, so the inline surface has none to update.
27
- */
28
- updateBranding(_branding: UploadBranding): void;
29
- /**
30
- * Get the body element for content rendering.
31
- */
32
- getBody(): HTMLDivElement | null;
33
- /**
34
- * Check if the container is currently active.
35
- */
36
- isOpen(): boolean;
37
- /**
38
- * Destroy the container, leaving the target empty.
39
- */
40
- destroy(): void;
41
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * Upload Modal Container
3
- *
4
- * Single responsibility: the upload dialog's chrome (branded header, body,
5
- * footer, and optional security help) inside the SDK's shared
6
- * modal shell, which owns the dialog behaviour (dismissal, scroll lock,
7
- * focus). Does NOT handle content rendering - that's the Renderer's job.
8
- */
9
- import type { UploadBranding } from './types';
10
- import type { UploadContainer } from './container';
11
- export declare class UploadModalContainer implements UploadContainer {
12
- private shell;
13
- private header;
14
- private body;
15
- private sidebar;
16
- private onCloseCallback;
17
- private isDarkMode;
18
- private branding;
19
- /**
20
- * Create and show the modal immediately with loading state.
21
- */
22
- createLoading(options: {
23
- backdropBlur?: boolean;
24
- }, onClose: () => void): void;
25
- private createHeader;
26
- /** Redraw the header for the current branding and theme, keeping its visibility. */
27
- private refreshHeader;
28
- /**
29
- * Update branding after vault config loads.
30
- */
31
- updateBranding(branding: UploadBranding): void;
32
- /**
33
- * Set dark mode for uploading/ceremony states.
34
- */
35
- setDarkMode(enabled: boolean): void;
36
- /**
37
- * Offer security education on demand during a transfer. Never expand it
38
- * automatically or widen the working view to accommodate explanatory copy.
39
- */
40
- toggleSidebar(show: boolean): void;
41
- private handleClose;
42
- /**
43
- * Get the modal body element for content rendering.
44
- */
45
- getBody(): HTMLDivElement | null;
46
- /**
47
- * Check if the modal is currently open.
48
- */
49
- isOpen(): boolean;
50
- /**
51
- * Destroy the modal; the shell removes its listeners, releases the scroll
52
- * lock and returns focus.
53
- */
54
- destroy(): void;
55
- }