@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.
Files changed (80) hide show
  1. package/dist/esm/base.d.ts +16 -32
  2. package/dist/esm/base.js +127 -122
  3. package/dist/esm/base.js.map +1 -1
  4. package/dist/esm/client/base.d.ts +3 -36
  5. package/dist/esm/client/base.js +15 -20
  6. package/dist/esm/client/base.js.map +1 -1
  7. package/dist/esm/client/index.d.ts +27 -40
  8. package/dist/esm/client/index.js +41 -164
  9. package/dist/esm/client/index.js.map +1 -1
  10. package/dist/esm/client/types.d.ts +27 -65
  11. package/dist/esm/client/types.js.map +1 -1
  12. package/dist/esm/errors.d.ts +0 -6
  13. package/dist/esm/errors.js +0 -18
  14. package/dist/esm/errors.js.map +1 -1
  15. package/dist/esm/index.d.ts +1 -1
  16. package/dist/esm/index.js +1 -1
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/metrics.d.ts +3 -0
  19. package/dist/esm/metrics.js.map +1 -1
  20. package/dist/esm/oauth.d.ts +5 -4
  21. package/dist/esm/oauth.js +16 -6
  22. package/dist/esm/oauth.js.map +1 -1
  23. package/dist/esm/session/manager.d.ts +0 -1
  24. package/dist/esm/session/manager.js +4 -0
  25. package/dist/esm/session/manager.js.map +1 -1
  26. package/dist/esm/session/types.d.ts +1 -1
  27. package/dist/esm/session/types.js.map +1 -1
  28. package/dist/esm/signer.d.ts +8 -5
  29. package/dist/esm/signer.js.map +1 -1
  30. package/dist/esm/types.d.ts +2 -9
  31. package/dist/esm/types.js +1 -5
  32. package/dist/esm/types.js.map +1 -1
  33. package/dist/esm/version.d.ts +1 -1
  34. package/dist/esm/version.js +1 -1
  35. package/dist/esm/version.js.map +1 -1
  36. package/dist/types/base.d.ts +16 -32
  37. package/dist/types/base.d.ts.map +1 -1
  38. package/dist/types/client/base.d.ts +3 -36
  39. package/dist/types/client/base.d.ts.map +1 -1
  40. package/dist/types/client/index.d.ts +27 -40
  41. package/dist/types/client/index.d.ts.map +1 -1
  42. package/dist/types/client/types.d.ts +27 -65
  43. package/dist/types/client/types.d.ts.map +1 -1
  44. package/dist/types/errors.d.ts +0 -6
  45. package/dist/types/errors.d.ts.map +1 -1
  46. package/dist/types/index.d.ts +1 -1
  47. package/dist/types/index.d.ts.map +1 -1
  48. package/dist/types/metrics.d.ts +3 -0
  49. package/dist/types/metrics.d.ts.map +1 -1
  50. package/dist/types/oauth.d.ts +5 -4
  51. package/dist/types/oauth.d.ts.map +1 -1
  52. package/dist/types/session/manager.d.ts +0 -1
  53. package/dist/types/session/manager.d.ts.map +1 -1
  54. package/dist/types/session/types.d.ts +1 -1
  55. package/dist/types/session/types.d.ts.map +1 -1
  56. package/dist/types/signer.d.ts +8 -5
  57. package/dist/types/signer.d.ts.map +1 -1
  58. package/dist/types/types.d.ts +2 -9
  59. package/dist/types/types.d.ts.map +1 -1
  60. package/dist/types/version.d.ts +1 -1
  61. package/package.json +4 -4
  62. package/src/base.ts +120 -166
  63. package/src/client/base.ts +26 -65
  64. package/src/client/index.ts +46 -174
  65. package/src/client/types.ts +31 -75
  66. package/src/errors.ts +1 -11
  67. package/src/index.ts +1 -5
  68. package/src/metrics.ts +2 -1
  69. package/src/oauth.ts +22 -8
  70. package/src/session/manager.ts +8 -7
  71. package/src/session/types.ts +1 -1
  72. package/src/signer.ts +13 -7
  73. package/src/types.ts +1 -9
  74. package/src/version.ts +1 -1
  75. package/dist/esm/utils/parseMfaError.d.ts +0 -2
  76. package/dist/esm/utils/parseMfaError.js +0 -15
  77. package/dist/esm/utils/parseMfaError.js.map +0 -1
  78. package/dist/types/utils/parseMfaError.d.ts +0 -3
  79. package/dist/types/utils/parseMfaError.d.ts.map +0 -1
  80. package/src/utils/parseMfaError.ts +0 -15
@@ -1,6 +1,6 @@
1
1
  import type { User } from "../client/types";
2
2
  export type Session = {
3
- type: "email" | "oauth" | "otp";
3
+ type: "email" | "oauth" | "otp" | "custom-jwt";
4
4
  bundle: string;
5
5
  expirationDateMs: number;
6
6
  user: User;
@@ -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;IAChC,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"}
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"}
@@ -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, VerifyMfaParams } from "./client/types.js";
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
- } & OauthProviderConfig & OauthRedirectConfig) | {
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":["../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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUlC,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;gBAES,MAAM,EAAE,mBAAmB;CAuDxC"}
@@ -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":[],"mapp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C,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"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.16.1-alpha.3";
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.16.1-alpha.3",
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.16.1-alpha.3",
53
- "@account-kit/logging": "^4.16.1-alpha.3",
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": "156dbc81d12e9f120f8123df6b4fec8a41f41e7a"
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 ("bundle" in params) {
828
- return this.completeEmailAuth(params);
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
- if (!("email" in params)) {
832
- throw new Error("Email is required");
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
- const { orgId, otpId, multiFactors, isNewUser } =
836
- await this.initOrCreateEmailUser(
837
- params.email,
838
- params.emailMode ?? "otp",
839
- params.multiFactors,
840
- params.redirectParams
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
- const isMfaRequired = multiFactors ? multiFactors?.length > 0 : false;
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
- this.sessionManager.setTemporarySession({
846
- orgId,
847
- isNewUser,
848
- isMfaRequired,
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
- this.store.setState({
852
- status: AlchemySignerStatus.AWAITING_EMAIL_AUTH,
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
- // We wait for the session manager to emit a connected event if
862
- // cross tab sessions are permitted
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, isMfaRequired } = tempSession ?? {};
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
- private async initOrCreateEmailUser(
1054
- email: string,
1055
- emailMode: EmailType,
1056
- multiFactors?: VerifyMfaParams[],
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
- if (!temporarySession) {
1109
- this.store.setState({ status: AlchemySignerStatus.DISCONNECTED });
1110
- throw new Error("Could not find email auth init session!");
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
- const user = await this.inner.completeAuthWithBundle({
1114
- bundle: params.bundle,
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
- return user;
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 {