@account-kit/signer 4.52.4 → 4.53.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.
Files changed (45) hide show
  1. package/dist/esm/base.d.ts +41 -1
  2. package/dist/esm/base.js +116 -39
  3. package/dist/esm/base.js.map +1 -1
  4. package/dist/esm/client/base.d.ts +14 -1
  5. package/dist/esm/client/base.js +24 -0
  6. package/dist/esm/client/base.js.map +1 -1
  7. package/dist/esm/client/index.d.ts +29 -1
  8. package/dist/esm/client/index.js +37 -0
  9. package/dist/esm/client/index.js.map +1 -1
  10. package/dist/esm/client/types.d.ts +13 -5
  11. package/dist/esm/client/types.js.map +1 -1
  12. package/dist/esm/metrics.d.ts +1 -1
  13. package/dist/esm/metrics.js.map +1 -1
  14. package/dist/esm/signer.d.ts +3 -0
  15. package/dist/esm/signer.js.map +1 -1
  16. package/dist/esm/types.d.ts +1 -0
  17. package/dist/esm/types.js +1 -0
  18. package/dist/esm/types.js.map +1 -1
  19. package/dist/esm/version.d.ts +1 -1
  20. package/dist/esm/version.js +1 -1
  21. package/dist/esm/version.js.map +1 -1
  22. package/dist/types/base.d.ts +41 -1
  23. package/dist/types/base.d.ts.map +1 -1
  24. package/dist/types/client/base.d.ts +14 -1
  25. package/dist/types/client/base.d.ts.map +1 -1
  26. package/dist/types/client/index.d.ts +29 -1
  27. package/dist/types/client/index.d.ts.map +1 -1
  28. package/dist/types/client/types.d.ts +13 -5
  29. package/dist/types/client/types.d.ts.map +1 -1
  30. package/dist/types/metrics.d.ts +1 -1
  31. package/dist/types/metrics.d.ts.map +1 -1
  32. package/dist/types/signer.d.ts +3 -0
  33. package/dist/types/signer.d.ts.map +1 -1
  34. package/dist/types/types.d.ts +1 -0
  35. package/dist/types/types.d.ts.map +1 -1
  36. package/dist/types/version.d.ts +1 -1
  37. package/package.json +4 -4
  38. package/src/base.ts +175 -12
  39. package/src/client/base.ts +27 -0
  40. package/src/client/index.ts +37 -0
  41. package/src/client/types.ts +19 -6
  42. package/src/metrics.ts +1 -0
  43. package/src/signer.ts +4 -0
  44. package/src/types.ts +1 -0
  45. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/metrics.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,kBAAkB,GAAG;IAC/B;QACE,SAAS,EAAE,oBAAoB,CAAC;QAChC,SAAS,EACL;YACE,QAAQ,EACJ,OAAO,GACP,cAAc,GACd,eAAe,GACf,KAAK,GACL,aAAa,CAAC;YAClB,QAAQ,CAAC,EAAE,KAAK,CAAC;SAClB,GACD;YAAE,QAAQ,EAAE,OAAO,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C;IACD;QACE,SAAS,EAAE,qBAAqB,CAAC;QACjC,SAAS,EAAE,SAAS,CAAC;KACtB;CACF,CAAC;AAEF,eAAO,MAAM,YAAY,gEAGvB,CAAC"}
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/metrics.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,kBAAkB,GAAG;IAC/B;QACE,SAAS,EAAE,oBAAoB,CAAC;QAChC,SAAS,EACL;YACE,QAAQ,EACJ,OAAO,GACP,KAAK,GACL,cAAc,GACd,eAAe,GACf,KAAK,GACL,aAAa,CAAC;YAClB,QAAQ,CAAC,EAAE,KAAK,CAAC;SAClB,GACD;YAAE,QAAQ,EAAE,OAAO,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KAC7C;IACD;QACE,SAAS,EAAE,qBAAqB,CAAC;QACjC,SAAS,EAAE,SAAS,CAAC;KACtB;CACF,CAAC;AAEF,eAAO,MAAM,YAAY,gEAGvB,CAAC"}
@@ -14,6 +14,9 @@ export type AuthParams = {
14
14
  bundle: string;
15
15
  orgId?: string;
16
16
  isNewUser?: boolean;
17
+ } | {
18
+ type: "sms";
19
+ phone: string;
17
20
  } | {
18
21
  type: "passkey";
19
22
  email: string;
@@ -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,EAEV,iCAAiC,EACjC,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,mKAAmK;IACnK,SAAS,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAChC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;CAClC,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACtE;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,iCAAiC,CAAC;CAClD,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC;CAClB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,iCAAiC,CAAC;CAClD,GACD,CAAC;IACC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,GAAG,mBAAmB,GACrB,mBAAmB,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AAM,iBAAiB,GACzB,QAAQ,GACR,OAAO,GACP,UAAU,GACV,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAE7C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAS;IACnD;;;;;;;;;;;;;;;;;;;;OAoBG;gBAES,MAAM,EAAE,mBAAmB;CA+FxC"}
@@ -21,6 +21,7 @@ export declare enum AlchemySignerStatus {
21
21
  AUTHENTICATING_EMAIL = "AUTHENTICATING_EMAIL",
22
22
  AUTHENTICATING_OAUTH = "AUTHENTICATING_OAUTH",
23
23
  AWAITING_EMAIL_AUTH = "AWAITING_EMAIL_AUTH",
24
+ AWAITING_SMS_AUTH = "AWAITING_SMS_AUTH",
24
25
  AWAITING_OTP_AUTH = "AWAITING_OTP_AUTH",
25
26
  AWAITING_MFA_AUTH = "AWAITING_MFA_AUTH"
26
27
  }
@@ -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,G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B,YAAY,IAAI,IAAI,CAAC;IACrB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IACjD,gBAAgB,CAAC,SAAS,EAAE;QAC1B,WAAW,EAAE,OAAO,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,IAAI,CAAC;IACT,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/C,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,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;CACxC;AAED,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.52.4";
1
+ export declare const VERSION = "4.53.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.52.4",
3
+ "version": "4.53.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.4",
52
- "@account-kit/logging": "^4.52.4",
51
+ "@aa-sdk/core": "^4.53.0",
52
+ "@account-kit/logging": "^4.53.0",
53
53
  "@noble/curves": "^1.9.2",
54
54
  "@noble/hashes": "1.7.1",
55
55
  "@noble/secp256k1": "^2.3.0",
@@ -78,5 +78,5 @@
78
78
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
79
79
  },
80
80
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
81
- "gitHead": "313c33fc5987d77963a3187c93da45ab416a4bb8"
81
+ "gitHead": "69204fae71bcb30680f819d4af5ff95ee1f3a5f2"
82
82
  }
package/src/base.ts CHANGED
@@ -103,6 +103,16 @@ export type SignerConfig = {
103
103
  email: EmailConfig;
104
104
  };
105
105
 
106
+ type GetUserParams =
107
+ | {
108
+ type: "email";
109
+ value: string;
110
+ }
111
+ | {
112
+ type: "phone";
113
+ value: string;
114
+ };
115
+
106
116
  /**
107
117
  * Base abstract class for Alchemy Signer, providing authentication and session management for smart accounts.
108
118
  * Implements the `SmartAccountAuthenticator` interface and handles various signer events.
@@ -310,6 +320,8 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
310
320
  switch (type) {
311
321
  case "email":
312
322
  return this.authenticateWithEmail(params);
323
+ case "sms":
324
+ return this.authenticateWithSms(params);
313
325
  case "passkey":
314
326
  return this.authenticateWithPasskey(params);
315
327
  case "oauth":
@@ -355,6 +367,14 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
355
367
  });
356
368
  return;
357
369
  }
370
+ case "sms": {
371
+ // we just want to track the start of phone auth
372
+ SignerLogger.trackEvent({
373
+ name: "signer_authnticate",
374
+ data: { authType: "sms" },
375
+ });
376
+ return;
377
+ }
358
378
  case "passkey": {
359
379
  const isAnon = !("email" in params) && params.createNew == null;
360
380
  SignerLogger.trackEvent({
@@ -701,6 +721,8 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
701
721
  /**
702
722
  * Unauthenticated call to look up a user's organizationId by email
703
723
  *
724
+ * @deprecated Use getUser({ type: "email", value: email }) instead
725
+ *
704
726
  * @example
705
727
  * ```ts
706
728
  * import { AlchemyWebSigner } from "@account-kit/signer";
@@ -722,18 +744,82 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
722
744
  * @param {string} email the email to lookup
723
745
  * @returns {Promise<{orgId: string}>} the organization id for the user if they exist
724
746
  */
725
- getUser: (email: string) => Promise<{ orgId: string } | null> =
726
- SignerLogger.profiled("BaseAlchemySigner.getUser", async (email) => {
727
- const result = await this.inner.lookupUserByEmail(email);
728
-
729
- if (result.orgId == null) {
730
- return null;
731
- }
747
+ getUser(email: string): Promise<{ orgId: string } | null>;
748
+ /**
749
+ * Unauthenticated call to look up a user's organizationId by email or phone
750
+ *
751
+ * @example
752
+ * ```ts
753
+ * import { AlchemyWebSigner } from "@account-kit/signer";
754
+ *
755
+ * const signer = new AlchemyWebSigner({
756
+ * client: {
757
+ * connection: {
758
+ * rpcUrl: "/api/rpc",
759
+ * },
760
+ * iframeConfig: {
761
+ * iframeContainerId: "alchemy-signer-iframe-container",
762
+ * },
763
+ * },
764
+ * });
765
+ *
766
+ * const result = await signer.getUser({ type: "email", value: "foo@mail.com" });
767
+ * ```
768
+ *
769
+ * @param {string} email the email to lookup
770
+ * @returns {Promise<{orgId: string}>} the organization id for the user if they exist
771
+ */
772
+ getUser(params: GetUserParams): Promise<{ orgId: string } | null>;
773
+ /**
774
+ * Unauthenticated call to look up a user's organizationId by email or phone
775
+ *
776
+ * @example
777
+ * ```ts
778
+ * import { AlchemyWebSigner } from "@account-kit/signer";
779
+ *
780
+ * const signer = new AlchemyWebSigner({
781
+ * client: {
782
+ * connection: {
783
+ * rpcUrl: "/api/rpc",
784
+ * },
785
+ * iframeConfig: {
786
+ * iframeContainerId: "alchemy-signer-iframe-container",
787
+ * },
788
+ * },
789
+ * });
790
+ *
791
+ * const result = await signer.getUser({ type: "email", value: "foo@mail.com" });
792
+ * ```
793
+ *
794
+ * @param {string | GetUserParams} params the params to look up
795
+ * @returns {Promise<{orgId: string}>} the organization id for the user if they exist
796
+ */
797
+ getUser(params: string | GetUserParams): Promise<{ orgId: string } | null> {
798
+ return SignerLogger.profiled(
799
+ "BaseAlchemySigner.getUser",
800
+ async (params: string | GetUserParams) => {
801
+ const _params =
802
+ typeof params === "string"
803
+ ? { type: "email" as const, value: params }
804
+ : params;
805
+
806
+ const result =
807
+ _params.type === "email"
808
+ ? await this.inner.lookupUserByEmail(_params.value)
809
+ : _params.type === "phone"
810
+ ? await this.inner.lookupUserByPhone(_params.value)
811
+ : assertNever(_params, "unhandled get user params");
812
+
813
+ if (result?.orgId == null) {
814
+ return null;
815
+ }
732
816
 
733
- return {
734
- orgId: result.orgId,
735
- };
736
- });
817
+ return {
818
+ orgId: result.orgId,
819
+ };
820
+ },
821
+ )(params);
822
+ }
737
823
 
738
824
  /*
739
825
  * Sets the email for the authenticated user, allowing them to login with that
@@ -975,13 +1061,39 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
975
1061
  return this.waitForConnected();
976
1062
  };
977
1063
 
1064
+ private authenticateWithSms = async (
1065
+ params: Extract<AuthParams, { type: "sms" }>,
1066
+ ): Promise<User> => {
1067
+ const { orgId, otpId, isNewUser } = await this.initOrCreateSmsUser(
1068
+ params.phone,
1069
+ );
1070
+
1071
+ this.setAwaitingSmsAuth({ orgId, otpId, isNewUser });
1072
+
1073
+ // TODO: add phone auth linking
1074
+ // // Clear the auth linking status if the email has changed. This would mean
1075
+ // // that the previously initiated social login is not associated with the
1076
+ // // email which is now being used to login.
1077
+ // const { authLinkingStatus } = this.store.getState();
1078
+ // if (authLinkingStatus && authLinkingStatus.email !== params.email) {
1079
+ // this.store.setState({ authLinkingStatus: undefined });
1080
+ // }
1081
+
1082
+ // We wait for the session manager to emit a connected event if
1083
+ // cross tab sessions are permitted
1084
+ return this.waitForConnected();
1085
+ };
1086
+
978
1087
  private authenticateWithPasskey = async (
979
1088
  args: Extract<AuthParams, { type: "passkey" }>,
980
1089
  ): Promise<User> => {
981
1090
  let user: User;
982
1091
  const shouldCreateNew = async () => {
983
1092
  if ("email" in args) {
984
- const existingUser = await this.getUser(args.email);
1093
+ const existingUser = await this.getUser({
1094
+ type: "email",
1095
+ value: args.email,
1096
+ });
985
1097
  return existingUser == null;
986
1098
  }
987
1099
 
@@ -1175,6 +1287,26 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
1175
1287
  });
1176
1288
  };
1177
1289
 
1290
+ private setAwaitingSmsAuth = ({
1291
+ orgId,
1292
+ otpId,
1293
+ isNewUser,
1294
+ }: {
1295
+ orgId: string;
1296
+ otpId?: string;
1297
+ isNewUser?: boolean;
1298
+ }): void => {
1299
+ this.sessionManager.setTemporarySession({
1300
+ orgId,
1301
+ isNewUser,
1302
+ });
1303
+ this.store.setState({
1304
+ status: AlchemySignerStatus.AWAITING_SMS_AUTH,
1305
+ otpId,
1306
+ error: null,
1307
+ });
1308
+ };
1309
+
1178
1310
  private handleOauthReturn = ({
1179
1311
  bundle,
1180
1312
  orgId,
@@ -1265,6 +1397,8 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
1265
1397
  case "otp":
1266
1398
  case "otpVerify":
1267
1399
  return AlchemySignerStatus.AWAITING_OTP_AUTH;
1400
+ case "sms":
1401
+ return AlchemySignerStatus.AWAITING_SMS_AUTH;
1268
1402
  default:
1269
1403
  assertNever(type, "unhandled authenticating type");
1270
1404
  }
@@ -1329,6 +1463,35 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
1329
1463
  };
1330
1464
  }
1331
1465
 
1466
+ private async initOrCreateSmsUser(phone: string): Promise<{
1467
+ orgId: string;
1468
+ otpId?: string;
1469
+ isNewUser: boolean;
1470
+ }> {
1471
+ const existingUser = await this.getUser({ type: "phone", value: phone });
1472
+
1473
+ if (existingUser) {
1474
+ const { orgId, otpId } = await this.inner.initSmsAuth({
1475
+ phone,
1476
+ });
1477
+ return {
1478
+ orgId,
1479
+ otpId,
1480
+ isNewUser: false,
1481
+ };
1482
+ }
1483
+
1484
+ const { orgId, otpId } = await this.inner.createAccount({
1485
+ type: "sms",
1486
+ phone,
1487
+ });
1488
+ return {
1489
+ orgId,
1490
+ otpId,
1491
+ isNewUser: true,
1492
+ };
1493
+ }
1494
+
1332
1495
  private async completeEmailAuth(
1333
1496
  params: Extract<AuthParams, { type: "email"; bundle: string }>,
1334
1497
  ): Promise<User> {
@@ -47,6 +47,7 @@ import type {
47
47
  OauthProviderInfo,
48
48
  IdTokenOnly,
49
49
  AuthMethods,
50
+ SmsAuthParams,
50
51
  } from "./types.js";
51
52
  import { VERSION } from "../version.js";
52
53
  import { secp256k1 } from "@noble/curves/secp256k1";
@@ -182,6 +183,18 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
182
183
  return response;
183
184
  }
184
185
 
186
+ if (params.type === "sms") {
187
+ this.eventEmitter.emit("authenticating", { type: "otp" });
188
+ const { phone } = params;
189
+ const publicKey = await this.initSessionStamper();
190
+
191
+ const response = await this.request("/v1/signup", {
192
+ phone,
193
+ targetPublicKey: publicKey,
194
+ });
195
+ return response;
196
+ }
197
+
185
198
  this.eventEmitter.emit("authenticating", { type: "passkey" });
186
199
  // Passkey account creation flow
187
200
  const { attestation, challenge } = await this.getWebAuthnAttestation(
@@ -218,6 +231,10 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
218
231
  params: Omit<EmailAuthParams, "targetPublicKey">,
219
232
  ): Promise<{ orgId: string; otpId?: string; multiFactors?: MfaFactor[] }>;
220
233
 
234
+ public abstract initSmsAuth(
235
+ params: Omit<SmsAuthParams, "targetPublicKey">,
236
+ ): Promise<{ orgId: string; otpId?: string }>;
237
+
221
238
  public abstract completeAuthWithBundle(params: {
222
239
  bundle: string;
223
240
  orgId: string;
@@ -645,6 +662,16 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
645
662
  return this.request("/v1/lookup", { email });
646
663
  };
647
664
 
665
+ /**
666
+ * Looks up information based on a phone number.
667
+ *
668
+ * @param {string} phone the phone number to look up
669
+ * @returns {Promise<any>} the result of the lookup request
670
+ */
671
+ public lookupUserByPhone = async (phone: string) => {
672
+ return this.request("/v1/lookup", { phone });
673
+ };
674
+
648
675
  /**
649
676
  * This will sign a message with the user's private key, without doing any transformations on the message.
650
677
  * For SignMessage or SignTypedData, the caller should hash the message before calling this method and pass
@@ -19,6 +19,7 @@ import type {
19
19
  AuthLinkingPrompt,
20
20
  GetWebAuthnAttestationResult,
21
21
  IdTokenOnly,
22
+ SmsAuthParams,
22
23
  } from "./types.js";
23
24
  import { MfaRequiredError } from "../errors.js";
24
25
  import { parseMfaError } from "../utils/parseMfaError.js";
@@ -160,6 +161,42 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
160
161
  }
161
162
  };
162
163
 
164
+ /**
165
+ * Begin authenticating a user through sms. Initializes the iframe stamper to get the target public key.
166
+ * This method sends a text message to the user to complete their login
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { AlchemySignerWebClient } from "@account-kit/signer";
171
+ *
172
+ * const client = new AlchemySignerWebClient({
173
+ * connection: {
174
+ * apiKey: "your-api-key",
175
+ * },
176
+ * iframeConfig: {
177
+ * iframeContainerId: "signer-iframe-container",
178
+ * },
179
+ * });
180
+ *
181
+ * const account = await client.initSmsAuth({ phone: "+1234567890" });
182
+ * ```
183
+ *
184
+ * @param {Omit<SmsAuthParams, "targetPublicKey">} params The parameters for sms authentication, excluding the target public key
185
+ * @returns {Promise<any>} The response from the authentication request
186
+ */
187
+ public override initSmsAuth = async (
188
+ params: Omit<SmsAuthParams, "targetPublicKey">,
189
+ ) => {
190
+ this.eventEmitter.emit("authenticating", { type: "otp" });
191
+ const { phone } = params;
192
+ const publicKey = await this.initSessionStamper();
193
+
194
+ return this.request("/v1/auth", {
195
+ phone,
196
+ targetPublicKey: publicKey,
197
+ });
198
+ };
199
+
163
200
  /**
164
201
  * Authenticates using an OTP code which was previously received via email.
165
202
  *
@@ -38,6 +38,10 @@ export type CreateAccountParams =
38
38
  expirationSeconds?: number;
39
39
  redirectParams?: URLSearchParams;
40
40
  }
41
+ | {
42
+ type: "sms";
43
+ phone: string;
44
+ }
41
45
  | {
42
46
  type: "passkey";
43
47
  email: string;
@@ -61,6 +65,11 @@ export type EmailAuthParams = {
61
65
  multiFactors?: VerifyMfaParams[];
62
66
  };
63
67
 
68
+ export type SmsAuthParams = {
69
+ phone: string;
70
+ targetPublicKey: string;
71
+ };
72
+
64
73
  export type OauthParams = Extract<AuthParams, { type: "oauth" }> & {
65
74
  expirationSeconds?: number;
66
75
  fetchIdTokenOnly?: boolean;
@@ -131,6 +140,7 @@ export type SignerEndpoints = [
131
140
  | (Omit<EmailAuthParams, "redirectParams"> & {
132
141
  redirectParams?: string;
133
142
  })
143
+ | SmsAuthParams
134
144
  | {
135
145
  passkey: {
136
146
  challenge: string;
@@ -148,10 +158,12 @@ export type SignerEndpoints = [
148
158
  },
149
159
  {
150
160
  Route: "/v1/auth";
151
- Body: Omit<EmailAuthParams, "redirectParams"> & {
152
- redirectParams?: string;
153
- multiFactors?: VerifyMfaParams[];
154
- };
161
+ Body:
162
+ | (Omit<EmailAuthParams, "redirectParams"> & {
163
+ redirectParams?: string;
164
+ multiFactors?: VerifyMfaParams[];
165
+ })
166
+ | SmsAuthParams;
155
167
  Response: {
156
168
  orgId: string;
157
169
  otpId?: string;
@@ -161,7 +173,8 @@ export type SignerEndpoints = [
161
173
  {
162
174
  Route: "/v1/lookup";
163
175
  Body: {
164
- email: string;
176
+ email?: string;
177
+ phone?: string;
165
178
  };
166
179
  Response: {
167
180
  orgId: string | null;
@@ -334,7 +347,7 @@ export type SignerEndpoints = [
334
347
  ];
335
348
 
336
349
  export type AuthenticatingEventMetadata = {
337
- type: "email" | "passkey" | "oauth" | "otp" | "otpVerify";
350
+ type: "email" | "passkey" | "oauth" | "otp" | "otpVerify" | "sms";
338
351
  };
339
352
 
340
353
  export type AlchemySignerClientEvents = {
package/src/metrics.ts CHANGED
@@ -8,6 +8,7 @@ export type SignerEventsSchema = [
8
8
  | {
9
9
  authType:
10
10
  | "email"
11
+ | "sms"
11
12
  | "passkey_anon"
12
13
  | "passkey_email"
13
14
  | "otp"
package/src/signer.ts CHANGED
@@ -21,6 +21,10 @@ export type AuthParams =
21
21
  multiFactors?: VerifyMfaParams[];
22
22
  }
23
23
  | { type: "email"; bundle: string; orgId?: string; isNewUser?: boolean }
24
+ | {
25
+ type: "sms";
26
+ phone: string;
27
+ }
24
28
  | {
25
29
  type: "passkey";
26
30
  email: string;
package/src/types.ts CHANGED
@@ -24,6 +24,7 @@ export enum AlchemySignerStatus {
24
24
  AUTHENTICATING_EMAIL = "AUTHENTICATING_EMAIL",
25
25
  AUTHENTICATING_OAUTH = "AUTHENTICATING_OAUTH",
26
26
  AWAITING_EMAIL_AUTH = "AWAITING_EMAIL_AUTH",
27
+ AWAITING_SMS_AUTH = "AWAITING_SMS_AUTH",
27
28
  AWAITING_OTP_AUTH = "AWAITING_OTP_AUTH",
28
29
  AWAITING_MFA_AUTH = "AWAITING_MFA_AUTH",
29
30
  }
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.52.4";
3
+ export const VERSION = "4.53.0";