@human.tech/waap-sdk 2.0.0 → 2.1.0-staging-fb27bb

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 (59) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +167 -216
  3. package/dist/WaaPError-C5nPcaKk.d.mts +168 -0
  4. package/dist/WaaPError-XLgIXUgh.d.ts +168 -0
  5. package/dist/WalletConnect-BTT6LtUu.d.mts +33 -0
  6. package/dist/WalletConnect-BTT6LtUu.d.ts +33 -0
  7. package/dist/WalletConnect-Deg7_JmH.mjs +4 -0
  8. package/dist/WalletConnect-G-lbqknM.js +4 -0
  9. package/dist/asyncSigning-B0KrmKk7.js +1 -0
  10. package/dist/asyncSigning-CzqBbYDP.mjs +1 -0
  11. package/dist/esm-B4jz8Emb.mjs +1 -0
  12. package/dist/esm-D5fDQenf.js +1 -0
  13. package/dist/evm-Ch-aWWat.js +1 -0
  14. package/dist/evm-DHVrAmEw.mjs +1 -0
  15. package/dist/evm.d.mts +7 -0
  16. package/dist/evm.d.ts +7 -0
  17. package/dist/evm.js +1 -0
  18. package/dist/evm.mjs +1 -0
  19. package/dist/index-CMSufeMa.d.ts +775 -0
  20. package/dist/index-CdKntlzX.d.mts +775 -0
  21. package/dist/index.d.mts +239 -933
  22. package/dist/index.d.ts +239 -933
  23. package/dist/index.js +1 -2191
  24. package/dist/index.mjs +1 -2162
  25. package/dist/initializerContext-0oKHzvQG.d.ts +21 -0
  26. package/dist/initializerContext-C39PUnGi.d.mts +21 -0
  27. package/dist/react.d.mts +2 -0
  28. package/dist/react.d.ts +2 -0
  29. package/dist/react.js +1 -0
  30. package/dist/react.mjs +1 -0
  31. package/dist/register-4Afr2Jx8.js +1 -0
  32. package/dist/register-CBlzg5ln.d.ts +107 -0
  33. package/dist/register-CNgjA0yl.mjs +1 -0
  34. package/dist/register-CxsUwgKJ.d.ts +282 -0
  35. package/dist/register-DIZnKDHF.mjs +1 -0
  36. package/dist/register-LmdJdvzn.d.mts +282 -0
  37. package/dist/register-QjrsOe7r.d.mts +107 -0
  38. package/dist/register-ozKwGWOb.js +1 -0
  39. package/dist/solana.d.mts +5 -0
  40. package/dist/solana.d.ts +5 -0
  41. package/dist/solana.js +1 -0
  42. package/dist/solana.mjs +1 -0
  43. package/dist/sui.d.mts +5 -0
  44. package/dist/sui.d.ts +5 -0
  45. package/dist/sui.js +1 -0
  46. package/dist/sui.mjs +1 -0
  47. package/dist/types-DexmJNke.d.mts +397 -0
  48. package/dist/types-DexmJNke.d.ts +397 -0
  49. package/dist/ui-16QpbEyG.js +1 -0
  50. package/dist/ui-BAYRtDQg.mjs +1 -0
  51. package/dist/useWaapAuth-BrqAhAn2.d.ts +246 -0
  52. package/dist/useWaapAuth-C5I7QqyW.d.mts +246 -0
  53. package/dist/useWaapAuth-DHIeb4yc.mjs +1 -0
  54. package/dist/useWaapAuth-Z_ONicYr.js +1 -0
  55. package/dist/walletconnect.d.mts +2 -0
  56. package/dist/walletconnect.d.ts +2 -0
  57. package/dist/walletconnect.js +1 -0
  58. package/dist/walletconnect.mjs +1 -0
  59. package/package.json +53 -18
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @human.tech/waap-sdk
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add multichain initializers (`initWaaPMulti`, `initWaaPSquid`), subpath entry
8
+ points (`/evm`, `/sui`, `/solana`, `/react`, `/walletconnect`), Solana Wallet
9
+ Standard support, `WaaPError`, and explicit wallet-environment selection.
10
+
11
+ Restores the published `asyncTxs` contract: `eth_sendTransaction` resolves with
12
+ the deterministic signed transaction hash, and every lifecycle event is keyed by
13
+ that same hash. The deprecated `asyncSigning` wire mode keeps returning
14
+ `{ pendingTxId, status: 'pending' }`.
15
+
16
+ `@human.tech/waap-interface-core` and `@human.tech/waap-constants` are runtime
17
+ dependencies of the SDK rather than bundled, so they must be published together
18
+ with it.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @human.tech/waap-interface-core@1.1.0
24
+ - @human.tech/waap-constants@1.1.0
25
+
3
26
  ## 2.0.0
4
27
 
5
28
  ### Major Changes
package/README.md CHANGED
@@ -1,257 +1,208 @@
1
1
  # WaaP SDK
2
2
 
3
- [npm link](https://www.npmjs.com/package/@human.tech/waap-sdk)
3
+ `@human.tech/waap-sdk` is a browser bridge to the WaaP wallet iframe. It does
4
+ not contain keys, policy-engine clients, transaction preparation, or signing
5
+ material. The wallet reviews, gates, signs, and broadcasts requests.
4
6
 
5
- ## Installation
7
+ ## Install
6
8
 
7
9
  ```bash
8
- npm install @human.tech/waap-sdk
9
- # or
10
- yarn add @human.tech/waap-sdk
11
- # or
12
10
  pnpm add @human.tech/waap-sdk
13
11
  ```
14
12
 
15
- ## Usage
13
+ ## EVM
16
14
 
17
- ### Basic Integration (Default Modal Mode)
18
-
19
- By default, the wallet renders as a centered modal with a backdrop overlay:
20
-
21
- ```javascript
15
+ ```ts
22
16
  import { initWaaP } from '@human.tech/waap-sdk'
23
17
 
24
- // Initialize Human Wallet. This will set window.waap with all necessary methods
25
- initWaaP()
26
-
27
- // Request accounts (prompts user to connect)
28
- const accounts = await window.waap.request({ method: 'eth_requestAccounts' })
29
- console.log('Connected accounts:', accounts)
30
-
31
- // Send a transaction
32
- const txHash = await window.waap.request({
33
- method: 'eth_sendTransaction',
34
- params: [
35
- {
36
- from: accounts[0],
37
- to: '0xRecipientAddress',
38
- value: '0x123' // hex value in wei
39
- }
40
- ]
18
+ const wallet = initWaaP({ environment: 'production' }) // `chains` defaults to ['evm']
19
+ const [address] = (await wallet.request({
20
+ method: 'eth_requestAccounts'
21
+ })) as string[]
22
+ const signature = await wallet.request({
23
+ method: 'personal_sign',
24
+ params: ['0x68656c6c6f', address]
41
25
  })
42
- ```
43
26
 
44
- ### Basic Integration
27
+ // Always release the public facade when the owning UI unmounts.
28
+ wallet.destroy()
29
+ ```
45
30
 
46
- ```javascript
47
- import { initWaap } from '@human.tech/waap-sdk'
31
+ For a local wallet iframe use `{ environment: 'development' }`; for a preview
32
+ host use `{ walletOrigin: 'https://wallet-preview.example' }`. An origin must
33
+ be HTTPS, except loopback development hosts. `useStaging` remains an alias for
34
+ `environment: 'staging'`.
48
35
 
49
- // Initialize Human Wallet. This will set window.silk with all necessary methods
50
- initWaap()
36
+ ## Sui
51
37
 
52
- // Request accounts (prompts user to connect)
53
- const accounts = await window.waap.request({ method: 'eth_requestAccounts' })
54
- console.log('Connected accounts:', accounts)
38
+ ```ts
39
+ import { initWaaP } from '@human.tech/waap-sdk'
55
40
 
56
- // Send a transaction
57
- const txHash = await window.waap.request({
58
- method: 'eth_sendTransaction',
59
- params: [
60
- {
61
- from: accounts[0],
62
- to: '0xRecipientAddress',
63
- value: '0x123' // hex value in wei
64
- }
65
- ]
41
+ const { sui: wallet } = initWaaP({
42
+ environment: 'production',
43
+ chains: ['sui']
66
44
  })
67
- ```
68
-
69
- ### Configuration Options
70
-
71
- `initWaaP` accepts the following configuration options:
72
-
73
- ````javascript
74
- // WaaP (recommended)
75
- initWaaP({
76
- // Optional: Your WalletConnect project ID (REQUIRED for WalletConnect functionality)
77
- walletConnectProjectId: 'YOUR_WALLETCONNECT_PROJECT_ID',
78
-
79
- // Optional: Human Wallet points referral code
80
- referralCode: 'YOUR_REFERRAL_CODE',
81
-
82
- // Optional: Custom UI configuration
83
- config: {
84
- // See documentation or the Developer Portal for more style options
85
- authenticationMethods: [],
86
- allowedSocials: [],
87
- styles: {
88
- darkMode: true
89
- },
90
- showSecured: true // Controls the display of 'Secured by human.tech' at the footer
91
- },
92
-
93
- // Optional: Project configuration
94
- project: {
95
- name: 'Your App Name', // Project name used throughout the SDK
96
- entryTitle: 'Log in to Your App', // Optional: Custom title (defaults to "Sign In")
97
- logo: 'Your app logo in base64 (see docs or portal)',
98
- authSuccessUrl: '' // The URL to redirect to after a successfull oauth login
99
- termsOfServiceUrl: '' // Terms of Service URL (will display at the footer)
100
- privacyPolicyUrl: '' // Privacy Policy URL (will display at the footer)
101
- projectId: '' // See documentation or the Developer Portal to learn how to set up a gastank for your users
102
- },
103
-
104
- // Optional: If you want to accept external wallets (by passing 'wallet' to the authenticationMethods array)
105
- walletConnectProjectId: ''
45
+ const { accounts } = await wallet.connect()
46
+ const signed = await wallet.signPersonalMessage({
47
+ account: accounts[0],
48
+ message: new TextEncoder().encode('hello')
106
49
  })
50
+ wallet.destroy()
51
+ ```
107
52
 
53
+ ## Solana
108
54
 
109
- ### WalletConnect Support
110
-
111
- To use WalletConnect functionality, you **must** provide a WalletConnect project ID. This ID can be obtained from [WalletConnect Cloud](https://cloud.walletconnect.com/).
112
-
113
- You can provide the project ID in several ways (in order of precedence):
114
-
115
- 1. **Pass it directly when initializing** (recommended):
116
-
117
- ```javascript
118
- // WaaP
119
- initWaaP({
120
- walletConnectProjectId: 'YOUR_WALLETCONNECT_PROJECT_ID'
121
- })
122
- ````
123
-
124
- 2. **Set it programmatically**:
125
-
126
- ```javascript
127
- // WaaP
128
- import { initWaaP, WaaPWalletConnect } from '@silk-wallet/silk-wallet-sdk'
129
-
130
- WaaPWalletConnect.setProjectId('YOUR_WALLETCONNECT_PROJECT_ID')
131
- initWaaP()
132
- ```
133
-
134
- 3. **Set it as an environment variable**:
135
- - Set `NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID` in your .env.local file (Next.js)
136
- - Or set `WALLET_CONNECT_PROJECT_ID` for other environments
137
-
138
- ### API Reference
139
-
140
- The SDK implements the standard Ethereum Provider API (EIP-1193) with some additional methods. `window.waap` provides the following interface:
141
-
142
- - `enable()`: Alias for `request({ method: 'eth_requestAccounts' })`
143
- - `isConnected()`: Returns whether the provider is connected
144
- - `login()`: Prompt the user to connect an external wallet
145
- - `logout()`: Disconnect the current session
146
- - `getLoginMethod()`: Returns the current login method ('waap', 'injected', 'walletconnect', or null)
147
- - `requestEmail()`: Request the user's email address
148
- - `requestSBT(type)`: Request a Soulbound Token of the specified type
149
- - `toggleDarkMode()`: Toggle between light and dark mode
150
-
151
- ### Auto-Connect Functionality
152
-
153
- The SDK automatically attempts to reconnect users when they refresh the page or return to your application. This works seamlessly in the background when you call `eth_requestAccounts`.
154
-
155
- #### How Auto-Connect Works
156
-
157
- 1. When a user successfully logs in via `login()`, their choice is remembered
158
- 2. On subsequent page loads, calling `eth_requestAccounts` (before `login()`) will automatically attempt to reconnect using their previous method
159
- 3. If the previous method is no longer available or connected, the auto-connect will fail gracefully
160
-
161
- #### Checking the Current Login Method
162
-
163
- You can check which login method is currently active without triggering a connection:
164
-
165
- ```javascript
166
- // WaaP
167
- const loginMethod = window.waap.getLoginMethod()
55
+ ```ts
56
+ import { initWaaP } from '@human.tech/waap-sdk'
168
57
 
169
- if (loginMethod === 'waap') {
170
- console.log('User is connected via WaaP')
171
- } else if (loginMethod === 'injected') {
172
- console.log('User is connected via injected wallet (e.g., MetaMask)')
173
- } else if (loginMethod === 'walletconnect') {
174
- console.log('User is connected via WalletConnect')
175
- } else {
176
- console.log('User is not connected')
177
- }
58
+ const { solana: wallet } = initWaaP({
59
+ environment: 'production',
60
+ chains: ['solana']
61
+ })
62
+ const { accounts } = await wallet.connect()
63
+ const signed = await wallet.signMessage({
64
+ account: accounts[0],
65
+ message: new TextEncoder().encode('hello')
66
+ })
67
+ wallet.destroy()
178
68
  ```
179
69
 
180
- **Note**: `getLoginMethod()` verifies that the connection is actually still valid. If the wallet extension is disabled, WalletConnect session expired, or any other connection issue exists, it will return `null` and automatically clean up the stored state.
181
-
182
- #### Implementing Auto-Connect
70
+ `features` implements `standard:connect`, `standard:disconnect`,
71
+ `standard:events`, `solana:signMessage`, `solana:signTransaction`, and
72
+ `solana:signAndSendTransaction`. The direct `signTransaction`,
73
+ and `signAndSendTransaction` helpers remain available for wallet-adapter-style
74
+ consumers. They accept
75
+ serialized bytes (or a serializable transaction object). Dapp-built Solana
76
+ transactions retain their exact bytes; obtain a fresh blockhash near approval
77
+ to avoid expiry.
183
78
 
184
- ```javascript
185
- // WaaP
186
- import { initWaaP } from '@silk-wallet/silk-wallet-sdk'
79
+ `signAllTransactions` is temporarily unsupported while WaaP completes a
80
+ batch-specific review and lifecycle controller. Submit transactions through
81
+ `signTransaction` individually until that capability is restored.
187
82
 
188
- initWaaP()
83
+ ## Squid multichain
189
84
 
190
- try {
191
- const accounts = await window.waap.request({
192
- method: 'eth_requestAccounts'
193
- })
194
- console.log('Auto-connected with accounts:', accounts)
85
+ ```ts
86
+ import { initWaaPSquid, useWaapAuth, WAAP_EVENTS } from '@human.tech/waap-sdk'
195
87
 
196
- if (accounts.length === 0) {
197
- await window.waap.login()
198
- }
199
- } catch (error) {
200
- console.log('Auto-connect failed, user needs to login again')
201
- }
88
+ const waap = initWaaPSquid({ environment: 'production' })
89
+ await waap.ethereum.login()
90
+ waap.auth.on(WAAP_EVENTS.squidReady, ({ evm, sui, solana }) => {
91
+ console.log(evm, sui, solana)
92
+ })
93
+ // In React: const auth = useWaapAuth(waap.auth); auth.squidReady
94
+ waap.destroy()
202
95
  ```
203
96
 
204
- #### Logout and Cleanup
97
+ `login()` is safe to call on startup: it first checks the existing WaaP iframe
98
+ session without showing wallet UI. The login screen opens only when there is
99
+ no valid session.
205
100
 
206
- When you call `logout()`, the stored login method is automatically cleared:
101
+ ## Advanced integration
207
102
 
208
- ```javascript
209
- // WaaP
210
- await window.waap.logout()
211
- console.log(window.waap.getLoginMethod()) // Returns null
212
- ```
103
+ ### SDK session protection
213
104
 
214
- ## Error Handling
105
+ The wallet iframe uses DPoP by default. It keeps the Better Auth bearer and
106
+ non-extractable proof key inside the wallet-origin iframe, scoped to the
107
+ observed host origin. Use the explicit bearer fallback only where browser
108
+ WebCrypto or IndexedDB cannot support DPoP:
215
109
 
216
- ```javascript
217
- // WaaP
218
- try {
219
- const accounts = await window.waap.request({ method: 'eth_requestAccounts' })
220
- } catch (error) {
221
- console.error('Error connecting:', error)
222
- }
110
+ ```ts
111
+ const waap = initWaaP({ sessionProtection: 'bearer' })
223
112
  ```
224
113
 
225
- ## Events
226
-
227
- Both providers emit the same events you can listen to:
228
-
229
- ```javascript
230
- // WaaP
231
- window.waap.on('connect', () => {
232
- console.log('Connected')
114
+ The host dapp never receives either credential. `legacy` is not a supported
115
+ session-protection mode.
116
+
117
+ Permission-token requests are available on EVM, Sui, and Solana facades.
118
+ Request a token first, then opt into its use through `withPT: true` on a
119
+ transaction call. This applies consistently to TAP and Squid transaction,
120
+ sign-and-send, and sign-only transaction methods. The wallet resolves only a
121
+ stored token matching the requesting origin, chain, wallet mode, and selected
122
+ signer; otherwise the transaction follows the ordinary approval / 2FA flow.
123
+ `withPT` never applies to personal-message or typed-data signing, and it is
124
+ not a browser-side authorization bypass.
125
+
126
+ For EVM background transaction status, use `useWaapTransaction(provider,
127
+ callbacks)`. The old one-argument hook form remains supported, but depends on
128
+ the global provider and is unsuitable for multiple wallets.
129
+
130
+ Runtime event names are exported as `WAAP_EVENTS`: `waap_squid_pending`,
131
+ `waap_squid_ready`, and `waap_squid_failed`. `squidReady` is the React-hook
132
+ readiness field.
133
+
134
+ ## Completion and lifecycle
135
+
136
+ The SDK bridge does not make every chain method mean the same thing:
137
+
138
+ - EVM message and sign-only methods resolve with a signature. With `asyncTxs`,
139
+ `eth_sendTransaction` resolves with a transaction hash and later lifecycle
140
+ events report pending/confirmed/failed status.
141
+ - Sui `signTransaction` returns signed bytes. `signAndExecuteTransaction`
142
+ returns a submitted digest; applications that require finality must query the
143
+ chain independently.
144
+ - Solana `signTransaction` returns signed bytes and `signAndSendTransaction`
145
+ returns the cluster signature. A caller-built transaction retains its exact
146
+ blockhash and can expire during a human approval.
147
+
148
+ Own and destroy the initializer at the same lifetime as the embedding UI. For
149
+ advanced layout control, `initWaaP({ deferIframe: true })` delays iframe mount
150
+ until the first request; adding `<waap-wallet>` before initialization uses
151
+ component rather than modal presentation.
152
+
153
+ ### Startup performance
154
+
155
+ The public iframe URL and `postMessage` protocol are stable: an already
156
+ released SDK continues to use `/iframe` without any host-app change. Current
157
+ SDK versions wait for the iframe's real navigation before posting their ready
158
+ ping, then use a bounded retry handshake. This avoids posting to the transient
159
+ `about:blank` document, which can otherwise produce target-origin warnings.
160
+
161
+ Initialize a facade once for the lifetime of the embedding UI; do not create
162
+ and destroy it for each Connect or Sign click. For a page where wallet
163
+ interaction is not above the fold, defer mounting and warm it after the host
164
+ page's LCP. `preload()` mounts the iframe and completes its non-interactive
165
+ setup; it never opens wallet UI or creates a Squid account.
166
+
167
+ ```ts
168
+ import { initWaaP, preloadWaaPOnIdle } from '@human.tech/waap-sdk'
169
+
170
+ // Omitted chains retain the original EVM EIP-1193 provider behavior.
171
+ const ethereum = initWaaP({ deferIframe: true })
172
+
173
+ // Select one or more native Wallet Standard facades through the same TAP API.
174
+ const { sui: suiWallet } = initWaaP({ chains: ['sui'] })
175
+ const { solana: solanaWallet } = initWaaP({ chains: ['solana'] })
176
+
177
+ // Call after LCP / from a post-LCP effect. The returned fn cancels warmup when
178
+ // the owning route unmounts.
179
+ const cancelPreload = preloadWaaPOnIdle(ethereum)
180
+
181
+ // Upgrade likely user intent to an immediate warmup. `preload()` is shared and
182
+ // idempotent, so this is safe if the idle callback is already pending.
183
+ connectButton.addEventListener('pointerenter', () => void ethereum.preload(), {
184
+ once: true
233
185
  })
234
-
235
- window.waap.on('accountsChanged', (accounts) => {
236
- console.log('Active account changed:', accounts[0])
237
- })
238
-
239
- window.waap.on('chainChanged', (chainId) => {
240
- console.log('Chain changed to:', chainId)
186
+ connectButton.addEventListener('focus', () => void ethereum.preload(), {
187
+ once: true
241
188
  })
242
- ```
243
-
244
- ## TypeScript Support
245
-
246
- The SDK includes TypeScript definitions. You can import them like this:
247
189
 
248
- ```typescript
249
- // WaaP
250
- import { initWaaP, WaaPProvider } from '@silk-wallet/silk-wallet-sdk'
251
-
252
- const waap: WaaPProvider = initWaaP()
190
+ // UI teardown:
191
+ cancelPreload()
192
+ ethereum.destroy()
253
193
  ```
254
194
 
255
- ## Support
256
-
257
- If you encounter any issues or have questions, please reach out to our support team or file an issue in our GitHub repository.
195
+ The EVM, Sui, Solana, and Squid facades expose the same `preload()` method.
196
+ Squid coalesces their shared setup into one iframe request. For troubleshooting
197
+ an embed, `getWaaPIframeDiagnostics()` reports navigation, visual render, and
198
+ modal timings without exposing request payloads. `subscribeWaaPIframeLifecycle`
199
+ can feed partner telemetry with `modal_requested`, `modal_visible`, and
200
+ `modal_hidden` events. The EVM provider's
201
+ `walletMessageManager.getHandshakeDiagnostics()` additionally reports ready-ping
202
+ retries and the last readiness error.
203
+
204
+ The SDK intentionally does not expose CLI-only account conversion, portable
205
+ signed-artifact/broadcast workflows, raw-digest signing, policy administration,
206
+ or headless automation. See
207
+ [the capability matrix](../../wiki/architecture/client-capabilities.md) for the supported
208
+ surface and test tiers.
@@ -0,0 +1,168 @@
1
+ import { A as SILK_METHOD, E as SilkResponse, T as SilkRequestCancellation, j as SilkNotificationData, w as SilkRequest } from "./types-DexmJNke.mjs";
2
+ //#region src/lib/WalletMessageManager.d.ts
3
+ type PostSilkRequestArgs = {
4
+ method: keyof typeof SILK_METHOD;
5
+ params: any[];
6
+ interactionRequired: boolean;
7
+ silkOptions?: {
8
+ async?: boolean;
9
+ };
10
+ };
11
+ /**
12
+ * Async transaction notification from iframe
13
+ */
14
+ interface AsyncTxNotification {
15
+ type: string;
16
+ payload: any;
17
+ }
18
+ /**
19
+ * Squid lifecycle notification from iframe
20
+ */
21
+ interface SquidLifecycleNotification {
22
+ type: string;
23
+ payload: any;
24
+ }
25
+ /**
26
+ * Listener interface for WalletMessageManager
27
+ */
28
+ interface MessageListenerConfig {
29
+ handleResponse: (response: SilkResponse) => void;
30
+ handleRequest: (request: SilkRequest) => void;
31
+ onReceiveConnectNotif?: () => void;
32
+ onAccountChanged?: (newAccount: string) => void;
33
+ onAsyncTxNotification?: (notification: AsyncTxNotification) => void;
34
+ onSquidLifecycleNotification?: (notification: SquidLifecycleNotification) => void;
35
+ }
36
+ type WalletHandshakeDiagnostics = {
37
+ walletOrigin: string;
38
+ iframeNavigationStartedAt: number | null;
39
+ iframeLoadedAt: number | null;
40
+ readyPingStartedAt: number | null;
41
+ readyAt: number | null;
42
+ readyAttempts: number;
43
+ visualReadySupported: boolean | null;
44
+ navigationGeneration: number | null;
45
+ lastError: string | null;
46
+ };
47
+ declare class WalletMessageManager {
48
+ private iframeWindow;
49
+ private unregisterListeners;
50
+ private readonly terminalResponseDeduper;
51
+ private unsubscribeIframeNavigation;
52
+ private disposed;
53
+ /** Public so the shared window-listener dispatcher can origin-filter per manager. */
54
+ readonly walletOrigin: string;
55
+ constructor(iframeWindow: Window | null, walletOrigin?: string | boolean);
56
+ private observeIframeNavigation;
57
+ /**
58
+ * Rebind the target iframe window. Used by `deferIframe` mode, where the
59
+ * iframe is created on first use rather than at init, so the manager starts
60
+ * with a null window and is pointed at the real one once it exists.
61
+ */
62
+ setIframeWindow(iframeWindow: Window): void;
63
+ getIframeWindow(): Window | null;
64
+ isDisposed(): boolean;
65
+ shouldHandleTerminalResponse(id: string): boolean;
66
+ getHandshakeDiagnostics(): WalletHandshakeDiagnostics;
67
+ /**
68
+ * Post a Silk notification to the given iframeWindow
69
+ */
70
+ postSilkNotification(data: SilkNotificationData | SilkRequestCancellation): void;
71
+ postReadyNotification(): void;
72
+ postConnectNotification(): void;
73
+ /** Tell the iframe to drop a request the SDK has already abandoned locally. */
74
+ cancelSilkRequest(requestId: string, method: string): void;
75
+ /**
76
+ * Post a 'ready' notification to the iframe, and wait
77
+ * for the iframe to respond with a 'ready' notification.
78
+ */
79
+ pingIframe(): Promise<void>;
80
+ /**
81
+ * Post a SilkRequest to the iframeWindow. Don't wait for a response.
82
+ */
83
+ postSilkRequest(req: PostSilkRequestArgs): Promise<string>;
84
+ /**
85
+ * Register this manager's callbacks with the shared window `message`
86
+ * listener (top frame). All managers share ONE global listener; each is
87
+ * still origin-filtered and id-routed independently. Returns an unregister
88
+ * function.
89
+ * @param config - Configuration that includes callbacks for handling specific messages.
90
+ */
91
+ addListener(config: MessageListenerConfig): () => void;
92
+ dispose(): void;
93
+ }
94
+ //#endregion
95
+ //#region src/lib/WalletModalController.d.ts
96
+ type WaaPIframeLifecyclePhase = 'modal_requested' | 'modal_visible' | 'modal_hidden' | 'modal_cancelled';
97
+ type WaaPIframeLifecycleEvent = {
98
+ phase: WaaPIframeLifecyclePhase;
99
+ at: number;
100
+ visualRevision: number;
101
+ fallback?: boolean;
102
+ };
103
+ type WaaPIframeDiagnostics = {
104
+ walletOrigin: string | null;
105
+ iframeNavigationStartedAt: number | null;
106
+ iframeLoadedAt: number | null;
107
+ visualRevision: number;
108
+ visualReadyAt: number | null;
109
+ modalPhase: 'idle' | 'pending' | 'visible' | 'hidden';
110
+ modalRequestedAt: number | null;
111
+ modalVisibleAt: number | null;
112
+ usedVisualFallback: boolean;
113
+ /** Redacted request-readiness timing, when an SDK facade has mounted. */
114
+ handshake: WalletHandshakeDiagnostics | null;
115
+ };
116
+ /** Subscribe to presentation-only iframe lifecycle timing events. */
117
+ declare const subscribeWaaPIframeLifecycle: (listener: (event: WaaPIframeLifecycleEvent) => void) => (() => void);
118
+ /**
119
+ * Snapshot startup and presentation timings without exposing message payloads,
120
+ * account data, or signing material. Useful for partner telemetry and support.
121
+ */
122
+ declare const getWaaPIframeDiagnostics: () => WaaPIframeDiagnostics;
123
+ //#endregion
124
+ //#region src/lib/preload.d.ts
125
+ /** Any public WaaP facade that can warm the shared wallet iframe. */
126
+ interface WaaPPreloadTarget {
127
+ preload(): Promise<void>;
128
+ }
129
+ interface WaaPIdlePreloadOptions {
130
+ /** Browser deadline for an idle callback. Default: 2 seconds. */
131
+ timeoutMs?: number;
132
+ /** Observes a best-effort warmup failure without making page startup fail. */
133
+ onError?: (error: unknown) => void;
134
+ }
135
+ type CancelWaaPPreload = () => void;
136
+ /**
137
+ * Warm an already-created WaaP facade when the browser is idle. It never opens
138
+ * wallet UI, and cancellation is useful when the embedding route unmounts.
139
+ *
140
+ * Use this after the host page's LCP. For a likely immediate action (for
141
+ * example Connect button hover/focus), call `target.preload()` directly.
142
+ */
143
+ declare const preloadWaaPOnIdle: (target: WaaPPreloadTarget, options?: WaaPIdlePreloadOptions) => CancelWaaPPreload;
144
+ //#endregion
145
+ //#region src/lib/WaaPError.d.ts
146
+ /** Stable, safe error vocabulary for non-EIP-1193 SDK facades. */
147
+ type WaaPErrorCode = 'cancelled' | 'timeout' | 'user_rejected' | 'policy_rejected' | 'not_authenticated' | 'not_connected' | 'unsupported_input' | 'wallet_error' | 'unknown';
148
+ type WaaPOperationMetadata = {
149
+ /**
150
+ * The chain the failed operation targeted. Declared structurally rather than
151
+ * as `WaaPChain` so the error vocabulary stays free of the initializer graph.
152
+ */
153
+ chain?: 'evm' | 'sui' | 'solana';
154
+ method?: string;
155
+ requestId?: string;
156
+ };
157
+ declare class WaaPError extends Error {
158
+ readonly code: WaaPErrorCode;
159
+ readonly operation?: WaaPOperationMetadata;
160
+ readonly cause?: unknown;
161
+ constructor(code: WaaPErrorCode, message: string, options?: {
162
+ cause?: unknown;
163
+ operation?: WaaPOperationMetadata;
164
+ });
165
+ }
166
+ declare function normalizeWaaPError(error: unknown, operation?: WaaPOperationMetadata): WaaPError;
167
+ //#endregion
168
+ export { CancelWaaPPreload as a, preloadWaaPOnIdle as c, WaaPIframeLifecyclePhase as d, getWaaPIframeDiagnostics as f, WalletMessageManager as h, normalizeWaaPError as i, WaaPIframeDiagnostics as l, PostSilkRequestArgs as m, WaaPErrorCode as n, WaaPIdlePreloadOptions as o, subscribeWaaPIframeLifecycle as p, WaaPOperationMetadata as r, WaaPPreloadTarget as s, WaaPError as t, WaaPIframeLifecycleEvent as u };