@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.
- package/README.md +26 -4
- package/dist/npm/chunks/index-BnP-2w0t.cjs +13025 -0
- package/dist/npm/chunks/index-BnP-2w0t.cjs.map +1 -0
- package/dist/npm/chunks/index-CgR08uMG.mjs +12960 -0
- package/dist/npm/chunks/index-CgR08uMG.mjs.map +1 -0
- package/dist/npm/identity.cjs +23 -0
- package/dist/npm/identity.cjs.map +1 -0
- package/dist/npm/identity.mjs +12 -0
- package/dist/npm/identity.mjs.map +1 -0
- package/dist/{index.cjs → npm/index.cjs} +799 -13755
- package/dist/npm/index.cjs.map +1 -0
- package/dist/{index.mjs → npm/index.mjs} +200 -13155
- package/dist/npm/index.mjs.map +1 -0
- package/dist/sparkvault-identity.js +2 -0
- package/dist/sparkvault-identity.js.map +1 -0
- package/dist/sparkvault.js +1 -1
- package/dist/types/identity.d.ts +8 -0
- package/dist/{index.d.ts → types/index.d.ts} +4 -790
- package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
- package/package.json +20 -9
- package/dist/api-base.d.ts +0 -116
- package/dist/auto-init.d.ts +0 -32
- package/dist/config.d.ts +0 -79
- package/dist/entropy/index.d.ts +0 -35
- package/dist/entropy/types.d.ts +0 -32
- package/dist/errors.d.ts +0 -146
- package/dist/folders/index.d.ts +0 -102
- package/dist/folders/types.d.ts +0 -91
- package/dist/health.d.ts +0 -18
- package/dist/http.d.ts +0 -46
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/ingots/fetch-download.d.ts +0 -78
- package/dist/ingots/history.d.ts +0 -4
- package/dist/ingots/index.d.ts +0 -388
- package/dist/ingots/revision.d.ts +0 -4
- package/dist/ingots/types.d.ts +0 -556
- package/dist/logger.d.ts +0 -32
- package/dist/notify/index.d.ts +0 -154
- package/dist/notify/types.d.ts +0 -232
- package/dist/products/help-desk/client.d.ts +0 -198
- package/dist/products/help-desk/desk-id.d.ts +0 -2
- package/dist/products/help-desk/form-draft.d.ts +0 -37
- package/dist/products/help-desk/form-types.d.ts +0 -123
- package/dist/products/help-desk/form.d.ts +0 -83
- package/dist/products/help-desk/index.d.ts +0 -47
- package/dist/products/help-desk/kb-client.d.ts +0 -48
- package/dist/products/help-desk/kb-types.d.ts +0 -59
- package/dist/products/help-desk/modal.d.ts +0 -8
- package/dist/products/help-desk/styles.d.ts +0 -9
- package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
- package/dist/products/help-desk/support-analytics.d.ts +0 -3
- package/dist/products/help-desk/support-brand.d.ts +0 -49
- package/dist/products/help-desk/support-controller.d.ts +0 -4
- package/dist/products/help-desk/support-history.d.ts +0 -38
- package/dist/products/help-desk/support-launcher.d.ts +0 -12
- package/dist/products/help-desk/support-styles.d.ts +0 -14
- package/dist/products/help-desk/support-types.d.ts +0 -66
- package/dist/products/help-desk/support-view.d.ts +0 -173
- package/dist/products/help-desk/types.d.ts +0 -285
- package/dist/products/help-desk/widget-identity.d.ts +0 -32
- package/dist/products/identity/api.d.ts +0 -237
- package/dist/products/identity/container.d.ts +0 -44
- package/dist/products/identity/dialog-launcher.d.ts +0 -133
- package/dist/products/identity/federation-flow.d.ts +0 -31
- package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
- package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
- package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
- package/dist/products/identity/index.d.ts +0 -296
- package/dist/products/identity/inline-container.d.ts +0 -53
- package/dist/products/identity/methods.d.ts +0 -19
- package/dist/products/identity/modal.d.ts +0 -51
- package/dist/products/identity/pending-signin.d.ts +0 -102
- package/dist/products/identity/popup-launcher.d.ts +0 -73
- package/dist/products/identity/renderer.d.ts +0 -525
- package/dist/products/identity/state.d.ts +0 -84
- package/dist/products/identity/styles.d.ts +0 -31
- package/dist/products/identity/types.d.ts +0 -561
- package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
- package/dist/products/identity/utils.d.ts +0 -85
- package/dist/products/identity/views/backup-verify.d.ts +0 -42
- package/dist/products/identity/views/base.d.ts +0 -51
- package/dist/products/identity/views/error.d.ts +0 -65
- package/dist/products/identity/views/icons.d.ts +0 -41
- package/dist/products/identity/views/identity-input.d.ts +0 -80
- package/dist/products/identity/views/index.d.ts +0 -20
- package/dist/products/identity/views/loading.d.ts +0 -23
- package/dist/products/identity/views/method-button.d.ts +0 -14
- package/dist/products/identity/views/method-select.d.ts +0 -42
- package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
- package/dist/products/identity/views/otp-verify.d.ts +0 -58
- package/dist/products/identity/views/passkey-auto.d.ts +0 -22
- package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
- package/dist/products/identity/views/passkey.d.ts +0 -38
- package/dist/products/identity/views/product-not-configured.d.ts +0 -21
- package/dist/products/identity/views/service-unavailable.d.ts +0 -21
- package/dist/products/identity/views/sms-consent.d.ts +0 -16
- package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
- package/dist/products/identity/views/two-factor.d.ts +0 -37
- package/dist/products/index.d.ts +0 -51
- package/dist/products/messaging/index.d.ts +0 -38
- package/dist/products/messaging/types.d.ts +0 -162
- package/dist/products/notify/index.d.ts +0 -436
- package/dist/products/notify/project-types.d.ts +0 -44
- package/dist/products/notify/projects.d.ts +0 -15
- package/dist/products/notify/types.d.ts +0 -1327
- package/dist/products/structured-ingots/index.d.ts +0 -31
- package/dist/products/structured-ingots/types-client.d.ts +0 -19
- package/dist/products/structured-ingots/types.d.ts +0 -293
- package/dist/products/structured-ingots/validation.d.ts +0 -25
- package/dist/request-path.d.ts +0 -44
- package/dist/sparks/index.d.ts +0 -91
- package/dist/sparks/types.d.ts +0 -304
- package/dist/ui/chrome.d.ts +0 -16
- package/dist/ui/ds-tokens.d.ts +0 -59
- package/dist/ui/inline-shell.d.ts +0 -19
- package/dist/ui/live-region.d.ts +0 -15
- package/dist/ui/modal-shell.d.ts +0 -67
- package/dist/ui/target.d.ts +0 -6
- package/dist/utils/dom.d.ts +0 -26
- package/dist/vault-session.d.ts +0 -2
- package/dist/vaults/index.d.ts +0 -254
- package/dist/vaults/types.d.ts +0 -368
- package/dist/vaults/upload/api.d.ts +0 -310
- package/dist/vaults/upload/chrome.d.ts +0 -21
- package/dist/vaults/upload/container.d.ts +0 -37
- package/dist/vaults/upload/index.d.ts +0 -76
- package/dist/vaults/upload/inline-container.d.ts +0 -41
- package/dist/vaults/upload/modal.d.ts +0 -55
- package/dist/vaults/upload/renderer.d.ts +0 -150
- package/dist/vaults/upload/styles.d.ts +0 -14
- package/dist/vaults/upload/types.d.ts +0 -220
|
@@ -0,0 +1,800 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SparkVault SDK Configuration
|
|
3
|
+
*/
|
|
4
|
+
/** Server-confirmed timing for the exact vault session a request presented. */
|
|
5
|
+
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
|
+
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
|
+
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
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Identity Module Types
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* The kind of identifier a sign-in verified. `federated` is a person the
|
|
82
|
+
* account's own identity provider signed in: one person of that account's
|
|
83
|
+
* directory alone, never a global identity.
|
|
84
|
+
*/
|
|
85
|
+
type VerifiedIdentityType = 'email' | 'phone' | 'social' | 'federated';
|
|
86
|
+
/**
|
|
87
|
+
* An identity type a sign-in may be restricted to (`SignInOptions.identityTypes`):
|
|
88
|
+
* the kinds a token's `identity_type` carries, as the sign-in contract
|
|
89
|
+
* (app-sdk identity-signin-contract SIGNIN_IDENTITY_TYPES) names them.
|
|
90
|
+
*/
|
|
91
|
+
type SigninIdentityType = VerifiedIdentityType;
|
|
92
|
+
/**
|
|
93
|
+
* Auth context for OIDC or simple redirect flows.
|
|
94
|
+
* Used by hosted login pages to complete authorization flows.
|
|
95
|
+
*/
|
|
96
|
+
interface AuthContext {
|
|
97
|
+
/** OIDC auth request ID for authorization code flow */
|
|
98
|
+
authRequestId?: string;
|
|
99
|
+
/**
|
|
100
|
+
* A verification against a verify session, as the SparkVault-hosted page
|
|
101
|
+
* that serves it describes it. Every request of the verification names the
|
|
102
|
+
* session, and the server reads its destination, state and purpose from it.
|
|
103
|
+
* `methods` and `allowedIdentityTypes` are what the session admits, decided
|
|
104
|
+
* by the server from the session, and the page offers them in place of the
|
|
105
|
+
* account's sign-in methods: a Notify recipient's proof of address admits a
|
|
106
|
+
* code emailed to the address it was sent to and a passkey, whatever the
|
|
107
|
+
* account's sign-in switches on, and the passkey alone for a request its
|
|
108
|
+
* sender held to a passkey; no verify session admits a SparkLink or a social
|
|
109
|
+
* sign-in, neither of which can complete one.
|
|
110
|
+
*/
|
|
111
|
+
simpleMode?: {
|
|
112
|
+
/** Opaque server-side verify session the verification completes against */
|
|
113
|
+
sessionId: string;
|
|
114
|
+
/** The methods the session admits */
|
|
115
|
+
methods: MethodId[];
|
|
116
|
+
/** The identifier types the session's methods deliver to */
|
|
117
|
+
allowedIdentityTypes: ('email' | 'phone')[];
|
|
118
|
+
/**
|
|
119
|
+
* True when the session proves a request its sender held to a passkey: it
|
|
120
|
+
* admits the passkey alone, so a person who holds no passkey registered
|
|
121
|
+
* with SparkVault is told that only the sender can resend the request at a
|
|
122
|
+
* level they can clear, never offered a way that cannot complete it.
|
|
123
|
+
* Absent reads as false.
|
|
124
|
+
*/
|
|
125
|
+
passkeyRequired?: boolean;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
interface VerifyOptions {
|
|
129
|
+
/** Pre-fill email address (mutually exclusive with phone) */
|
|
130
|
+
email?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Pre-fill phone number in E.164 format, e.g. "+14155551234" (mutually
|
|
133
|
+
* exclusive with email). The sign-in texts or calls it only once the person
|
|
134
|
+
* picks a text or call method, under the SMS and voice consent.
|
|
135
|
+
*/
|
|
136
|
+
phone?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Target element for inline rendering. Can be:
|
|
139
|
+
* - A CSS selector string (e.g., "#auth-container")
|
|
140
|
+
* - An HTMLElement reference
|
|
141
|
+
* - Omitted for dialog mode (default)
|
|
142
|
+
*/
|
|
143
|
+
target?: string | HTMLElement;
|
|
144
|
+
/** Override backdrop blur for this dialog (uses global config if omitted) */
|
|
145
|
+
backdropBlur?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Container chrome for inline (`target`) rendering. `'card'` (default) wraps
|
|
148
|
+
* the flow in a bordered, rounded surface with the SparkVault footer. `'bare'`
|
|
149
|
+
* drops the surface and footer so a host page (e.g. the SparkVault sign-in
|
|
150
|
+
* page) can supply its own full-window chrome: logo, background, footer.
|
|
151
|
+
* Ignored in dialog mode.
|
|
152
|
+
*/
|
|
153
|
+
chrome?: 'card' | 'bare';
|
|
154
|
+
/** Auth context for OIDC/simple mode flows (used by hosted login) */
|
|
155
|
+
authContext?: AuthContext;
|
|
156
|
+
/**
|
|
157
|
+
* How sign-in leaves this page. `'auto'` (default) and `'popup'` open the
|
|
158
|
+
* first-party popup; `'redirect'` navigates this tab to the sign-in page
|
|
159
|
+
* instead (its return leg is `handleRedirectResult()`), the opt-out for
|
|
160
|
+
* hosts that prefer a full-page redirect over a popup on mobile.
|
|
161
|
+
*/
|
|
162
|
+
flow?: 'auto' | 'popup' | 'redirect';
|
|
163
|
+
/**
|
|
164
|
+
* `'select_account'` always shows the sign-in page's account chooser instead
|
|
165
|
+
* of silently continuing as the current account, even when only one saved
|
|
166
|
+
* account exists. Any other value is dropped at URL serialization.
|
|
167
|
+
*/
|
|
168
|
+
prompt?: 'select_account';
|
|
169
|
+
/**
|
|
170
|
+
* `'federation'` starts sign-in with the account's own identity provider
|
|
171
|
+
* at once: the sign-in page skips its account chooser and the method list
|
|
172
|
+
* and leaves for the provider. Honoured only while the account has its
|
|
173
|
+
* identity provider switched on; otherwise the page starts as usual,
|
|
174
|
+
* account chooser included. Any other value is dropped at URL
|
|
175
|
+
* serialization.
|
|
176
|
+
*/
|
|
177
|
+
method?: 'federation';
|
|
178
|
+
/**
|
|
179
|
+
* The identity types this sign-in may produce (the token's `identity_type`),
|
|
180
|
+
* for a caller that accepts only some: the sign-in page offers only the ways
|
|
181
|
+
* in that can produce one, and Identity refuses a sign-in of any other type
|
|
182
|
+
* before it is counted, billed or minted. At least one type; a value that
|
|
183
|
+
* names none, or a type outside `SigninIdentityType`, is a ValidationError
|
|
184
|
+
* before anything opens. Omitted: any type, as without it. The caller's own
|
|
185
|
+
* check of the token's `identity_type` stays its final gate.
|
|
186
|
+
*/
|
|
187
|
+
identityTypes?: SigninIdentityType[];
|
|
188
|
+
/**
|
|
189
|
+
* Rendering strategy (internal). `'local'` renders the flow directly in this
|
|
190
|
+
* document: used inside the popup that runs the flow, and forced for inline
|
|
191
|
+
* (`target`) rendering. Dialog mode (omitted) renders a thin launcher and
|
|
192
|
+
* opens the popup.
|
|
193
|
+
*/
|
|
194
|
+
renderMode?: 'local';
|
|
195
|
+
/**
|
|
196
|
+
* The sign-in's reference (internal): set by the SparkVault sign-in page
|
|
197
|
+
* that runs the flow, never by a site. Every call that completes the
|
|
198
|
+
* sign-in from the page carries the reference the flow holds at that
|
|
199
|
+
* moment, and so does a start through the account's own identity
|
|
200
|
+
* provider, so Identity records it on the hub session the sign-in creates
|
|
201
|
+
* or chooses (or, for the provider, which opens none, releases it from the
|
|
202
|
+
* browser's hub sessions), and a lost popup result recovers that sign-in
|
|
203
|
+
* only. The flow offers the provider only on an explicit signal: a
|
|
204
|
+
* reference held, or `completesInWindow`. The reference never holds up the
|
|
205
|
+
* sign-in: a call made before it arrives carries none.
|
|
206
|
+
* - A reference: held from the start. The provider is offered. A value
|
|
207
|
+
* that is no reference is `null`.
|
|
208
|
+
* - A function: the reference arrives after the flow renders. The flow
|
|
209
|
+
* calls it once as it starts, and again only on the person's Try Again;
|
|
210
|
+
* each call asks afresh, and resolves to a reference, or to null when
|
|
211
|
+
* none could be had for now (a rejection, or a value that is no
|
|
212
|
+
* reference, is null too). The provider is offered once a reference
|
|
213
|
+
* arrives. Until then an account with other methods shows those; one
|
|
214
|
+
* whose only way in is the provider waits for it, and is told to try
|
|
215
|
+
* again when none could be had.
|
|
216
|
+
* - `null`: the page can never hold one (an SDK that predates the
|
|
217
|
+
* reference opened it), so the provider is never offered: such a
|
|
218
|
+
* sign-in opens no hub session, and its lost result could recover
|
|
219
|
+
* another person's.
|
|
220
|
+
* - Omitted: the provider is offered only when the page says it completes
|
|
221
|
+
* in its own window (`completesInWindow`); never for a page that predates
|
|
222
|
+
* the reference, whatever its window.
|
|
223
|
+
*/
|
|
224
|
+
signinRef?: string | null | (() => Promise<string | null>);
|
|
225
|
+
/**
|
|
226
|
+
* The sign-in completes in this window (internal): set by the SparkVault
|
|
227
|
+
* hosted sign-in page, which finishes an authorization request where it
|
|
228
|
+
* runs (an authorization code to the relying party, or a simple-mode
|
|
229
|
+
* redirect) and never hands its result to an opener. No recovery ever
|
|
230
|
+
* stands in for that result, so the page offers the account's own identity
|
|
231
|
+
* provider without a reference, in a popup too. Ignored when `signinRef`
|
|
232
|
+
* is given.
|
|
233
|
+
*/
|
|
234
|
+
completesInWindow?: boolean;
|
|
235
|
+
/** Called when user cancels (if omitted, uses server-configured redirect) */
|
|
236
|
+
onCancel?: () => void;
|
|
237
|
+
/** Called when verification completes (if omitted, uses server-configured redirect) */
|
|
238
|
+
onSuccess?: (result: VerifyResult) => void;
|
|
239
|
+
/** Called on error (if omitted, uses server-configured redirect) */
|
|
240
|
+
onError?: (error: Error) => void;
|
|
241
|
+
}
|
|
242
|
+
/** Options for attach() - binds verification to element clicks */
|
|
243
|
+
interface AttachOptions {
|
|
244
|
+
/** Pre-fill email address */
|
|
245
|
+
email?: string;
|
|
246
|
+
/** Pre-fill phone number in E.164 format (see `VerifyOptions.phone`) */
|
|
247
|
+
phone?: string;
|
|
248
|
+
/** Auth context for OIDC/simple mode flows */
|
|
249
|
+
authContext?: AuthContext;
|
|
250
|
+
/** `'select_account'` always shows the account chooser (see `VerifyOptions.prompt`) */
|
|
251
|
+
prompt?: 'select_account';
|
|
252
|
+
/** `'federation'` starts with the account's own identity provider (see `VerifyOptions.method`) */
|
|
253
|
+
method?: 'federation';
|
|
254
|
+
/** The identity types the sign-in may produce (see `VerifyOptions.identityTypes`) */
|
|
255
|
+
identityTypes?: SigninIdentityType[];
|
|
256
|
+
/** Called when user cancels */
|
|
257
|
+
onCancel?: () => void;
|
|
258
|
+
/** Called when verification completes */
|
|
259
|
+
onSuccess?: (result: VerifyResult) => void;
|
|
260
|
+
/** Called on error */
|
|
261
|
+
onError?: (error: Error) => void;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* A server-decided post-login nudge. Computed once per login (default mode);
|
|
265
|
+
* clients render the steps they support, in order, before completing.
|
|
266
|
+
*/
|
|
267
|
+
type Recommendation = {
|
|
268
|
+
type: 'passkey';
|
|
269
|
+
} | {
|
|
270
|
+
type: 'backup_identifier';
|
|
271
|
+
missingType: 'email' | 'phone';
|
|
272
|
+
};
|
|
273
|
+
/** A self-service screen in the auth.sv Identity portal. */
|
|
274
|
+
type PortalSection = 'home' | 'identity' | 'security' | 'sessions' | 'sites';
|
|
275
|
+
/** Options for building an auth.sv portal deep link (`portalUrl()`). */
|
|
276
|
+
interface PortalUrlOptions {
|
|
277
|
+
/** Which portal screen to open. Defaults to `'home'`. */
|
|
278
|
+
section?: PortalSection;
|
|
279
|
+
/**
|
|
280
|
+
* Focus a specific connected site on the Sites screen (an `acc_…` account ID).
|
|
281
|
+
* When `section` is `'sites'` and `site` is omitted, defaults to this SDK's
|
|
282
|
+
* own `accountId` (i.e. "manage this site"). Ignored for other sections.
|
|
283
|
+
*/
|
|
284
|
+
site?: string;
|
|
285
|
+
}
|
|
286
|
+
interface VerifyResult {
|
|
287
|
+
/** Signed JWT token */
|
|
288
|
+
token: string;
|
|
289
|
+
/** Verified identifier used for audit and user-facing attribution; passkey credentials route by SVID. */
|
|
290
|
+
identity: string;
|
|
291
|
+
/** Type of identifier returned with the verification result. */
|
|
292
|
+
identityType: VerifiedIdentityType;
|
|
293
|
+
/** Canonical SparkVault ID */
|
|
294
|
+
svid?: string;
|
|
295
|
+
/** Managed SparkVault Identity session ID */
|
|
296
|
+
sessionId?: string;
|
|
297
|
+
/** Managed-session refresh token, when the flow returns one */
|
|
298
|
+
refreshToken?: string;
|
|
299
|
+
/** Redirect URL (only present for OIDC/simple mode flows) */
|
|
300
|
+
redirect?: string;
|
|
301
|
+
/** Ordered post-login nudges (default-mode logins only). */
|
|
302
|
+
recommendations?: Recommendation[];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Options for `signIn()`: the customer-facing popup sign-in. The popup owns its
|
|
306
|
+
* rendering, so there is no inline `target`/`renderMode`/`chrome`/`signinRef`/
|
|
307
|
+
* `completesInWindow` here; those are internal to the SparkVault-hosted
|
|
308
|
+
* sign-in surfaces.
|
|
309
|
+
*/
|
|
310
|
+
type SignInOptions = Omit<VerifyOptions, 'target' | 'renderMode' | 'chrome' | 'signinRef' | 'completesInWindow'>;
|
|
311
|
+
/**
|
|
312
|
+
* Options for the SparkVault sign-in page's own render (internal): the flow's
|
|
313
|
+
* options, with the page's restriction as its URL's `identity_types` spells
|
|
314
|
+
* it, unread. The flow reads it (app-sdk readSigninIdentityTypes): absent is
|
|
315
|
+
* no restriction, and a spelling it cannot read shows as an error, never as
|
|
316
|
+
* no restriction.
|
|
317
|
+
*/
|
|
318
|
+
type RenderOptions = Omit<VerifyOptions, 'identityTypes'> & {
|
|
319
|
+
target: string | HTMLElement;
|
|
320
|
+
identityTypes?: string | null;
|
|
321
|
+
};
|
|
322
|
+
/** The verified identity returned by `signIn()`. */
|
|
323
|
+
type SignInResult = VerifyResult;
|
|
324
|
+
/**
|
|
325
|
+
* Options for `handleRedirectResult()`. Call once on every page load. It
|
|
326
|
+
* redeems a returned sign-in code (from `flow: 'redirect'` or the silent SSO
|
|
327
|
+
* self-heal) and, when a popup result was lost, triggers that self-heal. It
|
|
328
|
+
* no-ops otherwise.
|
|
329
|
+
*/
|
|
330
|
+
interface RedirectResultOptions {
|
|
331
|
+
/** Called with the verified result when a returned sign-in code is redeemed */
|
|
332
|
+
onSuccess?: (result: VerifyResult) => void;
|
|
333
|
+
/** Called when redeeming a returned sign-in code failed */
|
|
334
|
+
onError?: (error: Error) => void;
|
|
335
|
+
/** Called when the person cancelled sign-in on the hosted page */
|
|
336
|
+
onCancel?: () => void;
|
|
337
|
+
}
|
|
338
|
+
interface TokenClaims {
|
|
339
|
+
/** Issuer */
|
|
340
|
+
iss: string;
|
|
341
|
+
/** Subject. Managed Identity tokens use the SVID. */
|
|
342
|
+
sub: string;
|
|
343
|
+
/** Audience (account ID for simple tokens, client ID for OIDC) */
|
|
344
|
+
aud: string;
|
|
345
|
+
/** Expiry (Unix seconds) */
|
|
346
|
+
exp: number;
|
|
347
|
+
/** Issued at (Unix seconds) */
|
|
348
|
+
iat: number;
|
|
349
|
+
/** Unique token ID for replay protection */
|
|
350
|
+
jti?: string;
|
|
351
|
+
/** Verified identifier used for audit and user-facing attribution; passkey credentials route by SVID. */
|
|
352
|
+
identity: string;
|
|
353
|
+
/** Identifier type */
|
|
354
|
+
identity_type: VerifiedIdentityType;
|
|
355
|
+
/** Canonical SparkVault ID */
|
|
356
|
+
svid?: string;
|
|
357
|
+
/** Managed SparkVault Identity session ID */
|
|
358
|
+
session_id?: string;
|
|
359
|
+
/** Verification timestamp (Unix seconds) */
|
|
360
|
+
verified_at: number;
|
|
361
|
+
/** Authentication method used */
|
|
362
|
+
method: string;
|
|
363
|
+
/**
|
|
364
|
+
* Only on a `federated` sign-in whose provider asserted an email: the
|
|
365
|
+
* address as the provider sent it. The provider may assert an address it
|
|
366
|
+
* never verified, so it is no identifier: key people by `sub`.
|
|
367
|
+
*/
|
|
368
|
+
email?: string;
|
|
369
|
+
/** Only beside `email`: true only when the provider said it verified the address. */
|
|
370
|
+
email_verified?: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* The person's public avatar URL (my.auth.sv), present only when they have a visible
|
|
373
|
+
* avatar. The URL always renders an image: their photo, or a neutral placeholder.
|
|
374
|
+
*/
|
|
375
|
+
picture?: string;
|
|
376
|
+
}
|
|
377
|
+
/** Method ID returned by config endpoint */
|
|
378
|
+
type MethodId = 'otp_email' | 'otp_sms' | 'otp_voice' | 'passkey' | 'sparklink' | 'social_google' | 'social_apple' | 'social_microsoft' | 'social_github' | 'social_facebook' | 'social_linkedin' | 'federation';
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Identity Module
|
|
382
|
+
*
|
|
383
|
+
* Passwordless sign-in through the first-party SparkVault popup.
|
|
384
|
+
* Supports passkey, OTP, SparkLink, social authentication, and the account's
|
|
385
|
+
* own identity provider.
|
|
386
|
+
*
|
|
387
|
+
* @example Programmatic
|
|
388
|
+
* const result = await sv.products.identity.signIn();
|
|
389
|
+
*
|
|
390
|
+
* @example Attached to clicks
|
|
391
|
+
* sv.products.identity.attach('.login-btn');
|
|
392
|
+
*/
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Whether `handleRedirectResult()` has anything to do on this load: a returned
|
|
396
|
+
* sign-in fragment to consume, or a pending sign-in to self-heal. Public + side
|
|
397
|
+
* effect-free (peeks, never consumes) so a host that defers SDK init for
|
|
398
|
+
* performance can cheaply decide whether to boot the SDK on a given page load,
|
|
399
|
+
* WITHOUT reaching into the SDK's internal storage keys. Exposed as
|
|
400
|
+
* `SparkVault.isRecoveryPending()`.
|
|
401
|
+
*/
|
|
402
|
+
declare function isSignInRecoveryPending(): boolean;
|
|
403
|
+
declare class IdentityModule {
|
|
404
|
+
private readonly config;
|
|
405
|
+
private readonly api;
|
|
406
|
+
private renderer;
|
|
407
|
+
private launcher;
|
|
408
|
+
private pendingSignIn;
|
|
409
|
+
constructor(config: ResolvedConfig);
|
|
410
|
+
/**
|
|
411
|
+
* Build a deep link into the person's auth.sv Identity portal, where they
|
|
412
|
+
* manage their verified identity, passkeys, sessions, and connected sites
|
|
413
|
+
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
414
|
+
* self-serve;
|
|
415
|
+
* the portal authenticates them with their own SparkVault Identity.
|
|
416
|
+
*
|
|
417
|
+
* @example Manage this site (block/notifications/etc.)
|
|
418
|
+
* window.location.href = sv.products.identity.portalUrl({ section: 'sites' });
|
|
419
|
+
*
|
|
420
|
+
* @example Open the security screen
|
|
421
|
+
* sv.products.identity.portalUrl({ section: 'security' });
|
|
422
|
+
*
|
|
423
|
+
* @returns An absolute URL on the configured `portalBaseUrl` (default https://auth.sv).
|
|
424
|
+
*/
|
|
425
|
+
portalUrl(options?: PortalUrlOptions): string;
|
|
426
|
+
/**
|
|
427
|
+
* One-click sign-in through the browser's native FedCM account chooser.
|
|
428
|
+
*
|
|
429
|
+
* When the person is already signed into SparkVault Identity (carrying the
|
|
430
|
+
* SSO hub session on the Identity origin),
|
|
431
|
+
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
432
|
+
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
433
|
+
* with FedCM support: callers should feature-detect with
|
|
434
|
+
* `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
|
|
435
|
+
*
|
|
436
|
+
* @returns the verified result, or `null` when the browser has no FedCM
|
|
437
|
+
* support (so the caller can fall back). Throws `UserCancelledError` when
|
|
438
|
+
* the browser ends the request without a credential: the person dismissed
|
|
439
|
+
* the chooser, or the browser had no SparkVault account to offer (the
|
|
440
|
+
* browser reports both alike). Throws `IdentityProviderError`, carrying
|
|
441
|
+
* SparkVault's own error code, when SparkVault answered the sign-in with an
|
|
442
|
+
* error (`IDENTITY_TYPE_NOT_ALLOWED` for an account of a type
|
|
443
|
+
* `identityTypes` does not name).
|
|
444
|
+
*
|
|
445
|
+
* `identityTypes` restricts the sign-in as `SignInOptions.identityTypes`
|
|
446
|
+
* does; a bad value is a ValidationError before anything is asked.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* const result = IdentityModule.isFedcmAvailable()
|
|
450
|
+
* ? await sv.products.identity.signInWithFedcm().catch(() => sv.products.identity.signIn())
|
|
451
|
+
* : await sv.products.identity.signIn();
|
|
452
|
+
*/
|
|
453
|
+
signInWithFedcm(options?: {
|
|
454
|
+
mediation?: 'optional' | 'required' | 'silent';
|
|
455
|
+
nonce?: string;
|
|
456
|
+
identityTypes?: SigninIdentityType[];
|
|
457
|
+
}): Promise<VerifyResult | null>;
|
|
458
|
+
/** Whether this browser exposes the FedCM API (`navigator.credentials` + IdentityCredential). */
|
|
459
|
+
static isFedcmAvailable(): boolean;
|
|
460
|
+
/**
|
|
461
|
+
* Sign in through the first-party SparkVault sign-in popup.
|
|
462
|
+
*
|
|
463
|
+
* This is the single programmatic entry point; `attach()` binds it to element
|
|
464
|
+
* clicks. The popup runs the flow top-level on the Identity origin (so
|
|
465
|
+
* login's `__Host-` hub cookie is a first-party write and cross-domain SSO
|
|
466
|
+
* works) and posts the result back; the promise resolves with it.
|
|
467
|
+
*
|
|
468
|
+
* Resilience: pair this with `handleRedirectResult()` on page load. If the
|
|
469
|
+
* popup's result is ever lost (a mobile browser discards the backgrounded
|
|
470
|
+
* opener tab), the next load silently self-heals from the SSO session the
|
|
471
|
+
* popup signed in or chose; a sign-in that opened none (the account's own
|
|
472
|
+
* identity provider) comes back signed out, to sign in again. `flow:
|
|
473
|
+
* 'redirect'` opts a caller out of the popup into a same-tab navigation
|
|
474
|
+
* instead.
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* const result = await sv.products.identity.signIn();
|
|
478
|
+
* // Your backend verifies the token before it grants access; never log it.
|
|
479
|
+
* await fetch('/api/auth/login', {
|
|
480
|
+
* method: 'POST',
|
|
481
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
482
|
+
* body: JSON.stringify({ token: result.token }),
|
|
483
|
+
* });
|
|
484
|
+
*/
|
|
485
|
+
signIn(options?: SignInOptions): Promise<SignInResult>;
|
|
486
|
+
/**
|
|
487
|
+
* Core flow runner. Default mode (no `target`) opens the popup; `flow:
|
|
488
|
+
* 'redirect'` navigates the tab instead; local mode (`renderMode: 'local'` /
|
|
489
|
+
* `target`) renders into the current document and powers the
|
|
490
|
+
* SparkVault-hosted sign-in surfaces (see the internal `render`), which
|
|
491
|
+
* hands it its restriction as its page's URL spelled it (`identityTypes`)
|
|
492
|
+
* and what a round trip to the account's own identity provider returned
|
|
493
|
+
* (`federationReturn`). The popup and the redirect carry the restriction
|
|
494
|
+
* `options.identityTypes` names, which signIn() validated.
|
|
495
|
+
*/
|
|
496
|
+
private runFlow;
|
|
497
|
+
/**
|
|
498
|
+
* Attach identity verification to element clicks.
|
|
499
|
+
* When any matching element is clicked, opens the verification dialog.
|
|
500
|
+
*
|
|
501
|
+
* @param selector - CSS selector for elements to attach to
|
|
502
|
+
* @param options - Verification options and callbacks
|
|
503
|
+
* @returns Cleanup function to remove event listeners
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* const cleanup = sv.products.identity.attach('.login-btn', {
|
|
507
|
+
* onSuccess: (result) => console.log('Verified:', result.identity)
|
|
508
|
+
* });
|
|
509
|
+
*
|
|
510
|
+
* // Later, remove listeners
|
|
511
|
+
* cleanup();
|
|
512
|
+
*/
|
|
513
|
+
attach(selector: string, options?: AttachOptions): () => void;
|
|
514
|
+
/**
|
|
515
|
+
* Decode an identity token's claims WITHOUT verifying its signature.
|
|
516
|
+
*
|
|
517
|
+
* This is an UNVERIFIED, client-side decode: it parses the JWT payload and
|
|
518
|
+
* sanity-checks structure, `exp`, `iss`, `aud`, and the header `alg` (accepting
|
|
519
|
+
* only the algorithms the Identity server signs with, so an unsigned or
|
|
520
|
+
* algorithm-confused token cannot masquerade as valid). It does NOT verify the
|
|
521
|
+
* signature, so its result MUST NOT be trusted for any authorization decision.
|
|
522
|
+
*
|
|
523
|
+
* To trust a token (e.g. before keying records by `claims.svid`), verify the
|
|
524
|
+
* signature server-side against the Identity JWKS endpoint
|
|
525
|
+
* (`https://auth.sparkvault.com/{account_id}/.well-known/jwks.json`), which
|
|
526
|
+
* publishes the EdDSA and RS256 keys and selects the verifying key by `kid`.
|
|
527
|
+
* See docs/SDK.md.
|
|
528
|
+
*/
|
|
529
|
+
decodeToken(token: string): TokenClaims;
|
|
530
|
+
/**
|
|
531
|
+
* Complete a sign-in on page load: the return leg of `signIn()`. Call once
|
|
532
|
+
* on every page load; it resolves `null` when there is nothing to do.
|
|
533
|
+
*
|
|
534
|
+
* It handles two cases:
|
|
535
|
+
* 1. A one-time code is in the URL fragment (`#sv_code=…`): the popup's
|
|
536
|
+
* result was lost and self-heal navigated here, or `flow: 'redirect'`
|
|
537
|
+
* returned. Redeem it server-side and hand the full result to
|
|
538
|
+
* `onSuccess` (and resolve with it).
|
|
539
|
+
* 2. A sign-in was in flight but never delivered (a mobile browser
|
|
540
|
+
* discarded the backgrounded opener tab, killing the popup's
|
|
541
|
+
* postMessage): silently re-mint from the SSO session the popup signed
|
|
542
|
+
* in or chose, by navigating this tab through the silent SSO endpoint
|
|
543
|
+
* and straight back with a code (case 1 on return). The bounce names
|
|
544
|
+
* the sign-in's reference, and the endpoint mints only when the
|
|
545
|
+
* session it would mint from carries it. Nothing is shown; with no
|
|
546
|
+
* such session (a sign-in that opened none, such as one through the
|
|
547
|
+
* account's own identity provider) it comes back logged-out, no oracle.
|
|
548
|
+
*
|
|
549
|
+
* The code is one-time, PKCE-bound, and origin-locked, never the token. The
|
|
550
|
+
* host must still verify `result.token` server-side via the Identity JWKS.
|
|
551
|
+
*
|
|
552
|
+
* @example Call on page load; sign-in clicks stay unchanged.
|
|
553
|
+
* sv.products.identity.handleRedirectResult({
|
|
554
|
+
* onSuccess: (result) => createSession(result.token),
|
|
555
|
+
* }).catch((error) => showError(error));
|
|
556
|
+
*/
|
|
557
|
+
handleRedirectResult(options?: RedirectResultOptions): Promise<SignInResult | null>;
|
|
558
|
+
/** Redeem a returned `#sv_code` (or surface a returned `#sv_error`). */
|
|
559
|
+
private consumeHandoffFragment;
|
|
560
|
+
/**
|
|
561
|
+
* Silently re-mint the sign-in result from the SSO session the popup signed
|
|
562
|
+
* in or chose. Navigates this tab through the silent SSO endpoint
|
|
563
|
+
* (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
|
|
564
|
+
* PKCE-bound, returns a one-time code in the fragment, handled by case 1 on
|
|
565
|
+
* return. No-op (stays put) if session storage or WebCrypto is unavailable,
|
|
566
|
+
* so a degraded environment simply never recovers rather than erroring. The
|
|
567
|
+
* bounce's PKCE verifier and state are a draw from the Identity origin
|
|
568
|
+
* (`drawAuthorizationValues`): a draw that fails (the origin unreachable, a
|
|
569
|
+
* malformed answer) rejects `handleRedirectResult()` with that error, and the
|
|
570
|
+
* page stays put.
|
|
571
|
+
*/
|
|
572
|
+
private startRecoveryBounce;
|
|
573
|
+
/**
|
|
574
|
+
* Navigate this tab to the interactive sign-in page: explicit `flow:
|
|
575
|
+
* 'redirect'`, or a popup whose handle COOP severed. Plain sign-in carries
|
|
576
|
+
* redirect_uri + state + PKCE challenge and returns via the fragment code;
|
|
577
|
+
* OIDC/simple modes navigate without them (their server-rendered pages drive
|
|
578
|
+
* the server-validated redirect back). Either carries the severed popup's
|
|
579
|
+
* reference; a redirect draws none of its own.
|
|
580
|
+
*
|
|
581
|
+
* The return leg is armed first: the check that the sign-in still runs and
|
|
582
|
+
* the pending marker's removal then share one turn with the navigation, so
|
|
583
|
+
* no sign-in can start or end between them.
|
|
584
|
+
*
|
|
585
|
+
* @param severed - The popup sign-in whose severed popup this continues,
|
|
586
|
+
* with the reference its marker holds for that popup (null for none), or
|
|
587
|
+
* null for an explicit redirect, which carries none
|
|
588
|
+
* @returns false when the return leg cannot be armed (no session storage or
|
|
589
|
+
* WebCrypto), so the caller surfaces an actionable error instead of a
|
|
590
|
+
* silent dead-end, or when the severed popup's sign-in ended meanwhile.
|
|
591
|
+
*/
|
|
592
|
+
private startRedirectFlow;
|
|
593
|
+
/**
|
|
594
|
+
* Arm the PKCE + state return leg of a handoff navigation and return what
|
|
595
|
+
* the navigation carries for it (redirect_uri = this page, per
|
|
596
|
+
* `currentPageReturnUrl`). Returns null when session storage or WebCrypto is
|
|
597
|
+
* unavailable so callers can degrade.
|
|
598
|
+
*/
|
|
599
|
+
private armHandoffReturn;
|
|
600
|
+
/**
|
|
601
|
+
* Consume the pending marker: the marker once (then cleared) while a recent
|
|
602
|
+
* sign-in is still awaiting its result, else null. Its `hint` is the
|
|
603
|
+
* identifier that sign-in carried, for the recovery bounce's `login_hint`,
|
|
604
|
+
* and its `ref` the sign-in's reference, when the marker holds one.
|
|
605
|
+
*/
|
|
606
|
+
private consumeSignInPending;
|
|
607
|
+
/** Close the popup sign-in's launcher, ending the sign-in it ran. */
|
|
608
|
+
private closeLauncher;
|
|
609
|
+
/** Remove the result fragment from the URL bar (and history entry). */
|
|
610
|
+
private clearUrlFragment;
|
|
611
|
+
/** Drop the one-shot PKCE state/verifier a bounce staged. */
|
|
612
|
+
private clearOneShotAuthState;
|
|
613
|
+
/**
|
|
614
|
+
* Complete a social round trip, or one through the account's own identity
|
|
615
|
+
* provider, that returned to the sign-in page as `#token=…&state=…`. Only
|
|
616
|
+
* `render()`, the Identity-origin sign-in page,
|
|
617
|
+
* reads it: no SDK flow returns a `#token` to a site (a site's results arrive
|
|
618
|
+
* by the popup's postMessage, FedCM, or a PKCE-bound `#sv_code`), so on a site
|
|
619
|
+
* it could only be someone else's token, or the site's own direct
|
|
620
|
+
* token-redirect result.
|
|
621
|
+
*/
|
|
622
|
+
private consumeRedirectResult;
|
|
623
|
+
/**
|
|
624
|
+
* Read a refusal a round trip through the account's own identity provider
|
|
625
|
+
* returned to the sign-in page (`#error=…&state=…`, see federation-flow.ts).
|
|
626
|
+
* Such a fragment is consumed exactly once, with the state it answers,
|
|
627
|
+
* whatever it holds. Null for any other fragment, and for a refusal whose
|
|
628
|
+
* state is not the one this browser stored before it left: an answer to no
|
|
629
|
+
* sign-in this browser started, which the page ignores.
|
|
630
|
+
*/
|
|
631
|
+
private consumeFederationReturn;
|
|
632
|
+
/**
|
|
633
|
+
* Close the identity dialog/inline UI if open.
|
|
634
|
+
*
|
|
635
|
+
* Tears down whichever surface is active: the dialog launcher (default dialog
|
|
636
|
+
* mode) or the local renderer (inline / local mode).
|
|
637
|
+
*/
|
|
638
|
+
close(): void;
|
|
639
|
+
/**
|
|
640
|
+
* Whether the preloaded config has already settled as a *permanent* failure
|
|
641
|
+
* the popup can't surface (origin not allowed, or product not configured).
|
|
642
|
+
* Used to skip the launcher and show the error dialog in-page immediately.
|
|
643
|
+
* Returns false (proceed to the launcher) when config is not preloaded,
|
|
644
|
+
* still in flight (raced against a short timeout so the common path is never
|
|
645
|
+
* delayed), resolved, or failed only transiently (the launcher surfaces a
|
|
646
|
+
* transient failure in its own dialog).
|
|
647
|
+
*/
|
|
648
|
+
private preloadedConfigPermanentlyFailed;
|
|
649
|
+
/**
|
|
650
|
+
* The inline container for an embedded render. Bare chrome: the host page
|
|
651
|
+
* owns logo + footer + background, so the container drops its own surface
|
|
652
|
+
* and the SparkVault footer.
|
|
653
|
+
*/
|
|
654
|
+
private createInlineContainer;
|
|
655
|
+
/**
|
|
656
|
+
* Render the flow into a page element instead of a popup.
|
|
657
|
+
*
|
|
658
|
+
* A social login, or one through the account's own identity provider,
|
|
659
|
+
* started here returns to this same page with its result in the fragment,
|
|
660
|
+
* so a returned `#token` is completed first (see `consumeRedirectResult`)
|
|
661
|
+
* instead of starting the flow again, and a returned refusal of the
|
|
662
|
+
* account's own identity provider is handed to the flow it starts (see
|
|
663
|
+
* `consumeFederationReturn`).
|
|
664
|
+
*
|
|
665
|
+
* The page hands its restriction as its URL spelled it (`identityTypes`),
|
|
666
|
+
* which the flow reads here: a spelling it cannot read shows as an error.
|
|
667
|
+
*
|
|
668
|
+
* @internal Used only by the SparkVault-hosted sign-in popup and hosted login
|
|
669
|
+
* page (which own their chrome and pass `renderMode: 'local'`). Customer
|
|
670
|
+
* integrations have no inline mode; use `signIn()` / `attach()`.
|
|
671
|
+
*/
|
|
672
|
+
render(options: RenderOptions): Promise<VerifyResult>;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* SparkVault SDK Error Types
|
|
677
|
+
*/
|
|
678
|
+
declare class SparkVaultError extends Error {
|
|
679
|
+
readonly code: string;
|
|
680
|
+
readonly statusCode?: number;
|
|
681
|
+
readonly details?: Record<string, unknown>;
|
|
682
|
+
/**
|
|
683
|
+
* The answer's `Retry-After`, in ms from the answer, read by the platform's
|
|
684
|
+
* one parser (`parseRetryAfterMs`; RFC 9110 §10.2.3: delay-seconds or an
|
|
685
|
+
* HTTP-date): the earliest a next attempt can expect another answer, which
|
|
686
|
+
* every retry the SDK makes waits out as a floor. Null when the answer
|
|
687
|
+
* carried none the parser could read, or no answer arrived.
|
|
688
|
+
*/
|
|
689
|
+
readonly retryAfterMs: number | null;
|
|
690
|
+
/**
|
|
691
|
+
* The machine-readable code the API answered with (`INVALID_CURSOR`,
|
|
692
|
+
* `LICENSE_REQUIRED`), on every error the SDK's API client builds from a
|
|
693
|
+
* refused call of a data-plane module (`vaults`, `ingots`, `folders`,
|
|
694
|
+
* `sparks`, `entropy`, `notify`, `products.notify`); `api_error` when the
|
|
695
|
+
* answer named none (a gateway's HTML). A typed refusal's `code` names its
|
|
696
|
+
* class of failure: one per 400 (`validation_error`), two per 401
|
|
697
|
+
* (`authentication_error`, `UNAUTHORIZED`), 402 (`PLAN_REQUIRED`,
|
|
698
|
+
* `QUOTA_EXCEEDED`, `USAGE_CREDITS_EXHAUSTED`) and 403 (`authorization_error`;
|
|
699
|
+
* http.ts createErrorFromResponse), so this is what tells apart two
|
|
700
|
+
* refusals that share a code.
|
|
701
|
+
* Undefined on an error the SDK raised itself, on the Identity product's
|
|
702
|
+
* errors (`products.identity`, whose `code` is the service's own), and on the
|
|
703
|
+
* errors of an upload's transfer (`UploadApiError`, which names Core's code in
|
|
704
|
+
* its `code` or `details.coreCode`, a staging call Core refused for good among
|
|
705
|
+
* them) and of a download (`download_failed`, its status alone).
|
|
706
|
+
*/
|
|
707
|
+
readonly serviceCode?: string;
|
|
708
|
+
constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
709
|
+
}
|
|
710
|
+
declare class AuthenticationError extends SparkVaultError {
|
|
711
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* A key the request presents was refused (401 UNAUTHORIZED): the DVAK an
|
|
715
|
+
* unseal names is invalid or revoked. The caller's own credential stood, so
|
|
716
|
+
* this is no ended session, and signing in again changes nothing: present a
|
|
717
|
+
* live key. Every other 401 is an {@link AuthenticationError}.
|
|
718
|
+
*/
|
|
719
|
+
declare class UnauthorizedError extends SparkVaultError {
|
|
720
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
721
|
+
}
|
|
722
|
+
declare class AuthorizationError extends SparkVaultError {
|
|
723
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
724
|
+
}
|
|
725
|
+
declare class ValidationError extends SparkVaultError {
|
|
726
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* The pooled-capacity resource a quota gate refers to. Only the byte pools
|
|
730
|
+
* hard-gate: licenses are assigned per member, never drawn from a pool
|
|
731
|
+
* (inviting and licensing are never quota-gated), and Identity soft-gates
|
|
732
|
+
* through its own path.
|
|
733
|
+
*/
|
|
734
|
+
type QuotaResource = 'storage' | 'bandwidth';
|
|
735
|
+
/**
|
|
736
|
+
* Plan required gate (402 PLAN_REQUIRED): the account has no active
|
|
737
|
+
* subscription and attempted a billable/create action. Surface a subscribe CTA
|
|
738
|
+
* to admins, or "ask your account admin" to members.
|
|
739
|
+
*/
|
|
740
|
+
declare class PlanRequiredError extends SparkVaultError {
|
|
741
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Prepaid usage is exhausted (402 USAGE_CREDITS_EXHAUSTED). The subscription
|
|
745
|
+
* can still be active: an admin replenishes the shared usage-credit wallet.
|
|
746
|
+
*/
|
|
747
|
+
declare class UsageCreditsExhaustedError extends SparkVaultError {
|
|
748
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
749
|
+
}
|
|
750
|
+
/** A payment reversal requires billing review; buying more credits cannot clear it. */
|
|
751
|
+
declare class UsageCreditFundingReviewError extends SparkVaultError {
|
|
752
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Quota exceeded gate (402 QUOTA_EXCEEDED): a pooled-capacity limit is
|
|
756
|
+
* exhausted. `resource` identifies which pool so callers can point the CTA at
|
|
757
|
+
* the right capacity block.
|
|
758
|
+
*/
|
|
759
|
+
declare class QuotaExceededError extends SparkVaultError {
|
|
760
|
+
readonly resource?: QuotaResource;
|
|
761
|
+
constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
|
|
762
|
+
}
|
|
763
|
+
declare class NetworkError extends SparkVaultError {
|
|
764
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
765
|
+
}
|
|
766
|
+
declare class TimeoutError extends SparkVaultError {
|
|
767
|
+
constructor(message?: string);
|
|
768
|
+
}
|
|
769
|
+
declare class UserCancelledError extends SparkVaultError {
|
|
770
|
+
constructor(message?: string);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* The identity provider answered a FedCM sign-in with an error of its own
|
|
774
|
+
* (the browser's `IdentityCredentialError`), after the browser showed the
|
|
775
|
+
* person its error dialog: the request reached the provider, which refused or
|
|
776
|
+
* failed it, so it is no cancel. `code` is the provider's answer
|
|
777
|
+
* (`server_error`, `access_denied`, ...).
|
|
778
|
+
*/
|
|
779
|
+
declare class IdentityProviderError extends SparkVaultError {
|
|
780
|
+
constructor(code: string);
|
|
781
|
+
}
|
|
782
|
+
declare class PopupBlockedError extends SparkVaultError {
|
|
783
|
+
constructor();
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* The popup opened but its window handle went dead before the page ever
|
|
787
|
+
* pinged back: the host page's Cross-Origin-Opener-Policy severed it (a host
|
|
788
|
+
* page serving `COOP: same-origin` detaches any cross-origin popup: the popup
|
|
789
|
+
* loses `window.opener`, the opener's handle reports `closed`). postMessage
|
|
790
|
+
* can never work in this state, so retrying the popup is futile. Identity
|
|
791
|
+
* sign-in falls back to the redirect flow (popup-launcher.ts); the help desk
|
|
792
|
+
* widget's sign-in, which has none, passes a message that tells the person
|
|
793
|
+
* what to do (help-desk/widget-identity.ts).
|
|
794
|
+
*/
|
|
795
|
+
declare class PopupSeveredError extends SparkVaultError {
|
|
796
|
+
constructor(message?: string);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export { IdentityModule as I, NetworkError as N, PlanRequiredError as P, QuotaExceededError as Q, TimeoutError as T, UnauthorizedError as U, ValidationError as V, AuthenticationError as a, AuthorizationError as b, IdentityProviderError as c, PopupBlockedError as d, PopupSeveredError as e, SparkVaultError as n, UsageCreditFundingReviewError as p, UsageCreditsExhaustedError as q, UserCancelledError as r, isSignInRecoveryPending as v };
|
|
800
|
+
export type { AttachOptions as A, RedirectResultOptions as R, SignInOptions as S, PortalSection as f, PortalUrlOptions as g, QuotaResource as h, RenderOptions as i, ResolvedConfig as j, SignInResult as k, SigninIdentityType as l, SparkVaultConfig as m, TokenClaims as o, VaultSessionTiming as s, VerifyOptions as t, VerifyResult as u };
|