signer-test-sdk-react 0.0.14 → 0.0.16

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 (36) hide show
  1. package/dist/src/AbstraxnProvider.js +264 -2
  2. package/dist/src/AbstraxnProvider.js.map +1 -1
  3. package/dist/src/OnboardingUI.d.ts +1 -1
  4. package/dist/src/OnboardingUI.js +1 -1
  5. package/dist/src/components/OnboardingUI/OnboardingUI.css +227 -75
  6. package/dist/src/components/OnboardingUI/OnboardingUIReact.d.ts +3 -3
  7. package/dist/src/components/OnboardingUI/OnboardingUIReact.js +109 -55
  8. package/dist/src/components/OnboardingUI/OnboardingUIReact.js.map +1 -1
  9. package/dist/src/components/OnboardingUI/OnboardingUIWeb.d.ts +1 -2
  10. package/dist/src/components/OnboardingUI/OnboardingUIWeb.js +953 -861
  11. package/dist/src/components/OnboardingUI/OnboardingUIWeb.js.map +1 -1
  12. package/dist/src/components/OnboardingUI/components/EmailForm.d.ts +3 -3
  13. package/dist/src/components/OnboardingUI/components/EmailForm.js +13 -5
  14. package/dist/src/components/OnboardingUI/components/EmailForm.js.map +1 -1
  15. package/dist/src/components/OnboardingUI/components/Modal.d.ts +0 -1
  16. package/dist/src/components/OnboardingUI/components/Modal.js +4 -11
  17. package/dist/src/components/OnboardingUI/components/Modal.js.map +1 -1
  18. package/dist/src/components/OnboardingUI/components/OtpForm.d.ts +4 -3
  19. package/dist/src/components/OnboardingUI/components/OtpForm.js +19 -22
  20. package/dist/src/components/OnboardingUI/components/OtpForm.js.map +1 -1
  21. package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js +40 -0
  22. package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js.map +1 -1
  23. package/dist/src/components/OnboardingUI/hooks/useOnboarding.js +16 -0
  24. package/dist/src/components/OnboardingUI/hooks/useOnboarding.js.map +1 -1
  25. package/dist/src/connectors.d.ts +27 -0
  26. package/dist/src/connectors.js +70 -0
  27. package/dist/src/connectors.js.map +1 -0
  28. package/dist/src/hooks.d.ts +33 -0
  29. package/dist/src/hooks.js +62 -0
  30. package/dist/src/hooks.js.map +1 -1
  31. package/dist/src/index.d.ts +2 -1
  32. package/dist/src/index.js +2 -1
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/types.d.ts +12 -16
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +4 -2
@@ -97,6 +97,8 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
97
97
  const [isExternalWalletConnected, setIsExternalWalletConnected] = useState(false);
98
98
  const [externalWalletAddress, setExternalWalletAddress] = useState(null);
99
99
  const [externalWalletChainId, setExternalWalletChainId] = useState(null);
100
+ // Connection type tracking: 'google' | 'email' | 'discord' | 'x' | 'passkey' | 'metamask' | 'walletconnect' | 'coinbase' | 'phantom' | 'injected' | null
101
+ const [connectionType, setConnectionType] = useState(null);
100
102
  const explicitConnectionRef = useRef(false);
101
103
  const autoDisconnectHandledRef = useRef(false);
102
104
  // Track when we last connected to prevent premature reset
@@ -161,6 +163,37 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
161
163
  setIsConnected(true);
162
164
  setExternalWalletChainId(currentChainId);
163
165
  setChainId(currentChainId);
166
+ // Restore connection type from connector
167
+ const connector = wagmiAccount.connector;
168
+ if (connector) {
169
+ const connectorId = connector.id.toLowerCase();
170
+ const connectorName = connector.name?.toLowerCase() || '';
171
+ // Map connector to connection type
172
+ if (connectorId.includes('metamask') || connectorId.includes('io.metamask') || connectorName.includes('metamask')) {
173
+ setConnectionType('metamask');
174
+ }
175
+ else if (connectorId.includes('walletconnect') || connectorId.includes('wallet_connect') || connectorName.includes('walletconnect')) {
176
+ setConnectionType('walletconnect');
177
+ }
178
+ else {
179
+ // For other wallets (coinbase, phantom, injected), store as-is
180
+ // The hook will normalize them, but we keep the original for reference
181
+ const fallbackType = connectorName || connectorId;
182
+ setConnectionType(fallbackType);
183
+ }
184
+ }
185
+ else {
186
+ // Try to restore from localStorage as fallback
187
+ try {
188
+ const storedType = localStorage.getItem('abstraxn_connection_type');
189
+ if (storedType) {
190
+ setConnectionType(storedType);
191
+ }
192
+ }
193
+ catch (e) {
194
+ // Ignore localStorage errors
195
+ }
196
+ }
164
197
  // Update refs to track the restored connection
165
198
  lastAddressRef.current = walletAddress;
166
199
  lastChainIdRef.current = currentChainId;
@@ -291,6 +324,18 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
291
324
  }
292
325
  const cid = await walletInstance.getChainId();
293
326
  setChainId(cid);
327
+ // Always restore connection type from localStorage on connect
328
+ // This ensures connectionType is available after OAuth redirects (Google, X, Discord)
329
+ // and after page refreshes
330
+ try {
331
+ const storedType = localStorage.getItem('abstraxn_connection_type');
332
+ if (storedType && (storedType === 'google' || storedType === 'email' || storedType === 'discord' || storedType === 'x' || storedType === 'passkey')) {
333
+ setConnectionType(storedType);
334
+ }
335
+ }
336
+ catch (e) {
337
+ // Ignore localStorage errors
338
+ }
294
339
  }
295
340
  catch (err) {
296
341
  console.error('Error getting wallet info on connect:', err);
@@ -320,6 +365,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
320
365
  setUser(null);
321
366
  setWhoami(null);
322
367
  setChainId(null);
368
+ setConnectionType(null);
369
+ // Clear from localStorage
370
+ try {
371
+ localStorage.removeItem('abstraxn_connection_type');
372
+ }
373
+ catch (e) {
374
+ // Ignore localStorage errors
375
+ }
323
376
  });
324
377
  walletInstance.on('accountChanged', (newAddress) => {
325
378
  setAddress(newAddress);
@@ -336,10 +389,9 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
336
389
  logo: uiConfig.logo,
337
390
  theme: uiConfig.theme || 'light',
338
391
  showFooter: uiConfig.showFooter !== false,
339
- onboardTitle: uiConfig.onboardTitle || 'Sign in',
392
+ onboardTitle: uiConfig.onboardTitle || 'Sign In',
340
393
  modal: uiConfig.modal !== false,
341
394
  closeOnBackdropClick: uiConfig.closeOnBackdropClick !== false,
342
- showCloseButton: uiConfig.showCloseButton !== false,
343
395
  className: uiConfig.className,
344
396
  style: uiConfig.style,
345
397
  labels: uiConfig.labels,
@@ -351,6 +403,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
351
403
  if (!walletInstance)
352
404
  throw new Error('Wallet not initialized');
353
405
  const authManager = walletInstance.getAuthManager();
406
+ const connectionTypeValue = 'email';
407
+ setConnectionType(connectionTypeValue);
408
+ try {
409
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
410
+ }
411
+ catch (e) {
412
+ // Ignore localStorage errors
413
+ }
354
414
  const result = await authManager.loginWithOTP(email);
355
415
  otpIdRef.current = result.otpId;
356
416
  }
@@ -365,6 +425,15 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
365
425
  throw new Error('Wallet not initialized');
366
426
  if (!otpIdRef.current)
367
427
  throw new Error('OTP ID not found');
428
+ // Set connection type for email OTP before verification
429
+ const connectionTypeValue = 'email';
430
+ setConnectionType(connectionTypeValue);
431
+ try {
432
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
433
+ }
434
+ catch (e) {
435
+ // Ignore localStorage errors
436
+ }
368
437
  const authManager = walletInstance.getAuthManager();
369
438
  const user = await authManager.verifyOTP(otpIdRef.current, otp);
370
439
  otpIdRef.current = null;
@@ -384,24 +453,57 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
384
453
  onGoogleLogin: async () => {
385
454
  if (!walletInstance)
386
455
  throw new Error('Wallet not initialized');
456
+ const connectionTypeValue = 'google';
457
+ setConnectionType(connectionTypeValue);
458
+ // Store in localStorage for restoration
459
+ try {
460
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
461
+ }
462
+ catch (e) {
463
+ // Ignore localStorage errors
464
+ }
387
465
  const authManager = walletInstance.getAuthManager();
388
466
  await authManager.loginWithGoogle();
389
467
  },
390
468
  onTwitterLogin: async () => {
391
469
  if (!walletInstance)
392
470
  throw new Error('Wallet not initialized');
471
+ const connectionTypeValue = 'x';
472
+ setConnectionType(connectionTypeValue);
473
+ try {
474
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
475
+ }
476
+ catch (e) {
477
+ // Ignore localStorage errors
478
+ }
393
479
  const authManager = walletInstance.getAuthManager();
394
480
  await authManager.loginWithTwitter();
395
481
  },
396
482
  onDiscordLogin: async () => {
397
483
  if (!walletInstance)
398
484
  throw new Error('Wallet not initialized');
485
+ const connectionTypeValue = 'discord';
486
+ setConnectionType(connectionTypeValue);
487
+ try {
488
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
489
+ }
490
+ catch (e) {
491
+ // Ignore localStorage errors
492
+ }
399
493
  const authManager = walletInstance.getAuthManager();
400
494
  await authManager.loginWithDiscord();
401
495
  },
402
496
  onPasskeyLogin: async () => {
403
497
  if (!walletInstance)
404
498
  throw new Error('Wallet not initialized');
499
+ const connectionTypeValue = 'passkey';
500
+ setConnectionType(connectionTypeValue);
501
+ try {
502
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
503
+ }
504
+ catch (e) {
505
+ // Ignore localStorage errors
506
+ }
405
507
  const authManager = walletInstance.getAuthManager();
406
508
  const user = await authManager.loginWithPasskey();
407
509
  // Set user immediately so onLoginSuccess can access it
@@ -412,6 +514,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
412
514
  onPasskeySignup: async () => {
413
515
  if (!walletInstance)
414
516
  throw new Error('Wallet not initialized');
517
+ const connectionTypeValue = 'passkey';
518
+ setConnectionType(connectionTypeValue);
519
+ try {
520
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
521
+ }
522
+ catch (e) {
523
+ // Ignore localStorage errors
524
+ }
415
525
  const authManager = walletInstance.getAuthManager();
416
526
  const user = await authManager.signupWithPasskey();
417
527
  // Set user immediately so onLoginSuccess can access it
@@ -422,6 +532,17 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
422
532
  onLoginSuccess: async (data) => {
423
533
  // Clear any previous errors on successful login
424
534
  setError(null);
535
+ // Restore connection type from localStorage for OAuth logins (Google, X, Discord)
536
+ // This ensures connectionType is set after OAuth redirects
537
+ try {
538
+ const storedType = localStorage.getItem('abstraxn_connection_type');
539
+ if (storedType && (storedType === 'google' || storedType === 'x' || storedType === 'discord' || storedType === 'email' || storedType === 'passkey')) {
540
+ setConnectionType(storedType);
541
+ }
542
+ }
543
+ catch (e) {
544
+ // Ignore localStorage errors
545
+ }
425
546
  // Set user if provided in data
426
547
  if (data.user) {
427
548
  setUser(data.user);
@@ -968,6 +1089,16 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
968
1089
  setUser(userInfo);
969
1090
  setWhoami(whoamiInfo);
970
1091
  setIsConnected(true);
1092
+ // Restore connection type from localStorage
1093
+ try {
1094
+ const storedType = localStorage.getItem('abstraxn_connection_type');
1095
+ if (storedType && (storedType === 'google' || storedType === 'email' || storedType === 'discord' || storedType === 'x' || storedType === 'passkey')) {
1096
+ setConnectionType(storedType);
1097
+ }
1098
+ }
1099
+ catch (e) {
1100
+ // Ignore localStorage errors
1101
+ }
971
1102
  }
972
1103
  }
973
1104
  catch (err) {
@@ -996,6 +1127,16 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
996
1127
  }
997
1128
  const cid = await walletRef.current.getChainId();
998
1129
  setChainId(cid);
1130
+ // Restore connection type from localStorage
1131
+ try {
1132
+ const storedType = localStorage.getItem('abstraxn_connection_type');
1133
+ if (storedType && (storedType === 'google' || storedType === 'email' || storedType === 'discord' || storedType === 'x' || storedType === 'passkey')) {
1134
+ setConnectionType(storedType);
1135
+ }
1136
+ }
1137
+ catch (e) {
1138
+ // Ignore localStorage errors
1139
+ }
999
1140
  }
1000
1141
  catch (restoreErr) {
1001
1142
  console.error('Error restoring connection state:', restoreErr);
@@ -1065,6 +1206,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1065
1206
  setIsExternalWalletConnected(false);
1066
1207
  setExternalWalletAddress(null);
1067
1208
  setExternalWalletChainId(null);
1209
+ setConnectionType(null);
1210
+ // Clear from localStorage
1211
+ try {
1212
+ localStorage.removeItem('abstraxn_connection_type');
1213
+ }
1214
+ catch (e) {
1215
+ // Ignore localStorage errors
1216
+ }
1068
1217
  explicitConnectionRef.current = false;
1069
1218
  lastConnectionTimeRef.current = 0;
1070
1219
  // Always reset main isConnected when disconnecting external wallet
@@ -1088,6 +1237,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1088
1237
  setIsConnected(false);
1089
1238
  setAddress(null);
1090
1239
  setChainId(null);
1240
+ setConnectionType(null);
1241
+ // Clear from localStorage
1242
+ try {
1243
+ localStorage.removeItem('abstraxn_connection_type');
1244
+ }
1245
+ catch (e) {
1246
+ // Ignore localStorage errors
1247
+ }
1091
1248
  // console.log('✅ Abstraxn wallet disconnected, main state reset');
1092
1249
  }
1093
1250
  catch (err) {
@@ -1096,6 +1253,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1096
1253
  setIsConnected(false);
1097
1254
  setAddress(null);
1098
1255
  setChainId(null);
1256
+ setConnectionType(null);
1257
+ // Clear from localStorage
1258
+ try {
1259
+ localStorage.removeItem('abstraxn_connection_type');
1260
+ }
1261
+ catch (e) {
1262
+ // Ignore localStorage errors
1263
+ }
1099
1264
  }
1100
1265
  }
1101
1266
  // Final check: if neither wallet is connected, ensure main state is reset
@@ -1106,6 +1271,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1106
1271
  setIsConnected(false);
1107
1272
  setAddress(null);
1108
1273
  setChainId(null);
1274
+ setConnectionType(null);
1275
+ // Clear from localStorage
1276
+ try {
1277
+ localStorage.removeItem('abstraxn_connection_type');
1278
+ }
1279
+ catch (e) {
1280
+ // Ignore localStorage errors
1281
+ }
1109
1282
  // console.log('✅ Final check: All wallets disconnected, main state reset');
1110
1283
  }
1111
1284
  // Reset OTP screen and show initial login form
@@ -1345,6 +1518,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1345
1518
  setLoading(true);
1346
1519
  setError(null);
1347
1520
  try {
1521
+ const connectionTypeValue = 'email';
1522
+ setConnectionType(connectionTypeValue);
1523
+ try {
1524
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
1525
+ }
1526
+ catch (e) {
1527
+ // Ignore localStorage errors
1528
+ }
1348
1529
  const result = await walletRef.current.loginWithOTP(email);
1349
1530
  return result;
1350
1531
  }
@@ -1364,9 +1545,26 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1364
1545
  setLoading(true);
1365
1546
  setError(null);
1366
1547
  try {
1548
+ // Set connection type for email OTP before verification
1549
+ const connectionTypeValue = 'email';
1550
+ setConnectionType(connectionTypeValue);
1551
+ try {
1552
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
1553
+ }
1554
+ catch (e) {
1555
+ // Ignore localStorage errors
1556
+ }
1367
1557
  const user = await walletRef.current.verifyOTP(otpId, otpCode);
1368
1558
  setIsConnected(true);
1369
1559
  setUser(user);
1560
+ // Ensure connection type is set (in case connect event didn't restore it)
1561
+ setConnectionType('email');
1562
+ try {
1563
+ localStorage.setItem('abstraxn_connection_type', 'email');
1564
+ }
1565
+ catch (e) {
1566
+ // Ignore localStorage errors
1567
+ }
1370
1568
  // Load whoami and address after verification
1371
1569
  try {
1372
1570
  const whoamiInfo = await walletRef.current.getWhoami();
@@ -1396,6 +1594,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1396
1594
  setLoading(true);
1397
1595
  setError(null);
1398
1596
  try {
1597
+ const connectionTypeValue = 'google';
1598
+ setConnectionType(connectionTypeValue);
1599
+ try {
1600
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
1601
+ }
1602
+ catch (e) {
1603
+ // Ignore localStorage errors
1604
+ }
1399
1605
  await walletRef.current.loginWithGoogle();
1400
1606
  // Note: This will redirect, so loading state will be reset on callback
1401
1607
  }
@@ -1418,6 +1624,16 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1418
1624
  const user = await walletRef.current.handleGoogleCallback();
1419
1625
  if (user) {
1420
1626
  setUser(user);
1627
+ // Restore connection type for Google OAuth
1628
+ try {
1629
+ const storedType = localStorage.getItem('abstraxn_connection_type');
1630
+ if (storedType === 'google') {
1631
+ setConnectionType('google');
1632
+ }
1633
+ }
1634
+ catch (e) {
1635
+ // Ignore localStorage errors
1636
+ }
1421
1637
  // handleGoogleCallback() already calls whoami and emits 'connect' event
1422
1638
  // The 'connect' event handler will update whoami, address, and chainId
1423
1639
  // So we don't need to do it here to avoid duplicate whoami calls
@@ -1739,6 +1955,41 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1739
1955
  setIsExternalWalletConnected(true); // This marks it as an external wallet connection
1740
1956
  setAddress(formattedAddress);
1741
1957
  setIsConnected(true);
1958
+ // Track connection type based on connector
1959
+ const connector = wagmiAccount.connector;
1960
+ if (connector) {
1961
+ const connectorId = connector.id.toLowerCase();
1962
+ const connectorName = connector.name?.toLowerCase() || '';
1963
+ let connectionTypeValue;
1964
+ // Map connector to connection type
1965
+ if (connectorId.includes('metamask') || connectorId.includes('io.metamask') || connectorName.includes('metamask')) {
1966
+ connectionTypeValue = 'metamask';
1967
+ }
1968
+ else if (connectorId.includes('walletconnect') || connectorId.includes('wallet_connect') || connectorName.includes('walletconnect')) {
1969
+ connectionTypeValue = 'walletconnect';
1970
+ }
1971
+ else if (connectorId.includes('coinbase') || connectorId.includes('com.coinbase') || connectorName.includes('coinbase')) {
1972
+ connectionTypeValue = 'coinbase';
1973
+ }
1974
+ else if (connectorId.includes('phantom') || connectorId.includes('app.phantom') || connectorName.includes('phantom')) {
1975
+ connectionTypeValue = 'phantom';
1976
+ }
1977
+ else if (connectorId.includes('injected')) {
1978
+ connectionTypeValue = 'injected';
1979
+ }
1980
+ else {
1981
+ // Use connector name or ID as fallback
1982
+ connectionTypeValue = connectorName || connectorId;
1983
+ }
1984
+ setConnectionType(connectionTypeValue);
1985
+ // Store in localStorage for restoration on refresh
1986
+ try {
1987
+ localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
1988
+ }
1989
+ catch (e) {
1990
+ // Ignore localStorage errors
1991
+ }
1992
+ }
1742
1993
  if (currentChainId) {
1743
1994
  setChainId(currentChainId);
1744
1995
  setExternalWalletChainId(currentChainId);
@@ -1795,6 +2046,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1795
2046
  setIsExternalWalletConnected(false);
1796
2047
  setExternalWalletAddress(null);
1797
2048
  setExternalWalletChainId(null);
2049
+ setConnectionType(null);
2050
+ // Clear from localStorage
2051
+ try {
2052
+ localStorage.removeItem('abstraxn_connection_type');
2053
+ }
2054
+ catch (e) {
2055
+ // Ignore localStorage errors
2056
+ }
1798
2057
  explicitConnectionRef.current = false;
1799
2058
  lastConnectionTimeRef.current = 0;
1800
2059
  // CRITICAL: Reset refs so reconnect is detected as a new connection
@@ -1806,6 +2065,7 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
1806
2065
  setIsConnected(false);
1807
2066
  setAddress(null);
1808
2067
  setChainId(null);
2068
+ setConnectionType(null);
1809
2069
  }
1810
2070
  catch (err) {
1811
2071
  const error = err instanceof Error ? err : new Error('Failed to disconnect external wallet');
@@ -2109,6 +2369,8 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
2109
2369
  availableChains,
2110
2370
  // Balance (for Abstraxn wallet)
2111
2371
  walletBalance: !isExternalWalletConnected ? walletBalance : undefined,
2372
+ // Connection type
2373
+ connectionType,
2112
2374
  };
2113
2375
  // Ref to store latest value to avoid dependency issues (defined after value)
2114
2376
  const valueRef = useRef(value);