@sparkvault/sdk 1.23.9 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-base.d.ts +58 -0
- package/dist/identity/api.d.ts +19 -36
- package/dist/index.d.ts +31 -31
- package/dist/sparkvault.cjs.js +214 -256
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +214 -256
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/upload/api.d.ts +9 -33
- package/dist/vaults/upload/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SparkVault API Base
|
|
3
|
+
*
|
|
4
|
+
* Shared lifecycle and HTTP plumbing for every internal API client in the
|
|
5
|
+
* SDK. Concrete clients (IdentityApi, UploadApi, ...) extend this and
|
|
6
|
+
* provide:
|
|
7
|
+
* - their own error factory via makeError()
|
|
8
|
+
* - their own typed endpoint methods that call rawRequest()
|
|
9
|
+
*
|
|
10
|
+
* Session lifecycle invariant: every user-facing session (a modal open, a
|
|
11
|
+
* verify flow, an upload widget invocation) starts with the owning Module
|
|
12
|
+
* calling resetSession(). close() aborts the current AbortController; the
|
|
13
|
+
* next resetSession() swaps in a fresh one. The Module is responsible for
|
|
14
|
+
* this; clients of the SDK never see any of it.
|
|
15
|
+
*/
|
|
16
|
+
import { SparkVaultError } from './errors';
|
|
17
|
+
export interface RawRequestOptions {
|
|
18
|
+
method: string;
|
|
19
|
+
body?: string;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export interface RawResponse {
|
|
23
|
+
data: unknown;
|
|
24
|
+
status: number;
|
|
25
|
+
}
|
|
26
|
+
export declare abstract class SparkVaultApi {
|
|
27
|
+
protected readonly timeoutMs: number;
|
|
28
|
+
/**
|
|
29
|
+
* Abort controller for the current session. Replaced by resetSession()
|
|
30
|
+
* at the start of every user-facing session — an aborted controller can
|
|
31
|
+
* never leak into the next session.
|
|
32
|
+
*/
|
|
33
|
+
private closeController;
|
|
34
|
+
constructor(timeoutMs?: number);
|
|
35
|
+
/** Abort all pending requests on this client. Called by the Module on close. */
|
|
36
|
+
abort(): void;
|
|
37
|
+
/** Whether the *current* session has been aborted. */
|
|
38
|
+
isAborted(): boolean;
|
|
39
|
+
/** The current session's abort signal — for callers that need to wire it into XHR/etc. */
|
|
40
|
+
getAbortSignal(): AbortSignal;
|
|
41
|
+
/**
|
|
42
|
+
* Swap in a fresh AbortController. The Module calls this at the start of
|
|
43
|
+
* every user-facing session. Long-lived per-client state (e.g. config
|
|
44
|
+
* caches) is intentionally NOT cleared here.
|
|
45
|
+
*/
|
|
46
|
+
resetSession(): void;
|
|
47
|
+
/** Subclass-specific error factory. */
|
|
48
|
+
protected abstract makeError(message: string, code: string, statusCode: number): SparkVaultError;
|
|
49
|
+
/**
|
|
50
|
+
* Issue an HTTP request with timeout + session abort + standard error
|
|
51
|
+
* mapping. Subclasses build URLs and unwrap response envelopes on top.
|
|
52
|
+
*
|
|
53
|
+
* Returns the parsed JSON body (whatever shape it takes) plus the
|
|
54
|
+
* status code. Throws subclass-typed errors via makeError() for: aborted
|
|
55
|
+
* sessions, timeouts, network failures, and non-2xx responses.
|
|
56
|
+
*/
|
|
57
|
+
protected rawRequest(url: string, options: RawRequestOptions): Promise<RawResponse>;
|
|
58
|
+
}
|
package/dist/identity/api.d.ts
CHANGED
|
@@ -5,36 +5,16 @@
|
|
|
5
5
|
* Single responsibility: API calls only.
|
|
6
6
|
*/
|
|
7
7
|
import type { ResolvedConfig } from '../config';
|
|
8
|
+
import { SparkVaultApi } from '../api-base';
|
|
9
|
+
import { SparkVaultError } from '../errors';
|
|
8
10
|
import type { SdkConfig, TotpSendResponse, TotpVerifyResponse, PasskeyChallengeResponse, PasskeyVerifyResponse, SparkLinkSendResponse, AuthContext } from './types';
|
|
9
|
-
export declare class IdentityApi {
|
|
11
|
+
export declare class IdentityApi extends SparkVaultApi {
|
|
10
12
|
private readonly config;
|
|
11
|
-
private readonly timeoutMs;
|
|
12
13
|
/** Cached config promise - allows preloading and deduplication */
|
|
13
14
|
private configCache;
|
|
14
|
-
/**
|
|
15
|
-
* Abort controller for cancelling all pending requests on close.
|
|
16
|
-
* Replaced by resetSession() at the start of every user-facing session.
|
|
17
|
-
*/
|
|
18
|
-
private closeController;
|
|
19
15
|
constructor(config: ResolvedConfig, timeoutMs?: number);
|
|
20
|
-
/**
|
|
21
|
-
* Abort all pending requests.
|
|
22
|
-
* Call this when the renderer is closed to prevent orphaned requests.
|
|
23
|
-
*/
|
|
24
|
-
abort(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Check if the API has been aborted.
|
|
27
|
-
*/
|
|
28
|
-
isAborted(): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Reset the session lifecycle by swapping in a fresh AbortController.
|
|
31
|
-
* The Module calls this at the start of every user-facing session so a
|
|
32
|
-
* previously-closed session can never leak its aborted state into the
|
|
33
|
-
* next one. The config cache is intentionally preserved across sessions
|
|
34
|
-
* so preloadConfig() keeps making modal opens instant.
|
|
35
|
-
*/
|
|
36
|
-
resetSession(): void;
|
|
37
16
|
private get baseUrl();
|
|
17
|
+
protected makeError(message: string, code: string, statusCode: number): IdentityApiError;
|
|
38
18
|
private request;
|
|
39
19
|
/**
|
|
40
20
|
* Fetch SDK configuration (branding, enabled methods).
|
|
@@ -55,13 +35,18 @@ export declare class IdentityApi {
|
|
|
55
35
|
*/
|
|
56
36
|
isConfigPreloaded(): boolean;
|
|
57
37
|
/**
|
|
58
|
-
* Check if an email has registered passkeys
|
|
38
|
+
* Check if an identity (email or phone) has registered passkeys.
|
|
59
39
|
*
|
|
60
40
|
* Returns:
|
|
61
|
-
* -
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
* - identity_valid: identity passes per-type validity check
|
|
42
|
+
* (email: MX lookup; phone: E.164 format)
|
|
43
|
+
* - has_passkey: whether any passkeys are registered for this identity
|
|
44
|
+
* (cross-tenant — single global RP)
|
|
45
|
+
* - email_valid: legacy alias for identity_valid, present for backward
|
|
46
|
+
* compatibility with older SDK versions
|
|
47
|
+
*/
|
|
48
|
+
checkPasskey(identity: string, identityType?: 'email' | 'phone'): Promise<{
|
|
49
|
+
identity_valid: boolean;
|
|
65
50
|
email_valid: boolean;
|
|
66
51
|
has_passkey: boolean;
|
|
67
52
|
}>;
|
|
@@ -88,9 +73,9 @@ export declare class IdentityApi {
|
|
|
88
73
|
authContext?: AuthContext;
|
|
89
74
|
}): Promise<TotpVerifyResponse>;
|
|
90
75
|
/**
|
|
91
|
-
* Start passkey registration
|
|
76
|
+
* Start passkey registration for an identity (email or phone).
|
|
92
77
|
*/
|
|
93
|
-
startPasskeyRegister(
|
|
78
|
+
startPasskeyRegister(identity: string, identityType?: 'email' | 'phone'): Promise<PasskeyChallengeResponse>;
|
|
94
79
|
/**
|
|
95
80
|
* Complete passkey registration
|
|
96
81
|
*/
|
|
@@ -99,9 +84,9 @@ export declare class IdentityApi {
|
|
|
99
84
|
credential: PublicKeyCredential;
|
|
100
85
|
}): Promise<PasskeyVerifyResponse>;
|
|
101
86
|
/**
|
|
102
|
-
* Start passkey verification
|
|
87
|
+
* Start passkey verification for an identity (email or phone).
|
|
103
88
|
*/
|
|
104
|
-
startPasskeyVerify(
|
|
89
|
+
startPasskeyVerify(identity: string, identityType?: 'email' | 'phone', authContext?: AuthContext): Promise<PasskeyChallengeResponse>;
|
|
105
90
|
/**
|
|
106
91
|
* Complete passkey verification
|
|
107
92
|
*/
|
|
@@ -120,8 +105,6 @@ export declare class IdentityApi {
|
|
|
120
105
|
*/
|
|
121
106
|
sendSparkLink(email: string, connectionId: string, authContext?: AuthContext): Promise<SparkLinkSendResponse>;
|
|
122
107
|
}
|
|
123
|
-
export declare class IdentityApiError extends
|
|
124
|
-
readonly code: string;
|
|
125
|
-
readonly statusCode: number;
|
|
108
|
+
export declare class IdentityApiError extends SparkVaultError {
|
|
126
109
|
constructor(message: string, code: string, statusCode: number);
|
|
127
110
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -117,6 +117,37 @@ interface TokenClaims {
|
|
|
117
117
|
method: string;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* SparkVault SDK Error Types
|
|
122
|
+
*/
|
|
123
|
+
declare class SparkVaultError extends Error {
|
|
124
|
+
readonly code: string;
|
|
125
|
+
readonly statusCode?: number;
|
|
126
|
+
readonly details?: Record<string, unknown>;
|
|
127
|
+
constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>);
|
|
128
|
+
}
|
|
129
|
+
declare class AuthenticationError extends SparkVaultError {
|
|
130
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
131
|
+
}
|
|
132
|
+
declare class AuthorizationError extends SparkVaultError {
|
|
133
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
134
|
+
}
|
|
135
|
+
declare class ValidationError extends SparkVaultError {
|
|
136
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
137
|
+
}
|
|
138
|
+
declare class NetworkError extends SparkVaultError {
|
|
139
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
140
|
+
}
|
|
141
|
+
declare class TimeoutError extends SparkVaultError {
|
|
142
|
+
constructor(message?: string);
|
|
143
|
+
}
|
|
144
|
+
declare class UserCancelledError extends SparkVaultError {
|
|
145
|
+
constructor(message?: string);
|
|
146
|
+
}
|
|
147
|
+
declare class PopupBlockedError extends SparkVaultError {
|
|
148
|
+
constructor();
|
|
149
|
+
}
|
|
150
|
+
|
|
120
151
|
/**
|
|
121
152
|
* Identity Module
|
|
122
153
|
*
|
|
@@ -455,37 +486,6 @@ interface UploadResult {
|
|
|
455
486
|
uploadTime: string;
|
|
456
487
|
}
|
|
457
488
|
|
|
458
|
-
/**
|
|
459
|
-
* SparkVault SDK Error Types
|
|
460
|
-
*/
|
|
461
|
-
declare class SparkVaultError extends Error {
|
|
462
|
-
readonly code: string;
|
|
463
|
-
readonly statusCode?: number;
|
|
464
|
-
readonly details?: Record<string, unknown>;
|
|
465
|
-
constructor(message: string, code: string, statusCode?: number, details?: Record<string, unknown>);
|
|
466
|
-
}
|
|
467
|
-
declare class AuthenticationError extends SparkVaultError {
|
|
468
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
469
|
-
}
|
|
470
|
-
declare class AuthorizationError extends SparkVaultError {
|
|
471
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
472
|
-
}
|
|
473
|
-
declare class ValidationError extends SparkVaultError {
|
|
474
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
475
|
-
}
|
|
476
|
-
declare class NetworkError extends SparkVaultError {
|
|
477
|
-
constructor(message: string, details?: Record<string, unknown>);
|
|
478
|
-
}
|
|
479
|
-
declare class TimeoutError extends SparkVaultError {
|
|
480
|
-
constructor(message?: string);
|
|
481
|
-
}
|
|
482
|
-
declare class UserCancelledError extends SparkVaultError {
|
|
483
|
-
constructor(message?: string);
|
|
484
|
-
}
|
|
485
|
-
declare class PopupBlockedError extends SparkVaultError {
|
|
486
|
-
constructor();
|
|
487
|
-
}
|
|
488
|
-
|
|
489
489
|
/**
|
|
490
490
|
* Vaults Module
|
|
491
491
|
*
|