@account-kit/signer 4.36.1 → 4.38.0
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/dist/esm/client/base.d.ts +21 -4
- package/dist/esm/client/base.js +69 -1
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +4 -59
- package/dist/esm/client/index.js +27 -139
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +2 -2
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/client/base.d.ts +21 -4
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +4 -59
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +2 -2
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/client/base.ts +93 -8
- package/src/client/index.ts +35 -140
- package/src/client/types.ts +2 -2
- package/src/version.ts +1 -1
|
@@ -2,7 +2,7 @@ import { BaseError } from "@aa-sdk/core";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { AuthParams } from "../signer.js";
|
|
4
4
|
import { BaseSignerClient } from "./base.js";
|
|
5
|
-
import type { AlchemySignerClientEvents, AuthenticatingEventMetadata,
|
|
5
|
+
import type { AlchemySignerClientEvents, AuthenticatingEventMetadata, CredentialCreationOptionOverrides, EmailAuthParams, ExportWalletParams, OauthConfig, OtpParams, User, SubmitOtpCodeResponse, AuthLinkingPrompt, GetWebAuthnAttestationResult } from "./types.js";
|
|
6
6
|
export declare const AlchemySignerClientParamsSchema: z.ZodObject<{
|
|
7
7
|
connection: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
8
8
|
rpcUrl: z.ZodOptional<z.ZodNever>;
|
|
@@ -164,29 +164,6 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
164
164
|
* @param {string} params.rootOrgId The root organization ID
|
|
165
165
|
*/
|
|
166
166
|
constructor(params: AlchemySignerClientParams);
|
|
167
|
-
/**
|
|
168
|
-
* Authenticates the user by either email or passkey account creation flow. Emits events during the process.
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* ```ts
|
|
172
|
-
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
173
|
-
*
|
|
174
|
-
* const client = new AlchemySignerWebClient({
|
|
175
|
-
* connection: {
|
|
176
|
-
* apiKey: "your-api-key",
|
|
177
|
-
* },
|
|
178
|
-
* iframeConfig: {
|
|
179
|
-
* iframeContainerId: "signer-iframe-container",
|
|
180
|
-
* },
|
|
181
|
-
* });
|
|
182
|
-
*
|
|
183
|
-
* const account = await client.createAccount({ type: "email", email: "you@mail.com" });
|
|
184
|
-
* ```
|
|
185
|
-
*
|
|
186
|
-
* @param {CreateAccountParams} params The parameters for creating an account, including the type (email or passkey) and additional details.
|
|
187
|
-
* @returns {Promise<SignupResponse>} A promise that resolves with the response object containing the account creation result.
|
|
188
|
-
*/
|
|
189
|
-
createAccount: (params: CreateAccountParams) => Promise<import("./types.js").SignupResponse>;
|
|
190
167
|
/**
|
|
191
168
|
* Begin authenticating a user with their email and an expiration time for the authentication request. Initializes the iframe stamper to get the target public key.
|
|
192
169
|
* This method sends an email to the user to complete their login
|
|
@@ -278,29 +255,6 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
278
255
|
authenticatingType: AuthenticatingEventMetadata["type"];
|
|
279
256
|
idToken?: string;
|
|
280
257
|
}) => Promise<User>;
|
|
281
|
-
/**
|
|
282
|
-
* Asynchronously handles the authentication process using WebAuthn Stamper. If a user is provided, sets the user and returns it. Otherwise, retrieves the current user and initializes the WebAuthn stamper.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```ts
|
|
286
|
-
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
287
|
-
*
|
|
288
|
-
* const client = new AlchemySignerWebClient({
|
|
289
|
-
* connection: {
|
|
290
|
-
* apiKey: "your-api-key",
|
|
291
|
-
* },
|
|
292
|
-
* iframeConfig: {
|
|
293
|
-
* iframeContainerId: "signer-iframe-container",
|
|
294
|
-
* },
|
|
295
|
-
* });
|
|
296
|
-
*
|
|
297
|
-
* const account = await client.lookupUserWithPasskey();
|
|
298
|
-
* ```
|
|
299
|
-
*
|
|
300
|
-
* @param {User} [user] An optional user object to authenticate
|
|
301
|
-
* @returns {Promise<User>} A promise that resolves to the authenticated user object
|
|
302
|
-
*/
|
|
303
|
-
lookupUserWithPasskey: (user?: User | undefined) => Promise<User>;
|
|
304
258
|
/**
|
|
305
259
|
* Initiates the export of a wallet by creating an iframe stamper and calling the appropriate export function.
|
|
306
260
|
* The export can be based on a seed phrase or a private key.
|
|
@@ -432,21 +386,12 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
432
386
|
* @returns {Promise<string>} A promise that resolves with the target public key when the iframe stamper is successfully initialized, or throws an error if the target public key is not supported.
|
|
433
387
|
*/
|
|
434
388
|
targetPublicKey: () => Promise<string>;
|
|
435
|
-
private initIframeStamper;
|
|
436
|
-
private initWebauthnStamper;
|
|
437
389
|
protected getWebAuthnAttestation: (options?: CredentialCreationOptionOverrides, userDetails?: {
|
|
438
390
|
username: string;
|
|
439
|
-
}) => Promise<
|
|
440
|
-
challenge: ArrayBuffer;
|
|
441
|
-
authenticatorUserId: ArrayBuffer;
|
|
442
|
-
attestation: {
|
|
443
|
-
credentialId: string;
|
|
444
|
-
clientDataJson: string;
|
|
445
|
-
attestationObject: string;
|
|
446
|
-
transports: import("@turnkey/http").TurnkeyApiTypes["v1AuthenticatorTransport"][];
|
|
447
|
-
};
|
|
448
|
-
}>;
|
|
391
|
+
}) => Promise<GetWebAuthnAttestationResult>;
|
|
449
392
|
protected getOauthConfig: () => Promise<OauthConfig>;
|
|
393
|
+
protected initSessionStamper(): Promise<string>;
|
|
394
|
+
protected initWebauthnStamper(user?: User | undefined): Promise<void>;
|
|
450
395
|
}
|
|
451
396
|
/**
|
|
452
397
|
* This error is thrown when the OAuth flow is cancelled because the auth popup
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0B,MAAM,cAAc,CAAC;AAIjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0B,MAAM,cAAc,CAAC;AAIjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,iCAAiC,EACjC,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,IAAI,EACJ,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAMpB,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAEF;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,gBAAgB,CAAC,kBAAkB,CAAC;IAC9E,OAAO,CAAC,aAAa,CAAgB;IACrC,O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AAO,CAAC,IAAI,GAAG,iBAAiB,CAAC,CAqFlC;IAEF;;;;;;;;;;;;;;;;;;;;OAoBG;IACa,eAAe,QAAa,OAAO,CAAC,MAAM,CAAC,CAEzD;IAEF,UAAmB,sBAAsB,GACvC,UAAU,iCAAiC,EAC3C,cAAa;QAAE,QAAQ,EAAE,MAAM,CAAA;KAE9B,KACA,OAAO,CAAC,4BAA4B,CAAC,CAgDtC;IAEF,UAAmB,cAAc,QAAa,OAAO,CAAC,WAAW,CAAC,CAQhE;cAEuB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;cAUrC,mBAAmB,CAC1C,IAAI,GAAE,IAAI,GAAG,SAAqB,GACjC,OAAO,CAAC,IAAI,CAAC;CAajB;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IACvC,IAAI,SAAyB;IAEtC;;;OAGG;;CAIJ;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;IACpC,IAAI,SAAsB;CACpC"}
|
|
@@ -236,8 +236,8 @@ export type AlchemySignerClientEvents = {
|
|
|
236
236
|
export type AlchemySignerClientEvent = keyof AlchemySignerClientEvents;
|
|
237
237
|
export type GetWebAuthnAttestationResult = {
|
|
238
238
|
attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;
|
|
239
|
-
challenge: ArrayBuffer;
|
|
240
|
-
authenticatorUserId:
|
|
239
|
+
challenge: ArrayBuffer | string;
|
|
240
|
+
authenticatorUserId: BufferSource;
|
|
241
241
|
};
|
|
242
242
|
export type AuthLinkingPrompt = {
|
|
243
243
|
status: "ACCOUNT_LINKING_CONFIRMATION_REQUIRED";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,eAAe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AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,eAAe,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAChB;QACE,IAAI,EAAE,MAAM,CAAC;KACd,GACD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,KAAK,CAAA;CAAE,GACtC;IAAE,WAAW,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.38.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/signer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.38.0",
|
|
4
4
|
"description": "Core interfaces and clients for interfacing with the Alchemy Signer API",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"typescript-template": "*"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@aa-sdk/core": "^4.
|
|
52
|
-
"@account-kit/logging": "^4.
|
|
51
|
+
"@aa-sdk/core": "^4.38.0",
|
|
52
|
+
"@account-kit/logging": "^4.38.0",
|
|
53
53
|
"@solana/web3.js": "^1.98.0",
|
|
54
54
|
"@turnkey/http": "^2.22.0",
|
|
55
55
|
"@turnkey/iframe-stamper": "^1.0.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
76
76
|
},
|
|
77
77
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "1efa2bd289a23b74cd333579b32f8bb9b5cae0bb"
|
|
79
79
|
}
|
package/src/client/base.ts
CHANGED
|
@@ -36,6 +36,7 @@ import type {
|
|
|
36
36
|
ValidateMultiFactorsParams,
|
|
37
37
|
AuthLinkingPrompt,
|
|
38
38
|
AddOauthProviderParams,
|
|
39
|
+
CredentialCreationOptionOverrides,
|
|
39
40
|
} from "./types.js";
|
|
40
41
|
import { VERSION } from "../version.js";
|
|
41
42
|
|
|
@@ -142,11 +143,62 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Authenticates the user by either email or passkey account creation flow. Emits events during the process.
|
|
148
|
+
*
|
|
149
|
+
* @param {CreateAccountParams} params The parameters for creating an account, including the type (email or passkey) and additional details.
|
|
150
|
+
* @returns {Promise<SignupResponse>} A promise that resolves with the response object containing the account creation result.
|
|
151
|
+
*/
|
|
152
|
+
public async createAccount(
|
|
148
153
|
params: CreateAccountParams,
|
|
149
|
-
): Promise<SignupResponse
|
|
154
|
+
): Promise<SignupResponse> {
|
|
155
|
+
if (params.type === "email") {
|
|
156
|
+
this.eventEmitter.emit("authenticating", { type: "otp" });
|
|
157
|
+
const { email, emailMode, expirationSeconds } = params;
|
|
158
|
+
const publicKey = await this.initSessionStamper();
|
|
159
|
+
|
|
160
|
+
const response = await this.request("/v1/signup", {
|
|
161
|
+
email,
|
|
162
|
+
emailMode,
|
|
163
|
+
targetPublicKey: publicKey,
|
|
164
|
+
expirationSeconds,
|
|
165
|
+
redirectParams: params.redirectParams?.toString(),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return response;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.eventEmitter.emit("authenticating", { type: "passkey" });
|
|
172
|
+
// Passkey account creation flow
|
|
173
|
+
const { attestation, challenge } = await this.getWebAuthnAttestation(
|
|
174
|
+
params.creationOpts,
|
|
175
|
+
{ username: "email" in params ? params.email : params.username },
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
const result = await this.request("/v1/signup", {
|
|
179
|
+
passkey: {
|
|
180
|
+
challenge:
|
|
181
|
+
typeof challenge === "string"
|
|
182
|
+
? challenge
|
|
183
|
+
: base64UrlEncode(challenge),
|
|
184
|
+
attestation,
|
|
185
|
+
},
|
|
186
|
+
email: "email" in params ? params.email : undefined,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
this.user = {
|
|
190
|
+
orgId: result.orgId,
|
|
191
|
+
address: result.address!,
|
|
192
|
+
userId: result.userId!,
|
|
193
|
+
credentialId: attestation.credentialId,
|
|
194
|
+
};
|
|
195
|
+
this.initWebauthnStamper(this.user, params.creationOpts);
|
|
196
|
+
this.eventEmitter.emit("connectedPasskey", this.user);
|
|
197
|
+
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// #region ABSTRACT METHODS
|
|
150
202
|
|
|
151
203
|
public abstract initEmailAuth(
|
|
152
204
|
params: Omit<EmailAuthParams, "targetPublicKey">,
|
|
@@ -176,17 +228,25 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
176
228
|
|
|
177
229
|
public abstract exportWallet(params: TExportWalletParams): Promise<boolean>;
|
|
178
230
|
|
|
179
|
-
public abstract lookupUserWithPasskey(user?: User): Promise<User>;
|
|
180
|
-
|
|
181
231
|
public abstract targetPublicKey(): Promise<string>;
|
|
182
232
|
|
|
183
233
|
protected abstract getOauthConfig(): Promise<OauthConfig>;
|
|
184
234
|
|
|
185
235
|
protected abstract getWebAuthnAttestation(
|
|
186
|
-
options
|
|
236
|
+
options?: CredentialCreationOptionOverrides,
|
|
187
237
|
userDetails?: { username: string },
|
|
188
238
|
): Promise<GetWebAuthnAttestationResult>;
|
|
189
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Initializes the session stamper and returns its public key.
|
|
242
|
+
*/
|
|
243
|
+
protected abstract initSessionStamper(): Promise<string>;
|
|
244
|
+
|
|
245
|
+
protected abstract initWebauthnStamper(
|
|
246
|
+
user: User | undefined,
|
|
247
|
+
options: CredentialCreationOptionOverrides | undefined,
|
|
248
|
+
): Promise<void>;
|
|
249
|
+
|
|
190
250
|
// #endregion
|
|
191
251
|
|
|
192
252
|
// #region PUBLIC METHODS
|
|
@@ -231,7 +291,10 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
231
291
|
{
|
|
232
292
|
attestation,
|
|
233
293
|
authenticatorName: `passkey-${Date.now().toString()}`,
|
|
234
|
-
challenge:
|
|
294
|
+
challenge:
|
|
295
|
+
typeof challenge === "string"
|
|
296
|
+
? challenge
|
|
297
|
+
: base64UrlEncode(challenge),
|
|
235
298
|
},
|
|
236
299
|
],
|
|
237
300
|
},
|
|
@@ -246,6 +309,28 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
246
309
|
return authenticatorIds;
|
|
247
310
|
};
|
|
248
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Asynchronously handles the authentication process using WebAuthn Stamper. If a user is provided, sets the user and returns it. Otherwise, retrieves the current user and initializes the WebAuthn stamper.
|
|
314
|
+
*
|
|
315
|
+
* @param {User} [user] An optional user object to authenticate
|
|
316
|
+
* @returns {Promise<User>} A promise that resolves to the authenticated user object
|
|
317
|
+
*/
|
|
318
|
+
public lookupUserWithPasskey = async (user: User | undefined = undefined) => {
|
|
319
|
+
this.eventEmitter.emit("authenticating", { type: "passkey" });
|
|
320
|
+
await this.initWebauthnStamper(user, undefined);
|
|
321
|
+
if (user) {
|
|
322
|
+
this.user = user;
|
|
323
|
+
this.eventEmitter.emit("connectedPasskey", user);
|
|
324
|
+
return user;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const result = await this.whoami(this.rootOrg);
|
|
328
|
+
await this.initWebauthnStamper(result, undefined);
|
|
329
|
+
this.eventEmitter.emit("connectedPasskey", result);
|
|
330
|
+
|
|
331
|
+
return result;
|
|
332
|
+
};
|
|
333
|
+
|
|
249
334
|
/**
|
|
250
335
|
* Retrieves the status of the passkey for the current user. Requires the user to be authenticated.
|
|
251
336
|
*
|
package/src/client/index.ts
CHANGED
|
@@ -4,13 +4,11 @@ import { IframeStamper } from "@turnkey/iframe-stamper";
|
|
|
4
4
|
import { WebauthnStamper } from "@turnkey/webauthn-stamper";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import type { AuthParams } from "../signer.js";
|
|
7
|
-
import { base64UrlEncode } from "../utils/base64UrlEncode.js";
|
|
8
7
|
import { generateRandomBuffer } from "../utils/generateRandomBuffer.js";
|
|
9
8
|
import { BaseSignerClient } from "./base.js";
|
|
10
9
|
import type {
|
|
11
10
|
AlchemySignerClientEvents,
|
|
12
11
|
AuthenticatingEventMetadata,
|
|
13
|
-
CreateAccountParams,
|
|
14
12
|
CredentialCreationOptionOverrides,
|
|
15
13
|
EmailAuthParams,
|
|
16
14
|
ExportWalletParams,
|
|
@@ -19,6 +17,7 @@ import type {
|
|
|
19
17
|
User,
|
|
20
18
|
SubmitOtpCodeResponse,
|
|
21
19
|
AuthLinkingPrompt,
|
|
20
|
+
GetWebAuthnAttestationResult,
|
|
22
21
|
} from "./types.js";
|
|
23
22
|
import { MfaRequiredError } from "../errors.js";
|
|
24
23
|
import { parseMfaError } from "../utils/parseMfaError.js";
|
|
@@ -106,72 +105,6 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
106
105
|
this.oauthCallbackUrl = oauthCallbackUrl;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
/**
|
|
110
|
-
* Authenticates the user by either email or passkey account creation flow. Emits events during the process.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```ts
|
|
114
|
-
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
115
|
-
*
|
|
116
|
-
* const client = new AlchemySignerWebClient({
|
|
117
|
-
* connection: {
|
|
118
|
-
* apiKey: "your-api-key",
|
|
119
|
-
* },
|
|
120
|
-
* iframeConfig: {
|
|
121
|
-
* iframeContainerId: "signer-iframe-container",
|
|
122
|
-
* },
|
|
123
|
-
* });
|
|
124
|
-
*
|
|
125
|
-
* const account = await client.createAccount({ type: "email", email: "you@mail.com" });
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @param {CreateAccountParams} params The parameters for creating an account, including the type (email or passkey) and additional details.
|
|
129
|
-
* @returns {Promise<SignupResponse>} A promise that resolves with the response object containing the account creation result.
|
|
130
|
-
*/
|
|
131
|
-
public override createAccount = async (params: CreateAccountParams) => {
|
|
132
|
-
if (params.type === "email") {
|
|
133
|
-
this.eventEmitter.emit("authenticating", { type: "otp" });
|
|
134
|
-
const { email, emailMode, expirationSeconds } = params;
|
|
135
|
-
const publicKey = await this.initIframeStamper();
|
|
136
|
-
|
|
137
|
-
const response = await this.request("/v1/signup", {
|
|
138
|
-
email,
|
|
139
|
-
emailMode,
|
|
140
|
-
targetPublicKey: publicKey,
|
|
141
|
-
expirationSeconds,
|
|
142
|
-
redirectParams: params.redirectParams?.toString(),
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
return response;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
this.eventEmitter.emit("authenticating", { type: "passkey" });
|
|
149
|
-
// Passkey account creation flow
|
|
150
|
-
const { attestation, challenge } = await this.getWebAuthnAttestation(
|
|
151
|
-
params.creationOpts,
|
|
152
|
-
{ username: "email" in params ? params.email : params.username },
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
const result = await this.request("/v1/signup", {
|
|
156
|
-
passkey: {
|
|
157
|
-
challenge: base64UrlEncode(challenge),
|
|
158
|
-
attestation,
|
|
159
|
-
},
|
|
160
|
-
email: "email" in params ? params.email : undefined,
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
this.user = {
|
|
164
|
-
orgId: result.orgId,
|
|
165
|
-
address: result.address!,
|
|
166
|
-
userId: result.userId!,
|
|
167
|
-
credentialId: attestation.credentialId,
|
|
168
|
-
};
|
|
169
|
-
this.initWebauthnStamper(this.user);
|
|
170
|
-
this.eventEmitter.emit("connectedPasskey", this.user);
|
|
171
|
-
|
|
172
|
-
return result;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
108
|
/**
|
|
176
109
|
* Begin authenticating a user with their email and an expiration time for the authentication request. Initializes the iframe stamper to get the target public key.
|
|
177
110
|
* This method sends an email to the user to complete their login
|
|
@@ -200,7 +133,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
200
133
|
) => {
|
|
201
134
|
this.eventEmitter.emit("authenticating", { type: "otp" });
|
|
202
135
|
const { email, emailMode, expirationSeconds } = params;
|
|
203
|
-
const publicKey = await this.
|
|
136
|
+
const publicKey = await this.initSessionStamper();
|
|
204
137
|
|
|
205
138
|
try {
|
|
206
139
|
return await this.request("/v1/auth", {
|
|
@@ -253,7 +186,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
253
186
|
args: Omit<OtpParams, "targetPublicKey">,
|
|
254
187
|
): Promise<SubmitOtpCodeResponse> {
|
|
255
188
|
this.eventEmitter.emit("authenticating", { type: "otpVerify" });
|
|
256
|
-
const targetPublicKey = await this.
|
|
189
|
+
const targetPublicKey = await this.initSessionStamper();
|
|
257
190
|
const response = await this.request("/v1/otp", {
|
|
258
191
|
...args,
|
|
259
192
|
targetPublicKey,
|
|
@@ -328,7 +261,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
328
261
|
idToken?: string;
|
|
329
262
|
}): Promise<User> => {
|
|
330
263
|
this.eventEmitter.emit("authenticating", { type: authenticatingType });
|
|
331
|
-
await this.
|
|
264
|
+
await this.initSessionStamper();
|
|
332
265
|
|
|
333
266
|
const result = await this.iframeStamper.injectCredentialBundle(bundle);
|
|
334
267
|
|
|
@@ -343,46 +276,6 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
343
276
|
return user;
|
|
344
277
|
};
|
|
345
278
|
|
|
346
|
-
/**
|
|
347
|
-
* Asynchronously handles the authentication process using WebAuthn Stamper. If a user is provided, sets the user and returns it. Otherwise, retrieves the current user and initializes the WebAuthn stamper.
|
|
348
|
-
*
|
|
349
|
-
* @example
|
|
350
|
-
* ```ts
|
|
351
|
-
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
352
|
-
*
|
|
353
|
-
* const client = new AlchemySignerWebClient({
|
|
354
|
-
* connection: {
|
|
355
|
-
* apiKey: "your-api-key",
|
|
356
|
-
* },
|
|
357
|
-
* iframeConfig: {
|
|
358
|
-
* iframeContainerId: "signer-iframe-container",
|
|
359
|
-
* },
|
|
360
|
-
* });
|
|
361
|
-
*
|
|
362
|
-
* const account = await client.lookupUserWithPasskey();
|
|
363
|
-
* ```
|
|
364
|
-
*
|
|
365
|
-
* @param {User} [user] An optional user object to authenticate
|
|
366
|
-
* @returns {Promise<User>} A promise that resolves to the authenticated user object
|
|
367
|
-
*/
|
|
368
|
-
public override lookupUserWithPasskey = async (
|
|
369
|
-
user: User | undefined = undefined,
|
|
370
|
-
) => {
|
|
371
|
-
this.eventEmitter.emit("authenticating", { type: "passkey" });
|
|
372
|
-
await this.initWebauthnStamper(user);
|
|
373
|
-
if (user) {
|
|
374
|
-
this.user = user;
|
|
375
|
-
this.eventEmitter.emit("connectedPasskey", user);
|
|
376
|
-
return user;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const result = await this.whoami(this.rootOrg);
|
|
380
|
-
await this.initWebauthnStamper(result);
|
|
381
|
-
this.eventEmitter.emit("connectedPasskey", result);
|
|
382
|
-
|
|
383
|
-
return result;
|
|
384
|
-
};
|
|
385
|
-
|
|
386
279
|
/**
|
|
387
280
|
* Initiates the export of a wallet by creating an iframe stamper and calling the appropriate export function.
|
|
388
281
|
* The export can be based on a seed phrase or a private key.
|
|
@@ -489,7 +382,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
489
382
|
public override oauthWithRedirect = async (
|
|
490
383
|
args: Extract<AuthParams, { type: "oauth"; mode: "redirect" }>,
|
|
491
384
|
): Promise<never> => {
|
|
492
|
-
const turnkeyPublicKey = await this.
|
|
385
|
+
const turnkeyPublicKey = await this.initSessionStamper();
|
|
493
386
|
|
|
494
387
|
const oauthParams = args;
|
|
495
388
|
const providerUrl = await this.getOauthProviderUrl({
|
|
@@ -533,7 +426,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
533
426
|
public override oauthWithPopup = async (
|
|
534
427
|
args: Extract<AuthParams, { type: "oauth"; mode: "popup" }>,
|
|
535
428
|
): Promise<User | AuthLinkingPrompt> => {
|
|
536
|
-
const turnkeyPublicKey = await this.
|
|
429
|
+
const turnkeyPublicKey = await this.initSessionStamper();
|
|
537
430
|
const oauthParams = args;
|
|
538
431
|
const providerUrl = await this.getOauthProviderUrl({
|
|
539
432
|
oauthParams,
|
|
@@ -641,31 +534,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
641
534
|
* @returns {Promise<string>} A promise that resolves with the target public key when the iframe stamper is successfully initialized, or throws an error if the target public key is not supported.
|
|
642
535
|
*/
|
|
643
536
|
public override targetPublicKey = async (): Promise<string> => {
|
|
644
|
-
return this.
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
private initIframeStamper = async () => {
|
|
648
|
-
if (!this.iframeStamper.publicKey()) {
|
|
649
|
-
await this.iframeStamper.init();
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
this.setStamper(this.iframeStamper);
|
|
653
|
-
|
|
654
|
-
return this.iframeStamper.publicKey()!;
|
|
655
|
-
};
|
|
656
|
-
|
|
657
|
-
private initWebauthnStamper = async (user: User | undefined = this.user) => {
|
|
658
|
-
this.setStamper(this.webauthnStamper);
|
|
659
|
-
if (user && user.credentialId) {
|
|
660
|
-
// The goal here is to allow us to cache the allowed credential, but this doesn't work with hybrid transport :(
|
|
661
|
-
this.webauthnStamper.allowCredentials = [
|
|
662
|
-
{
|
|
663
|
-
id: Buffer.from(user.credentialId, "base64"),
|
|
664
|
-
type: "public-key",
|
|
665
|
-
transports: ["internal", "hybrid"],
|
|
666
|
-
},
|
|
667
|
-
];
|
|
668
|
-
}
|
|
537
|
+
return this.initSessionStamper();
|
|
669
538
|
};
|
|
670
539
|
|
|
671
540
|
protected override getWebAuthnAttestation = async (
|
|
@@ -673,7 +542,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
673
542
|
userDetails: { username: string } = {
|
|
674
543
|
username: this.user?.email ?? "anonymous",
|
|
675
544
|
},
|
|
676
|
-
) => {
|
|
545
|
+
): Promise<GetWebAuthnAttestationResult> => {
|
|
677
546
|
const challenge = generateRandomBuffer();
|
|
678
547
|
const authenticatorUserId = generateRandomBuffer();
|
|
679
548
|
|
|
@@ -725,13 +594,39 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
725
594
|
|
|
726
595
|
protected override getOauthConfig = async (): Promise<OauthConfig> => {
|
|
727
596
|
const currentStamper = this.turnkeyClient.stamper;
|
|
728
|
-
const publicKey = await this.
|
|
597
|
+
const publicKey = await this.initSessionStamper();
|
|
729
598
|
|
|
730
599
|
// swap the stamper back in case the user logged in with a different stamper (passkeys)
|
|
731
600
|
this.setStamper(currentStamper);
|
|
732
601
|
const nonce = this.getOauthNonce(publicKey);
|
|
733
602
|
return this.request("/v1/prepare-oauth", { nonce });
|
|
734
603
|
};
|
|
604
|
+
|
|
605
|
+
protected override async initSessionStamper(): Promise<string> {
|
|
606
|
+
if (!this.iframeStamper.publicKey()) {
|
|
607
|
+
await this.iframeStamper.init();
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
this.setStamper(this.iframeStamper);
|
|
611
|
+
|
|
612
|
+
return this.iframeStamper.publicKey()!;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
protected override async initWebauthnStamper(
|
|
616
|
+
user: User | undefined = this.user,
|
|
617
|
+
): Promise<void> {
|
|
618
|
+
this.setStamper(this.webauthnStamper);
|
|
619
|
+
if (user && user.credentialId) {
|
|
620
|
+
// The goal here is to allow us to cache the allowed credential, but this doesn't work with hybrid transport :(
|
|
621
|
+
this.webauthnStamper.allowCredentials = [
|
|
622
|
+
{
|
|
623
|
+
id: Buffer.from(user.credentialId, "base64"),
|
|
624
|
+
type: "public-key",
|
|
625
|
+
transports: ["internal", "hybrid"],
|
|
626
|
+
},
|
|
627
|
+
];
|
|
628
|
+
}
|
|
629
|
+
}
|
|
735
630
|
}
|
|
736
631
|
|
|
737
632
|
/**
|
package/src/client/types.ts
CHANGED
|
@@ -265,8 +265,8 @@ export type AlchemySignerClientEvent = keyof AlchemySignerClientEvents;
|
|
|
265
265
|
|
|
266
266
|
export type GetWebAuthnAttestationResult = {
|
|
267
267
|
attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;
|
|
268
|
-
challenge: ArrayBuffer;
|
|
269
|
-
authenticatorUserId:
|
|
268
|
+
challenge: ArrayBuffer | string;
|
|
269
|
+
authenticatorUserId: BufferSource;
|
|
270
270
|
};
|
|
271
271
|
|
|
272
272
|
export type AuthLinkingPrompt = {
|
package/src/version.ts
CHANGED