@human.tech/waap-sdk 2.1.0 → 2.2.0-staging-7f56bf

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 (60) hide show
  1. package/.agent/SKILL.md +179 -0
  2. package/CHANGELOG.md +69 -0
  3. package/README.md +264 -94
  4. package/dist/{WaaPError-XLgIXUgh.d.ts → WaaPError-DCJ9WDaR.d.ts} +1 -1
  5. package/dist/{WaaPError-C5nPcaKk.d.mts → WaaPError-DgDAQQKF.d.mts} +1 -1
  6. package/dist/{WalletConnect-G-lbqknM.js → WalletConnect-Dn40Omgo.js} +1 -1
  7. package/dist/{WalletConnect-Deg7_JmH.mjs → WalletConnect-UfxGn2M_.mjs} +1 -1
  8. package/dist/{esm-B4jz8Emb.mjs → esm-BUfmyWbN.mjs} +1 -1
  9. package/dist/esm-DFwVZkjo.js +1 -0
  10. package/dist/evm-BINU4e1N.mjs +2 -0
  11. package/dist/evm-BXkH-I90.js +2 -0
  12. package/dist/evm.d.mts +2 -2
  13. package/dist/evm.d.ts +2 -2
  14. package/dist/evm.js +1 -1
  15. package/dist/evm.mjs +1 -1
  16. package/dist/{index-CdKntlzX.d.mts → index-C0mLQs_a.d.mts} +44 -28
  17. package/dist/{index-CMSufeMa.d.ts → index-DOIss_GK.d.ts} +44 -28
  18. package/dist/index.d.mts +46 -10
  19. package/dist/index.d.ts +46 -10
  20. package/dist/index.js +4 -1
  21. package/dist/index.mjs +4 -1
  22. package/dist/{initializerContext-0oKHzvQG.d.ts → initializerContext-DIrqEE6B.d.ts} +1 -2
  23. package/dist/{initializerContext-C39PUnGi.d.mts → initializerContext-_YjbVTiL.d.mts} +1 -2
  24. package/dist/react.d.mts +1 -1
  25. package/dist/react.d.ts +1 -1
  26. package/dist/react.js +1 -1
  27. package/dist/react.mjs +1 -1
  28. package/dist/{register-QjrsOe7r.d.mts → register-9bEe9ATz.d.mts} +3 -3
  29. package/dist/register-BXqcetNF.mjs +1 -0
  30. package/dist/{register-CNgjA0yl.mjs → register-Bg4jW_HM.mjs} +1 -1
  31. package/dist/{register-4Afr2Jx8.js → register-CRhge1wE.js} +1 -1
  32. package/dist/{register-CxsUwgKJ.d.ts → register-Mb1D_xW4.d.ts} +5 -17
  33. package/dist/{register-CBlzg5ln.d.ts → register-PWKDsSRv.d.ts} +3 -3
  34. package/dist/{register-LmdJdvzn.d.mts → register-XzDVa7r8.d.mts} +5 -17
  35. package/dist/{register-ozKwGWOb.js → register-oYvnB41B.js} +1 -1
  36. package/dist/solana.d.mts +4 -4
  37. package/dist/solana.d.ts +4 -4
  38. package/dist/solana.js +1 -1
  39. package/dist/solana.mjs +1 -1
  40. package/dist/sui.d.mts +4 -4
  41. package/dist/sui.d.ts +4 -4
  42. package/dist/sui.js +1 -1
  43. package/dist/sui.mjs +1 -1
  44. package/dist/{types-DexmJNke.d.mts → types-BmCqyQtu.d.mts} +36 -15
  45. package/dist/{types-DexmJNke.d.ts → types-BmCqyQtu.d.ts} +36 -15
  46. package/dist/ui-Co16lVSp.mjs +1 -0
  47. package/dist/ui-lJmATPTt.js +1 -0
  48. package/dist/{useWaapAuth-Z_ONicYr.js → useWaapAuth-BPvve-_3.js} +1 -1
  49. package/dist/{useWaapAuth-DHIeb4yc.mjs → useWaapAuth-BcmVGb-D.mjs} +1 -1
  50. package/dist/{useWaapAuth-BrqAhAn2.d.ts → useWaapAuth-DgYO5KxO.d.ts} +2 -2
  51. package/dist/{useWaapAuth-C5I7QqyW.d.mts → useWaapAuth-vJAk2n_I.d.mts} +2 -2
  52. package/dist/walletconnect.js +1 -1
  53. package/dist/walletconnect.mjs +1 -1
  54. package/package.json +4 -2
  55. package/dist/esm-D5fDQenf.js +0 -1
  56. package/dist/evm-Ch-aWWat.js +0 -1
  57. package/dist/evm-DHVrAmEw.mjs +0 -1
  58. package/dist/register-DIZnKDHF.mjs +0 -1
  59. package/dist/ui-16QpbEyG.js +0 -1
  60. package/dist/ui-BAYRtDQg.mjs +0 -1
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # WaaP SDK
2
2
 
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.
3
+ `@human.tech/waap-sdk` is how a dApp integrates WaaP a wallet the user owns,
4
+ not one your app rents. One integration gives your users 1-click onboarding and
5
+ multi-chain support, and the same wallet follows them to every other WaaP dApp.
6
+ Signing happens in a secure enclave and is gated by policy engine rules.
6
7
 
7
8
  ## Install
8
9
 
@@ -10,12 +11,32 @@ material. The wallet reviews, gates, signs, and broadcasts requests.
10
11
  pnpm add @human.tech/waap-sdk
11
12
  ```
12
13
 
14
+ ## Documentation
15
+
16
+ This README covers the SDK surface. See [docs.waap.xyz](https://docs.waap.xyz)
17
+ for comprehensive documentation, integration guides, and recipes.
18
+
19
+ ## Choosing an entry point
20
+
21
+ | Entry point | Returns | Use when |
22
+ | ---------------------------------------- | --------------------------- | ------------------------------------------- |
23
+ | `initWaaP()` | EIP-1193 provider | One EVM integration (the published default) |
24
+ | `initWaaP({ chain: 'sui' \| 'solana' })` | That chain's facade | One non-EVM integration |
25
+ | `initWaaPSquid({ chains })` | Facades + `squid` lifecycle | Squid mode, several chains |
26
+
27
+ `initWaaP` returns the facade **directly** — it is not an object to destructure
28
+ a chain off. `initWaaPSquid` returns a container whose keys are the chains you
29
+ asked for.
30
+
31
+ Every initializer accepts `environment: 'production' | 'staging'`. Omit it and
32
+ the SDK targets production.
33
+
13
34
  ## EVM
14
35
 
15
36
  ```ts
16
37
  import { initWaaP } from '@human.tech/waap-sdk'
17
38
 
18
- const wallet = initWaaP({ environment: 'production' }) // `chains` defaults to ['evm']
39
+ const wallet = initWaaP({ environment: 'production' })
19
40
  const [address] = (await wallet.request({
20
41
  method: 'eth_requestAccounts'
21
42
  })) as string[]
@@ -28,20 +49,18 @@ const signature = await wallet.request({
28
49
  wallet.destroy()
29
50
  ```
30
51
 
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'`.
52
+ The returned object is a standard [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)
53
+ provider: it exposes `request()`, emits `connect`, `disconnect`,
54
+ `chainChanged`, and `accountsChanged`, and surfaces rejections as EIP-1193
55
+ provider errors. Any library that speaks EIP-1193 — wagmi, viem, ethers,
56
+ web3.js — accepts it without an adapter.
35
57
 
36
58
  ## Sui
37
59
 
38
60
  ```ts
39
61
  import { initWaaP } from '@human.tech/waap-sdk'
40
62
 
41
- const { sui: wallet } = initWaaP({
42
- environment: 'production',
43
- chains: ['sui']
44
- })
63
+ const wallet = initWaaP({ environment: 'production', chain: 'sui' })
45
64
  const { accounts } = await wallet.connect()
46
65
  const signed = await wallet.signPersonalMessage({
47
66
  account: accounts[0],
@@ -50,15 +69,18 @@ const signed = await wallet.signPersonalMessage({
50
69
  wallet.destroy()
51
70
  ```
52
71
 
72
+ `features` implements `standard:connect`, `standard:disconnect`,
73
+ `standard:events`, `sui:signPersonalMessage`, `sui:signTransaction`,
74
+ `sui:signAndExecuteTransaction`, and `sui:switchChain`, plus the legacy
75
+ `sui:signTransactionBlock` / `sui:signAndExecuteTransactionBlock` pair. The
76
+ equivalent methods are also on the facade for adapter-style consumers.
77
+
53
78
  ## Solana
54
79
 
55
80
  ```ts
56
81
  import { initWaaP } from '@human.tech/waap-sdk'
57
82
 
58
- const { solana: wallet } = initWaaP({
59
- environment: 'production',
60
- chains: ['solana']
61
- })
83
+ const wallet = initWaaP({ environment: 'production', chain: 'solana' })
62
84
  const { accounts } = await wallet.connect()
63
85
  const signed = await wallet.signMessage({
64
86
  account: accounts[0],
@@ -69,75 +91,168 @@ wallet.destroy()
69
91
 
70
92
  `features` implements `standard:connect`, `standard:disconnect`,
71
93
  `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.
94
+ `solana:signAndSendTransaction`. The direct `signTransaction` and
95
+ `signAndSendTransaction` helpers remain available for wallet-adapter-style
96
+ consumers. They accept serialized bytes (or a serializable transaction object).
97
+ Dapp-built Solana transactions retain their exact bytes; obtain a fresh
98
+ blockhash near approval to avoid expiry.
99
+
100
+ `signAllTransactions` is not implemented. Submit transactions through
101
+ `signTransaction` individually.
78
102
 
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.
103
+ ## Squid mode: multi chains
82
104
 
83
- ## Squid multichain
105
+ Squid accounts are created explicitly. Initialization and login alone never
106
+ create one: call `onboard()` after login and before signing.
84
107
 
85
108
  ```ts
86
- import { initWaaPSquid, useWaapAuth, WAAP_EVENTS } from '@human.tech/waap-sdk'
109
+ import { initWaaPSquid, WAAP_EVENTS } from '@human.tech/waap-sdk'
87
110
 
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)
111
+ const waap = initWaaPSquid({
112
+ environment: 'production',
113
+ chains: ['evm', 'sui']
114
+ })
115
+ await waap.session.login()
116
+ await waap.squid.onboard() // creates or restores both curves (sqd1 + sqd2)
117
+
118
+ waap.session.on(WAAP_EVENTS.squidReady, () => {
119
+ console.log(waap.squid.getStatus()) // { state: 'active' }
92
120
  })
93
- // In React: const auth = useWaapAuth(waap.auth); auth.squidReady
94
121
  waap.destroy()
95
122
  ```
96
123
 
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.
124
+ `chains` is required and must name at least one facade. Only the chains you
125
+ name are present on the returned object, and the type reflects that — reading
126
+ `waap.solana` above is a compile error rather than a runtime `undefined`.
100
127
 
101
- ## Advanced integration
128
+ `chains` scopes which SDK surfaces load, not the dual-curve provisioning
129
+ transaction, which always covers both curves. Naming the facades is deliberate:
130
+ the previous all-chain default loaded the Sui and Solana surfaces for callers
131
+ that only ever used EVM.
102
132
 
103
- ### SDK session protection
133
+ `session.login()` is safe to call on startup: it first checks the existing WaaP
134
+ iframe session without showing wallet UI. The login screen opens only when there
135
+ is no valid session.
104
136
 
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:
137
+ `squid.getStatus()` reports `absent`, `provisioning`, `awaiting-network`,
138
+ `active`, or `failed`. `onboardWithStatus()` triggers onboarding and resolves
139
+ with the immediately observable lifecycle.
109
140
 
110
- ```ts
111
- const waap = initWaaP({ sessionProtection: 'bearer' })
112
- ```
141
+ In React, `useWaapAuth(waap.session)` exposes `squidStatus` plus the derived
142
+ `isConnected`, `isPending`, `squidReady`, `error`, `address`, `suiAddress`, and
143
+ `solanaAddress` fields.
113
144
 
114
- The host dapp never receives either credential. `legacy` is not a supported
115
- session-protection mode.
145
+ The EVM facade is `waap.evm`. `waap.ethereum` is an alias for it, kept because
146
+ it is what the published integrations use — prefer `evm`, which matches the
147
+ `chains` value that produced the facade and reflects that it serves every EVM
148
+ chain rather than Ethereum specifically.
116
149
 
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.
150
+ `waap.auth` is a deprecated EVM alias for the _session_ surface, and exists only
151
+ when all three chains are selected. New code should use `waap.session`.
125
152
 
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.
153
+ ## Advanced integration
154
+
155
+ ### Permission tokens
156
+
157
+ A permission token lets a user pre-authorize a scoped batch of transactions so
158
+ each one does not need an individual confirmation. Every facade can request,
159
+ inspect, and clear one:
160
+
161
+ ```ts
162
+ import {
163
+ permissionTokenEvmFunction,
164
+ permissionTokenRecipient
165
+ } from '@human.tech/waap-sdk'
166
+
167
+ const recipient = permissionTokenRecipient(
168
+ 'evm:1',
169
+ '0x1111111111111111111111111111111111111111'
170
+ )
171
+ const deposit = permissionTokenEvmFunction(
172
+ '0x2222222222222222222222222222222222222222',
173
+ 'depositFor(address,uint256)'
174
+ )
175
+
176
+ await wallet.requestPermissionToken({
177
+ chain: 'evm:1',
178
+ allowedAddresses: [recipient, deposit],
179
+ requestedAmountUsd: 100,
180
+ requestedExpirySeconds: 3600 // max 7200
181
+ })
182
+ const status = await wallet.getPermissionTokenStatus({
183
+ chainId: 1,
184
+ sender: '0x…'
185
+ })
186
+ await wallet.clearPermissionToken({ chainId: 1, sender: '0x…' })
187
+ ```
129
188
 
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.
189
+ `allowedAddresses` contains two distinct scope types. A plain address permits
190
+ only asset delivery to that recipient. An application scope permits execution
191
+ as `target:*` or one exact chain action. The exported
192
+ `permissionTokenEvmFunction`, `permissionTokenSuiFunction`, and
193
+ `permissionTokenSolanaAnchorInstruction` builders derive selectors, Move paths,
194
+ and Anchor discriminators; the corresponding contract/package/program builders
195
+ create the broader `target:*` form. If an application call sends assets to an
196
+ external beneficiary, include a separate plain recipient scope. Unsupported or
197
+ incompletely simulated actions fall back to normal review; PE uses no target
198
+ registry.
199
+
200
+ The wallet mode is not a parameter. The facade decides it — `initWaaP` mints a
201
+ standard-mode token, `initWaaPSquid` mints a Squid one — so request the token
202
+ on the same facade that will send the transaction. A token is not redeemable
203
+ by the other mode.
204
+
205
+ `getPermissionTokenStatus` returns redacted metadata only — never the signed
206
+ token, which stays in the wallet.
207
+
208
+ Holding a token does not change anything on its own. Opt into its use per call
209
+ with `withPT: true`:
210
+
211
+ - **EVM** — `withPT` on `request()` for `eth_sendTransaction` and
212
+ `eth_signTransaction`.
213
+ - **Sui** — `withPT` on `signTransaction` and `signAndExecuteTransaction`, and
214
+ on the legacy `signTransactionBlock` / `signAndExecuteTransactionBlock` pair.
215
+ - **Solana** — `withPT` on `signTransaction` and `signAndSendTransaction`.
216
+
217
+ `withPT` is ignored on message signing — `personal_sign` and
218
+ `eth_signTypedData_v4` are permission-token-ineligible wallet-side, whatever the
219
+ caller passes.
220
+
221
+ The wallet resolves only a stored token matching the requesting origin, chain,
222
+ wallet mode, and selected signer; otherwise the transaction follows the ordinary
223
+ approval / 2FA flow. Permission tokens are an SDK-iframe capability and are not
224
+ a browser-side authorization bypass: the policy engine still makes the decision.
225
+
226
+ ### Events
227
+
228
+ Runtime event names are exported as `WAAP_EVENTS`:
229
+
230
+ | Key | Event | Meaning |
231
+ | ------------------- | -------------------- | ------------------------------------------- |
232
+ | `signPending` | `waap_sign_pending` | Signing started |
233
+ | `twoFactorRequired` | `waap_2fa_required` | Awaiting 2FA |
234
+ | `signComplete` | `waap_sign_complete` | Signed; carries `txHash` and `serializedTx` |
235
+ | `signFailed` | `waap_sign_failed` | Signing failed |
236
+ | `txPending` | `waap_tx_pending` | Node accepted; awaiting confirmation |
237
+ | `txConfirmed` | `waap_tx_confirmed` | Confirmed on-chain |
238
+ | `txFailed` | `waap_tx_failed` | Broadcast or confirmation failed |
239
+ | `squidPending` | `waap_squid_pending` | Squid onboarding in progress |
240
+ | `squidReady` | `waap_squid_ready` | Squid account active |
241
+ | `squidFailed` | `waap_squid_failed` | Squid onboarding failed |
242
+
243
+ The transaction events are EVM-only and fire only under `asyncTxs`. For those,
244
+ use `useWaapTransaction(provider, callbacks)`; the old one-argument form remains
245
+ supported but depends on the global provider and is unsuitable for multiple
246
+ wallets.
133
247
 
134
248
  ## Completion and lifecycle
135
249
 
136
250
  The SDK bridge does not make every chain method mean the same thing:
137
251
 
138
252
  - 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.
253
+ `eth_sendTransaction` resolves with the deterministic hash of the signed
254
+ transaction as soon as signing completes, then broadcast and confirmation
255
+ continue in the background and report through the events above.
141
256
  - Sui `signTransaction` returns signed bytes. `signAndExecuteTransaction`
142
257
  returns a submitted digest; applications that require finality must query the
143
258
  chain independently.
@@ -146,34 +261,31 @@ The SDK bridge does not make every chain method mean the same thing:
146
261
  blockhash and can expire during a human approval.
147
262
 
148
263
  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.
264
+ advanced layout control, `deferIframe: true` delays iframe mount until the first
265
+ request; adding `<waap-wallet>` before initialization uses component rather than
266
+ modal presentation.
152
267
 
153
268
  ### Startup performance
154
269
 
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.
270
+ The public iframe URL and `postMessage` protocol are stable: an already released
271
+ SDK continues to use `/iframe` without any host-app change. Current SDK versions
272
+ wait for the iframe's real navigation before posting their ready ping, then use a
273
+ bounded retry handshake. This avoids posting to the transient `about:blank`
274
+ document, which can otherwise produce target-origin warnings.
160
275
 
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.
276
+ Initialize a facade once for the lifetime of the embedding UI; do not create and
277
+ destroy it for each Connect or Sign click. By default the iframe warms itself
278
+ once the browser goes idle. Pass `deferIframe: false` to mount eagerly during
279
+ initialization, or `deferIframe: true` to mount nothing until `preload()` or the
280
+ first wallet operation the right choice for a page where wallet interaction is
281
+ not above the fold. `preload()` mounts the iframe and completes its
282
+ non-interactive setup; it never opens wallet UI or creates a Squid account.
166
283
 
167
284
  ```ts
168
285
  import { initWaaP, preloadWaaPOnIdle } from '@human.tech/waap-sdk'
169
286
 
170
- // Omitted chains retain the original EVM EIP-1193 provider behavior.
171
287
  const ethereum = initWaaP({ deferIframe: true })
172
288
 
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
289
  // Call after LCP / from a post-LCP effect. The returned fn cancels warmup when
178
290
  // the owning route unmounts.
179
291
  const cancelPreload = preloadWaaPOnIdle(ethereum)
@@ -192,17 +304,75 @@ cancelPreload()
192
304
  ethereum.destroy()
193
305
  ```
194
306
 
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.
307
+ Every facade — EVM, Sui, Solana, and the Squid container exposes the same
308
+ `preload()` method. `initWaaPSquid` coalesces its facades' shared setup into one
309
+ iframe request.
310
+
311
+ For troubleshooting an embed, `getWaaPIframeDiagnostics()` reports navigation,
312
+ visual render, and modal timings without exposing request payloads.
313
+ `subscribeWaaPIframeLifecycle` can feed partner telemetry with
314
+ `modal_requested`, `modal_visible`, `modal_hidden`, and `modal_cancelled`
315
+ events. The EVM provider's `walletMessageManager.getHandshakeDiagnostics()`
316
+ additionally reports ready-ping retries and the last readiness error.
317
+
318
+ ### Subpath entry points
319
+
320
+ The root export carries everything, including the React hooks. Import from a
321
+ subpath to keep an unrelated dependency graph out of your bundle:
322
+
323
+ | Subpath | Contents |
324
+ | ------------------------------------ | ----------------------------------- |
325
+ | `@human.tech/waap-sdk` | Everything |
326
+ | `@human.tech/waap-sdk/evm` | EVM provider |
327
+ | `@human.tech/waap-sdk/sui` | Sui Wallet Standard facade |
328
+ | `@human.tech/waap-sdk/solana` | Solana Wallet Standard facade |
329
+ | `@human.tech/waap-sdk/react` | `useWaapAuth`, `useWaapTransaction` |
330
+ | `@human.tech/waap-sdk/walletconnect` | WalletConnect integration |
331
+
332
+ `/react` is the only subpath that imports `react`.
333
+
334
+ ## Errors
335
+
336
+ - EVM follows EIP-1193: a rejected request surfaces the provider error object
337
+ (`{ code, message, ... }`) per spec — match on `error.code`.
338
+ - Sui and Solana throw `WaaPError` at the iframe transport boundary. Its stable
339
+ `code` and optional operation metadata make cancellation, timeout,
340
+ user/policy rejection, and wallet errors safe to handle programmatically.
341
+
342
+ ## Agent skills
343
+
344
+ ### Built into the package
345
+
346
+ The published tarball ships an agent skill at `.agent/SKILL.md`, so a coding
347
+ agent can read the SDK's intended usage straight from `node_modules` rather
348
+ than from the network:
349
+
350
+ ```bash
351
+ cat node_modules/@human.tech/waap-sdk/.agent/SKILL.md
352
+ ```
353
+
354
+ It covers entry-point selection, the chain facades, the session lifecycle, and
355
+ Privileges. The copy in the package always matches the version you installed,
356
+ which is why it is the one to prefer.
357
+
358
+ ### From the skills repository
359
+
360
+ The same skills are published to
361
+ [the-waap-skills](https://github.com/holonym-foundation/the-waap-skills) for
362
+ `skills.sh` and compatible loaders, which is the route to take when the agent
363
+ should have the skill available before any package is installed:
364
+
365
+ ```bash
366
+ npx skills add holonym-foundation/the-waap-skills --skill waap-sdk
367
+ ```
368
+
369
+ Omit `--skill` to install every skill in the repository, including the one for
370
+ `@human.tech/waap-cli`:
371
+
372
+ ```bash
373
+ npx skills add holonym-foundation/the-waap-skills
374
+ ```
375
+
376
+ The repository is generated from the `.agent/SKILL.md` files in this project
377
+ and is refreshed on release, so the two agree — but a freshly installed
378
+ package is the more precise answer for the exact version in use.
@@ -1,4 +1,4 @@
1
- import { A as SILK_METHOD, E as SilkResponse, T as SilkRequestCancellation, j as SilkNotificationData, w as SilkRequest } from "./types-DexmJNke.js";
1
+ import { D as SilkRequestCancellation, E as SilkRequest, M as SILK_METHOD, N as SilkNotificationData, O as SilkResponse } from "./types-BmCqyQtu.js";
2
2
  //#region src/lib/WalletMessageManager.d.ts
3
3
  type PostSilkRequestArgs = {
4
4
  method: keyof typeof SILK_METHOD;
@@ -1,4 +1,4 @@
1
- import { A as SILK_METHOD, E as SilkResponse, T as SilkRequestCancellation, j as SilkNotificationData, w as SilkRequest } from "./types-DexmJNke.mjs";
1
+ import { D as SilkRequestCancellation, E as SilkRequest, M as SILK_METHOD, N as SilkNotificationData, O as SilkResponse } from "./types-BmCqyQtu.mjs";
2
2
  //#region src/lib/WalletMessageManager.d.ts
3
3
  type PostSilkRequestArgs = {
4
4
  method: keyof typeof SILK_METHOD;
@@ -1,4 +1,4 @@
1
1
  var e=class e{static{this.instance=null}static{this.projectId=void 0}static{this.chains=[1,10,100,137,8453,43114,42161,42220,84532,11155111]}static setProjectId(t){e.projectId=t}static getProjectIdFromEnv(){try{if(typeof process<`u`&&process.env)return process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID||process.env.VITE_WALLET_CONNECT_PROJECT_ID||process.env.REACT_APP_WALLET_CONNECT_PROJECT_ID||process.env.WALLET_CONNECT_PROJECT_ID}catch{return}}static async getInstance(){if(typeof window>`u`||typeof document>`u`)return null;let{createAppKit:t}=await import(`@reown/appkit`),{mainnet:n,sepolia:r,optimism:i,arbitrum:a,optimismGoerli:o,polygon:s,gnosis:c,avalanche:l,aurora:u,fantom:d,base:f,celo:p}=await import(`@reown/appkit/networks`);try{let o={name:`Human Wallet`,description:`Silk lets you create human keys for web3 wallets that are recoverable with private identity proofs and secured by zero trust protocols.`,url:window.location.origin,icons:[`https://imagedelivery.net/_aTEfDRm7z3tKgu9JhfeKA/f11f5753-616a-4aa0-2aee-9b75befea700/sm`]},m=e.projectId||e.getProjectIdFromEnv();if(!m)return console.error(`WalletConnect project ID not found. Please set it using one of these methods:
2
2
  1. Pass walletConnectProjectId when calling initSilk
3
3
  2. Call SilkWalletConnect.setProjectId("your-project-id")
4
- 3. Set WALLET_CONNECT_PROJECT_ID (NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID for Next projects) environment variable`),null;if(e.projectId=m,!e.instance){let{EthersAdapter:h}=await import(`@reown/appkit-adapter-ethers`);e.instance=t({adapters:[new h],projectId:m,metadata:o,networks:[n,r,a,i,s,c,l,u,d,f,p],features:{socials:!1,email:!1}})}return e.instance}catch(e){return console.error(`Error importing or initializing WalletConnect:`,e),null}}static async listenToAccountChangeEvent(){await new Promise(t=>{e.instance.subscribeAccount(e=>{e?.isConnected&&t()})})}static async waitForReadyAndCheckConnection(){if(!e.instance)return!1;let t=!1,n=0;for(;!t&&n<15;){let r=n<5?500:1e3;await new Promise(e=>setTimeout(e,r)),t=e.instance.getIsConnectedState(),n++,console.log(`WalletConnect connection check attempt ${n}: ${t}`)}return t}static isConnected(){return e.instance?.getIsConnectedState()??!1}static getWalletProvider(){return e.instance?.getWalletProvider()??null}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
4
+ 3. Set WALLET_CONNECT_PROJECT_ID (NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID for Next projects) environment variable`),null;if(e.projectId=m,!e.instance){let{EthersAdapter:h}=await import(`@reown/appkit-adapter-ethers`);e.instance=t({adapters:[new h],projectId:m,metadata:o,networks:[n,r,a,i,s,c,l,u,d,f,p],features:{socials:!1,email:!1}})}return e.instance}catch(e){return console.error(`Error importing or initializing WalletConnect:`,e),null}}static async listenToAccountChangeEvent(){await new Promise((t,n)=>{let r=setTimeout(()=>{n(Error(`Wallet connection timed out`))},6e4);e.instance.subscribeAccount(e=>{e?.isConnected&&(clearTimeout(r),t())})})}static async waitForReadyAndCheckConnection(){if(!e.instance)return!1;let t=!1,n=0;for(;!t&&n<15;){let r=n<5?500:1e3;await new Promise(e=>setTimeout(e,r)),t=e.instance.getIsConnectedState(),n++,console.log(`WalletConnect connection check attempt ${n}: ${t}`)}return t}static isConnected(){return e.instance?.getIsConnectedState()??!1}static getWalletProvider(){return e.instance?.getWalletProvider()??null}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
@@ -1,4 +1,4 @@
1
1
  var e=class e{static{this.instance=null}static{this.projectId=void 0}static{this.chains=[1,10,100,137,8453,43114,42161,42220,84532,11155111]}static setProjectId(t){e.projectId=t}static getProjectIdFromEnv(){try{if(typeof process<`u`&&process.env)return process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID||process.env.VITE_WALLET_CONNECT_PROJECT_ID||process.env.REACT_APP_WALLET_CONNECT_PROJECT_ID||process.env.WALLET_CONNECT_PROJECT_ID}catch{return}}static async getInstance(){if(typeof window>`u`||typeof document>`u`)return null;let{createAppKit:t}=await import(`@reown/appkit`),{mainnet:n,sepolia:r,optimism:i,arbitrum:a,optimismGoerli:o,polygon:s,gnosis:c,avalanche:l,aurora:u,fantom:d,base:f,celo:p}=await import(`@reown/appkit/networks`);try{let o={name:`Human Wallet`,description:`Silk lets you create human keys for web3 wallets that are recoverable with private identity proofs and secured by zero trust protocols.`,url:window.location.origin,icons:[`https://imagedelivery.net/_aTEfDRm7z3tKgu9JhfeKA/f11f5753-616a-4aa0-2aee-9b75befea700/sm`]},m=e.projectId||e.getProjectIdFromEnv();if(!m)return console.error(`WalletConnect project ID not found. Please set it using one of these methods:
2
2
  1. Pass walletConnectProjectId when calling initSilk
3
3
  2. Call SilkWalletConnect.setProjectId("your-project-id")
4
- 3. Set WALLET_CONNECT_PROJECT_ID (NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID for Next projects) environment variable`),null;if(e.projectId=m,!e.instance){let{EthersAdapter:h}=await import(`@reown/appkit-adapter-ethers`);e.instance=t({adapters:[new h],projectId:m,metadata:o,networks:[n,r,a,i,s,c,l,u,d,f,p],features:{socials:!1,email:!1}})}return e.instance}catch(e){return console.error(`Error importing or initializing WalletConnect:`,e),null}}static async listenToAccountChangeEvent(){await new Promise(t=>{e.instance.subscribeAccount(e=>{e?.isConnected&&t()})})}static async waitForReadyAndCheckConnection(){if(!e.instance)return!1;let t=!1,n=0;for(;!t&&n<15;){let r=n<5?500:1e3;await new Promise(e=>setTimeout(e,r)),t=e.instance.getIsConnectedState(),n++,console.log(`WalletConnect connection check attempt ${n}: ${t}`)}return t}static isConnected(){return e.instance?.getIsConnectedState()??!1}static getWalletProvider(){return e.instance?.getWalletProvider()??null}};export{e as t};
4
+ 3. Set WALLET_CONNECT_PROJECT_ID (NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID for Next projects) environment variable`),null;if(e.projectId=m,!e.instance){let{EthersAdapter:h}=await import(`@reown/appkit-adapter-ethers`);e.instance=t({adapters:[new h],projectId:m,metadata:o,networks:[n,r,a,i,s,c,l,u,d,f,p],features:{socials:!1,email:!1}})}return e.instance}catch(e){return console.error(`Error importing or initializing WalletConnect:`,e),null}}static async listenToAccountChangeEvent(){await new Promise((t,n)=>{let r=setTimeout(()=>{n(Error(`Wallet connection timed out`))},6e4);e.instance.subscribeAccount(e=>{e?.isConnected&&(clearTimeout(r),t())})})}static async waitForReadyAndCheckConnection(){if(!e.instance)return!1;let t=!1,n=0;for(;!t&&n<15;){let r=n<5?500:1e3;await new Promise(e=>setTimeout(e,r)),t=e.instance.getIsConnectedState(),n++,console.log(`WalletConnect connection check attempt ${n}: ${t}`)}return t}static isConnected(){return e.instance?.getIsConnectedState()??!1}static getWalletProvider(){return e.instance?.getWalletProvider()??null}};export{e as t};
@@ -1 +1 @@
1
- var e;(function(e){e.request=`request`,e.response=`response`,e.notification=`notification`})(e||={});var t;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`,e.eth_accountsChanged=`eth_accountsChanged`,e.sui_connect=`sui_connect`,e.sui_disconnect=`sui_disconnect`,e.sui_getAccounts=`sui_getAccounts`,e.sui_signPersonalMessage=`sui_signPersonalMessage`,e.sui_signTransaction=`sui_signTransaction`,e.sui_signAndExecuteTransaction=`sui_signAndExecuteTransaction`,e.sui_switchChain=`sui_switchChain`,e.show_modal=`show_modal`,e.hide_modal=`hide_modal`,e.login=`login`,e.auto_conn=`auto_conn`,e.logout=`logout`,e.set_points_referral_code=`set_points_referral_code`,e.set_project=`set_project`,e.silk_requestEmail=`silk_requestEmail`,e.silk_requestSbt=`silk_requestSbt`,e.set_custom_config=`set_custom_config`,e.safe=`safe`,e.set_is_mobile=`set_is_mobile`,e.project_init=`project_init`,e.gastank_get_settings=`gastank_get_settings`,e.gastank_update_settings=`gastank_update_settings`,e.gastank_topup=`gastank_topup`,e.customization_get=`customization_get`,e.customization_update=`customization_update`,e.orcid=`orcid`,e.waap_requestPermissionToken=`waap_requestPermissionToken`,e.waap_getAccountStatus=`waap_getAccountStatus`,e.waap_getPermissionTokenStatus=`waap_getPermissionTokenStatus`,e.waap_clearPermissionToken=`waap_clearPermissionToken`,e.solana_connect=`solana_connect`,e.solana_disconnect=`solana_disconnect`,e.solana_signMessage=`solana_signMessage`,e.solana_signTransaction=`solana_signTransaction`,e.solana_signAllTransactions=`solana_signAllTransactions`,e.solana_signAndSendTransaction=`solana_signAndSendTransaction`,e.set_signing_mode=`set_signing_mode`,e.enter_lite_mode=`enter_lite_mode`})(t||={});var n;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`})(n||={});var r;(function(e){e.ready=`ready`,e.connect=`connect`,e.account_changed=`account_changed`,e.mobile_oauth_success=`mobile_oauth_success`,e.mobile_oauth_error=`mobile_oauth_error`,e.tx_pending=`waap_txPending`,e.tx_2fa_required=`waap_tx2faRequired`,e.tx_signed=`waap_txSigned`,e.tx_confirmed=`waap_txConfirmed`,e.tx_failed=`waap_txFailed`,e.squid_pending=`waap_squid_pending`,e.squid_ready=`waap_squid_ready`,e.squid_failed=`waap_squid_failed`,e.request_cancel=`waap_requestCancel`})(r||={});export{r as i,e as n,t as r,n as t};
1
+ var e;(function(e){e.request=`request`,e.response=`response`,e.notification=`notification`})(e||={});var t;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`,e.eth_accountsChanged=`eth_accountsChanged`,e.sui_connect=`sui_connect`,e.sui_disconnect=`sui_disconnect`,e.sui_getAccounts=`sui_getAccounts`,e.sui_signPersonalMessage=`sui_signPersonalMessage`,e.sui_signTransaction=`sui_signTransaction`,e.sui_signAndExecuteTransaction=`sui_signAndExecuteTransaction`,e.sui_switchChain=`sui_switchChain`,e.show_modal=`show_modal`,e.hide_modal=`hide_modal`,e.login=`login`,e.auto_conn=`auto_conn`,e.logout=`logout`,e.set_points_referral_code=`set_points_referral_code`,e.set_project=`set_project`,e.silk_requestEmail=`silk_requestEmail`,e.silk_requestSbt=`silk_requestSbt`,e.set_custom_config=`set_custom_config`,e.safe=`safe`,e.set_is_mobile=`set_is_mobile`,e.project_init=`project_init`,e.gastank_get_settings=`gastank_get_settings`,e.gastank_update_settings=`gastank_update_settings`,e.gastank_topup=`gastank_topup`,e.customization_get=`customization_get`,e.customization_update=`customization_update`,e.orcid=`orcid`,e.waap_requestPermissionToken=`waap_requestPermissionToken`,e.waap_getAccountStatus=`waap_getAccountStatus`,e.waap_getPermissionTokenStatus=`waap_getPermissionTokenStatus`,e.waap_clearPermissionToken=`waap_clearPermissionToken`,e.waap_getLinkedAddresses=`waap_getLinkedAddresses`,e.waap_linkAddress=`waap_linkAddress`,e.waap_unlinkAddress=`waap_unlinkAddress`,e.waap_getLinkAddressNonce=`waap_getLinkAddressNonce`,e.solana_connect=`solana_connect`,e.solana_disconnect=`solana_disconnect`,e.solana_signMessage=`solana_signMessage`,e.solana_signTransaction=`solana_signTransaction`,e.solana_signAllTransactions=`solana_signAllTransactions`,e.solana_signAndSendTransaction=`solana_signAndSendTransaction`,e.set_signing_mode=`set_signing_mode`,e.enter_lite_mode=`enter_lite_mode`})(t||={});var n;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`})(n||={});var r;(function(e){e.ready=`ready`,e.connect=`connect`,e.account_changed=`account_changed`,e.mobile_oauth_success=`mobile_oauth_success`,e.mobile_oauth_error=`mobile_oauth_error`,e.tx_pending=`waap_txPending`,e.tx_2fa_required=`waap_tx2faRequired`,e.tx_signed=`waap_txSigned`,e.tx_confirmed=`waap_txConfirmed`,e.tx_failed=`waap_txFailed`,e.squid_pending=`waap_squid_pending`,e.squid_ready=`waap_squid_ready`,e.squid_failed=`waap_squid_failed`,e.request_cancel=`waap_requestCancel`})(r||={});export{r as i,e as n,t as r,n as t};
@@ -0,0 +1 @@
1
+ var e;(function(e){e.request=`request`,e.response=`response`,e.notification=`notification`})(e||={});var t;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`,e.eth_accountsChanged=`eth_accountsChanged`,e.sui_connect=`sui_connect`,e.sui_disconnect=`sui_disconnect`,e.sui_getAccounts=`sui_getAccounts`,e.sui_signPersonalMessage=`sui_signPersonalMessage`,e.sui_signTransaction=`sui_signTransaction`,e.sui_signAndExecuteTransaction=`sui_signAndExecuteTransaction`,e.sui_switchChain=`sui_switchChain`,e.show_modal=`show_modal`,e.hide_modal=`hide_modal`,e.login=`login`,e.auto_conn=`auto_conn`,e.logout=`logout`,e.set_points_referral_code=`set_points_referral_code`,e.set_project=`set_project`,e.silk_requestEmail=`silk_requestEmail`,e.silk_requestSbt=`silk_requestSbt`,e.set_custom_config=`set_custom_config`,e.safe=`safe`,e.set_is_mobile=`set_is_mobile`,e.project_init=`project_init`,e.gastank_get_settings=`gastank_get_settings`,e.gastank_update_settings=`gastank_update_settings`,e.gastank_topup=`gastank_topup`,e.customization_get=`customization_get`,e.customization_update=`customization_update`,e.orcid=`orcid`,e.waap_requestPermissionToken=`waap_requestPermissionToken`,e.waap_getAccountStatus=`waap_getAccountStatus`,e.waap_getPermissionTokenStatus=`waap_getPermissionTokenStatus`,e.waap_clearPermissionToken=`waap_clearPermissionToken`,e.waap_getLinkedAddresses=`waap_getLinkedAddresses`,e.waap_linkAddress=`waap_linkAddress`,e.waap_unlinkAddress=`waap_unlinkAddress`,e.waap_getLinkAddressNonce=`waap_getLinkAddressNonce`,e.solana_connect=`solana_connect`,e.solana_disconnect=`solana_disconnect`,e.solana_signMessage=`solana_signMessage`,e.solana_signTransaction=`solana_signTransaction`,e.solana_signAllTransactions=`solana_signAllTransactions`,e.solana_signAndSendTransaction=`solana_signAndSendTransaction`,e.set_signing_mode=`set_signing_mode`,e.enter_lite_mode=`enter_lite_mode`})(t||={});var n;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`})(n||={});var r;(function(e){e.ready=`ready`,e.connect=`connect`,e.account_changed=`account_changed`,e.mobile_oauth_success=`mobile_oauth_success`,e.mobile_oauth_error=`mobile_oauth_error`,e.tx_pending=`waap_txPending`,e.tx_2fa_required=`waap_tx2faRequired`,e.tx_signed=`waap_txSigned`,e.tx_confirmed=`waap_txConfirmed`,e.tx_failed=`waap_txFailed`,e.squid_pending=`waap_squid_pending`,e.squid_ready=`waap_squid_ready`,e.squid_failed=`waap_squid_failed`,e.request_cancel=`waap_requestCancel`})(r||={}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
@@ -0,0 +1,2 @@
1
+ import{i as e,n as t,r as n,t as r}from"./esm-BUfmyWbN.mjs";import{t as i}from"./WalletConnect-UfxGn2M_.mjs";import{EventEmitter as a}from"events";import{getAddress as o}from"ethers";var s=class extends Error{constructor(e,t,n={}){super(t),this.name=`WaaPError`,this.code=e,this.operation=n.operation,this.cause=n.cause}};function c(e,t){if(e instanceof s)return e;let n=e&&typeof e==`object`?e:void 0,r=n&&typeof n.message==`string`&&n.message||e instanceof Error&&e.message||String(e||`WaaP request failed`),i=n?.code,a=r.toLowerCase();return new s(a.includes(`cancelled`)||a.includes(`canceled`)?`cancelled`:a.includes(`timed out`)?`timeout`:a.includes(`policy`)||a.includes(`permission token`)?`policy_rejected`:i===4001||a.includes(`rejected`)?`user_rejected`:a.includes(`not connected`)?`not_connected`:a.includes(`not authenticated`)||a.includes(`log in first`)?`not_authenticated`:a.includes(`unsupported`)||a.includes(`must be base64`)?`unsupported_input`:n?`wallet_error`:`unknown`,r,{cause:e,operation:t})}const l=`waap-wallet`,u=`waap-component-container`,d=typeof window<`u`&&typeof document<`u`&&typeof HTMLElement<`u`;let f;d?(f=class extends HTMLElement{constructor(){super()}connectedCallback(){(!this.style.display||this.style.display===``)&&(this.style.display=`flex`,this.style.alignItems=`center`,this.style.justifyContent=`center`),(!this.style.width||this.style.width===``)&&(this.style.width=`100%`),(!this.style.height||this.style.height===``)&&(this.style.height=`100%`),this.id=u,this.setAttribute(`data-waap-mounted`,`true`)}disconnectedCallback(){this.removeAttribute(`data-waap-mounted`)}},typeof customElements<`u`&&!customElements.get(l)&&customElements.define(l,f)):f=class{};function p(){return d?!!document.getElementById(u)||!!document.querySelector(l):!1}function m(){return d?document.getElementById(u)||document.querySelector(l):null}const h=`https://staging.waap.xyz`,g={development:`http://localhost:3000`,staging:h,production:`https://waap.xyz`},ee=e=>e===`localhost`||e===`127.0.0.1`||e===`[::1]`;function _(e){let t;try{t=new URL(e)}catch{throw Error(`Invalid WaaP wallet origin: ${e}`)}if(t.origin!==e||t.pathname!==`/`||t.search||t.hash||t.username||t.password)throw Error(`WaaP walletOrigin must be an absolute origin without a path, query, or credentials`);if(t.protocol!==`https:`&&!(t.protocol===`http:`&&ee(t.hostname)))throw Error(`WaaP walletOrigin must use HTTPS unless it is a loopback host`);return t.origin}function v(e={}){return e.walletOrigin?_(e.walletOrigin):e.environment?_(g[e.environment]):e.useStaging?_(h):_(g.production)}const y=new WeakMap,b=new WeakMap,te=()=>typeof performance<`u`?performance.now():Date.now(),x=e=>({generation:e.generation,navigationStartedAt:e.navigationStartedAt,loadedAt:e.loadedAt}),S=e=>{let t=e.contentWindow;if(!t)return;let n=b.get(e);if(n&&y.get(t)===n)return;n?.cleanup(),n&&(b.delete(e),y.get(t)===n&&y.delete(t));let r=y.get(t);if(r?.iframe===e)return;r?.cleanup(),r&&b.delete(r.iframe);let i={iframe:e,generation:0,navigationStartedAt:te(),loadedAt:null,listeners:new Set,cleanup:()=>{}},a=()=>{i.generation+=1,i.loadedAt=te();let e=x(i);for(let t of Array.from(i.listeners))t(e)};i.cleanup=()=>{e.removeEventListener(`load`,a),i.listeners.clear()},e.addEventListener(`load`,a),y.set(t,i),b.set(e,i)},ne=e=>{let t=b.get(e);if(t){t.cleanup(),b.delete(e);let n=e.contentWindow;n&&y.get(n)===t&&y.delete(n);return}let n=e.contentWindow;if(!n)return;let r=y.get(n);!r||r.iframe!==e||(r.cleanup(),y.delete(n))},C=e=>{let t=y.get(e);return t?x(t):null},re=(e,t)=>{let n=y.get(e);return n?n.loadedAt===null?new Promise((e,r)=>{let i=window.setTimeout(()=>{n.listeners.delete(a),r(Error(`WaaP iframe navigation timed out after ${Math.round(t/1e3)}s.`))},t),a=t=>{window.clearTimeout(i),n.listeners.delete(a),e(t)};n.listeners.add(a)}):Promise.resolve(x(n)):Promise.resolve(null)},ie=(e,t)=>{let n=y.get(e);return n?(n.listeners.add(t),()=>n.listeners.delete(t)):()=>{}},ae=`waap-wallet-loading-styles`,w=`waap-iframe-visual-ready`,T=typeof window<`u`&&typeof document<`u`,oe=()=>{if(!T||document.getElementById(ae))return;let e=document.createElement(`style`);e.id=ae,e.textContent=`@keyframes waap-loading-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } } @media (prefers-reduced-motion: reduce) { [data-waap-loading-part] { animation: none !important; } }`,document.head.appendChild(e)},se=(e={})=>v(e),E=()=>T?document.getElementById(`waap-wallet-iframe-container`)||document.getElementById(`silk-wallet-iframe-container`):null,D=()=>T?document.getElementById(`waap-wallet-iframe-wrapper`)||document.getElementById(`silk-wallet-iframe-wrapper`):null,O=()=>T?document.getElementById(`waap-wallet-iframe`)||document.getElementById(`silk-wallet-iframe`):null,k=(e=O())=>{let t=Number(e?.dataset.waapVisualRevision??`0`);return Number.isSafeInteger(t)&&t>=0?t:0},ce=(e=O())=>{let t=e?.dataset.waapVisualReadySupported;return t===`true`||t!==`false`&&null},A=(e,t)=>{if(e){if(t===null){delete e.dataset.waapVisualReadySupported;return}e.dataset.waapVisualReadySupported=String(t)}},le=(e,t)=>{let n=e.__silkCleanup;e.__silkCleanup=()=>{n?.(),t()}},ue=e=>{let t=O();if(!t)throw Error(`WaaP iframe does not exist on page`);let n=t.dataset.waapAccountMode;if(n&&n!==e)throw Error(`WaaP iframe is already bound to ${n}; destroy it before initializing ${e}.`);return t.dataset.waapAccountMode=e,t},de=e=>{if(T)try{if(document.querySelector(`link[data-waap-preconnect="${e}"]`))return;let t=document.createElement(`link`);t.rel=`preconnect`,t.href=e,t.crossOrigin=`anonymous`,t.setAttribute(`data-waap-preconnect`,e),document.head.appendChild(t);let n=document.createElement(`link`);n.rel=`dns-prefetch`,n.href=e,n.setAttribute(`data-waap-preconnect`,e),document.head.appendChild(n)}catch{}},fe=(e,t)=>{e.dataset.waapTheme=t?`dark`:`light`},pe=(e,t)=>{let n=e;de(n);let r=document.createElement(`iframe`);return r.id=`waap-wallet-iframe`,r.dataset.waapOrigin=n,fe(r,t),S(r),r.src=`${n}/iframe`,r.allow=`publickey-credentials-get; publickey-credentials-create`,r.style.width=`100%`,r.style.height=`100%`,r.style.border=`none`,r.style.borderRadius=`24px`,r.style.backgroundColor=`transparent`,r.style.background=`transparent`,r.style.padding=`0`,r.style.margin=`0`,r},me=()=>{let e=document.createElement(`div`);return e.id=`waap-wallet-iframe-wrapper`,e.style.position=`relative`,e.style.display=`flex`,e.style.alignItems=`center`,e.style.justifyContent=`center`,e.style.padding=`0`,e.style.margin=`0`,e.style.height=`600px`,e.style.width=`380px`,e},he=()=>{let e=document.createElement(`div`);return e.id=`waap-wallet-iframe-container`,e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.right=`0`,e.style.bottom=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.alignItems=`center`,e.style.justifyContent=`center`,e.style.backgroundColor=`rgba(0, 0, 0, 0.5)`,e.style.zIndex=`9999999999`,e.style.display=`flex`,e.style.visibility=`hidden`,e.style.opacity=`0`,e.style.pointerEvents=`none`,e.style.transition=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`none`:`opacity 140ms ease`,e},ge=(e,t)=>{let n=e,r,i,a,o,s=()=>{if(r=void 0,!o)return;let e=D();e&&e.dataset.waapSizeLocked!==`true`&&(i=o.width,a=o.height,e.style.height=`${o.height}px`,e.style.width=`${o.width}px`,o=void 0)},c=()=>{r===void 0&&(r=window.requestAnimationFrame(s))},l=()=>{!o&&i!==void 0&&a!==void 0&&(o={width:i,height:a}),c()},u=e=>{if(e.origin!==n||e.source!==t.contentWindow||!e.data||typeof e.data!=`object`||e.data.type!==`silk-iframe-size`)return;let r=e.data.height,s=e.data.width,l=2e3;if(typeof r!=`number`||typeof s!=`number`||r<50||r>l||s<50||s>l||!Number.isFinite(r)||!Number.isFinite(s))return;let u=Math.floor(s),d=Math.floor(r);u===i&&d===a||(o={width:u,height:d},c())};window.addEventListener(`message`,u),t.addEventListener(w,l);let d=()=>{r!==void 0&&window.cancelAnimationFrame(r),window.removeEventListener(`message`,u),t.removeEventListener(w,l)};return le(t,d),d},_e=(e,t)=>{let n=()=>{delete t.dataset.waapVisualRevision,delete t.dataset.waapVisualReadyAt,A(t,null)},r=n=>{if(n.origin!==e||n.source!==t.contentWindow||!n.data||typeof n.data!=`object`||n.data.type!==`silk-iframe-visual-ready`)return;let r=n.data.revision;!Number.isSafeInteger(r)||r<=0||r<=k(t)||(t.dataset.waapVisualRevision=String(r),t.dataset.waapVisualReadyAt=String(typeof performance<`u`?performance.now():Date.now()),t.dispatchEvent(new CustomEvent(w,{detail:{revision:r}})))};t.addEventListener(`load`,n),window.addEventListener(`message`,r);let i=()=>{t.removeEventListener(`load`,n),window.removeEventListener(`message`,r)};return le(t,i),i},ve=()=>{setTimeout(()=>{if(typeof document>`u`)return;let e=D();e&&(e.style.height=`600px`,e.style.width=`380px`)},100)},j=e=>{let t=O();if(!t)return!1;let n=t.dataset.waapOrigin??(()=>{try{return new URL(t.src).origin}catch{return}})();if(n&&n!==e)throw Error(`WaaP wallet iframe already exists for ${n}; destroy it before switching to ${e}`);return!0},ye=(e,t)=>{let n=m();if(!n)throw Error(`WaaP component not found in DOM`);if(j(e))return;let r=me(),i=pe(e,t);ge(e,i),_e(e,i),ve(),r.appendChild(i),n.appendChild(r),S(i)},be=(e,t)=>{if(j(e))return;let n=he(),r=me();n.appendChild(r);let i=pe(e,t);ge(e,i),_e(e,i),ve(),r.appendChild(i),document.body.appendChild(n),S(i)},M=(e={})=>{if(!T)return;oe();let t=se(e),n=e.config?.styles?.darkMode===!0,r=O();r&&fe(r,n),p()?ye(t,n):be(t,n)},N=()=>{if(!T)return;Fe();let e=O(),t=e?.__silkCleanup;typeof t==`function`&&t(),e&&ne(e);let n=D(),r=E();r?r.remove():n?.remove(),document.querySelectorAll(`link[data-waap-preconnect]`).forEach(e=>{e.remove()})};let P=0;async function xe(e){let t=Date.now().toString(),n=new TextEncoder().encode(JSON.stringify(e)+t),r=globalThis.crypto;if(r?.subtle?.digest){let e=await r.subtle.digest(`SHA-256`,new Uint8Array(n));return F(new Uint8Array(e))}return P+=1,F(new TextEncoder().encode(`${t}:${P}:${Math.random()}:${JSON.stringify(e)}`)).padEnd(64,`0`).slice(0,64)}function F(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}const I=new WeakMap,Se=(e,t)=>{let n=I.get(e);if(n)return n;let r=t();return I.set(e,r),r.catch(()=>{I.get(e)===r&&I.delete(e)}),r},Ce=e=>{I.delete(e)},L=(e,t={})=>({schemaVersion:1,accountMode:e,sessionProtection:`dpop`,...t.chains?.length?{chains:t.chains}:{},parentOrigin:typeof window>`u`?void 0:window.location?.origin,...t.referralCode?{referralCode:t.referralCode}:{},...t.project?{project:t.project}:{},...t.config?{config:t.config}:{}}),R=new Set;let z=!1,B;const V=new WeakMap,we=(e=256)=>{let t=new Set;return{accept(n){if(t.has(n))return!1;if(t.add(n),t.size>e){let e=t.values().next().value;e&&t.delete(e)}return!0},clear(){t.clear()},size(){return t.size}}},H=e=>{let t=V.get(e);if(t)return t;let n={ready:!1,promise:null,reject:null,cleanup:null,navigationGeneration:null,readyPingStartedAt:null,readyAt:null,readyAttempts:0,visualReadySupported:null,lastError:null};return V.set(e,n),n},U=(e,t)=>{let n=V.get(e);if(!n)return;n.ready=!1,n.cleanup?.(),n.cleanup=null;let r=n.reject;n.reject=null,n.promise=null,n.navigationGeneration=null,n.visualReadySupported=null;let i=O();i?.contentWindow===e&&A(i,null),r?.(t)},Te=()=>typeof performance<`u`?performance.now():Date.now();let Ee=null;const De=()=>Ee,Oe=(n,r,i)=>{let{handleResponse:a,handleRequest:o,onReceiveConnectNotif:s,onAccountChanged:c,onAsyncTxNotification:l,onSquidLifecycleNotification:u}=i;if(n.origin===r.walletOrigin&&n.source===r.getIframeWindow()&&n.data?.target===`silk`)if(n.data?.messageType===t.request)o(n.data);else if(n.data?.messageType===t.response){let e=n.data;r.shouldHandleTerminalResponse(e.id)&&a(e)}else n.data?.messageType===t.notification&&(n.data?.data===e.connect?s?.():n.data?.data?.type===e.account_changed&&c?c(n.data.data.account):(n.data?.data?.type?.startsWith(`waap_sign_`)||n.data?.data?.type?.startsWith(`waap_tx_`))&&l?l({type:n.data.data.type,payload:n.data.data.payload}):n.data?.data?.type?.startsWith(`waap_squid_`)&&u&&u({type:n.data.data.type,payload:n.data.data.payload}))},ke=()=>{z||typeof window>`u`||(z=!0,B=e=>{for(let{manager:t,config:n}of Array.from(R))Oe(e,t,n)},window.addEventListener(`message`,B))},Ae=()=>{R.size>0||!z||!B||typeof window>`u`||(window.removeEventListener(`message`,B),B=void 0,z=!1)};var je=class{constructor(e,t){this.iframeWindow=null,this.unregisterListeners=new Set,this.terminalResponseDeduper=we(),this.unsubscribeIframeNavigation=null,this.disposed=!1,this.iframeWindow=e,this.walletOrigin=typeof t==`string`?t:v(t===!0?{useStaging:!0}:{}),e&&this.observeIframeNavigation(e)}observeIframeNavigation(e){this.unsubscribeIframeNavigation?.(),this.unsubscribeIframeNavigation=ie(e,()=>{let t=H(e);(t.ready||t.readyPingStartedAt!==null)&&(Ce(e),U(e,Error(`WaaP iframe reloaded; readiness must be re-established`)),this.terminalResponseDeduper.clear())})}setIframeWindow(e){this.iframeWindow&&this.iframeWindow!==e&&(U(this.iframeWindow,Error(`Wallet iframe window changed`)),this.terminalResponseDeduper.clear()),this.iframeWindow=e,this.observeIframeNavigation(e)}getIframeWindow(){return this.iframeWindow}isDisposed(){return this.disposed}shouldHandleTerminalResponse(e){return this.terminalResponseDeduper.accept(e)}getHandshakeDiagnostics(){let e=this.iframeWindow,t=e?C(e):null,n=e?H(e):null,r={walletOrigin:this.walletOrigin,iframeNavigationStartedAt:t?.navigationStartedAt??null,iframeLoadedAt:t?.loadedAt??null,readyPingStartedAt:n?.readyPingStartedAt??null,readyAt:n?.readyAt??null,readyAttempts:n?.readyAttempts??0,visualReadySupported:n?.visualReadySupported??null,navigationGeneration:n?.navigationGeneration??null,lastError:n?.lastError??null};return Ee=r,r}postSilkNotification(e){if(!this.iframeWindow)throw Error(`WaaP iframe is not mounted`);this.iframeWindow.postMessage({target:`silk`,messageType:t.notification,data:e},this.walletOrigin)}postReadyNotification(){this.postSilkNotification(e.ready)}postConnectNotification(){this.postSilkNotification(e.connect)}cancelSilkRequest(t,n){this.postSilkNotification({type:e.request_cancel,requestId:t,method:n})}pingIframe(){if(this.disposed)return Promise.reject(Error(`Wallet message manager is disposed`));let n=this.iframeWindow;if(!n||typeof window>`u`)return Promise.reject(Error(`WaaP iframe is not mounted`));let r=H(n),i=C(n);return r.ready&&(!i||r.navigationGeneration===i.generation)?Promise.resolve():(r.ready&&U(n,Error(`WaaP iframe navigation changed; readiness must be re-established`)),r.promise?r.promise:(r.lastError=null,r.readyPingStartedAt=null,r.readyAt=null,r.readyAttempts=0,r.visualReadySupported=null,r.promise=new Promise((i,a)=>{r.reject=a,re(n,3e4).then(i=>{if(this.disposed||this.iframeWindow!==n)throw Error(`Wallet message manager is disposed`);return new Promise((a,o)=>{let s=o=>{if(o.origin===this.walletOrigin&&o.source===n&&o.data?.target===`silk`&&o.data.messageType===t.notification&&o.data.data===e.ready){r.ready=!0,r.navigationGeneration=C(n)?.generation??i?.generation??null,r.readyAt=Te(),r.visualReadySupported=o.data?.capabilities?.visualReady===1;let e=O();e?.contentWindow===n&&A(e,r.visualReadySupported),p(),a()}},c=()=>{try{r.readyAttempts+=1,this.postReadyNotification()}catch(e){p(),o(e)}};r.readyPingStartedAt=Te();let l=250,u,d=()=>{u=window.setTimeout(()=>{c(),l=Math.min(l*2,1e3),d()},l)},f=window.setTimeout(()=>{p(),o(Error(`WaaP wallet ready handshake timed out after 10s.`))},1e4),p=()=>{u!==void 0&&window.clearTimeout(u),window.clearTimeout(f),window.removeEventListener(`message`,s),r.cleanup===p&&(r.cleanup=null,r.reject=null)};r.cleanup=p,r.reject=o,window.addEventListener(`message`,s),c(),d()})}).then(i,a)}),r.promise=r.promise.finally(()=>{r.ready||(r.lastError=r.lastError??`Wallet readiness failed`,r.promise=null)}),r.promise.catch(e=>{r.lastError=e instanceof Error?e.message:String(e)}),r.promise))}async postSilkRequest(e){if(!this.iframeWindow)throw Error(`WaaP iframe is not mounted`);let{silkOptions:n,...r}=e,i={...r,target:`silk`,messageType:t.request,...n&&{silkOptions:n}},a=await xe(i);return this.iframeWindow.postMessage({...i,id:a},this.walletOrigin),a}addListener(e){if(this.disposed)throw Error(`Wallet message manager is disposed`);ke();let t={manager:this,config:e};R.add(t);let n=()=>{this.unregisterListeners.delete(n)&&(R.delete(t),Ae())};return this.unregisterListeners.add(n),n}dispose(){this.disposed||(this.disposed=!0,this.iframeWindow&&U(this.iframeWindow,Error(`Wallet message manager was disposed`)),Array.from(this.unregisterListeners).forEach(e=>e()),this.terminalResponseDeduper.clear(),this.unsubscribeIframeNavigation?.(),this.unsubscribeIframeNavigation=null,this.iframeWindow=null)}};const W=`waap-wallet-iframe-loading`,G=new Set,K=()=>typeof performance<`u`?performance.now():Date.now(),q=e=>{G.forEach(t=>{try{t(e)}catch{}})},Me=e=>(G.add(e),()=>G.delete(e));var Ne=class{constructor(e){this.pendingRevision=null,this.phase=`idle`,this.requestedAt=null,this.visibleAt=null,this.usedVisualFallback=!1,this.onVisualReady=e=>{let t=e.detail?.revision;this.pendingRevision!==null&&typeof t==`number`&&t>=this.pendingRevision&&this.revealIframe(!1)},this.iframe=e,e.addEventListener(w,this.onVisualReady)}show({layout:e=`signing`}={}){if(this.phase===`pending`||this.phase===`visible`)return;let t=D();if(!t)return;this.clearFallbackTimer();let n=this.moveToCurrentMode(t);n===`modal`&&e===`signing`?(t.dataset.waapSizeLocked=`true`,t.style.width=`380px`,t.style.height=`600px`):n===`modal`&&delete t.dataset.waapSizeLocked,this.pendingRevision=k(this.iframe)+1,this.phase=`pending`,this.requestedAt=K(),this.visibleAt=null,this.usedVisualFallback=!1,q({phase:`modal_requested`,at:this.requestedAt,visualRevision:this.pendingRevision}),this.hideIframeUntilPaint(t),n===`modal`?this.showModalSurface():t.style.display=`flex`;let r=ce(this.iframe);if(r===!1){this.revealIframe(!0);return}this.fallbackTimer=window.setTimeout(()=>{this.revealIframe(!0)},r===!0?3e3:750)}hide(){let e=this.pendingRevision!==null;this.pendingRevision=null,this.clearFallbackTimer(),this.phase=`hidden`;let t=K();e&&q({phase:`modal_cancelled`,at:t,visualRevision:k(this.iframe)}),q({phase:`modal_hidden`,at:t,visualRevision:k(this.iframe)});let n=D();if(n&&delete n.dataset.waapSizeLocked,p()){n&&(n.style.display=`none`);return}let r=E();r&&(r.style.opacity=`0`,r.style.visibility=`hidden`,r.style.pointerEvents=`none`)}dispose(){this.clearFallbackTimer(),this.iframe.removeEventListener(w,this.onVisualReady)}isFor(e){return this.iframe===e}getDiagnostics(){return{modalPhase:this.phase,modalRequestedAt:this.requestedAt,modalVisibleAt:this.visibleAt,usedVisualFallback:this.usedVisualFallback}}moveToCurrentMode(e){if(p()){let t=m();return t&&e.parentElement!==t&&t.appendChild(e),`component`}let t=E();return t||(t=he(),document.body.appendChild(t)),e.parentElement!==t&&t.appendChild(e),`modal`}showModalSurface(){let e=E();e&&(e.style.display=`flex`,e.style.visibility=`visible`,e.style.opacity=`1`,e.style.pointerEvents=`auto`)}hideIframeUntilPaint(e){e.style.display=`flex`,e.style.visibility=`visible`,e.style.opacity=`1`,e.style.pointerEvents=`auto`,this.iframe.style.visibility=`hidden`,this.iframe.style.opacity=`0`,this.iframe.style.pointerEvents=`none`,this.ensureLoadingIndicator(e).style.display=`flex`}revealIframe(e){if(this.pendingRevision===null)return;let t=k(this.iframe);this.pendingRevision=null,this.clearFallbackTimer(),this.phase=`visible`,this.visibleAt=K(),this.usedVisualFallback=e,q({phase:`modal_visible`,at:this.visibleAt,visualRevision:t,fallback:e});let n=D();if(!n)return;delete n.dataset.waapSizeLocked;let r=n.querySelector(`#${W}`);r&&(r.style.display=`none`),this.iframe.style.visibility=`visible`,this.iframe.style.opacity=`1`,this.iframe.style.pointerEvents=`auto`,n.style.visibility=`visible`,n.style.opacity=`1`,n.style.pointerEvents=`auto`}ensureLoadingIndicator(e){let t=e.querySelector(`#${W}`);if(t)return this.applyLoadingTheme(t),t;t=document.createElement(`div`),t.id=W,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-label`,`Loading WaaP wallet`),t.style.position=`absolute`,t.style.inset=`0`,t.style.zIndex=`1`,t.style.display=`none`,t.style.flexDirection=`column`,t.style.borderRadius=`24px`,t.style.fontFamily=`system-ui, sans-serif`,t.style.fontSize=`14px`,t.style.pointerEvents=`none`;let n=document.createElement(`div`);n.style.boxSizing=`border-box`,n.style.display=`flex`,n.style.flexDirection=`column`,n.style.width=`100%`,n.style.height=`100%`,n.style.padding=`24px`;let r=document.createElement(`img`),i=this.iframe.dataset.waapOrigin;i&&(r.src=`${i}/assets/svg/waaplogo.svg`),r.alt=`WaaP`,r.width=66,r.height=25,r.style.alignSelf=`center`,r.style.width=`66px`,r.style.height=`25px`,r.style.marginBottom=`20px`,r.dataset.waapLoadingLogo=`true`;let a=(e,t,n,r)=>{let i=document.createElement(`div`);return i.setAttribute(`aria-hidden`,`true`),i.dataset.waapLoadingPart=e,i.style.width=t,i.style.height=n,i.style.flexShrink=`0`,i.style.borderRadius=r,i.style.backgroundSize=`200% 100%`,i.style.animation=`waap-loading-shimmer 2.4s ease-in-out infinite`,i},o=a(`request-title`,`156px`,`16px`,`999px`);o.style.marginTop=`34px`;let s=a(`request-body`,`100%`,`220px`,`12px`);s.style.flex=`1`,s.style.marginTop=`18px`,s.style.opacity=`.58`;let c=document.createElement(`div`);return c.dataset.waapLoadingPart=`actions`,c.setAttribute(`aria-hidden`,`true`),c.style.display=`flex`,c.style.gap=`10px`,c.append(a(`cancel-action`,`calc(50% - 5px)`,`48px`,`12px`),a(`confirm-action`,`calc(50% - 5px)`,`48px`,`12px`)),n.append(r,o,s,c),t.appendChild(n),e.appendChild(t),this.applyLoadingTheme(t),t}applyLoadingTheme(e){let t=this.iframe.dataset.waapTheme===`dark`;e.dataset.waapTheme=t?`dark`:`light`,e.style.background=t?`#121212`:`#ffffff`,e.style.color=t?`#e6e6e6`:`#000000`;let n=e.querySelector(`[data-waap-loading-logo]`);n&&(n.style.filter=t?`invert(1)`:`none`);let r=t?`linear-gradient(90deg, rgba(255,255,255,.07), rgba(255,255,255,.14), rgba(255,255,255,.07))`:`linear-gradient(90deg, rgba(0,0,0,.05), rgba(0,0,0,.1), rgba(0,0,0,.05))`;e.querySelectorAll(`[data-waap-loading-part]`).forEach(e=>{e.style.background=r})}clearFallbackTimer(){this.fallbackTimer!==void 0&&(window.clearTimeout(this.fallbackTimer),this.fallbackTimer=void 0)}};let J;const Pe=()=>{let e=O();return e?(J&&!J.isFor(e)&&(J.dispose(),J=void 0),J??=new Ne(e),J):null},Y=e=>{Pe()?.show(e)},X=()=>{Pe()?.hide()},Fe=()=>{J?.dispose(),J=void 0},Ie=()=>{let e=O(),t=e?.contentWindow?C(e.contentWindow):null,n=J?.getDiagnostics(),r=Number(e?.dataset.waapVisualReadyAt??``);return{walletOrigin:e?.dataset.waapOrigin??null,iframeNavigationStartedAt:t?.navigationStartedAt??null,iframeLoadedAt:t?.loadedAt??null,visualRevision:k(e),visualReadyAt:Number.isFinite(r)?r:null,modalPhase:n?.modalPhase??`idle`,modalRequestedAt:n?.modalRequestedAt??null,modalVisibleAt:n?.modalVisibleAt??null,usedVisualFallback:n?.usedVisualFallback??!1,handshake:De()}},Le=new Set([r.eth_sendTransaction,r.eth_signTransaction,r.personal_sign,r.eth_signTypedData_v4]),Re=e=>Le.has(e);function ze(e){return new Promise((t,n)=>{let r,i=!1,a=()=>{r!==void 0&&clearTimeout(r),e.eventEmitter.removeListener(e.id,o),e.signal?.removeEventListener(`abort`,c)},o=e=>{i||(i=!0,a(),t(e))},s=t=>{i||(i=!0,a(),e.onCancel?.(),n(Error(t)))},c=()=>s(`WaaP request cancelled: ${e.method}`);if(e.signal?.aborted){c();return}e.interactionRequired||(r=setTimeout(()=>{s(`WaaP request timed out: ${e.method}`)},e.timeoutMs??3e4)),e.eventEmitter.once(e.id,o),e.signal?.addEventListener(`abort`,c,{once:!0})})}async function Z(e,t,r,i,a){let o=e.method,s=e.params,{timeoutMs:c,signal:l,...u}=a??{};t&&Y({layout:o===n.login?`auth`:`signing`});let d;try{d=await r.postSilkRequest({method:o,params:s,interactionRequired:t,silkOptions:a?u:void 0});let e=await ze({eventEmitter:i,id:d,method:o,interactionRequired:t,timeoutMs:c,signal:l,onCancel:()=>{r.cancelSilkRequest(d,o),t&&X()}});if(t&&X(),e.error)throw e.error;return e.data}catch(e){throw t&&d===void 0&&X(),e}}const Be=(e,t={})=>{if(typeof window>`u`)return()=>void 0;let n=!1,r,i,a=window,o=()=>{n||e.preload().catch(e=>t.onError?.(e))};return typeof a.requestIdleCallback==`function`?r=a.requestIdleCallback(o,{timeout:t.timeoutMs??2e3}):i=window.setTimeout(o,0),()=>{n=!0,r!==void 0&&a.cancelIdleCallback?.(r),i!==void 0&&window.clearTimeout(i)}};var Q=function(e){return e.show_modal=`show_modal`,e.hide_modal=`hide_modal`,e}(Q||{}),Ve=class extends a{constructor(){super()}};function He(e){return!(!e?.isMetaMask||e.isApexWallet||e.isAvalanche||e.isBitKeep||e.isBlockWallet||e.isMathWallet||e.isOkxWallet||e.isOKExWallet||e.isOneInchIOSWallet||e.isOneInchAndroidWallet||e.isOpera||e.isPortal||e.isRabby||e.isDefiant||e.isTokenPocket||e.isTokenary||e.isZerion)}function Ue(e){try{if(!e||!Array.isArray(e))return!1;let t=JSON.parse(typeof e[1]==`string`?e[1]:JSON.stringify(e[1]));return t.primaryType===`SafeTx`&&t.domain?.verifyingContract!==void 0&&t.message&&`to`in t.message&&`value`in t.message&&`safeTxGas`in t.message&&`baseGas`in t.message&&`gasPrice`in t.message&&`nonce`in t.message}catch{return!1}}const We={styles:{darkMode:!1}},$=[`waap`,`human`,`injected`,`walletconnect`],Ge=[r.eth_sendTransaction,r.eth_signTransaction,r.eth_signTypedData_v4,r.personal_sign];function Ke(e){if(e==null)return null;if(typeof e==`string`){if($.includes(e))return e;throw Error(`[EthereumProvider] Unexpected login method: "${e}". Expected one of: ${$.join(`, `)}`)}if(typeof e==`object`&&`loginMethod`in e&&typeof e.loginMethod==`string`){let t=e.loginMethod;if(console.warn(`[EthereumProvider] Received object login response. Normalizing "${t}" to string. This is unexpected for the web SDK.`),$.includes(t))return t;throw Error(`[EthereumProvider] Unknown loginMethod in object: "${t}". Expected one of: ${$.join(`, `)}`)}throw Error(`[EthereumProvider] Unexpected login response: ${JSON.stringify(e)} (type: ${typeof e})`)}var qe=class extends a{constructor(e,t,r,i,o,s=!1,c=!1,l,u=[`evm`]){super(),this.lastKnownConversion=`pending`,this.isSilk=!0,this.isWaaP=!0,this.connected=!1,this.currentAccount=null,this.accountMode=`tap`,this.walletConnectProvider=null,this.asyncTxs=!1,this.legacyAsyncSigning=!1,this.internalEventEmitter=new a,this.iframeMounted=!0,this.initializerPromise=null,this.sessionProbe=null,this.initializedIframeWindow=null,this.asyncTxs=s,this.legacyAsyncSigning=c,this.ensureIframe=l,this.iframeMounted=!l,this.referralCode=t,this.project=i,this.customConfig=r,this.initializerChains=u,this.uiMessageManager=new Ve,this.walletMessageManager=new je(e,o),this.config={...We,...r||{}},this.persistedMethods={login:this.login.bind(this),logout:this.logout.bind(this),getLoginMethod:this.getLoginMethod.bind(this),walletMessageManager:this.walletMessageManager,internalEventEmitter:this.internalEventEmitter,uiMessageManager:this.uiMessageManager,portal:this.portal.bind(this),requestEmail:this.requestEmail.bind(this),requestSBT:this.requestSBT.bind(this),requestPermissionToken:this.requestPermissionToken.bind(this),getLinkedAddresses:this.getLinkedAddresses.bind(this),linkAddress:this.linkAddress.bind(this),unlinkAddress:this.unlinkAddress.bind(this),orcid:this.orcid.bind(this),enable:this.enable.bind(this),isConnected:this.isConnected.bind(this),toggleDarkMode:this.toggleDarkMode.bind(this),destroy:this.destroy.bind(this),silkRequest:this.request.bind(this),waaPRequest:this.request.bind(this)},this.walletMessageManager.addListener({onReceiveConnectNotif:()=>{this.connected=!0,this.emit(`connect`)},handleResponse:e=>this.internalEventEmitter.emit(e.id,e),handleRequest:e=>{e.method===n.show_modal?this.uiMessageManager.emit(`show_modal`):e.method===n.hide_modal&&this.uiMessageManager.emit(`hide_modal`)},onAccountChanged:e=>{this.currentAccount!==e&&(this.currentAccount=e,this.emit(`accountsChanged`,e?[e]:[]))},onAsyncTxNotification:e=>{this.emit(e.type,e.payload)},onSquidLifecycleNotification:e=>{this.emit(e.type,e.payload)}})}async initializeWalletConnect(){try{this.walletConnectProvider=await i.getInstance()}catch(e){console.error(`Failed to initialize WalletConnect provider:`,e),this.walletConnectProvider=null}}async initializeIframeContext(){let e=this.walletMessageManager.getIframeWindow();if(!e)throw Error(`WaaP iframe is not mounted`);if(this.initializedIframeWindow===e&&this.initializerPromise)return this.initializerPromise;this.initializedIframeWindow=e,this.initializerPromise=Se(e,async()=>{await this.walletMessageManager.pingIframe(),await Z({method:n.set_signing_mode,params:[L(this.accountMode,{referralCode:this.referralCode,project:this.project,config:this.customConfig,chains:this.initializerChains})]},!1,this.walletMessageManager,this.internalEventEmitter)});try{await this.initializerPromise}catch(e){throw this.initializerPromise=null,this.initializedIframeWindow=null,e}}async reassertIframeAccountMode(){this.ensureIframeMounted(),await this.walletMessageManager.pingIframe(),await Z({method:n.set_signing_mode,params:[L(this.accountMode,{referralCode:this.referralCode,project:this.project,config:this.customConfig,chains:this.initializerChains})]},!1,this.walletMessageManager,this.internalEventEmitter)}ensureIframeMounted(){if(this.iframeMounted||!this.ensureIframe)return;let e=this.ensureIframe();e&&(this.iframeMounted=!0,this.walletMessageManager.setIframeWindow(e))}async ensureInitialized(){this.ensureIframeMounted(),await this.initializeIframeContext()}async preload(){await this.ensureInitialized()}async enable(){return this.request({method:`eth_requestAccounts`})}isConnected(){return this.connected}getAccountStatus(){let e=this.getLoginMethod();return{authenticated:e!==null,loginMethod:e,activeMode:e?this.accountMode:null,mode:this.accountMode,conversion:e?this.lastKnownConversion:`not_required`,tap:null,squid:null,accounts:this.currentAccount?{evm:this.currentAccount}:{}}}get session(){return{login:e=>this.login(e),logout:async()=>{await this.logout()},getLoginMethod:()=>this.getLoginMethod(),getAccountStatus:()=>this.getCanonicalAccountStatus()}}async getCanonicalAccountStatus(){await this.ensureInitialized();let e=await Z({method:n.waap_getAccountStatus,params:[]},!1,this.walletMessageManager,this.internalEventEmitter);return e?.conversion&&(this.lastKnownConversion=e.conversion),e}setAccountMode(e){this.accountMode=e,this.initializerPromise=null,this.initializedIframeWindow=null}async request(e){if(!Object.keys(r).includes(e.method))return Promise.reject({error:`Not implemented (${e.method})`});let t=await this.attemptAutoConnect(e.method);if(t!==null)return t;if(Ge.includes(e.method)&&!(this.getLoginMethod()!==null||await this.restorePersistedWaaPSession()!==null))return Promise.reject(new s(`not_authenticated`,`Not authenticated: call login() before signing.`,{operation:{chain:`evm`,method:e.method}}));if(Ue(e.params)&&e.method!==r.eth_signTypedData_v4)return Promise.reject({error:`Safe transactions must be signed using eth_signTypedData_v4`});await this.ensureInitialized();let n=(e.method===r.eth_sendTransaction||e.method===r.eth_signTransaction||e.method===r.eth_signTypedData_v4||e.method===r.personal_sign)&&this.asyncTxs||e.async,i=n||e.withPT||e.timeoutMs!==void 0||e.signal?this.legacyAsyncSigning?{asyncSigning:n||void 0,withPT:e.withPT,timeoutMs:e.timeoutMs,signal:e.signal}:{async:n,withPT:e.withPT,timeoutMs:e.timeoutMs,signal:e.signal}:void 0,a=await Z(e,Re(e.method),this.walletMessageManager,this.internalEventEmitter,i);if((e.method===r.wallet_switchEthereumChain||e.method===r.wallet_addEthereumChain)&&a===null){this.emit(`chainChanged`,e.params?.[0]?.chainId);try{let t=await this.request({method:`eth_accounts`});t&&t.length>0&&(this.currentAccount=t[0],this.emit(`accountsChanged`,t),this.emit(`connect`,{chainId:e.params?.[0]?.chainId}))}catch(t){console.warn(`[EthereumProvider] Failed to get accounts after chain switch:`,t),this.currentAccount&&(this.emit(`accountsChanged`,[this.currentAccount]),this.emit(`connect`,{chainId:e.params?.[0]?.chainId}))}}return e.method===r.eth_requestAccounts&&Array.isArray(a)&&typeof a[0]==`string`&&(this.currentAccount=a[0],this.connected=!0,typeof window<`u`&&typeof localStorage<`u`&&localStorage.setItem(`${window.location.origin}-connected`,`waap`),this.emit(`accountsChanged`,a),this.emit(`connect`)),a}async login(e){if(typeof window>`u`||typeof document>`u`)return null;let t=e&&!(`request`in e)?e:void 0,r=t?t.customProvider:e;if(await this.ensureInitialized(),!t?.force&&await this.restorePersistedWaaPSession())return this.getLoginMethod()??`waap`;let a=r||window.ethereum,o=a&&He(a)?`MetaMask`:`Browser Wallet`,s=Ke(await Z({method:n.login,params:[o]},!0,this.walletMessageManager,this.internalEventEmitter));if(s===null)return null;switch(s){case`waap`:case`human`:localStorage.setItem(`${window.location.origin}-connected`,`waap`),this.setupWaaP();break;case`injected`:a&&(localStorage.setItem(`${window.location.origin}-connected`,`injected`),this.setupInjectedWallet(a));break;case`walletconnect`:{localStorage.setItem(`${window.location.origin}-connected`,`walletconnect`),this.walletConnectProvider||await this.initializeWalletConnect(),i.isConnected()||(await this.walletConnectProvider.open({view:`Connect`}),await i.listenToAccountChangeEvent());let e=i.getWalletProvider();this.setupWalletConnect(e);break}}return s}async logout(){await this.ensureInitialized(),this.cleanupInvalidLoginState(),this.lastKnownConversion=`pending`,this.currentAccount=null,this.connected=!1,this.emit(`accountsChanged`,[]),this.emit(`disconnect`);try{this.walletConnectProvider&&await this.walletConnectProvider.disconnect()}catch(e){console.error(`Error disconnecting from WalletConnect:`,e)}return Z({method:n.logout},!1,this.walletMessageManager,this.internalEventEmitter)}destroy(){if(this.walletMessageManager.dispose(),this.internalEventEmitter.removeAllListeners(),this.uiMessageManager.removeAllListeners(),this.removeAllListeners(),this.connected=!1,this.walletConnectProvider&&=(this.walletConnectProvider.disconnect().catch(()=>void 0),null),typeof window<`u`){let e=window;(e.silk===this||e.silk?.walletMessageManager===this.walletMessageManager)&&delete e.silk,(e.waap===this||e.waap?.walletMessageManager===this.walletMessageManager)&&delete e.waap}N()}cleanupInvalidLoginState(){try{localStorage.removeItem(`${window.location.origin}-connected`)}catch(e){console.warn(`Could not clean up login state:`,e)}}setupWaaP(){let e={...this.persistedMethods,isWaaP:!0,on:this.on.bind(this),removeListener:this.removeListener.bind(this),request:this.request.bind(this)};window.silk=e,window.waap=e}setupInjectedWallet(e){let t={...this.persistedMethods,...e,isSilk:!0,connected:e.connected??!1,on:e.on?.bind(e)??(()=>{}),removeListener:e.removeListener?.bind(e)??(()=>{}),request:e.request.bind(e)};window.silk=t,window.waap=t}setupWalletConnect(e){let t={...this.persistedMethods,...e,isSilk:!0,connected:!0,on:e.on?.bind(e)??(()=>{}),removeListener:e.removeListener?.bind(e)??(()=>{}),request:e.request.bind(e)};window.silk=t,window.waap=t}setupAutoConnectInjected(e){let t={...this.persistedMethods,...e,isSilk:!1,connected:e.isConnected?.()??!1,on:e.on?.bind(e)??(()=>{}),removeListener:e.removeListener?.bind(e)??(()=>{}),request:e.request.bind(e)};window.silk=t,window.waap=t}setupAutoConnectWalletConnect(e){let t={...this.persistedMethods,...e,isSilk:!1,connected:!0,on:e.on?.bind(e)??(()=>{}),removeListener:e.removeListener?.bind(e)??(()=>{}),request:e.request.bind(e)};window.silk=t,window.waap=t}async attemptAutoConnect(e){if(e!==`eth_requestAccounts`&&e!==`eth_accounts`)return null;let t=this.getLoginMethod();if(t===`waap`||t===`human`){let e=await this.restorePersistedWaaPSession();if(e)return e}if(t===`injected`&&window.ethereum)try{return this.setupAutoConnectInjected(window.ethereum),window.ethereum.request({method:`eth_requestAccounts`})}catch(e){return console.warn(`Injected wallet auto-connect failed:`,e),this.cleanupInvalidLoginState(),null}else if(t===`walletconnect`)try{if(this.walletConnectProvider||=await i.getInstance(),await i.waitForReadyAndCheckConnection()){let e=i.getWalletProvider();return this.setupAutoConnectWalletConnect(e),e.request({method:`eth_requestAccounts`})}else return this.cleanupInvalidLoginState(),null}catch(e){return console.warn(`WalletConnect auto-connect failed:`,e),this.cleanupInvalidLoginState(),null}return null}restorePersistedWaaPSession(){return this.sessionProbe??=this.probeWaaPSession().finally(()=>{this.sessionProbe=null}),this.sessionProbe}async probeWaaPSession(){try{if(await this.ensureInitialized(),!(await this.getCanonicalAccountStatus()).authenticated)return this.cleanupInvalidLoginState(),null;let e=await Z({method:n.auto_conn,params:[window.location.origin]},!1,this.walletMessageManager,this.internalEventEmitter);if(Array.isArray(e)&&e.length>0)return this.currentAccount=e[0],this.connected=!0,localStorage.setItem(`${window.location.origin}-connected`,`waap`),this.setupWaaP(),e}catch(e){console.warn(`WaaP session probe failed:`,e)}return this.cleanupInvalidLoginState(),null}getLoginMethod(){if(typeof window>`u`||typeof localStorage>`u`)return null;try{let e=localStorage.getItem(`${window.location.origin}-connected`);if(!e)return null;if(![`waap`,`human`,`injected`,`walletconnect`].includes(e))return this.cleanupInvalidLoginState(),null;switch(e){case`injected`:return window.ethereum?`injected`:(this.cleanupInvalidLoginState(),null);case`walletconnect`:try{return i.isConnected()?`walletconnect`:(this.cleanupInvalidLoginState(),null)}catch{return this.cleanupInvalidLoginState(),null}case`waap`:return`waap`;case`human`:return`human`;default:return this.cleanupInvalidLoginState(),null}}catch(e){return console.warn(`Error checking login method:`,e),this.cleanupInvalidLoginState(),null}}async toggleDarkMode(){this.config.styles.darkMode=!this.config.styles.darkMode,await this.ensureInitialized();try{await Z({method:n.set_custom_config,params:[this.config]},!1,this.walletMessageManager,this.internalEventEmitter)}catch(e){console.error(`Error setting custom config in Silk iframe:`,e)}}async safe(){await this.ensureInitialized(),await Z({method:n.safe},!0,this.walletMessageManager,this.internalEventEmitter)}async orcid(){await this.ensureInitialized(),await Z({method:n.orcid},!0,this.walletMessageManager,this.internalEventEmitter)}async portal(e,t,r){await this.ensureInitialized();let i;switch(t){case`get`:i=e===`gastank`?n.gastank_get_settings:n.customization_get;break;case`update`:i=e===`gastank`?n.gastank_update_settings:n.customization_update;break;case`topup`:i=n.gastank_topup;break;case`init`:i=n.project_init;break}let a=t!==`get`&&e!==`customization`;return Z({method:i,params:[r,window.location.origin]},a,this.walletMessageManager,this.internalEventEmitter)}async requestEmail(){return await this.ensureInitialized(),Z({method:n.silk_requestEmail},!0,this.walletMessageManager,this.internalEventEmitter)}async requestPermissionToken(e){await this.ensureInitialized();let t={...e,walletMode:this.accountMode};return Z({method:n.waap_requestPermissionToken,params:[t]},!0,this.walletMessageManager,this.internalEventEmitter)}async getPermissionTokenStatus(e){return await this.ensureInitialized(),await Z({method:n.waap_getPermissionTokenStatus,params:[e]},!1,this.walletMessageManager,this.internalEventEmitter)}async clearPermissionToken(e){return await this.ensureInitialized(),await Z({method:n.waap_clearPermissionToken,params:[e]},!1,this.walletMessageManager,this.internalEventEmitter)}async requestSBT(e){return await this.ensureInitialized(),Z({method:n.silk_requestSbt,params:[e]},!0,this.walletMessageManager,this.internalEventEmitter)}async getLinkedAddresses(){return await this.walletMessageManager.pingIframe(),(await Z({method:n.waap_getLinkedAddresses,params:[]},!1,this.walletMessageManager,this.internalEventEmitter)).addresses}async linkAddress(e){if(typeof window>`u`)throw Error(`linkAddress requires a browser environment`);this.walletConnectProvider||await this.initializeWalletConnect(),i.isConnected()||(await this.walletConnectProvider.open({view:`Connect`}),await i.listenToAccountChangeEvent());let t=i.getWalletProvider();if(!t)throw Error(`No wallet provider available after connection`);let r=(await t.request({method:`eth_accounts`}))[0];if(!r||r.toLowerCase()!==e.toLowerCase())throw Error(`Connected wallet account ${r??`(none)`} does not match requested address ${e}`);await this.walletMessageManager.pingIframe();let a=await Z({method:n.waap_getLinkAddressNonce,params:[]},!1,this.walletMessageManager,this.internalEventEmitter),o=Je({domain:window.location.host,address:e,uri:window.location.origin,nonce:a.nonce,issuedAt:new Date().toISOString()}),s=await t.request({method:`personal_sign`,params:[o,e]});return(await Z({method:n.waap_linkAddress,params:[{message:o,signature:s}]},!1,this.walletMessageManager,this.internalEventEmitter)).addresses}async unlinkAddress(e){return await this.walletMessageManager.pingIframe(),(await Z({method:n.waap_unlinkAddress,params:[{address:e}]},!1,this.walletMessageManager,this.internalEventEmitter)).addresses}};function Je(e){let t=o(e.address);return`${`${e.domain} wants you to sign in with your Ethereum account:\n${t}`}\n\nLink this wallet to your Human Wallet account.\n\n${[`URI: ${e.uri}`,`Version: 1`,`Chain ID: 1`,`Nonce: ${e.nonce}`,`Issued At: ${e.issuedAt}`].join(`
2
+ `)}`}const Ye=(e,t,n=!0,r=[`evm`],a=!0)=>{let{referralCode:o,config:s,project:c,asyncTxs:l,asyncSigning:u,deferIframe:d}=e,f=v(e),p=!!u&&!l;e.walletConnectProjectId&&i.setProjectId(e.walletConnectProjectId),u&&!l&&console.warn("[WaaP SDK] `asyncSigning` is deprecated. Use `asyncTxs` instead.");let m=typeof window>`u`||typeof document>`u`,h=()=>typeof window>`u`||typeof document>`u`?null:(M(e),ue(t).contentWindow),g=d===!1&&!m,ee=d===void 0&&!m,_=g?h():null;if(g&&!_)throw Error(`WaaP iframe does not exist on page`);let y=new qe(_,o,s||{},c||{},f,l||u||!1,p,g?void 0:h,r);if(y.setAccountMode(t),!m&&n&&g&&y.initializeIframeContext().catch(()=>void 0),y.uiMessageManager.on(`show_modal`,()=>{Y()}),y.uiMessageManager.on(`hide_modal`,()=>{X()}),!m&&a&&(window.silk=y,window.waap=y),n&&ee){let e=Be(y),t=y.destroy.bind(y);y.destroy=()=>{e(),t()}}return y},Xe=(e={})=>Ye(e,`tap`);export{f as C,_ as S,c as T,Se as _,Ve as a,N as b,Z as c,Ie as d,X as f,L as g,je as h,We as i,Re as l,Me as m,Ye as n,Q as o,Y as p,qe as r,Be as s,Xe as t,ze as u,ue as v,s as w,v as x,M as y};