diff --git a/packages/alchemy/src/signer/client/index.ts b/packages/alchemy/src/signer/client/index.ts index 34b62a82d1..fb05e65017 100644 --- a/packages/alchemy/src/signer/client/index.ts +++ b/packages/alchemy/src/signer/client/index.ts @@ -89,6 +89,7 @@ export class AlchemySignerClient { email, targetPublicKey: publicKey, expirationSeconds, + redirectParams: params.redirectParams?.toString(), }); return response; @@ -117,6 +118,7 @@ export class AlchemySignerClient { email, targetPublicKey: publicKey, expirationSeconds, + redirectParams: params.redirectParams?.toString(), }); }; diff --git a/packages/alchemy/src/signer/client/types.ts b/packages/alchemy/src/signer/client/types.ts index 71eb371f3d..816ac7dd5a 100644 --- a/packages/alchemy/src/signer/client/types.ts +++ b/packages/alchemy/src/signer/client/types.ts @@ -18,6 +18,7 @@ export type CreateAccountParams = type: "email"; email: string; expirationSeconds?: number; + redirectParams?: URLSearchParams; } | { type: "passkey"; @@ -29,6 +30,7 @@ export type EmailAuthParams = { email: string; expirationSeconds?: number; targetPublicKey: string; + redirectParams?: URLSearchParams; }; export type SignerRoutes = SignerEndpoints[number]["Route"]; @@ -45,7 +47,7 @@ export type SignerEndpoints = [ { Route: "/v1/signup"; Body: - | EmailAuthParams + | (Omit & { redirectParams?: string }) | { passkey: { challenge: string; @@ -67,7 +69,7 @@ export type SignerEndpoints = [ }, { Route: "/v1/auth"; - Body: EmailAuthParams; + Body: Omit & { redirectParams?: string }; Response: { orgId: string; }; diff --git a/packages/alchemy/src/signer/signer.ts b/packages/alchemy/src/signer/signer.ts index e9807789b1..e572be4d90 100644 --- a/packages/alchemy/src/signer/signer.ts +++ b/packages/alchemy/src/signer/signer.ts @@ -25,8 +25,8 @@ import { } from "./session/manager.js"; export type AuthParams = - | { type: "email"; email: string } - | { type: "email"; bundle: string } + | { type: "email"; email: string; redirectParams?: URLSearchParams } + | { type: "email"; bundle: string; orgId?: string } | { type: "passkey"; createNew: false; @@ -196,11 +196,13 @@ export class AlchemySigner ? await this.inner.initEmailAuth({ email: params.email, expirationSeconds: this.sessionManager.expirationTimeMs, + redirectParams: params.redirectParams, }) : await this.inner.createAccount({ type: "email", email: params.email, expirationSeconds: this.sessionManager.expirationTimeMs, + redirectParams: params.redirectParams, }); this.sessionManager.setTemporarySession({ orgId }); @@ -214,7 +216,10 @@ export class AlchemySigner }); }); } else { - const temporarySession = this.sessionManager.getTemporarySession(); + const temporarySession = params.orgId + ? { orgId: params.orgId } + : this.sessionManager.getTemporarySession(); + if (!temporarySession) { throw new Error("Could not find email auth init session!"); }