@account-kit/signer 4.26.0 → 4.28.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.
- package/dist/esm/base.d.ts +4 -4
- package/dist/esm/base.js +2 -2
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +49 -43
- package/dist/esm/client/base.js +166 -0
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +2 -50
- package/dist/esm/client/index.js +1 -162
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +4 -7
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solanaSigner.d.ts +37 -4
- package/dist/esm/solanaSigner.js +107 -6
- package/dist/esm/solanaSigner.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/base.d.ts +4 -4
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +49 -43
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +2 -50
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +4 -7
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/solanaSigner.d.ts +37 -4
- package/dist/types/solanaSigner.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -4
- package/src/base.ts +5 -5
- package/src/client/base.ts +171 -49
- package/src/client/index.ts +1 -177
- package/src/client/types.ts +4 -7
- package/src/index.ts +1 -0
- package/src/solanaSigner.ts +155 -8
- package/src/version.ts +1 -1
package/dist/esm/base.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type SmartAccountAuthenticator } from "@aa-sdk/core";
|
|
|
2
2
|
import { type GetTransactionType, type Hex, type IsNarrowable, type LocalAccount, type SerializeTransactionFn, type SignableMessage, type TransactionSerializable, type TransactionSerialized, type TypedData, type TypedDataDefinition } from "viem";
|
|
3
3
|
import { type Authorization } from "viem/experimental";
|
|
4
4
|
import type { BaseSignerClient } from "./client/base";
|
|
5
|
-
import type { MfaFactor, OauthConfig, User, VerifyMfaParams,
|
|
5
|
+
import type { MfaFactor, OauthConfig, User, VerifyMfaParams, AddMfaParams, AddMfaResult, RemoveMfaParams } from "./client/types";
|
|
6
6
|
import { type SessionManagerParams } from "./session/manager.js";
|
|
7
7
|
import type { AuthParams } from "./signer";
|
|
8
8
|
import { SolanaSigner } from "./solanaSigner.js";
|
|
@@ -507,11 +507,11 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
507
507
|
* // Result contains multiFactorTotpUrl to display as QR code
|
|
508
508
|
* ```
|
|
509
509
|
*
|
|
510
|
-
* @param {
|
|
510
|
+
* @param {AddMfaParams} params The parameters required to enable a new MFA factor
|
|
511
511
|
* @throws {NotAuthenticatedError} If no user is authenticated
|
|
512
|
-
* @returns {Promise<
|
|
512
|
+
* @returns {Promise<AddMfaResult>} A promise that resolves to the factor setup information
|
|
513
513
|
*/
|
|
514
|
-
addMfa: (params:
|
|
514
|
+
addMfa: (params: AddMfaParams) => Promise<AddMfaResult>;
|
|
515
515
|
/**
|
|
516
516
|
* Verifies a newly created MFA factor to complete the setup process.
|
|
517
517
|
*
|
package/dist/esm/base.js
CHANGED
|
@@ -995,9 +995,9 @@ export class BaseAlchemySigner {
|
|
|
995
995
|
* // Result contains multiFactorTotpUrl to display as QR code
|
|
996
996
|
* ```
|
|
997
997
|
*
|
|
998
|
-
* @param {
|
|
998
|
+
* @param {AddMfaParams} params The parameters required to enable a new MFA factor
|
|
999
999
|
* @throws {NotAuthenticatedError} If no user is authenticated
|
|
1000
|
-
* @returns {Promise<
|
|
1000
|
+
* @returns {Promise<AddMfaResult>} A promise that resolves to the factor setup information
|
|
1001
1001
|
*/
|
|
1002
1002
|
Object.defineProperty(this, "addMfa", {
|
|
1003
1003
|
enumerable: true,
|
package/dist/esm/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkC,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,EACT,oBAAoB,GAWrB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAsB,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAa9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,cAAc,GAEf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,mBAAmB,GAKpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAwCxD;;;GAGG;AACH,MAAM,OAAgB,iBAAiB;IASrC;;;;;;;;;OASG;IACH,YAAY,EACV,MAAM,EACN,aAAa,EACb,YAAY,GACqB;QApBnC;;;;mBAAqD,gBAAgB;WAAC;QACtE;;;;;WAAe;QACP;;;;;WAA+B;QAC/B;;;;;WAAqB;QACrB;;;;;WAA8B;QA8CtC;;;;;;WAMG;QACH;;;;mBAAK,CACH,KAAQ,EACR,QAAgC,EAChC,EAAE;gBACF,+FAA+F;gBAC/F,gGAAgG;gBAChG,0GAA0G;gBAC1G,QAAQ,KAAK,EAAE,CAAC;oBACd,KAAK,WAAW;wBACd,OAA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ourcesContent":["import { takeBytes, type SmartAccountAuthenticator } from \"@aa-sdk/core\";\nimport {\n hashMessage,\n hashTypedData,\n keccak256,\n serializeTransaction,\n type GetTransactionType,\n type Hex,\n type IsNarrowable,\n type LocalAccount,\n type SerializeTransactionFn,\n type SignableMessage,\n type TransactionSerializable,\n type TransactionSerialized,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { hashAuthorization, type Authorization } from \"viem/experimental\";\nimport type { Mutate, StoreApi } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\nimport { createStore } from \"zustand/vanilla\";\nimport type { BaseSignerClient } from \"./client/base\";\nimport type {\n EmailType,\n MfaFactor,\n OauthConfig,\n OauthParams,\n User,\n VerifyMfaParams,\n EnableMfaParams,\n EnableMfaResult,\n RemoveMfaParams,\n} from \"./client/types\";\nimport { NotAuthenticatedError } from \"./errors.js\";\nimport { SignerLogger } from \"./metrics.js\";\nimport {\n SessionManager,\n type SessionManagerParams,\n} from \"./session/manager.js\";\nimport type { SessionManagerEvents } from \"./session/types\";\nimport type { AuthParams } from \"./signer\";\nimport { SolanaSigner } from \"./solanaSigner.js\";\nimport {\n AlchemySignerStatus,\n type AlchemySignerEvent,\n type AlchemySignerEvents,\n type ErrorInfo,\n type ValidateMultiFactorsArgs,\n} from \"./types.js\";\nimport { assertNever } from \"./utils/typeAssertions.js\";\n\nexport interface BaseAlchemySignerParams<TClient extends BaseSignerClient> {\n client: TClient;\n sessionConfig?: Omit<SessionManagerParams, \"client\">;\n initialError?: ErrorInfo;\n}\n\ntype AlchemySignerStore = {\n user: User | null;\n status: AlchemySignerStatus;\n error: ErrorInfo | null;\n otpId?: string;\n isNewUser?: boolean;\n mfaStatus: {\n mfaRequired: boolean;\n mfaFactorId?: string;\n encryptedPayload?: string;\n };\n};\n\ntype UnpackedSignature = {\n r: `0x${string}`;\n s: `0x${string}`;\n v: bigint;\n};\n\ntype InternalStore = Mutate<\n StoreApi<AlchemySignerStore>,\n [[\"zustand/subscribeWithSelector\", never]]\n>;\n\nexport type EmailConfig = {\n mode?: \"MAGIC_LINK\" | \"OTP\";\n};\n\nexport type SignerConfig = {\n email: EmailConfig;\n};\n\n/**\n * Base abstract class for Alchemy Signer, providing authentication and session management for smart accounts.\n * Implements the `SmartAccountAuthenticator` interface and handles various signer events.\n */\nexport abstract class BaseAlchemySigner<TClient extends BaseSignerClient>\n implements SmartAccountAuthenticator<AuthParams, User, TClient>\n{\n signerType: \"alchemy-signer\" | \"rn-alchemy-signer\" = \"alchemy-signer\";\n inner: TClient;\n private sessionManager: SessionManager;\n private store: InternalStore;\n private config: Promise<SignerConfig>;\n\n /**\n * Initializes an instance with the provided client and session configuration.\n * This function sets up the internal store, initializes the session manager,\n * registers listeners and initializes the session manager to manage session state.\n *\n * @param {BaseAlchemySignerParams<TClient>} param0 Object containing the client and session configuration\n * @param {TClient} param0.client The client instance to be used internally\n * @param {SessionConfig} param0.sessionConfig Configuration for managing sessions\n * @param {ErrorInfo | undefined} param0.initialError Error already present on the signer when initialized, if any\n */\n constructor({\n client,\n sessionConfig,\n initialError,\n }: BaseAlchemySignerParams<TClient>) {\n this.inner = client;\n this.store = createStore(\n subscribeWithSelector(\n () =>\n ({\n user: null,\n status: AlchemySignerStatus.INITIALIZING,\n error: initialError ?? null,\n mfaStatus: {\n mfaRequired: false,\n mfaFactorId: undefined,\n },\n } satisfies AlchemySignerStore)\n )\n );\n // NOTE: it's important that the session manager share a client\n // with the signer. The SessionManager leverages the Signer's client\n // to manage session state.\n this.sessionManager = new SessionManager({\n ...sessionConfig,\n client: this.inner,\n });\n // register listeners first\n this.registerListeners();\n // then initialize so that we can catch those events\n this.sessionManager.initialize();\n this.config = this.fetchConfig();\n }\n\n /**\n * Allows you to subscribe to events emitted by the signer\n *\n * @param {AlchemySignerEvent} event the event to subscribe to\n * @param {AlchemySignerEvents[AlchemySignerEvent]} listener the function to run when the event is emitted\n * @returns {() => void} a function to remove the listener\n */\n on = <E extends AlchemySignerEvent>(\n event: E,\n listener: AlchemySignerEvents[E]\n ) => {\n // NOTE: we're using zustand here to handle this because we are able to use the fireImmediately\n // option which deals with a possible race condition where the listener is added after the event\n // is fired. In the Client and SessionManager we use EventEmitter because it's easier to handle internally\n switch (event) {\n case \"connected\":\n return this.store.subscribe(\n ({ status }) => status,\n (status) =>\n status === AlchemySignerStatus.CONNECTED &&\n (listener as AlchemySignerEvents[\"connected\"])(\n this.store.getState().user!\n ),\n { fireImmediately: true }\n );\n case \"disconnected\":\n return this.store.subscribe(\n ({ status }) => status,\n (status) =>\n status === AlchemySignerStatus.DISCONNECTED &&\n (listener as AlchemySignerEvents[\"disconnected\"])(),\n { fireImmediately: true }\n );\n case \"statusChanged\":\n return this.store.subscribe(\n ({ status }) => status,\n listener as AlchemySignerEvents[\"statusChanged\"],\n { fireImmediately: true }\n );\n case \"errorChanged\":\n return this.store.subscribe(\n ({ error }) => error,\n (error) =>\n (listener as AlchemySignerEvents[\"errorChanged\"])(\n error ?? undefined\n ),\n { fireImmediately: true }\n );\n case \"newUserSignup\":\n return this.store.subscribe(\n ({ isNewUser }) => isNewUser,\n (isNewUser) => {\n if (isNewUser) (listener as AlchemySignerEvents[\"newUserSignup\"])();\n },\n { fireImmediately: true }\n );\n case \"mfaStatusChanged\":\n return this.store.subscribe(\n ({ mfaStatus }) => mfaStatus,\n (mfaStatus) =>\n (listener as AlchemySignerEvents[\"mfaStatusChanged\"])(mfaStatus),\n { fireImmediately: true }\n );\n default:\n assertNever(event, `Unknown event type ${event}`);\n }\n };\n\n /**\n * Prepares the config needed to use popup-based OAuth login. This must be\n * called before calling `.authenticate` with params `{ type: \"oauth\", mode:\n * \"popup\" }`, and is recommended to be called on page load.\n *\n * This method exists because browsers may prevent popups from opening unless\n * triggered by user interaction, and so the OAuth config must already have\n * been fetched at the time a user clicks a social login button.\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 * await signer.preparePopupOauth();\n * ```\n * @returns {Promise<OauthConfig>} the config which must be loaded before\n * using popup-based OAuth\n */\n preparePopupOauth = (): Promise<OauthConfig> => this.inner.initOauth();\n\n /**\n * Authenticate a user with either an email or a passkey and create a session for that user\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 * const result = await signer.authenticate({\n * type: \"email\",\n * email: \"foo@mail.com\",\n * });\n * ```\n *\n * @param {AuthParams} params - undefined if passkey login, otherwise an object with email and bundle to resolve\n * @returns {Promise<User>} the user that was authenticated\n */\n authenticate: (params: AuthParams) => Promise<User> = SignerLogger.profiled(\n \"BaseAlchemySigner.authenticate\",\n async (params) => {\n const { type } = params;\n const result = (() => {\n switch (type) {\n case \"email\":\n return this.authenticateWithEmail(params);\n case \"passkey\":\n return this.authenticateWithPasskey(params);\n case \"oauth\":\n return this.authenticateWithOauth(params);\n case \"oauthReturn\":\n return this.handleOauthReturn(params);\n case \"otp\":\n return this.authenticateWithOtp(params);\n default:\n assertNever(type, `Unknown auth type: ${type}`);\n }\n })();\n\n this.trackAuthenticateType(params);\n\n return result.catch((error) => {\n /**\n * 2 things going on here:\n * 1. for oauth flows we expect the status to remain in authenticating\n * 2. we do the ternary, because if we explicitly pass in `undefined` for the status, zustand will set the value of status to `undefined`.\n * However, if we omit it, then it will not override the current value of status.\n */\n this.store.setState({\n error: toErrorInfo(error),\n ...(type === \"oauthReturn\" || type === \"oauth\"\n ? {}\n : { status: AlchemySignerStatus.DISCONNECTED }),\n });\n throw error;\n });\n }\n );\n\n private trackAuthenticateType = (params: AuthParams) => {\n const { type } = params;\n switch (type) {\n case \"email\": {\n // we just want to track the start of email auth\n if (\"bundle\" in params) return;\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: { authType: \"email\" },\n });\n return;\n }\n case \"passkey\": {\n const isAnon = !(\"email\" in params) && params.createNew == null;\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: {\n authType: isAnon ? \"passkey_anon\" : \"passkey_email\",\n },\n });\n return;\n }\n case \"oauth\":\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: {\n authType: \"oauth\",\n provider: params.authProviderId,\n },\n });\n break;\n case \"oauthReturn\":\n break;\n case \"otp\":\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: { authType: \"otp\" },\n });\n break;\n default:\n assertNever(type, `Unknown auth type: ${type}`);\n }\n };\n\n /**\n * Clear a user session and log them out\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 * await signer.disconnect();\n * ```\n *\n * @returns {Promise<void>} a promise that resolves when the user is logged out\n */\n disconnect: () => Promise<void> = async () => {\n await this.inner.disconnect();\n };\n\n /**\n * Gets the current logged in user\n * If a user has an ongoing session, it will use that session and\n * try to authenticate\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 * // throws if not logged in\n * const user = await signer.getAuthDetails();\n * ```\n *\n * @throws if there is no user logged in\n * @returns {Promise<User>} the current user\n */\n getAuthDetails = async (): Promise<User> => {\n const sessionUser = await this.sessionManager.getSessionUser();\n if (sessionUser != null) {\n return sessionUser;\n }\n\n return this.inner.whoami();\n };\n\n /**\n * Retrieves the address of the current user by calling the `whoami` method on `this.inner`.\n *\n * @returns {Promise<string>} A promise that resolves to the address of the current user.\n */\n getAddress: () => Promise<`0x${string}`> = SignerLogger.profiled(\n \"BaseAlchemySigner.getAddress\",\n async () => {\n const { address } = await this.inner.whoami();\n\n return address;\n }\n );\n\n /**\n * Signs a raw message after hashing it.\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 * const signature = await signer.signMessage(\"Hello, world!\");\n * ```\n *\n * @param {string} msg the message to be hashed and then signed\n * @returns {Promise<string>} a promise that resolves to the signed message\n */\n signMessage: (msg: SignableMessage) => Promise<`0x${string}`> =\n SignerLogger.profiled(\"BaseAlchemySigner.signMessage\", async (msg) => {\n const messageHash = hashMessage(msg);\n\n const result = await this.inner.signRawMessage(messageHash);\n\n SignerLogger.trackEvent({\n name: \"signer_sign_message\",\n });\n\n return result;\n });\n\n /**\n * Signs a typed message by first hashing it and then signing the hashed message using the `signRawMessage` method.\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 * const signature = await signer.signTypedData({\n * domain: {},\n * types: {},\n * primaryType: \"\",\n * message: {},\n * });\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters for the typed message to be hashed and signed\n * @returns {Promise<any>} A promise that resolves to the signed message\n */\n signTypedData: <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" = keyof TTypedData\n >(\n params: TypedDataDefinition<TTypedData, TPrimaryType>\n ) => Promise<Hex> = SignerLogger.profiled(\n \"BaseAlchemySigner.signTypedData\",\n async (params) => {\n const messageHash = hashTypedData(params);\n\n return this.inner.signRawMessage(messageHash);\n }\n );\n\n /**\n * Serializes a transaction, signs it with a raw message, and then returns the serialized transaction with the signature.\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 * const tx = await signer.signTransaction({\n * to: \"0x1234\",\n * value: \"0x1234\",\n * data: \"0x1234\",\n * });\n * ```\n *\n * @param {Transaction} tx the transaction to be serialized and signed\n * @param {{serializer?: SerializeTransactionFn}} args options for serialization\n * @param {() => Hex} [args.serializer] an optional serializer function. If not provided, the default `serializeTransaction` function will be used\n * @returns {Promise<string>} a promise that resolves to the serialized transaction with the signature\n */\n signTransaction: <\n serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]\n >(\n transaction: transaction,\n options?:\n | {\n serializer?: serializer | undefined;\n }\n | undefined\n ) => Promise<\n IsNarrowable<\n TransactionSerialized<GetTransactionType<transaction>>,\n Hex\n > extends true\n ? TransactionSerialized<GetTransactionType<transaction>>\n : Hex\n > = SignerLogger.profiled(\n \"BaseAlchemySigner.signTransaction\",\n async (tx, args) => {\n const serializeFn = args?.serializer ?? serializeTransaction;\n const serializedTx = serializeFn(tx);\n const signatureHex = await this.inner.signRawMessage(\n keccak256(serializedTx)\n );\n\n const signature = this.unpackSignRawMessageBytes(signatureHex);\n\n return serializeFn(tx, signature);\n }\n );\n\n /**\n * Signs an EIP-7702 Authorization and then returns the authorization with the signature.\n *\n * @example\n * ```ts twoslash\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 * const tx = await signer.signAuthorization({\n * contractAddress: \"0x1234123412341234123412341234123412341234\",\n * chainId: 1,\n * nonce: 0,\n * });\n * ```\n *\n * @param {Authorization<number, false>} unsignedAuthorization the authorization to be signed\n * @returns {Promise<Authorization<number, true>> | undefined} a promise that resolves to the authorization with the signature\n */\n signAuthorization: (\n unsignedAuthorization: Authorization<number, false>\n ) => Promise<Authorization<number, true>> = SignerLogger.profiled(\n \"BaseAlchemySigner.signAuthorization\",\n async (unsignedAuthorization) => {\n const hashedAuthorization = hashAuthorization(unsignedAuthorization);\n const signedAuthorizationHex = await this.inner.signRawMessage(\n hashedAuthorization\n );\n const signature = this.unpackSignRawMessageBytes(signedAuthorizationHex);\n return { ...unsignedAuthorization, ...signature };\n }\n );\n\n /**\n * Gets the current MFA status\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 * const mfaStatus = signer.getMfaStatus();\n * if (mfaStatus === AlchemyMfaStatus.REQUIRED) {\n * // Handle MFA requirement\n * }\n * ```\n *\n * @returns {{ mfaRequired: boolean; mfaFactorId?: string }} The current MFA status\n */\n getMfaStatus = (): {\n mfaRequired: boolean;\n mfaFactorId?: string;\n } => {\n return this.store.getState().mfaStatus;\n };\n\n private unpackSignRawMessageBytes = (\n hex: `0x${string}`\n ): UnpackedSignature => {\n return {\n r: takeBytes(hex, { count: 32 }),\n s: takeBytes(hex, { count: 32, offset: 32 }),\n v: BigInt(takeBytes(hex, { count: 1, offset: 64 })),\n };\n };\n\n /**\n * Unauthenticated call to look up a user's organizationId by email\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 * const result = await signer.getUser(\"foo@mail.com\");\n * ```\n *\n * @param {string} email the email to lookup\n * @returns {Promise<{orgId: string}>} the organization id for the user if they exist\n */\n getUser: (email: string) => Promise<{ orgId: string } | null> =\n SignerLogger.profiled(\"BaseAlchemySigner.getUser\", async (email) => {\n const result = await this.inner.lookupUserByEmail(email);\n\n if (result.orgId == null) {\n return null;\n }\n\n return {\n orgId: result.orgId,\n };\n });\n\n /**\n * Adds a passkey to the user's account\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 * const result = await signer.addPasskey()\n * ```\n *\n * @param {CredentialCreationOptions | undefined} params optional parameters for the passkey creation\n * @returns {Promise<string[]>} an array of the authenticator ids added to the user\n */\n addPasskey: (params?: CredentialCreationOptions) => Promise<string[]> =\n SignerLogger.profiled(\"BaseAlchemySigner.addPasskey\", async (params) => {\n return this.inner.addPasskey(params ?? {});\n });\n\n getPasskeyStatus: () => Promise<{ isPasskeyAdded: boolean }> =\n SignerLogger.profiled(\"BaseAlchemySigner.getPasskeyStatus\", async () => {\n return this.inner.getPasskeyStatus();\n });\n\n /**\n * Used to export the wallet for a given user\n * If the user is authenticated with an Email, this will return a seed phrase\n * If the user is authenticated with a Passkey, this will return a private key\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 * // the params passed to this are different based on the specific signer\n * const result = signer.exportWallet()\n * ```\n *\n * @param {unknown} params export wallet parameters\n * @returns {boolean} true if the wallet was exported successfully\n */\n exportWallet: (\n params: Parameters<(typeof this.inner)[\"exportWallet\"]>[0]\n ) => Promise<boolean> = async (params) => {\n return this.inner.exportWallet(params);\n };\n\n /**\n * This method lets you adapt your AlchemySigner to a viem LocalAccount, which\n * will let you use the signer as an EOA directly.\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 * const account = signer.toViemAccount();\n * ```\n *\n * @throws if your signer is not authenticated\n * @returns {LocalAccount} a LocalAccount object that can be used with viem's wallet client\n */\n toViemAccount = (): LocalAccount => {\n // if we want this method to be synchronous, then we need to do this check here\n // otherwise we can use the sessionManager to get the user\n if (!this.inner.getUser()) {\n throw new NotAuthenticatedError();\n }\n\n return toAccount({\n address: this.inner.getUser()!.address,\n signMessage: (msg) => this.signMessage(msg.message),\n signTypedData: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ) => this.signTypedData<typedData, primaryType>(typedDataDefinition),\n signTransaction: this.signTransaction,\n });\n };\n\n /**\n * Creates a new instance of `SolanaSigner` using the provided inner value.\n * This requires the signer to be authenticated first\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 * const solanaSigner = signer.toSolanaSigner();\n * ```\n *\n * @returns {SolanaSigner} A new instance of `SolanaSigner`\n */\n experimental_toSolanaSigner = (): SolanaSigner => {\n if (!this.inner.getUser()) {\n throw new NotAuthenticatedError();\n }\n\n return new SolanaSigner(this.inner);\n };\n\n private authenticateWithEmail = async (\n params: Extract<AuthParams, { type: \"email\" }>\n ): Promise<User> => {\n if (\"bundle\" in params) {\n return this.completeEmailAuth(params);\n }\n\n const { orgId, otpId, isNewUser } = await this.initOrCreateEmailUser(\n params.email,\n params.emailMode,\n params.multiFactors,\n params.redirectParams\n );\n\n this.sessionManager.setTemporarySession({\n orgId,\n isNewUser,\n });\n\n this.store.setState({\n status: AlchemySignerStatus.AWAITING_EMAIL_AUTH,\n otpId,\n error: null,\n });\n\n // We wait for the session manager to emit a connected event if\n // cross tab sessions are permitted\n return new Promise<User>((resolve) => {\n const removeListener = this.sessionManager.on(\"connected\", (session) => {\n resolve(session.user);\n removeListener();\n });\n });\n };\n\n private authenticateWithPasskey = async (\n args: Extract<AuthParams, { type: \"passkey\" }>\n ): Promise<User> => {\n let user: User;\n const shouldCreateNew = async () => {\n if (\"email\" in args) {\n const existingUser = await this.getUser(args.email);\n return existingUser == null;\n }\n\n return args.createNew;\n };\n\n if (await shouldCreateNew()) {\n const result = await this.inner.createAccount(\n args as Extract<\n AuthParams,\n { type: \"passkey\" } & ({ email: string } | { createNew: true })\n >\n );\n // account creation for passkeys returns the whoami response so we don't have to\n // call it again after signup\n user = {\n address: result.address!,\n userId: result.userId!,\n orgId: result.orgId,\n };\n } else {\n user = await this.inner.lookupUserWithPasskey();\n if (!user) {\n this.store.setState({\n status: AlchemySignerStatus.DISCONNECTED,\n });\n throw new Error(\"No user found\");\n }\n }\n\n return user;\n };\n\n private authenticateWithOauth = async (\n args: Extract<AuthParams, { type: \"oauth\" }>\n ): Promise<User> => {\n const params: OauthParams = {\n ...args,\n expirationSeconds: this.getExpirationSeconds(),\n };\n if (params.mode === \"redirect\") {\n return this.inner.oauthWithRedirect(params);\n } else {\n return this.inner.oauthWithPopup(params);\n }\n };\n\n private authenticateWithOtp = async (\n args: Extract<AuthParams, { type: \"otp\" }>\n ): Promise<User> => {\n const tempSession = this.sessionManager.getTemporarySession();\n const { orgId, isNewUser } = tempSession ?? {};\n const { otpId } = this.store.getState();\n if (!orgId) {\n throw new Error(\"orgId not found in session\");\n }\n if (!otpId) {\n throw new Error(\"otpId not found in session\");\n }\n\n const response = await this.inner.submitOtpCode({\n orgId,\n otpId,\n otpCode: args.otpCode,\n expirationSeconds: this.getExpirationSeconds(),\n multiFactors: args.multiFactors,\n });\n\n if (response.mfaRequired) {\n this.handleMfaRequired(response.encryptedPayload, response.multiFactors);\n\n return new Promise<User>((resolve) => {\n const removeListener = this.sessionManager.on(\n \"connected\",\n (session) => {\n resolve(session.user);\n removeListener();\n }\n );\n });\n }\n\n const user = await this.inner.completeAuthWithBundle({\n bundle: response.bundle,\n orgId,\n connectedEventName: \"connectedOtp\",\n authenticatingType: \"otp\",\n });\n\n this.emitNewUserEvent(isNewUser);\n if (tempSession) {\n this.sessionManager.setTemporarySession({\n ...tempSession,\n isNewUser: false,\n });\n }\n\n return user;\n };\n\n private handleOauthReturn = ({\n bundle,\n orgId,\n idToken,\n isNewUser,\n }: Extract<AuthParams, { type: \"oauthReturn\" }>): Promise<User> => {\n const user = this.inner.completeAuthWithBundle({\n bundle,\n orgId,\n connectedEventName: \"connectedOauth\",\n authenticatingType: \"oauth\",\n idToken,\n });\n\n this.emitNewUserEvent(isNewUser);\n\n return user;\n };\n\n private handleMfaRequired(\n encryptedPayload: string,\n multiFactors: MfaFactor[]\n ) {\n // Store complete MFA context in the temporary session\n const tempSession = this.sessionManager.getTemporarySession();\n if (tempSession) {\n this.sessionManager.setTemporarySession({\n ...tempSession,\n encryptedPayload,\n mfaFactorId: multiFactors?.[0]?.multiFactorId,\n });\n }\n\n // Keep minimal state in the store for UI updates\n this.store.setState({\n status: AlchemySignerStatus.AWAITING_MFA_AUTH,\n error: null,\n mfaStatus: {\n mfaRequired: true,\n mfaFactorId: multiFactors?.[0]?.multiFactorId,\n },\n });\n }\n\n private getExpirationSeconds = () =>\n Math.floor(this.sessionManager.expirationTimeMs / 1000);\n\n private registerListeners = () => {\n // Declare listeners in an object to typecheck that every event type is\n // handled.\n const listeners: SessionManagerEvents = {\n connected: (session) => {\n this.store.setState({\n user: session.user,\n status: AlchemySignerStatus.CONNECTED,\n error: null,\n });\n },\n disconnected: () => {\n this.store.setState({\n user: null,\n status: AlchemySignerStatus.DISCONNECTED,\n });\n },\n initialized: () => {\n this.store.setState((state) => ({\n status: state.user\n ? AlchemySignerStatus.CONNECTED\n : AlchemySignerStatus.DISCONNECTED,\n ...(state.user ? { error: null } : undefined),\n }));\n },\n };\n\n for (const [event, listener] of Object.entries(listeners)) {\n this.sessionManager.on(event as keyof SessionManagerEvents, listener);\n }\n\n this.inner.on(\"authenticating\", ({ type }) => {\n const status = (() => {\n switch (type) {\n case \"email\":\n return AlchemySignerStatus.AUTHENTICATING_EMAIL;\n case \"passkey\":\n return AlchemySignerStatus.AUTHENTICATING_PASSKEY;\n case \"oauth\":\n return AlchemySignerStatus.AUTHENTICATING_OAUTH;\n case \"otp\":\n case \"otpVerify\":\n return AlchemySignerStatus.AWAITING_OTP_AUTH;\n default:\n assertNever(type, \"unhandled authenticating type\");\n }\n })();\n\n // trigger new user event on signer from client\n this.inner.on(\"newUserSignup\", () => {\n this.emitNewUserEvent(true);\n });\n\n this.store.setState({\n status,\n error: null,\n });\n });\n };\n\n private emitNewUserEvent = (isNewUser?: boolean) => {\n // assumes that if isNewUser is undefined it is a returning user\n if (isNewUser) this.store.setState({ isNewUser });\n };\n\n private async initOrCreateEmailUser(\n email: string,\n emailMode?: EmailType,\n multiFactors?: VerifyMfaParams[],\n redirectParams?: URLSearchParams\n ): Promise<{\n orgId: string;\n otpId?: string;\n isNewUser: boolean;\n }> {\n const existingUser = await this.getUser(email);\n const expirationSeconds = this.getExpirationSeconds();\n\n if (existingUser) {\n const { orgId, otpId } = await this.inner.initEmailAuth({\n email: email,\n emailMode: emailMode,\n expirationSeconds,\n redirectParams: redirectParams,\n multiFactors,\n });\n return {\n orgId,\n otpId,\n isNewUser: false,\n };\n }\n\n const { orgId, otpId } = await this.inner.createAccount({\n type: \"email\",\n email,\n emailMode,\n expirationSeconds,\n redirectParams,\n });\n return {\n orgId,\n otpId,\n isNewUser: true,\n };\n }\n\n private async completeEmailAuth(\n params: Extract<AuthParams, { type: \"email\"; bundle: string }>\n ): Promise<User> {\n const temporarySession = params.orgId\n ? { orgId: params.orgId }\n : this.sessionManager.getTemporarySession();\n\n if (!temporarySession) {\n this.store.setState({ status: AlchemySignerStatus.DISCONNECTED });\n throw new Error(\"Could not find email auth init session!\");\n }\n\n const user = await this.inner.completeAuthWithBundle({\n bundle: params.bundle,\n orgId: temporarySession.orgId,\n connectedEventName: \"connectedEmail\",\n authenticatingType: \"email\",\n });\n\n // fire new user event\n this.emitNewUserEvent(params.isNewUser);\n\n return user;\n }\n\n /**\n * Retrieves the list of MFA factors configured for the current user.\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 * const { multiFactors } = await signer.getMfaFactors();\n * ```\n *\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<{ multiFactors: Array<MfaFactor> }>} A promise that resolves to an array of configured MFA factors\n */\n getMfaFactors: () => Promise<{ multiFactors: MfaFactor[] }> =\n SignerLogger.profiled(\"BaseAlchemySigner.getMfaFactors\", async () => {\n return this.inner.getMfaFactors();\n });\n\n /**\n * Initiates the setup of a new MFA factor for the current user.\n * The factor will need to be verified using verifyMfa before it becomes active.\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 * const result = await signer.addMfa({ multiFactorType: \"totp\" });\n * // Result contains multiFactorTotpUrl to display as QR code\n * ```\n *\n * @param {EnableMfaParams} params The parameters required to enable a new MFA factor\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<EnableMfaResult>} A promise that resolves to the factor setup information\n */\n addMfa: (params: EnableMfaParams) => Promise<EnableMfaResult> =\n SignerLogger.profiled(\"BaseAlchemySigner.addMfa\", async (params) => {\n return this.inner.addMfa(params);\n });\n\n /**\n * Verifies a newly created MFA factor to complete the setup process.\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 * const result = await signer.verifyMfa({\n * multiFactorId: \"factor-id\",\n * multiFactorCode: \"123456\" // 6-digit code from authenticator app\n * });\n * ```\n *\n * @param {VerifyMfaParams} params The parameters required to verify the MFA factor\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors\n */\n verifyMfa: (\n params: VerifyMfaParams\n ) => Promise<{ multiFactors: MfaFactor[] }> = SignerLogger.profiled(\n \"BaseAlchemySigner.verifyMfa\",\n async (params) => {\n return this.inner.verifyMfa(params);\n }\n );\n\n /**\n * Removes existing MFA factors by their IDs.\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 * const result = await signer.removeMfa({\n * multiFactorIds: [\"factor-id-1\", \"factor-id-2\"]\n * });\n * ```\n *\n * @param {RemoveMfaParams} params The parameters specifying which factors to disable\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors\n */\n removeMfa: (\n params: RemoveMfaParams\n ) => Promise<{ multiFactors: MfaFactor[] }> = SignerLogger.profiled(\n \"BaseAlchemySigner.removeMfa\",\n async (params) => {\n return this.inner.removeMfa(params);\n }\n );\n\n /**\n * Validates MFA factors that were required during authentication.\n * This function should be called after MFA is required and the user has provided their MFA code.\n * It completes the authentication process by validating the MFA factors and completing the auth bundle.\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 * // After MFA is required and user provides code\n * const user = await signer.validateMultiFactors({\n * multiFactorCode: \"123456\", // 6-digit code from authenticator app\n * multiFactorId: \"factor-id\"\n * });\n * ```\n *\n * @param {ValidateMultiFactorsArgs} params - Parameters for validating MFA factors\n * @throws {Error} If there is no pending MFA context or if orgId is not found\n * @returns {Promise<User>} A promise that resolves to the authenticated user\n */\n public async validateMultiFactors(\n params: ValidateMultiFactorsArgs\n ): Promise<User> {\n // Get MFA context from temporary session\n const tempSession = this.sessionManager.getTemporarySession();\n if (\n !tempSession?.orgId ||\n !tempSession.encryptedPayload ||\n !tempSession.mfaFactorId\n ) {\n throw new Error(\n \"No pending MFA context found. Call submitOtpCode() first.\"\n );\n }\n\n if (\n params.multiFactorId &&\n tempSession.mfaFactorId !== params.multiFactorId\n ) {\n throw new Error(\"MFA factor ID mismatch\");\n }\n\n // Call the low-level client\n const { bundle } = await this.inner.validateMultiFactors({\n encryptedPayload: tempSession.encryptedPayload,\n multiFactors: [\n {\n multiFactorId: tempSession.mfaFactorId,\n multiFactorCode: params.multiFactorCode,\n },\n ],\n });\n\n // Complete the authentication\n const user = await this.inner.completeAuthWithBundle({\n bundle,\n orgId: tempSession.orgId,\n connectedEventName: \"connectedOtp\",\n authenticatingType: \"otp\",\n });\n\n // Remove MFA data from temporary session\n this.sessionManager.setTemporarySession({\n ...tempSession,\n encryptedPayload: undefined,\n mfaFactorId: undefined,\n });\n\n // Update UI state\n this.store.setState({\n mfaStatus: {\n mfaRequired: false,\n mfaFactorId: undefined,\n },\n });\n\n return user;\n }\n\n protected initConfig = async (): Promise<SignerConfig> => {\n this.config = this.fetchConfig();\n return this.config;\n };\n\n /**\n * Returns the signer configuration while fetching it if it's not already initialized.\n *\n * @returns {Promise<SignerConfig>} A promise that resolves to the signer configuration\n */\n public getConfig = async (): Promise<SignerConfig> => {\n if (!this.config) {\n return this.initConfig();\n }\n\n return this.config;\n };\n\n protected fetchConfig = async (): Promise<SignerConfig> => {\n return this.inner.request(\"/v1/signer-config\", {});\n };\n}\n\nfunction toErrorInfo(error: unknown): ErrorInfo {\n return error instanceof Error\n ? { name: error.name, message: error.message }\n : { name: \"Error\", message: \"Unknown error\" };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkC,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,EACT,oBAAoB,GAWrB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAsB,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAa9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,c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E,KAAK;SAC1B,CAAC,CAAC;QAEH,yCAAyC;QACzC,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC;YACtC,GAAG,WAAW;YACd,gBAAgB,EAAE,SAAS;YAC3B,WAAW,EAAE,SAAS;SACvB,CAAC,CAAC;QAEH,kBAAkB;QAClB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YAClB,SAAS,EAAE;gBACT,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,SAAS;aACvB;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CAuBF;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,YAAY,KAAK;QAC3B,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;QAC9C,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AAClD,CAAC","sourcesContent":["import { takeBytes, type SmartAccountAuthenticator } from \"@aa-sdk/core\";\nimport {\n hashMessage,\n hashTypedData,\n keccak256,\n serializeTransaction,\n type GetTransactionType,\n type Hex,\n type IsNarrowable,\n type LocalAccount,\n type SerializeTransactionFn,\n type SignableMessage,\n type TransactionSerializable,\n type TransactionSerialized,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { hashAuthorization, type Authorization } from \"viem/experimental\";\nimport type { Mutate, StoreApi } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\nimport { createStore } from \"zustand/vanilla\";\nimport type { BaseSignerClient } from \"./client/base\";\nimport type {\n EmailType,\n MfaFactor,\n OauthConfig,\n OauthParams,\n User,\n VerifyMfaParams,\n AddMfaParams,\n AddMfaResult,\n RemoveMfaParams,\n} from \"./client/types\";\nimport { NotAuthenticatedError } from \"./errors.js\";\nimport { SignerLogger } from \"./metrics.js\";\nimport {\n SessionManager,\n type SessionManagerParams,\n} from \"./session/manager.js\";\nimport type { SessionManagerEvents } from \"./session/types\";\nimport type { AuthParams } from \"./signer\";\nimport { SolanaSigner } from \"./solanaSigner.js\";\nimport {\n AlchemySignerStatus,\n type AlchemySignerEvent,\n type AlchemySignerEvents,\n type ErrorInfo,\n type ValidateMultiFactorsArgs,\n} from \"./types.js\";\nimport { assertNever } from \"./utils/typeAssertions.js\";\n\nexport interface BaseAlchemySignerParams<TClient extends BaseSignerClient> {\n client: TClient;\n sessionConfig?: Omit<SessionManagerParams, \"client\">;\n initialError?: ErrorInfo;\n}\n\ntype AlchemySignerStore = {\n user: User | null;\n status: AlchemySignerStatus;\n error: ErrorInfo | null;\n otpId?: string;\n isNewUser?: boolean;\n mfaStatus: {\n mfaRequired: boolean;\n mfaFactorId?: string;\n encryptedPayload?: string;\n };\n};\n\ntype UnpackedSignature = {\n r: `0x${string}`;\n s: `0x${string}`;\n v: bigint;\n};\n\ntype InternalStore = Mutate<\n StoreApi<AlchemySignerStore>,\n [[\"zustand/subscribeWithSelector\", never]]\n>;\n\nexport type EmailConfig = {\n mode?: \"MAGIC_LINK\" | \"OTP\";\n};\n\nexport type SignerConfig = {\n email: EmailConfig;\n};\n\n/**\n * Base abstract class for Alchemy Signer, providing authentication and session management for smart accounts.\n * Implements the `SmartAccountAuthenticator` interface and handles various signer events.\n */\nexport abstract class BaseAlchemySigner<TClient extends BaseSignerClient>\n implements SmartAccountAuthenticator<AuthParams, User, TClient>\n{\n signerType: \"alchemy-signer\" | \"rn-alchemy-signer\" = \"alchemy-signer\";\n inner: TClient;\n private sessionManager: SessionManager;\n private store: InternalStore;\n private config: Promise<SignerConfig>;\n\n /**\n * Initializes an instance with the provided client and session configuration.\n * This function sets up the internal store, initializes the session manager,\n * registers listeners and initializes the session manager to manage session state.\n *\n * @param {BaseAlchemySignerParams<TClient>} param0 Object containing the client and session configuration\n * @param {TClient} param0.client The client instance to be used internally\n * @param {SessionConfig} param0.sessionConfig Configuration for managing sessions\n * @param {ErrorInfo | undefined} param0.initialError Error already present on the signer when initialized, if any\n */\n constructor({\n client,\n sessionConfig,\n initialError,\n }: BaseAlchemySignerParams<TClient>) {\n this.inner = client;\n this.store = createStore(\n subscribeWithSelector(\n () =>\n ({\n user: null,\n status: AlchemySignerStatus.INITIALIZING,\n error: initialError ?? null,\n mfaStatus: {\n mfaRequired: false,\n mfaFactorId: undefined,\n },\n } satisfies AlchemySignerStore)\n )\n );\n // NOTE: it's important that the session manager share a client\n // with the signer. The SessionManager leverages the Signer's client\n // to manage session state.\n this.sessionManager = new SessionManager({\n ...sessionConfig,\n client: this.inner,\n });\n // register listeners first\n this.registerListeners();\n // then initialize so that we can catch those events\n this.sessionManager.initialize();\n this.config = this.fetchConfig();\n }\n\n /**\n * Allows you to subscribe to events emitted by the signer\n *\n * @param {AlchemySignerEvent} event the event to subscribe to\n * @param {AlchemySignerEvents[AlchemySignerEvent]} listener the function to run when the event is emitted\n * @returns {() => void} a function to remove the listener\n */\n on = <E extends AlchemySignerEvent>(\n event: E,\n listener: AlchemySignerEvents[E]\n ) => {\n // NOTE: we're using zustand here to handle this because we are able to use the fireImmediately\n // option which deals with a possible race condition where the listener is added after the event\n // is fired. In the Client and SessionManager we use EventEmitter because it's easier to handle internally\n switch (event) {\n case \"connected\":\n return this.store.subscribe(\n ({ status }) => status,\n (status) =>\n status === AlchemySignerStatus.CONNECTED &&\n (listener as AlchemySignerEvents[\"connected\"])(\n this.store.getState().user!\n ),\n { fireImmediately: true }\n );\n case \"disconnected\":\n return this.store.subscribe(\n ({ status }) => status,\n (status) =>\n status === AlchemySignerStatus.DISCONNECTED &&\n (listener as AlchemySignerEvents[\"disconnected\"])(),\n { fireImmediately: true }\n );\n case \"statusChanged\":\n return this.store.subscribe(\n ({ status }) => status,\n listener as AlchemySignerEvents[\"statusChanged\"],\n { fireImmediately: true }\n );\n case \"errorChanged\":\n return this.store.subscribe(\n ({ error }) => error,\n (error) =>\n (listener as AlchemySignerEvents[\"errorChanged\"])(\n error ?? undefined\n ),\n { fireImmediately: true }\n );\n case \"newUserSignup\":\n return this.store.subscribe(\n ({ isNewUser }) => isNewUser,\n (isNewUser) => {\n if (isNewUser) (listener as AlchemySignerEvents[\"newUserSignup\"])();\n },\n { fireImmediately: true }\n );\n case \"mfaStatusChanged\":\n return this.store.subscribe(\n ({ mfaStatus }) => mfaStatus,\n (mfaStatus) =>\n (listener as AlchemySignerEvents[\"mfaStatusChanged\"])(mfaStatus),\n { fireImmediately: true }\n );\n default:\n assertNever(event, `Unknown event type ${event}`);\n }\n };\n\n /**\n * Prepares the config needed to use popup-based OAuth login. This must be\n * called before calling `.authenticate` with params `{ type: \"oauth\", mode:\n * \"popup\" }`, and is recommended to be called on page load.\n *\n * This method exists because browsers may prevent popups from opening unless\n * triggered by user interaction, and so the OAuth config must already have\n * been fetched at the time a user clicks a social login button.\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 * await signer.preparePopupOauth();\n * ```\n * @returns {Promise<OauthConfig>} the config which must be loaded before\n * using popup-based OAuth\n */\n preparePopupOauth = (): Promise<OauthConfig> => this.inner.initOauth();\n\n /**\n * Authenticate a user with either an email or a passkey and create a session for that user\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 * const result = await signer.authenticate({\n * type: \"email\",\n * email: \"foo@mail.com\",\n * });\n * ```\n *\n * @param {AuthParams} params - undefined if passkey login, otherwise an object with email and bundle to resolve\n * @returns {Promise<User>} the user that was authenticated\n */\n authenticate: (params: AuthParams) => Promise<User> = SignerLogger.profiled(\n \"BaseAlchemySigner.authenticate\",\n async (params) => {\n const { type } = params;\n const result = (() => {\n switch (type) {\n case \"email\":\n return this.authenticateWithEmail(params);\n case \"passkey\":\n return this.authenticateWithPasskey(params);\n case \"oauth\":\n return this.authenticateWithOauth(params);\n case \"oauthReturn\":\n return this.handleOauthReturn(params);\n case \"otp\":\n return this.authenticateWithOtp(params);\n default:\n assertNever(type, `Unknown auth type: ${type}`);\n }\n })();\n\n this.trackAuthenticateType(params);\n\n return result.catch((error) => {\n /**\n * 2 things going on here:\n * 1. for oauth flows we expect the status to remain in authenticating\n * 2. we do the ternary, because if we explicitly pass in `undefined` for the status, zustand will set the value of status to `undefined`.\n * However, if we omit it, then it will not override the current value of status.\n */\n this.store.setState({\n error: toErrorInfo(error),\n ...(type === \"oauthReturn\" || type === \"oauth\"\n ? {}\n : { status: AlchemySignerStatus.DISCONNECTED }),\n });\n throw error;\n });\n }\n );\n\n private trackAuthenticateType = (params: AuthParams) => {\n const { type } = params;\n switch (type) {\n case \"email\": {\n // we just want to track the start of email auth\n if (\"bundle\" in params) return;\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: { authType: \"email\" },\n });\n return;\n }\n case \"passkey\": {\n const isAnon = !(\"email\" in params) && params.createNew == null;\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: {\n authType: isAnon ? \"passkey_anon\" : \"passkey_email\",\n },\n });\n return;\n }\n case \"oauth\":\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: {\n authType: \"oauth\",\n provider: params.authProviderId,\n },\n });\n break;\n case \"oauthReturn\":\n break;\n case \"otp\":\n SignerLogger.trackEvent({\n name: \"signer_authnticate\",\n data: { authType: \"otp\" },\n });\n break;\n default:\n assertNever(type, `Unknown auth type: ${type}`);\n }\n };\n\n /**\n * Clear a user session and log them out\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 * await signer.disconnect();\n * ```\n *\n * @returns {Promise<void>} a promise that resolves when the user is logged out\n */\n disconnect: () => Promise<void> = async () => {\n await this.inner.disconnect();\n };\n\n /**\n * Gets the current logged in user\n * If a user has an ongoing session, it will use that session and\n * try to authenticate\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 * // throws if not logged in\n * const user = await signer.getAuthDetails();\n * ```\n *\n * @throws if there is no user logged in\n * @returns {Promise<User>} the current user\n */\n getAuthDetails = async (): Promise<User> => {\n const sessionUser = await this.sessionManager.getSessionUser();\n if (sessionUser != null) {\n return sessionUser;\n }\n\n return this.inner.whoami();\n };\n\n /**\n * Retrieves the address of the current user by calling the `whoami` method on `this.inner`.\n *\n * @returns {Promise<string>} A promise that resolves to the address of the current user.\n */\n getAddress: () => Promise<`0x${string}`> = SignerLogger.profiled(\n \"BaseAlchemySigner.getAddress\",\n async () => {\n const { address } = await this.inner.whoami();\n\n return address;\n }\n );\n\n /**\n * Signs a raw message after hashing it.\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 * const signature = await signer.signMessage(\"Hello, world!\");\n * ```\n *\n * @param {string} msg the message to be hashed and then signed\n * @returns {Promise<string>} a promise that resolves to the signed message\n */\n signMessage: (msg: SignableMessage) => Promise<`0x${string}`> =\n SignerLogger.profiled(\"BaseAlchemySigner.signMessage\", async (msg) => {\n const messageHash = hashMessage(msg);\n\n const result = await this.inner.signRawMessage(messageHash);\n\n SignerLogger.trackEvent({\n name: \"signer_sign_message\",\n });\n\n return result;\n });\n\n /**\n * Signs a typed message by first hashing it and then signing the hashed message using the `signRawMessage` method.\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 * const signature = await signer.signTypedData({\n * domain: {},\n * types: {},\n * primaryType: \"\",\n * message: {},\n * });\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters for the typed message to be hashed and signed\n * @returns {Promise<any>} A promise that resolves to the signed message\n */\n signTypedData: <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" = keyof TTypedData\n >(\n params: TypedDataDefinition<TTypedData, TPrimaryType>\n ) => Promise<Hex> = SignerLogger.profiled(\n \"BaseAlchemySigner.signTypedData\",\n async (params) => {\n const messageHash = hashTypedData(params);\n\n return this.inner.signRawMessage(messageHash);\n }\n );\n\n /**\n * Serializes a transaction, signs it with a raw message, and then returns the serialized transaction with the signature.\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 * const tx = await signer.signTransaction({\n * to: \"0x1234\",\n * value: \"0x1234\",\n * data: \"0x1234\",\n * });\n * ```\n *\n * @param {Transaction} tx the transaction to be serialized and signed\n * @param {{serializer?: SerializeTransactionFn}} args options for serialization\n * @param {() => Hex} [args.serializer] an optional serializer function. If not provided, the default `serializeTransaction` function will be used\n * @returns {Promise<string>} a promise that resolves to the serialized transaction with the signature\n */\n signTransaction: <\n serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]\n >(\n transaction: transaction,\n options?:\n | {\n serializer?: serializer | undefined;\n }\n | undefined\n ) => Promise<\n IsNarrowable<\n TransactionSerialized<GetTransactionType<transaction>>,\n Hex\n > extends true\n ? TransactionSerialized<GetTransactionType<transaction>>\n : Hex\n > = SignerLogger.profiled(\n \"BaseAlchemySigner.signTransaction\",\n async (tx, args) => {\n const serializeFn = args?.serializer ?? serializeTransaction;\n const serializedTx = serializeFn(tx);\n const signatureHex = await this.inner.signRawMessage(\n keccak256(serializedTx)\n );\n\n const signature = this.unpackSignRawMessageBytes(signatureHex);\n\n return serializeFn(tx, signature);\n }\n );\n\n /**\n * Signs an EIP-7702 Authorization and then returns the authorization with the signature.\n *\n * @example\n * ```ts twoslash\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 * const tx = await signer.signAuthorization({\n * contractAddress: \"0x1234123412341234123412341234123412341234\",\n * chainId: 1,\n * nonce: 0,\n * });\n * ```\n *\n * @param {Authorization<number, false>} unsignedAuthorization the authorization to be signed\n * @returns {Promise<Authorization<number, true>> | undefined} a promise that resolves to the authorization with the signature\n */\n signAuthorization: (\n unsignedAuthorization: Authorization<number, false>\n ) => Promise<Authorization<number, true>> = SignerLogger.profiled(\n \"BaseAlchemySigner.signAuthorization\",\n async (unsignedAuthorization) => {\n const hashedAuthorization = hashAuthorization(unsignedAuthorization);\n const signedAuthorizationHex = await this.inner.signRawMessage(\n hashedAuthorization\n );\n const signature = this.unpackSignRawMessageBytes(signedAuthorizationHex);\n return { ...unsignedAuthorization, ...signature };\n }\n );\n\n /**\n * Gets the current MFA status\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 * const mfaStatus = signer.getMfaStatus();\n * if (mfaStatus === AlchemyMfaStatus.REQUIRED) {\n * // Handle MFA requirement\n * }\n * ```\n *\n * @returns {{ mfaRequired: boolean; mfaFactorId?: string }} The current MFA status\n */\n getMfaStatus = (): {\n mfaRequired: boolean;\n mfaFactorId?: string;\n } => {\n return this.store.getState().mfaStatus;\n };\n\n private unpackSignRawMessageBytes = (\n hex: `0x${string}`\n ): UnpackedSignature => {\n return {\n r: takeBytes(hex, { count: 32 }),\n s: takeBytes(hex, { count: 32, offset: 32 }),\n v: BigInt(takeBytes(hex, { count: 1, offset: 64 })),\n };\n };\n\n /**\n * Unauthenticated call to look up a user's organizationId by email\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 * const result = await signer.getUser(\"foo@mail.com\");\n * ```\n *\n * @param {string} email the email to lookup\n * @returns {Promise<{orgId: string}>} the organization id for the user if they exist\n */\n getUser: (email: string) => Promise<{ orgId: string } | null> =\n SignerLogger.profiled(\"BaseAlchemySigner.getUser\", async (email) => {\n const result = await this.inner.lookupUserByEmail(email);\n\n if (result.orgId == null) {\n return null;\n }\n\n return {\n orgId: result.orgId,\n };\n });\n\n /**\n * Adds a passkey to the user's account\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 * const result = await signer.addPasskey()\n * ```\n *\n * @param {CredentialCreationOptions | undefined} params optional parameters for the passkey creation\n * @returns {Promise<string[]>} an array of the authenticator ids added to the user\n */\n addPasskey: (params?: CredentialCreationOptions) => Promise<string[]> =\n SignerLogger.profiled(\"BaseAlchemySigner.addPasskey\", async (params) => {\n return this.inner.addPasskey(params ?? {});\n });\n\n getPasskeyStatus: () => Promise<{ isPasskeyAdded: boolean }> =\n SignerLogger.profiled(\"BaseAlchemySigner.getPasskeyStatus\", async () => {\n return this.inner.getPasskeyStatus();\n });\n\n /**\n * Used to export the wallet for a given user\n * If the user is authenticated with an Email, this will return a seed phrase\n * If the user is authenticated with a Passkey, this will return a private key\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 * // the params passed to this are different based on the specific signer\n * const result = signer.exportWallet()\n * ```\n *\n * @param {unknown} params export wallet parameters\n * @returns {boolean} true if the wallet was exported successfully\n */\n exportWallet: (\n params: Parameters<(typeof this.inner)[\"exportWallet\"]>[0]\n ) => Promise<boolean> = async (params) => {\n return this.inner.exportWallet(params);\n };\n\n /**\n * This method lets you adapt your AlchemySigner to a viem LocalAccount, which\n * will let you use the signer as an EOA directly.\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 * const account = signer.toViemAccount();\n * ```\n *\n * @throws if your signer is not authenticated\n * @returns {LocalAccount} a LocalAccount object that can be used with viem's wallet client\n */\n toViemAccount = (): LocalAccount => {\n // if we want this method to be synchronous, then we need to do this check here\n // otherwise we can use the sessionManager to get the user\n if (!this.inner.getUser()) {\n throw new NotAuthenticatedError();\n }\n\n return toAccount({\n address: this.inner.getUser()!.address,\n signMessage: (msg) => this.signMessage(msg.message),\n signTypedData: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ) => this.signTypedData<typedData, primaryType>(typedDataDefinition),\n signTransaction: this.signTransaction,\n });\n };\n\n /**\n * Creates a new instance of `SolanaSigner` using the provided inner value.\n * This requires the signer to be authenticated first\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 * const solanaSigner = signer.toSolanaSigner();\n * ```\n *\n * @returns {SolanaSigner} A new instance of `SolanaSigner`\n */\n experimental_toSolanaSigner = (): SolanaSigner => {\n if (!this.inner.getUser()) {\n throw new NotAuthenticatedError();\n }\n\n return new SolanaSigner(this.inner);\n };\n\n private authenticateWithEmail = async (\n params: Extract<AuthParams, { type: \"email\" }>\n ): Promise<User> => {\n if (\"bundle\" in params) {\n return this.completeEmailAuth(params);\n }\n\n const { orgId, otpId, isNewUser } = await this.initOrCreateEmailUser(\n params.email,\n params.emailMode,\n params.multiFactors,\n params.redirectParams\n );\n\n this.sessionManager.setTemporarySession({\n orgId,\n isNewUser,\n });\n\n this.store.setState({\n status: AlchemySignerStatus.AWAITING_EMAIL_AUTH,\n otpId,\n error: null,\n });\n\n // We wait for the session manager to emit a connected event if\n // cross tab sessions are permitted\n return new Promise<User>((resolve) => {\n const removeListener = this.sessionManager.on(\"connected\", (session) => {\n resolve(session.user);\n removeListener();\n });\n });\n };\n\n private authenticateWithPasskey = async (\n args: Extract<AuthParams, { type: \"passkey\" }>\n ): Promise<User> => {\n let user: User;\n const shouldCreateNew = async () => {\n if (\"email\" in args) {\n const existingUser = await this.getUser(args.email);\n return existingUser == null;\n }\n\n return args.createNew;\n };\n\n if (await shouldCreateNew()) {\n const result = await this.inner.createAccount(\n args as Extract<\n AuthParams,\n { type: \"passkey\" } & ({ email: string } | { createNew: true })\n >\n );\n // account creation for passkeys returns the whoami response so we don't have to\n // call it again after signup\n user = {\n address: result.address!,\n userId: result.userId!,\n orgId: result.orgId,\n };\n } else {\n user = await this.inner.lookupUserWithPasskey();\n if (!user) {\n this.store.setState({\n status: AlchemySignerStatus.DISCONNECTED,\n });\n throw new Error(\"No user found\");\n }\n }\n\n return user;\n };\n\n private authenticateWithOauth = async (\n args: Extract<AuthParams, { type: \"oauth\" }>\n ): Promise<User> => {\n const params: OauthParams = {\n ...args,\n expirationSeconds: this.getExpirationSeconds(),\n };\n if (params.mode === \"redirect\") {\n return this.inner.oauthWithRedirect(params);\n } else {\n return this.inner.oauthWithPopup(params);\n }\n };\n\n private authenticateWithOtp = async (\n args: Extract<AuthParams, { type: \"otp\" }>\n ): Promise<User> => {\n const tempSession = this.sessionManager.getTemporarySession();\n const { orgId, isNewUser } = tempSession ?? {};\n const { otpId } = this.store.getState();\n if (!orgId) {\n throw new Error(\"orgId not found in session\");\n }\n if (!otpId) {\n throw new Error(\"otpId not found in session\");\n }\n\n const response = await this.inner.submitOtpCode({\n orgId,\n otpId,\n otpCode: args.otpCode,\n expirationSeconds: this.getExpirationSeconds(),\n multiFactors: args.multiFactors,\n });\n\n if (response.mfaRequired) {\n this.handleMfaRequired(response.encryptedPayload, response.multiFactors);\n\n return new Promise<User>((resolve) => {\n const removeListener = this.sessionManager.on(\n \"connected\",\n (session) => {\n resolve(session.user);\n removeListener();\n }\n );\n });\n }\n\n const user = await this.inner.completeAuthWithBundle({\n bundle: response.bundle,\n orgId,\n connectedEventName: \"connectedOtp\",\n authenticatingType: \"otp\",\n });\n\n this.emitNewUserEvent(isNewUser);\n if (tempSession) {\n this.sessionManager.setTemporarySession({\n ...tempSession,\n isNewUser: false,\n });\n }\n\n return user;\n };\n\n private handleOauthReturn = ({\n bundle,\n orgId,\n idToken,\n isNewUser,\n }: Extract<AuthParams, { type: \"oauthReturn\" }>): Promise<User> => {\n const user = this.inner.completeAuthWithBundle({\n bundle,\n orgId,\n connectedEventName: \"connectedOauth\",\n authenticatingType: \"oauth\",\n idToken,\n });\n\n this.emitNewUserEvent(isNewUser);\n\n return user;\n };\n\n private handleMfaRequired(\n encryptedPayload: string,\n multiFactors: MfaFactor[]\n ) {\n // Store complete MFA context in the temporary session\n const tempSession = this.sessionManager.getTemporarySession();\n if (tempSession) {\n this.sessionManager.setTemporarySession({\n ...tempSession,\n encryptedPayload,\n mfaFactorId: multiFactors?.[0]?.multiFactorId,\n });\n }\n\n // Keep minimal state in the store for UI updates\n this.store.setState({\n status: AlchemySignerStatus.AWAITING_MFA_AUTH,\n error: null,\n mfaStatus: {\n mfaRequired: true,\n mfaFactorId: multiFactors?.[0]?.multiFactorId,\n },\n });\n }\n\n private getExpirationSeconds = () =>\n Math.floor(this.sessionManager.expirationTimeMs / 1000);\n\n private registerListeners = () => {\n // Declare listeners in an object to typecheck that every event type is\n // handled.\n const listeners: SessionManagerEvents = {\n connected: (session) => {\n this.store.setState({\n user: session.user,\n status: AlchemySignerStatus.CONNECTED,\n error: null,\n });\n },\n disconnected: () => {\n this.store.setState({\n user: null,\n status: AlchemySignerStatus.DISCONNECTED,\n });\n },\n initialized: () => {\n this.store.setState((state) => ({\n status: state.user\n ? AlchemySignerStatus.CONNECTED\n : AlchemySignerStatus.DISCONNECTED,\n ...(state.user ? { error: null } : undefined),\n }));\n },\n };\n\n for (const [event, listener] of Object.entries(listeners)) {\n this.sessionManager.on(event as keyof SessionManagerEvents, listener);\n }\n\n this.inner.on(\"authenticating\", ({ type }) => {\n const status = (() => {\n switch (type) {\n case \"email\":\n return AlchemySignerStatus.AUTHENTICATING_EMAIL;\n case \"passkey\":\n return AlchemySignerStatus.AUTHENTICATING_PASSKEY;\n case \"oauth\":\n return AlchemySignerStatus.AUTHENTICATING_OAUTH;\n case \"otp\":\n case \"otpVerify\":\n return AlchemySignerStatus.AWAITING_OTP_AUTH;\n default:\n assertNever(type, \"unhandled authenticating type\");\n }\n })();\n\n // trigger new user event on signer from client\n this.inner.on(\"newUserSignup\", () => {\n this.emitNewUserEvent(true);\n });\n\n this.store.setState({\n status,\n error: null,\n });\n });\n };\n\n private emitNewUserEvent = (isNewUser?: boolean) => {\n // assumes that if isNewUser is undefined it is a returning user\n if (isNewUser) this.store.setState({ isNewUser });\n };\n\n private async initOrCreateEmailUser(\n email: string,\n emailMode?: EmailType,\n multiFactors?: VerifyMfaParams[],\n redirectParams?: URLSearchParams\n ): Promise<{\n orgId: string;\n otpId?: string;\n isNewUser: boolean;\n }> {\n const existingUser = await this.getUser(email);\n const expirationSeconds = this.getExpirationSeconds();\n\n if (existingUser) {\n const { orgId, otpId } = await this.inner.initEmailAuth({\n email: email,\n emailMode: emailMode,\n expirationSeconds,\n redirectParams: redirectParams,\n multiFactors,\n });\n return {\n orgId,\n otpId,\n isNewUser: false,\n };\n }\n\n const { orgId, otpId } = await this.inner.createAccount({\n type: \"email\",\n email,\n emailMode,\n expirationSeconds,\n redirectParams,\n });\n return {\n orgId,\n otpId,\n isNewUser: true,\n };\n }\n\n private async completeEmailAuth(\n params: Extract<AuthParams, { type: \"email\"; bundle: string }>\n ): Promise<User> {\n const temporarySession = params.orgId\n ? { orgId: params.orgId }\n : this.sessionManager.getTemporarySession();\n\n if (!temporarySession) {\n this.store.setState({ status: AlchemySignerStatus.DISCONNECTED });\n throw new Error(\"Could not find email auth init session!\");\n }\n\n const user = await this.inner.completeAuthWithBundle({\n bundle: params.bundle,\n orgId: temporarySession.orgId,\n connectedEventName: \"connectedEmail\",\n authenticatingType: \"email\",\n });\n\n // fire new user event\n this.emitNewUserEvent(params.isNewUser);\n\n return user;\n }\n\n /**\n * Retrieves the list of MFA factors configured for the current user.\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 * const { multiFactors } = await signer.getMfaFactors();\n * ```\n *\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<{ multiFactors: Array<MfaFactor> }>} A promise that resolves to an array of configured MFA factors\n */\n getMfaFactors: () => Promise<{ multiFactors: MfaFactor[] }> =\n SignerLogger.profiled(\"BaseAlchemySigner.getMfaFactors\", async () => {\n return this.inner.getMfaFactors();\n });\n\n /**\n * Initiates the setup of a new MFA factor for the current user.\n * The factor will need to be verified using verifyMfa before it becomes active.\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 * const result = await signer.addMfa({ multiFactorType: \"totp\" });\n * // Result contains multiFactorTotpUrl to display as QR code\n * ```\n *\n * @param {AddMfaParams} params The parameters required to enable a new MFA factor\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<AddMfaResult>} A promise that resolves to the factor setup information\n */\n addMfa: (params: AddMfaParams) => Promise<AddMfaResult> =\n SignerLogger.profiled(\"BaseAlchemySigner.addMfa\", async (params) => {\n return this.inner.addMfa(params);\n });\n\n /**\n * Verifies a newly created MFA factor to complete the setup process.\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 * const result = await signer.verifyMfa({\n * multiFactorId: \"factor-id\",\n * multiFactorCode: \"123456\" // 6-digit code from authenticator app\n * });\n * ```\n *\n * @param {VerifyMfaParams} params The parameters required to verify the MFA factor\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors\n */\n verifyMfa: (\n params: VerifyMfaParams\n ) => Promise<{ multiFactors: MfaFactor[] }> = SignerLogger.profiled(\n \"BaseAlchemySigner.verifyMfa\",\n async (params) => {\n return this.inner.verifyMfa(params);\n }\n );\n\n /**\n * Removes existing MFA factors by their IDs.\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 * const result = await signer.removeMfa({\n * multiFactorIds: [\"factor-id-1\", \"factor-id-2\"]\n * });\n * ```\n *\n * @param {RemoveMfaParams} params The parameters specifying which factors to disable\n * @throws {NotAuthenticatedError} If no user is authenticated\n * @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors\n */\n removeMfa: (\n params: RemoveMfaParams\n ) => Promise<{ multiFactors: MfaFactor[] }> = SignerLogger.profiled(\n \"BaseAlchemySigner.removeMfa\",\n async (params) => {\n return this.inner.removeMfa(params);\n }\n );\n\n /**\n * Validates MFA factors that were required during authentication.\n * This function should be called after MFA is required and the user has provided their MFA code.\n * It completes the authentication process by validating the MFA factors and completing the auth bundle.\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 * // After MFA is required and user provides code\n * const user = await signer.validateMultiFactors({\n * multiFactorCode: \"123456\", // 6-digit code from authenticator app\n * multiFactorId: \"factor-id\"\n * });\n * ```\n *\n * @param {ValidateMultiFactorsArgs} params - Parameters for validating MFA factors\n * @throws {Error} If there is no pending MFA context or if orgId is not found\n * @returns {Promise<User>} A promise that resolves to the authenticated user\n */\n public async validateMultiFactors(\n params: ValidateMultiFactorsArgs\n ): Promise<User> {\n // Get MFA context from temporary session\n const tempSession = this.sessionManager.getTemporarySession();\n if (\n !tempSession?.orgId ||\n !tempSession.encryptedPayload ||\n !tempSession.mfaFactorId\n ) {\n throw new Error(\n \"No pending MFA context found. Call submitOtpCode() first.\"\n );\n }\n\n if (\n params.multiFactorId &&\n tempSession.mfaFactorId !== params.multiFactorId\n ) {\n throw new Error(\"MFA factor ID mismatch\");\n }\n\n // Call the low-level client\n const { bundle } = await this.inner.validateMultiFactors({\n encryptedPayload: tempSession.encryptedPayload,\n multiFactors: [\n {\n multiFactorId: tempSession.mfaFactorId,\n multiFactorCode: params.multiFactorCode,\n },\n ],\n });\n\n // Complete the authentication\n const user = await this.inner.completeAuthWithBundle({\n bundle,\n orgId: tempSession.orgId,\n connectedEventName: \"connectedOtp\",\n authenticatingType: \"otp\",\n });\n\n // Remove MFA data from temporary session\n this.sessionManager.setTemporarySession({\n ...tempSession,\n encryptedPayload: undefined,\n mfaFactorId: undefined,\n });\n\n // Update UI state\n this.store.setState({\n mfaStatus: {\n mfaRequired: false,\n mfaFactorId: undefined,\n },\n });\n\n return user;\n }\n\n protected initConfig = async (): Promise<SignerConfig> => {\n this.config = this.fetchConfig();\n return this.config;\n };\n\n /**\n * Returns the signer configuration while fetching it if it's not already initialized.\n *\n * @returns {Promise<SignerConfig>} A promise that resolves to the signer configuration\n */\n public getConfig = async (): Promise<SignerConfig> => {\n if (!this.config) {\n return this.initConfig();\n }\n\n return this.config;\n };\n\n protected fetchConfig = async (): Promise<SignerConfig> => {\n return this.inner.request(\"/v1/signer-config\", {});\n };\n}\n\nfunction toErrorInfo(error: unknown): ErrorInfo {\n return error instanceof Error\n ? { name: error.name, message: error.message }\n : { name: \"Error\", message: \"Unknown error\" };\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { type ConnectionConfig } from "@aa-sdk/core";
|
|
|
2
2
|
import { TurnkeyClient, type TSignedRequest } from "@turnkey/http";
|
|
3
3
|
import EventEmitter from "eventemitter3";
|
|
4
4
|
import { type Hex } from "viem";
|
|
5
|
-
import type { AlchemySignerClientEvents, AuthenticatingEventMetadata, CreateAccountParams, RemoveMfaParams, EmailAuthParams,
|
|
5
|
+
import type { AlchemySignerClientEvents, AuthenticatingEventMetadata, CreateAccountParams, RemoveMfaParams, EmailAuthParams, AddMfaParams, AddMfaResult, experimental_CreateApiKeyParams, GetOauthProviderUrlArgs, GetWebAuthnAttestationResult, MfaFactor, OauthConfig, OauthParams, OtpParams, SignerBody, SignerResponse, SignupResponse, User, VerifyMfaParams, SubmitOtpCodeResponse, ValidateMultiFactorsParams } from "./types.js";
|
|
6
6
|
export interface BaseSignerClientParams {
|
|
7
7
|
stamper: TurnkeyClient["stamper"];
|
|
8
8
|
connection: ConnectionConfig;
|
|
@@ -62,48 +62,6 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
62
62
|
otpId?: string;
|
|
63
63
|
multiFactors?: MfaFactor[];
|
|
64
64
|
}>;
|
|
65
|
-
/**
|
|
66
|
-
* Retrieves the list of MFA factors configured for the current user.
|
|
67
|
-
*
|
|
68
|
-
* @returns {Promise<{ multiFactors: Array<MfaFactor> }>} A promise that resolves to an array of configured MFA factors
|
|
69
|
-
*/
|
|
70
|
-
abstract getMfaFactors(): Promise<{
|
|
71
|
-
multiFactors: MfaFactor[];
|
|
72
|
-
}>;
|
|
73
|
-
/**
|
|
74
|
-
* Initiates the setup of a new MFA factor for the current user. Mfa will need to be verified before it is active.
|
|
75
|
-
*
|
|
76
|
-
* @param {EnableMfaParams} params The parameters required to enable a new MFA factor
|
|
77
|
-
* @returns {Promise<EnableMfaResult>} A promise that resolves to the factor setup information
|
|
78
|
-
*/
|
|
79
|
-
abstract addMfa(params: EnableMfaParams): Promise<EnableMfaResult>;
|
|
80
|
-
/**
|
|
81
|
-
* Verifies a newly created MFA factor to complete the setup process.
|
|
82
|
-
*
|
|
83
|
-
* @param {VerifyMfaParams} params The parameters required to verify the MFA factor
|
|
84
|
-
* @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors
|
|
85
|
-
*/
|
|
86
|
-
abstract verifyMfa(params: VerifyMfaParams): Promise<{
|
|
87
|
-
multiFactors: MfaFactor[];
|
|
88
|
-
}>;
|
|
89
|
-
/**
|
|
90
|
-
* Removes existing MFA factors by ID or factor type.
|
|
91
|
-
*
|
|
92
|
-
* @param {RemoveMfaParams} params The parameters specifying which factors to disable
|
|
93
|
-
* @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors
|
|
94
|
-
*/
|
|
95
|
-
abstract removeMfa(params: RemoveMfaParams): Promise<{
|
|
96
|
-
multiFactors: MfaFactor[];
|
|
97
|
-
}>;
|
|
98
|
-
/**
|
|
99
|
-
* Validates multiple MFA factors using the provided encrypted payload and MFA codes.
|
|
100
|
-
*
|
|
101
|
-
* @param {ValidateMultiFactorsParams} params The validation parameters
|
|
102
|
-
* @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle
|
|
103
|
-
*/
|
|
104
|
-
abstract validateMultiFactors(params: ValidateMultiFactorsParams): Promise<{
|
|
105
|
-
bundle: string;
|
|
106
|
-
}>;
|
|
107
65
|
abstract completeAuthWithBundle(params: {
|
|
108
66
|
bundle: string;
|
|
109
67
|
orgId: string;
|
|
@@ -222,6 +180,54 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
222
180
|
* @returns {Promise<SignerResponse<R>>} A promise that resolves to the response from the signer
|
|
223
181
|
*/
|
|
224
182
|
request: <R extends "/v1/signup" | "/v1/whoami" | "/v1/auth" | "/v1/lookup" | "/v1/sign-payload" | "/v1/prepare-oauth" | "/v1/otp" | "/v1/auth-list-multi-factors" | "/v1/auth-delete-multi-factors" | "/v1/auth-request-multi-factor" | "/v1/auth-verify-multi-factor" | "/v1/signer-config" | "/v1/auth-validate-multi-factors">(route: R, body: SignerBody<R>) => Promise<SignerResponse<R>>;
|
|
183
|
+
/**
|
|
184
|
+
* Retrieves the list of MFA factors configured for the current user.
|
|
185
|
+
*
|
|
186
|
+
* @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to an array of configured MFA factors
|
|
187
|
+
* @throws {NotAuthenticatedError} If no user is authenticated
|
|
188
|
+
*/
|
|
189
|
+
getMfaFactors: () => Promise<{
|
|
190
|
+
multiFactors: MfaFactor[];
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Initiates the setup of a new MFA factor for the current user. Mfa will need to be verified before it is active.
|
|
194
|
+
*
|
|
195
|
+
* @param {AddMfaParams} params The parameters required to enable a new MFA factor
|
|
196
|
+
* @returns {Promise<AddMfaResult>} A promise that resolves to the factor setup information
|
|
197
|
+
* @throws {NotAuthenticatedError} If no user is authenticated
|
|
198
|
+
* @throws {Error} If an unsupported factor type is provided
|
|
199
|
+
*/
|
|
200
|
+
addMfa: (params: AddMfaParams) => Promise<AddMfaResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Verifies a newly created MFA factor to complete the setup process.
|
|
203
|
+
*
|
|
204
|
+
* @param {VerifyMfaParams} params The parameters required to verify the MFA factor
|
|
205
|
+
* @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors
|
|
206
|
+
* @throws {NotAuthenticatedError} If no user is authenticated
|
|
207
|
+
*/
|
|
208
|
+
verifyMfa: (params: VerifyMfaParams) => Promise<{
|
|
209
|
+
multiFactors: MfaFactor[];
|
|
210
|
+
}>;
|
|
211
|
+
/**
|
|
212
|
+
* Removes existing MFA factors by ID.
|
|
213
|
+
*
|
|
214
|
+
* @param {RemoveMfaParams} params The parameters specifying which factors to disable
|
|
215
|
+
* @returns {Promise<{ multiFactors: MfaFactor[] }>} A promise that resolves to the updated list of MFA factors
|
|
216
|
+
* @throws {NotAuthenticatedError} If no user is authenticated
|
|
217
|
+
*/
|
|
218
|
+
removeMfa: (params: RemoveMfaParams) => Promise<{
|
|
219
|
+
multiFactors: MfaFactor[];
|
|
220
|
+
}>;
|
|
221
|
+
/**
|
|
222
|
+
* Validates multiple MFA factors using the provided encrypted payload and MFA codes.
|
|
223
|
+
*
|
|
224
|
+
* @param {ValidateMultiFactorsParams} params The validation parameters
|
|
225
|
+
* @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle
|
|
226
|
+
* @throws {Error} If no credential bundle is returned from the server
|
|
227
|
+
*/
|
|
228
|
+
validateMultiFactors: (params: ValidateMultiFactorsParams) => Promise<{
|
|
229
|
+
bundle: string;
|
|
230
|
+
}>;
|
|
225
231
|
private exportAsSeedPhrase;
|
|
226
232
|
private exportAsPrivateKey;
|
|
227
233
|
/**
|