@swype-org/deposit 0.3.31 → 0.3.34

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-NMNL3Jut.cjs';
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-NMNL3Jut.cjs';
1
+ import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-Bwy_1TQT.cjs';
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-Bwy_1TQT.cjs';
3
3
 
4
4
  declare const DEFAULT_WEBVIEW_BASE_URL = "https://pay.blink.cash";
5
5
  declare const SANDBOX_WEBVIEW_BASE_URL = "https://pay-sandbox.blink.cash";
@@ -224,6 +224,31 @@ declare class Deposit {
224
224
  * ignoring the config.
225
225
  */
226
226
  private applyBrandParam;
227
+ /**
228
+ * Normalizes the display-only {@link DepositRequest.balance} for the wire,
229
+ * or returns `undefined` to omit it everywhere — the `blink:signed-payload`
230
+ * sibling field and the legacy fallback URL param alike. Additive wire
231
+ * discipline: an unset or rejected balance leaves both channels
232
+ * byte-for-byte what they always were, and old webviews ignore the field
233
+ * by construction.
234
+ *
235
+ * Validated here purely so the merchant sees the complaint in their OWN
236
+ * console (same rationale as {@link applyBrandParam}); the hosted flow
237
+ * re-validates whatever arrives, since both channels are host-controlled
238
+ * input. A rejected balance never blocks the deposit — the flow proceeds
239
+ * without the subtitle.
240
+ */
241
+ private normalizeRequestBalance;
242
+ /**
243
+ * Normalizes {@link DepositRequest.minimumDeposit} for the wire, or returns
244
+ * `undefined` to omit it everywhere. Same additive discipline and same
245
+ * console-complaint rationale as {@link normalizeRequestBalance}.
246
+ *
247
+ * A rejected minimum never blocks the deposit — the flow proceeds on
248
+ * Blink's own per-route floor, which is the safe direction to fail: the
249
+ * merchant loses their higher floor, nobody is locked out of depositing.
250
+ */
251
+ private normalizeRequestMinimumDeposit;
227
252
  /**
228
253
  * Fluid is the default; `layout: 'fixed'` opts back into the legacy
229
254
  * container. Embedded is a separate presentation and never fluid — the
@@ -419,6 +444,6 @@ interface RpcHostOptions {
419
444
  */
420
445
  declare function attachRpcHost(options: RpcHostOptions): RpcHostHandle;
421
446
 
422
- declare const VERSION = "0.3.27";
447
+ declare const VERSION = "0.3.32";
423
448
 
424
449
  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, SANDBOX_WEBVIEW_BASE_URL, VERSION, type WalletDiscovererHandle, type WalletsAdvertisedMessage, attachRpcHost, createWalletDiscoverer, parseBridgeMessage };
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-NMNL3Jut.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-NMNL3Jut.js';
1
+ import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-Bwy_1TQT.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-Bwy_1TQT.js';
3
3
 
4
4
  declare const DEFAULT_WEBVIEW_BASE_URL = "https://pay.blink.cash";
5
5
  declare const SANDBOX_WEBVIEW_BASE_URL = "https://pay-sandbox.blink.cash";
@@ -224,6 +224,31 @@ declare class Deposit {
224
224
  * ignoring the config.
225
225
  */
226
226
  private applyBrandParam;
227
+ /**
228
+ * Normalizes the display-only {@link DepositRequest.balance} for the wire,
229
+ * or returns `undefined` to omit it everywhere — the `blink:signed-payload`
230
+ * sibling field and the legacy fallback URL param alike. Additive wire
231
+ * discipline: an unset or rejected balance leaves both channels
232
+ * byte-for-byte what they always were, and old webviews ignore the field
233
+ * by construction.
234
+ *
235
+ * Validated here purely so the merchant sees the complaint in their OWN
236
+ * console (same rationale as {@link applyBrandParam}); the hosted flow
237
+ * re-validates whatever arrives, since both channels are host-controlled
238
+ * input. A rejected balance never blocks the deposit — the flow proceeds
239
+ * without the subtitle.
240
+ */
241
+ private normalizeRequestBalance;
242
+ /**
243
+ * Normalizes {@link DepositRequest.minimumDeposit} for the wire, or returns
244
+ * `undefined` to omit it everywhere. Same additive discipline and same
245
+ * console-complaint rationale as {@link normalizeRequestBalance}.
246
+ *
247
+ * A rejected minimum never blocks the deposit — the flow proceeds on
248
+ * Blink's own per-route floor, which is the safe direction to fail: the
249
+ * merchant loses their higher floor, nobody is locked out of depositing.
250
+ */
251
+ private normalizeRequestMinimumDeposit;
227
252
  /**
228
253
  * Fluid is the default; `layout: 'fixed'` opts back into the legacy
229
254
  * container. Embedded is a separate presentation and never fluid — the
@@ -419,6 +444,6 @@ interface RpcHostOptions {
419
444
  */
420
445
  declare function attachRpcHost(options: RpcHostOptions): RpcHostHandle;
421
446
 
422
- declare const VERSION = "0.3.27";
447
+ declare const VERSION = "0.3.32";
423
448
 
424
449
  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, SANDBOX_WEBVIEW_BASE_URL, VERSION, type WalletDiscovererHandle, type WalletsAdvertisedMessage, attachRpcHost, createWalletDiscoverer, parseBridgeMessage };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { ALLOWED_RPC_METHODS, BRIDGE_PROTOCOL_VERSION, Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, SANDBOX_WEBVIEW_BASE_URL, attachRpcHost, createWalletDiscoverer, getDisplayMessage, parseBridgeMessage } from './chunk-HBW7IVRJ.js';
1
+ export { ALLOWED_RPC_METHODS, BRIDGE_PROTOCOL_VERSION, Checkout, CheckoutError, DEFAULT_WEBVIEW_BASE_URL, Deposit, DepositError, SANDBOX_WEBVIEW_BASE_URL, attachRpcHost, createWalletDiscoverer, getDisplayMessage, parseBridgeMessage } from './chunk-24WCJE4H.js';
2
2
 
3
3
  // src/index.ts
4
- var VERSION = "0.3.27";
4
+ var VERSION = "0.3.32";
5
5
 
6
6
  export { VERSION };
7
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA2CO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["export { Deposit, Checkout, DEFAULT_WEBVIEW_BASE_URL, SANDBOX_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.27';\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, SANDBOX_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.32';\n"]}
package/dist/react.cjs CHANGED
@@ -150,12 +150,14 @@ function parseWidthHint(key, value) {
150
150
  function buildRevealMessage() {
151
151
  return { type: "blink:reveal" };
152
152
  }
153
- function buildSignedPayloadMessage(merchantId, payload, signature) {
153
+ function buildSignedPayloadMessage(merchantId, payload, signature, balance, minimumDeposit) {
154
154
  return {
155
155
  type: "blink:signed-payload",
156
156
  merchantId,
157
157
  payload,
158
- signature
158
+ signature,
159
+ ...balance === void 0 ? {} : { balance },
160
+ ...minimumDeposit === void 0 ? {} : { minimumDeposit }
159
161
  };
160
162
  }
161
163
 
@@ -176,6 +178,26 @@ function normalizeBrandHex(value) {
176
178
  return `#${digits[0]}${digits[0]}${digits[1]}${digits[1]}${digits[2]}${digits[2]}`;
177
179
  }
178
180
 
181
+ // src/balanceParam.ts
182
+ var MAX_BALANCE_USD = 1e12;
183
+ function normalizeDisplayBalance(value) {
184
+ if (typeof value !== "number" || !Number.isFinite(value)) return null;
185
+ if (value < 0 || value >= MAX_BALANCE_USD) return null;
186
+ const cents = Math.floor(Number((value * 100).toPrecision(15)));
187
+ if (cents < 0 || cents >= MAX_BALANCE_USD * 100) return null;
188
+ return (cents / 100).toFixed(2);
189
+ }
190
+
191
+ // src/minimumDepositParam.ts
192
+ var MAX_MINIMUM_DEPOSIT_USD = 1e6;
193
+ function normalizeMinimumDeposit(value) {
194
+ if (typeof value !== "number" || !Number.isFinite(value)) return null;
195
+ if (value <= 0 || value >= MAX_MINIMUM_DEPOSIT_USD) return null;
196
+ const cents = Math.ceil(Number((value * 100).toPrecision(15)));
197
+ if (cents <= 0 || cents >= MAX_MINIMUM_DEPOSIT_USD * 100) return null;
198
+ return (cents / 100).toFixed(2);
199
+ }
200
+
179
201
  // src/walletBridge/discover.ts
180
202
  function createWalletDiscoverer() {
181
203
  if (typeof window === "undefined") {
@@ -1576,6 +1598,53 @@ var Deposit = class {
1576
1598
  const encoded = Object.keys(BRAND_COLOR_PARAM_KEYS).filter((key) => accepted[key] !== void 0).map((key) => `${BRAND_COLOR_PARAM_KEYS[key]}-${accepted[key].slice(1)}`).join(".");
1577
1599
  if (encoded) url.searchParams.set("brand", encoded);
1578
1600
  }
1601
+ /**
1602
+ * Normalizes the display-only {@link DepositRequest.balance} for the wire,
1603
+ * or returns `undefined` to omit it everywhere — the `blink:signed-payload`
1604
+ * sibling field and the legacy fallback URL param alike. Additive wire
1605
+ * discipline: an unset or rejected balance leaves both channels
1606
+ * byte-for-byte what they always were, and old webviews ignore the field
1607
+ * by construction.
1608
+ *
1609
+ * Validated here purely so the merchant sees the complaint in their OWN
1610
+ * console (same rationale as {@link applyBrandParam}); the hosted flow
1611
+ * re-validates whatever arrives, since both channels are host-controlled
1612
+ * input. A rejected balance never blocks the deposit — the flow proceeds
1613
+ * without the subtitle.
1614
+ */
1615
+ normalizeRequestBalance(balance) {
1616
+ if (balance === void 0 || balance === null) return void 0;
1617
+ const normalized = normalizeDisplayBalance(balance);
1618
+ if (normalized === null) {
1619
+ const received = typeof balance === "number" ? String(balance) : JSON.stringify(balance) ?? String(balance);
1620
+ console.error(
1621
+ `[blink] balance must be a finite number >= 0 and < 1e12 (USD, display only); received ${received}. Ignoring it.`
1622
+ );
1623
+ return void 0;
1624
+ }
1625
+ return normalized;
1626
+ }
1627
+ /**
1628
+ * Normalizes {@link DepositRequest.minimumDeposit} for the wire, or returns
1629
+ * `undefined` to omit it everywhere. Same additive discipline and same
1630
+ * console-complaint rationale as {@link normalizeRequestBalance}.
1631
+ *
1632
+ * A rejected minimum never blocks the deposit — the flow proceeds on
1633
+ * Blink's own per-route floor, which is the safe direction to fail: the
1634
+ * merchant loses their higher floor, nobody is locked out of depositing.
1635
+ */
1636
+ normalizeRequestMinimumDeposit(minimumDeposit) {
1637
+ if (minimumDeposit === void 0 || minimumDeposit === null) return void 0;
1638
+ const normalized = normalizeMinimumDeposit(minimumDeposit);
1639
+ if (normalized === null) {
1640
+ const received = typeof minimumDeposit === "number" ? String(minimumDeposit) : JSON.stringify(minimumDeposit) ?? String(minimumDeposit);
1641
+ console.error(
1642
+ `[blink] minimumDeposit must be a finite number > 0 and < 1e6 (USD); received ${received}. Ignoring it.`
1643
+ );
1644
+ return void 0;
1645
+ }
1646
+ return normalized;
1647
+ }
1579
1648
  /**
1580
1649
  * Fluid is the default; `layout: 'fixed'` opts back into the legacy
1581
1650
  * container. Embedded is a separate presentation and never fluid — the
@@ -1634,6 +1703,8 @@ var Deposit = class {
1634
1703
  signer: typeof this.config.signer === "string" ? this.config.signer : "<function>"
1635
1704
  });
1636
1705
  const signerRequest = buildSignerRequest(request, webviewBaseUrl);
1706
+ const displayBalance = this.normalizeRequestBalance(request.balance);
1707
+ const minimumDeposit = this.normalizeRequestMinimumDeposit(request.minimumDeposit);
1637
1708
  let preloadIframe;
1638
1709
  let iframeReadyPromise;
1639
1710
  const warm = this.takeWarmIframe();
@@ -1686,7 +1757,9 @@ var Deposit = class {
1686
1757
  buildSignedPayloadMessage(
1687
1758
  signerResponse.merchantId,
1688
1759
  signerResponse.payload,
1689
- signerResponse.signature
1760
+ signerResponse.signature,
1761
+ displayBalance,
1762
+ minimumDeposit
1690
1763
  ),
1691
1764
  this.hostedOrigin
1692
1765
  );
@@ -1700,6 +1773,12 @@ var Deposit = class {
1700
1773
  hostedUrl.searchParams.set("merchantId", signerResponse.merchantId);
1701
1774
  hostedUrl.searchParams.set("payload", signerResponse.payload);
1702
1775
  hostedUrl.searchParams.set("signature", signerResponse.signature);
1776
+ if (displayBalance !== void 0) {
1777
+ hostedUrl.searchParams.set("balance", displayBalance);
1778
+ }
1779
+ if (minimumDeposit !== void 0) {
1780
+ hostedUrl.searchParams.set("minDeposit", minimumDeposit);
1781
+ }
1703
1782
  this.applyFullWidgetParam(hostedUrl);
1704
1783
  if (this.isEmbedded()) {
1705
1784
  this.applyLayoutParam(hostedUrl);