@web3auth/no-modal 10.0.0-beta.4 → 10.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.cjs/connectors/coinbase-connector/coinbaseConnector.js +4 -2
- package/dist/lib.cjs/connectors/coinbase-connector/index.js +7 -0
- package/dist/lib.cjs/index.js +0 -2
- package/dist/lib.cjs/react/solana/hooks/useSignAndSendTransaction.js +35 -0
- package/dist/lib.cjs/react/solana/hooks/useSignMessage.js +36 -0
- package/dist/lib.cjs/react/solana/hooks/useSignTransaction.js +34 -0
- package/dist/lib.cjs/react/solana/hooks/useSolanaWallet.js +52 -0
- package/dist/lib.cjs/react/solana/index.js +13 -0
- package/dist/lib.cjs/types/connectors/coinbase-connector/coinbaseConnector.d.ts +1 -1
- package/dist/lib.cjs/types/connectors/index.d.ts +0 -1
- package/dist/lib.cjs/types/react/solana/hooks/index.d.ts +4 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignAndSendTransaction.d.ts +9 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignMessage.d.ts +8 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSignTransaction.d.ts +14 -0
- package/dist/lib.cjs/types/react/solana/hooks/useSolanaWallet.d.ts +6 -0
- package/dist/lib.cjs/types/react/solana/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/WalletServicesInnerProvider.d.ts +1 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +13 -0
- package/dist/lib.cjs/types/vue/composables/useCheckout.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useEnableMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useIdentityToken.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useManageMFA.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/useSwap.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useSwitchChain.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWalletConnectScanner.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWalletServicesPlugin.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWalletUI.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3Auth.d.ts +3 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthDisconnect.d.ts +10 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthInner.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthUser.d.ts +10 -0
- package/dist/lib.cjs/types/vue/{wallet-services-plugin/context.d.ts → context/WalletServicesContext.d.ts} +2 -2
- package/dist/lib.cjs/types/vue/context/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/index.d.ts +4 -2
- package/dist/lib.cjs/types/vue/interfaces.d.ts +30 -0
- package/dist/lib.cjs/vue/{wallet-services-plugin/WalletServicesProvider.js → WalletServicesInnerProvider.js} +26 -43
- package/dist/lib.cjs/vue/{no-modal/Web3AuthProvider.js → Web3AuthProvider.js} +32 -87
- package/dist/lib.cjs/vue/composables/useCheckout.js +45 -0
- package/dist/lib.cjs/vue/composables/useEnableMFA.js +43 -0
- package/dist/lib.cjs/vue/composables/useIdentityToken.js +55 -0
- package/dist/lib.cjs/vue/composables/useManageMFA.js +43 -0
- package/dist/lib.cjs/vue/composables/useSwap.js +45 -0
- package/dist/lib.cjs/vue/composables/useSwitchChain.js +43 -0
- package/dist/lib.cjs/vue/composables/useWalletConnectScanner.js +45 -0
- package/dist/lib.cjs/vue/composables/useWalletServicesPlugin.js +12 -0
- package/dist/lib.cjs/vue/composables/useWalletUI.js +45 -0
- package/dist/lib.cjs/vue/composables/useWeb3Auth.js +28 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthConnect.js +57 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthDisconnect.js +43 -0
- package/dist/lib.cjs/vue/{no-modal/composables/useWeb3Auth.js → composables/useWeb3AuthInner.js} +9 -9
- package/dist/lib.cjs/vue/composables/useWeb3AuthUser.js +64 -0
- package/dist/lib.cjs/vue/index.js +28 -8
- package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +3 -1
- package/dist/lib.esm/connectors/coinbase-connector/index.js +1 -0
- package/dist/lib.esm/index.js +0 -1
- package/dist/lib.esm/react/solana/hooks/useSignAndSendTransaction.js +33 -0
- package/dist/lib.esm/react/solana/hooks/useSignMessage.js +34 -0
- package/dist/lib.esm/react/solana/hooks/useSignTransaction.js +32 -0
- package/dist/lib.esm/react/solana/hooks/useSolanaWallet.js +50 -0
- package/dist/lib.esm/react/solana/index.js +4 -0
- package/dist/lib.esm/vue/WalletServicesInnerProvider.js +79 -0
- package/dist/lib.esm/vue/{no-modal/Web3AuthProvider.js → Web3AuthProvider.js} +32 -87
- package/dist/lib.esm/vue/composables/useCheckout.js +43 -0
- package/dist/lib.esm/vue/composables/useEnableMFA.js +41 -0
- package/dist/lib.esm/vue/composables/useIdentityToken.js +53 -0
- package/dist/lib.esm/vue/composables/useManageMFA.js +41 -0
- package/dist/lib.esm/vue/composables/useSwap.js +43 -0
- package/dist/lib.esm/vue/composables/useSwitchChain.js +41 -0
- package/dist/lib.esm/vue/composables/useWalletConnectScanner.js +43 -0
- package/dist/lib.esm/vue/composables/useWalletServicesPlugin.js +10 -0
- package/dist/lib.esm/vue/composables/useWalletUI.js +43 -0
- package/dist/lib.esm/vue/composables/useWeb3Auth.js +26 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthConnect.js +55 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthDisconnect.js +41 -0
- package/dist/lib.esm/vue/{no-modal/composables/useWeb3Auth.js → composables/useWeb3AuthInner.js} +9 -9
- package/dist/lib.esm/vue/composables/useWeb3AuthUser.js +62 -0
- package/dist/lib.esm/vue/index.js +15 -5
- package/dist/noModal.umd.min.js +1 -1
- package/dist/noModal.umd.min.js.LICENSE.txt +4 -0
- package/package.json +27 -11
- package/dist/lib.cjs/types/vue/no-modal/composables/index.d.ts +0 -1
- package/dist/lib.cjs/types/vue/no-modal/composables/useWeb3Auth.d.ts +0 -2
- package/dist/lib.cjs/types/vue/no-modal/index.d.ts +0 -3
- package/dist/lib.cjs/types/vue/no-modal/interfaces.d.ts +0 -39
- package/dist/lib.cjs/types/vue/wallet-services-plugin/WalletServicesProvider.d.ts +0 -1
- package/dist/lib.cjs/types/vue/wallet-services-plugin/composables/index.d.ts +0 -1
- package/dist/lib.cjs/types/vue/wallet-services-plugin/composables/useWalletServicesPlugin.d.ts +0 -2
- package/dist/lib.cjs/types/vue/wallet-services-plugin/index.d.ts +0 -4
- package/dist/lib.cjs/types/vue/wallet-services-plugin/interfaces.d.ts +0 -13
- package/dist/lib.cjs/vue/wallet-services-plugin/composables/useWalletServicesPlugin.js +0 -24
- package/dist/lib.esm/vue/wallet-services-plugin/WalletServicesProvider.js +0 -96
- package/dist/lib.esm/vue/wallet-services-plugin/composables/useWalletServicesPlugin.js +0 -22
- /package/dist/lib.cjs/types/vue/{no-modal/Web3AuthProvider.d.ts → Web3AuthProvider.d.ts} +0 -0
- /package/dist/lib.cjs/vue/{wallet-services-plugin/context.js → context/WalletServicesContext.js} +0 -0
- /package/dist/lib.esm/vue/{wallet-services-plugin/context.js → context/WalletServicesContext.js} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
15
|
+
|
|
16
|
+
const useCheckout = () => {
|
|
17
|
+
const {
|
|
18
|
+
plugin,
|
|
19
|
+
ready
|
|
20
|
+
} = useWalletServicesPlugin();
|
|
21
|
+
const loading = ref(false);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const showCheckout = async showCheckoutParams => {
|
|
24
|
+
loading.value = true;
|
|
25
|
+
error.value = null;
|
|
26
|
+
try {
|
|
27
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
28
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
29
|
+
await plugin.value.showCheckout(showCheckoutParams);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
error.value = err;
|
|
32
|
+
} finally {
|
|
33
|
+
loading.value = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
loading,
|
|
38
|
+
error,
|
|
39
|
+
showCheckout
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { useCheckout };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
15
|
+
|
|
16
|
+
const useEnableMFA = () => {
|
|
17
|
+
const {
|
|
18
|
+
web3Auth
|
|
19
|
+
} = useWeb3AuthInner();
|
|
20
|
+
const loading = ref(false);
|
|
21
|
+
const error = ref(null);
|
|
22
|
+
const enableMFA = async () => {
|
|
23
|
+
try {
|
|
24
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
25
|
+
error.value = null;
|
|
26
|
+
loading.value = true;
|
|
27
|
+
await web3Auth.value.enableMFA();
|
|
28
|
+
} catch (err) {
|
|
29
|
+
error.value = err;
|
|
30
|
+
} finally {
|
|
31
|
+
loading.value = false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
loading,
|
|
36
|
+
error,
|
|
37
|
+
enableMFA
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { useEnableMFA };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
15
|
+
|
|
16
|
+
const useIdentityToken = () => {
|
|
17
|
+
const {
|
|
18
|
+
web3Auth,
|
|
19
|
+
isConnected
|
|
20
|
+
} = useWeb3AuthInner();
|
|
21
|
+
const loading = ref(false);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const token = ref(null);
|
|
24
|
+
const authenticateUser = async () => {
|
|
25
|
+
try {
|
|
26
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
27
|
+
error.value = null;
|
|
28
|
+
loading.value = true;
|
|
29
|
+
const result = await web3Auth.value.authenticateUser();
|
|
30
|
+
if (result !== null && result !== void 0 && result.idToken) {
|
|
31
|
+
token.value = result.idToken;
|
|
32
|
+
}
|
|
33
|
+
return result === null || result === void 0 ? void 0 : result.idToken;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
error.value = err;
|
|
36
|
+
} finally {
|
|
37
|
+
loading.value = false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
watch(isConnected, newIsConnected => {
|
|
41
|
+
if (!newIsConnected && token.value) {
|
|
42
|
+
token.value = null;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
loading,
|
|
47
|
+
error,
|
|
48
|
+
token,
|
|
49
|
+
authenticateUser
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { useIdentityToken };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
15
|
+
|
|
16
|
+
const useManageMFA = () => {
|
|
17
|
+
const {
|
|
18
|
+
web3Auth
|
|
19
|
+
} = useWeb3AuthInner();
|
|
20
|
+
const loading = ref(false);
|
|
21
|
+
const error = ref(null);
|
|
22
|
+
const manageMFA = async () => {
|
|
23
|
+
try {
|
|
24
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
25
|
+
error.value = null;
|
|
26
|
+
loading.value = true;
|
|
27
|
+
await web3Auth.value.enableMFA();
|
|
28
|
+
} catch (err) {
|
|
29
|
+
error.value = err;
|
|
30
|
+
} finally {
|
|
31
|
+
loading.value = false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
loading,
|
|
36
|
+
error,
|
|
37
|
+
manageMFA
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { useManageMFA };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
15
|
+
|
|
16
|
+
const useSwap = () => {
|
|
17
|
+
const {
|
|
18
|
+
plugin,
|
|
19
|
+
ready
|
|
20
|
+
} = useWalletServicesPlugin();
|
|
21
|
+
const loading = ref(false);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const showSwap = async showSwapParams => {
|
|
24
|
+
loading.value = true;
|
|
25
|
+
error.value = null;
|
|
26
|
+
try {
|
|
27
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
28
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
29
|
+
await plugin.value.showSwap(showSwapParams);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
error.value = err;
|
|
32
|
+
} finally {
|
|
33
|
+
loading.value = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
loading,
|
|
38
|
+
error,
|
|
39
|
+
showSwap
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { useSwap };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
15
|
+
|
|
16
|
+
const useSwitchChain = () => {
|
|
17
|
+
const {
|
|
18
|
+
web3Auth
|
|
19
|
+
} = useWeb3AuthInner();
|
|
20
|
+
const loading = ref(false);
|
|
21
|
+
const error = ref(null);
|
|
22
|
+
const switchChain = async chainParams => {
|
|
23
|
+
try {
|
|
24
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
25
|
+
error.value = null;
|
|
26
|
+
loading.value = true;
|
|
27
|
+
await web3Auth.value.switchChain(chainParams);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
error.value = err;
|
|
30
|
+
} finally {
|
|
31
|
+
loading.value = false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
loading,
|
|
36
|
+
error,
|
|
37
|
+
switchChain
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { useSwitchChain };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
15
|
+
|
|
16
|
+
const useWalletConnectScanner = () => {
|
|
17
|
+
const {
|
|
18
|
+
plugin,
|
|
19
|
+
ready
|
|
20
|
+
} = useWalletServicesPlugin();
|
|
21
|
+
const loading = ref(false);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const showWalletConnectScanner = async showWalletConnectScannerParams => {
|
|
24
|
+
loading.value = true;
|
|
25
|
+
error.value = null;
|
|
26
|
+
try {
|
|
27
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
28
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
29
|
+
await plugin.value.showWalletConnectScanner(showWalletConnectScannerParams);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
error.value = err;
|
|
32
|
+
} finally {
|
|
33
|
+
loading.value = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
loading,
|
|
38
|
+
error,
|
|
39
|
+
showWalletConnectScanner
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { useWalletConnectScanner };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { inject } from 'vue';
|
|
2
|
+
import { WalletServicesContextKey } from '../context/WalletServicesContext.js';
|
|
3
|
+
|
|
4
|
+
const useWalletServicesPlugin = () => {
|
|
5
|
+
const context = inject(WalletServicesContextKey);
|
|
6
|
+
if (!context) throw new Error("WalletServicesContext not found");
|
|
7
|
+
return context;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { useWalletServicesPlugin };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
15
|
+
|
|
16
|
+
const useWalletUI = () => {
|
|
17
|
+
const {
|
|
18
|
+
plugin,
|
|
19
|
+
ready
|
|
20
|
+
} = useWalletServicesPlugin();
|
|
21
|
+
const loading = ref(false);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const showWalletUI = async showWalletUiParams => {
|
|
24
|
+
loading.value = true;
|
|
25
|
+
error.value = null;
|
|
26
|
+
try {
|
|
27
|
+
if (!plugin) throw WalletServicesPluginError.notInitialized();
|
|
28
|
+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
|
|
29
|
+
await plugin.value.showWalletUi(showWalletUiParams);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
error.value = err;
|
|
32
|
+
} finally {
|
|
33
|
+
loading.value = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
loading,
|
|
38
|
+
error,
|
|
39
|
+
showWalletUI
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { useWalletUI };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
2
|
+
|
|
3
|
+
const useWeb3Auth = () => {
|
|
4
|
+
const {
|
|
5
|
+
initError,
|
|
6
|
+
isConnected,
|
|
7
|
+
isInitialized,
|
|
8
|
+
isInitializing,
|
|
9
|
+
provider,
|
|
10
|
+
status,
|
|
11
|
+
web3Auth,
|
|
12
|
+
getPlugin
|
|
13
|
+
} = useWeb3AuthInner();
|
|
14
|
+
return {
|
|
15
|
+
initError,
|
|
16
|
+
isConnected,
|
|
17
|
+
isInitialized,
|
|
18
|
+
isInitializing,
|
|
19
|
+
provider,
|
|
20
|
+
status,
|
|
21
|
+
web3Auth,
|
|
22
|
+
getPlugin
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { useWeb3Auth };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
15
|
+
|
|
16
|
+
const useWeb3AuthConnect = () => {
|
|
17
|
+
const {
|
|
18
|
+
web3Auth,
|
|
19
|
+
isConnected
|
|
20
|
+
} = useWeb3AuthInner();
|
|
21
|
+
const loading = ref(false);
|
|
22
|
+
const error = ref(null);
|
|
23
|
+
const connectorName = ref(null);
|
|
24
|
+
watch(isConnected, newVal => {
|
|
25
|
+
if (!newVal && connectorName.value) {
|
|
26
|
+
connectorName.value = null;
|
|
27
|
+
}
|
|
28
|
+
}, {
|
|
29
|
+
immediate: true
|
|
30
|
+
});
|
|
31
|
+
const connect = async (connectorType, loginParams) => {
|
|
32
|
+
try {
|
|
33
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
34
|
+
error.value = null;
|
|
35
|
+
loading.value = true;
|
|
36
|
+
const localProvider = await web3Auth.value.connectTo(connectorType, loginParams);
|
|
37
|
+
connectorName.value = web3Auth.value.connectedConnectorName;
|
|
38
|
+
return localProvider;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
error.value = err;
|
|
41
|
+
return null;
|
|
42
|
+
} finally {
|
|
43
|
+
loading.value = false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
isConnected,
|
|
48
|
+
loading,
|
|
49
|
+
error,
|
|
50
|
+
connectorName,
|
|
51
|
+
connect
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { useWeb3AuthConnect };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
15
|
+
|
|
16
|
+
const useWeb3AuthDisconnect = () => {
|
|
17
|
+
const {
|
|
18
|
+
web3Auth
|
|
19
|
+
} = useWeb3AuthInner();
|
|
20
|
+
const loading = ref(false);
|
|
21
|
+
const error = ref(null);
|
|
22
|
+
const disconnect = async options => {
|
|
23
|
+
try {
|
|
24
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
25
|
+
error.value = null;
|
|
26
|
+
loading.value = true;
|
|
27
|
+
await web3Auth.value.logout(options);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
error.value = err;
|
|
30
|
+
} finally {
|
|
31
|
+
loading.value = false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
loading,
|
|
36
|
+
error,
|
|
37
|
+
disconnect
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { useWeb3AuthDisconnect };
|
package/dist/lib.esm/vue/{no-modal/composables/useWeb3Auth.js → composables/useWeb3AuthInner.js}
RENAMED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { inject } from 'vue';
|
|
2
2
|
import '@toruslabs/base-controllers';
|
|
3
|
-
import { Web3AuthContextKey } from '
|
|
3
|
+
import { Web3AuthContextKey } from '../../base/composables/index.js';
|
|
4
4
|
import '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import '@web3auth/auth';
|
|
6
|
-
import { WalletInitializationError } from '
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
6
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
7
|
+
import '../../base/wallet/index.js';
|
|
8
|
+
import '../../base/connector/constants.js';
|
|
9
9
|
import 'jwt-decode';
|
|
10
|
-
import '
|
|
11
|
-
import '
|
|
12
|
-
import '
|
|
10
|
+
import '../../base/loglevel.js';
|
|
11
|
+
import '../../base/plugin/errors.js';
|
|
12
|
+
import '../../base/plugin/IPlugin.js';
|
|
13
13
|
import '@toruslabs/constants';
|
|
14
14
|
import '@toruslabs/http-helpers';
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const useWeb3AuthInner = () => {
|
|
17
17
|
const context = inject(Web3AuthContextKey);
|
|
18
18
|
if (!context) throw WalletInitializationError.fromCode(1000, "usage of `useWeb3Auth` not wrapped in `Web3AuthProvider`.");
|
|
19
19
|
return context;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export { useWeb3AuthInner };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
import '@toruslabs/base-controllers';
|
|
3
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import '@web3auth/auth';
|
|
5
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
6
|
+
import '../../base/wallet/index.js';
|
|
7
|
+
import '../../base/connector/constants.js';
|
|
8
|
+
import 'jwt-decode';
|
|
9
|
+
import '../../base/loglevel.js';
|
|
10
|
+
import '../../base/plugin/errors.js';
|
|
11
|
+
import '../../base/plugin/IPlugin.js';
|
|
12
|
+
import '@toruslabs/constants';
|
|
13
|
+
import '@toruslabs/http-helpers';
|
|
14
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
15
|
+
|
|
16
|
+
const useWeb3AuthUser = () => {
|
|
17
|
+
const {
|
|
18
|
+
web3Auth,
|
|
19
|
+
isConnected,
|
|
20
|
+
isMFAEnabled,
|
|
21
|
+
setIsMFAEnabled
|
|
22
|
+
} = useWeb3AuthInner();
|
|
23
|
+
const loading = ref(false);
|
|
24
|
+
const error = ref(null);
|
|
25
|
+
const userInfo = ref(null);
|
|
26
|
+
const getUserInfo = async () => {
|
|
27
|
+
try {
|
|
28
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
29
|
+
error.value = null;
|
|
30
|
+
loading.value = true;
|
|
31
|
+
const result = await web3Auth.value.getUserInfo();
|
|
32
|
+
userInfo.value = result;
|
|
33
|
+
return result;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
error.value = err;
|
|
36
|
+
} finally {
|
|
37
|
+
loading.value = false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
watch(isConnected, async newIsConnected => {
|
|
41
|
+
if (newIsConnected && !userInfo.value) {
|
|
42
|
+
const result = await getUserInfo();
|
|
43
|
+
userInfo.value = result;
|
|
44
|
+
setIsMFAEnabled((result === null || result === void 0 ? void 0 : result.isMfaEnabled) || false);
|
|
45
|
+
}
|
|
46
|
+
if (!newIsConnected && userInfo.value) {
|
|
47
|
+
userInfo.value = null;
|
|
48
|
+
setIsMFAEnabled(false);
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
immediate: true
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
loading,
|
|
55
|
+
error,
|
|
56
|
+
userInfo,
|
|
57
|
+
isMFAEnabled,
|
|
58
|
+
getUserInfo
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { useWeb3AuthUser };
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { useCheckout } from './composables/useCheckout.js';
|
|
2
|
+
export { useEnableMFA } from './composables/useEnableMFA.js';
|
|
3
|
+
export { useIdentityToken } from './composables/useIdentityToken.js';
|
|
4
|
+
export { useManageMFA } from './composables/useManageMFA.js';
|
|
5
|
+
export { useSwap } from './composables/useSwap.js';
|
|
6
|
+
export { useSwitchChain } from './composables/useSwitchChain.js';
|
|
7
|
+
export { useWalletConnectScanner } from './composables/useWalletConnectScanner.js';
|
|
8
|
+
export { useWalletServicesPlugin } from './composables/useWalletServicesPlugin.js';
|
|
9
|
+
export { useWalletUI } from './composables/useWalletUI.js';
|
|
10
|
+
export { useWeb3Auth } from './composables/useWeb3Auth.js';
|
|
11
|
+
export { useWeb3AuthConnect } from './composables/useWeb3AuthConnect.js';
|
|
12
|
+
export { useWeb3AuthDisconnect } from './composables/useWeb3AuthDisconnect.js';
|
|
13
|
+
export { useWeb3AuthUser } from './composables/useWeb3AuthUser.js';
|
|
14
|
+
export { WalletServicesContextKey } from './context/WalletServicesContext.js';
|
|
15
|
+
export { Web3AuthProvider } from './Web3AuthProvider.js';
|