diff --git a/packages/thirdweb/src/utils/domain.test.ts b/packages/thirdweb/src/utils/domain.test.ts index 8c22e32f024..21ad80b1339 100644 --- a/packages/thirdweb/src/utils/domain.test.ts +++ b/packages/thirdweb/src/utils/domain.test.ts @@ -18,6 +18,7 @@ describe("Thirdweb Domains", () => { rpc: "rpc.thirdweb.com", social: "social.thirdweb.com", storage: "storage.thirdweb.com", + api: "api.thirdweb.com", }; beforeEach(() => { diff --git a/packages/thirdweb/src/utils/domains.ts b/packages/thirdweb/src/utils/domains.ts index 9e345046ee9..d39a840e15e 100644 --- a/packages/thirdweb/src/utils/domains.ts +++ b/packages/thirdweb/src/utils/domains.ts @@ -14,6 +14,11 @@ type DomainOverrides = { * @default "embedded-wallet.thirdweb.com" */ inAppWallet?: string; + /** + * The base URL for the API server. + * @default "api.thirdweb.com" + */ + api?: string; /** * The base URL for the payment server. * @default "pay.thirdweb.com" @@ -54,6 +59,7 @@ type DomainOverrides = { export const DEFAULT_RPC_URL = "rpc.thirdweb.com"; const DEFAULT_SOCIAL_URL = "social.thirdweb.com"; const DEFAULT_IN_APP_WALLET_URL = "embedded-wallet.thirdweb.com"; +const DEFAULT_API_URL = "api.thirdweb.com"; const DEFAULT_PAY_URL = "pay.thirdweb.com"; const DEFAULT_STORAGE_URL = "storage.thirdweb.com"; const DEFAULT_BUNDLER_URL = "bundler.thirdweb.com"; @@ -64,6 +70,7 @@ const DEFAULT_BRIDGE_URL = "bridge.thirdweb.com"; let domains: { [k in keyof DomainOverrides]-?: string } = { analytics: DEFAULT_ANALYTICS_URL, + api: DEFAULT_API_URL, bridge: DEFAULT_BRIDGE_URL, bundler: DEFAULT_BUNDLER_URL, engineCloud: DEFAULT_ENGINE_CLOUD_URL, @@ -78,6 +85,7 @@ let domains: { [k in keyof DomainOverrides]-?: string } = { export const setThirdwebDomains = (DomainOverrides: DomainOverrides) => { domains = { analytics: DomainOverrides.analytics ?? DEFAULT_ANALYTICS_URL, + api: DomainOverrides.api ?? DEFAULT_API_URL, bridge: DomainOverrides.bridge ?? DEFAULT_BRIDGE_URL, bundler: DomainOverrides.bundler ?? DEFAULT_BUNDLER_URL, engineCloud: DomainOverrides.engineCloud ?? DEFAULT_ENGINE_CLOUD_URL, diff --git a/packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts b/packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts index b14fec04aca..4626ff47f9d 100644 --- a/packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts +++ b/packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts @@ -1,9 +1,7 @@ import type { ThirdwebClient } from "../../../../../client/client.js"; +import { getThirdwebBaseUrl } from "../../../../../utils/domains.js"; import { stringify } from "../../../../../utils/json.js"; -import { - getLoginCallbackUrl, - getLoginUrl, -} from "../../../core/authentication/getLoginPath.js"; +import { getLoginCallbackUrl } from "../../../core/authentication/getLoginPath.js"; import type { AuthStoredTokenWithCookieReturnType, MultiStepAuthArgsType, @@ -16,7 +14,7 @@ import type { Ecosystem } from "../../../core/wallet/types.js"; */ export const sendOtp = async (args: PreAuthArgsType): Promise => { const { client, ecosystem } = args; - const url = getLoginUrl({ authOption: args.strategy, client, ecosystem }); + const url = `${getThirdwebBaseUrl("api")}/v1/auth/initiate`; const headers: Record = { "Content-Type": "application/json", @@ -35,10 +33,12 @@ export const sendOtp = async (args: PreAuthArgsType): Promise => { switch (args.strategy) { case "email": return { + method: "email", email: args.email, }; case "phone": return { + method: "sms", phone: args.phoneNumber, }; } @@ -54,7 +54,7 @@ export const sendOtp = async (args: PreAuthArgsType): Promise => { throw new Error("Failed to send verification code"); } - return await response.json(); + return; }; /**