@account-kit/signer 4.16.1-alpha.3 → 4.18.0-alpha.3
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 +16 -32
- package/dist/esm/base.js +127 -122
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +3 -36
- package/dist/esm/client/base.js +15 -20
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +27 -40
- package/dist/esm/client/index.js +41 -164
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +27 -65
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/errors.d.ts +0 -6
- package/dist/esm/errors.js +0 -18
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/metrics.d.ts +3 -0
- package/dist/esm/metrics.js.map +1 -1
- package/dist/esm/oauth.d.ts +5 -4
- package/dist/esm/oauth.js +16 -6
- package/dist/esm/oauth.js.map +1 -1
- package/dist/esm/session/manager.d.ts +0 -1
- package/dist/esm/session/manager.js +4 -0
- 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 +8 -5
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/types.d.ts +2 -9
- package/dist/esm/types.js +1 -5
- package/dist/esm/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/base.d.ts +16 -32
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +3 -36
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +27 -40
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +27 -65
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/errors.d.ts +0 -6
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/metrics.d.ts +3 -0
- package/dist/types/metrics.d.ts.map +1 -1
- package/dist/types/oauth.d.ts +5 -4
- package/dist/types/oauth.d.ts.map +1 -1
- package/dist/types/session/manager.d.ts +0 -1
- 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 +8 -5
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -9
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/base.ts +120 -166
- package/src/client/base.ts +26 -65
- package/src/client/index.ts +46 -174
- package/src/client/types.ts +31 -75
- package/src/errors.ts +1 -11
- package/src/index.ts +1 -5
- package/src/metrics.ts +2 -1
- package/src/oauth.ts +22 -8
- package/src/session/manager.ts +8 -7
- package/src/session/types.ts +1 -1
- package/src/signer.ts +13 -7
- package/src/types.ts +1 -9
- package/src/version.ts +1 -1
- package/dist/esm/utils/parseMfaError.d.ts +0 -2
- package/dist/esm/utils/parseMfaError.js +0 -15
- package/dist/esm/utils/parseMfaError.js.map +0 -1
- package/dist/types/utils/parseMfaError.d.ts +0 -3
- package/dist/types/utils/parseMfaError.d.ts.map +0 -1
- package/src/utils/parseMfaError.ts +0 -15
|
@@ -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,GAAG,OAAO,GAAG,KAAK,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,GAAG,KAAK,GAAG,YAAY,CAAC;IAC/C,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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { BaseAlchemySigner } from "./base.js";
|
|
3
3
|
import { AlchemySignerWebClient } from "./client/index.js";
|
|
4
|
-
import type { CredentialCreationOptionOverrides
|
|
4
|
+
import type { CredentialCreationOptionOverrides } from "./client/types.js";
|
|
5
5
|
export type AuthParams = {
|
|
6
6
|
type: "email";
|
|
7
7
|
email: string;
|
|
8
|
+
/** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */
|
|
8
9
|
emailMode?: "magicLink" | "otp";
|
|
9
10
|
redirectParams?: URLSearchParams;
|
|
10
|
-
multiFactors?: VerifyMfaParams[];
|
|
11
11
|
} | {
|
|
12
12
|
type: "email";
|
|
13
13
|
bundle: string;
|
|
@@ -29,7 +29,11 @@ export type AuthParams = {
|
|
|
29
29
|
type: "oauth";
|
|
30
30
|
scope?: string;
|
|
31
31
|
claims?: string;
|
|
32
|
-
|
|
32
|
+
otherParameters?: Record<string, string>;
|
|
33
|
+
} & OauthProviderConfig & OauthRedirectConfig) | ({
|
|
34
|
+
type: "custom-jwt";
|
|
35
|
+
jwt: string;
|
|
36
|
+
} & OauthProviderConfig) | {
|
|
33
37
|
type: "oauthReturn";
|
|
34
38
|
bundle: string;
|
|
35
39
|
orgId: string;
|
|
@@ -38,7 +42,6 @@ export type AuthParams = {
|
|
|
38
42
|
} | {
|
|
39
43
|
type: "otp";
|
|
40
44
|
otpCode: string;
|
|
41
|
-
multiFactors?: VerifyMfaParams[];
|
|
42
45
|
};
|
|
43
46
|
export type OauthProviderConfig = {
|
|
44
47
|
authProviderId: "auth0";
|
|
@@ -60,7 +63,7 @@ export type OauthRedirectConfig = {
|
|
|
60
63
|
mode: "popup";
|
|
61
64
|
redirectUrl?: never;
|
|
62
65
|
};
|
|
63
|
-
export type KnownAuthProvider = "google" | "apple" | "facebook" | "auth0";
|
|
66
|
+
export type KnownAuthProvider = "google" | "apple" | "facebook" | "twitch" | "auth0";
|
|
64
67
|
export type OauthMode = "redirect" | "popup";
|
|
65
68
|
export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
66
69
|
client: z.ZodUnion<[z.ZodType<AlchemySignerWebClient, z.ZodTypeDef, AlchemySignerWebClient>, z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAEL,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAEL,sBAAsB,EACvB,MAAM,mBAAmB,CAAC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CAAC;IAC7E;;;;;;;;;;;;;;;;;;;;OAoBG;gBAES,MAAM,EAAE,mBAAmB;CAuDxC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -5,10 +5,6 @@ export type AlchemySignerEvents = {
|
|
|
5
5
|
disconnected(): void;
|
|
6
6
|
statusChanged(status: AlchemySignerStatus): void;
|
|
7
7
|
errorChanged(error: ErrorInfo | undefined): void;
|
|
8
|
-
mfaStatusChanged(mfaStatus: {
|
|
9
|
-
mfaRequired: boolean;
|
|
10
|
-
mfaFactorId?: string;
|
|
11
|
-
}): void;
|
|
12
8
|
};
|
|
13
9
|
export type AlchemySignerEvent = keyof AlchemySignerEvents;
|
|
14
10
|
export declare enum AlchemySignerStatus {
|
|
@@ -19,11 +15,8 @@ export declare enum AlchemySignerStatus {
|
|
|
19
15
|
AUTHENTICATING_EMAIL = "AUTHENTICATING_EMAIL",
|
|
20
16
|
AUTHENTICATING_OAUTH = "AUTHENTICATING_OAUTH",
|
|
21
17
|
AWAITING_EMAIL_AUTH = "AWAITING_EMAIL_AUTH",
|
|
22
|
-
AWAITING_OTP_AUTH = "AWAITING_OTP_AUTH"
|
|
23
|
-
|
|
24
|
-
export declare enum AlchemyMfaStatus {
|
|
25
|
-
NOT_REQUIRED = "not_required",
|
|
26
|
-
REQUIRED = "required"
|
|
18
|
+
AWAITING_OTP_AUTH = "AWAITING_OTP_AUTH",
|
|
19
|
+
AUTHENTICATING_JWT = "AUTHENTICATING_JWT"
|
|
27
20
|
}
|
|
28
21
|
export interface ErrorInfo {
|
|
29
22
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,aAAa,IAAI,IAAI,CAAC;IACtB,YAAY,IAAI,IAAI,CAAC;IACrB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,aAAa,IAAI,IAAI,CAAC;IACtB,YAAY,IAAI,IAAI,CAAC;IACrB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,mBAAmB,CAAC;AAE3D,oBAAY,mBAAmB;IAC7B,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,sBAAsB,2BAA2B;IACjD,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,mBAAmB,wBAAwB;IAC3C,iBAAiB,sBAAsB;IACvC,kBAAkB,uBAAuB;CAC1C;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.18.0-alpha.3";
|
|
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.18.0-alpha.3",
|
|
4
4
|
"description": "Core interfaces and clients for interfacing with the Alchemy Signer API",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"vitest": "^2.0.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aa-sdk/core": "^4.
|
|
53
|
-
"@account-kit/logging": "^4.
|
|
52
|
+
"@aa-sdk/core": "^4.18.0-alpha.3",
|
|
53
|
+
"@account-kit/logging": "^4.18.0-alpha.3",
|
|
54
54
|
"@solana/web3.js": "^1.98.0",
|
|
55
55
|
"@turnkey/http": "^2.6.2",
|
|
56
56
|
"@turnkey/iframe-stamper": "^1.0.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
75
75
|
},
|
|
76
76
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "3ab0862d913254d5f4208981cbcc5e3ed8d6708f"
|
|
78
78
|
}
|
package/src/base.ts
CHANGED
|
@@ -21,14 +21,7 @@ import type { Mutate, StoreApi } from "zustand";
|
|
|
21
21
|
import { subscribeWithSelector } from "zustand/middleware";
|
|
22
22
|
import { createStore } from "zustand/vanilla";
|
|
23
23
|
import type { BaseSignerClient } from "./client/base";
|
|
24
|
-
import type {
|
|
25
|
-
EmailType,
|
|
26
|
-
MfaFactor,
|
|
27
|
-
OauthConfig,
|
|
28
|
-
OauthParams,
|
|
29
|
-
User,
|
|
30
|
-
VerifyMfaParams,
|
|
31
|
-
} from "./client/types";
|
|
24
|
+
import type { OauthConfig, OauthParams, User } from "./client/types";
|
|
32
25
|
import { NotAuthenticatedError } from "./errors.js";
|
|
33
26
|
import { SignerLogger } from "./metrics.js";
|
|
34
27
|
import {
|
|
@@ -58,10 +51,6 @@ type AlchemySignerStore = {
|
|
|
58
51
|
error: ErrorInfo | null;
|
|
59
52
|
otpId?: string;
|
|
60
53
|
isNewUser?: boolean;
|
|
61
|
-
mfaStatus: {
|
|
62
|
-
mfaRequired: boolean;
|
|
63
|
-
mfaFactorId?: string;
|
|
64
|
-
};
|
|
65
54
|
};
|
|
66
55
|
|
|
67
56
|
type UnpackedSignature = {
|
|
@@ -75,6 +64,14 @@ type InternalStore = Mutate<
|
|
|
75
64
|
[["zustand/subscribeWithSelector", never]]
|
|
76
65
|
>;
|
|
77
66
|
|
|
67
|
+
export type EmailConfig = {
|
|
68
|
+
mode?: "MAGIC_LINK" | "OTP";
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type SignerConfig = {
|
|
72
|
+
email: EmailConfig;
|
|
73
|
+
};
|
|
74
|
+
|
|
78
75
|
/**
|
|
79
76
|
* Base abstract class for Alchemy Signer, providing authentication and session management for smart accounts.
|
|
80
77
|
* Implements the `SmartAccountAuthenticator` interface and handles various signer events.
|
|
@@ -86,6 +83,7 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
86
83
|
inner: TClient;
|
|
87
84
|
private sessionManager: SessionManager;
|
|
88
85
|
private store: InternalStore;
|
|
86
|
+
private config: Promise<SignerConfig>;
|
|
89
87
|
|
|
90
88
|
/**
|
|
91
89
|
* Initializes an instance with the provided client and session configuration.
|
|
@@ -110,10 +108,6 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
110
108
|
user: null,
|
|
111
109
|
status: AlchemySignerStatus.INITIALIZING,
|
|
112
110
|
error: initialError ?? null,
|
|
113
|
-
mfaStatus: {
|
|
114
|
-
mfaRequired: false,
|
|
115
|
-
mfaFactorId: undefined,
|
|
116
|
-
},
|
|
117
111
|
} satisfies AlchemySignerStore)
|
|
118
112
|
)
|
|
119
113
|
);
|
|
@@ -128,6 +122,7 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
128
122
|
this.registerListeners();
|
|
129
123
|
// then initialize so that we can catch those events
|
|
130
124
|
this.sessionManager.initialize();
|
|
125
|
+
this.config = this.fetchConfig();
|
|
131
126
|
}
|
|
132
127
|
|
|
133
128
|
/**
|
|
@@ -186,13 +181,6 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
186
181
|
},
|
|
187
182
|
{ fireImmediately: true }
|
|
188
183
|
);
|
|
189
|
-
case "mfaStatusChanged":
|
|
190
|
-
return this.store.subscribe(
|
|
191
|
-
({ mfaStatus }) => mfaStatus,
|
|
192
|
-
(mfaStatus) =>
|
|
193
|
-
(listener as AlchemySignerEvents["mfaStatusChanged"])(mfaStatus),
|
|
194
|
-
{ fireImmediately: true }
|
|
195
|
-
);
|
|
196
184
|
default:
|
|
197
185
|
assertNever(event, `Unknown event type ${event}`);
|
|
198
186
|
}
|
|
@@ -272,6 +260,8 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
272
260
|
return this.handleOauthReturn(params);
|
|
273
261
|
case "otp":
|
|
274
262
|
return this.authenticateWithOtp(params);
|
|
263
|
+
case "custom-jwt":
|
|
264
|
+
return this.authenticateWithJwt(params);
|
|
275
265
|
default:
|
|
276
266
|
assertNever(type, `Unknown auth type: ${type}`);
|
|
277
267
|
}
|
|
@@ -319,6 +309,16 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
319
309
|
});
|
|
320
310
|
return;
|
|
321
311
|
}
|
|
312
|
+
case "custom-jwt": {
|
|
313
|
+
SignerLogger.trackEvent({
|
|
314
|
+
name: "signer_authnticate",
|
|
315
|
+
data: {
|
|
316
|
+
authType: "custom-jwt",
|
|
317
|
+
provider: params.authProviderId,
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
322
|
case "oauth":
|
|
323
323
|
SignerLogger.trackEvent({
|
|
324
324
|
name: "signer_authnticate",
|
|
@@ -602,39 +602,6 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
602
602
|
}
|
|
603
603
|
);
|
|
604
604
|
|
|
605
|
-
/**
|
|
606
|
-
* Gets the current MFA status
|
|
607
|
-
*
|
|
608
|
-
* @example
|
|
609
|
-
* ```ts
|
|
610
|
-
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
611
|
-
*
|
|
612
|
-
* const signer = new AlchemyWebSigner({
|
|
613
|
-
* client: {
|
|
614
|
-
* connection: {
|
|
615
|
-
* rpcUrl: "/api/rpc",
|
|
616
|
-
* },
|
|
617
|
-
* iframeConfig: {
|
|
618
|
-
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
619
|
-
* },
|
|
620
|
-
* },
|
|
621
|
-
* });
|
|
622
|
-
*
|
|
623
|
-
* const mfaStatus = signer.getMfaStatus();
|
|
624
|
-
* if (mfaStatus === AlchemyMfaStatus.REQUIRED) {
|
|
625
|
-
* // Handle MFA requirement
|
|
626
|
-
* }
|
|
627
|
-
* ```
|
|
628
|
-
*
|
|
629
|
-
* @returns {{ mfaRequired: boolean; mfaFactorId?: string }} The current MFA status
|
|
630
|
-
*/
|
|
631
|
-
getMfaStatus = (): {
|
|
632
|
-
mfaRequired: boolean;
|
|
633
|
-
mfaFactorId?: string;
|
|
634
|
-
} => {
|
|
635
|
-
return this.store.getState().mfaStatus;
|
|
636
|
-
};
|
|
637
|
-
|
|
638
605
|
private unpackSignRawMessageBytes = (
|
|
639
606
|
hex: `0x${string}`
|
|
640
607
|
): UnpackedSignature => {
|
|
@@ -824,48 +791,70 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
824
791
|
private authenticateWithEmail = async (
|
|
825
792
|
params: Extract<AuthParams, { type: "email" }>
|
|
826
793
|
): Promise<User> => {
|
|
827
|
-
if ("
|
|
828
|
-
|
|
829
|
-
|
|
794
|
+
if ("email" in params) {
|
|
795
|
+
const existingUser = await this.getUser(params.email);
|
|
796
|
+
const expirationSeconds = this.getExpirationSeconds();
|
|
797
|
+
|
|
798
|
+
const { orgId, otpId } = existingUser
|
|
799
|
+
? await this.inner.initEmailAuth({
|
|
800
|
+
email: params.email,
|
|
801
|
+
emailMode: params.emailMode,
|
|
802
|
+
expirationSeconds,
|
|
803
|
+
redirectParams: params.redirectParams,
|
|
804
|
+
})
|
|
805
|
+
: await this.inner.createAccount({
|
|
806
|
+
type: "email",
|
|
807
|
+
email: params.email,
|
|
808
|
+
emailMode: params.emailMode,
|
|
809
|
+
expirationSeconds,
|
|
810
|
+
redirectParams: params.redirectParams,
|
|
811
|
+
});
|
|
830
812
|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
813
|
+
this.sessionManager.setTemporarySession({
|
|
814
|
+
orgId,
|
|
815
|
+
isNewUser: !existingUser,
|
|
816
|
+
});
|
|
817
|
+
this.store.setState({
|
|
818
|
+
status: AlchemySignerStatus.AWAITING_EMAIL_AUTH,
|
|
819
|
+
otpId,
|
|
820
|
+
error: null,
|
|
821
|
+
});
|
|
834
822
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
823
|
+
// We wait for the session manager to emit a connected event if
|
|
824
|
+
// cross tab sessions are permitted
|
|
825
|
+
return new Promise<User>((resolve) => {
|
|
826
|
+
const removeListener = this.sessionManager.on(
|
|
827
|
+
"connected",
|
|
828
|
+
(session) => {
|
|
829
|
+
resolve(session.user);
|
|
830
|
+
removeListener();
|
|
831
|
+
}
|
|
832
|
+
);
|
|
833
|
+
});
|
|
834
|
+
} else {
|
|
835
|
+
const temporarySession = params.orgId
|
|
836
|
+
? { orgId: params.orgId }
|
|
837
|
+
: this.sessionManager.getTemporarySession();
|
|
842
838
|
|
|
843
|
-
|
|
839
|
+
if (!temporarySession) {
|
|
840
|
+
this.store.setState({
|
|
841
|
+
status: AlchemySignerStatus.DISCONNECTED,
|
|
842
|
+
});
|
|
843
|
+
throw new Error("Could not find email auth init session!");
|
|
844
|
+
}
|
|
844
845
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
846
|
+
const user = await this.inner.completeAuthWithBundle({
|
|
847
|
+
bundle: params.bundle,
|
|
848
|
+
orgId: temporarySession.orgId,
|
|
849
|
+
connectedEventName: "connectedEmail",
|
|
850
|
+
authenticatingType: "email",
|
|
851
|
+
});
|
|
850
852
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
otpId,
|
|
854
|
-
error: null,
|
|
855
|
-
mfaStatus: {
|
|
856
|
-
mfaRequired: isMfaRequired,
|
|
857
|
-
mfaFactorId: multiFactors?.[0]?.multiFactorId,
|
|
858
|
-
},
|
|
859
|
-
});
|
|
853
|
+
// fire new user event
|
|
854
|
+
this.emitNewUserEvent(params.isNewUser);
|
|
860
855
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
return new Promise<User>((resolve) => {
|
|
864
|
-
const removeListener = this.sessionManager.on("connected", (session) => {
|
|
865
|
-
resolve(session.user);
|
|
866
|
-
removeListener();
|
|
867
|
-
});
|
|
868
|
-
});
|
|
856
|
+
return user;
|
|
857
|
+
}
|
|
869
858
|
};
|
|
870
859
|
|
|
871
860
|
private authenticateWithPasskey = async (
|
|
@@ -922,11 +911,30 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
922
911
|
}
|
|
923
912
|
};
|
|
924
913
|
|
|
914
|
+
private authenticateWithJwt = async (
|
|
915
|
+
args: Extract<AuthParams, { type: "custom-jwt" }>
|
|
916
|
+
): Promise<User> => {
|
|
917
|
+
const { credentialBundle, orgId, isSignUp } = await this.inner.submitJwt({
|
|
918
|
+
jwt: args.jwt,
|
|
919
|
+
authProvider: args.authProviderId,
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
const user = await this.inner.completeAuthWithBundle({
|
|
923
|
+
bundle: credentialBundle,
|
|
924
|
+
orgId: orgId,
|
|
925
|
+
connectedEventName: "connectedJwt",
|
|
926
|
+
authenticatingType: "custom-jwt",
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
this.emitNewUserEvent(isSignUp);
|
|
930
|
+
return user;
|
|
931
|
+
};
|
|
932
|
+
|
|
925
933
|
private authenticateWithOtp = async (
|
|
926
934
|
args: Extract<AuthParams, { type: "otp" }>
|
|
927
935
|
): Promise<User> => {
|
|
928
936
|
const tempSession = this.sessionManager.getTemporarySession();
|
|
929
|
-
const { orgId, isNewUser
|
|
937
|
+
const { orgId, isNewUser } = tempSession ?? {};
|
|
930
938
|
const { otpId } = this.store.getState();
|
|
931
939
|
if (!orgId) {
|
|
932
940
|
throw new Error("orgId not found in session");
|
|
@@ -934,16 +942,11 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
934
942
|
if (!otpId) {
|
|
935
943
|
throw new Error("otpId not found in session");
|
|
936
944
|
}
|
|
937
|
-
if (isMfaRequired && !args.multiFactors) {
|
|
938
|
-
throw new Error(`MFA is required.`);
|
|
939
|
-
}
|
|
940
|
-
|
|
941
945
|
const { bundle } = await this.inner.submitOtpCode({
|
|
942
946
|
orgId,
|
|
943
947
|
otpId,
|
|
944
948
|
otpCode: args.otpCode,
|
|
945
949
|
expirationSeconds: this.getExpirationSeconds(),
|
|
946
|
-
multiFactors: args.multiFactors,
|
|
947
950
|
});
|
|
948
951
|
const user = await this.inner.completeAuthWithBundle({
|
|
949
952
|
bundle,
|
|
@@ -1028,6 +1031,8 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
1028
1031
|
case "otp":
|
|
1029
1032
|
case "otpVerify":
|
|
1030
1033
|
return AlchemySignerStatus.AWAITING_OTP_AUTH;
|
|
1034
|
+
case "custom-jwt":
|
|
1035
|
+
return AlchemySignerStatus.AUTHENTICATING_JWT;
|
|
1031
1036
|
default:
|
|
1032
1037
|
assertNever(type, "unhandled authenticating type");
|
|
1033
1038
|
}
|
|
@@ -1050,78 +1055,27 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
1050
1055
|
if (isNewUser) this.store.setState({ isNewUser });
|
|
1051
1056
|
};
|
|
1052
1057
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
redirectParams?: URLSearchParams
|
|
1058
|
-
): Promise<{
|
|
1059
|
-
orgId: string;
|
|
1060
|
-
otpId?: string;
|
|
1061
|
-
multiFactors?: MfaFactor[];
|
|
1062
|
-
isNewUser: boolean;
|
|
1063
|
-
}> {
|
|
1064
|
-
const existingUser = await this.getUser(email);
|
|
1065
|
-
const expirationSeconds = this.getExpirationSeconds();
|
|
1066
|
-
|
|
1067
|
-
if (existingUser) {
|
|
1068
|
-
const {
|
|
1069
|
-
orgId,
|
|
1070
|
-
otpId,
|
|
1071
|
-
multiFactors: mfaFactors,
|
|
1072
|
-
} = await this.inner.initEmailAuth({
|
|
1073
|
-
email: email,
|
|
1074
|
-
emailMode: emailMode,
|
|
1075
|
-
expirationSeconds,
|
|
1076
|
-
redirectParams: redirectParams,
|
|
1077
|
-
multiFactors,
|
|
1078
|
-
});
|
|
1079
|
-
return {
|
|
1080
|
-
orgId,
|
|
1081
|
-
otpId,
|
|
1082
|
-
multiFactors: mfaFactors,
|
|
1083
|
-
isNewUser: false,
|
|
1084
|
-
};
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
const { orgId, otpId } = await this.inner.createAccount({
|
|
1088
|
-
type: "email",
|
|
1089
|
-
email,
|
|
1090
|
-
emailMode,
|
|
1091
|
-
expirationSeconds,
|
|
1092
|
-
redirectParams,
|
|
1093
|
-
});
|
|
1094
|
-
return {
|
|
1095
|
-
orgId,
|
|
1096
|
-
otpId,
|
|
1097
|
-
isNewUser: true,
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
private async completeEmailAuth(
|
|
1102
|
-
params: Extract<AuthParams, { type: "email"; bundle: string }>
|
|
1103
|
-
): Promise<User> {
|
|
1104
|
-
const temporarySession = params.orgId
|
|
1105
|
-
? { orgId: params.orgId }
|
|
1106
|
-
: this.sessionManager.getTemporarySession();
|
|
1058
|
+
protected initConfig = async (): Promise<SignerConfig> => {
|
|
1059
|
+
this.config = this.fetchConfig();
|
|
1060
|
+
return this.config;
|
|
1061
|
+
};
|
|
1107
1062
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1063
|
+
/**
|
|
1064
|
+
* Returns the signer configuration while fetching it if it's not already initialized.
|
|
1065
|
+
*
|
|
1066
|
+
* @returns {Promise<SignerConfig>} A promise that resolves to the signer configuration
|
|
1067
|
+
*/
|
|
1068
|
+
public getConfig = async (): Promise<SignerConfig> => {
|
|
1069
|
+
if (!this.config) {
|
|
1070
|
+
return this.initConfig();
|
|
1111
1071
|
}
|
|
1112
1072
|
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
orgId: temporarySession.orgId,
|
|
1116
|
-
connectedEventName: "connectedEmail",
|
|
1117
|
-
authenticatingType: "email",
|
|
1118
|
-
});
|
|
1119
|
-
|
|
1120
|
-
// fire new user event
|
|
1121
|
-
this.emitNewUserEvent(params.isNewUser);
|
|
1073
|
+
return this.config;
|
|
1074
|
+
};
|
|
1122
1075
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1076
|
+
protected fetchConfig = async (): Promise<SignerConfig> => {
|
|
1077
|
+
return this.inner.request("/v1/signer-config", {});
|
|
1078
|
+
};
|
|
1125
1079
|
}
|
|
1126
1080
|
|
|
1127
1081
|
function toErrorInfo(error: unknown): ErrorInfo {
|