@web3auth/modal 10.0.0-alpha.0 → 10.0.0-alpha.1

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.
Files changed (40) hide show
  1. package/dist/lib.cjs/packages/modal/src/config.js +11 -23
  2. package/dist/lib.cjs/packages/modal/src/modalManager.js +232 -297
  3. package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +16 -42
  4. package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +9 -9
  5. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +7 -7
  6. package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +3 -3
  7. package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +11 -11
  8. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +3 -3
  9. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +3 -3
  10. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +21 -21
  11. package/dist/lib.cjs/packages/modal/src/ui/utils.js +4 -4
  12. package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +15 -41
  13. package/dist/lib.esm/packages/modal/src/config.js +12 -24
  14. package/dist/lib.esm/packages/modal/src/modalManager.js +234 -299
  15. package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +17 -43
  16. package/dist/lib.esm/packages/modal/src/ui/components/AdapterLoader.js +10 -10
  17. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +8 -8
  18. package/dist/lib.esm/packages/modal/src/ui/components/Loader.js +4 -4
  19. package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +12 -12
  20. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +3 -3
  21. package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +3 -3
  22. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +22 -22
  23. package/dist/lib.esm/packages/modal/src/ui/utils.js +5 -5
  24. package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +16 -42
  25. package/dist/modal.cjs.js +2306 -2383
  26. package/dist/modal.umd.min.js +1 -1
  27. package/dist/modal.umd.min.js.LICENSE.txt +0 -9
  28. package/dist/types/config.d.ts +6 -6
  29. package/dist/types/interface.d.ts +5 -5
  30. package/dist/types/modalManager.d.ts +11 -11
  31. package/dist/types/react/interfaces.d.ts +4 -4
  32. package/dist/types/ui/components/AdapterLoader.d.ts +2 -2
  33. package/dist/types/ui/components/ExternalWallets.d.ts +3 -3
  34. package/dist/types/ui/components/SocialLoginPasswordless.d.ts +2 -2
  35. package/dist/types/ui/components/SocialLogins.d.ts +1 -1
  36. package/dist/types/ui/interfaces.d.ts +11 -15
  37. package/dist/types/ui/loginModal.d.ts +4 -4
  38. package/dist/types/ui/utils.d.ts +1 -1
  39. package/dist/types/vue/interfaces.d.ts +5 -8
  40. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { ADAPTER_EVENTS, Web3AuthContextKey, ADAPTER_STATUS, WalletInitializationError, WalletLoginError } from '@web3auth/no-modal';
1
+ import { CONNECTOR_EVENTS, Web3AuthContextKey, CONNECTOR_STATUS, WalletInitializationError, WalletLoginError } from '@web3auth/no-modal';
2
2
  import { defineComponent, h, shallowRef, ref, watch, provide } from 'vue';
3
3
  import { Web3Auth } from '../modalManager.js';
4
4
 
@@ -22,10 +22,6 @@ const Web3AuthProvider = defineComponent({
22
22
  const isConnecting = ref(false);
23
23
  const connectError = ref(null);
24
24
  const isConnected = ref(false);
25
- const addPlugin = plugin => {
26
- if (!web3Auth.value) throw WalletInitializationError.notReady();
27
- return web3Auth.value.addPlugin(plugin);
28
- };
29
25
  const getPlugin = name => {
30
26
  if (!web3Auth.value) throw WalletInitializationError.notReady();
31
27
  return web3Auth.value.getPlugin(name);
@@ -64,21 +60,10 @@ const Web3AuthProvider = defineComponent({
64
60
  isConnecting.value = false;
65
61
  }
66
62
  };
67
- const addAndSwitchChain = async chainConfig => {
68
- if (!web3Auth.value) throw WalletInitializationError.notReady();
69
- await web3Auth.value.addChain(chainConfig);
70
- await web3Auth.value.switchChain({
71
- chainId: chainConfig.chainId
72
- });
73
- };
74
63
  const authenticateUser = async () => {
75
64
  if (!web3Auth.value) throw WalletInitializationError.notReady();
76
65
  return web3Auth.value.authenticateUser();
77
66
  };
78
- const addChain = async chainConfig => {
79
- if (!web3Auth.value) throw WalletInitializationError.notReady();
80
- return web3Auth.value.addChain(chainConfig);
81
- };
82
67
  const switchChain = chainParams => {
83
68
  if (!web3Auth.value) throw WalletInitializationError.notReady();
84
69
  return web3Auth.value.switchChain(chainParams);
@@ -93,17 +78,9 @@ const Web3AuthProvider = defineComponent({
93
78
  };
94
79
  resetHookState();
95
80
  const {
96
- web3AuthOptions,
97
- adapters = [],
98
- plugins = []
81
+ web3AuthOptions
99
82
  } = newConfig;
100
83
  const web3AuthInstance = new Web3Auth(web3AuthOptions);
101
- if (adapters.length) adapters.map(adapter => web3AuthInstance.configureAdapter(adapter));
102
- if (plugins.length) {
103
- plugins.forEach(plugin => {
104
- web3AuthInstance.addPlugin(plugin);
105
- });
106
- }
107
84
  web3Auth.value = web3AuthInstance;
108
85
  }, {
109
86
  immediate: true
@@ -161,7 +138,7 @@ const Web3AuthProvider = defineComponent({
161
138
  const connectedListener = () => {
162
139
  status.value = web3Auth.value.status;
163
140
  // we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
164
- if (web3Auth.value.status === ADAPTER_STATUS.CONNECTED) {
141
+ if (web3Auth.value.status === CONNECTOR_STATUS.CONNECTED) {
165
142
  isInitialized.value = true;
166
143
  isConnected.value = true;
167
144
  }
@@ -174,27 +151,27 @@ const Web3AuthProvider = defineComponent({
174
151
  status.value = web3Auth.value.status;
175
152
  };
176
153
  const errorListener = () => {
177
- status.value = ADAPTER_EVENTS.ERRORED;
154
+ status.value = CONNECTOR_EVENTS.ERRORED;
178
155
  };
179
156
 
180
157
  // unregister previous listeners
181
158
  if (prevWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
182
- prevWeb3Auth.off(ADAPTER_EVENTS.NOT_READY, notReadyListener);
183
- prevWeb3Auth.off(ADAPTER_EVENTS.READY, readyListener);
184
- prevWeb3Auth.off(ADAPTER_EVENTS.CONNECTED, connectedListener);
185
- prevWeb3Auth.off(ADAPTER_EVENTS.DISCONNECTED, disconnectedListener);
186
- prevWeb3Auth.off(ADAPTER_EVENTS.CONNECTING, connectingListener);
187
- prevWeb3Auth.off(ADAPTER_EVENTS.ERRORED, errorListener);
159
+ prevWeb3Auth.off(CONNECTOR_EVENTS.NOT_READY, notReadyListener);
160
+ prevWeb3Auth.off(CONNECTOR_EVENTS.READY, readyListener);
161
+ prevWeb3Auth.off(CONNECTOR_EVENTS.CONNECTED, connectedListener);
162
+ prevWeb3Auth.off(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
163
+ prevWeb3Auth.off(CONNECTOR_EVENTS.CONNECTING, connectingListener);
164
+ prevWeb3Auth.off(CONNECTOR_EVENTS.ERRORED, errorListener);
188
165
  }
189
166
  if (newWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
190
167
  status.value = newWeb3Auth.status;
191
168
  // web3Auth is initialized here.
192
- newWeb3Auth.on(ADAPTER_EVENTS.NOT_READY, notReadyListener);
193
- newWeb3Auth.on(ADAPTER_EVENTS.READY, readyListener);
194
- newWeb3Auth.on(ADAPTER_EVENTS.CONNECTED, connectedListener);
195
- newWeb3Auth.on(ADAPTER_EVENTS.DISCONNECTED, disconnectedListener);
196
- newWeb3Auth.on(ADAPTER_EVENTS.CONNECTING, connectingListener);
197
- newWeb3Auth.on(ADAPTER_EVENTS.ERRORED, errorListener);
169
+ newWeb3Auth.on(CONNECTOR_EVENTS.NOT_READY, notReadyListener);
170
+ newWeb3Auth.on(CONNECTOR_EVENTS.READY, readyListener);
171
+ newWeb3Auth.on(CONNECTOR_EVENTS.CONNECTED, connectedListener);
172
+ newWeb3Auth.on(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
173
+ newWeb3Auth.on(CONNECTOR_EVENTS.CONNECTING, connectingListener);
174
+ newWeb3Auth.on(CONNECTOR_EVENTS.ERRORED, errorListener);
198
175
  }
199
176
  }, {
200
177
  immediate: true
@@ -212,9 +189,6 @@ const Web3AuthProvider = defineComponent({
212
189
  enableMFA,
213
190
  manageMFA,
214
191
  logout,
215
- addAndSwitchChain,
216
- addChain,
217
- addPlugin,
218
192
  authenticateUser,
219
193
  switchChain,
220
194
  isInitializing,