@metamask-previews/passkey-controller 2.1.0-preview-789f7f935 → 2.1.0-preview-eade524
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/CHANGELOG.md +21 -0
- package/README.md +85 -20
- package/dist/PasskeyController-method-action-types.cjs.map +1 -1
- package/dist/PasskeyController-method-action-types.d.cts +85 -7
- package/dist/PasskeyController-method-action-types.d.cts.map +1 -1
- package/dist/PasskeyController-method-action-types.d.mts +85 -7
- package/dist/PasskeyController-method-action-types.d.mts.map +1 -1
- package/dist/PasskeyController-method-action-types.mjs.map +1 -1
- package/dist/PasskeyController.cjs +326 -164
- package/dist/PasskeyController.cjs.map +1 -1
- package/dist/PasskeyController.d.cts +88 -50
- package/dist/PasskeyController.d.cts.map +1 -1
- package/dist/PasskeyController.d.mts +88 -50
- package/dist/PasskeyController.d.mts.map +1 -1
- package/dist/PasskeyController.mjs +326 -164
- package/dist/PasskeyController.mjs.map +1 -1
- package/dist/constants.cjs +3 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +4 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +4 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +3 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +38 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +38 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +4 -2
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import type { ControllerGetStateAction, ControllerStateChangedEvent } from "@metamask/base-controller";
|
|
2
1
|
import { BaseController } from "@metamask/base-controller";
|
|
3
|
-
import type { Messenger } from "@metamask/messenger";
|
|
4
2
|
import { controllerName } from "./constants.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import type { PasskeyRecord } from "./types.mjs";
|
|
3
|
+
import type { PasskeyControllerMessenger, PasskeyControllerOptions, PasskeyControllerState } from "./types.mjs";
|
|
7
4
|
import type { PasskeyAuthenticationOptions, PasskeyAuthenticationResponse, PasskeyRegistrationOptions, PasskeyRegistrationResponse } from "./webauthn/types.mjs";
|
|
8
|
-
export type PasskeyControllerState
|
|
9
|
-
passkeyRecord: PasskeyRecord | null;
|
|
10
|
-
};
|
|
11
|
-
export type PasskeyControllerGetStateAction = ControllerGetStateAction<typeof controllerName, PasskeyControllerState>;
|
|
12
|
-
/**
|
|
13
|
-
* Actions exposed by {@link PasskeyController} on its messenger.
|
|
14
|
-
*
|
|
15
|
-
* Only `:getState` is exposed. Derived enrollment status is available via
|
|
16
|
-
* {@link passkeyControllerSelectors.selectIsPasskeyEnrolled}, and lifecycle
|
|
17
|
-
* methods ({@link PasskeyController.generateRegistrationOptions},
|
|
18
|
-
* {@link PasskeyController.protectVaultKeyWithPasskey}, etc.) accept or
|
|
19
|
-
* return non-`Json` runtime values (WebAuthn `PublicKeyCredential` objects
|
|
20
|
-
* and the vault key string), so they require a direct controller reference.
|
|
21
|
-
*/
|
|
22
|
-
export type PasskeyControllerActions = PasskeyControllerGetStateAction | PasskeyControllerMethodActions;
|
|
23
|
-
export type PasskeyControllerStateChangedEvent = ControllerStateChangedEvent<typeof controllerName, PasskeyControllerState>;
|
|
24
|
-
export type PasskeyControllerEvents = PasskeyControllerStateChangedEvent;
|
|
25
|
-
export type PasskeyControllerMessenger = Messenger<typeof controllerName, PasskeyControllerActions, PasskeyControllerEvents>;
|
|
5
|
+
export type { PasskeyControllerActions, PasskeyControllerAllowedActions, PasskeyControllerEvents, PasskeyControllerGetStateAction, PasskeyControllerMessenger, PasskeyControllerOptions, PasskeyControllerState, PasskeyControllerStateChangedEvent, } from "./types.mjs";
|
|
26
6
|
/**
|
|
27
7
|
* Returns the default (empty) state for {@link PasskeyController}.
|
|
28
8
|
*
|
|
@@ -48,29 +28,18 @@ export declare class PasskeyController extends BaseController<typeof controllerN
|
|
|
48
28
|
/**
|
|
49
29
|
* Creates a passkey controller with WebAuthn relying-party settings.
|
|
50
30
|
*
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @param
|
|
58
|
-
*
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*/
|
|
64
|
-
constructor({ messenger, state, rpId, expectedRPID, rpName, expectedOrigin, userName, userDisplayName, }: {
|
|
65
|
-
messenger: PasskeyControllerMessenger;
|
|
66
|
-
state?: Partial<PasskeyControllerState>;
|
|
67
|
-
rpId?: string;
|
|
68
|
-
expectedRPID: string | string[];
|
|
69
|
-
rpName: string;
|
|
70
|
-
expectedOrigin: string | string[];
|
|
71
|
-
userName?: string;
|
|
72
|
-
userDisplayName?: string;
|
|
73
|
-
});
|
|
31
|
+
* @param options - Constructor options.
|
|
32
|
+
* @param options.messenger - The messenger to use for communication.
|
|
33
|
+
* @param options.state - The initial state of the controller.
|
|
34
|
+
* @param options.rpId - The relying party ID to use for the passkey.
|
|
35
|
+
* @param options.expectedRPID - The expected relying party ID to use for the passkey.
|
|
36
|
+
* @param options.rpName - The relying party name to use for the passkey.
|
|
37
|
+
* @param options.expectedOrigin - The expected origin to use for the passkey.
|
|
38
|
+
* @param options.userName - The user name to use for the passkey.
|
|
39
|
+
* @param options.userDisplayName - The user display name to use for the passkey.
|
|
40
|
+
* @param options.getIsOnboardingCompleted - The callback to use to check if onboarding is complete.
|
|
41
|
+
*/
|
|
42
|
+
constructor({ messenger, state, rpId, expectedRPID, rpName, expectedOrigin, userName, userDisplayName, getIsOnboardingCompleted, }: PasskeyControllerOptions);
|
|
74
43
|
/**
|
|
75
44
|
* Whether a passkey is enrolled and vault key material is stored.
|
|
76
45
|
*
|
|
@@ -108,23 +77,54 @@ export declare class PasskeyController extends BaseController<typeof controllerN
|
|
|
108
77
|
* Verifies registration and post-registration authentication, then stores the
|
|
109
78
|
* vault key encrypted under the new passkey.
|
|
110
79
|
*
|
|
80
|
+
* Fetches the current vault encryption key from KeyringController before wrapping.
|
|
81
|
+
* When onboarding is complete, requires `password` for step-up verification first.
|
|
82
|
+
*
|
|
111
83
|
* @param params - Enrollment completion inputs.
|
|
112
84
|
* @param params.registrationResponse - Result of `navigator.credentials.create()`.
|
|
113
85
|
* @param params.authenticationResponse - Result of `navigator.credentials.get()` after {@link generatePostRegistrationAuthenticationOptions}.
|
|
114
|
-
* @param params.
|
|
86
|
+
* @param params.password - Wallet password when onboarding is complete (step-up).
|
|
87
|
+
* @returns Resolves when enrollment completes.
|
|
115
88
|
*/
|
|
116
89
|
protectVaultKeyWithPasskey(params: {
|
|
117
90
|
registrationResponse: PasskeyRegistrationResponse;
|
|
118
91
|
authenticationResponse: PasskeyAuthenticationResponse;
|
|
119
|
-
|
|
92
|
+
password?: string;
|
|
120
93
|
}): Promise<void>;
|
|
121
94
|
/**
|
|
122
95
|
* Verifies an authentication assertion and returns the decrypted vault key.
|
|
123
96
|
*
|
|
97
|
+
* Prefer orchestrated methods ({@link unlockWithPasskey},
|
|
98
|
+
* {@link exportSeedPhraseWithPasskey}, {@link exportAccountsWithPasskey}) for product
|
|
99
|
+
* flows instead of calling KeyringController with the returned key manually.
|
|
100
|
+
*
|
|
124
101
|
* @param authenticationResponse - Result of `navigator.credentials.get()`.
|
|
125
102
|
* @returns The plaintext vault encryption key.
|
|
126
103
|
*/
|
|
127
104
|
retrieveVaultKeyWithPasskey(authenticationResponse: PasskeyAuthenticationResponse): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Unlocks the keyring using a passkey authentication assertion.
|
|
107
|
+
*
|
|
108
|
+
* @param authenticationResponse - Result of `navigator.credentials.get()`.
|
|
109
|
+
* @returns Resolves when the keyring is unlocked.
|
|
110
|
+
*/
|
|
111
|
+
unlockWithPasskey(authenticationResponse: PasskeyAuthenticationResponse): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Exports the seed phrase after passkey step-up authentication.
|
|
114
|
+
*
|
|
115
|
+
* @param authenticationResponse - Result of `navigator.credentials.get()`.
|
|
116
|
+
* @param keyringId - Optional keyring id; defaults to the primary HD keyring.
|
|
117
|
+
* @returns Raw seed phrase bytes from KeyringController.
|
|
118
|
+
*/
|
|
119
|
+
exportSeedPhraseWithPasskey(authenticationResponse: PasskeyAuthenticationResponse, keyringId?: string): Promise<Uint8Array>;
|
|
120
|
+
/**
|
|
121
|
+
* Exports private keys for the given addresses after passkey step-up authentication.
|
|
122
|
+
*
|
|
123
|
+
* @param authenticationResponse - Result of `navigator.credentials.get()`.
|
|
124
|
+
* @param addresses - Account addresses to export.
|
|
125
|
+
* @returns Private keys in the same order as `addresses`.
|
|
126
|
+
*/
|
|
127
|
+
exportAccountsWithPasskey(authenticationResponse: PasskeyAuthenticationResponse, addresses: string[]): Promise<string[]>;
|
|
128
128
|
/**
|
|
129
129
|
* Checks whether the given authentication assertion is valid for the enrolled passkey.
|
|
130
130
|
*
|
|
@@ -143,10 +143,15 @@ export declare class PasskeyController extends BaseController<typeof controllerN
|
|
|
143
143
|
* pass the same `authenticationResponse` you just verified (e.g. from
|
|
144
144
|
* {@link retrieveVaultKeyWithPasskey} / {@link verifyPasskeyAuthentication}).
|
|
145
145
|
*
|
|
146
|
+
* For password change with passkey step-up, prefer
|
|
147
|
+
* {@link changePasswordWithPasskeyVerification}, which orchestrates keyring export,
|
|
148
|
+
* `changePassword`, and re-wrap in one call.
|
|
149
|
+
*
|
|
146
150
|
* @param params - Re-wrap inputs.
|
|
147
151
|
* @param params.authenticationResponse - Used to derive the wrapping key.
|
|
148
152
|
* @param params.oldVaultKey - Expected current vault key.
|
|
149
153
|
* @param params.newVaultKey - New vault key to encrypt under the passkey.
|
|
154
|
+
* @returns Resolves when the passkey record is updated.
|
|
150
155
|
*/
|
|
151
156
|
renewVaultKeyProtection(params: {
|
|
152
157
|
authenticationResponse: PasskeyAuthenticationResponse;
|
|
@@ -154,12 +159,45 @@ export declare class PasskeyController extends BaseController<typeof controllerN
|
|
|
154
159
|
newVaultKey: string;
|
|
155
160
|
}): Promise<void>;
|
|
156
161
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
162
|
+
* Changes the wallet password after passkey step-up authentication.
|
|
163
|
+
*
|
|
164
|
+
* When `renewVaultKeyProtection` is `true` (default), re-wraps the vault key under the
|
|
165
|
+
* passkey after rotation. When `false`, removes the passkey instead.
|
|
166
|
+
*
|
|
167
|
+
* @param params - Change-password inputs.
|
|
168
|
+
* @param params.newPassword - New wallet password.
|
|
169
|
+
* @param params.authenticationResponse - Result of `navigator.credentials.get()`.
|
|
170
|
+
* @param params.options - Optional flow controls.
|
|
171
|
+
* @param params.options.renewVaultKeyProtection - Re-wrap vault key after password change.
|
|
172
|
+
* @returns Resolves when the password change completes.
|
|
173
|
+
*/
|
|
174
|
+
changePasswordWithPasskeyVerification(params: {
|
|
175
|
+
newPassword: string;
|
|
176
|
+
authenticationResponse: PasskeyAuthenticationResponse;
|
|
177
|
+
options?: {
|
|
178
|
+
renewVaultKeyProtection?: boolean;
|
|
179
|
+
};
|
|
180
|
+
}): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Removes the enrolled passkey after verifying a passkey authentication assertion.
|
|
183
|
+
*
|
|
184
|
+
* @param authenticationResponse - Result of `navigator.credentials.get()`.
|
|
185
|
+
* @returns Resolves when the passkey is removed.
|
|
186
|
+
*/
|
|
187
|
+
removePasskeyWithPasskeyVerification(authenticationResponse: PasskeyAuthenticationResponse): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Removes the enrolled passkey after verifying the wallet password.
|
|
190
|
+
*
|
|
191
|
+
* @param password - Wallet password for step-up verification.
|
|
192
|
+
* @returns Resolves when the passkey is removed.
|
|
159
193
|
*/
|
|
160
|
-
|
|
194
|
+
removePasskeyWithPasswordVerification(password: string): Promise<void>;
|
|
161
195
|
/**
|
|
162
196
|
* Resets state and clears in-flight registration/authentication ceremonies.
|
|
197
|
+
*
|
|
198
|
+
* For user-facing passkey removal with step-up, use
|
|
199
|
+
* {@link removePasskeyWithPasskeyVerification} or
|
|
200
|
+
* {@link removePasskeyWithPasswordVerification}.
|
|
163
201
|
*/
|
|
164
202
|
clearState(): void;
|
|
165
203
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasskeyController.d.mts","sourceRoot":"","sources":["../src/PasskeyController.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PasskeyController.d.mts","sourceRoot":"","sources":["../src/PasskeyController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,EACL,cAAc,EAGf,wBAAoB;AAIrB,OAAO,KAAK,EAEV,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EAKvB,oBAAgB;AASjB,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC5B,6BAAyB;AAI1B,YAAY,EACV,wBAAwB,EACxB,+BAA+B,EAC/B,uBAAuB,EACvB,+BAA+B,EAC/B,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,kCAAkC,GACnC,oBAAgB;AAEjB;;;;GAIG;AACH,wBAAgB,gCAAgC,IAAI,sBAAsB,CAEzE;AAaD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B;qCACJ,sBAAsB,KAAG,OAAO;CAElE,CAAC;AAqBF;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CACnD,OAAO,cAAc,EACrB,sBAAsB,EACtB,0BAA0B,CAC3B;;IAmBC;;;;;;;;;;;;;OAaG;gBACS,EACV,SAAS,EACT,K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