@swype-org/deposit 0.3.6 → 0.3.14

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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-DJikyy3z.js';
2
- export { C as CheckoutConfig, e as CheckoutError, f as CheckoutErrorCode, g as CheckoutStatus, h as DepositErrorCode, S as SignerFunction, i as SignerRequest, j as SignerResponse, T as TransferSummary, k as getDisplayMessage } from './types-DJikyy3z.js';
1
+ import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-DYsZwNXq.js';
2
+ export { C as CheckoutConfig, e as CheckoutError, f as CheckoutErrorCode, g as CheckoutStatus, h as DepositErrorCode, S as SignerFunction, i as SignerRequest, j as SignerResponse, T as TransferSummary, k as getDisplayMessage } from './types-DYsZwNXq.js';
3
3
 
4
4
  declare const DEFAULT_WEBVIEW_BASE_URL = "https://pay.blink.cash";
5
5
  type EventMap = {
@@ -73,6 +73,162 @@ declare class Deposit {
73
73
  /** @deprecated Use {@link Deposit} instead. */
74
74
  declare const Checkout: typeof Deposit;
75
75
 
76
+ /** Current wire-protocol version. Bump on breaking changes. */
77
+ declare const BRIDGE_PROTOCOL_VERSION = 1;
78
+ interface EIP6963ProviderInfo {
79
+ uuid: string;
80
+ name: string;
81
+ icon: string;
82
+ rdns: string;
83
+ }
84
+ interface EIP1193RequestArgs {
85
+ method: string;
86
+ params?: unknown[] | Record<string, unknown>;
87
+ }
88
+ interface EIP1193Provider {
89
+ request(args: EIP1193RequestArgs): Promise<unknown>;
90
+ on?: (event: string, listener: (...args: unknown[]) => void) => unknown;
91
+ removeListener?: (event: string, listener: (...args: unknown[]) => void) => unknown;
92
+ }
93
+ interface EIP6963ProviderDetail {
94
+ info: EIP6963ProviderInfo;
95
+ provider: EIP1193Provider;
96
+ }
97
+ /** Iframe → Parent: handshake, sent once on mount. */
98
+ interface BridgeHelloMessage {
99
+ type: 'blink:bridge-hello';
100
+ protocolVersion: number;
101
+ }
102
+ /** Parent → Iframe: list of installed wallets the iframe can borrow. */
103
+ interface WalletsAdvertisedMessage {
104
+ type: 'blink:wallets-advertised';
105
+ protocolVersion: number;
106
+ wallets: AdvertisedWallet[];
107
+ }
108
+ interface AdvertisedWallet {
109
+ uuid: string;
110
+ rdns: string;
111
+ name: string;
112
+ icon: string;
113
+ }
114
+ /** Iframe → Parent: invoke a JSON-RPC method on a top-frame wallet. */
115
+ interface RpcRequestMessage {
116
+ type: 'blink:rpc-request';
117
+ protocolVersion: number;
118
+ uuid: string;
119
+ id: string;
120
+ method: string;
121
+ params?: unknown[] | Record<string, unknown>;
122
+ }
123
+ /** Parent → Iframe: result of a previous `RpcRequestMessage`. */
124
+ interface RpcResponseMessage {
125
+ type: 'blink:rpc-response';
126
+ protocolVersion: number;
127
+ id: string;
128
+ result?: unknown;
129
+ error?: {
130
+ code: number;
131
+ message: string;
132
+ data?: unknown;
133
+ };
134
+ }
135
+ /** Parent → Iframe: forwarded EIP-1193 event from a top-frame wallet. */
136
+ interface RpcEventMessage {
137
+ type: 'blink:rpc-event';
138
+ protocolVersion: number;
139
+ uuid: string;
140
+ event: string;
141
+ args: unknown[];
142
+ }
143
+ /**
144
+ * Iframe → Parent: ask "which advertised wallet has any of these flags
145
+ * (e.g. `isUniswapWallet`) set as a truthy property on its provider?".
146
+ * Used to disambiguate Reown registry entries that lack `rdns` (e.g.
147
+ * Uniswap, where Reown only ships `injected[].injectedId:
148
+ * 'isUniswapWallet'`). The parent reads `provider[flag]` defensively
149
+ * for each advertised provider and returns the first hit, or null.
150
+ *
151
+ * The parent answers each request once; the response is matched by
152
+ * `id`. Cost is local property reads on already-discovered providers —
153
+ * no network and no cross-frame I/O beyond the postMessage round-trip.
154
+ */
155
+ interface ResolveByFlagRequestMessage {
156
+ type: 'blink:resolve-by-flag';
157
+ protocolVersion: number;
158
+ /** Request id, mirrored on the response so the iframe can route it. */
159
+ id: string;
160
+ /** Flag names to test in order; first truthy property wins. */
161
+ flags: string[];
162
+ }
163
+ /** Parent → Iframe: result of a previous `ResolveByFlagRequestMessage`. */
164
+ interface ResolveByFlagResponseMessage {
165
+ type: 'blink:resolve-by-flag-response';
166
+ protocolVersion: number;
167
+ id: string;
168
+ /** `null` when no advertised provider had any flag set. */
169
+ match: ResolveByFlagMatch | null;
170
+ }
171
+ interface ResolveByFlagMatch {
172
+ /** EIP-6963 `rdns` of the matched provider. */
173
+ rdns: string;
174
+ /** EIP-6963 `uuid` of the matched provider. */
175
+ uuid: string;
176
+ /** Which flag matched first (lets the caller log/telemeter). */
177
+ flag: string;
178
+ }
179
+ type BridgeMessage = BridgeHelloMessage | WalletsAdvertisedMessage | RpcRequestMessage | RpcResponseMessage | RpcEventMessage | ResolveByFlagRequestMessage | ResolveByFlagResponseMessage;
180
+ declare const ALLOWED_RPC_METHODS: Set<string>;
181
+ declare function parseBridgeMessage(data: unknown): BridgeMessage | null;
182
+
183
+ interface RegisteredProvider {
184
+ info: EIP6963ProviderInfo;
185
+ provider: EIP1193Provider;
186
+ }
187
+ interface WalletDiscovererHandle {
188
+ /** Snapshot of currently-registered providers. */
189
+ list(): RegisteredProvider[];
190
+ /** Look up a single provider by EIP-6963 uuid. */
191
+ get(uuid: string): EIP1193Provider | undefined;
192
+ /** Subscribe to registry changes. Returns an unsubscribe callback. */
193
+ subscribe(listener: (snapshot: RegisteredProvider[]) => void): () => void;
194
+ /**
195
+ * Re-dispatch `eip6963:requestProvider`. Wallets that wired up after
196
+ * page load (or after the initial sweep) will re-announce in response.
197
+ */
198
+ requestProviders(): void;
199
+ /** Tear down listeners. After this, `list()` returns `[]`. */
200
+ destroy(): void;
201
+ }
202
+ /**
203
+ * Start discovering EIP-6963 providers in the current (top-level) frame.
204
+ *
205
+ * Safe to call multiple times — each handle owns its own listeners and
206
+ * registry; calling `destroy()` releases both. In practice, `createIframe`
207
+ * spins one handle per modal open.
208
+ */
209
+ declare function createWalletDiscoverer(): WalletDiscovererHandle;
210
+
211
+ interface RpcHostHandle {
212
+ /** Tear down listeners and unsubscribe from all bridged providers. */
213
+ detach(): void;
214
+ }
215
+ interface RpcHostOptions {
216
+ /** Cross-origin iframe window we're talking to. */
217
+ iframeWindow: Window;
218
+ /** Origin of the iframe — origin-pin all postMessage send/receive. */
219
+ iframeOrigin: string;
220
+ /** Discoverer providing the EIP-6963 provider registry. */
221
+ discoverer: WalletDiscovererHandle;
222
+ /** Optional debug logger; defaults to a no-op. */
223
+ log?: (message: string, data?: Record<string, unknown>) => void;
224
+ }
225
+ /**
226
+ * Attach an RPC host to the given iframe. Listens on `window` for
227
+ * messages from the iframe and routes allowlisted JSON-RPC calls to the
228
+ * matching top-frame EIP-1193 provider.
229
+ */
230
+ declare function attachRpcHost(options: RpcHostOptions): RpcHostHandle;
231
+
76
232
  declare const VERSION = "0.3.0";
77
233
 
78
- export { Checkout, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositConfig, DepositError, DepositRequest, DepositResult, DepositStatus, VERSION };
234
+ export { ALLOWED_RPC_METHODS, type AdvertisedWallet, BRIDGE_PROTOCOL_VERSION, type EIP1193Provider as BridgeEIP1193Provider, type BridgeHelloMessage, type BridgeMessage, Checkout, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositConfig, DepositError, DepositRequest, DepositResult, DepositStatus, type EIP6963ProviderDetail, type EIP6963ProviderInfo, type RegisteredProvider, type RpcEventMessage, type RpcHostHandle, type RpcHostOptions, type RpcRequestMessage, type RpcResponseMessage, VERSION, type WalletDiscovererHandle, type WalletsAdvertisedMessage, attachRpcHost, createWalletDiscoverer, parseBridgeMessage };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, getDisplayMessage } from './chunk-KDRGSQ2W.js';
1
+ export { ALLOWED_RPC_METHODS, BRIDGE_PROTOCOL_VERSION, Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, attachRpcHost, createWalletDiscoverer, getDisplayMessage, parseBridgeMessage } from './chunk-XYI3ZPQD.js';
2
2
 
3
3
  // src/index.ts
4
4
  var VERSION = "0.3.0";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAgBO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["export { Deposit, Checkout, DEFAULT_WEBVIEW_BASE_URL } from './checkout.ts';\nexport { DepositError, CheckoutError, getDisplayMessage } from './errors.ts';\nexport type { DepositErrorCode, CheckoutErrorCode } from './errors.ts';\nexport type {\n DepositConfig,\n CheckoutConfig,\n DepositStatus,\n CheckoutStatus,\n DepositRequest,\n DepositResult,\n SignerFunction,\n SignerRequest,\n SignerResponse,\n TransferSummary,\n} from './types.ts';\n\nexport const VERSION = '0.3.0';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA2CO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["export { Deposit, Checkout, DEFAULT_WEBVIEW_BASE_URL } from './checkout.ts';\nexport { DepositError, CheckoutError, getDisplayMessage } from './errors.ts';\nexport type { DepositErrorCode, CheckoutErrorCode } from './errors.ts';\nexport type {\n DepositConfig,\n CheckoutConfig,\n DepositStatus,\n CheckoutStatus,\n DepositRequest,\n DepositResult,\n SignerFunction,\n SignerRequest,\n SignerResponse,\n TransferSummary,\n} from './types.ts';\n\n// ── Wallet bridge (advanced) ──────────────────────────────────────────\n// Internal building blocks for the top-frame → iframe wallet bridge.\n// Default merchant integrations don't need these — `createIframe()` wires\n// them automatically. Re-exported so monorepo tests and any merchant\n// custom-iframe wrapper can poke at the protocol shapes.\nexport { createWalletDiscoverer } from './walletBridge/discover.ts';\nexport type { WalletDiscovererHandle, RegisteredProvider } from './walletBridge/discover.ts';\nexport { attachRpcHost } from './walletBridge/rpcHost.ts';\nexport type { RpcHostHandle, RpcHostOptions } from './walletBridge/rpcHost.ts';\nexport {\n ALLOWED_RPC_METHODS,\n BRIDGE_PROTOCOL_VERSION,\n parseBridgeMessage,\n} from './walletBridge/protocol.ts';\nexport type {\n AdvertisedWallet,\n BridgeMessage,\n BridgeHelloMessage,\n WalletsAdvertisedMessage,\n RpcRequestMessage,\n RpcResponseMessage,\n RpcEventMessage,\n EIP1193Provider as BridgeEIP1193Provider,\n EIP6963ProviderInfo,\n EIP6963ProviderDetail,\n} from './walletBridge/protocol.ts';\n\nexport const VERSION = '0.3.0';\n"]}