@metamask-previews/passkey-controller 4.0.0-preview-d3f9964be → 4.1.0-preview-aecbce4ff

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.
@@ -41,6 +41,9 @@ export class CeremonyManager {
41
41
  for (const [key, ceremony] of map) {
42
42
  if (now - ceremony.createdAt > CEREMONY_MAX_AGE_MS) {
43
43
  map.delete(key);
44
+ if (ceremonyType === 'registration') {
45
+ this.#deleteAuthenticationCeremoniesForRegistration(key);
46
+ }
44
47
  }
45
48
  }
46
49
  }
@@ -64,6 +67,16 @@ export class CeremonyManager {
64
67
  break;
65
68
  }
66
69
  map.delete(oldestKey);
70
+ if (ceremonyType === 'registration') {
71
+ this.#deleteAuthenticationCeremoniesForRegistration(oldestKey);
72
+ }
73
+ }
74
+ }
75
+ #deleteAuthenticationCeremoniesForRegistration(registrationChallenge) {
76
+ for (const [authenticationChallenge, ceremony] of this.#authenticationMap) {
77
+ if (ceremony.registrationChallenge === registrationChallenge) {
78
+ this.#authenticationMap.delete(authenticationChallenge);
79
+ }
67
80
  }
68
81
  }
69
82
  /**
@@ -115,7 +128,9 @@ export class CeremonyManager {
115
128
  * @returns Whether an entry was deleted.
116
129
  */
117
130
  deleteRegistrationCeremony(challenge) {
118
- return this.#registrationMap.delete(challenge);
131
+ const deleted = this.#registrationMap.delete(challenge);
132
+ this.#deleteAuthenticationCeremoniesForRegistration(challenge);
133
+ return deleted;
119
134
  }
120
135
  /**
121
136
  * Removes an authentication ceremony by challenge.
@@ -1 +1 @@
1
- {"version":3,"file":"ceremony-manager.js","sourceRoot":"","sources":["../src/ceremony-manager.ts"],"names":[],"mappings":"AAKA,qEAAqE;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB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IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACF","sourcesContent":["import type {\n PasskeyAuthenticationCeremony,\n PasskeyRegistrationCeremony,\n} from './types.js';\n\n/** WebAuthn `timeout` for credential creation and assertion (ms). */\nexport const WEBAUTHN_TIMEOUT_MS = 60_000;\n\n/**\n * Extra allowance beyond {@link WEBAUTHN_TIMEOUT_MS} before in-memory\n * ceremony state is discarded (covers slow UX, multi-step enrollment, and\n * clock skew).\n */\nexport const CEREMONY_TTL_SLACK_MS = 120_000;\n\n/**\n * Maximum age for in-flight registration or authentication ceremony state\n * (between options and verified response). This bounds the lifetime of a\n * single WebAuthn ceremony only; it is not a user login session timeout.\n */\nexport const CEREMONY_MAX_AGE_MS = WEBAUTHN_TIMEOUT_MS + CEREMONY_TTL_SLACK_MS;\n\n/**\n * Upper bound on concurrent in-memory ceremonies per flow type (registration\n * vs authentication), for abuse / leak protection.\n */\nexport const MAX_CONCURRENT_PASSKEY_CEREMONIES = 16;\n\ntype CeremonyFlow = 'registration' | 'authentication';\n\n/**\n * In-memory store for in-flight WebAuthn ceremonies (registration vs authentication),\n * keyed by base64url challenge. Enforces TTL and a per-flow size cap; not user session state.\n */\nexport class CeremonyManager {\n readonly #registrationMap = new Map<string, PasskeyRegistrationCeremony>();\n\n readonly #authenticationMap = new Map<\n string,\n PasskeyAuthenticationCeremony\n >();\n\n /**\n * Challenge-keyed map for prune/capacity helpers.\n *\n * @param ceremonyType - Which in-flight ceremony map to use.\n * @returns The registration or authentication ceremony map for the given flow.\n */\n #getMap(\n ceremonyType: CeremonyFlow,\n ): Map<string, PasskeyRegistrationCeremony | PasskeyAuthenticationCeremony> {\n return ceremonyType === 'registration'\n ? this.#registrationMap\n : this.#authenticationMap;\n }\n\n #pruneExpired(ceremonyType: CeremonyFlow): void {\n const now = Date.now();\n const map = this.#getMap(ceremonyType);\n for (const [key, ceremony] of map) {\n if (now - ceremony.createdAt > CEREMONY_MAX_AGE_MS) {\n map.delete(key);\n }\n }\n }\n\n /**\n * Removes the oldest entry (by `createdAt`) until size is below the cap.\n *\n * @param ceremonyType - Which in-flight ceremony map to evict from.\n */\n #enforceCapacity(ceremonyType: CeremonyFlow): void {\n const map = this.#getMap(ceremonyType);\n while (map.size >= MAX_CONCURRENT_PASSKEY_CEREMONIES) {\n let oldestKey: string | undefined;\n let oldestTime = Infinity;\n for (const [mapKey, ceremony] of map) {\n if (ceremony.createdAt < oldestTime) {\n oldestTime = ceremony.createdAt;\n oldestKey = mapKey;\n }\n }\n if (oldestKey === undefined) {\n break;\n }\n map.delete(oldestKey);\n }\n }\n\n /**\n * Records registration ceremony state after pruning expired rows and evicting oldest if at cap.\n *\n * @param challenge - Same base64url challenge as in the creation options `challenge` field.\n * @param ceremony - Payload to retrieve when the registration response returns.\n */\n saveRegistrationCeremony(\n challenge: string,\n ceremony: PasskeyRegistrationCeremony,\n ): void {\n this.#pruneExpired('registration');\n this.#enforceCapacity('registration');\n this.#registrationMap.set(challenge, ceremony);\n }\n\n /**\n * Records authentication ceremony state after pruning expired rows and evicting oldest if at cap.\n *\n * @param challenge - Same base64url challenge as in the request options `challenge` field.\n * @param ceremony - Payload to retrieve when the assertion response returns.\n */\n saveAuthenticationCeremony(\n challenge: string,\n ceremony: PasskeyAuthenticationCeremony,\n ): void {\n this.#pruneExpired('authentication');\n this.#enforceCapacity('authentication');\n this.#authenticationMap.set(challenge, ceremony);\n }\n\n /**\n * Returns registration ceremony for a challenge, pruning expired entries on this map first.\n *\n * @param challenge - Base64url challenge from decoded `clientDataJSON` (matches stored key).\n * @returns Stored ceremony, or `undefined` if none or expired.\n */\n getRegistrationCeremony(\n challenge: string,\n ): PasskeyRegistrationCeremony | undefined {\n this.#pruneExpired('registration');\n return this.#registrationMap.get(challenge);\n }\n\n /**\n * Returns authentication ceremony for a challenge, pruning expired entries on this map first.\n *\n * @param challenge - Base64url challenge from decoded `clientDataJSON` (matches stored key).\n * @returns Stored ceremony, or `undefined` if none or expired.\n */\n getAuthenticationCeremony(\n challenge: string,\n ): PasskeyAuthenticationCeremony | undefined {\n this.#pruneExpired('authentication');\n return this.#authenticationMap.get(challenge);\n }\n\n /**\n * Removes a registration ceremony by challenge.\n *\n * @param challenge - Map key for the ceremony to remove.\n * @returns Whether an entry was deleted.\n */\n deleteRegistrationCeremony(challenge: string): boolean {\n return this.#registrationMap.delete(challenge);\n }\n\n /**\n * Removes an authentication ceremony by challenge.\n *\n * @param challenge - Map key for the ceremony to remove.\n * @returns Whether an entry was deleted.\n */\n deleteAuthenticationCeremony(challenge: string): boolean {\n return this.#authenticationMap.delete(challenge);\n }\n\n /** Drops all in-flight registration and authentication ceremonies. */\n clear(): void {\n this.#registrationMap.clear();\n this.#authenticationMap.clear();\n }\n}\n"]}
1
+ {"version":3,"file":"ceremony-manager.js","sourceRoot":"","sources":["../src/ceremony-manager.ts"],"names":[],"mappings":"AAKA,qEAAqE;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAIpD;;;GAGG;AACH,MAAM,OAAO,eAAe;IACjB,gBAAgB,GAAG,IAAI,GAAG,EAAuC,CAAC;IAElE,kBAAkB,GAAG,IAAI,GAAG,EAGlC,CAAC;IAEJ;;;;;OAKG;IACH,OAAO,CACL,YAA0B;QAE1B,OAAO,YAAY,KAAK,cAAc;YACpC,CAAC,CAAC,IAAI,CAAC,gBAAgB;YACvB,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,YAA0B;QACtC,MAAM,GAAG,GAAG,IAAI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;;OAKG;IACH,4BAA4B,CAAC,SAAiB;QAC5C,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IAED,sEAAsE;IACtE,KAAK;QACH,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;CACF","sourcesContent":["import type {\n PasskeyAuthenticationCeremony,\n PasskeyRegistrationCeremony,\n} from './types.js';\n\n/** WebAuthn `timeout` for credential creation and assertion (ms). */\nexport const WEBAUTHN_TIMEOUT_MS = 60_000;\n\n/**\n * Extra allowance beyond {@link WEBAUTHN_TIMEOUT_MS} before in-memory\n * ceremony state is discarded (covers slow UX, multi-step enrollment, and\n * clock skew).\n */\nexport const CEREMONY_TTL_SLACK_MS = 120_000;\n\n/**\n * Maximum age for in-flight registration or authentication ceremony state\n * (between options and verified response). This bounds the lifetime of a\n * single WebAuthn ceremony only; it is not a user login session timeout.\n */\nexport const CEREMONY_MAX_AGE_MS = WEBAUTHN_TIMEOUT_MS + CEREMONY_TTL_SLACK_MS;\n\n/**\n * Upper bound on concurrent in-memory ceremonies per flow type (registration\n * vs authentication), for abuse / leak protection.\n */\nexport const MAX_CONCURRENT_PASSKEY_CEREMONIES = 16;\n\ntype CeremonyFlow = 'registration' | 'authentication';\n\n/**\n * In-memory store for in-flight WebAuthn ceremonies (registration vs authentication),\n * keyed by base64url challenge. Enforces TTL and a per-flow size cap; not user session state.\n */\nexport class CeremonyManager {\n readonly #registrationMap = new Map<string, PasskeyRegistrationCeremony>();\n\n readonly #authenticationMap = new Map<\n string,\n PasskeyAuthenticationCeremony\n >();\n\n /**\n * Challenge-keyed map for prune/capacity helpers.\n *\n * @param ceremonyType - Which in-flight ceremony map to use.\n * @returns The registration or authentication ceremony map for the given flow.\n */\n #getMap(\n ceremonyType: CeremonyFlow,\n ): Map<string, PasskeyRegistrationCeremony | PasskeyAuthenticationCeremony> {\n return ceremonyType === 'registration'\n ? this.#registrationMap\n : this.#authenticationMap;\n }\n\n #pruneExpired(ceremonyType: CeremonyFlow): void {\n const now = Date.now();\n const map = this.#getMap(ceremonyType);\n for (const [key, ceremony] of map) {\n if (now - ceremony.createdAt > CEREMONY_MAX_AGE_MS) {\n map.delete(key);\n if (ceremonyType === 'registration') {\n this.#deleteAuthenticationCeremoniesForRegistration(key);\n }\n }\n }\n }\n\n /**\n * Removes the oldest entry (by `createdAt`) until size is below the cap.\n *\n * @param ceremonyType - Which in-flight ceremony map to evict from.\n */\n #enforceCapacity(ceremonyType: CeremonyFlow): void {\n const map = this.#getMap(ceremonyType);\n while (map.size >= MAX_CONCURRENT_PASSKEY_CEREMONIES) {\n let oldestKey: string | undefined;\n let oldestTime = Infinity;\n for (const [mapKey, ceremony] of map) {\n if (ceremony.createdAt < oldestTime) {\n oldestTime = ceremony.createdAt;\n oldestKey = mapKey;\n }\n }\n if (oldestKey === undefined) {\n break;\n }\n map.delete(oldestKey);\n if (ceremonyType === 'registration') {\n this.#deleteAuthenticationCeremoniesForRegistration(oldestKey);\n }\n }\n }\n\n #deleteAuthenticationCeremoniesForRegistration(\n registrationChallenge: string,\n ): void {\n for (const [authenticationChallenge, ceremony] of this.#authenticationMap) {\n if (ceremony.registrationChallenge === registrationChallenge) {\n this.#authenticationMap.delete(authenticationChallenge);\n }\n }\n }\n\n /**\n * Records registration ceremony state after pruning expired rows and evicting oldest if at cap.\n *\n * @param challenge - Same base64url challenge as in the creation options `challenge` field.\n * @param ceremony - Payload to retrieve when the registration response returns.\n */\n saveRegistrationCeremony(\n challenge: string,\n ceremony: PasskeyRegistrationCeremony,\n ): void {\n this.#pruneExpired('registration');\n this.#enforceCapacity('registration');\n this.#registrationMap.set(challenge, ceremony);\n }\n\n /**\n * Records authentication ceremony state after pruning expired rows and evicting oldest if at cap.\n *\n * @param challenge - Same base64url challenge as in the request options `challenge` field.\n * @param ceremony - Payload to retrieve when the assertion response returns.\n */\n saveAuthenticationCeremony(\n challenge: string,\n ceremony: PasskeyAuthenticationCeremony,\n ): void {\n this.#pruneExpired('authentication');\n this.#enforceCapacity('authentication');\n this.#authenticationMap.set(challenge, ceremony);\n }\n\n /**\n * Returns registration ceremony for a challenge, pruning expired entries on this map first.\n *\n * @param challenge - Base64url challenge from decoded `clientDataJSON` (matches stored key).\n * @returns Stored ceremony, or `undefined` if none or expired.\n */\n getRegistrationCeremony(\n challenge: string,\n ): PasskeyRegistrationCeremony | undefined {\n this.#pruneExpired('registration');\n return this.#registrationMap.get(challenge);\n }\n\n /**\n * Returns authentication ceremony for a challenge, pruning expired entries on this map first.\n *\n * @param challenge - Base64url challenge from decoded `clientDataJSON` (matches stored key).\n * @returns Stored ceremony, or `undefined` if none or expired.\n */\n getAuthenticationCeremony(\n challenge: string,\n ): PasskeyAuthenticationCeremony | undefined {\n this.#pruneExpired('authentication');\n return this.#authenticationMap.get(challenge);\n }\n\n /**\n * Removes a registration ceremony by challenge.\n *\n * @param challenge - Map key for the ceremony to remove.\n * @returns Whether an entry was deleted.\n */\n deleteRegistrationCeremony(challenge: string): boolean {\n const deleted = this.#registrationMap.delete(challenge);\n this.#deleteAuthenticationCeremoniesForRegistration(challenge);\n return deleted;\n }\n\n /**\n * Removes an authentication ceremony by challenge.\n *\n * @param challenge - Map key for the ceremony to remove.\n * @returns Whether an entry was deleted.\n */\n deleteAuthenticationCeremony(challenge: string): boolean {\n return this.#authenticationMap.delete(challenge);\n }\n\n /** Drops all in-flight registration and authentication ceremonies. */\n clear(): void {\n this.#registrationMap.clear();\n this.#authenticationMap.clear();\n }\n}\n"]}
@@ -6,6 +6,9 @@ export declare const controllerName = "PasskeyController";
6
6
  export declare const PasskeyControllerErrorCode: {
7
7
  readonly NotEnrolled: 'not_enrolled';
8
8
  readonly AlreadyEnrolled: 'already_enrolled';
9
+ readonly MigrationNotRequired: 'migration_not_required';
10
+ readonly PrfRequired: 'prf_required';
11
+ readonly ReplacementSourceChanged: 'replacement_source_changed';
9
12
  readonly NoRegistrationCeremony: 'no_registration_ceremony';
10
13
  readonly RegistrationVerificationFailed: 'registration_verification_failed';
11
14
  readonly NoAuthenticationCeremony: 'no_authentication_ceremony';
@@ -23,6 +26,9 @@ export type PasskeyControllerErrorCode = (typeof PasskeyControllerErrorCode)[key
23
26
  export declare enum PasskeyControllerErrorMessage {
24
27
  NotEnrolled = "PasskeyController - Passkey is not enrolled",
25
28
  AlreadyEnrolled = "PasskeyController - Passkey is already enrolled",
29
+ MigrationNotRequired = "PasskeyController - PRF migration is not required",
30
+ PrfRequired = "PasskeyController - PRF output required for passkey migration",
31
+ ReplacementSourceChanged = "PasskeyController - Passkey replacement source changed",
26
32
  NoRegistrationCeremony = "PasskeyController - No active passkey registration ceremony",
27
33
  RegistrationVerificationFailed = "PasskeyController - Passkey registration verification failed",
28
34
  NoAuthenticationCeremony = "PasskeyController - No active passkey authentication ceremony",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,0BAA0B;aACrC,WAAW,EAAE,cAAc;aAC3B,eAAe,EAAE,kBAAkB;aACnC,sBAAsB,EAAE,0BAA0B;aAClD,8BAA8B,EAAE,kCAAkC;aAClE,wBAAwB,EAAE,4BAA4B;aACtD,gCAAgC,EAAE,oCAAoC;aACtE,kBAAkB,EAAE,sBAAsB;aAC1C,wBAAwB,EAAE,6BAA6B;aACvD,gBAAgB,EAAE,oBAAoB;aACtC,qBAAqB,EAAE,0BAA0B;aACjD,0BAA0B,EAAE,8BAA8B;CAClD,CAAC;AAEX,MAAM,MAAM,0BAA0B,GACpC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;AAE/E;;GAEG;AACH,oBAAY,6BAA6B;IACvC,WAAW,gDAAgD;IAC3D,eAAe,oDAAoD;IACnE,sB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/constants.js CHANGED
@@ -6,6 +6,9 @@ export const controllerName = 'PasskeyController';
6
6
  export const PasskeyControllerErrorCode = {
7
7
  NotEnrolled: 'not_enrolled',
8
8
  AlreadyEnrolled: 'already_enrolled',
9
+ MigrationNotRequired: 'migration_not_required',
10
+ PrfRequired: 'prf_required',
11
+ ReplacementSourceChanged: 'replacement_source_changed',
9
12
  NoRegistrationCeremony: 'no_registration_ceremony',
10
13
  RegistrationVerificationFailed: 'registration_verification_failed',
11
14
  NoAuthenticationCeremony: 'no_authentication_ceremony',
@@ -23,6 +26,9 @@ export var PasskeyControllerErrorMessage;
23
26
  (function (PasskeyControllerErrorMessage) {
24
27
  PasskeyControllerErrorMessage["NotEnrolled"] = "PasskeyController - Passkey is not enrolled";
25
28
  PasskeyControllerErrorMessage["AlreadyEnrolled"] = "PasskeyController - Passkey is already enrolled";
29
+ PasskeyControllerErrorMessage["MigrationNotRequired"] = "PasskeyController - PRF migration is not required";
30
+ PasskeyControllerErrorMessage["PrfRequired"] = "PasskeyController - PRF output required for passkey migration";
31
+ PasskeyControllerErrorMessage["ReplacementSourceChanged"] = "PasskeyController - Passkey replacement source changed";
26
32
  PasskeyControllerErrorMessage["NoRegistrationCeremony"] = "PasskeyController - No active passkey registration ceremony";
27
33
  PasskeyControllerErrorMessage["RegistrationVerificationFailed"] = "PasskeyController - Passkey registration verification failed";
28
34
  PasskeyControllerErrorMessage["NoAuthenticationCeremony"] = "PasskeyController - No active passkey authentication ceremony";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,WAAW,EAAE,cAAc;IAC3B,eAAe,EAAE,kBAAkB;IACnC,sBAAsB,EAAE,0BAA0B;IAClD,8BAA8B,EAAE,kCAAkC;IAClE,wBAAwB,EAAE,4BAA4B;IACtD,gCAAgC,EAAE,oCAAoC;IACtE,kBAAkB,EAAE,sBAAsB;IAC1C,wBAAwB,EAAE,6BAA6B;IACvD,gBAAgB,EAAE,oBAAoB;IACtC,qBAAqB,EAAE,0BAA0B;IACjD,0BAA0B,EAAE,8BAA8B;CAClD,CAAC;AAKX;;GAEG;AACH,MAAM,CAAN,IAAY,6BAYX;AAZD,WAAY,6BAA6B;IACvC,4FAA2D,CAAA;IAC3D,oGAAmE,CAAA;IACnE,uHAAsF,CAAA;IACtF,gIAA+F,CAAA;IAC/F,2HAA0F,CAAA;IAC1F,oIAAmG,CAAA;IACnG,2HAA0F,CAAA;IAC1F,qHAAoF,CAAA;IACpF,qIAAoG,CAAA;IACpG,yHAAwF,CAAA;IACxF,+GAA8E,CAAA;AAChF,CAAC,EAZW,6BAA6B,KAA7B,6BAA6B,QAYxC","sourcesContent":["export const controllerName = 'PasskeyController';\n\n/**\n * Stable programmatic codes for {@link PasskeyControllerError}.\n * Use these instead of matching `message` strings.\n */\nexport const PasskeyControllerErrorCode = {\n NotEnrolled: 'not_enrolled',\n AlreadyEnrolled: 'already_enrolled',\n NoRegistrationCeremony: 'no_registration_ceremony',\n RegistrationVerificationFailed: 'registration_verification_failed',\n NoAuthenticationCeremony: 'no_authentication_ceremony',\n AuthenticationVerificationFailed: 'authentication_verification_failed',\n MissingKeyMaterial: 'missing_key_material',\n VaultKeyDecryptionFailed: 'vault_key_decryption_failed',\n VaultKeyMismatch: 'vault_key_mismatch',\n VaultKeyRenewalFailed: 'vault_key_renewal_failed',\n EnrollmentPasswordRequired: 'enrollment_password_required',\n} as const;\n\nexport type PasskeyControllerErrorCode =\n (typeof PasskeyControllerErrorCode)[keyof typeof PasskeyControllerErrorCode];\n\n/**\n * Human-readable messages for {@link PasskeyControllerError}.\n */\nexport enum PasskeyControllerErrorMessage {\n NotEnrolled = `${controllerName} - Passkey is not enrolled`,\n AlreadyEnrolled = `${controllerName} - Passkey is already enrolled`,\n NoRegistrationCeremony = `${controllerName} - No active passkey registration ceremony`,\n RegistrationVerificationFailed = `${controllerName} - Passkey registration verification failed`,\n NoAuthenticationCeremony = `${controllerName} - No active passkey authentication ceremony`,\n AuthenticationVerificationFailed = `${controllerName} - Passkey authentication verification failed`,\n MissingKeyMaterial = `${controllerName} - Passkey assertion missing required key material`,\n VaultKeyDecryptionFailed = `${controllerName} - Passkey vault key decryption failed`,\n VaultKeyMismatch = `${controllerName} - Passkey authentication does not match the current vault key`,\n EnrollmentPasswordRequired = `${controllerName} - Password required to register passkey`,\n VaultKeyRenewalFailed = `${controllerName} - Passkey vault key renewal failed`,\n}\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,WAAW,EAAE,cAAc;IAC3B,eAAe,EAAE,kBAAkB;IACnC,oBAAoB,EAAE,wBAAwB;IAC9C,WAAW,EAAE,cAAc;IAC3B,wBAAwB,EAAE,4BAA4B;IACtD,sBAAsB,EAAE,0BAA0B;IAClD,8BAA8B,EAAE,kCAAkC;IAClE,wBAAwB,EAAE,4BAA4B;IACtD,gCAAgC,EAAE,oCAAoC;IACtE,kBAAkB,EAAE,sBAAsB;IAC1C,wBAAwB,EAAE,6BAA6B;IACvD,gBAAgB,EAAE,oBAAoB;IACtC,qBAAqB,EAAE,0BAA0B;IACjD,0BAA0B,EAAE,8BAA8B;CAClD,CAAC;AAKX;;GAEG;AACH,MAAM,CAAN,IAAY,6BAeX;AAfD,WAAY,6BAA6B;IACvC,4FAA2D,CAAA;IAC3D,oGAAmE,CAAA;IACnE,2GAA0E,CAAA;IAC1E,8GAA6E,CAAA;IAC7E,oHAAmF,CAAA;IACnF,uHAAsF,CAAA;IACtF,gIAA+F,CAAA;IAC/F,2HAA0F,CAAA;IAC1F,oIAAmG,CAAA;IACnG,2HAA0F,CAAA;IAC1F,qHAAoF,CAAA;IACpF,qIAAoG,CAAA;IACpG,yHAAwF,CAAA;IACxF,+GAA8E,CAAA;AAChF,CAAC,EAfW,6BAA6B,KAA7B,6BAA6B,QAexC","sourcesContent":["export const controllerName = 'PasskeyController';\n\n/**\n * Stable programmatic codes for {@link PasskeyControllerError}.\n * Use these instead of matching `message` strings.\n */\nexport const PasskeyControllerErrorCode = {\n NotEnrolled: 'not_enrolled',\n AlreadyEnrolled: 'already_enrolled',\n MigrationNotRequired: 'migration_not_required',\n PrfRequired: 'prf_required',\n ReplacementSourceChanged: 'replacement_source_changed',\n NoRegistrationCeremony: 'no_registration_ceremony',\n RegistrationVerificationFailed: 'registration_verification_failed',\n NoAuthenticationCeremony: 'no_authentication_ceremony',\n AuthenticationVerificationFailed: 'authentication_verification_failed',\n MissingKeyMaterial: 'missing_key_material',\n VaultKeyDecryptionFailed: 'vault_key_decryption_failed',\n VaultKeyMismatch: 'vault_key_mismatch',\n VaultKeyRenewalFailed: 'vault_key_renewal_failed',\n EnrollmentPasswordRequired: 'enrollment_password_required',\n} as const;\n\nexport type PasskeyControllerErrorCode =\n (typeof PasskeyControllerErrorCode)[keyof typeof PasskeyControllerErrorCode];\n\n/**\n * Human-readable messages for {@link PasskeyControllerError}.\n */\nexport enum PasskeyControllerErrorMessage {\n NotEnrolled = `${controllerName} - Passkey is not enrolled`,\n AlreadyEnrolled = `${controllerName} - Passkey is already enrolled`,\n MigrationNotRequired = `${controllerName} - PRF migration is not required`,\n PrfRequired = `${controllerName} - PRF output required for passkey migration`,\n ReplacementSourceChanged = `${controllerName} - Passkey replacement source changed`,\n NoRegistrationCeremony = `${controllerName} - No active passkey registration ceremony`,\n RegistrationVerificationFailed = `${controllerName} - Passkey registration verification failed`,\n NoAuthenticationCeremony = `${controllerName} - No active passkey authentication ceremony`,\n AuthenticationVerificationFailed = `${controllerName} - Passkey authentication verification failed`,\n MissingKeyMaterial = `${controllerName} - Passkey assertion missing required key material`,\n VaultKeyDecryptionFailed = `${controllerName} - Passkey vault key decryption failed`,\n VaultKeyMismatch = `${controllerName} - Passkey authentication does not match the current vault key`,\n EnrollmentPasswordRequired = `${controllerName} - Password required to register passkey`,\n VaultKeyRenewalFailed = `${controllerName} - Passkey vault key renewal failed`,\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export { PasskeyController, getDefaultPasskeyControllerState, passkeyControllerS
4
4
  export type { PasskeyControllerState, PasskeyControllerMessenger, PasskeyControllerOptions, PasskeyControllerGetStateAction, PasskeyControllerActions, PasskeyControllerStateChangedEvent, PasskeyControllerEvents, PasskeyCredentialInfo, PasskeyDerivationMethod, PasskeyKeyDerivation, PasskeyRecord, PrfEvalExtension, PrfClientExtensionResults, } from './types.js';
5
5
  export type { PasskeyRegistrationOptions, PasskeyRegistrationResponse, PasskeyAuthenticationOptions, PasskeyAuthenticationResponse, } from './webauthn/types.js';
6
6
  export { getAAGUIDFromRegistrationResponse } from './webauthn/verify-registration-response.js';
7
- export type { PasskeyControllerIsPasskeyEnrolledAction, PasskeyControllerGenerateRegistrationOptionsAction, PasskeyControllerGeneratePostRegistrationAuthenticationOptionsAction, PasskeyControllerGenerateAuthenticationOptionsAction, PasskeyControllerProtectVaultKeyWithPasskeyAction, PasskeyControllerRetrieveVaultKeyWithPasskeyAction, PasskeyControllerUnlockWithPasskeyAction, PasskeyControllerExportSeedPhraseWithPasskeyAction, PasskeyControllerExportAccountsWithPasskeyAction, PasskeyControllerVerifyPasskeyAuthenticationAction, PasskeyControllerRenewVaultKeyProtectionAction, PasskeyControllerChangePasswordWithPasskeyVerificationAction, PasskeyControllerRemovePasskeyWithPasskeyVerificationAction, PasskeyControllerRemovePasskeyWithPasswordVerificationAction, PasskeyControllerClearStateAction, PasskeyControllerDestroyAction, } from './PasskeyController-method-action-types.js';
7
+ export type { PasskeyControllerIsPasskeyEnrolledAction, PasskeyControllerGenerateRegistrationOptionsAction, PasskeyControllerGeneratePasskeyReplacementRegistrationOptionsAction, PasskeyControllerCompletePasskeyReplacementAction, PasskeyControllerCancelPasskeyReplacementAction, PasskeyControllerGeneratePostRegistrationAuthenticationOptionsAction, PasskeyControllerGenerateAuthenticationOptionsAction, PasskeyControllerProtectVaultKeyWithPasskeyAction, PasskeyControllerRetrieveVaultKeyWithPasskeyAction, PasskeyControllerUnlockWithPasskeyAction, PasskeyControllerExportSeedPhraseWithPasskeyAction, PasskeyControllerExportAccountsWithPasskeyAction, PasskeyControllerVerifyPasskeyAuthenticationAction, PasskeyControllerRenewVaultKeyProtectionAction, PasskeyControllerChangePasswordWithPasskeyVerificationAction, PasskeyControllerRemovePasskeyWithPasskeyVerificationAction, PasskeyControllerRemovePasskeyWithPasswordVerificationAction, PasskeyControllerClearStateAction, PasskeyControllerDestroyAction, } from './PasskeyController-method-action-types.js';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,iBAAiB,EACjB,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,+BAA+B,EAC/B,wBAAwB,EACxB,kCAAkC,EAClC,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,YAAY,EACV,wCAAwC,EACxC,kDAAkD,EAClD,oEAAoE,EACpE,oDAAoD,EACpD,iDAAiD,EACjD,kDAAkD,EAClD,wCAAwC,EACxC,kDAAkD,EAClD,gDAAgD,EAChD,kDAAkD,EAClD,8CAA8C,EAC9C,4DAA4D,EAC5D,2DAA2D,EAC3D,4DAA4D,EAC5D,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,4CAA4C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,iBAAiB,EACjB,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,+BAA+B,EAC/B,wBAAwB,EACxB,kCAAkC,EAClC,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,YAAY,EACV,wCAAwC,EACxC,kDAAkD,EAClD,oEAAoE,EACpE,iDAAiD,EACjD,+CAA+C,EAC/C,oEAAoE,EACpE,oDAAoD,EACpD,iDAAiD,EACjD,kDAAkD,EAClD,wCAAwC,EACxC,kDAAkD,EAClD,gDAAgD,EAChD,kDAAkD,EAClD,8CAA8C,EAC9C,4DAA4D,EAC5D,2DAA2D,EAC3D,4DAA4D,EAC5D,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,4CAA4C,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,iBAAiB,EACjB,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAsBhC,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC","sourcesContent":["export {\n PasskeyControllerErrorCode,\n PasskeyControllerErrorMessage,\n} from './constants.js';\nexport { PasskeyControllerError } from './errors.js';\nexport {\n PasskeyController,\n getDefaultPasskeyControllerState,\n passkeyControllerSelectors,\n} from './PasskeyController.js';\nexport type {\n PasskeyControllerState,\n PasskeyControllerMessenger,\n PasskeyControllerOptions,\n PasskeyControllerGetStateAction,\n PasskeyControllerActions,\n PasskeyControllerStateChangedEvent,\n PasskeyControllerEvents,\n PasskeyCredentialInfo,\n PasskeyDerivationMethod,\n PasskeyKeyDerivation,\n PasskeyRecord,\n PrfEvalExtension,\n PrfClientExtensionResults,\n} from './types.js';\nexport type {\n PasskeyRegistrationOptions,\n PasskeyRegistrationResponse,\n PasskeyAuthenticationOptions,\n PasskeyAuthenticationResponse,\n} from './webauthn/types.js';\nexport { getAAGUIDFromRegistrationResponse } from './webauthn/verify-registration-response.js';\nexport type {\n PasskeyControllerIsPasskeyEnrolledAction,\n PasskeyControllerGenerateRegistrationOptionsAction,\n PasskeyControllerGeneratePostRegistrationAuthenticationOptionsAction,\n PasskeyControllerGenerateAuthenticationOptionsAction,\n PasskeyControllerProtectVaultKeyWithPasskeyAction,\n PasskeyControllerRetrieveVaultKeyWithPasskeyAction,\n PasskeyControllerUnlockWithPasskeyAction,\n PasskeyControllerExportSeedPhraseWithPasskeyAction,\n PasskeyControllerExportAccountsWithPasskeyAction,\n PasskeyControllerVerifyPasskeyAuthenticationAction,\n PasskeyControllerRenewVaultKeyProtectionAction,\n PasskeyControllerChangePasswordWithPasskeyVerificationAction,\n PasskeyControllerRemovePasskeyWithPasskeyVerificationAction,\n PasskeyControllerRemovePasskeyWithPasswordVerificationAction,\n PasskeyControllerClearStateAction,\n PasskeyControllerDestroyAction,\n} from './PasskeyController-method-action-types.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,iBAAiB,EACjB,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAsBhC,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC","sourcesContent":["export {\n PasskeyControllerErrorCode,\n PasskeyControllerErrorMessage,\n} from './constants.js';\nexport { PasskeyControllerError } from './errors.js';\nexport {\n PasskeyController,\n getDefaultPasskeyControllerState,\n passkeyControllerSelectors,\n} from './PasskeyController.js';\nexport type {\n PasskeyControllerState,\n PasskeyControllerMessenger,\n PasskeyControllerOptions,\n PasskeyControllerGetStateAction,\n PasskeyControllerActions,\n PasskeyControllerStateChangedEvent,\n PasskeyControllerEvents,\n PasskeyCredentialInfo,\n PasskeyDerivationMethod,\n PasskeyKeyDerivation,\n PasskeyRecord,\n PrfEvalExtension,\n PrfClientExtensionResults,\n} from './types.js';\nexport type {\n PasskeyRegistrationOptions,\n PasskeyRegistrationResponse,\n PasskeyAuthenticationOptions,\n PasskeyAuthenticationResponse,\n} from './webauthn/types.js';\nexport { getAAGUIDFromRegistrationResponse } from './webauthn/verify-registration-response.js';\nexport type {\n PasskeyControllerIsPasskeyEnrolledAction,\n PasskeyControllerGenerateRegistrationOptionsAction,\n PasskeyControllerGeneratePasskeyReplacementRegistrationOptionsAction,\n PasskeyControllerCompletePasskeyReplacementAction,\n PasskeyControllerCancelPasskeyReplacementAction,\n PasskeyControllerGeneratePostRegistrationAuthenticationOptionsAction,\n PasskeyControllerGenerateAuthenticationOptionsAction,\n PasskeyControllerProtectVaultKeyWithPasskeyAction,\n PasskeyControllerRetrieveVaultKeyWithPasskeyAction,\n PasskeyControllerUnlockWithPasskeyAction,\n PasskeyControllerExportSeedPhraseWithPasskeyAction,\n PasskeyControllerExportAccountsWithPasskeyAction,\n PasskeyControllerVerifyPasskeyAuthenticationAction,\n PasskeyControllerRenewVaultKeyProtectionAction,\n PasskeyControllerChangePasswordWithPasskeyVerificationAction,\n PasskeyControllerRemovePasskeyWithPasskeyVerificationAction,\n PasskeyControllerRemovePasskeyWithPasswordVerificationAction,\n PasskeyControllerClearStateAction,\n PasskeyControllerDestroyAction,\n} from './PasskeyController-method-action-types.js';\n"]}
package/dist/types.d.ts CHANGED
@@ -60,9 +60,10 @@ export type PasskeyRecord = {
60
60
  };
61
61
  /**
62
62
  * In-memory state for one **in-flight** WebAuthn **registration** ceremony
63
- * (from `create()` options until `protectVaultKeyWithPasskey` completes). This is
64
- * not a user login session; it is keyed by challenge and distinct from the full
65
- * spec ceremony (which includes the authenticator round-trip).
63
+ * (from `create()` options until the enrollment or replacement completion
64
+ * method finishes). This is not a user login session; it is keyed by challenge
65
+ * and distinct from the full spec ceremony (which includes the authenticator
66
+ * round-trip).
66
67
  */
67
68
  export type PasskeyRegistrationCeremony = {
68
69
  userHandle: Base64URLString;
@@ -70,6 +71,14 @@ export type PasskeyRegistrationCeremony = {
70
71
  challenge: Base64URLString;
71
72
  /** When this ceremony was started (ms since epoch); used for TTL pruning. */
72
73
  createdAt: number;
74
+ /**
75
+ * Whether this ceremony is for replacing an existing passkey.
76
+ *
77
+ * Omitted or `false` for existing enrollment ceremonies.
78
+ */
79
+ isReplacement?: boolean;
80
+ /** Credential ID of the record being replaced. */
81
+ sourceCredentialId?: Base64URLString;
73
82
  };
74
83
  /**
75
84
  * In-memory state for one **in-flight** WebAuthn **authentication** ceremony
@@ -77,6 +86,11 @@ export type PasskeyRegistrationCeremony = {
77
86
  */
78
87
  export type PasskeyAuthenticationCeremony = {
79
88
  challenge: Base64URLString;
89
+ /**
90
+ * Registration challenge when this authentication is the post-registration
91
+ * step of an enrollment or replacement ceremony.
92
+ */
93
+ registrationChallenge?: Base64URLString;
80
94
  /** When this ceremony was started (ms since epoch); used for TTL pruning. */
81
95
  createdAt: number;
82
96
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,qCAAqC,EACrC,oCAAoC,EACpC,0CAA0C,EAC1C,uCAAuC,EACvC,0CAA0C,EAC1C,qCAAqC,EACtC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAEjG,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,4BAA4B,GACpC,KAAK,GACL,OAAO,GACP,QAAQ,GACR,UAAU,GACV,KAAK,GACL,YAAY,GACZ,KAAK,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,0CAA0C;IAC1C,EAAE,EAAE,eAAe,CAAC;IACpB,gFAAgF;IAChF,SAAS,EAAE,eAAe,CAAC;IAC3B,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;IAC5C,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAA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M,wBAAwB,GAChC,+BAA+B,GAC/B,8BAA8B,CAAC;AAEnC,MAAM,MAAM,kCAAkC,GAAG,2BAA2B,CAC1E,OAAO,cAAc,EACrB,sBAAsB,CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,kCAAkC,CAAC;AAEzE,MAAM,MAAM,0BAA0B,GAAG,SAAS,CAChD,OAAO,cAAc,EACrB,wBAAwB,GAAG,+BAA+B,EAC1D,uBAAuB,CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,0BAA0B,CAAC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,wBAAwB,EAAE,MAAM,OAAO,CAAC;CACzC,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n} from '@metamask/base-controller';\nimport type {\n KeyringControllerChangePasswordAction,\n KeyringControllerExportAccountAction,\n KeyringControllerExportEncryptionKeyAction,\n KeyringControllerExportSeedPhraseAction,\n KeyringControllerSubmitEncryptionKeyAction,\n KeyringControllerVerifyPasswordAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { controllerName } from './constants.js';\nimport type { PasskeyControllerMethodActions } from './PasskeyController-method-action-types.js';\n\nexport type Base64String = string;\n\nexport type Base64URLString = string;\n\nexport type AuthenticatorTransportFuture =\n | 'ble'\n | 'cable'\n | 'hybrid'\n | 'internal'\n | 'nfc'\n | 'smart-card'\n | 'usb';\n\n/**\n * WebAuthn credential metadata used to identify the passkey and verify\n * subsequent assertions.\n */\nexport type PasskeyCredentialInfo = {\n /** WebAuthn credential ID (base64url). */\n id: Base64URLString;\n /** COSE-encoded credential public key (base64url) used to verify assertions. */\n publicKey: Base64URLString;\n /** Authenticator signature counter for replay/clone detection. */\n counter: number;\n /** Authenticator transports hint for `allowCredentials`. */\n transports?: AuthenticatorTransportFuture[];\n /** Authenticator AAGUID captured from attested credential data at registration. */\n aaguid: string;\n};\n\n/**\n * Vault key wrapped under the passkey-derived AES-256-GCM key.\n */\nexport type EncryptedVaultKey = {\n /** Base64-encoded AES-256-GCM ciphertext of the vault key. */\n ciphertext: Base64String;\n /** Base64-encoded AES-GCM IV used during encryption. */\n iv: Base64String;\n};\n\n/**\n * Parameters needed to reproduce the AES-256 wrapping key at unlock time.\n *\n * Encoded as a discriminated union so PRF-only fields (e.g. `prfSalt`) can\n * only exist on the PRF branch, removing the \"optional but actually\n * required\" footgun.\n */\nexport type PasskeyKeyDerivation =\n | {\n method: 'prf';\n /**\n * PRF salt sent in `get()` extension options to reproduce the same PRF\n * output that was generated at registration.\n */\n prfSalt: Base64URLString;\n }\n | { method: 'userHandle' };\n\n/** Discriminator value for {@link PasskeyKeyDerivation}. */\nexport type PasskeyDerivationMethod = PasskeyKeyDerivation['method'];\n\nexport type PasskeyRecord = {\n /** WebAuthn credential metadata used for assertion verification & re-discovery. */\n credential: PasskeyCredentialInfo;\n /** Vault key wrapped under the passkey-derived key. */\n encryptedVaultKey: EncryptedVaultKey;\n /** How the wrapping key is reconstructed at unlock time. */\n keyDerivation: PasskeyKeyDerivation;\n};\n\n/**\n * In-memory state for one **in-flight** WebAuthn **registration** ceremony\n * (from `create()` options until `protectVaultKeyWithPasskey` completes). This is\n * not a user login session; it is keyed by challenge and distinct from the full\n * spec ceremony (which includes the authenticator round-trip).\n */\nexport type PasskeyRegistrationCeremony = {\n userHandle: Base64URLString;\n prfSalt?: Base64URLString;\n challenge: Base64URLString;\n /** When this ceremony was started (ms since epoch); used for TTL pruning. */\n createdAt: number;\n};\n\n/**\n * In-memory state for one **in-flight** WebAuthn **authentication** ceremony\n * (`get()` options until the assertion is verified). Not a user login session.\n */\nexport type PasskeyAuthenticationCeremony = {\n challenge: Base64URLString;\n /** When this ceremony was started (ms since epoch); used for TTL pruning. */\n createdAt: number;\n};\n\n/**\n * PRF extension types not covered by DOM typings.\n */\nexport type PrfEvalExtension = {\n eval: {\n first: Base64URLString;\n };\n};\n\nexport type PrfClientExtensionResults = {\n prf?: {\n enabled?: boolean;\n results?: { first?: Base64URLString };\n };\n};\n\nexport type PasskeyControllerState = {\n passkeyRecord: PasskeyRecord | null;\n};\n\nexport type PasskeyControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n PasskeyControllerState\n>;\n\n/**\n * KeyringController actions that {@link PasskeyController} may call during\n * orchestrated passkey flows. The restricted messenger must allow these at init.\n */\nexport type PasskeyControllerAllowedActions =\n | KeyringControllerVerifyPasswordAction\n | KeyringControllerExportEncryptionKeyAction\n | KeyringControllerSubmitEncryptionKeyAction\n | KeyringControllerChangePasswordAction\n | KeyringControllerExportSeedPhraseAction\n | KeyringControllerExportAccountAction;\n\n/**\n * Actions exposed by {@link PasskeyController} on its messenger, including\n * `:getState`, enrollment/unlock ceremony methods, and lifecycle helpers.\n */\nexport type PasskeyControllerActions =\n | PasskeyControllerGetStateAction\n | PasskeyControllerMethodActions;\n\nexport type PasskeyControllerStateChangedEvent = ControllerStateChangedEvent<\n typeof controllerName,\n PasskeyControllerState\n>;\n\nexport type PasskeyControllerEvents = PasskeyControllerStateChangedEvent;\n\nexport type PasskeyControllerMessenger = Messenger<\n typeof controllerName,\n PasskeyControllerActions | PasskeyControllerAllowedActions,\n PasskeyControllerEvents\n>;\n\nexport type PasskeyControllerOptions = {\n messenger: PasskeyControllerMessenger;\n state?: Partial<PasskeyControllerState>;\n rpId?: string;\n expectedRPID: string | string[];\n rpName: string;\n expectedOrigin: string | string[];\n userName?: string;\n userDisplayName?: string;\n /**\n * Returns whether wallet onboarding is complete. When `true`, enrollment\n * requires password step-up. The integrator typically supplies\n * `() => onboardingController.state.completedOnboarding`.\n */\n getIsOnboardingCompleted: () => boolean;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangedEvent,\n} from '@metamask/base-controller';\nimport type {\n KeyringControllerChangePasswordAction,\n KeyringControllerExportAccountAction,\n KeyringControllerExportEncryptionKeyAction,\n KeyringControllerExportSeedPhraseAction,\n KeyringControllerSubmitEncryptionKeyAction,\n KeyringControllerVerifyPasswordAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { controllerName } from './constants.js';\nimport type { PasskeyControllerMethodActions } from './PasskeyController-method-action-types.js';\n\nexport type Base64String = string;\n\nexport type Base64URLString = string;\n\nexport type AuthenticatorTransportFuture =\n | 'ble'\n | 'cable'\n | 'hybrid'\n | 'internal'\n | 'nfc'\n | 'smart-card'\n | 'usb';\n\n/**\n * WebAuthn credential metadata used to identify the passkey and verify\n * subsequent assertions.\n */\nexport type PasskeyCredentialInfo = {\n /** WebAuthn credential ID (base64url). */\n id: Base64URLString;\n /** COSE-encoded credential public key (base64url) used to verify assertions. */\n publicKey: Base64URLString;\n /** Authenticator signature counter for replay/clone detection. */\n counter: number;\n /** Authenticator transports hint for `allowCredentials`. */\n transports?: AuthenticatorTransportFuture[];\n /** Authenticator AAGUID captured from attested credential data at registration. */\n aaguid: string;\n};\n\n/**\n * Vault key wrapped under the passkey-derived AES-256-GCM key.\n */\nexport type EncryptedVaultKey = {\n /** Base64-encoded AES-256-GCM ciphertext of the vault key. */\n ciphertext: Base64String;\n /** Base64-encoded AES-GCM IV used during encryption. */\n iv: Base64String;\n};\n\n/**\n * Parameters needed to reproduce the AES-256 wrapping key at unlock time.\n *\n * Encoded as a discriminated union so PRF-only fields (e.g. `prfSalt`) can\n * only exist on the PRF branch, removing the \"optional but actually\n * required\" footgun.\n */\nexport type PasskeyKeyDerivation =\n | {\n method: 'prf';\n /**\n * PRF salt sent in `get()` extension options to reproduce the same PRF\n * output that was generated at registration.\n */\n prfSalt: Base64URLString;\n }\n | { method: 'userHandle' };\n\n/** Discriminator value for {@link PasskeyKeyDerivation}. */\nexport type PasskeyDerivationMethod = PasskeyKeyDerivation['method'];\n\nexport type PasskeyRecord = {\n /** WebAuthn credential metadata used for assertion verification & re-discovery. */\n credential: PasskeyCredentialInfo;\n /** Vault key wrapped under the passkey-derived key. */\n encryptedVaultKey: EncryptedVaultKey;\n /** How the wrapping key is reconstructed at unlock time. */\n keyDerivation: PasskeyKeyDerivation;\n};\n\n/**\n * In-memory state for one **in-flight** WebAuthn **registration** ceremony\n * (from `create()` options until the enrollment or replacement completion\n * method finishes). This is not a user login session; it is keyed by challenge\n * and distinct from the full spec ceremony (which includes the authenticator\n * round-trip).\n */\nexport type PasskeyRegistrationCeremony = {\n userHandle: Base64URLString;\n prfSalt?: Base64URLString;\n challenge: Base64URLString;\n /** When this ceremony was started (ms since epoch); used for TTL pruning. */\n createdAt: number;\n /**\n * Whether this ceremony is for replacing an existing passkey.\n *\n * Omitted or `false` for existing enrollment ceremonies.\n */\n isReplacement?: boolean;\n /** Credential ID of the record being replaced. */\n sourceCredentialId?: Base64URLString;\n};\n\n/**\n * In-memory state for one **in-flight** WebAuthn **authentication** ceremony\n * (`get()` options until the assertion is verified). Not a user login session.\n */\nexport type PasskeyAuthenticationCeremony = {\n challenge: Base64URLString;\n /**\n * Registration challenge when this authentication is the post-registration\n * step of an enrollment or replacement ceremony.\n */\n registrationChallenge?: Base64URLString;\n /** When this ceremony was started (ms since epoch); used for TTL pruning. */\n createdAt: number;\n};\n\n/**\n * PRF extension types not covered by DOM typings.\n */\nexport type PrfEvalExtension = {\n eval: {\n first: Base64URLString;\n };\n};\n\nexport type PrfClientExtensionResults = {\n prf?: {\n enabled?: boolean;\n results?: { first?: Base64URLString };\n };\n};\n\nexport type PasskeyControllerState = {\n passkeyRecord: PasskeyRecord | null;\n};\n\nexport type PasskeyControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n PasskeyControllerState\n>;\n\n/**\n * KeyringController actions that {@link PasskeyController} may call during\n * orchestrated passkey flows. The restricted messenger must allow these at init.\n */\nexport type PasskeyControllerAllowedActions =\n | KeyringControllerVerifyPasswordAction\n | KeyringControllerExportEncryptionKeyAction\n | KeyringControllerSubmitEncryptionKeyAction\n | KeyringControllerChangePasswordAction\n | KeyringControllerExportSeedPhraseAction\n | KeyringControllerExportAccountAction;\n\n/**\n * Actions exposed by {@link PasskeyController} on its messenger, including\n * `:getState`, enrollment/unlock ceremony methods, and lifecycle helpers.\n */\nexport type PasskeyControllerActions =\n | PasskeyControllerGetStateAction\n | PasskeyControllerMethodActions;\n\nexport type PasskeyControllerStateChangedEvent = ControllerStateChangedEvent<\n typeof controllerName,\n PasskeyControllerState\n>;\n\nexport type PasskeyControllerEvents = PasskeyControllerStateChangedEvent;\n\nexport type PasskeyControllerMessenger = Messenger<\n typeof controllerName,\n PasskeyControllerActions | PasskeyControllerAllowedActions,\n PasskeyControllerEvents\n>;\n\nexport type PasskeyControllerOptions = {\n messenger: PasskeyControllerMessenger;\n state?: Partial<PasskeyControllerState>;\n rpId?: string;\n expectedRPID: string | string[];\n rpName: string;\n expectedOrigin: string | string[];\n userName?: string;\n userDisplayName?: string;\n /**\n * Returns whether wallet onboarding is complete. When `true`, enrollment\n * requires password step-up. The integrator typically supplies\n * `() => onboardingController.state.completedOnboarding`.\n */\n getIsOnboardingCompleted: () => boolean;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/passkey-controller",
3
- "version": "4.0.0-preview-d3f9964be",
3
+ "version": "4.1.0-preview-aecbce4ff",
4
4
  "description": "Controller and utilities for passkey-based wallet unlock",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -62,14 +62,14 @@
62
62
  "async-mutex": "^0.5.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@metamask/auto-changelog": "^6.1.0",
65
+ "@metamask/auto-changelog": "^6.2.1",
66
66
  "@types/jest": "^30.0.0",
67
67
  "@typescript/native": "npm:typescript@^7.0.2",
68
68
  "deepmerge": "^4.2.2",
69
69
  "jest": "^30.4.2",
70
- "rimraf": "^5.0.5",
71
- "ts-jest": "^29.4.11",
72
- "tsx": "^4.20.5",
70
+ "rimraf": "^6.1.3",
71
+ "ts-jest": "^29.4.12",
72
+ "tsx": "^4.23.13",
73
73
  "typedoc": "^0.25.13",
74
74
  "typedoc-plugin-missing-exports": "^2.0.0",
75
75
  "typescript": "npm:@typescript/typescript6@^6.0.2"