@swype-org/deposit 0.3.31 → 0.3.32
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/README.md +24 -0
- package/dist/{chunk-HBW7IVRJ.js → chunk-MJSD7JWR.js} +47 -5
- package/dist/chunk-MJSD7JWR.js.map +1 -0
- package/dist/index.cjs +46 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +45 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +2 -2
- package/dist/{types-NMNL3Jut.d.cts → types-QRkKxsoP.d.cts} +18 -0
- package/dist/{types-NMNL3Jut.d.ts → types-QRkKxsoP.d.ts} +18 -0
- package/package.json +1 -1
- package/dist/chunk-HBW7IVRJ.js.map +0 -1
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-
|
|
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-
|
|
1
|
+
import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-QRkKxsoP.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-QRkKxsoP.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,21 @@ 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;
|
|
227
242
|
/**
|
|
228
243
|
* Fluid is the default; `layout: 'fixed'` opts back into the legacy
|
|
229
244
|
* container. Embedded is a separate presentation and never fluid — the
|
|
@@ -419,6 +434,6 @@ interface RpcHostOptions {
|
|
|
419
434
|
*/
|
|
420
435
|
declare function attachRpcHost(options: RpcHostOptions): RpcHostHandle;
|
|
421
436
|
|
|
422
|
-
declare const VERSION = "0.3.
|
|
437
|
+
declare const VERSION = "0.3.32";
|
|
423
438
|
|
|
424
439
|
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-
|
|
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-
|
|
1
|
+
import { D as DepositStatus, a as DepositResult, b as DepositError, c as DepositConfig, d as DepositRequest } from './types-QRkKxsoP.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-QRkKxsoP.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,21 @@ 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;
|
|
227
242
|
/**
|
|
228
243
|
* Fluid is the default; `layout: 'fixed'` opts back into the legacy
|
|
229
244
|
* container. Embedded is a separate presentation and never fluid — the
|
|
@@ -419,6 +434,6 @@ interface RpcHostOptions {
|
|
|
419
434
|
*/
|
|
420
435
|
declare function attachRpcHost(options: RpcHostOptions): RpcHostHandle;
|
|
421
436
|
|
|
422
|
-
declare const VERSION = "0.3.
|
|
437
|
+
declare const VERSION = "0.3.32";
|
|
423
438
|
|
|
424
439
|
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-
|
|
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-MJSD7JWR.js';
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
var VERSION = "0.3.
|
|
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.
|
|
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,13 @@ 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) {
|
|
154
154
|
return {
|
|
155
155
|
type: "blink:signed-payload",
|
|
156
156
|
merchantId,
|
|
157
157
|
payload,
|
|
158
|
-
signature
|
|
158
|
+
signature,
|
|
159
|
+
...balance === void 0 ? {} : { balance }
|
|
159
160
|
};
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -176,6 +177,16 @@ function normalizeBrandHex(value) {
|
|
|
176
177
|
return `#${digits[0]}${digits[0]}${digits[1]}${digits[1]}${digits[2]}${digits[2]}`;
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
// src/balanceParam.ts
|
|
181
|
+
var MAX_BALANCE_USD = 1e12;
|
|
182
|
+
function normalizeDisplayBalance(value) {
|
|
183
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
184
|
+
if (value < 0 || value >= MAX_BALANCE_USD) return null;
|
|
185
|
+
const cents = Math.floor(Number((value * 100).toPrecision(15)));
|
|
186
|
+
if (cents < 0 || cents >= MAX_BALANCE_USD * 100) return null;
|
|
187
|
+
return (cents / 100).toFixed(2);
|
|
188
|
+
}
|
|
189
|
+
|
|
179
190
|
// src/walletBridge/discover.ts
|
|
180
191
|
function createWalletDiscoverer() {
|
|
181
192
|
if (typeof window === "undefined") {
|
|
@@ -1576,6 +1587,32 @@ var Deposit = class {
|
|
|
1576
1587
|
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
1588
|
if (encoded) url.searchParams.set("brand", encoded);
|
|
1578
1589
|
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Normalizes the display-only {@link DepositRequest.balance} for the wire,
|
|
1592
|
+
* or returns `undefined` to omit it everywhere — the `blink:signed-payload`
|
|
1593
|
+
* sibling field and the legacy fallback URL param alike. Additive wire
|
|
1594
|
+
* discipline: an unset or rejected balance leaves both channels
|
|
1595
|
+
* byte-for-byte what they always were, and old webviews ignore the field
|
|
1596
|
+
* by construction.
|
|
1597
|
+
*
|
|
1598
|
+
* Validated here purely so the merchant sees the complaint in their OWN
|
|
1599
|
+
* console (same rationale as {@link applyBrandParam}); the hosted flow
|
|
1600
|
+
* re-validates whatever arrives, since both channels are host-controlled
|
|
1601
|
+
* input. A rejected balance never blocks the deposit — the flow proceeds
|
|
1602
|
+
* without the subtitle.
|
|
1603
|
+
*/
|
|
1604
|
+
normalizeRequestBalance(balance) {
|
|
1605
|
+
if (balance === void 0 || balance === null) return void 0;
|
|
1606
|
+
const normalized = normalizeDisplayBalance(balance);
|
|
1607
|
+
if (normalized === null) {
|
|
1608
|
+
const received = typeof balance === "number" ? String(balance) : JSON.stringify(balance) ?? String(balance);
|
|
1609
|
+
console.error(
|
|
1610
|
+
`[blink] balance must be a finite number >= 0 and < 1e12 (USD, display only); received ${received}. Ignoring it.`
|
|
1611
|
+
);
|
|
1612
|
+
return void 0;
|
|
1613
|
+
}
|
|
1614
|
+
return normalized;
|
|
1615
|
+
}
|
|
1579
1616
|
/**
|
|
1580
1617
|
* Fluid is the default; `layout: 'fixed'` opts back into the legacy
|
|
1581
1618
|
* container. Embedded is a separate presentation and never fluid — the
|
|
@@ -1634,6 +1671,7 @@ var Deposit = class {
|
|
|
1634
1671
|
signer: typeof this.config.signer === "string" ? this.config.signer : "<function>"
|
|
1635
1672
|
});
|
|
1636
1673
|
const signerRequest = buildSignerRequest(request, webviewBaseUrl);
|
|
1674
|
+
const displayBalance = this.normalizeRequestBalance(request.balance);
|
|
1637
1675
|
let preloadIframe;
|
|
1638
1676
|
let iframeReadyPromise;
|
|
1639
1677
|
const warm = this.takeWarmIframe();
|
|
@@ -1686,7 +1724,8 @@ var Deposit = class {
|
|
|
1686
1724
|
buildSignedPayloadMessage(
|
|
1687
1725
|
signerResponse.merchantId,
|
|
1688
1726
|
signerResponse.payload,
|
|
1689
|
-
signerResponse.signature
|
|
1727
|
+
signerResponse.signature,
|
|
1728
|
+
displayBalance
|
|
1690
1729
|
),
|
|
1691
1730
|
this.hostedOrigin
|
|
1692
1731
|
);
|
|
@@ -1700,6 +1739,9 @@ var Deposit = class {
|
|
|
1700
1739
|
hostedUrl.searchParams.set("merchantId", signerResponse.merchantId);
|
|
1701
1740
|
hostedUrl.searchParams.set("payload", signerResponse.payload);
|
|
1702
1741
|
hostedUrl.searchParams.set("signature", signerResponse.signature);
|
|
1742
|
+
if (displayBalance !== void 0) {
|
|
1743
|
+
hostedUrl.searchParams.set("balance", displayBalance);
|
|
1744
|
+
}
|
|
1703
1745
|
this.applyFullWidgetParam(hostedUrl);
|
|
1704
1746
|
if (this.isEmbedded()) {
|
|
1705
1747
|
this.applyLayoutParam(hostedUrl);
|