Skip to content

Commit

Permalink
useMpc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed Oct 30, 2024
1 parent 20337b6 commit cdeefc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/vue-example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 5 additions & 15 deletions src/core/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ export class Auth {

constructor(options: AuthOptions) {
if (!options.clientId) throw InitializationError.invalidParams("clientId is required");
if (options.useMpc) {
if (Object.values(WEB3AUTH_LEGACY_NETWORK).includes(options.network as WEB3AUTH_LEGACY_NETWORK_TYPE))
throw InitializationError.invalidParams("MPC is not supported on legacy networks, please use sapphire_devnet or sapphire_mainnet.");
}
if (!options.network) options.network = WEB3AUTH_NETWORK.SAPPHIRE_MAINNET;
if (!options.buildEnv) options.buildEnv = BUILD_ENV.PRODUCTION;
if (options.buildEnv === BUILD_ENV.DEVELOPMENT || options.buildEnv === BUILD_ENV.TESTING || options.sdkUrl) this.addVersionInUrls = false;
if (!options.sdkUrl && !options.useMpc) {
if (!options.sdkUrl) {
if (options.buildEnv === BUILD_ENV.DEVELOPMENT) {
options.sdkUrl = "http://localhost:3000";
options.dashboardUrl = "http://localhost:5173/wallet/account";
Expand All @@ -62,20 +66,6 @@ export class Auth {
}
}

if (options.useMpc && !options.sdkUrl) {
if (Object.values(WEB3AUTH_LEGACY_NETWORK).includes(options.network as WEB3AUTH_LEGACY_NETWORK_TYPE))
throw InitializationError.invalidParams("MPC is not supported on legacy networks, please use sapphire_devnet or sapphire_mainnet.");
if (options.buildEnv === BUILD_ENV.DEVELOPMENT) {
options.sdkUrl = "http://localhost:3000";
} else if (options.buildEnv === BUILD_ENV.STAGING) {
options.sdkUrl = "https://staging-mpc-auth.web3auth.io";
} else if (options.buildEnv === BUILD_ENV.TESTING) {
options.sdkUrl = "https://develop-mpc-auth.web3auth.io";
} else {
options.sdkUrl = "https://mpc-auth.web3auth.io";
}
}

if (!options.redirectUrl && typeof window !== "undefined") {
options.redirectUrl = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
}
Expand Down

0 comments on commit cdeefc4

Please sign in to comment.