Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/thirdweb/src/utils/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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";
Expand All @@ -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,
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -16,7 +14,7 @@ import type { Ecosystem } from "../../../core/wallet/types.js";
*/
export const sendOtp = async (args: PreAuthArgsType): Promise<void> => {
const { client, ecosystem } = args;
const url = getLoginUrl({ authOption: args.strategy, client, ecosystem });
const url = `${getThirdwebBaseUrl("api")}/v1/auth/initiate`;

const headers: Record<string, string> = {
"Content-Type": "application/json",
Expand All @@ -35,10 +33,12 @@ export const sendOtp = async (args: PreAuthArgsType): Promise<void> => {
switch (args.strategy) {
case "email":
return {
method: "email",
email: args.email,
};
case "phone":
return {
method: "sms",
phone: args.phoneNumber,
};
}
Expand All @@ -54,7 +54,7 @@ export const sendOtp = async (args: PreAuthArgsType): Promise<void> => {
throw new Error("Failed to send verification code");
}

return await response.json();
return;
};

/**
Expand Down
Loading