UNPKG

@0xsequence/connect

Version:
213 lines 8.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDefaultUniversalConnectors = exports.getDefaultWaasConnectors = exports.getDefaultConnectors = void 0; const apple_js_1 = require("../connectors/apple/apple.js"); const appleWaas_js_1 = require("../connectors/apple/appleWaas.js"); const coinbaseWallet_js_1 = require("../connectors/coinbaseWallet/coinbaseWallet.js"); const index_js_1 = require("../connectors/ecosystem/index.js"); const email_js_1 = require("../connectors/email/email.js"); const emailWaas_js_1 = require("../connectors/email/emailWaas.js"); const epicWaas_js_1 = require("../connectors/epic/epicWaas.js"); const facebook_js_1 = require("../connectors/facebook/facebook.js"); const google_js_1 = require("../connectors/google/google.js"); const googleWaas_js_1 = require("../connectors/google/googleWaas.js"); const guestWaas_js_1 = require("../connectors/guest/guestWaas.js"); const metaMask_js_1 = require("../connectors/metaMask/metaMask.js"); const sequence_js_1 = require("../connectors/sequence/sequence.js"); const twitch_js_1 = require("../connectors/twitch/twitch.js"); const walletConnect_js_1 = require("../connectors/walletConnect/walletConnect.js"); const XWaas_js_1 = require("../connectors/X/XWaas.js"); const getConnectWallets_js_1 = require("../utils/getConnectWallets.js"); const getDefaultConnectors = (walletType, options) => { if (walletType === 'waas') { return (0, exports.getDefaultWaasConnectors)(options); } else if (walletType === 'universal') { return (0, exports.getDefaultUniversalConnectors)(options); } }; exports.getDefaultConnectors = getDefaultConnectors; const getDefaultWaasConnectors = (options) => { const { projectAccessKey, waasConfigKey, appName, enableConfirmationModal, defaultChainId } = options; const wallets = []; if (options.guest) { wallets.push((0, guestWaas_js_1.guestWaas)({ projectAccessKey, waasConfigKey, enableConfirmationModal, network: defaultChainId })); } if (options.email) { wallets.push((0, emailWaas_js_1.emailWaas)({ projectAccessKey, waasConfigKey, enableConfirmationModal, network: defaultChainId })); } if (options.google || options.googleClientId) { const googleClientId = (options.google && options.google.clientId) || options.googleClientId; wallets.push((0, googleWaas_js_1.googleWaas)({ projectAccessKey, waasConfigKey, googleClientId, enableConfirmationModal, network: defaultChainId })); } if (options.apple || (options.appleClientId && options.appleRedirectURI)) { const appleClientId = (options.apple && options.apple.clientId) || options.appleClientId; const appleRedirectURI = (options.apple && options.apple.redirectURI) || options.appleRedirectURI; wallets.push((0, appleWaas_js_1.appleWaas)({ projectAccessKey, waasConfigKey, appleClientId, appleRedirectURI, enableConfirmationModal, network: defaultChainId })); } if (options.epic) { wallets.push((0, epicWaas_js_1.epicWaas)({ projectAccessKey, waasConfigKey, epicAuthUrl: options.epic.authUrl, enableConfirmationModal, network: defaultChainId })); } if (options.X) { wallets.push((0, XWaas_js_1.XWaas)({ projectAccessKey, waasConfigKey, XClientId: options.X.clientId, XRedirectURI: options.X.redirectURI, enableConfirmationModal, network: defaultChainId })); } if (options.ecosystem) { wallets.push((0, index_js_1.ecosystemWallet)({ ...options.ecosystem, projectAccessKey, defaultNetwork: defaultChainId ?? 1 })); } if (options.metaMask !== false) { if (typeof window !== 'undefined') { wallets.push((0, metaMask_js_1.metaMask)({ dappMetadata: { name: appName, url: window.location.origin, iconUrl: `https://www.google.com/s2/favicons?domain_url=${window.location.origin}` } })); } } if (options.coinbase !== false) { wallets.push((0, coinbaseWallet_js_1.coinbaseWallet)({ appName })); } if (options.walletConnect || options.walletConnectProjectId) { const projectId = (options.walletConnect && options.walletConnect?.projectId) || options.walletConnectProjectId; wallets.push((0, walletConnect_js_1.walletConnect)({ projectId, defaultNetwork: defaultChainId })); } if (options?.additionalWallets && options?.additionalWallets.length > 0) { wallets.push(...options.additionalWallets); } return (0, getConnectWallets_js_1.getConnectWallets)(projectAccessKey, wallets); }; exports.getDefaultWaasConnectors = getDefaultWaasConnectors; const getDefaultUniversalConnectors = (options) => { const { projectAccessKey, appName, defaultChainId } = options; const wallets = []; if (options.email !== false) { wallets.push((0, email_js_1.email)({ defaultNetwork: defaultChainId, connect: { app: appName } })); } if (options.google !== false) { wallets.push((0, google_js_1.google)({ defaultNetwork: defaultChainId, connect: { app: appName } })); } if (options.facebook !== false) { wallets.push((0, facebook_js_1.facebook)({ defaultNetwork: defaultChainId, connect: { app: appName } })); } if (options.twitch !== false) { wallets.push((0, twitch_js_1.twitch)({ defaultNetwork: defaultChainId, connect: { app: appName } })); } if (options.apple !== false) { wallets.push((0, apple_js_1.apple)({ defaultNetwork: defaultChainId, connect: { app: appName } })); } if (options.sequence !== false) { wallets.push((0, sequence_js_1.sequence)({ defaultNetwork: defaultChainId, connect: { app: appName } })); } if (options.ecosystem) { wallets.push((0, index_js_1.ecosystemWallet)({ ...options.ecosystem, projectAccessKey, defaultNetwork: defaultChainId ?? 1 })); } if (options.metaMask !== false) { if (typeof window !== 'undefined') { wallets.push((0, metaMask_js_1.metaMask)({ dappMetadata: { name: appName, url: window.location.origin, iconUrl: `https://www.google.com/s2/favicons?domain_url=${window.location.origin}` } })); } } if (options.coinbase !== false) { wallets.push((0, coinbaseWallet_js_1.coinbaseWallet)({ appName })); } if (options.walletConnect || options.walletConnectProjectId) { const projectId = (options.walletConnect && options.walletConnect?.projectId) || options.walletConnectProjectId; wallets.push((0, walletConnect_js_1.walletConnect)({ projectId, defaultNetwork: defaultChainId })); } if (options?.additionalWallets && options?.additionalWallets.length > 0) { wallets.push(...options.additionalWallets); } return (0, getConnectWallets_js_1.getConnectWallets)(projectAccessKey, wallets); }; exports.getDefaultUniversalConnectors = getDefaultUniversalConnectors; //# sourceMappingURL=defaultConnectors.js.map