@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.
@@ -846,14 +846,19 @@ class IdentityApi extends SparkVaultApi {
846
846
  return this.configCache !== null;
847
847
  }
848
848
  /**
849
- * Check if an email has registered passkeys and validate email domain
849
+ * Check if an identity (email or phone) has registered passkeys.
850
850
  *
851
851
  * Returns:
852
- * - email_valid: whether the email domain has valid MX records
853
- * - has_passkey: whether any passkeys are registered (only meaningful if email_valid)
852
+ * - identity_valid: identity passes per-type validity check
853
+ * (email: MX lookup; phone: E.164 format)
854
+ * - has_passkey: whether any passkeys are registered for this identity
855
+ * (cross-tenant — single global RP)
856
+ * - email_valid: legacy alias for identity_valid, present for backward
857
+ * compatibility with older SDK versions
854
858
  */
855
- async checkPasskey(email) {
856
- return this.request('POST', '/passkey/check', { email });
859
+ async checkPasskey(identity, identityType = 'email') {
860
+ const body = identityType === 'phone' ? { phone: identity } : { email: identity };
861
+ return this.request('POST', '/passkey/check', body);
857
862
  }
858
863
  /**
859
864
  * Build auth context params for API requests (OIDC/simple mode).
@@ -898,12 +903,13 @@ class IdentityApi extends SparkVaultApi {
898
903
  });
899
904
  }
900
905
  /**
901
- * Start passkey registration
906
+ * Start passkey registration for an identity (email or phone).
902
907
  */
903
- async startPasskeyRegister(email) {
908
+ async startPasskeyRegister(identity, identityType = 'email') {
909
+ const body = identityType === 'phone' ? { phone: identity } : { email: identity };
904
910
  // Backend returns { options: PublicKeyCredentialCreationOptions, session: {...} }
905
911
  // Extract and flatten to match PasskeyChallengeResponse
906
- const response = await this.request('POST', '/passkey/register', { email });
912
+ const response = await this.request('POST', '/passkey/register', body);
907
913
  return {
908
914
  challenge: response.options.challenge,
909
915
  rpId: response.options.rp.id,
@@ -933,12 +939,13 @@ class IdentityApi extends SparkVaultApi {
933
939
  });
934
940
  }
935
941
  /**
936
- * Start passkey verification
942
+ * Start passkey verification for an identity (email or phone).
937
943
  */
938
- async startPasskeyVerify(email, authContext) {
944
+ async startPasskeyVerify(identity, identityType = 'email', authContext) {
945
+ const identityField = identityType === 'phone' ? { phone: identity } : { email: identity };
939
946
  // Backend returns { options: PublicKeyCredentialRequestOptions, session: {...} }
940
947
  // Extract and flatten to match PasskeyChallengeResponse
941
- const response = await this.request('POST', '/passkey/verify', { email, ...this.buildAuthContextParams(authContext) });
948
+ const response = await this.request('POST', '/passkey/verify', { ...identityField, ...this.buildAuthContextParams(authContext) });
942
949
  return {
943
950
  challenge: response.options.challenge,
944
951
  rpId: response.options.rpId,
@@ -1345,10 +1352,12 @@ class PasskeyHandler {
1345
1352
  */
1346
1353
  async checkPasskey() {
1347
1354
  try {
1348
- const response = await this.api.checkPasskey(this.state.recipient);
1355
+ const response = await this.api.checkPasskey(this.state.recipient, this.state.identityType);
1349
1356
  this.state.setPasskeyStatus(response.has_passkey);
1357
+ // Prefer identity_valid; fall back to email_valid for older backends.
1358
+ const valid = response.identity_valid ?? response.email_valid;
1350
1359
  return {
1351
- emailValid: response.email_valid,
1360
+ emailValid: valid,
1352
1361
  hasPasskey: response.has_passkey,
1353
1362
  };
1354
1363
  }
@@ -1380,12 +1389,14 @@ class PasskeyHandler {
1380
1389
  */
1381
1390
  async openPasskeyPopup(mode) {
1382
1391
  return new Promise((resolve) => {
1383
- // Build popup URL
1392
+ // Build popup URL. Pass identity as `email` or `phone` (mutually
1393
+ // exclusive) so the popup can render and POST the correct field.
1384
1394
  const params = new URLSearchParams({
1385
1395
  mode,
1386
- email: this.state.recipient,
1387
1396
  origin: window.location.origin,
1388
1397
  });
1398
+ const identityParam = this.state.identityType === 'phone' ? 'phone' : 'email';
1399
+ params.set(identityParam, this.state.recipient);
1389
1400
  // Add auth context for OIDC/simple mode flows
1390
1401
  const authContext = this.state.authContext;
1391
1402
  if (authContext?.authRequestId) {