@account-kit/signer 4.0.0-beta.3 → 4.0.0-beta.5
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/base.d.ts +33 -1
- package/dist/esm/base.js +81 -7
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +28 -5
- package/dist/esm/client/base.js +25 -1
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +78 -5
- package/dist/esm/client/index.js +211 -6
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +25 -0
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/oauth.d.ts +18 -0
- package/dist/esm/oauth.js +29 -0
- package/dist/esm/oauth.js.map +1 -0
- package/dist/esm/session/manager.d.ts +3 -2
- package/dist/esm/session/manager.js +28 -15
- package/dist/esm/session/manager.js.map +1 -1
- package/dist/esm/session/types.d.ts +1 -1
- package/dist/esm/session/types.js.map +1 -1
- package/dist/esm/signer.d.ts +39 -7
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/utils/typeAssertions.d.ts +1 -0
- package/dist/esm/utils/typeAssertions.js +4 -0
- package/dist/esm/utils/typeAssertions.js.map +1 -0
- 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/base.d.ts +33 -1
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +28 -5
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +78 -5
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +25 -0
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/oauth.d.ts +19 -0
- package/dist/types/oauth.d.ts.map +1 -0
- package/dist/types/session/manager.d.ts +3 -2
- package/dist/types/session/manager.d.ts.map +1 -1
- package/dist/types/session/types.d.ts +1 -1
- package/dist/types/session/types.d.ts.map +1 -1
- package/dist/types/signer.d.ts +39 -7
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/utils/typeAssertions.d.ts +2 -0
- package/dist/types/utils/typeAssertions.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/base.ts +80 -10
- package/src/client/base.ts +31 -3
- package/src/client/index.ts +244 -12
- package/src/client/types.ts +26 -0
- package/src/oauth.ts +38 -0
- package/src/session/manager.ts +45 -19
- package/src/session/types.ts +1 -1
- package/src/signer.ts +15 -1
- package/src/utils/typeAssertions.ts +3 -0
- package/src/version.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { BaseSignerClient } from "./base.js";
|
|
3
|
-
import type { CreateAccountParams, CredentialCreationOptionOverrides, EmailAuthParams, ExportWalletParams, User } from "./types.js";
|
|
3
|
+
import type { AlchemySignerClientEvents, CreateAccountParams, CredentialCreationOptionOverrides, EmailAuthParams, ExportWalletParams, OauthConfig, User } from "./types.js";
|
|
4
|
+
import type { AuthParams } from "../signer.js";
|
|
4
5
|
export declare const AlchemySignerClientParamsSchema: z.ZodObject<{
|
|
5
6
|
connection: z.ZodUnion<[z.ZodObject<{
|
|
6
7
|
rpcUrl: z.ZodOptional<z.ZodNever>;
|
|
@@ -63,6 +64,8 @@ export declare const AlchemySignerClientParamsSchema: z.ZodObject<{
|
|
|
63
64
|
}>;
|
|
64
65
|
rpId: z.ZodOptional<z.ZodString>;
|
|
65
66
|
rootOrgId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
67
|
+
oauthCallbackUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
68
|
+
enablePopupOauth: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
66
69
|
}, "strip", z.ZodTypeAny, {
|
|
67
70
|
connection: {
|
|
68
71
|
apiKey: string;
|
|
@@ -81,11 +84,13 @@ export declare const AlchemySignerClientParamsSchema: z.ZodObject<{
|
|
|
81
84
|
jwt: string;
|
|
82
85
|
apiKey?: undefined;
|
|
83
86
|
};
|
|
84
|
-
rootOrgId: string;
|
|
85
87
|
iframeConfig: {
|
|
86
88
|
iframeElementId: string;
|
|
87
89
|
iframeContainerId: string;
|
|
88
90
|
};
|
|
91
|
+
rootOrgId: string;
|
|
92
|
+
oauthCallbackUrl: string;
|
|
93
|
+
enablePopupOauth: boolean;
|
|
89
94
|
rpId?: string | undefined;
|
|
90
95
|
}, {
|
|
91
96
|
connection: {
|
|
@@ -111,6 +116,8 @@ export declare const AlchemySignerClientParamsSchema: z.ZodObject<{
|
|
|
111
116
|
};
|
|
112
117
|
rpId?: string | undefined;
|
|
113
118
|
rootOrgId?: string | undefined;
|
|
119
|
+
oauthCallbackUrl?: string | undefined;
|
|
120
|
+
enablePopupOauth?: boolean | undefined;
|
|
114
121
|
}>;
|
|
115
122
|
export type AlchemySignerClientParams = z.input<typeof AlchemySignerClientParamsSchema>;
|
|
116
123
|
/**
|
|
@@ -120,6 +127,7 @@ export type AlchemySignerClientParams = z.input<typeof AlchemySignerClientParams
|
|
|
120
127
|
export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams> {
|
|
121
128
|
private iframeStamper;
|
|
122
129
|
private webauthnStamper;
|
|
130
|
+
oauthCallbackUrl: string;
|
|
123
131
|
iframeContainerId: string;
|
|
124
132
|
/**
|
|
125
133
|
* Initializes a new instance with the given parameters, setting up the connection, iframe configuration, and WebAuthn stamper.
|
|
@@ -195,7 +203,7 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
195
203
|
orgId: string;
|
|
196
204
|
}>;
|
|
197
205
|
/**
|
|
198
|
-
* Completes
|
|
206
|
+
* Completes auth for the user by injecting a credential bundle and retrieving the user information based on the provided organization ID. Emits events during the process.
|
|
199
207
|
*
|
|
200
208
|
* @example
|
|
201
209
|
* ```ts
|
|
@@ -210,15 +218,16 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
210
218
|
* },
|
|
211
219
|
* });
|
|
212
220
|
*
|
|
213
|
-
* const account = await client.
|
|
221
|
+
* const account = await client.completeAuthWithBundle({ orgId: "user-org-id", bundle: "bundle-from-email", connectedEventName: "connectedEmail" });
|
|
214
222
|
* ```
|
|
215
223
|
*
|
|
216
224
|
* @param {{ bundle: string; orgId: string }} config The configuration object for the authentication function containing the credential bundle to inject and the organization id associated with the user
|
|
217
225
|
* @returns {Promise<User>} A promise that resolves to the authenticated user information
|
|
218
226
|
*/
|
|
219
|
-
|
|
227
|
+
completeAuthWithBundle: ({ bundle, orgId, connectedEventName, }: {
|
|
220
228
|
bundle: string;
|
|
221
229
|
orgId: string;
|
|
230
|
+
connectedEventName: keyof AlchemySignerClientEvents;
|
|
222
231
|
}) => Promise<User>;
|
|
223
232
|
/**
|
|
224
233
|
* 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.
|
|
@@ -291,6 +300,68 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
291
300
|
* ```
|
|
292
301
|
*/
|
|
293
302
|
disconnect: () => Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Redirects the user to the OAuth provider URL based on the provided arguments. This function will always reject after 1 second if the redirection does not occur.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
309
|
+
*
|
|
310
|
+
* const client = new AlchemySignerWebClient({
|
|
311
|
+
* connection: {
|
|
312
|
+
* apiKey: "your-api-key",
|
|
313
|
+
* },
|
|
314
|
+
* iframeConfig: {
|
|
315
|
+
* iframeContainerId: "signer-iframe-container",
|
|
316
|
+
* },
|
|
317
|
+
* });
|
|
318
|
+
*
|
|
319
|
+
* await client.oauthWithRedirect({
|
|
320
|
+
* type: "oauth",
|
|
321
|
+
* authProviderId: "google",
|
|
322
|
+
* mode: "redirect",
|
|
323
|
+
* redirectUrl: "/",
|
|
324
|
+
* });
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* @param {Extract<AuthParams, { type: "oauth"; mode: "redirect" }>} args The arguments required to obtain the OAuth provider URL
|
|
328
|
+
* @returns {Promise<never>} A promise that will never resolve, only reject if the redirection fails
|
|
329
|
+
*/
|
|
330
|
+
oauthWithRedirect: (args: Extract<AuthParams, {
|
|
331
|
+
type: "oauth";
|
|
332
|
+
mode: "redirect";
|
|
333
|
+
}>) => Promise<never>;
|
|
334
|
+
/**
|
|
335
|
+
* Initiates an OAuth authentication flow in a popup window and returns the authenticated user.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
340
|
+
*
|
|
341
|
+
* const client = new AlchemySignerWebClient({
|
|
342
|
+
* connection: {
|
|
343
|
+
* apiKey: "your-api-key",
|
|
344
|
+
* },
|
|
345
|
+
* iframeConfig: {
|
|
346
|
+
* iframeContainerId: "signer-iframe-container",
|
|
347
|
+
* },
|
|
348
|
+
* });
|
|
349
|
+
*
|
|
350
|
+
* const user = await client.oauthWithPopup({
|
|
351
|
+
* type: "oauth",
|
|
352
|
+
* authProviderId: "google",
|
|
353
|
+
* mode: "popup"
|
|
354
|
+
* });
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* @param {Extract<AuthParams, { type: "oauth"; mode: "popup" }>} args The authentication parameters specifying OAuth type and popup mode
|
|
358
|
+
* @returns {Promise<User>} A promise that resolves to a `User` object containing the authenticated user information
|
|
359
|
+
*/
|
|
360
|
+
oauthWithPopup: (args: Extract<AuthParams, {
|
|
361
|
+
type: "oauth";
|
|
362
|
+
mode: "popup";
|
|
363
|
+
}>) => Promise<User>;
|
|
364
|
+
private getOauthProviderUrl;
|
|
294
365
|
private initIframeStamper;
|
|
295
366
|
private initWebauthnStamper;
|
|
296
367
|
protected getWebAuthnAttestation: (options?: CredentialCreationOptionOverrides, userDetails?: {
|
|
@@ -305,5 +376,7 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
305
376
|
transports: ("AUTHENTICATOR_TRANSPORT_BLE" | "AUTHENTICATOR_TRANSPORT_INTERNAL" | "AUTHENTICATOR_TRANSPORT_NFC" | "AUTHENTICATOR_TRANSPORT_USB" | "AUTHENTICATOR_TRANSPORT_HYBRID")[];
|
|
306
377
|
};
|
|
307
378
|
}>;
|
|
379
|
+
protected getOauthConfig: () => Promise<OauthConfig>;
|
|
380
|
+
private getOauthConfigForMode;
|
|
308
381
|
}
|
|
309
382
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EACV,mBAAmB,EACnB,iCAAiC,EACjC,eAAe,EACf,kBAAkB,EAClB,IAAI,EACL,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,+BAA+B
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,iCAAiC,EACjC,eAAe,EACf,kBAAkB,EAClB,WAAW,EAEX,IAAI,EACL,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AAI1D,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AO,CAAA;KAAE,CAAC,KAC1D,QAAQ,IAAI,CAAC,CAqCd;IAEF,OAAO,CAAC,mBAAmB,CAsEzB;IAEF,OAAO,CAAC,iBAAiB,CAQvB;IAEF,OAAO,CAAC,mBAAmB,CAYzB;IAEF,UAAmB,sBAAsB,aAC7B,iCAAiC,gBAC9B;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE;;;;;;;;;OAmDjC;IAEF,UAAmB,cAAc,QAAa,QAAQ,WAAW,CAAC,CAIhE;IAEF,OAAO,CAAC,qBAAqB,CAY3B;CACH"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address } from "@aa-sdk/core";
|
|
2
2
|
import type { TSignedRequest, getWebAuthnAttestation } from "@turnkey/http";
|
|
3
3
|
import type { Hex } from "viem";
|
|
4
|
+
import type { AuthParams } from "../signer";
|
|
4
5
|
export type CredentialCreationOptionOverrides = {
|
|
5
6
|
publicKey?: Partial<CredentialCreationOptions["publicKey"]>;
|
|
6
7
|
} & Pick<CredentialCreationOptions, "signal">;
|
|
@@ -35,11 +36,27 @@ export type EmailAuthParams = {
|
|
|
35
36
|
targetPublicKey: string;
|
|
36
37
|
redirectParams?: URLSearchParams;
|
|
37
38
|
};
|
|
39
|
+
export type OauthParams = Extract<AuthParams, {
|
|
40
|
+
type: "oauth";
|
|
41
|
+
}> & {
|
|
42
|
+
expirationSeconds?: number;
|
|
43
|
+
};
|
|
38
44
|
export type SignupResponse = {
|
|
39
45
|
orgId: string;
|
|
40
46
|
userId?: string;
|
|
41
47
|
address?: Address;
|
|
42
48
|
};
|
|
49
|
+
export type OauthConfig = {
|
|
50
|
+
codeChallenge: string;
|
|
51
|
+
requestKey: string;
|
|
52
|
+
authProviders: AuthProviderConfig[];
|
|
53
|
+
};
|
|
54
|
+
export type AuthProviderConfig = {
|
|
55
|
+
id: string;
|
|
56
|
+
isCustomProvider?: boolean;
|
|
57
|
+
clientId: string;
|
|
58
|
+
authEndpoint: string;
|
|
59
|
+
};
|
|
43
60
|
export type SignerRoutes = SignerEndpoints[number]["Route"];
|
|
44
61
|
export type SignerBody<T extends SignerRoutes> = Extract<SignerEndpoints[number], {
|
|
45
62
|
Route: T;
|
|
@@ -93,6 +110,13 @@ export type SignerEndpoints = [
|
|
|
93
110
|
Response: {
|
|
94
111
|
signature: Hex;
|
|
95
112
|
};
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
Route: "/v1/prepare-oauth";
|
|
116
|
+
Body: {
|
|
117
|
+
nonce: string;
|
|
118
|
+
};
|
|
119
|
+
Response: OauthConfig;
|
|
96
120
|
}
|
|
97
121
|
];
|
|
98
122
|
export type AlchemySignerClientEvents = {
|
|
@@ -100,6 +124,7 @@ export type AlchemySignerClientEvents = {
|
|
|
100
124
|
authenticating(): void;
|
|
101
125
|
connectedEmail(user: User, bundle: string): void;
|
|
102
126
|
connectedPasskey(user: User): void;
|
|
127
|
+
connectedOauth(user: User, bundle: string): void;
|
|
103
128
|
disconnected(): void;
|
|
104
129
|
};
|
|
105
130
|
export type AlchemySignerClientEvent = keyof AlchemySignerClientEvents;
|
|
@@ -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,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;
|
|
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,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EA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G,MAAM,yBAAyB,CAAC;AAEvE,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC;IAChE,SAAS,EAAE,WAAW,CAAC;IACvB,mBAAmB,EAAE,WAAW,CAAC;CAClC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turnkey requires the nonce in the id token to be in this format.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} turnkeyPublicKey key from a Turnkey iframe
|
|
5
|
+
* @returns {string} nonce to be used in OIDC
|
|
6
|
+
*/
|
|
7
|
+
export declare function getOauthNonce(turnkeyPublicKey: string): string;
|
|
8
|
+
export type ScopeAndClaims = {
|
|
9
|
+
scope: string;
|
|
10
|
+
claims?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns the default scope and claims when using a known auth provider
|
|
14
|
+
*
|
|
15
|
+
* @param {string} knownAuthProviderId id of a known auth provider, e.g. "google"
|
|
16
|
+
* @returns {ScopeAndClaims | undefined} default scope and claims
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDefaultScopeAndClaims(knownAuthProviderId: string): ScopeAndClaims | undefined;
|
|
19
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/oauth.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAYF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,mBAAmB,EAAE,MAAM,GAC1B,cAAc,GAAG,SAAS,CAE5B"}
|
|
@@ -10,14 +10,14 @@ export declare const SessionManagerParamsSchema: z.ZodObject<{
|
|
|
10
10
|
expirationTimeMs: z.ZodDefault<z.ZodNumber>;
|
|
11
11
|
client: z.ZodType<BaseSignerClient<unknown>, z.ZodTypeDef, BaseSignerClient<unknown>>;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
storage: (Storage | "localStorage" | "sessionStorage") & (Storage | "localStorage" | "sessionStorage" | undefined);
|
|
13
14
|
sessionKey: string;
|
|
14
|
-
storage: ("localStorage" | "sessionStorage" | Storage) & ("localStorage" | "sessionStorage" | Storage | undefined);
|
|
15
15
|
expirationTimeMs: number;
|
|
16
16
|
client: BaseSignerClient<unknown>;
|
|
17
17
|
}, {
|
|
18
18
|
client: BaseSignerClient<unknown>;
|
|
19
19
|
sessionKey?: string | undefined;
|
|
20
|
-
storage?: "localStorage" | "sessionStorage" |
|
|
20
|
+
storage?: Storage | "localStorage" | "sessionStorage" | undefined;
|
|
21
21
|
expirationTimeMs?: number | undefined;
|
|
22
22
|
}>;
|
|
23
23
|
export type SessionManagerParams = z.input<typeof SessionManagerParamsSchema>;
|
|
@@ -42,5 +42,6 @@ export declare class SessionManager {
|
|
|
42
42
|
initialize(): void;
|
|
43
43
|
private getInitialState;
|
|
44
44
|
private registerEventListeners;
|
|
45
|
+
private setSessionWithUserAndBundle;
|
|
45
46
|
}
|
|
46
47
|
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/session/manager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAW,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/session/manager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAW,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG7D,eAAO,MAAM,kBAAkB,QAAiB,CAAC;AAEjD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;EAarC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAW9E,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,YAAY,CAAqC;IACzD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,OAAO,CAAC,KAAK,CAAQ;gBAET,MAAM,EAAE,oBAAoB;IA8BjC,cAAc,QAAa,QAAQ,IAAI,GAAG,IAAI,CAAC,CA4CpD;IAEK,YAAY,aAEjB;IAEK,mBAAmB,YAAa;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,UAMtD;IAEK,mBAAmB,QAAO;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CASvD;IAEF,EAAE,uIAOA;IAEF,OAAO,CAAC,UAAU,CAoBhB;IAEF,OAAO,CAAC,UAAU,CAWhB;IAEK,UAAU;IAYjB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,sBAAsB,CAwC5B;IAEF,OAAO,CAAC,2BAA2B,CAsBjC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,OAAO,GACf;IACE,IAAI,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,OAAO,GACf;IACE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC;CACZ,GACD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,YAAY,IAAI,IAAI,CAAC;IACrB,WAAW,IAAI,IAAI,CAAC;CACrB,CAAC"}
|
package/dist/types/signer.d.ts
CHANGED
|
@@ -22,6 +22,24 @@ export type AuthParams = {
|
|
|
22
22
|
createNew: true;
|
|
23
23
|
username: string;
|
|
24
24
|
creationOpts?: CredentialCreationOptionOverrides;
|
|
25
|
+
} | ({
|
|
26
|
+
type: "oauth";
|
|
27
|
+
authProviderId: string;
|
|
28
|
+
isCustomProvider?: boolean;
|
|
29
|
+
scope?: string;
|
|
30
|
+
claims?: string;
|
|
31
|
+
} & RedirectConfig) | {
|
|
32
|
+
type: "oauthReturn";
|
|
33
|
+
bundle: string;
|
|
34
|
+
orgId: string;
|
|
35
|
+
};
|
|
36
|
+
export type OauthMode = "redirect" | "popup";
|
|
37
|
+
export type RedirectConfig = {
|
|
38
|
+
mode: "redirect";
|
|
39
|
+
redirectUrl: string;
|
|
40
|
+
} | {
|
|
41
|
+
mode: "popup";
|
|
42
|
+
redirectUrl?: never;
|
|
25
43
|
};
|
|
26
44
|
export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
27
45
|
client: z.ZodUnion<[z.ZodType<AlchemySignerWebClient, z.ZodTypeDef, AlchemySignerWebClient>, z.ZodObject<{
|
|
@@ -86,6 +104,8 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
86
104
|
}>;
|
|
87
105
|
rpId: z.ZodOptional<z.ZodString>;
|
|
88
106
|
rootOrgId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
107
|
+
oauthCallbackUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
108
|
+
enablePopupOauth: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
89
109
|
}, "strip", z.ZodTypeAny, {
|
|
90
110
|
connection: {
|
|
91
111
|
apiKey: string;
|
|
@@ -104,11 +124,13 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
104
124
|
jwt: string;
|
|
105
125
|
apiKey?: undefined;
|
|
106
126
|
};
|
|
107
|
-
rootOrgId: string;
|
|
108
127
|
iframeConfig: {
|
|
109
128
|
iframeElementId: string;
|
|
110
129
|
iframeContainerId: string;
|
|
111
130
|
};
|
|
131
|
+
rootOrgId: string;
|
|
132
|
+
oauthCallbackUrl: string;
|
|
133
|
+
enablePopupOauth: boolean;
|
|
112
134
|
rpId?: string | undefined;
|
|
113
135
|
}, {
|
|
114
136
|
connection: {
|
|
@@ -134,6 +156,8 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
134
156
|
};
|
|
135
157
|
rpId?: string | undefined;
|
|
136
158
|
rootOrgId?: string | undefined;
|
|
159
|
+
oauthCallbackUrl?: string | undefined;
|
|
160
|
+
enablePopupOauth?: boolean | undefined;
|
|
137
161
|
}>]>;
|
|
138
162
|
sessionConfig: z.ZodOptional<z.ZodObject<Omit<{
|
|
139
163
|
sessionKey: z.ZodDefault<z.ZodString>;
|
|
@@ -141,12 +165,12 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
141
165
|
expirationTimeMs: z.ZodDefault<z.ZodNumber>;
|
|
142
166
|
client: z.ZodType<import("./index.js").BaseSignerClient<unknown>, z.ZodTypeDef, import("./index.js").BaseSignerClient<unknown>>;
|
|
143
167
|
}, "client">, "strip", z.ZodTypeAny, {
|
|
168
|
+
storage: (Storage | "localStorage" | "sessionStorage") & (Storage | "localStorage" | "sessionStorage" | undefined);
|
|
144
169
|
sessionKey: string;
|
|
145
|
-
storage: ("localStorage" | "sessionStorage" | Storage) & ("localStorage" | "sessionStorage" | Storage | undefined);
|
|
146
170
|
expirationTimeMs: number;
|
|
147
171
|
}, {
|
|
172
|
+
storage?: Storage | "localStorage" | "sessionStorage" | undefined;
|
|
148
173
|
sessionKey?: string | undefined;
|
|
149
|
-
storage?: "localStorage" | "sessionStorage" | Storage | undefined;
|
|
150
174
|
expirationTimeMs?: number | undefined;
|
|
151
175
|
}>>;
|
|
152
176
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -168,11 +192,13 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
168
192
|
jwt: string;
|
|
169
193
|
apiKey?: undefined;
|
|
170
194
|
};
|
|
171
|
-
rootOrgId: string;
|
|
172
195
|
iframeConfig: {
|
|
173
196
|
iframeElementId: string;
|
|
174
197
|
iframeContainerId: string;
|
|
175
198
|
};
|
|
199
|
+
rootOrgId: string;
|
|
200
|
+
oauthCallbackUrl: string;
|
|
201
|
+
enablePopupOauth: boolean;
|
|
176
202
|
rpId?: string | undefined;
|
|
177
203
|
} | AlchemySignerWebClient) & ({
|
|
178
204
|
connection: {
|
|
@@ -192,16 +218,18 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
192
218
|
jwt: string;
|
|
193
219
|
apiKey?: undefined;
|
|
194
220
|
};
|
|
195
|
-
rootOrgId: string;
|
|
196
221
|
iframeConfig: {
|
|
197
222
|
iframeElementId: string;
|
|
198
223
|
iframeContainerId: string;
|
|
199
224
|
};
|
|
225
|
+
rootOrgId: string;
|
|
226
|
+
oauthCallbackUrl: string;
|
|
227
|
+
enablePopupOauth: boolean;
|
|
200
228
|
rpId?: string | undefined;
|
|
201
229
|
} | AlchemySignerWebClient | undefined);
|
|
202
230
|
sessionConfig?: {
|
|
231
|
+
storage: (Storage | "localStorage" | "sessionStorage") & (Storage | "localStorage" | "sessionStorage" | undefined);
|
|
203
232
|
sessionKey: string;
|
|
204
|
-
storage: ("localStorage" | "sessionStorage" | Storage) & ("localStorage" | "sessionStorage" | Storage | undefined);
|
|
205
233
|
expirationTimeMs: number;
|
|
206
234
|
} | undefined;
|
|
207
235
|
}, {
|
|
@@ -229,6 +257,8 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
229
257
|
};
|
|
230
258
|
rpId?: string | undefined;
|
|
231
259
|
rootOrgId?: string | undefined;
|
|
260
|
+
oauthCallbackUrl?: string | undefined;
|
|
261
|
+
enablePopupOauth?: boolean | undefined;
|
|
232
262
|
} | AlchemySignerWebClient) & ({
|
|
233
263
|
connection: {
|
|
234
264
|
apiKey: string;
|
|
@@ -253,10 +283,12 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
253
283
|
};
|
|
254
284
|
rpId?: string | undefined;
|
|
255
285
|
rootOrgId?: string | undefined;
|
|
286
|
+
oauthCallbackUrl?: string | undefined;
|
|
287
|
+
enablePopupOauth?: boolean | undefined;
|
|
256
288
|
} | AlchemySignerWebClient | undefined);
|
|
257
289
|
sessionConfig?: {
|
|
290
|
+
storage?: Storage | "localStorage" | "sessionStorage" | undefined;
|
|
258
291
|
sessionKey?: string | undefined;
|
|
259
|
-
storage?: "localStorage" | "sessionStorage" | Storage | undefined;
|
|
260
292
|
expirationTimeMs?: number | undefined;
|
|
261
293
|
} | undefined;
|
|
262
294
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQlC,CAAC;AAEL,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,sBAAsB,CAAC;IAC7E;;;;;;;;;;;;;;;;;;;;OAoBG;gBACS,MAAM,EAAE,mBAAmB;CAexC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeAssertions.d.ts","sourceRoot":"","sources":["../../../src/utils/typeAssertions.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAE5D"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.0.0-beta.
|
|
1
|
+
export declare const VERSION = "4.0.0-beta.5";
|
|
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.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.5",
|
|
4
4
|
"description": "Core interfaces and clients for interfacing with the Alchemy Signer API",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"vitest": "^2.0.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aa-sdk/core": "^4.0.0-beta.
|
|
52
|
+
"@aa-sdk/core": "^4.0.0-beta.5",
|
|
53
53
|
"@turnkey/http": "^2.6.2",
|
|
54
54
|
"@turnkey/iframe-stamper": "^1.0.0",
|
|
55
55
|
"@turnkey/viem": "^0.4.8",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
72
72
|
},
|
|
73
73
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "d786e35ceed57e8262a1904c95364203c8c3a3fc"
|
|
75
75
|
}
|
package/src/base.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { Mutate, StoreApi } from "zustand";
|
|
|
16
16
|
import { subscribeWithSelector } from "zustand/middleware";
|
|
17
17
|
import { createStore } from "zustand/vanilla";
|
|
18
18
|
import type { BaseSignerClient } from "./client/base";
|
|
19
|
-
import type { User } from "./client/types";
|
|
19
|
+
import type { OauthConfig, OauthParams, User } from "./client/types";
|
|
20
20
|
import { NotAuthenticatedError } from "./errors.js";
|
|
21
21
|
import {
|
|
22
22
|
SessionManager,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
type AlchemySignerEvent,
|
|
29
29
|
type AlchemySignerEvents,
|
|
30
30
|
} from "./types.js";
|
|
31
|
+
import { assertNever } from "./utils/typeAssertions.js";
|
|
31
32
|
|
|
32
33
|
export interface BaseAlchemySignerParams<TClient extends BaseSignerClient> {
|
|
33
34
|
client: TClient;
|
|
@@ -138,10 +139,41 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
138
139
|
{ fireImmediately: true }
|
|
139
140
|
);
|
|
140
141
|
default:
|
|
141
|
-
throw new Error(`
|
|
142
|
+
throw new Error(`Unknown event type ${event}`);
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Prepares the config needed to use popup-based OAuth login. This must be
|
|
148
|
+
* called before calling `.authenticate` with params `{ type: "oauth", mode:
|
|
149
|
+
* "popup" }`, and is recommended to be called on page load.
|
|
150
|
+
*
|
|
151
|
+
* This method exists because browsers may prevent popups from opening unless
|
|
152
|
+
* triggered by user interaction, and so the OAuth config must already have
|
|
153
|
+
* been fetched at the time a user clicks a social login button.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
158
|
+
*
|
|
159
|
+
* const signer = new AlchemyWebSigner({
|
|
160
|
+
* client: {
|
|
161
|
+
* connection: {
|
|
162
|
+
* rpcUrl: "/api/rpc",
|
|
163
|
+
* },
|
|
164
|
+
* iframeConfig: {
|
|
165
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
166
|
+
* },
|
|
167
|
+
* },
|
|
168
|
+
* });
|
|
169
|
+
*
|
|
170
|
+
* await signer.preparePopupOauth();
|
|
171
|
+
* ```
|
|
172
|
+
* @returns {Promise<OauthConfig>} the config which must be loaded before
|
|
173
|
+
* using popup-based OAuth
|
|
174
|
+
*/
|
|
175
|
+
preparePopupOauth = (): Promise<OauthConfig> => this.inner.initOauth();
|
|
176
|
+
|
|
145
177
|
/**
|
|
146
178
|
* Authenticate a user with either an email or a passkey and create a session for that user
|
|
147
179
|
*
|
|
@@ -170,11 +202,19 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
170
202
|
* @returns {Promise<User>} the user that was authenticated
|
|
171
203
|
*/
|
|
172
204
|
authenticate: (params: AuthParams) => Promise<User> = async (params) => {
|
|
173
|
-
|
|
174
|
-
|
|
205
|
+
const { type } = params;
|
|
206
|
+
switch (type) {
|
|
207
|
+
case "email":
|
|
208
|
+
return this.authenticateWithEmail(params);
|
|
209
|
+
case "passkey":
|
|
210
|
+
return this.authenticateWithPasskey(params);
|
|
211
|
+
case "oauth":
|
|
212
|
+
return this.authenticateWithOauth(params);
|
|
213
|
+
case "oauthReturn":
|
|
214
|
+
return this.handleOauthReturn(params);
|
|
215
|
+
default:
|
|
216
|
+
assertNever(type, `Unknown auth type: ${type}`);
|
|
175
217
|
}
|
|
176
|
-
|
|
177
|
-
return this.authenticateWithPasskey(params);
|
|
178
218
|
};
|
|
179
219
|
|
|
180
220
|
/**
|
|
@@ -519,17 +559,20 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
519
559
|
): Promise<User> => {
|
|
520
560
|
if ("email" in params) {
|
|
521
561
|
const existingUser = await this.getUser(params.email);
|
|
562
|
+
const expirationSeconds = Math.floor(
|
|
563
|
+
this.sessionManager.expirationTimeMs / 1000
|
|
564
|
+
);
|
|
522
565
|
|
|
523
566
|
const { orgId } = existingUser
|
|
524
567
|
? await this.inner.initEmailAuth({
|
|
525
568
|
email: params.email,
|
|
526
|
-
expirationSeconds
|
|
569
|
+
expirationSeconds,
|
|
527
570
|
redirectParams: params.redirectParams,
|
|
528
571
|
})
|
|
529
572
|
: await this.inner.createAccount({
|
|
530
573
|
type: "email",
|
|
531
574
|
email: params.email,
|
|
532
|
-
expirationSeconds
|
|
575
|
+
expirationSeconds,
|
|
533
576
|
redirectParams: params.redirectParams,
|
|
534
577
|
});
|
|
535
578
|
|
|
@@ -557,9 +600,10 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
557
600
|
throw new Error("Could not find email auth init session!");
|
|
558
601
|
}
|
|
559
602
|
|
|
560
|
-
const user = await this.inner.
|
|
603
|
+
const user = await this.inner.completeAuthWithBundle({
|
|
561
604
|
bundle: params.bundle,
|
|
562
605
|
orgId: temporarySession.orgId,
|
|
606
|
+
connectedEventName: "connectedEmail",
|
|
563
607
|
});
|
|
564
608
|
|
|
565
609
|
return user;
|
|
@@ -568,7 +612,7 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
568
612
|
|
|
569
613
|
private authenticateWithPasskey = async (
|
|
570
614
|
args: Extract<AuthParams, { type: "passkey" }>
|
|
571
|
-
) => {
|
|
615
|
+
): Promise<User> => {
|
|
572
616
|
let user: User;
|
|
573
617
|
const shouldCreateNew = async () => {
|
|
574
618
|
if ("email" in args) {
|
|
@@ -604,6 +648,32 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
604
648
|
return user;
|
|
605
649
|
};
|
|
606
650
|
|
|
651
|
+
private authenticateWithOauth = async (
|
|
652
|
+
args: Extract<AuthParams, { type: "oauth" }>
|
|
653
|
+
): Promise<User> => {
|
|
654
|
+
const params: OauthParams = {
|
|
655
|
+
...args,
|
|
656
|
+
expirationSeconds: Math.floor(
|
|
657
|
+
this.sessionManager.expirationTimeMs / 1000
|
|
658
|
+
),
|
|
659
|
+
};
|
|
660
|
+
if (params.mode === "redirect") {
|
|
661
|
+
return this.inner.oauthWithRedirect(params);
|
|
662
|
+
} else {
|
|
663
|
+
return this.inner.oauthWithPopup(params);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
private handleOauthReturn = ({
|
|
668
|
+
bundle,
|
|
669
|
+
orgId,
|
|
670
|
+
}: Extract<AuthParams, { type: "oauthReturn" }>): Promise<User> =>
|
|
671
|
+
this.inner.completeAuthWithBundle({
|
|
672
|
+
bundle,
|
|
673
|
+
orgId,
|
|
674
|
+
connectedEventName: "connectedOauth",
|
|
675
|
+
});
|
|
676
|
+
|
|
607
677
|
private registerListeners = () => {
|
|
608
678
|
this.sessionManager.on("connected", (session) => {
|
|
609
679
|
this.store.setState({
|