@sparkvault/sdk 1.24.0 → 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.
@@ -35,13 +35,18 @@ export declare class IdentityApi extends SparkVaultApi {
35
35
  */
36
36
  isConfigPreloaded(): boolean;
37
37
  /**
38
- * Check if an email has registered passkeys and validate email domain
38
+ * Check if an identity (email or phone) has registered passkeys.
39
39
  *
40
40
  * Returns:
41
- * - email_valid: whether the email domain has valid MX records
42
- * - has_passkey: whether any passkeys are registered (only meaningful if email_valid)
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
43
47
  */
44
- checkPasskey(email: string): Promise<{
48
+ checkPasskey(identity: string, identityType?: 'email' | 'phone'): Promise<{
49
+ identity_valid: boolean;
45
50
  email_valid: boolean;
46
51
  has_passkey: boolean;
47
52
  }>;
@@ -68,9 +73,9 @@ export declare class IdentityApi extends SparkVaultApi {
68
73
  authContext?: AuthContext;
69
74
  }): Promise<TotpVerifyResponse>;
70
75
  /**
71
- * Start passkey registration
76
+ * Start passkey registration for an identity (email or phone).
72
77
  */
73
- startPasskeyRegister(email: string): Promise<PasskeyChallengeResponse>;
78
+ startPasskeyRegister(identity: string, identityType?: 'email' | 'phone'): Promise<PasskeyChallengeResponse>;
74
79
  /**
75
80
  * Complete passkey registration
76
81
  */
@@ -79,9 +84,9 @@ export declare class IdentityApi extends SparkVaultApi {
79
84
  credential: PublicKeyCredential;
80
85
  }): Promise<PasskeyVerifyResponse>;
81
86
  /**
82
- * Start passkey verification
87
+ * Start passkey verification for an identity (email or phone).
83
88
  */
84
- startPasskeyVerify(email: string, authContext?: AuthContext): Promise<PasskeyChallengeResponse>;
89
+ startPasskeyVerify(identity: string, identityType?: 'email' | 'phone', authContext?: AuthContext): Promise<PasskeyChallengeResponse>;
85
90
  /**
86
91
  * Complete passkey verification
87
92
  */
@@ -850,14 +850,19 @@ class IdentityApi extends SparkVaultApi {
850
850
  return this.configCache !== null;
851
851
  }
852
852
  /**
853
- * Check if an email has registered passkeys and validate email domain
853
+ * Check if an identity (email or phone) has registered passkeys.
854
854
  *
855
855
  * Returns:
856
- * - email_valid: whether the email domain has valid MX records
857
- * - has_passkey: whether any passkeys are registered (only meaningful if email_valid)
856
+ * - identity_valid: identity passes per-type validity check
857
+ * (email: MX lookup; phone: E.164 format)
858
+ * - has_passkey: whether any passkeys are registered for this identity
859
+ * (cross-tenant — single global RP)
860
+ * - email_valid: legacy alias for identity_valid, present for backward
861
+ * compatibility with older SDK versions
858
862
  */
859
- async checkPasskey(email) {
860
- return this.request('POST', '/passkey/check', { email });
863
+ async checkPasskey(identity, identityType = 'email') {
864
+ const body = identityType === 'phone' ? { phone: identity } : { email: identity };
865
+ return this.request('POST', '/passkey/check', body);
861
866
  }
862
867
  /**
863
868
  * Build auth context params for API requests (OIDC/simple mode).
@@ -902,12 +907,13 @@ class IdentityApi extends SparkVaultApi {
902
907
  });
903
908
  }
904
909
  /**
905
- * Start passkey registration
910
+ * Start passkey registration for an identity (email or phone).
906
911
  */
907
- async startPasskeyRegister(email) {
912
+ async startPasskeyRegister(identity, identityType = 'email') {
913
+ const body = identityType === 'phone' ? { phone: identity } : { email: identity };
908
914
  // Backend returns { options: PublicKeyCredentialCreationOptions, session: {...} }
909
915
  // Extract and flatten to match PasskeyChallengeResponse
910
- const response = await this.request('POST', '/passkey/register', { email });
916
+ const response = await this.request('POST', '/passkey/register', body);
911
917
  return {
912
918
  challenge: response.options.challenge,
913
919
  rpId: response.options.rp.id,
@@ -937,12 +943,13 @@ class IdentityApi extends SparkVaultApi {
937
943
  });
938
944
  }
939
945
  /**
940
- * Start passkey verification
946
+ * Start passkey verification for an identity (email or phone).
941
947
  */
942
- async startPasskeyVerify(email, authContext) {
948
+ async startPasskeyVerify(identity, identityType = 'email', authContext) {
949
+ const identityField = identityType === 'phone' ? { phone: identity } : { email: identity };
943
950
  // Backend returns { options: PublicKeyCredentialRequestOptions, session: {...} }
944
951
  // Extract and flatten to match PasskeyChallengeResponse
945
- const response = await this.request('POST', '/passkey/verify', { email, ...this.buildAuthContextParams(authContext) });
952
+ const response = await this.request('POST', '/passkey/verify', { ...identityField, ...this.buildAuthContextParams(authContext) });
946
953
  return {
947
954
  challenge: response.options.challenge,
948
955
  rpId: response.options.rpId,
@@ -1349,10 +1356,12 @@ class PasskeyHandler {
1349
1356
  */
1350
1357
  async checkPasskey() {
1351
1358
  try {
1352
- const response = await this.api.checkPasskey(this.state.recipient);
1359
+ const response = await this.api.checkPasskey(this.state.recipient, this.state.identityType);
1353
1360
  this.state.setPasskeyStatus(response.has_passkey);
1361
+ // Prefer identity_valid; fall back to email_valid for older backends.
1362
+ const valid = response.identity_valid ?? response.email_valid;
1354
1363
  return {
1355
- emailValid: response.email_valid,
1364
+ emailValid: valid,
1356
1365
  hasPasskey: response.has_passkey,
1357
1366
  };
1358
1367
  }
@@ -1384,12 +1393,14 @@ class PasskeyHandler {
1384
1393
  */
1385
1394
  async openPasskeyPopup(mode) {
1386
1395
  return new Promise((resolve) => {
1387
- // Build popup URL
1396
+ // Build popup URL. Pass identity as `email` or `phone` (mutually
1397
+ // exclusive) so the popup can render and POST the correct field.
1388
1398
  const params = new URLSearchParams({
1389
1399
  mode,
1390
- email: this.state.recipient,
1391
1400
  origin: window.location.origin,
1392
1401
  });
1402
+ const identityParam = this.state.identityType === 'phone' ? 'phone' : 'email';
1403
+ params.set(identityParam, this.state.recipient);
1393
1404
  // Add auth context for OIDC/simple mode flows
1394
1405
  const authContext = this.state.authContext;
1395
1406
  if (authContext?.authRequestId) {