@sparkvault/sdk-js 19.0.0 → 19.1.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 (132) hide show
  1. package/README.md +26 -4
  2. package/dist/npm/chunks/index-BnP-2w0t.cjs +13025 -0
  3. package/dist/npm/chunks/index-BnP-2w0t.cjs.map +1 -0
  4. package/dist/npm/chunks/index-CgR08uMG.mjs +12960 -0
  5. package/dist/npm/chunks/index-CgR08uMG.mjs.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} +799 -13755
  11. package/dist/npm/index.cjs.map +1 -0
  12. package/dist/{index.mjs → npm/index.mjs} +200 -13155
  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/types/identity.d.ts +8 -0
  18. package/dist/{index.d.ts → types/index.d.ts} +4 -790
  19. package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
  20. package/package.json +20 -9
  21. package/dist/api-base.d.ts +0 -116
  22. package/dist/auto-init.d.ts +0 -32
  23. package/dist/config.d.ts +0 -79
  24. package/dist/entropy/index.d.ts +0 -35
  25. package/dist/entropy/types.d.ts +0 -32
  26. package/dist/errors.d.ts +0 -146
  27. package/dist/folders/index.d.ts +0 -102
  28. package/dist/folders/types.d.ts +0 -91
  29. package/dist/health.d.ts +0 -18
  30. package/dist/http.d.ts +0 -46
  31. package/dist/index.cjs.map +0 -1
  32. package/dist/index.mjs.map +0 -1
  33. package/dist/ingots/fetch-download.d.ts +0 -78
  34. package/dist/ingots/history.d.ts +0 -4
  35. package/dist/ingots/index.d.ts +0 -388
  36. package/dist/ingots/revision.d.ts +0 -4
  37. package/dist/ingots/types.d.ts +0 -556
  38. package/dist/logger.d.ts +0 -32
  39. package/dist/notify/index.d.ts +0 -154
  40. package/dist/notify/types.d.ts +0 -232
  41. package/dist/products/help-desk/client.d.ts +0 -198
  42. package/dist/products/help-desk/desk-id.d.ts +0 -2
  43. package/dist/products/help-desk/form-draft.d.ts +0 -37
  44. package/dist/products/help-desk/form-types.d.ts +0 -123
  45. package/dist/products/help-desk/form.d.ts +0 -83
  46. package/dist/products/help-desk/index.d.ts +0 -47
  47. package/dist/products/help-desk/kb-client.d.ts +0 -48
  48. package/dist/products/help-desk/kb-types.d.ts +0 -59
  49. package/dist/products/help-desk/modal.d.ts +0 -8
  50. package/dist/products/help-desk/styles.d.ts +0 -9
  51. package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
  52. package/dist/products/help-desk/support-analytics.d.ts +0 -3
  53. package/dist/products/help-desk/support-brand.d.ts +0 -49
  54. package/dist/products/help-desk/support-controller.d.ts +0 -4
  55. package/dist/products/help-desk/support-history.d.ts +0 -38
  56. package/dist/products/help-desk/support-launcher.d.ts +0 -12
  57. package/dist/products/help-desk/support-styles.d.ts +0 -14
  58. package/dist/products/help-desk/support-types.d.ts +0 -66
  59. package/dist/products/help-desk/support-view.d.ts +0 -173
  60. package/dist/products/help-desk/types.d.ts +0 -285
  61. package/dist/products/help-desk/widget-identity.d.ts +0 -32
  62. package/dist/products/identity/api.d.ts +0 -237
  63. package/dist/products/identity/container.d.ts +0 -44
  64. package/dist/products/identity/dialog-launcher.d.ts +0 -133
  65. package/dist/products/identity/federation-flow.d.ts +0 -31
  66. package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
  67. package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
  68. package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
  69. package/dist/products/identity/index.d.ts +0 -296
  70. package/dist/products/identity/inline-container.d.ts +0 -53
  71. package/dist/products/identity/methods.d.ts +0 -19
  72. package/dist/products/identity/modal.d.ts +0 -51
  73. package/dist/products/identity/pending-signin.d.ts +0 -102
  74. package/dist/products/identity/popup-launcher.d.ts +0 -73
  75. package/dist/products/identity/renderer.d.ts +0 -525
  76. package/dist/products/identity/state.d.ts +0 -84
  77. package/dist/products/identity/styles.d.ts +0 -31
  78. package/dist/products/identity/types.d.ts +0 -561
  79. package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
  80. package/dist/products/identity/utils.d.ts +0 -85
  81. package/dist/products/identity/views/backup-verify.d.ts +0 -42
  82. package/dist/products/identity/views/base.d.ts +0 -51
  83. package/dist/products/identity/views/error.d.ts +0 -65
  84. package/dist/products/identity/views/icons.d.ts +0 -41
  85. package/dist/products/identity/views/identity-input.d.ts +0 -80
  86. package/dist/products/identity/views/index.d.ts +0 -20
  87. package/dist/products/identity/views/loading.d.ts +0 -23
  88. package/dist/products/identity/views/method-button.d.ts +0 -14
  89. package/dist/products/identity/views/method-select.d.ts +0 -42
  90. package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
  91. package/dist/products/identity/views/otp-verify.d.ts +0 -58
  92. package/dist/products/identity/views/passkey-auto.d.ts +0 -22
  93. package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
  94. package/dist/products/identity/views/passkey.d.ts +0 -38
  95. package/dist/products/identity/views/product-not-configured.d.ts +0 -21
  96. package/dist/products/identity/views/service-unavailable.d.ts +0 -21
  97. package/dist/products/identity/views/sms-consent.d.ts +0 -16
  98. package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
  99. package/dist/products/identity/views/two-factor.d.ts +0 -37
  100. package/dist/products/index.d.ts +0 -51
  101. package/dist/products/messaging/index.d.ts +0 -38
  102. package/dist/products/messaging/types.d.ts +0 -162
  103. package/dist/products/notify/index.d.ts +0 -436
  104. package/dist/products/notify/project-types.d.ts +0 -44
  105. package/dist/products/notify/projects.d.ts +0 -15
  106. package/dist/products/notify/types.d.ts +0 -1327
  107. package/dist/products/structured-ingots/index.d.ts +0 -31
  108. package/dist/products/structured-ingots/types-client.d.ts +0 -19
  109. package/dist/products/structured-ingots/types.d.ts +0 -293
  110. package/dist/products/structured-ingots/validation.d.ts +0 -25
  111. package/dist/request-path.d.ts +0 -44
  112. package/dist/sparks/index.d.ts +0 -91
  113. package/dist/sparks/types.d.ts +0 -304
  114. package/dist/ui/chrome.d.ts +0 -16
  115. package/dist/ui/ds-tokens.d.ts +0 -59
  116. package/dist/ui/inline-shell.d.ts +0 -19
  117. package/dist/ui/live-region.d.ts +0 -15
  118. package/dist/ui/modal-shell.d.ts +0 -67
  119. package/dist/ui/target.d.ts +0 -6
  120. package/dist/utils/dom.d.ts +0 -26
  121. package/dist/vault-session.d.ts +0 -2
  122. package/dist/vaults/index.d.ts +0 -254
  123. package/dist/vaults/types.d.ts +0 -368
  124. package/dist/vaults/upload/api.d.ts +0 -310
  125. package/dist/vaults/upload/chrome.d.ts +0 -21
  126. package/dist/vaults/upload/container.d.ts +0 -37
  127. package/dist/vaults/upload/index.d.ts +0 -76
  128. package/dist/vaults/upload/inline-container.d.ts +0 -41
  129. package/dist/vaults/upload/modal.d.ts +0 -55
  130. package/dist/vaults/upload/renderer.d.ts +0 -150
  131. package/dist/vaults/upload/styles.d.ts +0 -14
  132. package/dist/vaults/upload/types.d.ts +0 -220
package/package.json CHANGED
@@ -1,23 +1,34 @@
1
1
  {
2
2
  "name": "@sparkvault/sdk-js",
3
- "version": "19.0.0",
3
+ "version": "19.1.0",
4
4
  "description": "SparkVault JavaScript SDK - Identity, Secure Help Desk, Notifications and Encrypted Vaults",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
- "types": "./dist/index.d.ts",
9
- "import": "./dist/index.mjs",
10
- "require": "./dist/index.cjs",
11
- "default": "./dist/index.mjs"
8
+ "types": "./dist/types/index.d.ts",
9
+ "import": "./dist/npm/index.mjs",
10
+ "require": "./dist/npm/index.cjs",
11
+ "default": "./dist/npm/index.mjs"
12
+ },
13
+ "./identity": {
14
+ "types": "./dist/types/identity.d.ts",
15
+ "import": "./dist/npm/identity.mjs",
16
+ "require": "./dist/npm/identity.cjs",
17
+ "default": "./dist/npm/identity.mjs"
12
18
  },
13
19
  "./package.json": "./package.json"
14
20
  },
15
- "main": "./dist/index.cjs",
16
- "module": "./dist/index.mjs",
21
+ "main": "./dist/npm/index.cjs",
22
+ "module": "./dist/npm/index.mjs",
17
23
  "browser": "./dist/sparkvault.js",
18
- "types": "./dist/index.d.ts",
24
+ "types": "./dist/types/index.d.ts",
19
25
  "files": [
20
- "dist"
26
+ "dist/npm",
27
+ "dist/types",
28
+ "dist/sparkvault.js",
29
+ "dist/sparkvault.js.map",
30
+ "dist/sparkvault-identity.js",
31
+ "dist/sparkvault-identity.js.map"
21
32
  ],
22
33
  "scripts": {
23
34
  "build": "rollup -c",
@@ -1,116 +0,0 @@
1
- /**
2
- * SparkVault API Base
3
- *
4
- * The one transport every SDK request goes through, and the shared lifecycle
5
- * for the internal API clients (IdentityApi, UploadApi, ...), which provide:
6
- * - their own error factory via makeError()
7
- * - their own typed endpoint methods on top of rawRequest() and send()
8
- *
9
- * Session lifecycle invariant: every user-facing session (a modal open, a
10
- * verify flow, an upload widget invocation) starts with the owning Module
11
- * calling resetSession(). close() aborts the current AbortController; the
12
- * next resetSession() swaps in a fresh one. The Module is responsible for
13
- * this; clients of the SDK never see any of it.
14
- */
15
- import { SparkVaultError } from './errors';
16
- export interface RawRequestOptions {
17
- method: string;
18
- body?: string;
19
- headers?: Record<string, string>;
20
- /** Observe a successful response before its body is consumed. */
21
- onResponse?: (response: Response) => void;
22
- }
23
- export interface RawResponse {
24
- data: unknown;
25
- status: number;
26
- }
27
- /** Why a request produced no answer. */
28
- export type TransportFailure = 'cancelled' | 'timeout' | 'network' | 'unknown';
29
- export interface ExchangeOptions<T> {
30
- timeoutMs: number;
31
- /** The session's close signal, captured when the request starts. */
32
- closeSignal?: AbortSignal;
33
- /** Reads the response: runs under the same deadline and close signal as the request. */
34
- read: (response: Response) => Promise<T>;
35
- /** The SDK error for a request that produced no answer. */
36
- fail: (failure: TransportFailure, cause: unknown) => SparkVaultError;
37
- }
38
- /** The copy a SparkVaultApi client shows for each way a request can produce no answer. */
39
- export interface TransportCopy {
40
- readonly cancelled: string;
41
- readonly timeout: string;
42
- readonly network: string;
43
- }
44
- /**
45
- * Combine a fresh timeout with a session close signal into one AbortSignal.
46
- *
47
- * The returned dispose() MUST run in a finally block: it clears the timeout
48
- * and unlinks the close listener (the fallback path for browsers without
49
- * AbortSignal.any) so nothing leaks across requests. Callers discriminate
50
- * close-vs-timeout afterwards by checking the close signal's aborted flag.
51
- */
52
- export declare function combineTimeoutAndCloseSignals(timeoutMs: number, closeSignal?: AbortSignal): {
53
- signal: AbortSignal;
54
- dispose: () => void;
55
- };
56
- /**
57
- * One request under a deadline and an optional session close signal: the
58
- * fetch every SDK transport makes.
59
- *
60
- * The whole exchange (the response headers AND whatever `read` consumes of the
61
- * body) runs inside the deadline, so a body that stalls after its headers can
62
- * never pin the caller. An already-closed session never reaches fetch. A
63
- * failure with no answer is classified once: the close signal the caller
64
- * captured says cancelled, otherwise an abort is the deadline, a TypeError is
65
- * the network (browsers' "Failed to fetch" / "Load failed"), and anything else
66
- * is unknown. SDK errors `read` throws pass through as they are.
67
- */
68
- export declare function exchange<T>(url: string, init: RequestInit, options: ExchangeOptions<T>): Promise<T>;
69
- export declare abstract class SparkVaultApi {
70
- protected readonly timeoutMs: number;
71
- /**
72
- * Abort controller for the current session. Replaced by resetSession()
73
- * at the start of every user-facing session, so an aborted controller can
74
- * never leak into the next session.
75
- */
76
- private closeController;
77
- constructor(timeoutMs?: number);
78
- /** Abort all pending requests on this client. Called by the Module on close. */
79
- abort(): void;
80
- /** Whether the *current* session has been aborted. */
81
- isAborted(): boolean;
82
- /** The current session's abort signal, for callers that need to wire it into XHR/etc. */
83
- getAbortSignal(): AbortSignal;
84
- /**
85
- * Swap in a fresh AbortController. The Module calls this at the start of
86
- * every user-facing session. Long-lived per-client state (e.g. config
87
- * caches) is intentionally NOT cleared here.
88
- */
89
- resetSession(): void;
90
- /**
91
- * Subclass-specific error factory. A refused answer passes its
92
- * `Retry-After` (ms, as the transfer policy reads it) for the error to carry
93
- * as `retryAfterMs`; a request that got no answer passes none.
94
- */
95
- protected abstract makeError(message: string, code: string, statusCode: number, details?: Record<string, unknown>, retryAfterMs?: number | null): SparkVaultError;
96
- /**
97
- * One request in the current session: `exchange` bound to this client's
98
- * deadline, its error factory, and the session's close signal, captured
99
- * here, when the request starts. resetSession() can swap the controller
100
- * while the request is in flight, and reading the live one afterwards would
101
- * misreport a genuine cancel as a timeout.
102
- *
103
- * @param timeoutMs - The deadline of a request whose server-side wait is
104
- * its own (a tus HEAD or receipt, which Forge answers only after its call
105
- * to Core); every other request takes the client's.
106
- */
107
- protected send<T>(url: string, init: RequestInit, copy: TransportCopy, read: (response: Response) => Promise<T>, timeoutMs?: number): Promise<T>;
108
- /**
109
- * Issue a JSON API request. Returns the parsed JSON body (whatever shape it
110
- * takes; null when the body is not JSON) plus the status code. A non-2xx
111
- * answer throws the subclass error carrying the server's code, message,
112
- * details and `Retry-After`, read by the one failed-answer reader every
113
- * transport shares.
114
- */
115
- protected rawRequest(url: string, options: RawRequestOptions): Promise<RawResponse>;
116
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * SparkVault Auto-Initialization
3
- *
4
- * Auto-initializes the SDK from script tag data attributes.
5
- *
6
- * @example
7
- * ```html
8
- * <script
9
- * src="https://cdn.sparkvault.com/sdk/v1/sparkvault.js"
10
- * data-account-id="acc_your_account_id"
11
- * ></script>
12
- *
13
- * <script>
14
- * // SDK is ready - just use it
15
- * SparkVault.products.identity.attach('.login-btn', {
16
- * onSuccess: (result) => console.log('Verified:', result.identity)
17
- * });
18
- * </script>
19
- * ```
20
- *
21
- * Supported attributes:
22
- * - data-account-id: Account ID (required for auto-init)
23
- * - data-debug: Set to "true" to enable verbose console logging
24
- */
25
- import type { SparkVault } from './index';
26
- /**
27
- * Initialize the SDK from script tag attributes.
28
- *
29
- * Called automatically when the script loads.
30
- * Returns the initialized instance if data-account-id is present, null otherwise.
31
- */
32
- export declare function autoInit(SparkVaultClass: typeof SparkVault): SparkVault | null;
package/dist/config.d.ts DELETED
@@ -1,79 +0,0 @@
1
- /**
2
- * SparkVault SDK Configuration
3
- */
4
- /** Server-confirmed timing for the exact vault session a request presented. */
5
- export interface VaultSessionTiming {
6
- vat: string;
7
- /** Current reseal deadline in server Unix seconds. */
8
- expiresAt: number;
9
- /** Fixed maximum deadline from the original unseal, in server Unix seconds. */
10
- hardExpiresAt: number;
11
- /** Seconds remaining on the server, suitable for a device-local countdown. */
12
- remainingSeconds: number;
13
- hardRemainingSeconds: number;
14
- /** Zero for a fixed session; absent when talking to an older Core version. */
15
- idleTimeoutSeconds?: number;
16
- /** Device clock before the Core request, for conservative local countdowns. */
17
- requestStartedAtMs?: number;
18
- }
19
- export interface SparkVaultConfig {
20
- /** Account ID for Identity operations */
21
- accountId: string;
22
- /** Core API origin. Defaults to https://api.sparkvault.com. A trailing /v1 is accepted and normalized. */
23
- apiBaseUrl?: string;
24
- /** Identity Product API base URL. Defaults to https://auth.sparkvault.com. */
25
- identityBaseUrl?: string;
26
- /** auth.sv portal origin for self-service deep links (`portalUrl()`). Defaults to https://auth.sv. */
27
- portalBaseUrl?: string;
28
- /** Static SparkVault Core access token for authenticated API calls. */
29
- accessToken?: string;
30
- /** Dynamic SparkVault Core access token provider for authenticated API calls. */
31
- getAccessToken?: () => string | null | Promise<string | null>;
32
- /** Observe server-confirmed vault-session timing after an authorized Core response. */
33
- onVaultSessionTiming?: (timing: VaultSessionTiming) => void;
34
- /** Optional API key for server-side SDK use. */
35
- apiKey?: string;
36
- /**
37
- * OIDC client id registered for this account. Required only for FedCM
38
- * one-click sign-in (`signInWithFedcm()`), which asserts to a registered RP.
39
- */
40
- clientId?: string;
41
- /** Request timeout in milliseconds (default: 30000) */
42
- timeout?: number;
43
- /**
44
- * Preload Identity configuration on SDK init (default: true in a browser,
45
- * false off-DOM). When enabled, the /config call is made immediately when the
46
- * SDK initializes, so verify() opens instantly without waiting for the config
47
- * fetch. It buys nothing in a server process (there is no dialog to open),
48
- * so a Node host does not pay for a network call it will never use.
49
- * Set explicitly to override in either direction.
50
- */
51
- preloadConfig?: boolean;
52
- /** Enable backdrop blur on dialogs (default: true) */
53
- backdropBlur?: boolean;
54
- /**
55
- * Host allowlist for the backend-issued Forge transfer URLs the SDK sends an
56
- * ingot's ISTK to (downloads and uploads alike). Defaults to the SparkVault
57
- * platform's own hosts; override only when pointing at another deployment.
58
- */
59
- allowedDownloadHostPatterns?: RegExp[];
60
- }
61
- export interface ResolvedConfig {
62
- accountId: string;
63
- timeout: number;
64
- apiBaseUrl: string;
65
- identityBaseUrl: string;
66
- portalBaseUrl: string;
67
- accessToken?: string;
68
- getAccessToken?: () => string | null | Promise<string | null>;
69
- onVaultSessionTiming?: (timing: VaultSessionTiming) => void;
70
- apiKey?: string;
71
- clientId?: string;
72
- preloadConfig: boolean;
73
- backdropBlur: boolean;
74
- allowedDownloadHostPatterns: RegExp[];
75
- }
76
- export declare function resolveConfig(config: SparkVaultConfig): ResolvedConfig;
77
- /** Whether the configured allowlist trusts the host of a backend-issued transfer URL. */
78
- export declare function isAllowedTransferHost(config: ResolvedConfig, hostname: string): boolean;
79
- export declare function validateConfig(config: SparkVaultConfig): void;
@@ -1,35 +0,0 @@
1
- /**
2
- * Entropy Module
3
- *
4
- * Generate cryptographically strong random values from the SparkVault
5
- * hardware-backed entropy service.
6
- */
7
- import { HttpClient } from '../http';
8
- import type { GenerateEntropyOptions, EntropyResult } from './types';
9
- export declare class EntropyModule {
10
- private readonly http;
11
- constructor(http: HttpClient);
12
- /**
13
- * Generate random entropy in the requested format.
14
- *
15
- * @example
16
- * const { value } = await sv.entropy.generate({ bytes: 32, format: 'hex' });
17
- */
18
- generate(options: GenerateEntropyOptions): Promise<EntropyResult>;
19
- /**
20
- * Generate `n` random bytes as a Uint8Array.
21
- *
22
- * SECURITY: this returns raw *server* entropy; it is NOT finished key
23
- * material. Client secret keys MUST hybrid-mix it: XOR the returned bytes with
24
- * a local CSPRNG (`crypto.getRandomValues`) before use, so the server share
25
- * alone can never determine the key.
26
- *
27
- * @example
28
- * const serverEntropy = await sv.entropy.generateBytes(32);
29
- * const localEntropy = crypto.getRandomValues(new Uint8Array(32));
30
- * // Hybrid-mixed key material, safe to use as a secret key.
31
- * const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
32
- */
33
- generateBytes(n: number): Promise<Uint8Array>;
34
- }
35
- export type { GenerateEntropyOptions, EntropyResult, EntropyFormat } from './types';
@@ -1,32 +0,0 @@
1
- /**
2
- * Entropy Module Types
3
- *
4
- * Hardware-backed random generation. Public domain objects are camelCase;
5
- * wire shapes (snake_case) stay private to the module.
6
- */
7
- /** Output encoding for generated entropy. */
8
- export type EntropyFormat = 'hex' | 'base64' | 'base64url' | 'alphanumeric' | 'alphanumeric-mixed' | 'password' | 'numeric' | 'uuid' | 'bytes';
9
- /** Options for generate. */
10
- export interface GenerateEntropyOptions {
11
- /** Number of random bytes: 1 to 1024, or 1 to 512 for alphanumeric, alphanumeric-mixed and password. */
12
- bytes: number;
13
- /** Output format. Defaults to hex. */
14
- format?: EntropyFormat;
15
- }
16
- /** The result of generating entropy. */
17
- export interface EntropyResult {
18
- /** Generated value in the requested format. For `bytes`, a number array. */
19
- value: string | number[];
20
- /** Number of bytes the server drew */
21
- numBytes: number;
22
- /** Format the value is encoded in */
23
- format: EntropyFormat;
24
- /** Server reference ID for the operation */
25
- referenceId?: string;
26
- }
27
- export interface EntropyResponse {
28
- value: string | number[];
29
- num_bytes: number;
30
- format: EntropyFormat;
31
- reference_id?: string;
32
- }
package/dist/errors.d.ts DELETED
@@ -1,146 +0,0 @@
1
- /**
2
- * SparkVault SDK Error Types
3
- */
4
- export declare class SparkVaultError extends Error {
5
- readonly code: string;
6
- readonly statusCode?: number;
7
- readonly details?: Record<string, unknown>;
8
- /**
9
- * The answer's `Retry-After`, in ms from the answer, read by the platform's
10
- * one parser (`parseRetryAfterMs`; RFC 9110 §10.2.3: delay-seconds or an
11
- * HTTP-date): the earliest a next attempt can expect another answer, which
12
- * every retry the SDK makes waits out as a floor. Null when the answer
13
- * carried none the parser could read, or no answer arrived.
14
- */
15
- readonly retryAfterMs: number | null;
16
- /**
17
- * The machine-readable code the API answered with (`INVALID_CURSOR`,
18
- * `LICENSE_REQUIRED`), on every error the SDK's API client builds from a
19
- * refused call of a data-plane module (`vaults`, `ingots`, `folders`,
20
- * `sparks`, `entropy`, `notify`, `products.notify`); `api_error` when the
21
- * answer named none (a gateway's HTML). A typed refusal's `code` names its
22
- * class of failure: one per 400 (`validation_error`), two per 401
23
- * (`authentication_error`, `UNAUTHORIZED`), 402 (`PLAN_REQUIRED`,
24
- * `QUOTA_EXCEEDED`, `USAGE_CREDITS_EXHAUSTED`) and 403 (`authorization_error`;
25
- * http.ts createErrorFromResponse), so this is what tells apart two
26
- * refusals that share a code.
27
- * Undefined on an error the SDK raised itself, on the Identity product's
28
- * errors (`products.identity`, whose `code` is the service's own), and on the
29
- * errors of an upload's transfer (`UploadApiError`, which names Core's code in
30
- * its `code` or `details.coreCode`, a staging call Core refused for good among
31
- * them) and of a download (`download_failed`, its status alone).
32
- */
33
- readonly serviceCode?: string;
34
- constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
35
- }
36
- export declare class AuthenticationError extends SparkVaultError {
37
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
38
- }
39
- /**
40
- * A key the request presents was refused (401 UNAUTHORIZED): the DVAK an
41
- * unseal names is invalid or revoked. The caller's own credential stood, so
42
- * this is no ended session, and signing in again changes nothing: present a
43
- * live key. Every other 401 is an {@link AuthenticationError}.
44
- */
45
- export declare class UnauthorizedError extends SparkVaultError {
46
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
47
- }
48
- export declare class AuthorizationError extends SparkVaultError {
49
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
50
- }
51
- export declare class ValidationError extends SparkVaultError {
52
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
53
- }
54
- /**
55
- * The pooled-capacity resource a quota gate refers to. Only the byte pools
56
- * hard-gate: licenses are assigned per member, never drawn from a pool
57
- * (inviting and licensing are never quota-gated), and Identity soft-gates
58
- * through its own path.
59
- */
60
- export type QuotaResource = 'storage' | 'bandwidth';
61
- /**
62
- * Plan required gate (402 PLAN_REQUIRED): the account has no active
63
- * subscription and attempted a billable/create action. Surface a subscribe CTA
64
- * to admins, or "ask your account admin" to members.
65
- */
66
- export declare class PlanRequiredError extends SparkVaultError {
67
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
68
- }
69
- /**
70
- * Prepaid usage is exhausted (402 USAGE_CREDITS_EXHAUSTED). The subscription
71
- * can still be active: an admin replenishes the shared usage-credit wallet.
72
- */
73
- export declare class UsageCreditsExhaustedError extends SparkVaultError {
74
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
75
- }
76
- /** A payment reversal requires billing review; buying more credits cannot clear it. */
77
- export declare class UsageCreditFundingReviewError extends SparkVaultError {
78
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
79
- }
80
- /**
81
- * Quota exceeded gate (402 QUOTA_EXCEEDED): a pooled-capacity limit is
82
- * exhausted. `resource` identifies which pool so callers can point the CTA at
83
- * the right capacity block.
84
- */
85
- export declare class QuotaExceededError extends SparkVaultError {
86
- readonly resource?: QuotaResource;
87
- constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
88
- }
89
- export declare class NetworkError extends SparkVaultError {
90
- constructor(message: string, details?: Record<string, unknown>);
91
- }
92
- export declare class TimeoutError extends SparkVaultError {
93
- constructor(message?: string);
94
- }
95
- export declare class UserCancelledError extends SparkVaultError {
96
- constructor(message?: string);
97
- }
98
- /**
99
- * The identity provider answered a FedCM sign-in with an error of its own
100
- * (the browser's `IdentityCredentialError`), after the browser showed the
101
- * person its error dialog: the request reached the provider, which refused or
102
- * failed it, so it is no cancel. `code` is the provider's answer
103
- * (`server_error`, `access_denied`, ...).
104
- */
105
- export declare class IdentityProviderError extends SparkVaultError {
106
- constructor(code: string);
107
- }
108
- export declare class PopupBlockedError extends SparkVaultError {
109
- constructor();
110
- }
111
- /**
112
- * The popup opened but its window handle went dead before the page ever
113
- * pinged back: the host page's Cross-Origin-Opener-Policy severed it (a host
114
- * page serving `COOP: same-origin` detaches any cross-origin popup: the popup
115
- * loses `window.opener`, the opener's handle reports `closed`). postMessage
116
- * can never work in this state, so retrying the popup is futile. Identity
117
- * sign-in falls back to the redirect flow (popup-launcher.ts); the help desk
118
- * widget's sign-in, which has none, passes a message that tells the person
119
- * what to do (help-desk/widget-identity.ts).
120
- */
121
- export declare class PopupSeveredError extends SparkVaultError {
122
- constructor(message?: string);
123
- }
124
- /** What a failed SparkVault API response says about itself: its status, its error body, and the floor it names. */
125
- export interface ApiFailure {
126
- status: number;
127
- message: string;
128
- code: string;
129
- details?: Record<string, unknown>;
130
- /** The answer's `Retry-After` in ms ({@link SparkVaultError.retryAfterMs}); null when it carries none. */
131
- retryAfterMs: number | null;
132
- }
133
- /** A failed answer as a transport holds it: its status, its whole body's text, and a reader of its headers. */
134
- export interface FailedAnswer {
135
- readonly status: number;
136
- readonly body: string;
137
- readonly header: (name: string) => string | null;
138
- }
139
- /**
140
- * Read a failed answer a transport holds as text (an XMLHttpRequest's
141
- * `responseText`, a body it also keeps a snippet of), parsed whole, so
142
- * nothing past any length is lost to the reading.
143
- */
144
- export declare function apiFailureOf(answer: FailedAnswer): ApiFailure;
145
- /** Read a failed fetch response; a body that is not JSON, or cannot be read, reads as none. */
146
- export declare function readApiFailure(response: Response): Promise<ApiFailure>;
@@ -1,102 +0,0 @@
1
- /**
2
- * Folders Module
3
- *
4
- * Organize ingots within an *unsealed* vault. Every method takes the
5
- * {@link UnsealedVault} returned by `sv.vaults.unseal(...)` and authenticates
6
- * with its short-lived Vault Access Token (VAT).
7
- */
8
- import { HttpClient } from '../http';
9
- import type { UnsealedVault, Folder, FolderBreadcrumbItem, CreateFolderOptions, UpdateFolderOptions, FolderWire, FolderPage, ListFoldersOptions } from './types';
10
- export declare class FoldersModule {
11
- private readonly http;
12
- constructor(http: HttpClient);
13
- /**
14
- * One page of the vault's folders ({@link FolderPage}). Pass a page's
15
- * `nextPageToken` back as `pageToken` until it is null. To show one
16
- * folder's subfolders, list its contents (`ingots.listContents`) instead.
17
- *
18
- * @example
19
- * let pageToken: string | undefined;
20
- * do {
21
- * const page = await sv.folders.list(unsealed, { pageToken });
22
- * page.folders.forEach((f) => console.log(f.name));
23
- * pageToken = page.nextPageToken ?? undefined;
24
- * } while (pageToken);
25
- */
26
- list(vault: UnsealedVault, options?: ListFoldersOptions): Promise<FolderPage>;
27
- /**
28
- * The folder at `path`, or null when the vault has none there. `path` is an
29
- * upload's folder path (`folder` on an upload): slash-delimited from the
30
- * vault root, each name matched in any case, validated by the API as an
31
- * upload's is. The API reads only that path, never the vault's folder list.
32
- *
33
- * @throws ValidationError when `path` is not a non-empty string: an empty
34
- * value is left out of the query, which would ask for every folder instead
35
- * of the one at a path
36
- * @throws SparkVaultError (`invalid_response`) when the answer is not one
37
- * folder or none
38
- *
39
- * @example
40
- * const invoices = await sv.folders.findByPath(unsealed, 'Clients/Northfield/Invoices');
41
- */
42
- findByPath(vault: UnsealedVault, path: string): Promise<Folder | null>;
43
- /**
44
- * Get a single folder.
45
- *
46
- * @example
47
- * const folder = await sv.folders.get(unsealed, 'fld_abc');
48
- */
49
- get(vault: UnsealedVault, folderId: string): Promise<Folder>;
50
- /**
51
- * Get a folder's breadcrumb trail (Root → … → folder).
52
- *
53
- * @example
54
- * const trail = await sv.folders.getBreadcrumb(unsealed, 'fld_abc');
55
- */
56
- getBreadcrumb(vault: UnsealedVault, folderId: string): Promise<FolderBreadcrumbItem[]>;
57
- /**
58
- * Create a folder.
59
- *
60
- * @example
61
- * const folder = await sv.folders.create(unsealed, { name: 'Invoices' });
62
- */
63
- create(vault: UnsealedVault, data: CreateFolderOptions): Promise<Folder>;
64
- /**
65
- * Update a folder (rename, move, pin/unpin).
66
- *
67
- * @example
68
- * await sv.folders.update(unsealed, 'fld_abc', { name: 'Renamed' });
69
- */
70
- update(vault: UnsealedVault, folderId: string, data: UpdateFolderOptions): Promise<Folder>;
71
- /**
72
- * Move a folder under a new parent, or to the vault root with `null`.
73
- *
74
- * @example
75
- * await sv.folders.move(unsealed, 'fld_abc', 'fld_parent');
76
- */
77
- move(vault: UnsealedVault, folderId: string, newParentId: string | null): Promise<Folder>;
78
- /**
79
- * Pin or unpin a folder.
80
- *
81
- * @example
82
- * await sv.folders.togglePin(unsealed, 'fld_abc', true);
83
- */
84
- togglePin(vault: UnsealedVault, folderId: string, pinned: boolean): Promise<Folder>;
85
- /**
86
- * Delete a folder.
87
- *
88
- * @example
89
- * await sv.folders.delete(unsealed, 'fld_abc');
90
- */
91
- delete(vault: UnsealedVault, folderId: string): Promise<void>;
92
- /**
93
- * Move an ingot into a folder, or to the vault root with `null`.
94
- *
95
- * @example
96
- * await sv.folders.moveIngot(unsealed, 'ing_abc', 'fld_xyz');
97
- */
98
- moveIngot(vault: UnsealedVault, ingotId: string, folderId: string | null): Promise<void>;
99
- }
100
- /** A folder as the API sends it, in the SDK's shape (also the contents listing's subfolders). */
101
- export declare function mapFolder(wire: FolderWire): Folder;
102
- export type { UnsealedVault, Folder, FolderBreadcrumbItem, FolderPage, ListFoldersOptions, CreateFolderOptions, UpdateFolderOptions, } from './types';