@account-kit/signer 4.39.0 → 4.41.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 +61 -1
- package/dist/esm/base.js +148 -1
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +47 -4
- package/dist/esm/client/base.js +139 -1
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +3 -3
- package/dist/esm/client/index.js +7 -0
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +44 -0
- package/dist/esm/client/types.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 +61 -1
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +47 -4
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +3 -3
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +44 -0
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/base.ts +148 -1
- package/src/client/base.ts +123 -4
- package/src/client/index.ts +10 -2
- package/src/client/types.ts +46 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,O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J,CAAC;QAED,kCAAkC;QAClC,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IAkYkB,KAAK,CAAC,kBAAkB;QACzC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAG,CAAC;IACzC,CAAC;IAEkB,KAAK,CAAC,mBAAmB,CAC1C,OAAyB,IAAI,CAAC,IAAI;QAElC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACtC,IAAI,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC9B,+GAA+G;YAC/G,IAAI,CAAC,eAAe,CAAC,gBAAgB,GAAG;gBACtC;oBACE,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC;oBAC5C,IAAI,EAAE,YAAY;oBAClB,UAAU,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;iBACnC;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAGhD;;;OAGG;IACH;QACE,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAPlB;;;;mBAAO,qBAAqB;WAAC;IAQtC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAA/C;;QACW;;;;mBAAO,kBAAkB;WAAC;IACrC,CAAC;CAAA","sourcesContent":["import { BaseError, ConnectionConfigSchema } from \"@aa-sdk/core\";\nimport { getWebAuthnAttestation } from \"@turnkey/http\";\nimport { IframeStamper } from \"@turnkey/iframe-stamper\";\nimport { WebauthnStamper } from \"@turnkey/webauthn-stamper\";\nimport { z } from \"zod\";\nimport type { AuthParams } from \"../signer.js\";\nimport { generateRandomBuffer } from \"../utils/generateRandomBuffer.js\";\nimport { BaseSignerClient } from \"./base.js\";\nimport type {\n AlchemySignerClientEvents,\n AuthenticatingEventMetadata,\n CredentialCreationOptionOverrides,\n EmailAuthParams,\n ExportWalletParams,\n OauthConfig,\n OtpParams,\n User,\n SubmitOtpCodeResponse,\n AuthLinkingPrompt,\n GetWebAuthnAttestationResult,\n} from \"./types.js\";\nimport { MfaRequiredError } from \"../errors.js\";\nimport { parseMfaError } from \"../utils/parseMfaError.js\";\n\nconst CHECK_CLOSE_INTERVAL = 500;\n\nexport const AlchemySignerClientParamsSchema = z.object({\n connection: ConnectionConfigSchema,\n iframeConfig: z.object({\n iframeElementId: z.string().default(\"turnkey-iframe\"),\n iframeContainerId: z.string(),\n }),\n rpId: z.string().optional(),\n rootOrgId: z\n .string()\n .optional()\n .default(\"24c1acf5-810f-41e0-a503-d5d13fa8e830\"),\n oauthCallbackUrl: z\n .string()\n .optional()\n .default(\"https://signer.alchemy.com/callback\"),\n enablePopupOauth: z.boolean().optional().default(false),\n});\n\nexport type AlchemySignerClientParams = z.input<\n typeof AlchemySignerClientParamsSchema\n>;\n\n/**\n * A lower level client used by the AlchemySigner used to communicate with\n * Alchemy's signer service.\n */\nexport class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams> {\n private iframeStamper: IframeStamper;\n private webauthnStamper: WebauthnStamper;\n oauthCallbackUrl: string;\n iframeContainerId: string;\n\n /**\n * Initializes a new instance with the given parameters, setting up the connection, iframe configuration, and WebAuthn stamper.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n * ```\n *\n * @param {AlchemySignerClientParams} params the parameters required to initialize the client\n * @param {ConnectionConfig} params.connection The connection details needed to connect to the service\n * @param {{ iframeElementId?: string; iframeContainerId: string }} params.iframeConfig The configuration details for setting up the iframe stamper\n * @param {string} params.rpId The relying party ID, defaulting to the current hostname if not provided\n * @param {string} params.rootOrgId The root organization ID\n */\n constructor(params: AlchemySignerClientParams) {\n const { connection, iframeConfig, rpId, rootOrgId, oauthCallbackUrl } =\n AlchemySignerClientParamsSchema.parse(params);\n\n const iframeStamper = new IframeStamper({\n iframeElementId: iframeConfig.iframeElementId,\n iframeUrl: \"https://auth.turnkey.com\",\n iframeContainer: document.getElementById(iframeConfig.iframeContainerId),\n });\n\n super({\n connection,\n rootOrgId,\n stamper: iframeStamper,\n });\n\n this.iframeStamper = iframeStamper;\n this.iframeContainerId = iframeConfig.iframeContainerId;\n\n this.webauthnStamper = new WebauthnStamper({\n rpId: rpId ?? window.location.hostname,\n });\n\n this.oauthCallbackUrl = oauthCallbackUrl;\n }\n\n /**\n * Begin authenticating a user with their email and an expiration time for the authentication request. Initializes the iframe stamper to get the target public key.\n * This method sends an email to the user to complete their login\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.initEmailAuth({ email: \"you@mail.com\" });\n * ```\n *\n * @param {Omit<EmailAuthParams, \"targetPublicKey\">} params The parameters for email authentication, excluding the target public key\n * @returns {Promise<any>} The response from the authentication request\n */\n public override initEmailAuth = async (\n params: Omit<EmailAuthParams, \"targetPublicKey\">,\n ) => {\n this.eventEmitter.emit(\"authenticating\", { type: \"otp\" });\n const { email, emailMode, expirationSeconds } = params;\n const publicKey = await this.initSessionStamper();\n\n try {\n return await this.request(\"/v1/auth\", {\n email,\n emailMode,\n targetPublicKey: publicKey,\n expirationSeconds,\n redirectParams: params.redirectParams?.toString(),\n multiFactors: params.multiFactors,\n });\n } catch (error) {\n const multiFactors = parseMfaError(error);\n\n // If MFA is required, and emailMode is Magic Link, the user must submit mfa with the request or\n // the the server will return an error with the required mfa factors.\n if (multiFactors) {\n throw new MfaRequiredError(multiFactors);\n }\n throw error;\n }\n };\n\n /**\n * Authenticates using an OTP code which was previously received via email.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.submitOtpCode({\n * orgId: \"user-org-id\",\n * otpId: \"opt-returned-from-initEmailAuth\",\n * otpCode: \"otp-code-from-email\",\n * });\n * ```\n *\n * @param {Omit<OtpParams, \"targetPublicKey\">} args The parameters for the OTP request, excluding the target public key.\n * @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle.\n */\n public override async submitOtpCode(\n args: Omit<OtpParams, \"targetPublicKey\">,\n ): Promise<SubmitOtpCodeResponse> {\n this.eventEmitter.emit(\"authenticating\", { type: \"otpVerify\" });\n const targetPublicKey = await this.initSessionStamper();\n const response = await this.request(\"/v1/otp\", {\n ...args,\n targetPublicKey,\n });\n\n if (\"credentialBundle\" in response && response.credentialBundle) {\n return {\n mfaRequired: false,\n bundle: response.credentialBundle,\n };\n }\n\n // If the server says \"MFA_REQUIRED\", pass that data back to the caller:\n if (\n response.status === \"MFA_REQUIRED\" &&\n response.encryptedPayload &&\n response.multiFactors\n ) {\n return {\n mfaRequired: true,\n encryptedPayload: response.encryptedPayload,\n multiFactors: response.multiFactors,\n };\n }\n\n // Otherwise, it's truly an error:\n throw new Error(\n \"Failed to submit OTP code. Server did not return required fields.\",\n );\n }\n\n /**\n * Completes auth for the user by injecting a credential bundle and retrieving\n * the user information based on the provided organization ID. Emits events\n * during the process.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.completeAuthWithBundle({ orgId: \"user-org-id\", bundle: \"bundle-from-email\", connectedEventName: \"connectedEmail\" });\n * ```\n *\n * @param {{ bundle: string; orgId: string, connectedEventName: keyof AlchemySignerClientEvents, idToken?: string }} config\n * The configuration object for the authentication function containing the\n * credential bundle to inject and the organization id associated with the\n * user, as well as the event to be emitted on success and optionally an OIDC\n * ID token with extra user information\n * @returns {Promise<User>} A promise that resolves to the authenticated user\n * information\n */\n public override completeAuthWithBundle = async ({\n bundle,\n orgId,\n connectedEventName,\n idToken,\n authenticatingType,\n }: {\n bundle: string;\n orgId: string;\n connectedEventName: keyof AlchemySignerClientEvents;\n authenticatingType: AuthenticatingEventMetadata[\"type\"];\n idToken?: string;\n }): Promise<User> => {\n this.eventEmitter.emit(\"authenticating\", { type: authenticatingType });\n await this.initSessionStamper();\n\n const result = await this.iframeStamper.injectCredentialBundle(bundle);\n\n if (!result) {\n throw new Error(\"Failed to inject credential bundle\");\n }\n\n const user = await this.whoami(orgId, idToken);\n\n this.eventEmitter.emit(connectedEventName, user, bundle);\n\n return user;\n };\n\n /**\n * Initiates the export of a wallet by creating an iframe stamper and calling the appropriate export function.\n * The export can be based on a seed phrase or a private key.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.exportWallet({\n * iframeContainerId: \"export-iframe-container\",\n * });\n * ```\n *\n * @param {ExportWalletParams} config The parameters for exporting the wallet\n * @param {string} config.iframeContainerId The ID of the container element that will hold the iframe stamper\n * @param {string} [config.iframeElementId] Optional ID for the iframe element\n * @returns {Promise<void>} A promise that resolves when the export process is complete\n */\n public override exportWallet = async ({\n iframeContainerId,\n iframeElementId = \"turnkey-export-iframe\",\n }: ExportWalletParams) => {\n const exportWalletIframeStamper = new IframeStamper({\n iframeContainer: document.getElementById(iframeContainerId),\n iframeElementId: iframeElementId,\n iframeUrl: \"https://export.turnkey.com\",\n });\n await exportWalletIframeStamper.init();\n\n if (this.turnkeyClient.stamper === this.iframeStamper) {\n return this.exportWalletInner({\n exportStamper: exportWalletIframeStamper,\n exportAs: \"SEED_PHRASE\",\n });\n }\n\n return this.exportWalletInner({\n exportStamper: exportWalletIframeStamper,\n exportAs: \"PRIVATE_KEY\",\n });\n };\n\n /**\n * Asynchronous function that clears the user and resets the iframe stamper.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.disconnect();\n * ```\n */\n public override disconnect = async () => {\n this.user = undefined;\n this.iframeStamper.clear();\n await this.iframeStamper.init();\n };\n\n /**\n * Redirects the user to the OAuth provider URL based on the provided arguments. This function will always reject after 1 second if the redirection does not occur.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * await client.oauthWithRedirect({\n * type: \"oauth\",\n * authProviderId: \"google\",\n * mode: \"redirect\",\n * redirectUrl: \"/\",\n * });\n * ```\n *\n * @param {Extract<AuthParams, { type: \"oauth\"; mode: \"redirect\" }>} args The arguments required to obtain the OAuth provider URL\n * @returns {Promise<never>} A promise that will never resolve, only reject if the redirection fails\n */\n public override oauthWithRedirect = async (\n args: Extract<AuthParams, { type: \"oauth\"; mode: \"redirect\" }>,\n ): Promise<never> => {\n const turnkeyPublicKey = await this.initSessionStamper();\n\n const oauthParams = args;\n const providerUrl = await this.getOauthProviderUrl({\n oauthParams,\n turnkeyPublicKey,\n oauthCallbackUrl: this.oauthCallbackUrl,\n });\n\n window.location.href = providerUrl;\n return new Promise((_, reject) =>\n setTimeout(() => reject(\"Failed to redirect to OAuth provider\"), 1000),\n );\n };\n\n /**\n * Initiates an OAuth authentication flow in a popup window and returns the authenticated user.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const user = await client.oauthWithPopup({\n * type: \"oauth\",\n * authProviderId: \"google\",\n * mode: \"popup\"\n * });\n * ```\n *\n * @param {Extract<AuthParams, { type: \"oauth\"; mode: \"popup\" }>} args The authentication parameters specifying OAuth type and popup mode\n * @returns {Promise<User>} A promise that resolves to a `User` object containing the authenticated user information\n */\n public override oauthWithPopup = async (\n args: Extract<AuthParams, { type: \"oauth\"; mode: \"popup\" }>,\n ): Promise<User | AuthLinkingPrompt> => {\n const turnkeyPublicKey = await this.initSessionStamper();\n const oauthParams = args;\n const providerUrl = await this.getOauthProviderUrl({\n oauthParams,\n turnkeyPublicKey,\n oauthCallbackUrl: this.oauthCallbackUrl,\n });\n const popup = window.open(\n providerUrl,\n \"_blank\",\n \"popup,width=500,height=600\",\n );\n const eventEmitter = this.eventEmitter;\n return new Promise((resolve, reject) => {\n const handleMessage = (event: MessageEvent) => {\n if (!event.data) {\n return;\n }\n const {\n alchemyStatus: status,\n alchemyBundle: bundle,\n alchemyOrgId: orgId,\n alchemyIdToken: idToken,\n alchemyIsSignup: isSignup,\n alchemyError,\n alchemyOtpId: otpId,\n alchemyEmail: email,\n alchemyAuthProvider: providerName,\n } = event.data;\n if (alchemyError) {\n cleanup();\n popup?.close();\n reject(new OauthFailedError(alchemyError));\n }\n if (!status) {\n // This message isn't meant for us.\n return;\n }\n cleanup();\n popup?.close();\n switch (status) {\n case \"SUCCESS\":\n this.completeAuthWithBundle({\n bundle,\n orgId,\n connectedEventName: \"connectedOauth\",\n idToken,\n authenticatingType: \"oauth\",\n }).then((user) => {\n if (isSignup) {\n eventEmitter.emit(\"newUserSignup\");\n }\n resolve(user);\n }, reject);\n break;\n case \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\":\n resolve({\n status,\n idToken,\n email,\n providerName,\n otpId,\n orgId,\n } satisfies AuthLinkingPrompt);\n break;\n default:\n reject(new Error(`Unknown status: ${status}`));\n }\n };\n\n window.addEventListener(\"message\", handleMessage);\n\n const checkCloseIntervalId = setInterval(() => {\n if (popup?.closed) {\n cleanup();\n reject(new OauthCancelledError());\n }\n }, CHECK_CLOSE_INTERVAL);\n\n const cleanup = () => {\n window.removeEventListener(\"message\", handleMessage);\n clearInterval(checkCloseIntervalId);\n };\n });\n };\n\n /**\n * Initializes the iframe stamper and returns its public key.\n *\n * @example\n * ```ts twoslash\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const publicKey = await client.targetPublicKey();\n * ```\n *\n * @returns {Promise<string>} A promise that resolves with the target public key when the iframe stamper is successfully initialized, or throws an error if the target public key is not supported.\n */\n public override targetPublicKey = async (): Promise<string> => {\n return this.initSessionStamper();\n };\n\n protected override getWebAuthnAttestation = async (\n options?: CredentialCreationOptionOverrides,\n userDetails: { username: string } = {\n username: this.user?.email ?? \"anonymous\",\n },\n ): Promise<GetWebAuthnAttestationResult> => {\n const challenge = generateRandomBuffer();\n const authenticatorUserId = generateRandomBuffer();\n\n const attestation = await getWebAuthnAttestation({\n publicKey: {\n ...options?.publicKey,\n authenticatorSelection: {\n residentKey: \"preferred\",\n requireResidentKey: false,\n userVerification: \"preferred\",\n ...options?.publicKey?.authenticatorSelection,\n },\n challenge,\n rp: {\n id: window.location.hostname,\n name: window.location.hostname,\n ...options?.publicKey?.rp,\n },\n pubKeyCredParams: [\n {\n type: \"public-key\",\n alg: -7,\n },\n {\n type: \"public-key\",\n alg: -257,\n },\n ],\n user: {\n id: authenticatorUserId,\n name: userDetails.username,\n displayName: userDetails.username,\n ...options?.publicKey?.user,\n },\n },\n signal: options?.signal,\n });\n\n // on iOS sometimes this is returned as empty or null, so handling that here\n if (attestation.transports == null || attestation.transports.length === 0) {\n attestation.transports = [\n \"AUTHENTICATOR_TRANSPORT_INTERNAL\",\n \"AUTHENTICATOR_TRANSPORT_HYBRID\",\n ];\n }\n\n return { challenge, authenticatorUserId, attestation };\n };\n\n protected override getOauthConfig = async (): Promise<OauthConfig> => {\n const currentStamper = this.turnkeyClient.stamper;\n const publicKey = await this.initSessionStamper();\n\n // swap the stamper back in case the user logged in with a different stamper (passkeys)\n this.setStamper(currentStamper);\n const nonce = this.getOauthNonce(publicKey);\n return this.request(\"/v1/prepare-oauth\", { nonce });\n };\n\n protected override async initSessionStamper(): Promise<string> {\n if (!this.iframeStamper.publicKey()) {\n await this.iframeStamper.init();\n }\n\n this.setStamper(this.iframeStamper);\n\n return this.iframeStamper.publicKey()!;\n }\n\n protected override async initWebauthnStamper(\n user: User | undefined = this.user,\n ): Promise<void> {\n this.setStamper(this.webauthnStamper);\n if (user && user.credentialId) {\n // The goal here is to allow us to cache the allowed credential, but this doesn't work with hybrid transport :(\n this.webauthnStamper.allowCredentials = [\n {\n id: Buffer.from(user.credentialId, \"base64\"),\n type: \"public-key\",\n transports: [\"internal\", \"hybrid\"],\n },\n ];\n }\n }\n}\n\n/**\n * This error is thrown when the OAuth flow is cancelled because the auth popup\n * window was closed.\n */\nexport class OauthCancelledError extends BaseError {\n override name = \"OauthCancelledError\";\n\n /**\n * Constructor for initializing an error indicating that the OAuth flow was\n * cancelled.\n */\n constructor() {\n super(\"OAuth cancelled\");\n }\n}\n\n/**\n * This error is thrown when an error occurs during the OAuth login flow.\n */\nexport class OauthFailedError extends BaseError {\n override name = \"OauthFailedError\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAe7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IACtD,UAAU,EAAE,sBAAsB;IAClC,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACrD,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;KAC9B,CAAC;IACF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,sCAAsC,CAAC;IAClD,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,qCAAqC,CAAC;IACjD,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACx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Q,CAAC;oBAC5C,IAAI,EAAE,YAAY;oBAClB,UAAU,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;iBACnC;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAGhD;;;OAGG;IACH;QACE,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAPlB;;;;mBAAO,qBAAqB;WAAC;IAQtC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAA/C;;QACW;;;;mBAAO,kBAAkB;WAAC;IACrC,CAAC;CAAA","sourcesContent":["import { BaseError, ConnectionConfigSchema } from \"@aa-sdk/core\";\nimport { getWebAuthnAttestation } from \"@turnkey/http\";\nimport { IframeStamper } from \"@turnkey/iframe-stamper\";\nimport { WebauthnStamper } from \"@turnkey/webauthn-stamper\";\nimport { z } from \"zod\";\nimport type { AuthParams } from \"../signer.js\";\nimport { generateRandomBuffer } from \"../utils/generateRandomBuffer.js\";\nimport { BaseSignerClient } from \"./base.js\";\nimport type {\n AlchemySignerClientEvents,\n AuthenticatingEventMetadata,\n CredentialCreationOptionOverrides,\n EmailAuthParams,\n ExportWalletParams,\n OauthConfig,\n OtpParams,\n User,\n SubmitOtpCodeResponse,\n AuthLinkingPrompt,\n GetWebAuthnAttestationResult,\n IdTokenOnly,\n} from \"./types.js\";\nimport { MfaRequiredError } from \"../errors.js\";\nimport { parseMfaError } from \"../utils/parseMfaError.js\";\n\nconst CHECK_CLOSE_INTERVAL = 500;\n\nexport const AlchemySignerClientParamsSchema = z.object({\n connection: ConnectionConfigSchema,\n iframeConfig: z.object({\n iframeElementId: z.string().default(\"turnkey-iframe\"),\n iframeContainerId: z.string(),\n }),\n rpId: z.string().optional(),\n rootOrgId: z\n .string()\n .optional()\n .default(\"24c1acf5-810f-41e0-a503-d5d13fa8e830\"),\n oauthCallbackUrl: z\n .string()\n .optional()\n .default(\"https://signer.alchemy.com/callback\"),\n enablePopupOauth: z.boolean().optional().default(false),\n});\n\nexport type AlchemySignerClientParams = z.input<\n typeof AlchemySignerClientParamsSchema\n>;\n\n/**\n * A lower level client used by the AlchemySigner used to communicate with\n * Alchemy's signer service.\n */\nexport class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams> {\n private iframeStamper: IframeStamper;\n private webauthnStamper: WebauthnStamper;\n oauthCallbackUrl: string;\n iframeContainerId: string;\n\n /**\n * Initializes a new instance with the given parameters, setting up the connection, iframe configuration, and WebAuthn stamper.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n * ```\n *\n * @param {AlchemySignerClientParams} params the parameters required to initialize the client\n * @param {ConnectionConfig} params.connection The connection details needed to connect to the service\n * @param {{ iframeElementId?: string; iframeContainerId: string }} params.iframeConfig The configuration details for setting up the iframe stamper\n * @param {string} params.rpId The relying party ID, defaulting to the current hostname if not provided\n * @param {string} params.rootOrgId The root organization ID\n */\n constructor(params: AlchemySignerClientParams) {\n const { connection, iframeConfig, rpId, rootOrgId, oauthCallbackUrl } =\n AlchemySignerClientParamsSchema.parse(params);\n\n const iframeStamper = new IframeStamper({\n iframeElementId: iframeConfig.iframeElementId,\n iframeUrl: \"https://auth.turnkey.com\",\n iframeContainer: document.getElementById(iframeConfig.iframeContainerId),\n });\n\n super({\n connection,\n rootOrgId,\n stamper: iframeStamper,\n });\n\n this.iframeStamper = iframeStamper;\n this.iframeContainerId = iframeConfig.iframeContainerId;\n\n this.webauthnStamper = new WebauthnStamper({\n rpId: rpId ?? window.location.hostname,\n });\n\n this.oauthCallbackUrl = oauthCallbackUrl;\n }\n\n /**\n * Begin authenticating a user with their email and an expiration time for the authentication request. Initializes the iframe stamper to get the target public key.\n * This method sends an email to the user to complete their login\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.initEmailAuth({ email: \"you@mail.com\" });\n * ```\n *\n * @param {Omit<EmailAuthParams, \"targetPublicKey\">} params The parameters for email authentication, excluding the target public key\n * @returns {Promise<any>} The response from the authentication request\n */\n public override initEmailAuth = async (\n params: Omit<EmailAuthParams, \"targetPublicKey\">,\n ) => {\n this.eventEmitter.emit(\"authenticating\", { type: \"otp\" });\n const { email, emailMode, expirationSeconds } = params;\n const publicKey = await this.initSessionStamper();\n\n try {\n return await this.request(\"/v1/auth\", {\n email,\n emailMode,\n targetPublicKey: publicKey,\n expirationSeconds,\n redirectParams: params.redirectParams?.toString(),\n multiFactors: params.multiFactors,\n });\n } catch (error) {\n const multiFactors = parseMfaError(error);\n\n // If MFA is required, and emailMode is Magic Link, the user must submit mfa with the request or\n // the the server will return an error with the required mfa factors.\n if (multiFactors) {\n throw new MfaRequiredError(multiFactors);\n }\n throw error;\n }\n };\n\n /**\n * Authenticates using an OTP code which was previously received via email.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.submitOtpCode({\n * orgId: \"user-org-id\",\n * otpId: \"opt-returned-from-initEmailAuth\",\n * otpCode: \"otp-code-from-email\",\n * });\n * ```\n *\n * @param {Omit<OtpParams, \"targetPublicKey\">} args The parameters for the OTP request, excluding the target public key.\n * @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle.\n */\n public override async submitOtpCode(\n args: Omit<OtpParams, \"targetPublicKey\">,\n ): Promise<SubmitOtpCodeResponse> {\n this.eventEmitter.emit(\"authenticating\", { type: \"otpVerify\" });\n const targetPublicKey = await this.initSessionStamper();\n const response = await this.request(\"/v1/otp\", {\n ...args,\n targetPublicKey,\n });\n\n if (\"credentialBundle\" in response && response.credentialBundle) {\n return {\n mfaRequired: false,\n bundle: response.credentialBundle,\n };\n }\n\n // If the server says \"MFA_REQUIRED\", pass that data back to the caller:\n if (\n response.status === \"MFA_REQUIRED\" &&\n response.encryptedPayload &&\n response.multiFactors\n ) {\n return {\n mfaRequired: true,\n encryptedPayload: response.encryptedPayload,\n multiFactors: response.multiFactors,\n };\n }\n\n // Otherwise, it's truly an error:\n throw new Error(\n \"Failed to submit OTP code. Server did not return required fields.\",\n );\n }\n\n /**\n * Completes auth for the user by injecting a credential bundle and retrieving\n * the user information based on the provided organization ID. Emits events\n * during the process.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.completeAuthWithBundle({ orgId: \"user-org-id\", bundle: \"bundle-from-email\", connectedEventName: \"connectedEmail\" });\n * ```\n *\n * @param {{ bundle: string; orgId: string, connectedEventName: keyof AlchemySignerClientEvents, idToken?: string }} config\n * The configuration object for the authentication function containing the\n * credential bundle to inject and the organization id associated with the\n * user, as well as the event to be emitted on success and optionally an OIDC\n * ID token with extra user information\n * @returns {Promise<User>} A promise that resolves to the authenticated user\n * information\n */\n public override completeAuthWithBundle = async ({\n bundle,\n orgId,\n connectedEventName,\n idToken,\n authenticatingType,\n }: {\n bundle: string;\n orgId: string;\n connectedEventName: keyof AlchemySignerClientEvents;\n authenticatingType: AuthenticatingEventMetadata[\"type\"];\n idToken?: string;\n }): Promise<User> => {\n this.eventEmitter.emit(\"authenticating\", { type: authenticatingType });\n await this.initSessionStamper();\n\n const result = await this.iframeStamper.injectCredentialBundle(bundle);\n\n if (!result) {\n throw new Error(\"Failed to inject credential bundle\");\n }\n\n const user = await this.whoami(orgId, idToken);\n\n this.eventEmitter.emit(connectedEventName, user, bundle);\n\n return user;\n };\n\n /**\n * Initiates the export of a wallet by creating an iframe stamper and calling the appropriate export function.\n * The export can be based on a seed phrase or a private key.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.exportWallet({\n * iframeContainerId: \"export-iframe-container\",\n * });\n * ```\n *\n * @param {ExportWalletParams} config The parameters for exporting the wallet\n * @param {string} config.iframeContainerId The ID of the container element that will hold the iframe stamper\n * @param {string} [config.iframeElementId] Optional ID for the iframe element\n * @returns {Promise<void>} A promise that resolves when the export process is complete\n */\n public override exportWallet = async ({\n iframeContainerId,\n iframeElementId = \"turnkey-export-iframe\",\n }: ExportWalletParams) => {\n const exportWalletIframeStamper = new IframeStamper({\n iframeContainer: document.getElementById(iframeContainerId),\n iframeElementId: iframeElementId,\n iframeUrl: \"https://export.turnkey.com\",\n });\n await exportWalletIframeStamper.init();\n\n if (this.turnkeyClient.stamper === this.iframeStamper) {\n return this.exportWalletInner({\n exportStamper: exportWalletIframeStamper,\n exportAs: \"SEED_PHRASE\",\n });\n }\n\n return this.exportWalletInner({\n exportStamper: exportWalletIframeStamper,\n exportAs: \"PRIVATE_KEY\",\n });\n };\n\n /**\n * Asynchronous function that clears the user and resets the iframe stamper.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const account = await client.disconnect();\n * ```\n */\n public override disconnect = async () => {\n this.user = undefined;\n this.iframeStamper.clear();\n await this.iframeStamper.init();\n };\n\n /**\n * Redirects the user to the OAuth provider URL based on the provided arguments. This function will always reject after 1 second if the redirection does not occur.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * await client.oauthWithRedirect({\n * type: \"oauth\",\n * authProviderId: \"google\",\n * mode: \"redirect\",\n * redirectUrl: \"/\",\n * });\n * ```\n *\n * @param {Extract<AuthParams, { type: \"oauth\"; mode: \"redirect\" }>} args The arguments required to obtain the OAuth provider URL\n * @returns {Promise<never>} A promise that will never resolve, only reject if the redirection fails\n */\n public override oauthWithRedirect = async (\n args: Extract<AuthParams, { type: \"oauth\"; mode: \"redirect\" }>,\n ): Promise<User | IdTokenOnly> => {\n const turnkeyPublicKey = await this.initSessionStamper();\n\n const oauthParams = args;\n const providerUrl = await this.getOauthProviderUrl({\n oauthParams,\n turnkeyPublicKey,\n oauthCallbackUrl: this.oauthCallbackUrl,\n });\n\n window.location.href = providerUrl;\n return new Promise((_, reject) =>\n setTimeout(() => reject(\"Failed to redirect to OAuth provider\"), 1000),\n );\n };\n\n /**\n * Initiates an OAuth authentication flow in a popup window and returns the authenticated user.\n *\n * @example\n * ```ts\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const user = await client.oauthWithPopup({\n * type: \"oauth\",\n * authProviderId: \"google\",\n * mode: \"popup\"\n * });\n * ```\n *\n * @param {Extract<AuthParams, { type: \"oauth\"; mode: \"popup\" }>} args The authentication parameters specifying OAuth type and popup mode\n * @returns {Promise<User>} A promise that resolves to a `User` object containing the authenticated user information\n */\n public override oauthWithPopup = async (\n args: Extract<AuthParams, { type: \"oauth\"; mode: \"popup\" }>,\n ): Promise<User | AuthLinkingPrompt | IdTokenOnly> => {\n const turnkeyPublicKey = await this.initSessionStamper();\n const oauthParams = args;\n const providerUrl = await this.getOauthProviderUrl({\n oauthParams,\n turnkeyPublicKey,\n oauthCallbackUrl: this.oauthCallbackUrl,\n });\n const popup = window.open(\n providerUrl,\n \"_blank\",\n \"popup,width=500,height=600\",\n );\n const eventEmitter = this.eventEmitter;\n return new Promise((resolve, reject) => {\n const handleMessage = (event: MessageEvent) => {\n if (!event.data) {\n return;\n }\n const {\n alchemyStatus: status,\n alchemyBundle: bundle,\n alchemyOrgId: orgId,\n alchemyIdToken: idToken,\n alchemyIsSignup: isSignup,\n alchemyError,\n alchemyOtpId: otpId,\n alchemyEmail: email,\n alchemyAuthProvider: providerName,\n } = event.data;\n if (alchemyError) {\n cleanup();\n popup?.close();\n reject(new OauthFailedError(alchemyError));\n }\n if (!status) {\n // This message isn't meant for us.\n return;\n }\n cleanup();\n popup?.close();\n switch (status) {\n case \"SUCCESS\":\n this.completeAuthWithBundle({\n bundle,\n orgId,\n connectedEventName: \"connectedOauth\",\n idToken,\n authenticatingType: \"oauth\",\n }).then((user) => {\n if (isSignup) {\n eventEmitter.emit(\"newUserSignup\");\n }\n resolve(user);\n }, reject);\n break;\n case \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\":\n resolve({\n status,\n idToken,\n email,\n providerName,\n otpId,\n orgId,\n } satisfies AuthLinkingPrompt);\n break;\n case \"FETCHED_ID_TOKEN_ONLY\":\n resolve({\n status,\n idToken,\n providerName,\n } satisfies IdTokenOnly);\n break;\n default:\n reject(new Error(`Unknown status: ${status}`));\n }\n };\n\n window.addEventListener(\"message\", handleMessage);\n\n const checkCloseIntervalId = setInterval(() => {\n if (popup?.closed) {\n cleanup();\n reject(new OauthCancelledError());\n }\n }, CHECK_CLOSE_INTERVAL);\n\n const cleanup = () => {\n window.removeEventListener(\"message\", handleMessage);\n clearInterval(checkCloseIntervalId);\n };\n });\n };\n\n /**\n * Initializes the iframe stamper and returns its public key.\n *\n * @example\n * ```ts twoslash\n * import { AlchemySignerWebClient } from \"@account-kit/signer\";\n *\n * const client = new AlchemySignerWebClient({\n * connection: {\n * apiKey: \"your-api-key\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"signer-iframe-container\",\n * },\n * });\n *\n * const publicKey = await client.targetPublicKey();\n * ```\n *\n * @returns {Promise<string>} A promise that resolves with the target public key when the iframe stamper is successfully initialized, or throws an error if the target public key is not supported.\n */\n public override targetPublicKey = async (): Promise<string> => {\n return this.initSessionStamper();\n };\n\n protected override getWebAuthnAttestation = async (\n options?: CredentialCreationOptionOverrides,\n userDetails: { username: string } = {\n username: this.user?.email ?? \"anonymous\",\n },\n ): Promise<GetWebAuthnAttestationResult> => {\n const challenge = generateRandomBuffer();\n const authenticatorUserId = generateRandomBuffer();\n\n const attestation = await getWebAuthnAttestation({\n publicKey: {\n ...options?.publicKey,\n authenticatorSelection: {\n residentKey: \"preferred\",\n requireResidentKey: false,\n userVerification: \"preferred\",\n ...options?.publicKey?.authenticatorSelection,\n },\n challenge,\n rp: {\n id: window.location.hostname,\n name: window.location.hostname,\n ...options?.publicKey?.rp,\n },\n pubKeyCredParams: [\n {\n type: \"public-key\",\n alg: -7,\n },\n {\n type: \"public-key\",\n alg: -257,\n },\n ],\n user: {\n id: authenticatorUserId,\n name: userDetails.username,\n displayName: userDetails.username,\n ...options?.publicKey?.user,\n },\n },\n signal: options?.signal,\n });\n\n // on iOS sometimes this is returned as empty or null, so handling that here\n if (attestation.transports == null || attestation.transports.length === 0) {\n attestation.transports = [\n \"AUTHENTICATOR_TRANSPORT_INTERNAL\",\n \"AUTHENTICATOR_TRANSPORT_HYBRID\",\n ];\n }\n\n return { challenge, authenticatorUserId, attestation };\n };\n\n protected override getOauthConfig = async (): Promise<OauthConfig> => {\n const currentStamper = this.turnkeyClient.stamper;\n const publicKey = await this.initSessionStamper();\n\n // swap the stamper back in case the user logged in with a different stamper (passkeys)\n this.setStamper(currentStamper);\n const nonce = this.getOauthNonce(publicKey);\n return this.request(\"/v1/prepare-oauth\", { nonce });\n };\n\n protected override async initSessionStamper(): Promise<string> {\n if (!this.iframeStamper.publicKey()) {\n await this.iframeStamper.init();\n }\n\n this.setStamper(this.iframeStamper);\n\n return this.iframeStamper.publicKey()!;\n }\n\n protected override async initWebauthnStamper(\n user: User | undefined = this.user,\n ): Promise<void> {\n this.setStamper(this.webauthnStamper);\n if (user && user.credentialId) {\n // The goal here is to allow us to cache the allowed credential, but this doesn't work with hybrid transport :(\n this.webauthnStamper.allowCredentials = [\n {\n id: Buffer.from(user.credentialId, \"base64\"),\n type: \"public-key\",\n transports: [\"internal\", \"hybrid\"],\n },\n ];\n }\n }\n}\n\n/**\n * This error is thrown when the OAuth flow is cancelled because the auth popup\n * window was closed.\n */\nexport class OauthCancelledError extends BaseError {\n override name = \"OauthCancelledError\";\n\n /**\n * Constructor for initializing an error indicating that the OAuth flow was\n * cancelled.\n */\n constructor() {\n super(\"OAuth cancelled\");\n }\n}\n\n/**\n * This error is thrown when an error occurs during the OAuth login flow.\n */\nexport class OauthFailedError extends BaseError {\n override name = \"OauthFailedError\";\n}\n"]}
|
|
@@ -49,6 +49,7 @@ export type OauthParams = Extract<AuthParams, {
|
|
|
49
49
|
type: "oauth";
|
|
50
50
|
}> & {
|
|
51
51
|
expirationSeconds?: number;
|
|
52
|
+
fetchIdTokenOnly?: boolean;
|
|
52
53
|
};
|
|
53
54
|
export type OtpParams = {
|
|
54
55
|
orgId: string;
|
|
@@ -146,13 +147,34 @@ export type SignerEndpoints = [
|
|
|
146
147
|
signature: Hex;
|
|
147
148
|
};
|
|
148
149
|
},
|
|
150
|
+
{
|
|
151
|
+
Route: "/v1/update-email-auth";
|
|
152
|
+
Body: {
|
|
153
|
+
stampedRequest: TSignedRequest;
|
|
154
|
+
};
|
|
155
|
+
Response: void;
|
|
156
|
+
},
|
|
149
157
|
{
|
|
150
158
|
Route: "/v1/add-oauth-provider";
|
|
151
159
|
Body: {
|
|
152
160
|
stampedRequest: TSignedRequest;
|
|
153
161
|
};
|
|
162
|
+
Response: {
|
|
163
|
+
oauthProviders: OauthProviderInfo[];
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
Route: "/v1/remove-oauth-provider";
|
|
168
|
+
Body: {
|
|
169
|
+
stampedRequest: TSignedRequest;
|
|
170
|
+
};
|
|
154
171
|
Response: void;
|
|
155
172
|
},
|
|
173
|
+
{
|
|
174
|
+
Route: "/v1/list-auth-methods";
|
|
175
|
+
Body: {};
|
|
176
|
+
Response: AuthMethods;
|
|
177
|
+
},
|
|
156
178
|
{
|
|
157
179
|
Route: "/v1/prepare-oauth";
|
|
158
180
|
Body: {
|
|
@@ -247,6 +269,11 @@ export type AuthLinkingPrompt = {
|
|
|
247
269
|
otpId: string;
|
|
248
270
|
orgId: string;
|
|
249
271
|
};
|
|
272
|
+
export type IdTokenOnly = {
|
|
273
|
+
status: "FETCHED_ID_TOKEN_ONLY";
|
|
274
|
+
idToken: string;
|
|
275
|
+
providerName: string;
|
|
276
|
+
};
|
|
250
277
|
export type OauthState = {
|
|
251
278
|
authProviderId: string;
|
|
252
279
|
isCustomProvider?: boolean;
|
|
@@ -255,6 +282,7 @@ export type OauthState = {
|
|
|
255
282
|
expirationSeconds?: number;
|
|
256
283
|
redirectUrl?: string;
|
|
257
284
|
openerOrigin?: string;
|
|
285
|
+
fetchIdTokenOnly?: boolean;
|
|
258
286
|
};
|
|
259
287
|
export type GetOauthProviderUrlArgs = {
|
|
260
288
|
oauthParams: OauthParams;
|
|
@@ -305,6 +333,22 @@ export type AddOauthProviderParams = {
|
|
|
305
333
|
providerName: string;
|
|
306
334
|
oidcToken: string;
|
|
307
335
|
};
|
|
336
|
+
export type AuthMethods = {
|
|
337
|
+
email?: string;
|
|
338
|
+
oauthProviders: OauthProviderInfo[];
|
|
339
|
+
passkeys: PasskeyInfo[];
|
|
340
|
+
};
|
|
341
|
+
export type OauthProviderInfo = {
|
|
342
|
+
providerId: string;
|
|
343
|
+
issuer: string;
|
|
344
|
+
providerName?: string;
|
|
345
|
+
userDisplayName?: string;
|
|
346
|
+
};
|
|
347
|
+
export type PasskeyInfo = {
|
|
348
|
+
authenticatorId: string;
|
|
349
|
+
name: string;
|
|
350
|
+
createdAt: number;
|
|
351
|
+
};
|
|
308
352
|
export type experimental_CreateApiKeyParams = {
|
|
309
353
|
name: string;
|
|
310
354
|
publicKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"@aa-sdk/core\";\nimport type { TSignedRequest, getWebAuthnAttestation } from \"@turnkey/http\";\nimport type { Hex } from \"viem\";\nimport type { AuthParams } from \"../signer\";\n\nexport type CredentialCreationOptionOverrides = {\n publicKey?: Partial<CredentialCreationOptions[\"publicKey\"]>;\n} & Pick<CredentialCreationOptions, \"signal\">;\n\n// [!region User]\nexport type User = {\n email?: string;\n orgId: string;\n userId: string;\n address: Address;\n solanaAddress?: string;\n credentialId?: string;\n idToken?: string;\n claims?: Record<string, unknown>;\n};\n// [!endregion User]\n\nexport type ExportWalletParams = {\n iframeContainerId: string;\n iframeElementId?: string;\n};\n\nexport type CreateAccountParams =\n | {\n type: \"email\";\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n redirectParams?: URLSearchParams;\n }\n | {\n type: \"passkey\";\n email: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | {\n type: \"passkey\";\n username: string;\n creationOpts?: CredentialCreationOptionOverrides;\n };\n\nexport type EmailType = \"magicLink\" | \"otp\";\n\nexport type EmailAuthParams = {\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n targetPublicKey: string;\n redirectParams?: URLSearchParams;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type OauthParams = Extract<AuthParams, { type: \"oauth\" }> & {\n expirationSeconds?: number;\n};\n\nexport type OtpParams = {\n orgId: string;\n otpId: string;\n otpCode: string;\n targetPublicKey: string;\n expirationSeconds?: number;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type OtpResponse =\n | {\n status: \"SUCCESS\";\n credentialBundle: string;\n }\n | {\n status: \"MFA_REQUIRED\";\n encryptedPayload: string;\n multiFactors: MfaFactor[];\n };\n\nexport type SignupResponse = {\n orgId: string;\n userId?: string;\n address?: Address;\n otpId?: string;\n};\n\nexport type OauthConfig = {\n codeChallenge: string;\n requestKey: string;\n authProviders: AuthProviderConfig[];\n};\n\nexport type EmailConfig = {\n mode?: \"MAGIC_LINK\" | \"OTP\";\n};\n\nexport type SignerConfig = {\n email: EmailConfig;\n};\n\nexport type AuthProviderConfig = {\n id: string;\n isCustomProvider?: boolean;\n clientId: string;\n authEndpoint: string;\n};\n\nexport type SignerRoutes = SignerEndpoints[number][\"Route\"];\nexport type SignerBody<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Body\"];\nexport type SignerResponse<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Response\"];\n\nexport type SignerEndpoints = [\n {\n Route: \"/v1/signup\";\n Body:\n | (Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n })\n | {\n passkey: {\n challenge: string;\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n };\n };\n Response: SignupResponse;\n },\n {\n Route: \"/v1/whoami\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: User;\n },\n {\n Route: \"/v1/auth\";\n Body: Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n multiFactors?: VerifyMfaParams[];\n };\n Response: {\n orgId: string;\n otpId?: string;\n multiFactors?: MfaFactor[];\n };\n },\n {\n Route: \"/v1/lookup\";\n Body: {\n email: string;\n };\n Response: {\n orgId: string | null;\n };\n },\n {\n Route: \"/v1/sign-payload\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n signature: Hex;\n };\n },\n {\n Route: \"/v1/add-oauth-provider\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: void;\n },\n {\n Route: \"/v1/prepare-oauth\";\n Body: {\n nonce: string;\n };\n Response: OauthConfig;\n },\n {\n Route: \"/v1/otp\";\n Body: OtpParams;\n Response: OtpResponse;\n },\n {\n Route: \"/v1/auth-list-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-delete-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorIds: string[];\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-request-multi-factor\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorType: MultiFactorType;\n };\n Response: AddMfaResult;\n },\n {\n Route: \"/v1/auth-verify-multi-factor\";\n Body: VerifyMfaParams & {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/signer-config\";\n Body: {};\n Response: SignerConfig;\n },\n {\n Route: \"/v1/auth-validate-multi-factors\";\n Body: {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n };\n Response: {\n payload: {\n credentialBundle?: string;\n };\n multiFactors: MfaFactor[];\n };\n },\n];\n\nexport type AuthenticatingEventMetadata = {\n type: \"email\" | \"passkey\" | \"oauth\" | \"otp\" | \"otpVerify\";\n};\n\nexport type AlchemySignerClientEvents = {\n connected(user: User): void;\n newUserSignup(): void;\n authenticating(data: AuthenticatingEventMetadata): void;\n connectedEmail(user: User, bundle: string): void;\n connectedPasskey(user: User): void;\n connectedOauth(user: User, bundle: string): void;\n connectedOtp(user: User, bundle: string): void;\n disconnected(): void;\n};\n\nexport type AlchemySignerClientEvent = keyof AlchemySignerClientEvents;\n\nexport type GetWebAuthnAttestationResult = {\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n challenge: ArrayBuffer | string;\n authenticatorUserId: BufferSource;\n};\n\nexport type AuthLinkingPrompt = {\n status: \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\";\n idToken: string;\n email: string;\n providerName: string;\n otpId: string;\n orgId: string;\n};\n\nexport type OauthState = {\n authProviderId: string;\n isCustomProvider?: boolean;\n requestKey: string;\n turnkeyPublicKey: string;\n expirationSeconds?: number;\n redirectUrl?: string;\n openerOrigin?: string;\n};\n\nexport type GetOauthProviderUrlArgs = {\n oauthParams: OauthParams;\n turnkeyPublicKey: string;\n oauthCallbackUrl: string;\n oauthConfig?: OauthConfig;\n usesRelativeUrl?: boolean;\n};\n\nexport type MfaFactor = {\n multiFactorId: string;\n multiFactorType: string;\n};\n\ntype MultiFactorType = \"totp\";\n\nexport type AddMfaParams = {\n multiFactorType: MultiFactorType;\n};\n\nexport type AddMfaResult = {\n multiFactorType: MultiFactorType;\n multiFactorId: string;\n multiFactorTotpUrl: string;\n};\n\nexport type VerifyMfaParams = {\n multiFactorId: string;\n multiFactorCode: string;\n};\n\nexport type RemoveMfaParams = {\n multiFactorIds: string[];\n};\n\nexport type ValidateMultiFactorsParams = {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n};\n\nexport type MfaChallenge = {\n multiFactorId: string;\n multiFactorChallenge:\n | {\n code: string;\n }\n | Record<string, any>;\n};\n\nexport type SubmitOtpCodeResponse =\n | { bundle: string; mfaRequired: false }\n | { mfaRequired: true; encryptedPayload: string; multiFactors: MfaFactor[] };\n\nexport type AddOauthProviderParams = {\n providerName: string;\n oidcToken: string;\n};\n\nexport type experimental_CreateApiKeyParams = {\n name: string;\n publicKey: string;\n expirationSec: number;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"@aa-sdk/core\";\nimport type { TSignedRequest, getWebAuthnAttestation } from \"@turnkey/http\";\nimport type { Hex } from \"viem\";\nimport type { AuthParams } from \"../signer\";\n\nexport type CredentialCreationOptionOverrides = {\n publicKey?: Partial<CredentialCreationOptions[\"publicKey\"]>;\n} & Pick<CredentialCreationOptions, \"signal\">;\n\n// [!region User]\nexport type User = {\n email?: string;\n orgId: string;\n userId: string;\n address: Address;\n solanaAddress?: string;\n credentialId?: string;\n idToken?: string;\n claims?: Record<string, unknown>;\n};\n// [!endregion User]\n\nexport type ExportWalletParams = {\n iframeContainerId: string;\n iframeElementId?: string;\n};\n\nexport type CreateAccountParams =\n | {\n type: \"email\";\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n redirectParams?: URLSearchParams;\n }\n | {\n type: \"passkey\";\n email: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | {\n type: \"passkey\";\n username: string;\n creationOpts?: CredentialCreationOptionOverrides;\n };\n\nexport type EmailType = \"magicLink\" | \"otp\";\n\nexport type EmailAuthParams = {\n email: string;\n /** @deprecated This option will be overriden by dashboard settings. Please use the dashboard settings instead. This option will be removed in a future release. */\n emailMode?: EmailType;\n expirationSeconds?: number;\n targetPublicKey: string;\n redirectParams?: URLSearchParams;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type OauthParams = Extract<AuthParams, { type: \"oauth\" }> & {\n expirationSeconds?: number;\n fetchIdTokenOnly?: boolean;\n};\n\nexport type OtpParams = {\n orgId: string;\n otpId: string;\n otpCode: string;\n targetPublicKey: string;\n expirationSeconds?: number;\n multiFactors?: VerifyMfaParams[];\n};\n\nexport type OtpResponse =\n | {\n status: \"SUCCESS\";\n credentialBundle: string;\n }\n | {\n status: \"MFA_REQUIRED\";\n encryptedPayload: string;\n multiFactors: MfaFactor[];\n };\n\nexport type SignupResponse = {\n orgId: string;\n userId?: string;\n address?: Address;\n otpId?: string;\n};\n\nexport type OauthConfig = {\n codeChallenge: string;\n requestKey: string;\n authProviders: AuthProviderConfig[];\n};\n\nexport type EmailConfig = {\n mode?: \"MAGIC_LINK\" | \"OTP\";\n};\n\nexport type SignerConfig = {\n email: EmailConfig;\n};\n\nexport type AuthProviderConfig = {\n id: string;\n isCustomProvider?: boolean;\n clientId: string;\n authEndpoint: string;\n};\n\nexport type SignerRoutes = SignerEndpoints[number][\"Route\"];\nexport type SignerBody<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Body\"];\nexport type SignerResponse<T extends SignerRoutes> = Extract<\n SignerEndpoints[number],\n { Route: T }\n>[\"Response\"];\n\nexport type SignerEndpoints = [\n {\n Route: \"/v1/signup\";\n Body:\n | (Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n })\n | {\n passkey: {\n challenge: string;\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n };\n };\n Response: SignupResponse;\n },\n {\n Route: \"/v1/whoami\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: User;\n },\n {\n Route: \"/v1/auth\";\n Body: Omit<EmailAuthParams, \"redirectParams\"> & {\n redirectParams?: string;\n multiFactors?: VerifyMfaParams[];\n };\n Response: {\n orgId: string;\n otpId?: string;\n multiFactors?: MfaFactor[];\n };\n },\n {\n Route: \"/v1/lookup\";\n Body: {\n email: string;\n };\n Response: {\n orgId: string | null;\n };\n },\n {\n Route: \"/v1/sign-payload\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n signature: Hex;\n };\n },\n {\n Route: \"/v1/update-email-auth\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: void;\n },\n {\n Route: \"/v1/add-oauth-provider\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: { oauthProviders: OauthProviderInfo[] };\n },\n {\n Route: \"/v1/remove-oauth-provider\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: void;\n },\n {\n Route: \"/v1/list-auth-methods\";\n Body: {};\n Response: AuthMethods;\n },\n {\n Route: \"/v1/prepare-oauth\";\n Body: {\n nonce: string;\n };\n Response: OauthConfig;\n },\n {\n Route: \"/v1/otp\";\n Body: OtpParams;\n Response: OtpResponse;\n },\n {\n Route: \"/v1/auth-list-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-delete-multi-factors\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorIds: string[];\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/auth-request-multi-factor\";\n Body: {\n stampedRequest: TSignedRequest;\n multiFactorType: MultiFactorType;\n };\n Response: AddMfaResult;\n },\n {\n Route: \"/v1/auth-verify-multi-factor\";\n Body: VerifyMfaParams & {\n stampedRequest: TSignedRequest;\n };\n Response: {\n multiFactors: MfaFactor[];\n };\n },\n {\n Route: \"/v1/signer-config\";\n Body: {};\n Response: SignerConfig;\n },\n {\n Route: \"/v1/auth-validate-multi-factors\";\n Body: {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n };\n Response: {\n payload: {\n credentialBundle?: string;\n };\n multiFactors: MfaFactor[];\n };\n },\n];\n\nexport type AuthenticatingEventMetadata = {\n type: \"email\" | \"passkey\" | \"oauth\" | \"otp\" | \"otpVerify\";\n};\n\nexport type AlchemySignerClientEvents = {\n connected(user: User): void;\n newUserSignup(): void;\n authenticating(data: AuthenticatingEventMetadata): void;\n connectedEmail(user: User, bundle: string): void;\n connectedPasskey(user: User): void;\n connectedOauth(user: User, bundle: string): void;\n connectedOtp(user: User, bundle: string): void;\n disconnected(): void;\n};\n\nexport type AlchemySignerClientEvent = keyof AlchemySignerClientEvents;\n\nexport type GetWebAuthnAttestationResult = {\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;\n challenge: ArrayBuffer | string;\n authenticatorUserId: BufferSource;\n};\n\nexport type AuthLinkingPrompt = {\n status: \"ACCOUNT_LINKING_CONFIRMATION_REQUIRED\";\n idToken: string;\n email: string;\n providerName: string;\n otpId: string;\n orgId: string;\n};\n\nexport type IdTokenOnly = {\n status: \"FETCHED_ID_TOKEN_ONLY\";\n idToken: string;\n providerName: string;\n};\n\nexport type OauthState = {\n authProviderId: string;\n isCustomProvider?: boolean;\n requestKey: string;\n turnkeyPublicKey: string;\n expirationSeconds?: number;\n redirectUrl?: string;\n openerOrigin?: string;\n fetchIdTokenOnly?: boolean;\n};\n\nexport type GetOauthProviderUrlArgs = {\n oauthParams: OauthParams;\n turnkeyPublicKey: string;\n oauthCallbackUrl: string;\n oauthConfig?: OauthConfig;\n usesRelativeUrl?: boolean;\n};\n\nexport type MfaFactor = {\n multiFactorId: string;\n multiFactorType: string;\n};\n\ntype MultiFactorType = \"totp\";\n\nexport type AddMfaParams = {\n multiFactorType: MultiFactorType;\n};\n\nexport type AddMfaResult = {\n multiFactorType: MultiFactorType;\n multiFactorId: string;\n multiFactorTotpUrl: string;\n};\n\nexport type VerifyMfaParams = {\n multiFactorId: string;\n multiFactorCode: string;\n};\n\nexport type RemoveMfaParams = {\n multiFactorIds: string[];\n};\n\nexport type ValidateMultiFactorsParams = {\n encryptedPayload: string;\n multiFactors: VerifyMfaParams[];\n};\n\nexport type MfaChallenge = {\n multiFactorId: string;\n multiFactorChallenge:\n | {\n code: string;\n }\n | Record<string, any>;\n};\n\nexport type SubmitOtpCodeResponse =\n | { bundle: string; mfaRequired: false }\n | { mfaRequired: true; encryptedPayload: string; multiFactors: MfaFactor[] };\n\nexport type AddOauthProviderParams = {\n providerName: string;\n oidcToken: string;\n};\n\nexport type AuthMethods = {\n email?: string;\n oauthProviders: OauthProviderInfo[];\n passkeys: PasskeyInfo[];\n};\n\nexport type OauthProviderInfo = {\n providerId: string;\n issuer: string;\n providerName?: string;\n userDisplayName?: string;\n};\n\nexport type PasskeyInfo = {\n authenticatorId: string;\n name: string;\n createdAt: number;\n};\n\nexport type experimental_CreateApiKeyParams = {\n name: string;\n publicKey: string;\n expirationSec: number;\n};\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.41.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.41.0\";\n"]}
|
package/dist/types/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SmartAccountAuthenticator, type AuthorizationRequest } from "@aa-sdk/core";
|
|
2
2
|
import { type GetTransactionType, type Hex, type IsNarrowable, type LocalAccount, type SerializeTransactionFn, type SignableMessage, type SignedAuthorization, type TransactionSerializable, type TransactionSerialized, type TypedData, type TypedDataDefinition } from "viem";
|
|
3
3
|
import type { BaseSignerClient } from "./client/base";
|
|
4
|
-
import { type MfaFactor, type OauthConfig, type User, type VerifyMfaParams, type AddMfaParams, type AddMfaResult, type RemoveMfaParams, type AuthLinkingPrompt } from "./client/types.js";
|
|
4
|
+
import { type MfaFactor, type OauthConfig, type User, type VerifyMfaParams, type AddMfaParams, type AddMfaResult, type RemoveMfaParams, type AuthLinkingPrompt, type OauthProviderInfo, type AuthMethods } from "./client/types.js";
|
|
5
5
|
import { type SessionManagerParams } from "./session/manager.js";
|
|
6
6
|
import type { AuthParams } from "./signer";
|
|
7
7
|
import { SolanaSigner } from "./solanaSigner.js";
|
|
@@ -339,6 +339,14 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
339
339
|
getUser: (email: string) => Promise<{
|
|
340
340
|
orgId: string;
|
|
341
341
|
} | null>;
|
|
342
|
+
setEmail: (email: string) => Promise<void>;
|
|
343
|
+
/**
|
|
344
|
+
* Removes the email for the authenticated user, disallowing them from login with that email.
|
|
345
|
+
*
|
|
346
|
+
* @returns {Promise<void>} A promise that resolves when the email is removed
|
|
347
|
+
* @throws {NotAuthenticatedError} If the user is not authenticated
|
|
348
|
+
*/
|
|
349
|
+
removeEmail: () => Promise<void>;
|
|
342
350
|
/**
|
|
343
351
|
* Adds a passkey to the user's account
|
|
344
352
|
*
|
|
@@ -364,6 +372,34 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
364
372
|
* @returns {Promise<string[]>} an array of the authenticator ids added to the user
|
|
365
373
|
*/
|
|
366
374
|
addPasskey: (params?: CredentialCreationOptions) => Promise<string[]>;
|
|
375
|
+
/**
|
|
376
|
+
* Removes a passkey from a user's account
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```ts
|
|
380
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
381
|
+
*
|
|
382
|
+
* const signer = new AlchemyWebSigner({
|
|
383
|
+
* client: {
|
|
384
|
+
* connection: {
|
|
385
|
+
* rpcUrl: "/api/rpc",
|
|
386
|
+
* },
|
|
387
|
+
* iframeConfig: {
|
|
388
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
389
|
+
* },
|
|
390
|
+
* },
|
|
391
|
+
* });
|
|
392
|
+
*
|
|
393
|
+
* const authMethods = await signer.listAuthMethods();
|
|
394
|
+
* const passkey = authMethods.passkeys[0];
|
|
395
|
+
*
|
|
396
|
+
* const result = await signer.removePasskey(passkey.authenticatorId);
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @param {CredentialCreationOptions | undefined} params optional parameters for the passkey creation
|
|
400
|
+
* @returns {Promise<string[]>} an array of the authenticator ids added to the user
|
|
401
|
+
*/
|
|
402
|
+
removePasskey: (authenticatorId: string) => Promise<void>;
|
|
367
403
|
getPasskeyStatus: () => Promise<{
|
|
368
404
|
isPasskeyAdded: boolean;
|
|
369
405
|
}>;
|
|
@@ -449,6 +485,30 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
449
485
|
private authenticateWithEmail;
|
|
450
486
|
private authenticateWithPasskey;
|
|
451
487
|
private authenticateWithOauth;
|
|
488
|
+
/**
|
|
489
|
+
* Handles OAuth authentication by augmenting the provided arguments with a type and performing authentication based on the OAuth mode (either using redirect or popup).
|
|
490
|
+
*
|
|
491
|
+
* @param {Omit<Extract<AuthParams, { type: "oauth" }>, "type">} args Authentication parameters omitting the type, which will be set to "oauth"
|
|
492
|
+
* @returns {Promise<OauthProviderInfo>} A promise that resolves to an `OauthProviderInfo` object containing provider information and the ID token.
|
|
493
|
+
*/
|
|
494
|
+
addOauthProvider: (args: Omit<Extract<AuthParams, {
|
|
495
|
+
type: "oauth";
|
|
496
|
+
}>, "type">) => Promise<OauthProviderInfo>;
|
|
497
|
+
/**
|
|
498
|
+
* Removes an OAuth provider by its ID if the user is authenticated.
|
|
499
|
+
*
|
|
500
|
+
* @param {string} providerId The ID of the OAuth provider to be removed, as obtained from `listOauthProviders`
|
|
501
|
+
* @returns {Promise<any>} A promise indicating the result of the removal process
|
|
502
|
+
* @throws {NotAuthenticatedError} Thrown if the user is not authenticated
|
|
503
|
+
*/
|
|
504
|
+
removeOauthProvider: (providerId: string) => Promise<void>;
|
|
505
|
+
/**
|
|
506
|
+
* Retrieves a list of auth methods associated with the authenticated user.
|
|
507
|
+
*
|
|
508
|
+
* @returns {Promise<AuthMethods>} A promise that resolves to an `AuthMethods` object containing the user's email, OAuth providers, and passkeys.
|
|
509
|
+
* @throws {NotAuthenticatedError} Thrown if the user is not authenticated
|
|
510
|
+
*/
|
|
511
|
+
listAuthMethods: () => Promise<AuthMethods>;
|
|
452
512
|
private authenticateWithOtp;
|
|
453
513
|
private setAwaitingEmailAuth;
|
|
454
514
|
private handleOauthReturn;
|
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,EAEL,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAEhB,KAAK,IAAI,EACT,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAKd,O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AAC,iBAAiB,CA0DvB;IAEF,OAAO,CAAC,gBAAgB,CAGtB;YAEY,qBAAqB;YA0CrB,iBAAiB;IAyB/B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC;QAAE,YAAY,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CAGtD;IAEL;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAGlD;IAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,SAAS,EAAE,CACT,MAAM,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,OAAO,CAAC,YAAY,CAAC,CAGpD;IAEF;;;;OAIG;IACI,SAAS,QAAa,OAAO,CAAC,YAAY,CAAC,CAMhD;IAEF,SAAS,CAAC,WAAW,QAAa,OAAO,CAAC,YAAY,CAAC,CAErD;IAEF,OAAO,CAAC,oBAAoB,CAa1B;IAEF,OAAO,CAAC,gBAAgB,CAOtB;CACH"}
|
|
@@ -2,7 +2,7 @@ import { type ConnectionConfig } from "@aa-sdk/core";
|
|
|
2
2
|
import { TurnkeyClient, type TSignedRequest } from "@turnkey/http";
|
|
3
3
|
import EventEmitter from "eventemitter3";
|
|
4
4
|
import { type Hex } from "viem";
|
|
5
|
-
import type { AlchemySignerClientEvent, AlchemySignerClientEvents, AuthenticatingEventMetadata, CreateAccountParams, RemoveMfaParams, EmailAuthParams, AddMfaParams, AddMfaResult, experimental_CreateApiKeyParams, GetOauthProviderUrlArgs, GetWebAuthnAttestationResult, MfaFactor, OauthConfig, OauthParams, OtpParams, SignerBody, SignerResponse, SignerRoutes, SignupResponse, User, VerifyMfaParams, SubmitOtpCodeResponse, ValidateMultiFactorsParams, AuthLinkingPrompt, AddOauthProviderParams, CredentialCreationOptionOverrides } from "./types.js";
|
|
5
|
+
import type { AlchemySignerClientEvent, AlchemySignerClientEvents, AuthenticatingEventMetadata, CreateAccountParams, RemoveMfaParams, EmailAuthParams, AddMfaParams, AddMfaResult, experimental_CreateApiKeyParams, GetOauthProviderUrlArgs, GetWebAuthnAttestationResult, MfaFactor, OauthConfig, OauthParams, OtpParams, SignerBody, SignerResponse, SignerRoutes, SignupResponse, User, VerifyMfaParams, SubmitOtpCodeResponse, ValidateMultiFactorsParams, AuthLinkingPrompt, AddOauthProviderParams, CredentialCreationOptionOverrides, OauthProviderInfo, IdTokenOnly, AuthMethods } from "./types.js";
|
|
6
6
|
export interface BaseSignerClientParams {
|
|
7
7
|
stamper: TurnkeyClient["stamper"];
|
|
8
8
|
connection: ConnectionConfig;
|
|
@@ -77,10 +77,10 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
77
77
|
}): Promise<User>;
|
|
78
78
|
abstract oauthWithRedirect(args: Extract<OauthParams, {
|
|
79
79
|
mode: "redirect";
|
|
80
|
-
}>): Promise<User>;
|
|
80
|
+
}>): Promise<User | IdTokenOnly>;
|
|
81
81
|
abstract oauthWithPopup(args: Extract<OauthParams, {
|
|
82
82
|
mode: "popup";
|
|
83
|
-
}>): Promise<User | AuthLinkingPrompt>;
|
|
83
|
+
}>): Promise<User | AuthLinkingPrompt | IdTokenOnly>;
|
|
84
84
|
abstract submitOtpCode(args: Omit<OtpParams, "targetPublicKey">): Promise<SubmitOtpCodeResponse>;
|
|
85
85
|
abstract disconnect(): Promise<void>;
|
|
86
86
|
abstract exportWallet(params: TExportWalletParams): Promise<boolean>;
|
|
@@ -102,6 +102,27 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
102
102
|
* @returns {() => void} a function that will remove the listener when called
|
|
103
103
|
*/
|
|
104
104
|
on: <E extends AlchemySignerClientEvent>(event: E, listener: AlchemySignerClientEvents[E]) => () => EventEmitter<AlchemySignerClientEvents, any>;
|
|
105
|
+
/**
|
|
106
|
+
* Sets the email for the authenticated user, allowing them to login with that
|
|
107
|
+
* email.
|
|
108
|
+
*
|
|
109
|
+
* You must contact Alchemy to enable this feature for your team, as there are
|
|
110
|
+
* important security considerations. In particular, you must not call this
|
|
111
|
+
* without first validating that the user owns this email account.
|
|
112
|
+
*
|
|
113
|
+
* @param {string} email The email to set for the user
|
|
114
|
+
* @returns {Promise<void>} A promise that resolves when the email is set
|
|
115
|
+
* @throws {NotAuthenticatedError} If the user is not authenticated
|
|
116
|
+
*/
|
|
117
|
+
setEmail: (email: string) => Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Removes the email for the authenticated user, disallowing them from login with that email.
|
|
120
|
+
*
|
|
121
|
+
* @returns {Promise<void>} A promise that resolves when the email is removed
|
|
122
|
+
* @throws {NotAuthenticatedError} If the user is not authenticated
|
|
123
|
+
*/
|
|
124
|
+
removeEmail: () => Promise<void>;
|
|
125
|
+
private updateEmail;
|
|
105
126
|
/**
|
|
106
127
|
* Handles the creation of authenticators using WebAuthn attestation and the provided options. Requires the user to be authenticated.
|
|
107
128
|
*
|
|
@@ -110,6 +131,14 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
110
131
|
* @throws {NotAuthenticatedError} If the user is not authenticated
|
|
111
132
|
*/
|
|
112
133
|
addPasskey: (options: CredentialCreationOptions) => Promise<string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Removes a passkey authenticator from the user's account.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} authenticatorId The ID of the authenticator to remove.
|
|
138
|
+
* @returns {Promise<void>} A promise that resolves when the authenticator is removed.
|
|
139
|
+
* @throws {NotAuthenticatedError} If the user is not authenticated.
|
|
140
|
+
*/
|
|
141
|
+
removePasskey: (authenticatorId: string) => Promise<void>;
|
|
113
142
|
/**
|
|
114
143
|
* Asynchronously handles the authentication process using WebAuthn Stamper. If a user is provided, sets the user and returns it. Otherwise, retrieves the current user and initializes the WebAuthn stamper.
|
|
115
144
|
*
|
|
@@ -133,7 +162,21 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
133
162
|
* @throws {NotAuthenticatedError} Throws if the user is not authenticated.
|
|
134
163
|
* @returns {Promise<void>} A Promise that resolves when the OAuth provider is added.
|
|
135
164
|
*/
|
|
136
|
-
addOauthProvider: (params: AddOauthProviderParams) => Promise<
|
|
165
|
+
addOauthProvider: (params: AddOauthProviderParams) => Promise<OauthProviderInfo>;
|
|
166
|
+
/**
|
|
167
|
+
* Deletes a specified OAuth provider for the authenticated user.
|
|
168
|
+
*
|
|
169
|
+
* @param {string} providerId The ID of the provider to be deleted
|
|
170
|
+
* @throws {NotAuthenticatedError} If the user is not authenticated
|
|
171
|
+
*/
|
|
172
|
+
removeOauthProvider: (providerId: string) => Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Retrieves the list of authentication methods for the current user.
|
|
175
|
+
*
|
|
176
|
+
* @returns {Promise<AuthMethods>} A promise that resolves to the list of authentication methods
|
|
177
|
+
* @throws {NotAuthenticatedError} If the user is not authenticated
|
|
178
|
+
*/
|
|
179
|
+
listAuthMethods: () => Promise<AuthMethods>;
|
|
137
180
|
/**
|
|
138
181
|
* Retrieves the current user or fetches the user information if not already available.
|
|
139
182
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/client/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAA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EF,OAAO,CAAC,kBAAkB,CA4BxB;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,SAAS,CAAC,mBAAmB,GAC3B,MAAM,uBAAuB,KAC5B,OAAO,CAAC,MAAM,CAAC,CAqGhB;IAEF,OAAO,CAAC,qBAAqB,CAY3B;IAGF,SAAS,CAAC,sBAAsB,GAC9B,CAAC,SAAS,MAAM,OAAO,CACrB,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CACvD,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EAEvB,UAAU,OAAO,CACf,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CACvD,CAAC,UAAU,CAAC,EACb,gBAAgB,MAAM,EACtB,WAAW,CAAC,KACX,OAAO,CACR,WAAW,CACT,OAAO,CACL,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CACvD,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAC3B,CACF,CA8BC;IAGF;;;;;OAKG;IACH,SAAS,CAAC,aAAa,GAAI,kBAAkB,MAAM,KAAG,MAAM,CAE1D;CACH"}
|
|
@@ -2,7 +2,7 @@ import { BaseError } from "@aa-sdk/core";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { AuthParams } from "../signer.js";
|
|
4
4
|
import { BaseSignerClient } from "./base.js";
|
|
5
|
-
import type { AlchemySignerClientEvents, AuthenticatingEventMetadata, CredentialCreationOptionOverrides, EmailAuthParams, ExportWalletParams, OauthConfig, OtpParams, User, SubmitOtpCodeResponse, AuthLinkingPrompt, GetWebAuthnAttestationResult } from "./types.js";
|
|
5
|
+
import type { AlchemySignerClientEvents, AuthenticatingEventMetadata, CredentialCreationOptionOverrides, EmailAuthParams, ExportWalletParams, OauthConfig, OtpParams, User, SubmitOtpCodeResponse, AuthLinkingPrompt, GetWebAuthnAttestationResult, IdTokenOnly } from "./types.js";
|
|
6
6
|
export declare const AlchemySignerClientParamsSchema: z.ZodObject<{
|
|
7
7
|
connection: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
8
8
|
rpcUrl: z.ZodOptional<z.ZodNever>;
|
|
@@ -333,7 +333,7 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
333
333
|
oauthWithRedirect: (args: Extract<AuthParams, {
|
|
334
334
|
type: "oauth";
|
|
335
335
|
mode: "redirect";
|
|
336
|
-
}>) => Promise<
|
|
336
|
+
}>) => Promise<User | IdTokenOnly>;
|
|
337
337
|
/**
|
|
338
338
|
* Initiates an OAuth authentication flow in a popup window and returns the authenticated user.
|
|
339
339
|
*
|
|
@@ -363,7 +363,7 @@ export declare class AlchemySignerWebClient extends BaseSignerClient<ExportWalle
|
|
|
363
363
|
oauthWithPopup: (args: Extract<AuthParams, {
|
|
364
364
|
type: "oauth";
|
|
365
365
|
mode: "popup";
|
|
366
|
-
}>) => Promise<User | AuthLinkingPrompt>;
|
|
366
|
+
}>) => Promise<User | AuthLinkingPrompt | IdTokenOnly>;
|
|
367
367
|
/**
|
|
368
368
|
* Initializes the iframe stamper and returns its public key.
|
|
369
369
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0B,MAAM,cAAc,CAAC;AAIjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,iCAAiC,EACjC,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,IAAI,EACJ,qBAAq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