@account-kit/signer 4.52.4 → 4.53.1-alpha.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 (62) 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/index.d.ts +1 -0
  13. package/dist/esm/index.js +1 -0
  14. package/dist/esm/index.js.map +1 -1
  15. package/dist/esm/metrics.d.ts +1 -1
  16. package/dist/esm/metrics.js.map +1 -1
  17. package/dist/esm/signer.d.ts +3 -0
  18. package/dist/esm/signer.js.map +1 -1
  19. package/dist/esm/solanaSigner.js +2 -40
  20. package/dist/esm/solanaSigner.js.map +1 -1
  21. package/dist/esm/types.d.ts +1 -0
  22. package/dist/esm/types.js +1 -0
  23. package/dist/esm/types.js.map +1 -1
  24. package/dist/esm/utils/solana.d.ts +21 -0
  25. package/dist/esm/utils/solana.js +72 -0
  26. package/dist/esm/utils/solana.js.map +1 -0
  27. package/dist/esm/version.d.ts +1 -1
  28. package/dist/esm/version.js +1 -1
  29. package/dist/esm/version.js.map +1 -1
  30. package/dist/types/base.d.ts +41 -1
  31. package/dist/types/base.d.ts.map +1 -1
  32. package/dist/types/client/base.d.ts +14 -1
  33. package/dist/types/client/base.d.ts.map +1 -1
  34. package/dist/types/client/index.d.ts +29 -1
  35. package/dist/types/client/index.d.ts.map +1 -1
  36. package/dist/types/client/types.d.ts +13 -5
  37. package/dist/types/client/types.d.ts.map +1 -1
  38. package/dist/types/index.d.ts +1 -0
  39. package/dist/types/index.d.ts.map +1 -1
  40. package/dist/types/metrics.d.ts +1 -1
  41. package/dist/types/metrics.d.ts.map +1 -1
  42. package/dist/types/signer.d.ts +3 -0
  43. package/dist/types/signer.d.ts.map +1 -1
  44. package/dist/types/solanaSigner.d.ts.map +1 -1
  45. package/dist/types/types.d.ts +1 -0
  46. package/dist/types/types.d.ts.map +1 -1
  47. package/dist/types/utils/solana.d.ts +22 -0
  48. package/dist/types/utils/solana.d.ts.map +1 -0
  49. package/dist/types/version.d.ts +1 -1
  50. package/dist/types/version.d.ts.map +1 -1
  51. package/package.json +4 -4
  52. package/src/base.ts +175 -12
  53. package/src/client/base.ts +27 -0
  54. package/src/client/index.ts +37 -0
  55. package/src/client/types.ts +19 -6
  56. package/src/index.ts +4 -0
  57. package/src/metrics.ts +1 -0
  58. package/src/signer.ts +4 -0
  59. package/src/solanaSigner.ts +5 -49
  60. package/src/types.ts +1 -0
  61. package/src/utils/solana.ts +100 -0
  62. package/src/version.ts +1 -1
@@ -26,6 +26,9 @@ export type CreateAccountParams = {
26
26
  emailMode?: EmailType;
27
27
  expirationSeconds?: number;
28
28
  redirectParams?: URLSearchParams;
29
+ } | {
30
+ type: "sms";
31
+ phone: string;
29
32
  } | {
30
33
  type: "passkey";
31
34
  email: string;
@@ -45,6 +48,10 @@ export type EmailAuthParams = {
45
48
  redirectParams?: URLSearchParams;
46
49
  multiFactors?: VerifyMfaParams[];
47
50
  };
51
+ export type SmsAuthParams = {
52
+ phone: string;
53
+ targetPublicKey: string;
54
+ };
48
55
  export type OauthParams = Extract<AuthParams, {
49
56
  type: "oauth";
50
57
  }> & {
@@ -102,7 +109,7 @@ export type SignerEndpoints = [
102
109
  Route: "/v1/signup";
103
110
  Body: (Omit<EmailAuthParams, "redirectParams"> & {
104
111
  redirectParams?: string;
105
- }) | {
112
+ }) | SmsAuthParams | {
106
113
  passkey: {
107
114
  challenge: string;
108
115
  attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;
@@ -119,10 +126,10 @@ export type SignerEndpoints = [
119
126
  },
120
127
  {
121
128
  Route: "/v1/auth";
122
- Body: Omit<EmailAuthParams, "redirectParams"> & {
129
+ Body: (Omit<EmailAuthParams, "redirectParams"> & {
123
130
  redirectParams?: string;
124
131
  multiFactors?: VerifyMfaParams[];
125
- };
132
+ }) | SmsAuthParams;
126
133
  Response: {
127
134
  orgId: string;
128
135
  otpId?: string;
@@ -132,7 +139,8 @@ export type SignerEndpoints = [
132
139
  {
133
140
  Route: "/v1/lookup";
134
141
  Body: {
135
- email: string;
142
+ email?: string;
143
+ phone?: string;
136
144
  };
137
145
  Response: {
138
146
  orgId: string | null;
@@ -306,7 +314,7 @@ export type SignerEndpoints = [
306
314
  }
307
315
  ];
308
316
  export type AuthenticatingEventMetadata = {
309
- type: "email" | "passkey" | "oauth" | "otp" | "otpVerify";
317
+ type: "email" | "passkey" | "oauth" | "otp" | "otpVerify" | "sms";
310
318
  };
311
319
  export type AlchemySignerClientEvents = {
312
320
  connected(user: User): void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"@aa-sdk/core\";\nimport type {\n TSignedRequest,\n TurnkeyApiTypes,\n getWebAuthnAttestation,\n} from \"@turnkey/http\";\nimport type { Hex } from \"viem\";\nimport type { AuthParams } from \"../signer\";\n\nexport type CredentialCreationOptionOverrides = {\n publicKey?: Partial<CredentialCreationOptions[\"publicKey\"]>;\n} & Pick<CredentialCreationOptions, \"signal\">;\n\n// [!region User]\nexport type User = {\n email?: string;\n orgId: string;\n userId: string;\n address: Address;\n solanaAddress?: string;\n credentialId?: string;\n idToken?: string;\n claims?: Record<string, unknown>;\n};\n// [!endregion User]\n\nexport type ExportWalletParams = {\n iframeContainerId: string;\n iframeElementId?: string;\n};\n\nexport type CreateAccountParams =\n | {\n type: \"email\";\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n redirectParams?: URLSearchParams;\n }\n | {\n type: \"passkey\";\n email: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | {\n type: \"passkey\";\n username: string;\n creationOpts?: CredentialCreationOptionOverrides;\n };\n\nexport type EmailType = \"magicLink\" | \"otp\";\n\nexport type EmailAuthParams = {\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n targetPublicKey: string;\n redirectParams?: URLSearchParams;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type OauthParams = Extract<AuthParams, { type: \"oauth\" }> & {\n expirationSeconds?: number;\n fetchIdTokenOnly?: boolean;\n};\n\nexport type OtpParams = {\n orgId: string;\n otpId: string;\n otpCode: string;\n targetPublicKey: string;\n expirationSeconds?: number;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type OtpResponse =\n | {\n status: \"SUCCESS\";\n credentialBundle: string;\n }\n | {\n status: \"MFA_REQUIRED\";\n encryptedPayload: string;\n multiFactors: MfaFactor[];\n };\n\nexport type SignupResponse = {\n orgId: string;\n userId?: string;\n address?: Address;\n otpId?: string;\n};\n\nexport type OauthConfig = {\n codeChallenge: string;\n requestKey: string;\n authProviders: AuthProviderConfig[];\n};\n\nexport type EmailConfig = {\n mode?: \"MAGIC_LINK\" | \"OTP\";\n};\n\nexport type SignerConfig = {\n email: EmailConfig;\n};\n\nexport type AuthProviderConfig = {\n id: string;\n isCustomProvider?: boolean;\n clientId: string;\n authEndpoint: string;\n};\n\nexport type SignerRoutes = SignerEndpoints[number][\"Route\"];\nexport type SignerBody<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Body\"];\nexport type SignerResponse<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Response\"];\n\nexport type SignerEndpoints = [\n {\n Route: \"/v1/signup\";\n Body:\n | (Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n })\n | {\n passkey: {\n challenge: string;\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n };\n };\n Response: SignupResponse;\n },\n {\n Route: \"/v1/whoami\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: User;\n },\n {\n Route: \"/v1/auth\";\n Body: Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n multiFactors?: VerifyMfaParams[];\n };\n Response: {\n orgId: string;\n otpId?: string;\n multiFactors?: MfaFactor[];\n };\n },\n {\n Route: \"/v1/lookup\";\n Body: {\n email: string;\n };\n Response: {\n orgId: string | null;\n };\n },\n {\n Route: \"/v1/sign-payload\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n signature: Hex;\n };\n },\n {\n Route: \"/v1/update-email-auth\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: void;\n },\n {\n Route: \"/v1/add-oauth-provider\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: { oauthProviders: OauthProviderInfo[] };\n },\n {\n Route: \"/v1/remove-oauth-provider\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: void;\n },\n {\n Route: \"/v1/list-auth-methods\";\n Body: {};\n Response: AuthMethods;\n },\n {\n Route: \"/v1/prepare-oauth\";\n Body: {\n nonce: string;\n };\n Response: OauthConfig;\n },\n {\n Route: \"/v1/otp\";\n Body: OtpParams;\n Response: OtpResponse;\n },\n {\n Route: \"/v1/auth-list-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-delete-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorIds: string[];\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-request-multi-factor\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorType: MultiFactorType;\n };\n Response: AddMfaResult;\n },\n {\n Route: \"/v1/auth-verify-multi-factor\";\n Body: VerifyMfaParams & {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/signer-config\";\n Body: {};\n Response: SignerConfig;\n },\n {\n Route: \"/v1/auth-validate-multi-factors\";\n Body: {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n };\n Response: {\n payload: {\n credentialBundle?: string;\n };\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/multi-owner-create\";\n Body: {\n members: {\n evmSignerAddress: Address;\n }[];\n };\n Response: {\n result: {\n orgId: string;\n evmSignerAddress: Address;\n members: {\n evmSignerAddress: Address;\n }[];\n };\n };\n },\n {\n Route: \"/v1/multi-owner-prepare-add\";\n Body: {\n organizationId: string;\n members: {\n evmSignerAddress: Address;\n }[];\n };\n Response: {\n result: TurnkeyApiTypes[\"v1CreateUsersRequest\"];\n };\n },\n {\n Route: \"/v1/multi-owner-add\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n result: {\n members: {\n evmSignerAddress: Address;\n }[];\n updateRootQuorumRequest: TurnkeyApiTypes[\"v1UpdateRootQuorumRequest\"];\n };\n };\n },\n {\n Route: \"/v1/multi-owner-update-root-quorum\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n result: TurnkeyApiTypes[\"v1UpdateRootQuorumResult\"];\n };\n },\n {\n Route: \"/v1/multi-owner-sign-raw-payload\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n result: {\n signRawPayloadResult: TurnkeyApiTypes[\"v1SignRawPayloadResult\"];\n };\n };\n },\n];\n\nexport type AuthenticatingEventMetadata = {\n type: \"email\" | \"passkey\" | \"oauth\" | \"otp\" | \"otpVerify\";\n};\n\nexport type AlchemySignerClientEvents = {\n connected(user: User): void;\n newUserSignup(): void;\n authenticating(data: AuthenticatingEventMetadata): void;\n connectedEmail(user: User, bundle: string): void;\n connectedPasskey(user: User): void;\n connectedOauth(user: User, bundle: string): void;\n connectedOtp(user: User, bundle: string): void;\n disconnected(): void;\n};\n\nexport type AlchemySignerClientEvent = keyof AlchemySignerClientEvents;\n\nexport type GetWebAuthnAttestationResult = {\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n challenge: ArrayBuffer | string;\n authenticatorUserId: BufferSource;\n};\n\nexport type AuthLinkingPrompt = {\n status: \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\";\n idToken: string;\n email: string;\n providerName: string;\n otpId: string;\n orgId: string;\n};\n\nexport type IdTokenOnly = {\n status: \"FETCHED_ID_TOKEN_ONLY\";\n idToken: string;\n providerName: string;\n};\n\nexport type OauthState = {\n authProviderId: string;\n isCustomProvider?: boolean;\n requestKey: string;\n turnkeyPublicKey: string;\n expirationSeconds?: number;\n redirectUrl?: string;\n openerOrigin?: string;\n fetchIdTokenOnly?: boolean;\n};\n\nexport type GetOauthProviderUrlArgs = {\n oauthParams: OauthParams;\n turnkeyPublicKey: string;\n oauthCallbackUrl: string;\n oauthConfig?: OauthConfig;\n usesRelativeUrl?: boolean;\n};\n\nexport type MfaFactor = {\n multiFactorId: string;\n multiFactorType: string;\n};\n\ntype MultiFactorType = \"totp\";\n\nexport type AddMfaParams = {\n multiFactorType: MultiFactorType;\n};\n\nexport type AddMfaResult = {\n multiFactorType: MultiFactorType;\n multiFactorId: string;\n multiFactorTotpUrl: string;\n};\n\nexport type VerifyMfaParams = {\n multiFactorId: string;\n multiFactorCode: string;\n};\n\nexport type RemoveMfaParams = {\n multiFactorIds: string[];\n};\n\nexport type ValidateMultiFactorsParams = {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n};\n\nexport type MfaChallenge = {\n multiFactorId: string;\n multiFactorChallenge:\n | {\n code: string;\n }\n | Record<string, any>;\n};\n\nexport type SubmitOtpCodeResponse =\n | { bundle: string; mfaRequired: false }\n | { mfaRequired: true; encryptedPayload: string; multiFactors: MfaFactor[] };\n\nexport type AddOauthProviderParams = {\n providerName: string;\n oidcToken: string;\n};\n\nexport type AuthMethods = {\n email?: string;\n oauthProviders: OauthProviderInfo[];\n passkeys: PasskeyInfo[];\n};\n\nexport type OauthProviderInfo = {\n providerId: string;\n issuer: string;\n providerName?: string;\n userDisplayName?: string;\n};\n\nexport type PasskeyInfo = {\n authenticatorId: string;\n name: string;\n createdAt: number;\n};\n\nexport type experimental_CreateApiKeyParams = {\n name: string;\n publicKey: string;\n expirationSec: number;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"@aa-sdk/core\";\nimport type {\n TSignedRequest,\n TurnkeyApiTypes,\n getWebAuthnAttestation,\n} from \"@turnkey/http\";\nimport type { Hex } from \"viem\";\nimport type { AuthParams } from \"../signer\";\n\nexport type CredentialCreationOptionOverrides = {\n publicKey?: Partial<CredentialCreationOptions[\"publicKey\"]>;\n} & Pick<CredentialCreationOptions, \"signal\">;\n\n// [!region User]\nexport type User = {\n email?: string;\n orgId: string;\n userId: string;\n address: Address;\n solanaAddress?: string;\n credentialId?: string;\n idToken?: string;\n claims?: Record<string, unknown>;\n};\n// [!endregion User]\n\nexport type ExportWalletParams = {\n iframeContainerId: string;\n iframeElementId?: string;\n};\n\nexport type CreateAccountParams =\n | {\n type: \"email\";\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n redirectParams?: URLSearchParams;\n }\n | {\n type: \"sms\";\n phone: string;\n }\n | {\n type: \"passkey\";\n email: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | {\n type: \"passkey\";\n username: string;\n creationOpts?: CredentialCreationOptionOverrides;\n };\n\nexport type EmailType = \"magicLink\" | \"otp\";\n\nexport type EmailAuthParams = {\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n targetPublicKey: string;\n redirectParams?: URLSearchParams;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type SmsAuthParams = {\n phone: string;\n targetPublicKey: string;\n};\n\nexport type OauthParams = Extract<AuthParams, { type: \"oauth\" }> & {\n expirationSeconds?: number;\n fetchIdTokenOnly?: boolean;\n};\n\nexport type OtpParams = {\n orgId: string;\n otpId: string;\n otpCode: string;\n targetPublicKey: string;\n expirationSeconds?: number;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type OtpResponse =\n | {\n status: \"SUCCESS\";\n credentialBundle: string;\n }\n | {\n status: \"MFA_REQUIRED\";\n encryptedPayload: string;\n multiFactors: MfaFactor[];\n };\n\nexport type SignupResponse = {\n orgId: string;\n userId?: string;\n address?: Address;\n otpId?: string;\n};\n\nexport type OauthConfig = {\n codeChallenge: string;\n requestKey: string;\n authProviders: AuthProviderConfig[];\n};\n\nexport type EmailConfig = {\n mode?: \"MAGIC_LINK\" | \"OTP\";\n};\n\nexport type SignerConfig = {\n email: EmailConfig;\n};\n\nexport type AuthProviderConfig = {\n id: string;\n isCustomProvider?: boolean;\n clientId: string;\n authEndpoint: string;\n};\n\nexport type SignerRoutes = SignerEndpoints[number][\"Route\"];\nexport type SignerBody<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Body\"];\nexport type SignerResponse<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Response\"];\n\nexport type SignerEndpoints = [\n {\n Route: \"/v1/signup\";\n Body:\n | (Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n })\n | SmsAuthParams\n | {\n passkey: {\n challenge: string;\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n };\n };\n Response: SignupResponse;\n },\n {\n Route: \"/v1/whoami\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: User;\n },\n {\n Route: \"/v1/auth\";\n Body:\n | (Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n multiFactors?: VerifyMfaParams[];\n })\n | SmsAuthParams;\n Response: {\n orgId: string;\n otpId?: string;\n multiFactors?: MfaFactor[];\n };\n },\n {\n Route: \"/v1/lookup\";\n Body: {\n email?: string;\n phone?: string;\n };\n Response: {\n orgId: string | null;\n };\n },\n {\n Route: \"/v1/sign-payload\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n signature: Hex;\n };\n },\n {\n Route: \"/v1/update-email-auth\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: void;\n },\n {\n Route: \"/v1/add-oauth-provider\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: { oauthProviders: OauthProviderInfo[] };\n },\n {\n Route: \"/v1/remove-oauth-provider\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: void;\n },\n {\n Route: \"/v1/list-auth-methods\";\n Body: {};\n Response: AuthMethods;\n },\n {\n Route: \"/v1/prepare-oauth\";\n Body: {\n nonce: string;\n };\n Response: OauthConfig;\n },\n {\n Route: \"/v1/otp\";\n Body: OtpParams;\n Response: OtpResponse;\n },\n {\n Route: \"/v1/auth-list-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-delete-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorIds: string[];\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-request-multi-factor\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorType: MultiFactorType;\n };\n Response: AddMfaResult;\n },\n {\n Route: \"/v1/auth-verify-multi-factor\";\n Body: VerifyMfaParams & {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/signer-config\";\n Body: {};\n Response: SignerConfig;\n },\n {\n Route: \"/v1/auth-validate-multi-factors\";\n Body: {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n };\n Response: {\n payload: {\n credentialBundle?: string;\n };\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/multi-owner-create\";\n Body: {\n members: {\n evmSignerAddress: Address;\n }[];\n };\n Response: {\n result: {\n orgId: string;\n evmSignerAddress: Address;\n members: {\n evmSignerAddress: Address;\n }[];\n };\n };\n },\n {\n Route: \"/v1/multi-owner-prepare-add\";\n Body: {\n organizationId: string;\n members: {\n evmSignerAddress: Address;\n }[];\n };\n Response: {\n result: TurnkeyApiTypes[\"v1CreateUsersRequest\"];\n };\n },\n {\n Route: \"/v1/multi-owner-add\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n result: {\n members: {\n evmSignerAddress: Address;\n }[];\n updateRootQuorumRequest: TurnkeyApiTypes[\"v1UpdateRootQuorumRequest\"];\n };\n };\n },\n {\n Route: \"/v1/multi-owner-update-root-quorum\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n result: TurnkeyApiTypes[\"v1UpdateRootQuorumResult\"];\n };\n },\n {\n Route: \"/v1/multi-owner-sign-raw-payload\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n result: {\n signRawPayloadResult: TurnkeyApiTypes[\"v1SignRawPayloadResult\"];\n };\n };\n },\n];\n\nexport type AuthenticatingEventMetadata = {\n type: \"email\" | \"passkey\" | \"oauth\" | \"otp\" | \"otpVerify\" | \"sms\";\n};\n\nexport type AlchemySignerClientEvents = {\n connected(user: User): void;\n newUserSignup(): void;\n authenticating(data: AuthenticatingEventMetadata): void;\n connectedEmail(user: User, bundle: string): void;\n connectedPasskey(user: User): void;\n connectedOauth(user: User, bundle: string): void;\n connectedOtp(user: User, bundle: string): void;\n disconnected(): void;\n};\n\nexport type AlchemySignerClientEvent = keyof AlchemySignerClientEvents;\n\nexport type GetWebAuthnAttestationResult = {\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n challenge: ArrayBuffer | string;\n authenticatorUserId: BufferSource;\n};\n\nexport type AuthLinkingPrompt = {\n status: \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\";\n idToken: string;\n email: string;\n providerName: string;\n otpId: string;\n orgId: string;\n};\n\nexport type IdTokenOnly = {\n status: \"FETCHED_ID_TOKEN_ONLY\";\n idToken: string;\n providerName: string;\n};\n\nexport type OauthState = {\n authProviderId: string;\n isCustomProvider?: boolean;\n requestKey: string;\n turnkeyPublicKey: string;\n expirationSeconds?: number;\n redirectUrl?: string;\n openerOrigin?: string;\n fetchIdTokenOnly?: boolean;\n};\n\nexport type GetOauthProviderUrlArgs = {\n oauthParams: OauthParams;\n turnkeyPublicKey: string;\n oauthCallbackUrl: string;\n oauthConfig?: OauthConfig;\n usesRelativeUrl?: boolean;\n};\n\nexport type MfaFactor = {\n multiFactorId: string;\n multiFactorType: string;\n};\n\ntype MultiFactorType = \"totp\";\n\nexport type AddMfaParams = {\n multiFactorType: MultiFactorType;\n};\n\nexport type AddMfaResult = {\n multiFactorType: MultiFactorType;\n multiFactorId: string;\n multiFactorTotpUrl: string;\n};\n\nexport type VerifyMfaParams = {\n multiFactorId: string;\n multiFactorCode: string;\n};\n\nexport type RemoveMfaParams = {\n multiFactorIds: string[];\n};\n\nexport type ValidateMultiFactorsParams = {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n};\n\nexport type MfaChallenge = {\n multiFactorId: string;\n multiFactorChallenge:\n | {\n code: string;\n }\n | Record<string, any>;\n};\n\nexport type SubmitOtpCodeResponse =\n | { bundle: string; mfaRequired: false }\n | { mfaRequired: true; encryptedPayload: string; multiFactors: MfaFactor[] };\n\nexport type AddOauthProviderParams = {\n providerName: string;\n oidcToken: string;\n};\n\nexport type AuthMethods = {\n email?: string;\n oauthProviders: OauthProviderInfo[];\n passkeys: PasskeyInfo[];\n};\n\nexport type OauthProviderInfo = {\n providerId: string;\n issuer: string;\n providerName?: string;\n userDisplayName?: string;\n};\n\nexport type PasskeyInfo = {\n authenticatorId: string;\n name: string;\n createdAt: number;\n};\n\nexport type experimental_CreateApiKeyParams = {\n name: string;\n publicKey: string;\n expirationSec: number;\n};\n"]}
@@ -10,3 +10,4 @@ export type * from "./solanaSigner.js";
10
10
  export type * from "./types.js";
11
11
  export { AlchemySignerStatus } from "./types.js";
12
12
  export { SolanaSigner } from "./solanaSigner.js";
13
+ export { createSolanaSponsoredTransaction, createSolanaTransaction, } from "./utils/solana.js";
package/dist/esm/index.js CHANGED
@@ -6,4 +6,5 @@ export { DEFAULT_SESSION_MS, SessionManagerParamsSchema, } from "./session/manag
6
6
  export { AlchemyWebSigner } from "./signer.js";
7
7
  export { AlchemySignerStatus } from "./types.js";
8
8
  export { SolanaSigner } from "./solanaSigner.js";
9
+ export { createSolanaSponsoredTransaction, createSolanaTransaction, } from "./utils/solana.js";
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { BaseAlchemySigner } from \"./base.js\";\nexport { BaseSignerClient } from \"./client/base.js\";\nexport {\n AlchemySignerWebClient,\n OauthCancelledError,\n OauthFailedError,\n} from \"./client/index.js\";\nexport type * from \"./client/types.js\";\nexport {\n NotAuthenticatedError,\n OAuthProvidersError,\n MfaRequiredError,\n} from \"./errors.js\";\nexport {\n DEFAULT_SESSION_MS,\n SessionManagerParamsSchema,\n} from \"./session/manager.js\";\nexport type * from \"./signer.js\";\nexport { AlchemyWebSigner } from \"./signer.js\";\nexport type * from \"./solanaSigner.js\";\nexport type * from \"./types.js\";\nexport { AlchemySignerStatus } from \"./types.js\";\nexport { SolanaSigner } from \"./solanaSigner.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,gCAAgC,EAChC,uBAAuB,GACxB,MAAM,mBAAmB,CAAC","sourcesContent":["export { BaseAlchemySigner } from \"./base.js\";\nexport { BaseSignerClient } from \"./client/base.js\";\nexport {\n AlchemySignerWebClient,\n OauthCancelledError,\n OauthFailedError,\n} from \"./client/index.js\";\nexport type * from \"./client/types.js\";\nexport {\n NotAuthenticatedError,\n OAuthProvidersError,\n MfaRequiredError,\n} from \"./errors.js\";\nexport {\n DEFAULT_SESSION_MS,\n SessionManagerParamsSchema,\n} from \"./session/manager.js\";\nexport type * from \"./signer.js\";\nexport { AlchemyWebSigner } from \"./signer.js\";\nexport type * from \"./solanaSigner.js\";\nexport type * from \"./types.js\";\nexport { AlchemySignerStatus } from \"./types.js\";\nexport { SolanaSigner } from \"./solanaSigner.js\";\nexport {\n createSolanaSponsoredTransaction,\n createSolanaTransaction,\n} from \"./utils/solana.js\";\n"]}
@@ -2,7 +2,7 @@ export type SignerEventsSchema = [
2
2
  {
3
3
  EventName: "signer_authnticate";
4
4
  EventData: {
5
- authType: "email" | "passkey_anon" | "passkey_email" | "otp" | "oauthReturn";
5
+ authType: "email" | "sms" | "passkey_anon" | "passkey_email" | "otp" | "oauthReturn";
6
6
  provider?: never;
7
7
  } | {
8
8
  authType: "oauth";
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAuBvC,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAqB;IAC3D,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC","sourcesContent":["import { createLogger } from \"@account-kit/logging\";\nimport { VERSION } from \"./version.js\";\n\nexport type SignerEventsSchema = [\n {\n EventName: \"signer_authnticate\";\n EventData:\n | {\n authType:\n | \"email\"\n | \"passkey_anon\"\n | \"passkey_email\"\n | \"otp\"\n | \"oauthReturn\";\n provider?: never;\n }\n | { authType: \"oauth\"; provider: string };\n },\n {\n EventName: \"signer_sign_message\";\n EventData: undefined;\n },\n];\n\nexport const SignerLogger = createLogger<SignerEventsSchema>({\n package: \"@account-kit/signer\",\n version: VERSION,\n});\n"]}
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAwBvC,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAqB;IAC3D,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC","sourcesContent":["import { createLogger } from \"@account-kit/logging\";\nimport { VERSION } from \"./version.js\";\n\nexport type SignerEventsSchema = [\n {\n EventName: \"signer_authnticate\";\n EventData:\n | {\n authType:\n | \"email\"\n | \"sms\"\n | \"passkey_anon\"\n | \"passkey_email\"\n | \"otp\"\n | \"oauthReturn\";\n provider?: never;\n }\n | { authType: \"oauth\"; provider: string };\n },\n {\n EventName: \"signer_sign_message\";\n EventData: undefined;\n },\n];\n\nexport const SignerLogger = createLogger<SignerEventsSchema>({\n package: \"@account-kit/signer\",\n version: VERSION,\n});\n"]}
@@ -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.js","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,EACL,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AA6ElE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,MAAM,EAAE,CAAC;SACN,MAAM,EAA0B;SAChC,EAAE,CAAC,+BAA+B,CAAC;CACvC,CAAC;KACD,MAAM,CAAC;IACN,aAAa,EAAE,0BAA0B,CAAC,IAAI,CAAC;QAC7C,MAAM,EAAE,IAAI;KACb,CAAC,CAAC,QAAQ,EAAE;CACd,CAAC,CAAC;AAIL;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAyC;IAE7E;;;;;;;;;;;;;;;;;;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AAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC;QACvD,eAAe,KAAf,eAAe,GAAK,KAAK,IAAI,IAAI,EAAC;QAClC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,MAAgD,CAAC;AAC1D,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { BaseAlchemySigner } from \"./base.js\";\nimport {\n AlchemySignerClientParamsSchema,\n AlchemySignerWebClient,\n} from \"./client/index.js\";\nimport type {\n AuthLinkingPrompt,\n CredentialCreationOptionOverrides,\n VerifyMfaParams,\n} from \"./client/types.js\";\nimport { SessionManagerParamsSchema } from \"./session/manager.js\";\n\nexport type AuthParams =\n | {\n type: \"email\";\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: \"magicLink\" | \"otp\";\n redirectParams?: URLSearchParams;\n multiFactors?: VerifyMfaParams[];\n }\n | { type: \"email\"; bundle: string; orgId?: string; isNewUser?: boolean }\n | {\n type: \"passkey\";\n email: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | {\n type: \"passkey\";\n createNew: false;\n }\n | {\n type: \"passkey\";\n createNew: true;\n username: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | ({\n type: \"oauth\";\n scope?: string;\n claims?: string;\n otherParameters?: Record<string, string>;\n } & OauthProviderConfig &\n OauthRedirectConfig)\n | {\n type: \"oauthReturn\";\n bundle: string;\n orgId: string;\n idToken: string;\n isNewUser?: boolean;\n }\n | {\n type: \"otp\";\n otpCode: string;\n multiFactors?: VerifyMfaParams[];\n };\n\nexport type OauthProviderConfig =\n | {\n authProviderId: \"auth0\";\n isCustomProvider?: false;\n auth0Connection?: string;\n }\n | {\n authProviderId: KnownAuthProvider;\n isCustomProvider?: false;\n auth0Connection?: never;\n }\n | {\n authProviderId: string;\n isCustomProvider: true;\n auth0Connection?: never;\n };\n\nexport type OauthRedirectConfig =\n | { mode: \"redirect\"; redirectUrl: string }\n | { mode: \"popup\"; redirectUrl?: never };\n\nexport type KnownAuthProvider =\n | \"google\"\n | \"apple\"\n | \"facebook\"\n | \"twitch\"\n | \"auth0\";\n\nexport type OauthMode = \"redirect\" | \"popup\";\n\nexport const AlchemySignerParamsSchema = z\n .object({\n client: z\n .custom<AlchemySignerWebClient>()\n .or(AlchemySignerClientParamsSchema),\n })\n .extend({\n sessionConfig: SessionManagerParamsSchema.omit({\n client: true,\n }).optional(),\n });\n\nexport type AlchemySignerParams = z.input<typeof AlchemySignerParamsSchema>;\n\n/**\n * A SmartAccountSigner that can be used with any SmartContractAccount\n */\nexport class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient> {\n private static replaceStateFilterInstalled = false;\n /**\n * Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.\n *\n * @example\n * ```ts\n * import { AlchemyWebSigner } from \"@account-kit/signer\";\n *\n * const signer = new AlchemyWebSigner({\n * client: {\n * connection: {\n * rpcUrl: \"/api/rpc\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"alchemy-signer-iframe-container\",\n * },\n * },\n * });\n * ```\n *\n * @param {AlchemySignerParams} params The parameters for the Alchemy signer, including the client and session configuration\n */\n\n constructor(params: AlchemySignerParams) {\n const { sessionConfig, ...params_ } =\n AlchemySignerParamsSchema.parse(params);\n\n let client: AlchemySignerWebClient;\n if (\"connection\" in params_.client) {\n client = new AlchemySignerWebClient(params_.client);\n } else {\n client = params_.client;\n }\n\n const qpStructure = {\n emailBundle: \"bundle\",\n // We don't need this, but we still want to remove it from the URL.\n emailOrgId: \"orgId\",\n status: \"alchemy-status\",\n oauthBundle: \"alchemy-bundle\",\n oauthOrgId: \"alchemy-org-id\",\n idToken: \"alchemy-id-token\",\n isSignup: \"aa-is-signup\",\n otpId: \"alchemy-otp-id\",\n email: \"alchemy-email\",\n authProvider: \"alchemy-auth-provider\",\n oauthError: \"alchemy-error\",\n };\n\n const {\n emailBundle,\n status,\n oauthBundle,\n oauthOrgId,\n idToken,\n isSignup,\n otpId,\n email,\n authProvider,\n oauthError,\n } = getAndRemoveQueryParams(qpStructure);\n\n if (!AlchemyWebSigner.replaceStateFilterInstalled) {\n installReplaceStateFilter(Object.values(qpStructure));\n AlchemyWebSigner.replaceStateFilterInstalled = true;\n }\n\n const initialError =\n oauthError != null\n ? { name: \"OauthError\", message: oauthError }\n : undefined;\n\n const initialAuthLinkingPrompt: AuthLinkingPrompt | undefined = (() => {\n if (status !== \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\") {\n return undefined;\n }\n if (\n idToken == null ||\n email == null ||\n authProvider == null ||\n otpId == null ||\n oauthOrgId == null\n ) {\n console.error(\"Missing required query params for auth linking prompt\");\n return undefined;\n }\n return {\n status,\n idToken,\n email,\n providerName: authProvider,\n otpId,\n orgId: oauthOrgId,\n };\n })();\n\n super({ client, sessionConfig, initialError, initialAuthLinkingPrompt });\n\n const isNewUser = isSignup === \"true\";\n\n this.signerType = \"alchemy-signer\";\n\n if (emailBundle) {\n this.authenticate({\n type: \"email\",\n bundle: emailBundle,\n isNewUser,\n });\n } else if (oauthBundle && oauthOrgId && idToken) {\n this.authenticate({\n type: \"oauthReturn\",\n bundle: oauthBundle,\n orgId: oauthOrgId,\n idToken,\n isNewUser,\n });\n }\n }\n}\n\n/**\n * Overrides `window.history.replaceState` to remove the specified query params from target URLs.\n *\n * @param {string[]} qpToRemove The query params to remove from target URLs.\n */\nfunction installReplaceStateFilter(qpToRemove: string[]) {\n const originalReplaceState = window.history.replaceState;\n\n const processUrl = (src: string | URL | undefined | null) => {\n if (!src) {\n return src;\n }\n\n try {\n const url = new URL(src, document.baseURI);\n const originalSearch = url.search;\n\n qpToRemove.forEach((qp) => url.searchParams.delete(qp));\n if (originalSearch === url.search) return src;\n\n console.log(\"[Alchemy] filtered query params from URL\");\n return url;\n } catch (e) {\n console.log(\"[Alchemy] failed to process URL in state filter\", e);\n return src;\n }\n };\n\n window.history.replaceState = function (...args) {\n const [state, unused, url] = args;\n\n const result = originalReplaceState.apply(this, [\n state,\n unused,\n processUrl(url),\n ]);\n\n return result;\n };\n\n console.log(\"[Alchemy] installed window.history.replaceState interceptor\");\n}\n\n/**\n * Reads and removes the specified query params from the URL.\n *\n * @param {T} keys object whose values are the query parameter keys to read and\n * remove\n * @returns {{ [K in keyof T]: string | undefined }} object with the same keys\n * as the input whose values are the values of the query params.\n */\nfunction getAndRemoveQueryParams<T extends Record<string, string>>(\n keys: T,\n): { [K in keyof T]: string | undefined } {\n const url = new URL(window.location.href);\n const result: Record<string, string | undefined> = {};\n let foundQueryParam = false;\n for (const [key, param] of Object.entries(keys)) {\n const value = url.searchParams.get(param) ?? undefined;\n foundQueryParam ||= value != null;\n result[key] = value;\n url.searchParams.delete(param);\n }\n if (foundQueryParam) {\n window.history.replaceState(window.history.state, \"\", url.toString());\n }\n return result as { [K in keyof T]: string | undefined };\n}\n"]}
1
+ {"version":3,"file":"signer.js","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,EACL,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAiFlE,MAAM,CAAC,MAAM,yBAAyB,GAA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;IAChB,CAAC,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,uBAAuB,CAC9B,IAAO;IAEP,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAuC,EAAE,CAAC;IACtD,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC;QACvD,eAAe,KAAf,eAAe,GAAK,KAAK,IAAI,IAAI,EAAC;QAClC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,MAAgD,CAAC;AAC1D,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { BaseAlchemySigner } from \"./base.js\";\nimport {\n AlchemySignerClientParamsSchema,\n AlchemySignerWebClient,\n} from \"./client/index.js\";\nimport type {\n AuthLinkingPrompt,\n CredentialCreationOptionOverrides,\n VerifyMfaParams,\n} from \"./client/types.js\";\nimport { SessionManagerParamsSchema } from \"./session/manager.js\";\n\nexport type AuthParams =\n | {\n type: \"email\";\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: \"magicLink\" | \"otp\";\n redirectParams?: URLSearchParams;\n multiFactors?: VerifyMfaParams[];\n }\n | { type: \"email\"; bundle: string; orgId?: string; isNewUser?: boolean }\n | {\n type: \"sms\";\n phone: string;\n }\n | {\n type: \"passkey\";\n email: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | {\n type: \"passkey\";\n createNew: false;\n }\n | {\n type: \"passkey\";\n createNew: true;\n username: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | ({\n type: \"oauth\";\n scope?: string;\n claims?: string;\n otherParameters?: Record<string, string>;\n } & OauthProviderConfig &\n OauthRedirectConfig)\n | {\n type: \"oauthReturn\";\n bundle: string;\n orgId: string;\n idToken: string;\n isNewUser?: boolean;\n }\n | {\n type: \"otp\";\n otpCode: string;\n multiFactors?: VerifyMfaParams[];\n };\n\nexport type OauthProviderConfig =\n | {\n authProviderId: \"auth0\";\n isCustomProvider?: false;\n auth0Connection?: string;\n }\n | {\n authProviderId: KnownAuthProvider;\n isCustomProvider?: false;\n auth0Connection?: never;\n }\n | {\n authProviderId: string;\n isCustomProvider: true;\n auth0Connection?: never;\n };\n\nexport type OauthRedirectConfig =\n | { mode: \"redirect\"; redirectUrl: string }\n | { mode: \"popup\"; redirectUrl?: never };\n\nexport type KnownAuthProvider =\n | \"google\"\n | \"apple\"\n | \"facebook\"\n | \"twitch\"\n | \"auth0\";\n\nexport type OauthMode = \"redirect\" | \"popup\";\n\nexport const AlchemySignerParamsSchema = z\n .object({\n client: z\n .custom<AlchemySignerWebClient>()\n .or(AlchemySignerClientParamsSchema),\n })\n .extend({\n sessionConfig: SessionManagerParamsSchema.omit({\n client: true,\n }).optional(),\n });\n\nexport type AlchemySignerParams = z.input<typeof AlchemySignerParamsSchema>;\n\n/**\n * A SmartAccountSigner that can be used with any SmartContractAccount\n */\nexport class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient> {\n private static replaceStateFilterInstalled = false;\n /**\n * Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.\n *\n * @example\n * ```ts\n * import { AlchemyWebSigner } from \"@account-kit/signer\";\n *\n * const signer = new AlchemyWebSigner({\n * client: {\n * connection: {\n * rpcUrl: \"/api/rpc\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"alchemy-signer-iframe-container\",\n * },\n * },\n * });\n * ```\n *\n * @param {AlchemySignerParams} params The parameters for the Alchemy signer, including the client and session configuration\n */\n\n constructor(params: AlchemySignerParams) {\n const { sessionConfig, ...params_ } =\n AlchemySignerParamsSchema.parse(params);\n\n let client: AlchemySignerWebClient;\n if (\"connection\" in params_.client) {\n client = new AlchemySignerWebClient(params_.client);\n } else {\n client = params_.client;\n }\n\n const qpStructure = {\n emailBundle: \"bundle\",\n // We don't need this, but we still want to remove it from the URL.\n emailOrgId: \"orgId\",\n status: \"alchemy-status\",\n oauthBundle: \"alchemy-bundle\",\n oauthOrgId: \"alchemy-org-id\",\n idToken: \"alchemy-id-token\",\n isSignup: \"aa-is-signup\",\n otpId: \"alchemy-otp-id\",\n email: \"alchemy-email\",\n authProvider: \"alchemy-auth-provider\",\n oauthError: \"alchemy-error\",\n };\n\n const {\n emailBundle,\n status,\n oauthBundle,\n oauthOrgId,\n idToken,\n isSignup,\n otpId,\n email,\n authProvider,\n oauthError,\n } = getAndRemoveQueryParams(qpStructure);\n\n if (!AlchemyWebSigner.replaceStateFilterInstalled) {\n installReplaceStateFilter(Object.values(qpStructure));\n AlchemyWebSigner.replaceStateFilterInstalled = true;\n }\n\n const initialError =\n oauthError != null\n ? { name: \"OauthError\", message: oauthError }\n : undefined;\n\n const initialAuthLinkingPrompt: AuthLinkingPrompt | undefined = (() => {\n if (status !== \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\") {\n return undefined;\n }\n if (\n idToken == null ||\n email == null ||\n authProvider == null ||\n otpId == null ||\n oauthOrgId == null\n ) {\n console.error(\"Missing required query params for auth linking prompt\");\n return undefined;\n }\n return {\n status,\n idToken,\n email,\n providerName: authProvider,\n otpId,\n orgId: oauthOrgId,\n };\n })();\n\n super({ client, sessionConfig, initialError, initialAuthLinkingPrompt });\n\n const isNewUser = isSignup === \"true\";\n\n this.signerType = \"alchemy-signer\";\n\n if (emailBundle) {\n this.authenticate({\n type: \"email\",\n bundle: emailBundle,\n isNewUser,\n });\n } else if (oauthBundle && oauthOrgId && idToken) {\n this.authenticate({\n type: \"oauthReturn\",\n bundle: oauthBundle,\n orgId: oauthOrgId,\n idToken,\n isNewUser,\n });\n }\n }\n}\n\n/**\n * Overrides `window.history.replaceState` to remove the specified query params from target URLs.\n *\n * @param {string[]} qpToRemove The query params to remove from target URLs.\n */\nfunction installReplaceStateFilter(qpToRemove: string[]) {\n const originalReplaceState = window.history.replaceState;\n\n const processUrl = (src: string | URL | undefined | null) => {\n if (!src) {\n return src;\n }\n\n try {\n const url = new URL(src, document.baseURI);\n const originalSearch = url.search;\n\n qpToRemove.forEach((qp) => url.searchParams.delete(qp));\n if (originalSearch === url.search) return src;\n\n console.log(\"[Alchemy] filtered query params from URL\");\n return url;\n } catch (e) {\n console.log(\"[Alchemy] failed to process URL in state filter\", e);\n return src;\n }\n };\n\n window.history.replaceState = function (...args) {\n const [state, unused, url] = args;\n\n const result = originalReplaceState.apply(this, [\n state,\n unused,\n processUrl(url),\n ]);\n\n return result;\n };\n\n console.log(\"[Alchemy] installed window.history.replaceState interceptor\");\n}\n\n/**\n * Reads and removes the specified query params from the URL.\n *\n * @param {T} keys object whose values are the query parameter keys to read and\n * remove\n * @returns {{ [K in keyof T]: string | undefined }} object with the same keys\n * as the input whose values are the values of the query params.\n */\nfunction getAndRemoveQueryParams<T extends Record<string, string>>(\n keys: T,\n): { [K in keyof T]: string | undefined } {\n const url = new URL(window.location.href);\n const result: Record<string, string | undefined> = {};\n let foundQueryParam = false;\n for (const [key, param] of Object.entries(keys)) {\n const value = url.searchParams.get(param) ?? undefined;\n foundQueryParam ||= value != null;\n result[key] = value;\n url.searchParams.delete(param);\n }\n if (foundQueryParam) {\n window.history.replaceState(window.history.state, \"\", url.toString());\n }\n return result as { [K in keyof T]: string | undefined };\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Connection, PublicKey, Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
2
2
  import { size, slice, toBytes, toHex } from "viem";
3
3
  import { NotAuthenticatedError } from "./errors.js";
4
+ import { createSolanaSponsoredTransaction } from "./utils/solana.js";
4
5
  /**
5
6
  * The SolanaSigner class is used to sign transactions and messages for the Solana blockchain.
6
7
  * It provides methods to add signatures to transactions and sign messages.
@@ -108,43 +109,7 @@ export class SolanaSigner {
108
109
  * @returns {Promise<VersionedTransaction>} The transaction with sponsorship added
109
110
  */
110
111
  async addSponsorship(instructions, connection, policyId) {
111
- const { blockhash } = await connection.getLatestBlockhash({
112
- commitment: "finalized",
113
- });
114
- const message = new TransactionMessage({
115
- // Right now the backend will rewrite this payer Key to the server's address
116
- payerKey: new PublicKey(this.address),
117
- recentBlockhash: blockhash,
118
- instructions,
119
- }).compileToV0Message();
120
- const versionedTransaction = new VersionedTransaction(message);
121
- const serializedTransaction = Buffer.from(versionedTransaction.serialize()).toString("base64");
122
- const body = JSON.stringify({
123
- id: crypto?.randomUUID() ?? Math.floor(Math.random() * 1000000),
124
- jsonrpc: "2.0",
125
- method: "alchemy_requestFeePayer",
126
- params: [
127
- {
128
- policyId,
129
- serializedTransaction,
130
- },
131
- ],
132
- });
133
- const options = {
134
- method: "POST",
135
- headers: {
136
- accept: "application/json",
137
- "content-type": "application/json",
138
- },
139
- body,
140
- };
141
- const response = await fetch(
142
- // TODO: Use the connection??
143
- connection.rpcEndpoint, options);
144
- const jsonResponse = await response.json();
145
- if (!jsonResponse?.result?.serializedTransaction)
146
- throw new Error(`Response doesn't include the serializedTransaction ${JSON.stringify(jsonResponse)}`);
147
- return VersionedTransaction.deserialize(decodeBase64(jsonResponse.result.serializedTransaction));
112
+ return createSolanaSponsoredTransaction(instructions, connection, policyId, this.address);
148
113
  }
149
114
  formatSignatureForSolana(signature) {
150
115
  if (size(signature) === 64)
@@ -162,7 +127,4 @@ export class SolanaSigner {
162
127
  return toHex(messageToSign);
163
128
  }
164
129
  }
165
- function decodeBase64(serializedTransaction) {
166
- return Buffer.from(serializedTransaction, "base64");
167
- }
168
130
  //# sourceMappingURL=solanaSigner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solanaSigner.js","sourceRoot":"","sources":["../../src/solanaSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAA4B,MAAM,MAAM,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,YAAY;IAIvB;;;;OAIG;IACH,YAAY,MAAwB;QAR3B;;;;;WAAgC;QACzB;;;;;WAAgB;QAQ9B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAEjE,wBAAwB;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,EAAG,CAAC,aAAc,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAChB,WAA+C;QAE/C,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACpC,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,aAAa,CAA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AS,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;CACF;AACD,SAAS,YAAY,CAAC,qBAA6B;IACjD,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import {\n Connection,\n PublicKey,\n Transaction,\n TransactionInstruction,\n TransactionMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { size, slice, toBytes, toHex, type ByteArray, type Hex } from \"viem\";\nimport type { BaseSignerClient } from \"./client/base\";\nimport { NotAuthenticatedError } from \"./errors.js\";\n\n/**\n * The SolanaSigner class is used to sign transactions and messages for the Solana blockchain.\n * It provides methods to add signatures to transactions and sign messages.\n */\nexport class SolanaSigner {\n readonly alchemyClient: BaseSignerClient;\n public readonly address: string;\n\n /**\n * Constructor for the SolanaSigner class which is a wrapper around the alchemy client, and is more focused on the solana web3\n *\n * @param {object} client This is the client that will be used to sign the transaction, and we are just having functions on top of it.\n */\n constructor(client: BaseSignerClient) {\n this.alchemyClient = client;\n if (!client.getUser()) throw new Error(\"Must be authenticated!\");\n\n // TODO: also throw here\n this.address = client.getUser()!.solanaAddress!;\n }\n\n /**\n * Adds a signature of the client user to a transaction\n *\n * @param {Transaction | VersionedTransaction} transaction - The transaction to add the signature to\n * @returns {Promise<Transaction | VersionedTransaction >} The transaction with the signature added\n */\n async addSignature(\n transaction: Transaction | VersionedTransaction,\n ): Promise<Transaction | VersionedTransaction> {\n const user = this.alchemyClient.getUser();\n if (!user) {\n throw new NotAuthenticatedError();\n }\n\n if (!user.solanaAddress) {\n throw new Error(\"no solana address\");\n }\n\n const fromKey = new PublicKey(user.solanaAddress);\n const messageToSign = this.getMessageToSign(transaction);\n const signature = await this.alchemyClient.signRawMessage(\n messageToSign,\n \"SOLANA\",\n );\n\n transaction.addSignature(\n fromKey,\n Buffer.from(toBytes(this.formatSignatureForSolana(signature))),\n );\n return transaction;\n }\n\n /**\n * Signs a message\n *\n * @param {Uint8Array} message - The message to sign\n * @returns {Promise<ByteArray>} The signature of the message\n */\n async signMessage(message: Uint8Array): Promise<ByteArray> {\n const user = this.alchemyClient.getUser();\n if (!user) {\n throw new NotAuthenticatedError();\n }\n\n if (!user.solanaAddress) {\n throw new Error(\"no solana address\");\n }\n\n const messageToSign = toHex(message);\n const signature = await this.alchemyClient.signRawMessage(\n messageToSign,\n \"SOLANA\",\n );\n\n return toBytes(this.formatSignatureForSolana(signature));\n }\n\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n version?: \"versioned\",\n ): Promise<VersionedTransaction>;\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n version?: \"legacy\",\n ): Promise<Transaction>;\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n ): Promise<VersionedTransaction>;\n\n /**\n * Creates a transfer transaction. Used for the SolanaCard example.\n *\n * @param {TransactionInstruction[]} instructions - The instructions to add to the transaction\n * @param {Connection} connection - The connection to use for the transaction\n * @param {\"versioned\" | \"legacy\"} [version] - The version of the transaction\n * @returns {Promise<Transaction | VersionedTransaction>} The transfer transaction\n */\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n version?: string,\n ): Promise<Transaction | VersionedTransaction> {\n const blockhash = (await connection.getLatestBlockhash()).blockhash;\n\n let transferTransaction;\n\n if (version === \"legacy\") {\n // Legacy transaction\n transferTransaction = instructions.reduce(\n (tx, instruction) => tx.add(instruction),\n new Transaction(),\n );\n\n // Get a recent block hash\n transferTransaction.recentBlockhash = blockhash;\n // Set the signer\n transferTransaction.feePayer = new PublicKey(this.address);\n } else {\n // VersionedTransaction\n const txMessage = new TransactionMessage({\n payerKey: new PublicKey(this.address),\n recentBlockhash: blockhash,\n instructions,\n });\n\n const versionedTxMessage = txMessage.compileToV0Message();\n transferTransaction = new VersionedTransaction(versionedTxMessage);\n }\n\n return transferTransaction;\n }\n\n /**\n * Adds sponsorship to a transaction. Used to have a party like Alchemy pay for the transaction.\n *\n * @param {TransactionInstruction[]} instructions - The instructions to add to the transaction\n * @param {Connection} connection - The connection to use for the transaction\n * @param {string} [policyId] - The policy ID to add sponsorship to\n * @returns {Promise<VersionedTransaction>} The transaction with sponsorship added\n */\n async addSponsorship(\n instructions: TransactionInstruction[],\n connection: Connection,\n policyId: string,\n ): Promise<VersionedTransaction> {\n const { blockhash } = await connection.getLatestBlockhash({\n commitment: \"finalized\",\n });\n const message = new TransactionMessage({\n // Right now the backend will rewrite this payer Key to the server's address\n payerKey: new PublicKey(this.address),\n recentBlockhash: blockhash,\n instructions,\n }).compileToV0Message();\n const versionedTransaction = new VersionedTransaction(message);\n const serializedTransaction = Buffer.from(\n versionedTransaction.serialize(),\n ).toString(\"base64\");\n const body = JSON.stringify({\n id: crypto?.randomUUID() ?? Math.floor(Math.random() * 1000000),\n jsonrpc: \"2.0\",\n method: \"alchemy_requestFeePayer\",\n params: [\n {\n policyId,\n serializedTransaction,\n },\n ],\n });\n const options = {\n method: \"POST\",\n headers: {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n },\n body,\n };\n\n const response = await fetch(\n // TODO: Use the connection??\n connection.rpcEndpoint,\n options,\n );\n const jsonResponse = await response.json();\n if (!jsonResponse?.result?.serializedTransaction)\n throw new Error(\n `Response doesn't include the serializedTransaction ${JSON.stringify(\n jsonResponse,\n )}`,\n );\n return VersionedTransaction.deserialize(\n decodeBase64(jsonResponse.result.serializedTransaction),\n );\n }\n\n private formatSignatureForSolana(signature: Hex): Hex {\n if (size(signature) === 64) return signature;\n\n return slice(signature, 0, 64);\n }\n\n private getMessageToSign(tx: Transaction | VersionedTransaction): Hex {\n let messageToSign;\n if (tx instanceof Transaction) {\n messageToSign = tx.serializeMessage();\n } else {\n messageToSign = Buffer.from(tx.message.serialize());\n }\n return toHex(messageToSign);\n }\n}\nfunction decodeBase64(serializedTransaction: string): Uint8Array {\n return Buffer.from(serializedTransaction, \"base64\");\n}\n"]}
1
+ {"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age,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { size, slice, toBytes, toHex, type ByteArray, type Hex } from \"viem\";\nimport type { BaseSignerClient } from \"./client/base\";\nimport { NotAuthenticatedError } from \"./errors.js\";\nimport { createSolanaSponsoredTransaction } from \"./utils/solana.js\";\n\n/**\n * The SolanaSigner class is used to sign transactions and messages for the Solana blockchain.\n * It provides methods to add signatures to transactions and sign messages.\n */\nexport class SolanaSigner {\n readonly alchemyClient: BaseSignerClient;\n public readonly address: string;\n\n /**\n * Constructor for the SolanaSigner class which is a wrapper around the alchemy client, and is more focused on the solana web3\n *\n * @param {object} client This is the client that will be used to sign the transaction, and we are just having functions on top of it.\n */\n constructor(client: BaseSignerClient) {\n this.alchemyClient = client;\n if (!client.getUser()) throw new Error(\"Must be authenticated!\");\n\n // TODO: also throw here\n this.address = client.getUser()!.solanaAddress!;\n }\n\n /**\n * Adds a signature of the client user to a transaction\n *\n * @param {Transaction | VersionedTransaction} transaction - The transaction to add the signature to\n * @returns {Promise<Transaction | VersionedTransaction >} The transaction with the signature added\n */\n async addSignature(\n transaction: Transaction | VersionedTransaction,\n ): Promise<Transaction | VersionedTransaction> {\n const user = this.alchemyClient.getUser();\n if (!user) {\n throw new NotAuthenticatedError();\n }\n\n if (!user.solanaAddress) {\n throw new Error(\"no solana address\");\n }\n\n const fromKey = new PublicKey(user.solanaAddress);\n const messageToSign = this.getMessageToSign(transaction);\n const signature = await this.alchemyClient.signRawMessage(\n messageToSign,\n \"SOLANA\",\n );\n\n transaction.addSignature(\n fromKey,\n Buffer.from(toBytes(this.formatSignatureForSolana(signature))),\n );\n return transaction;\n }\n\n /**\n * Signs a message\n *\n * @param {Uint8Array} message - The message to sign\n * @returns {Promise<ByteArray>} The signature of the message\n */\n async signMessage(message: Uint8Array): Promise<ByteArray> {\n const user = this.alchemyClient.getUser();\n if (!user) {\n throw new NotAuthenticatedError();\n }\n\n if (!user.solanaAddress) {\n throw new Error(\"no solana address\");\n }\n\n const messageToSign = toHex(message);\n const signature = await this.alchemyClient.signRawMessage(\n messageToSign,\n \"SOLANA\",\n );\n\n return toBytes(this.formatSignatureForSolana(signature));\n }\n\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n version?: \"versioned\",\n ): Promise<VersionedTransaction>;\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n version?: \"legacy\",\n ): Promise<Transaction>;\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n ): Promise<VersionedTransaction>;\n\n /**\n * Creates a transfer transaction. Used for the SolanaCard example.\n *\n * @param {TransactionInstruction[]} instructions - The instructions to add to the transaction\n * @param {Connection} connection - The connection to use for the transaction\n * @param {\"versioned\" | \"legacy\"} [version] - The version of the transaction\n * @returns {Promise<Transaction | VersionedTransaction>} The transfer transaction\n */\n async createTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n version?: string,\n ): Promise<Transaction | VersionedTransaction> {\n const blockhash = (await connection.getLatestBlockhash()).blockhash;\n\n let transferTransaction;\n\n if (version === \"legacy\") {\n // Legacy transaction\n transferTransaction = instructions.reduce(\n (tx, instruction) => tx.add(instruction),\n new Transaction(),\n );\n\n // Get a recent block hash\n transferTransaction.recentBlockhash = blockhash;\n // Set the signer\n transferTransaction.feePayer = new PublicKey(this.address);\n } else {\n // VersionedTransaction\n const txMessage = new TransactionMessage({\n payerKey: new PublicKey(this.address),\n recentBlockhash: blockhash,\n instructions,\n });\n\n const versionedTxMessage = txMessage.compileToV0Message();\n transferTransaction = new VersionedTransaction(versionedTxMessage);\n }\n\n return transferTransaction;\n }\n\n /**\n * Adds sponsorship to a transaction. Used to have a party like Alchemy pay for the transaction.\n *\n * @param {TransactionInstruction[]} instructions - The instructions to add to the transaction\n * @param {Connection} connection - The connection to use for the transaction\n * @param {string} [policyId] - The policy ID to add sponsorship to\n * @returns {Promise<VersionedTransaction>} The transaction with sponsorship added\n */\n async addSponsorship(\n instructions: TransactionInstruction[],\n connection: Connection,\n policyId: string,\n ): Promise<VersionedTransaction> {\n return createSolanaSponsoredTransaction(\n instructions,\n connection,\n policyId,\n this.address,\n );\n }\n\n private formatSignatureForSolana(signature: Hex): Hex {\n if (size(signature) === 64) return signature;\n\n return slice(signature, 0, 64);\n }\n\n private getMessageToSign(tx: Transaction | VersionedTransaction): Hex {\n let messageToSign;\n if (tx instanceof Transaction) {\n messageToSign = tx.serializeMessage();\n } else {\n messageToSign = Buffer.from(tx.message.serialize());\n }\n return toHex(messageToSign);\n }\n}\n"]}
@@ -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
  }
package/dist/esm/types.js CHANGED
@@ -7,6 +7,7 @@ export var AlchemySignerStatus;
7
7
  AlchemySignerStatus["AUTHENTICATING_EMAIL"] = "AUTHENTICATING_EMAIL";
8
8
  AlchemySignerStatus["AUTHENTICATING_OAUTH"] = "AUTHENTICATING_OAUTH";
9
9
  AlchemySignerStatus["AWAITING_EMAIL_AUTH"] = "AWAITING_EMAIL_AUTH";
10
+ AlchemySignerStatus["AWAITING_SMS_AUTH"] = "AWAITING_SMS_AUTH";
10
11
  AlchemySignerStatus["AWAITING_OTP_AUTH"] = "AWAITING_OTP_AUTH";
11
12
  AlchemySignerStatus["AWAITING_MFA_AUTH"] = "AWAITING_MFA_AUTH";
12
13
  })(AlchemySignerStatus || (AlchemySignerStatus = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAN,IAAY,mBAUX;AAVD,WAAY,mBAAmB;IAC7B,oDAA6B,CAAA;IAC7B,8CAAuB,CAAA;IACvB,oDAA6B,CAAA;IAC7B,wEAAiD,CAAA;IACjD,oEAA6C,CAAA;IAC7C,oEAA6C,CAAA;IAC7C,kEAA2C,CAAA;IAC3C,8DAAuC,CAAA;IACvC,8DAAuC,CAAA;AACzC,CAAC,EAVW,mBAAmB,KAAnB,mBAAmB,QAU9B;AAED,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,yCAAqB,CAAA;AACvB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B","sourcesContent":["import type { User } from \"./client/types\";\n\nexport type AlchemySignerEvents = {\n connected(user: User): void;\n newUserSignup(): void;\n disconnected(): void;\n statusChanged(status: AlchemySignerStatus): void;\n errorChanged(error: ErrorInfo | undefined): void;\n mfaStatusChanged(mfaStatus: {\n mfaRequired: boolean;\n mfaFactorId?: string;\n encryptedPayload?: string;\n }): void;\n emailAuthLinkingRequired(email: string): void;\n};\n\nexport type AlchemySignerEvent = keyof AlchemySignerEvents;\n\nexport enum AlchemySignerStatus {\n INITIALIZING = \"INITIALIZING\",\n CONNECTED = \"CONNECTED\",\n DISCONNECTED = \"DISCONNECTED\",\n AUTHENTICATING_PASSKEY = \"AUTHENTICATING_PASSKEY\",\n AUTHENTICATING_EMAIL = \"AUTHENTICATING_EMAIL\",\n AUTHENTICATING_OAUTH = \"AUTHENTICATING_OAUTH\",\n AWAITING_EMAIL_AUTH = \"AWAITING_EMAIL_AUTH\",\n AWAITING_OTP_AUTH = \"AWAITING_OTP_AUTH\",\n AWAITING_MFA_AUTH = \"AWAITING_MFA_AUTH\",\n}\n\nexport enum AlchemyMfaStatus {\n NOT_REQUIRED = \"not_required\",\n REQUIRED = \"required\",\n}\n\nexport interface ErrorInfo {\n name: string;\n message: string;\n}\n\nexport type ValidateMultiFactorsArgs = {\n multiFactorId?: string;\n multiFactorCode: string;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAN,IAAY,mBAWX;AAXD,WAAY,mBAAmB;IAC7B,oDAA6B,CAAA;IAC7B,8CAAuB,CAAA;IACvB,oDAA6B,CAAA;IAC7B,wEAAiD,CAAA;IACjD,oEAA6C,CAAA;IAC7C,oEAA6C,CAAA;IAC7C,kEAA2C,CAAA;IAC3C,8DAAuC,CAAA;IACvC,8DAAuC,CAAA;IACvC,8DAAuC,CAAA;AACzC,CAAC,EAXW,mBAAmB,KAAnB,mBAAmB,QAW9B;AAED,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,yCAAqB,CAAA;AACvB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B","sourcesContent":["import type { User } from \"./client/types\";\n\nexport type AlchemySignerEvents = {\n connected(user: User): void;\n newUserSignup(): void;\n disconnected(): void;\n statusChanged(status: AlchemySignerStatus): void;\n errorChanged(error: ErrorInfo | undefined): void;\n mfaStatusChanged(mfaStatus: {\n mfaRequired: boolean;\n mfaFactorId?: string;\n encryptedPayload?: string;\n }): void;\n emailAuthLinkingRequired(email: string): void;\n};\n\nexport type AlchemySignerEvent = keyof AlchemySignerEvents;\n\nexport enum AlchemySignerStatus {\n INITIALIZING = \"INITIALIZING\",\n CONNECTED = \"CONNECTED\",\n DISCONNECTED = \"DISCONNECTED\",\n AUTHENTICATING_PASSKEY = \"AUTHENTICATING_PASSKEY\",\n AUTHENTICATING_EMAIL = \"AUTHENTICATING_EMAIL\",\n AUTHENTICATING_OAUTH = \"AUTHENTICATING_OAUTH\",\n AWAITING_EMAIL_AUTH = \"AWAITING_EMAIL_AUTH\",\n AWAITING_SMS_AUTH = \"AWAITING_SMS_AUTH\",\n AWAITING_OTP_AUTH = \"AWAITING_OTP_AUTH\",\n AWAITING_MFA_AUTH = \"AWAITING_MFA_AUTH\",\n}\n\nexport enum AlchemyMfaStatus {\n NOT_REQUIRED = \"not_required\",\n REQUIRED = \"required\",\n}\n\nexport interface ErrorInfo {\n name: string;\n message: string;\n}\n\nexport type ValidateMultiFactorsArgs = {\n multiFactorId?: string;\n multiFactorCode: string;\n};\n"]}
@@ -0,0 +1,21 @@
1
+ import type { TransactionInstruction } from "@solana/web3.js";
2
+ import { Connection, VersionedTransaction } from "@solana/web3.js";
3
+ /**
4
+ * This function wraps instructions in a sponsored transaction using Alchemy's fee payer service
5
+ *
6
+ * @param {TransactionInstruction[]} instructions - The instructions to add sponsorship to
7
+ * @param {Connection} connection - The connection to use
8
+ * @param {string} policyId - The policy id to use
9
+ * @param {string} address - The address to use
10
+ * @returns {Promise<VersionedTransaction>} - The sponsored transaction
11
+ */
12
+ export declare function createSolanaSponsoredTransaction(instructions: TransactionInstruction[], connection: Connection, policyId: string, address: string): Promise<VersionedTransaction>;
13
+ /**
14
+ * Creates a regular (non-sponsored) Solana transaction from instructions
15
+ *
16
+ * @param {TransactionInstruction[]} instructions - The instructions to create transaction from
17
+ * @param {Connection} connection - The connection to use
18
+ * @param {string} address - The payer address
19
+ * @returns {Promise<VersionedTransaction>} - The transaction
20
+ */
21
+ export declare function createSolanaTransaction(instructions: TransactionInstruction[], connection: Connection, address: string): Promise<VersionedTransaction>;
@@ -0,0 +1,72 @@
1
+ import { Connection, PublicKey, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
2
+ /**
3
+ * This function wraps instructions in a sponsored transaction using Alchemy's fee payer service
4
+ *
5
+ * @param {TransactionInstruction[]} instructions - The instructions to add sponsorship to
6
+ * @param {Connection} connection - The connection to use
7
+ * @param {string} policyId - The policy id to use
8
+ * @param {string} address - The address to use
9
+ * @returns {Promise<VersionedTransaction>} - The sponsored transaction
10
+ */
11
+ export async function createSolanaSponsoredTransaction(instructions, connection, policyId, address) {
12
+ const { blockhash } = await connection.getLatestBlockhash({
13
+ commitment: "finalized",
14
+ });
15
+ const message = new TransactionMessage({
16
+ // Right now the backend will rewrite this payer Key to the server's address
17
+ payerKey: new PublicKey(address),
18
+ recentBlockhash: blockhash,
19
+ instructions,
20
+ }).compileToV0Message();
21
+ const versionedTransaction = new VersionedTransaction(message);
22
+ const serializedTransaction = Buffer.from(versionedTransaction.serialize()).toString("base64");
23
+ const body = JSON.stringify({
24
+ id: crypto?.randomUUID() ?? Math.floor(Math.random() * 1000000),
25
+ jsonrpc: "2.0",
26
+ method: "alchemy_requestFeePayer",
27
+ params: [
28
+ {
29
+ policyId,
30
+ serializedTransaction,
31
+ },
32
+ ],
33
+ });
34
+ const options = {
35
+ method: "POST",
36
+ headers: {
37
+ accept: "application/json",
38
+ "content-type": "application/json",
39
+ },
40
+ body,
41
+ };
42
+ const response = await fetch(
43
+ // TODO: Use the connection??
44
+ connection.rpcEndpoint, options);
45
+ const jsonResponse = await response.json();
46
+ if (!jsonResponse?.result?.serializedTransaction)
47
+ throw new Error(`Response doesn't include the serializedTransaction ${JSON.stringify(jsonResponse)}`);
48
+ return VersionedTransaction.deserialize(decodeBase64(jsonResponse.result.serializedTransaction));
49
+ }
50
+ /**
51
+ * Creates a regular (non-sponsored) Solana transaction from instructions
52
+ *
53
+ * @param {TransactionInstruction[]} instructions - The instructions to create transaction from
54
+ * @param {Connection} connection - The connection to use
55
+ * @param {string} address - The payer address
56
+ * @returns {Promise<VersionedTransaction>} - The transaction
57
+ */
58
+ export async function createSolanaTransaction(instructions, connection, address) {
59
+ const { blockhash } = await connection.getLatestBlockhash({
60
+ commitment: "finalized",
61
+ });
62
+ const message = new TransactionMessage({
63
+ payerKey: new PublicKey(address),
64
+ recentBlockhash: blockhash,
65
+ instructions,
66
+ }).compileToV0Message();
67
+ return new VersionedTransaction(message);
68
+ }
69
+ function decodeBase64(serializedTransaction) {
70
+ return Buffer.from(serializedTransaction, "base64");
71
+ }
72
+ //# sourceMappingURL=solana.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../src/utils/solana.ts"],"names":[],"mappings":"AACA,OAA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AM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3C,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,qBAAqB;QAC9C,MAAM,IAAI,KAAK,CACb,sDAAsD,IAAI,CAAC,SAAS,CAClE,YAAY,CACb,EAAE,CACJ,CAAC;IACJ,OAAO,oBAAoB,CAAC,WAAW,CACrC,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,qBAAqB,CAAC,CACxD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,YAAsC,EACtC,UAAsB,EACtB,OAAe;IAEf,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;QACxD,UAAU,EAAE,WAAW;KACxB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC;QACrC,QAAQ,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC;QAChC,eAAe,EAAE,SAAS;QAC1B,YAAY;KACb,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACxB,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,qBAA6B;IACjD,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { TransactionInstruction } from \"@solana/web3.js\";\nimport {\n Connection,\n PublicKey,\n TransactionMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\n\n/**\n * This function wraps instructions in a sponsored transaction using Alchemy's fee payer service\n *\n * @param {TransactionInstruction[]} instructions - The instructions to add sponsorship to\n * @param {Connection} connection - The connection to use\n * @param {string} policyId - The policy id to use\n * @param {string} address - The address to use\n * @returns {Promise<VersionedTransaction>} - The sponsored transaction\n */\nexport async function createSolanaSponsoredTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n policyId: string,\n address: string,\n): Promise<VersionedTransaction> {\n const { blockhash } = await connection.getLatestBlockhash({\n commitment: \"finalized\",\n });\n const message = new TransactionMessage({\n // Right now the backend will rewrite this payer Key to the server's address\n payerKey: new PublicKey(address),\n recentBlockhash: blockhash,\n instructions,\n }).compileToV0Message();\n const versionedTransaction = new VersionedTransaction(message);\n const serializedTransaction = Buffer.from(\n versionedTransaction.serialize(),\n ).toString(\"base64\");\n const body = JSON.stringify({\n id: crypto?.randomUUID() ?? Math.floor(Math.random() * 1000000),\n jsonrpc: \"2.0\",\n method: \"alchemy_requestFeePayer\",\n params: [\n {\n policyId,\n serializedTransaction,\n },\n ],\n });\n const options = {\n method: \"POST\",\n headers: {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n },\n body,\n };\n\n const response = await fetch(\n // TODO: Use the connection??\n connection.rpcEndpoint,\n options,\n );\n const jsonResponse = await response.json();\n if (!jsonResponse?.result?.serializedTransaction)\n throw new Error(\n `Response doesn't include the serializedTransaction ${JSON.stringify(\n jsonResponse,\n )}`,\n );\n return VersionedTransaction.deserialize(\n decodeBase64(jsonResponse.result.serializedTransaction),\n );\n}\n\n/**\n * Creates a regular (non-sponsored) Solana transaction from instructions\n *\n * @param {TransactionInstruction[]} instructions - The instructions to create transaction from\n * @param {Connection} connection - The connection to use\n * @param {string} address - The payer address\n * @returns {Promise<VersionedTransaction>} - The transaction\n */\nexport async function createSolanaTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n address: string,\n): Promise<VersionedTransaction> {\n const { blockhash } = await connection.getLatestBlockhash({\n commitment: \"finalized\",\n });\n const message = new TransactionMessage({\n payerKey: new PublicKey(address),\n recentBlockhash: blockhash,\n instructions,\n }).compileToV0Message();\n return new VersionedTransaction(message);\n}\n\nfunction decodeBase64(serializedTransaction: string): Uint8Array {\n return Buffer.from(serializedTransaction, \"base64\");\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.52.4";
1
+ export declare const VERSION = "4.53.1-alpha.0";
@@ -1,4 +1,4 @@
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.1-alpha.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.52.4\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.53.1-alpha.0\";\n"]}
@@ -18,6 +18,13 @@ export type EmailConfig = {
18
18
  export type SignerConfig = {
19
19
  email: EmailConfig;
20
20
  };
21
+ type GetUserParams = {
22
+ type: "email";
23
+ value: string;
24
+ } | {
25
+ type: "phone";
26
+ value: string;
27
+ };
21
28
  /**
22
29
  * Base abstract class for Alchemy Signer, providing authentication and session management for smart accounts.
23
30
  * Implements the `SmartAccountAuthenticator` interface and handles various signer events.
@@ -315,6 +322,8 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
315
322
  /**
316
323
  * Unauthenticated call to look up a user's organizationId by email
317
324
  *
325
+ * @deprecated Use getUser({ type: "email", value: email }) instead
326
+ *
318
327
  * @example
319
328
  * ```ts
320
329
  * import { AlchemyWebSigner } from "@account-kit/signer";
@@ -336,7 +345,34 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
336
345
  * @param {string} email the email to lookup
337
346
  * @returns {Promise<{orgId: string}>} the organization id for the user if they exist
338
347
  */
339
- getUser: (email: string) => Promise<{
348
+ getUser(email: string): Promise<{
349
+ orgId: string;
350
+ } | null>;
351
+ /**
352
+ * Unauthenticated call to look up a user's organizationId by email or phone
353
+ *
354
+ * @example
355
+ * ```ts
356
+ * import { AlchemyWebSigner } from "@account-kit/signer";
357
+ *
358
+ * const signer = new AlchemyWebSigner({
359
+ * client: {
360
+ * connection: {
361
+ * rpcUrl: "/api/rpc",
362
+ * },
363
+ * iframeConfig: {
364
+ * iframeContainerId: "alchemy-signer-iframe-container",
365
+ * },
366
+ * },
367
+ * });
368
+ *
369
+ * const result = await signer.getUser({ type: "email", value: "foo@mail.com" });
370
+ * ```
371
+ *
372
+ * @param {string} email the email to lookup
373
+ * @returns {Promise<{orgId: string}>} the organization id for the user if they exist
374
+ */
375
+ getUser(params: GetUserParams): Promise<{
340
376
  orgId: string;
341
377
  } | null>;
342
378
  setEmail: (email: string) => Promise<void>;
@@ -483,6 +519,7 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
483
519
  */
484
520
  toSolanaSigner: () => SolanaSigner;
485
521
  private authenticateWithEmail;
522
+ private authenticateWithSms;
486
523
  private authenticateWithPasskey;
487
524
  private authenticateWithOauth;
488
525
  /**
@@ -511,12 +548,14 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
511
548
  listAuthMethods: () => Promise<AuthMethods>;
512
549
  private authenticateWithOtp;
513
550
  private setAwaitingEmailAuth;
551
+ private setAwaitingSmsAuth;
514
552
  private handleOauthReturn;
515
553
  private handleMfaRequired;
516
554
  private getExpirationSeconds;
517
555
  private registerListeners;
518
556
  private emitNewUserEvent;
519
557
  private initOrCreateEmailUser;
558
+ private initOrCreateSmsUser;
520
559
  private completeEmailAuth;
521
560
  /**
522
561
  * Retrieves the list of MFA factors configured for the current user.
@@ -677,4 +716,5 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
677
716
  private setAuthLinkingPrompt;
678
717
  private waitForConnected;
679
718
  }
719
+ export {};
680
720
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"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