@account-kit/signer 4.29.0 → 4.31.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 +1 -1
- package/dist/esm/base.js +1 -1
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/signer.d.ts +1 -0
- package/dist/esm/signer.js +49 -2
- package/dist/esm/signer.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 +1 -1
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/signer.d.ts +1 -0
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/base.ts +1 -1
- package/src/signer.ts +61 -9
- package/src/version.ts +1 -1
package/dist/esm/base.d.ts
CHANGED
|
@@ -445,7 +445,7 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
445
445
|
*
|
|
446
446
|
* @returns {SolanaSigner} A new instance of `SolanaSigner`
|
|
447
447
|
*/
|
|
448
|
-
|
|
448
|
+
toSolanaSigner: () => SolanaSigner;
|
|
449
449
|
private authenticateWithEmail;
|
|
450
450
|
private authenticateWithPasskey;
|
|
451
451
|
private authenticateWithOauth;
|
package/dist/esm/base.js
CHANGED
|
@@ -711,7 +711,7 @@ export class BaseAlchemySigner {
|
|
|
711
711
|
*
|
|
712
712
|
* @returns {SolanaSigner} A new instance of `SolanaSigner`
|
|
713
713
|
*/
|
|
714
|
-
Object.defineProperty(this, "
|
|
714
|
+
Object.defineProperty(this, "toSolanaSigner", {
|
|
715
715
|
enumerable: true,
|
|
716
716
|
configurable: true,
|
|
717
717
|
writable: 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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AE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC;YACvD,gBAAgB,EAAE,WAAW,CAAC,gBAAgB;YAC9C,YAAY,EAAE;gBACZ;oBACE,aAAa,EAAE,WAAW,CAAC,WAAW;oBACtC,eAAe,EAAE,MAAM,CAAC,eAAe;iBACxC;aACF;SACF,CAAC,CAAC;QAEH,8BAA8B;QAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC;YACnD,MAAM;YACN,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,kBAAkB,EAAE,cAAc;YAClC,kBAAkB,EAAE,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"]}
|
|
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;;;GA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C;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 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"]}
|
package/dist/esm/signer.d.ts
CHANGED
|
@@ -320,6 +320,7 @@ export type AlchemySignerParams = z.input<typeof AlchemySignerParamsSchema>;
|
|
|
320
320
|
* A SmartAccountSigner that can be used with any SmartContractAccount
|
|
321
321
|
*/
|
|
322
322
|
export declare class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient> {
|
|
323
|
+
private static replaceStateFilterInstalled;
|
|
323
324
|
/**
|
|
324
325
|
* Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.
|
|
325
326
|
*
|
package/dist/esm/signer.js
CHANGED
|
@@ -47,7 +47,7 @@ export class AlchemyWebSigner extends BaseAlchemySigner {
|
|
|
47
47
|
else {
|
|
48
48
|
client = params_.client;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const qpStructure = {
|
|
51
51
|
emailBundle: "bundle",
|
|
52
52
|
// We don't need this, but we still want to remove it from the URL.
|
|
53
53
|
emailOrgId: "orgId",
|
|
@@ -56,7 +56,12 @@ export class AlchemyWebSigner extends BaseAlchemySigner {
|
|
|
56
56
|
oauthError: "alchemy-error",
|
|
57
57
|
idToken: "alchemy-id-token",
|
|
58
58
|
isSignup: "aa-is-signup",
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
|
+
const { emailBundle, oauthBundle, oauthOrgId, oauthError, idToken, isSignup, } = getAndRemoveQueryParams(qpStructure);
|
|
61
|
+
if (!AlchemyWebSigner.replaceStateFilterInstalled) {
|
|
62
|
+
installReplaceStateFilter(Object.values(qpStructure));
|
|
63
|
+
AlchemyWebSigner.replaceStateFilterInstalled = true;
|
|
64
|
+
}
|
|
60
65
|
const initialError = oauthError != null
|
|
61
66
|
? { name: "OauthError", message: oauthError }
|
|
62
67
|
: undefined;
|
|
@@ -81,6 +86,48 @@ export class AlchemyWebSigner extends BaseAlchemySigner {
|
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
}
|
|
89
|
+
Object.defineProperty(AlchemyWebSigner, "replaceStateFilterInstalled", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: false
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Overrides `window.history.replaceState` to remove the specified query params from target URLs.
|
|
97
|
+
*
|
|
98
|
+
* @param {string[]} qpToRemove The query params to remove from target URLs.
|
|
99
|
+
*/
|
|
100
|
+
function installReplaceStateFilter(qpToRemove) {
|
|
101
|
+
const originalReplaceState = window.history.replaceState;
|
|
102
|
+
const processUrl = (src) => {
|
|
103
|
+
if (!src) {
|
|
104
|
+
return src;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const url = new URL(src, document.baseURI);
|
|
108
|
+
const originalSearch = url.search;
|
|
109
|
+
qpToRemove.forEach((qp) => url.searchParams.delete(qp));
|
|
110
|
+
if (originalSearch === url.search)
|
|
111
|
+
return src;
|
|
112
|
+
console.log("[Alchemy] filtered query params from URL");
|
|
113
|
+
return url;
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
console.log("[Alchemy] failed to process URL in state filter", e);
|
|
117
|
+
return src;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
window.history.replaceState = function (...args) {
|
|
121
|
+
const [state, unused, url] = args;
|
|
122
|
+
const result = originalReplaceState.apply(this, [
|
|
123
|
+
state,
|
|
124
|
+
unused,
|
|
125
|
+
processUrl(url),
|
|
126
|
+
]);
|
|
127
|
+
return result;
|
|
128
|
+
};
|
|
129
|
+
console.log("[Alchemy] installed window.history.replaceState interceptor");
|
|
130
|
+
}
|
|
84
131
|
/**
|
|
85
132
|
* Reads and removes the specified query params from the URL.
|
|
86
133
|
*
|
package/dist/esm/signer.js.map
CHANGED
|
@@ -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;AAK3B,OAAO,EAAE,0BAA0B,EAAE,M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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 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 /**\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 const {\n emailBundle,\n oauthBundle,\n oauthOrgId,\n oauthError,\n idToken,\n isSignup,\n } = getAndRemoveQueryParams({\n emailBundle: \"bundle\",\n // We don't need this, but we still want to remove it from the URL.\n emailOrgId: \"orgId\",\n oauthBundle: \"alchemy-bundle\",\n oauthOrgId: \"alchemy-org-id\",\n oauthError: \"alchemy-error\",\n idToken: \"alchemy-id-token\",\n isSignup: \"aa-is-signup\",\n });\n\n const initialError =\n oauthError != null\n ? { name: \"OauthError\", message: oauthError }\n : undefined;\n\n super({ client, sessionConfig, initialError });\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 * 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;AAK3B,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;;;;;;;;;;;;;;;;;;;;OAoBG;IAEH,YAA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AM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;QAElC,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE;YAC9C,KAAK;YACL,MAAM;YACN,UAAU,CAAC,GAAG,CAAC;SAChB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;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 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 oauthBundle: \"alchemy-bundle\",\n oauthOrgId: \"alchemy-org-id\",\n oauthError: \"alchemy-error\",\n idToken: \"alchemy-id-token\",\n isSignup: \"aa-is-signup\",\n };\n\n const {\n emailBundle,\n oauthBundle,\n oauthOrgId,\n oauthError,\n idToken,\n isSignup,\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 super({ client, sessionConfig, initialError });\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"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.31.0";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -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.
|
|
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.31.0\";\n"]}
|
package/dist/types/base.d.ts
CHANGED
|
@@ -445,7 +445,7 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
445
445
|
*
|
|
446
446
|
* @returns {SolanaSigner} A new instance of `SolanaSigner`
|
|
447
447
|
*/
|
|
448
|
-
|
|
448
|
+
toSolanaSigner: () => SolanaSigner;
|
|
449
449
|
private authenticateWithEmail;
|
|
450
450
|
private authenticateWithPasskey;
|
|
451
451
|
private authenticateWithOauth;
|
package/dist/types/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAI1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,C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AAM,EAAE,eAAe,KACpB,OAAO,CAAC;QAAE,YAAY,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CAKzC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,SAAS,EAAE,CACT,MAAM,EAAE,eAAe,KACpB,OAAO,CAAC;QAAE,YAAY,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CAKzC;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,oBAAoB,CAC/B,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC;IAyDhB,SAAS,CAAC,UAAU,QAAa,QAAQ,YAAY,CAAC,CAGpD;IAEF;;;;OAIG;IACI,SAAS,QAAa,QAAQ,YAAY,CAAC,CAMhD;IAEF,SAAS,CAAC,WAAW,QAAa,QAAQ,YAAY,CAAC,CAErD;CACH"}
|
package/dist/types/signer.d.ts
CHANGED
|
@@ -320,6 +320,7 @@ export type AlchemySignerParams = z.input<typeof AlchemySignerParamsSchema>;
|
|
|
320
320
|
* A SmartAccountSigner that can be used with any SmartContractAccount
|
|
321
321
|
*/
|
|
322
322
|
export declare class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient> {
|
|
323
|
+
private static replaceStateFilterInstalled;
|
|
323
324
|
/**
|
|
324
325
|
* Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.
|
|
325
326
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAEL,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,iCAAiC,EACjC,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,MAAM,UAAU,GAClB;IACE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiFrK,CAAC;AAEL,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,sBAAsB,CAAC;IAC7E,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAS;IACnD;;;;;;;;;;;;;;;;;;;;OAoBG;gBAES,MAAM,EAAE,mBAAmB;CA+DxC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.31.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/signer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.31.0",
|
|
4
4
|
"description": "Core interfaces and clients for interfacing with the Alchemy Signer API",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"vitest": "^2.0.4"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@aa-sdk/core": "^4.
|
|
55
|
-
"@account-kit/logging": "^4.
|
|
54
|
+
"@aa-sdk/core": "^4.31.0",
|
|
55
|
+
"@account-kit/logging": "^4.31.0",
|
|
56
56
|
"@solana/web3.js": "^1.98.0",
|
|
57
57
|
"@turnkey/http": "^2.6.2",
|
|
58
58
|
"@turnkey/iframe-stamper": "^1.0.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
79
79
|
},
|
|
80
80
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "52ba77868cce319bd35dab6a2a7c42546c59517f"
|
|
82
82
|
}
|
package/src/base.ts
CHANGED
|
@@ -833,7 +833,7 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
833
833
|
*
|
|
834
834
|
* @returns {SolanaSigner} A new instance of `SolanaSigner`
|
|
835
835
|
*/
|
|
836
|
-
|
|
836
|
+
toSolanaSigner = (): SolanaSigner => {
|
|
837
837
|
if (!this.inner.getUser()) {
|
|
838
838
|
throw new NotAuthenticatedError();
|
|
839
839
|
}
|
package/src/signer.ts
CHANGED
|
@@ -103,6 +103,7 @@ export type AlchemySignerParams = z.input<typeof AlchemySignerParamsSchema>;
|
|
|
103
103
|
* A SmartAccountSigner that can be used with any SmartContractAccount
|
|
104
104
|
*/
|
|
105
105
|
export class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient> {
|
|
106
|
+
private static replaceStateFilterInstalled = false;
|
|
106
107
|
/**
|
|
107
108
|
* Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.
|
|
108
109
|
*
|
|
@@ -135,14 +136,8 @@ export class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient>
|
|
|
135
136
|
} else {
|
|
136
137
|
client = params_.client;
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
oauthBundle,
|
|
141
|
-
oauthOrgId,
|
|
142
|
-
oauthError,
|
|
143
|
-
idToken,
|
|
144
|
-
isSignup,
|
|
145
|
-
} = getAndRemoveQueryParams({
|
|
139
|
+
|
|
140
|
+
const qpStructure = {
|
|
146
141
|
emailBundle: "bundle",
|
|
147
142
|
// We don't need this, but we still want to remove it from the URL.
|
|
148
143
|
emailOrgId: "orgId",
|
|
@@ -151,7 +146,21 @@ export class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient>
|
|
|
151
146
|
oauthError: "alchemy-error",
|
|
152
147
|
idToken: "alchemy-id-token",
|
|
153
148
|
isSignup: "aa-is-signup",
|
|
154
|
-
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const {
|
|
152
|
+
emailBundle,
|
|
153
|
+
oauthBundle,
|
|
154
|
+
oauthOrgId,
|
|
155
|
+
oauthError,
|
|
156
|
+
idToken,
|
|
157
|
+
isSignup,
|
|
158
|
+
} = getAndRemoveQueryParams(qpStructure);
|
|
159
|
+
|
|
160
|
+
if (!AlchemyWebSigner.replaceStateFilterInstalled) {
|
|
161
|
+
installReplaceStateFilter(Object.values(qpStructure));
|
|
162
|
+
AlchemyWebSigner.replaceStateFilterInstalled = true;
|
|
163
|
+
}
|
|
155
164
|
|
|
156
165
|
const initialError =
|
|
157
166
|
oauthError != null
|
|
@@ -182,6 +191,49 @@ export class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient>
|
|
|
182
191
|
}
|
|
183
192
|
}
|
|
184
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Overrides `window.history.replaceState` to remove the specified query params from target URLs.
|
|
196
|
+
*
|
|
197
|
+
* @param {string[]} qpToRemove The query params to remove from target URLs.
|
|
198
|
+
*/
|
|
199
|
+
function installReplaceStateFilter(qpToRemove: string[]) {
|
|
200
|
+
const originalReplaceState = window.history.replaceState;
|
|
201
|
+
|
|
202
|
+
const processUrl = (src: string | URL | undefined | null) => {
|
|
203
|
+
if (!src) {
|
|
204
|
+
return src;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
const url = new URL(src, document.baseURI);
|
|
209
|
+
const originalSearch = url.search;
|
|
210
|
+
|
|
211
|
+
qpToRemove.forEach((qp) => url.searchParams.delete(qp));
|
|
212
|
+
if (originalSearch === url.search) return src;
|
|
213
|
+
|
|
214
|
+
console.log("[Alchemy] filtered query params from URL");
|
|
215
|
+
return url;
|
|
216
|
+
} catch (e) {
|
|
217
|
+
console.log("[Alchemy] failed to process URL in state filter", e);
|
|
218
|
+
return src;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
window.history.replaceState = function (...args) {
|
|
223
|
+
const [state, unused, url] = args;
|
|
224
|
+
|
|
225
|
+
const result = originalReplaceState.apply(this, [
|
|
226
|
+
state,
|
|
227
|
+
unused,
|
|
228
|
+
processUrl(url),
|
|
229
|
+
]);
|
|
230
|
+
|
|
231
|
+
return result;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
console.log("[Alchemy] installed window.history.replaceState interceptor");
|
|
235
|
+
}
|
|
236
|
+
|
|
185
237
|
/**
|
|
186
238
|
* Reads and removes the specified query params from the URL.
|
|
187
239
|
*
|
package/src/version.ts
CHANGED