Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/thirdweb/src/utils/domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("Thirdweb Domains", () => {
rpc: "rpc.thirdweb.com",
social: "social.thirdweb.com",
storage: "storage.thirdweb.com",
api: "api.thirdweb.com",
};

beforeEach(() => {
Expand Down
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 @@
*/
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`;

Check warning on line 17 in packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts#L17

Added line #L17 was not covered by tests

const headers: Record<string, string> = {
"Content-Type": "application/json",
Expand All @@ -35,10 +33,12 @@
switch (args.strategy) {
case "email":
return {
method: "email",

Check warning on line 36 in packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts#L36

Added line #L36 was not covered by tests
email: args.email,
};
case "phone":
return {
method: "sms",

Check warning on line 41 in packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts#L41

Added line #L41 was not covered by tests
phone: args.phoneNumber,
};
}
Expand All @@ -54,7 +54,7 @@
throw new Error("Failed to send verification code");
}

return await response.json();
return;

Check warning on line 57 in packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts#L57

Added line #L57 was not covered by tests
};

/**
Expand Down
Loading