@veridex/sdk 1.1.4 → 1.1.6

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.
@@ -1,6 +1,6 @@
1
1
  import { RegisterSessionParams, SessionValidationResult, RevokeSessionParams, SessionKey, IdentityState } from './types.mjs';
2
2
  import { ethers } from 'ethers';
3
- import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from './types-DP2CQT8p.mjs';
3
+ import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from './types-DQ5dtU9x.mjs';
4
4
 
5
5
  interface EVMClientConfig {
6
6
  chainId: number;
@@ -1,4 +1,4 @@
1
- import { P as PasskeyCredential, T as TransferParams, E as ExecuteParams, B as BridgeParams } from '../types-DP2CQT8p.mjs';
1
+ import { P as PasskeyCredential, T as TransferParams, E as ExecuteParams, B as BridgeParams } from '../types-DQ5dtU9x.mjs';
2
2
 
3
3
  type AuthenticateAndPrepareParams = {
4
4
  credential: PasskeyCredential;
@@ -499,7 +499,8 @@ var PasskeyManager = class _PasskeyManager {
499
499
  credentialId: response.id,
500
500
  publicKeyX: publicKey.x,
501
501
  publicKeyY: publicKey.y,
502
- keyHash
502
+ keyHash,
503
+ assurance: _PasskeyManager.assuranceFromRegistration(response) ?? void 0
503
504
  };
504
505
  return this.credential;
505
506
  }
@@ -878,7 +879,8 @@ var PasskeyManager = class _PasskeyManager {
878
879
  credentialId: response.id,
879
880
  publicKeyX: publicKey.x,
880
881
  publicKeyY: publicKey.y,
881
- keyHash
882
+ keyHash,
883
+ assurance: _PasskeyManager.assuranceFromRegistration(response) ?? void 0
882
884
  };
883
885
  this.addCredentialToStorage(backupCredential);
884
886
  return backupCredential;
@@ -895,17 +897,94 @@ var PasskeyManager = class _PasskeyManager {
895
897
  */
896
898
  static parseBackupFlags(authenticatorData) {
897
899
  try {
898
- const data = import_ethers2.ethers.getBytes(authenticatorData);
899
- if (data.length < 37) return null;
900
- const flags = data[32];
900
+ const assurance = _PasskeyManager.deriveAssurance(import_ethers2.ethers.getBytes(authenticatorData));
901
+ if (!assurance) return null;
901
902
  return {
902
- backupEligible: (flags & 8) !== 0,
903
- backupState: (flags & 16) !== 0
903
+ backupEligible: assurance.backupEligible,
904
+ backupState: assurance.backupState
904
905
  };
905
906
  } catch {
906
907
  return null;
907
908
  }
908
909
  }
910
+ /**
911
+ * Derive credential assurance from raw WebAuthn authenticator data.
912
+ *
913
+ * authData layout:
914
+ * rpIdHash (32) | flags (1) | signCount (4) | [attestedCredentialData: aaguid (16) | ...]
915
+ *
916
+ * Flags byte: UP 0x01 | UV 0x04 | BE 0x08 | BS 0x10 | AT 0x40 | ED 0x80
917
+ *
918
+ * BE is the authoritative signal for whether a credential is device-bound or
919
+ * syncable. It is set by the authenticator itself — unlike a platform/user-agent
920
+ * guess, it correctly identifies a hardware key used on a syncing platform.
921
+ *
922
+ * @returns Assurance, or `null` if authData is too short to be valid.
923
+ */
924
+ static deriveAssurance(authData) {
925
+ if (authData.length < 37) return null;
926
+ const flags = authData[32];
927
+ const backupEligible = (flags & 8) !== 0;
928
+ const attestedCredentialData = (flags & 64) !== 0;
929
+ let aaguid;
930
+ if (attestedCredentialData && authData.length >= 53) {
931
+ aaguid = import_ethers2.ethers.hexlify(authData.slice(37, 53));
932
+ }
933
+ return {
934
+ backupEligible,
935
+ backupState: (flags & 16) !== 0,
936
+ userVerified: (flags & 4) !== 0,
937
+ level: backupEligible ? "synced" : "device-bound",
938
+ aaguid
939
+ };
940
+ }
941
+ /**
942
+ * Extract raw authenticator data from a registration response.
943
+ *
944
+ * Prefers the `authenticatorData` field when the authenticator provides it,
945
+ * and otherwise locates the `authData` byte string inside the CBOR
946
+ * attestation object.
947
+ */
948
+ static extractAuthData(response) {
949
+ const direct = response.response.authenticatorData;
950
+ if (direct) {
951
+ try {
952
+ return base64URLDecode(direct);
953
+ } catch {
954
+ }
955
+ }
956
+ try {
957
+ const attestationObject = base64URLDecode(response.response.attestationObject);
958
+ let offset = 0;
959
+ if (attestationObject[offset] >= 160 && attestationObject[offset] <= 191) {
960
+ offset++;
961
+ }
962
+ const key = [104, 97, 117, 116, 104, 68, 97, 116, 97];
963
+ let found = false;
964
+ while (offset < attestationObject.length - 37) {
965
+ if (key.every((byte, i) => attestationObject[offset + i] === byte)) {
966
+ offset += key.length;
967
+ found = true;
968
+ break;
969
+ }
970
+ offset++;
971
+ }
972
+ if (!found) return null;
973
+ if (attestationObject[offset] === 88) {
974
+ offset += 2;
975
+ } else if (attestationObject[offset] === 89) {
976
+ offset += 3;
977
+ }
978
+ return attestationObject.slice(offset);
979
+ } catch {
980
+ return null;
981
+ }
982
+ }
983
+ /** Derive assurance directly from a registration response. */
984
+ static assuranceFromRegistration(response) {
985
+ const authData = _PasskeyManager.extractAuthData(response);
986
+ return authData ? _PasskeyManager.deriveAssurance(authData) : null;
987
+ }
909
988
  /**
910
989
  * Get the number of credentials stored locally.
911
990
  */