@thru/wallet 0.2.22

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 (69) hide show
  1. package/README.md +67 -0
  2. package/android/build.gradle +37 -0
  3. package/android/src/main/AndroidManifest.xml +1 -0
  4. package/android/src/main/java/org/thru/walletnative/ThruWebViewBridgeModule.kt +77 -0
  5. package/app.plugin.cjs +101 -0
  6. package/dist/BrowserSDK-CpRFiJsW.d.ts +409 -0
  7. package/dist/index.d.ts +23 -0
  8. package/dist/index.js +941 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/native/react.d.ts +109 -0
  11. package/dist/native/react.js +2381 -0
  12. package/dist/native/react.js.map +1 -0
  13. package/dist/native.d.ts +329 -0
  14. package/dist/native.js +1126 -0
  15. package/dist/native.js.map +1 -0
  16. package/dist/react-ui.d.ts +5 -0
  17. package/dist/react-ui.js +266 -0
  18. package/dist/react-ui.js.map +1 -0
  19. package/dist/react.d.ts +66 -0
  20. package/dist/react.js +1151 -0
  21. package/dist/react.js.map +1 -0
  22. package/expo-module.config.json +6 -0
  23. package/package.json +114 -0
  24. package/src/BrowserSDK.ts +315 -0
  25. package/src/index.ts +27 -0
  26. package/src/interfaces/IThruChain.ts +37 -0
  27. package/src/interfaces/accounts.ts +61 -0
  28. package/src/interfaces/index.ts +9 -0
  29. package/src/interfaces/types.ts +95 -0
  30. package/src/native/NativeSDK.test.ts +819 -0
  31. package/src/native/NativeSDK.ts +773 -0
  32. package/src/native/index.ts +39 -0
  33. package/src/native/provider/NativeProvider.ts +363 -0
  34. package/src/native/provider/WebViewBridge.test.ts +339 -0
  35. package/src/native/provider/WebViewBridge.ts +339 -0
  36. package/src/native/provider/chains/ThruChain.ts +85 -0
  37. package/src/native/provider/shell.html +88 -0
  38. package/src/native/provider/shell.test.ts +56 -0
  39. package/src/native/provider/shell.ts +111 -0
  40. package/src/native/provider/shims-html.d.ts +4 -0
  41. package/src/native/react/ThruContext.ts +37 -0
  42. package/src/native/react/ThruProvider.tsx +168 -0
  43. package/src/native/react/ThruWalletSheet.tsx +1162 -0
  44. package/src/native/react/android-webauthn.ts +37 -0
  45. package/src/native/react/hooks/useAccounts.ts +35 -0
  46. package/src/native/react/hooks/useThru.ts +11 -0
  47. package/src/native/react/hooks/useWallet.ts +71 -0
  48. package/src/native/react/hooks/useWalletAvailability.ts +31 -0
  49. package/src/native/react/hooks/waitForWallet.ts +21 -0
  50. package/src/native/react/index.ts +29 -0
  51. package/src/protocol/index.ts +2 -0
  52. package/src/protocol/postMessage.ts +283 -0
  53. package/src/protocol/walletState.ts +12 -0
  54. package/src/provider/EmbeddedProvider.ts +330 -0
  55. package/src/provider/IframeManager.ts +438 -0
  56. package/src/provider/chains/ThruChain.ts +86 -0
  57. package/src/provider/index.ts +17 -0
  58. package/src/provider/types/messages.ts +37 -0
  59. package/src/react/ThruContext.ts +31 -0
  60. package/src/react/ThruProvider.tsx +169 -0
  61. package/src/react/hooks/useAccounts.ts +38 -0
  62. package/src/react/hooks/useThru.ts +11 -0
  63. package/src/react/hooks/useWallet.ts +81 -0
  64. package/src/react/index.ts +30 -0
  65. package/src/react-ui/ThruAccountSwitcher.tsx +187 -0
  66. package/src/react-ui/custom.d.ts +8 -0
  67. package/src/react-ui/index.ts +1 -0
  68. package/src/static/logo.png +0 -0
  69. package/src/static/logomark_red.svg +11 -0
@@ -0,0 +1,66 @@
1
+ import { B as BrowserSDK, a0 as WalletAccount, v as ManageAccountsResult, b as BrowserSDKConfig, s as IThruChain, d as ConnectOptions, g as ConnectResult } from './BrowserSDK-CpRFiJsW.js';
2
+ export { l as ErrorCode, S as SDKEvent, K as SignMessageParams, O as SignMessageResult, W as ThruSigningContext, X as ThruTransactionEncoding } from './BrowserSDK-CpRFiJsW.js';
3
+ import { Thru } from '@thru/sdk/client';
4
+ import * as react from 'react';
5
+ import { ReactNode } from 'react';
6
+
7
+ interface ThruContextValue {
8
+ wallet: BrowserSDK | null;
9
+ isConnected: boolean;
10
+ accounts: WalletAccount[];
11
+ isConnecting: boolean;
12
+ error: Error | null;
13
+ thru: Thru | null;
14
+ selectedAccount: WalletAccount | null;
15
+ selectAccount: (account: WalletAccount) => Promise<void>;
16
+ manageAccounts: () => Promise<ManageAccountsResult>;
17
+ }
18
+
19
+ interface ThruProviderProps {
20
+ children: ReactNode;
21
+ config: BrowserSDKConfig;
22
+ }
23
+ /**
24
+ * ThruProvider - React context provider for Thru Wallet SDK
25
+ * Wraps the BrowserSDK and exposes state via context
26
+ */
27
+ declare function ThruProvider({ children, config }: ThruProviderProps): react.JSX.Element;
28
+
29
+ interface UseAccountsResult {
30
+ accounts: WalletAccount[];
31
+ selectedAccount: WalletAccount | null;
32
+ isConnected: boolean;
33
+ isConnecting: boolean;
34
+ }
35
+ interface UseAccountsOptions {
36
+ onAccountSelect?: (account: WalletAccount) => void;
37
+ }
38
+ /**
39
+ * useAccounts - Exposes connected wallet accounts and selection helpers.
40
+ */
41
+ declare function useAccounts(options?: UseAccountsOptions): UseAccountsResult;
42
+
43
+ /**
44
+ * useThru - Access the Thru SDK context
45
+ * Must be used within a ThruProvider
46
+ */
47
+ declare function useThru(): ThruContextValue;
48
+
49
+ /**
50
+ * useThruChain - Hook for accessing the Thru chain API exposed by the Browser SDK.
51
+ * Returns the chain instance (if available) and a boolean indicating readiness.
52
+ */
53
+ declare function useWallet(): {
54
+ wallet: IThruChain | undefined;
55
+ accounts: WalletAccount[];
56
+ connect: (options?: ConnectOptions) => Promise<ConnectResult>;
57
+ disconnect: () => Promise<void>;
58
+ mountInline: (container: HTMLElement) => Promise<void>;
59
+ manageAccounts: () => Promise<ManageAccountsResult>;
60
+ isConnected: boolean;
61
+ isConnecting: boolean;
62
+ selectedAccount: WalletAccount | null;
63
+ selectAccount: (account: WalletAccount) => Promise<void>;
64
+ };
65
+
66
+ export { BrowserSDK, BrowserSDKConfig, ConnectOptions, ConnectResult, IThruChain, type ThruContextValue, ThruProvider, type ThruProviderProps, type UseAccountsOptions, type UseAccountsResult, WalletAccount, useAccounts, useThru, useWallet };