@binopartner/pay-sdk 0.3.3 → 0.3.4
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 +3 -3
- package/dist/elements/components/deposit.d.ts +11 -9
- package/dist/elements/components/deposit.js +7 -2
- package/dist/elements/index.d.ts +1 -1
- package/dist/elements/presets/DepositForm.d.ts +9 -1
- package/dist/elements/presets/DepositForm.js +2 -2
- package/dist/elements.css +6 -0
- package/dist/ui/fields.d.ts +6 -0
- package/dist/ui/fields.js +5 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -263,10 +263,10 @@ Every component accepts `className`, `style` and `unstyled`, forwards its ref an
|
|
|
263
263
|
| `Quote` | Fees, amount received, ETA, slippage. |
|
|
264
264
|
| `CryptoAddress` | Address, copy button, QR code (rendered locally, no image host), network warning, high-fee warning. |
|
|
265
265
|
| `Requisites` | Fiat payment details: raw rows with copy buttons, or the requisites frame (see Security). `data-delivery="raw" \| "frame"`. |
|
|
266
|
-
| `RequisitesFrame`, `ReceiptUpload`, `Countdown`, `RedirectButton`, `Onramp` | Frame, receipt upload (RU deposits in raw mode; in frame mode the receipt is uploaded inside the frame), server-clock countdown, hosted page link, onramp link
|
|
266
|
+
| `RequisitesFrame`, `ReceiptUpload`, `Countdown`, `RedirectButton`, `Onramp` | Frame, receipt upload (RU deposits in raw mode; in frame mode the receipt is uploaded inside the frame), server-clock countdown, hosted page link, card onramp (Coindisco). The onramp is a link that opens it in a new tab; with `display="embed"` it is a frame (`height`, 640 px by default) with that link under it. Coindisco frames only on the origins listed in its dashboard: ask Binodex to list your site (`https://host`, each subdomain separately) before you turn the frame on. On a site that is not listed the frame stays blank and the link under it still works. `ref`, `className` and `style` go to the link. |
|
|
267
267
|
| `SlippageWarning`, `SubmitButton`, `Status`, `BackButton`, `Qr` | |
|
|
268
268
|
| `RestartButton`, `MethodNotice` | Cancel / new payment for card deposits (and a new withdrawal after a final status); the receipt notice under the amount for rails that may need a receipt. |
|
|
269
|
-
| `DepositForm`, `WithdrawForm` | Full screens composed from the parts above, laid out like the binodex payment modal: a card with the title, the balance and a close button, the Crypto / Card tabs, the payment country and the bank tiles. Replace any piece: `<Pay.DepositForm components={{ MethodPicker: MyPicker }} />`. |
|
|
269
|
+
| `DepositForm`, `WithdrawForm` | Full screens composed from the parts above, laid out like the binodex payment modal: a card with the title, the balance and a close button, the Crypto / Card tabs, the payment country and the bank tiles. Replace any piece: `<Pay.DepositForm components={{ MethodPicker: MyPicker }} />`. `<Pay.DepositForm onrampDisplay="embed" />` frames the card onramp (see `Onramp`). |
|
|
270
270
|
|
|
271
271
|
### Hooks
|
|
272
272
|
|
|
@@ -314,7 +314,7 @@ font-src https://binodex.app https://binodex.pro;
|
|
|
314
314
|
img-src 'self' data: https:;
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
-
Replace the hosts with the ones in your session responses (`api_bases`, `widget_origins`) and in `allowedApiOrigins` / `allowedWidgetOrigins`. `img-src` covers the bank logos, coin icons and flags from the Binodex domains, your logo from the partner cabinet and providers that send a QR image instead of a QR payload; crypto QR codes are drawn locally as SVG. With `assetBaseUrl` / `fontBaseUrl` on your own host, list that host instead.
|
|
317
|
+
Replace the hosts with the ones in your session responses (`api_bases`, `widget_origins`) and in `allowedApiOrigins` / `allowedWidgetOrigins`. `img-src` covers the bank logos, coin icons and flags from the Binodex domains, your logo from the partner cabinet and providers that send a QR image instead of a QR payload; crypto QR codes are drawn locally as SVG. With `assetBaseUrl` / `fontBaseUrl` on your own host, list that host instead. With the card onramp framed (`display="embed"`), add `https://widget.coindisco.com` to `frame-src`.
|
|
318
318
|
|
|
319
319
|
## Migration from the iframe widget
|
|
320
320
|
|
|
@@ -50,21 +50,23 @@ export declare const RestartButton: import("react").ForwardRefExoticComponent<Om
|
|
|
50
50
|
export declare const MethodNotice: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "style" | "children" | "className"> & ui.PartStyleProps & {
|
|
51
51
|
children?: ReactNode;
|
|
52
52
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
53
|
+
export type OnrampDisplay = "tab" | "embed";
|
|
53
54
|
/**
|
|
54
|
-
* The card on-ramp is Coindisco
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* The card on-ramp is Coindisco. `display="tab"` (the default) is a link that
|
|
56
|
+
* opens it in a new tab, which works on any site. `display="embed"` frames it on
|
|
57
|
+
* your page; Coindisco lets itself be framed only on the origins listed in its
|
|
58
|
+
* dashboard, so ask Binodex to list your site first. The new-tab link stays
|
|
59
|
+
* under the frame: on a site that is not listed the frame is blank, and the link
|
|
60
|
+
* is the way through. `ref`, `className` and `style` are always that link's.
|
|
57
61
|
*/
|
|
58
62
|
export type OnrampProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "className" | "style" | "href"> & PartStyleProps & {
|
|
59
|
-
|
|
60
|
-
display
|
|
61
|
-
/** @deprecated Ignored: the on-ramp always opens in a new tab. */
|
|
63
|
+
display?: OnrampDisplay;
|
|
64
|
+
/** Frame height in pixels with `display="embed"`. */
|
|
62
65
|
height?: number;
|
|
63
66
|
};
|
|
64
67
|
export declare const Onramp: import("react").ForwardRefExoticComponent<Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "style" | "className" | "href"> & ui.PartStyleProps & {
|
|
65
|
-
|
|
66
|
-
display
|
|
67
|
-
/** @deprecated Ignored: the on-ramp always opens in a new tab. */
|
|
68
|
+
display?: OnrampDisplay;
|
|
69
|
+
/** Frame height in pixels with `display="embed"`. */
|
|
68
70
|
height?: number;
|
|
69
71
|
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
70
72
|
export {};
|
|
@@ -249,7 +249,9 @@ export const MethodNotice = forwardRef(function MethodNotice({ className, style,
|
|
|
249
249
|
return null;
|
|
250
250
|
return (_jsx(ui.Notice, { ...rest, ref: ref, part: "method-notice", variant: "receipt", className: className, style: style, unstyled: unstyled, children: children ?? root.t("fiat.receiptMayBeNeeded") }));
|
|
251
251
|
});
|
|
252
|
-
|
|
252
|
+
/** Allows the frame what the widget's checkout and identity check use. */
|
|
253
|
+
const ONRAMP_FRAME_ALLOW = "payment; clipboard-write; camera; microphone";
|
|
254
|
+
export const Onramp = forwardRef(function Onramp({ display = "tab", height = 640, className, style, unstyled, ...rest }, ref) {
|
|
253
255
|
const { root, actions, state } = useDeposit("<Pay.Onramp>");
|
|
254
256
|
const active = state?.step === "onramp";
|
|
255
257
|
useEffect(() => {
|
|
@@ -265,5 +267,8 @@ export const Onramp = forwardRef(function Onramp({ display: _display, height: _h
|
|
|
265
267
|
if (!url || !/^https:\/\//i.test(url)) {
|
|
266
268
|
return state.onrampLoading ? _jsx(ui.Loader, { unstyled: unstyled }) : null;
|
|
267
269
|
}
|
|
268
|
-
|
|
270
|
+
if (display !== "embed") {
|
|
271
|
+
return (_jsx(ui.SubmitLink, { ...rest, ref: ref, part: "onramp", href: url, className: className, style: style, unstyled: unstyled, "data-display": "tab", children: root.t("onramp.open") }));
|
|
272
|
+
}
|
|
273
|
+
return (_jsxs(_Fragment, { children: [_jsx("iframe", { title: root.t("onramp.title"), src: url, height: height, allow: ONRAMP_FRAME_ALLOW, ...partProps("onramp-frame", { style: { width: "100%", border: 0 }, unstyled }, root.unstyled) }), _jsx(ui.LinkAnchor, { ...rest, ref: ref, part: "onramp", href: url, className: className, style: style, unstyled: unstyled, "data-display": "embed", children: root.t("onramp.open") })] }));
|
|
269
274
|
});
|
package/dist/elements/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { CurrencyPicker, MethodPicker, NetworkPicker } from "./components/picker
|
|
|
6
6
|
export type { CurrencyPickerProps, MethodOption, MethodPickerProps, NetworkPickerProps, } from "./components/pickers.js";
|
|
7
7
|
export { AddressInput, AmountInput, PhoneInput, TwoFactorInput } from "./components/inputs.js";
|
|
8
8
|
export { Countdown, CryptoAddress, MethodNotice, Onramp, ReceiptUpload, RedirectButton, Requisites, RequisitesFrame, RestartButton, } from "./components/deposit.js";
|
|
9
|
-
export type { OnrampProps, RequisitesFrameProps, RequisitesProps } from "./components/deposit.js";
|
|
9
|
+
export type { OnrampDisplay, OnrampProps, RequisitesFrameProps, RequisitesProps } from "./components/deposit.js";
|
|
10
10
|
export { Quote, SlippageWarning, Status } from "./components/status.js";
|
|
11
11
|
export type { StatusProps } from "./components/status.js";
|
|
12
12
|
export { Qr } from "./components/Qr.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ComponentType, type HTMLAttributes } from "react";
|
|
2
2
|
import * as ui from "../../ui/index.js";
|
|
3
3
|
import { type PartStyleProps } from "../part.js";
|
|
4
|
+
import { type OnrampDisplay } from "../components/deposit.js";
|
|
4
5
|
export interface DepositFormComponents {
|
|
5
6
|
Loader: ComponentType;
|
|
6
7
|
ErrorMessage: ComponentType;
|
|
@@ -21,12 +22,19 @@ export interface DepositFormComponents {
|
|
|
21
22
|
ReceiptUpload: ComponentType;
|
|
22
23
|
RedirectButton: ComponentType;
|
|
23
24
|
RestartButton: ComponentType;
|
|
24
|
-
|
|
25
|
+
/** Gets the form's `onrampDisplay`. */
|
|
26
|
+
Onramp: ComponentType<{
|
|
27
|
+
display?: OnrampDisplay;
|
|
28
|
+
}>;
|
|
25
29
|
Status: ComponentType;
|
|
26
30
|
}
|
|
27
31
|
export type DepositFormProps = Omit<HTMLAttributes<HTMLDivElement>, "className" | "style" | "children"> & PartStyleProps & {
|
|
28
32
|
components?: Partial<DepositFormComponents>;
|
|
33
|
+
/** How the card on-ramp opens: `"tab"` (default) or `"embed"`, see `<Pay.Onramp display>`. */
|
|
34
|
+
onrampDisplay?: OnrampDisplay;
|
|
29
35
|
};
|
|
30
36
|
export declare const DepositForm: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "style" | "children" | "className"> & ui.PartStyleProps & {
|
|
31
37
|
components?: Partial<DepositFormComponents>;
|
|
38
|
+
/** How the card on-ramp opens: `"tab"` (default) or `"embed"`, see `<Pay.Onramp display>`. */
|
|
39
|
+
onrampDisplay?: OnrampDisplay;
|
|
32
40
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -55,7 +55,7 @@ const screenOf = (state, cryptoOpen) => {
|
|
|
55
55
|
return "credited";
|
|
56
56
|
return "paying";
|
|
57
57
|
};
|
|
58
|
-
export const DepositForm = forwardRef(function DepositForm({ components, className, style, unstyled, ...rest }, ref) {
|
|
58
|
+
export const DepositForm = forwardRef(function DepositForm({ components, onrampDisplay, className, style, unstyled, ...rest }, ref) {
|
|
59
59
|
const { root, state } = useDepositFlowStore("<Pay.DepositForm>");
|
|
60
60
|
const picker = useStoreValue(root.picker);
|
|
61
61
|
const screen = screenOf(state, picker.cryptoOpen);
|
|
@@ -81,7 +81,7 @@ export const DepositForm = forwardRef(function DepositForm({ components, classNa
|
|
|
81
81
|
body = (_jsx(ui.PayBody, { unstyled: isUnstyled, children: _jsx(c.ErrorMessage, {}) }));
|
|
82
82
|
break;
|
|
83
83
|
case "entry":
|
|
84
|
-
body = (_jsxs(ui.PayBody, { unstyled: isUnstyled, children: [_jsx(c.MethodPicker, {}), fiatSelected ? (_jsxs("div", { className: isUnstyled ? undefined : "bp-rail-form", children: [_jsx(c.AmountInput, {}), _jsx(c.PhoneInput, {}), _jsx(c.MethodNotice, {}), _jsx(c.Quote, {}), _jsx(c.ErrorMessage, {}), _jsx(c.SubmitButton, {})] })) : onrampSelected ? (_jsxs("div", { className: isUnstyled ? undefined : "bp-onramp-tab", children: [_jsx(c.Onramp, {}), state?.onrampUrl ? (_jsx("p", { className: isUnstyled ? undefined : "bp-onramp-note", "data-binodex-pay": "onramp-note", children: root.t("onramp.disclosure") })) : null] })) : (_jsx(c.ErrorMessage, {}))] }));
|
|
84
|
+
body = (_jsxs(ui.PayBody, { unstyled: isUnstyled, children: [_jsx(c.MethodPicker, {}), fiatSelected ? (_jsxs("div", { className: isUnstyled ? undefined : "bp-rail-form", children: [_jsx(c.AmountInput, {}), _jsx(c.PhoneInput, {}), _jsx(c.MethodNotice, {}), _jsx(c.Quote, {}), _jsx(c.ErrorMessage, {}), _jsx(c.SubmitButton, {})] })) : onrampSelected ? (_jsxs("div", { className: isUnstyled ? undefined : "bp-onramp-tab", children: [_jsx(c.Onramp, { display: onrampDisplay }), state?.onrampUrl ? (_jsx("p", { className: isUnstyled ? undefined : "bp-onramp-note", "data-binodex-pay": "onramp-note", children: root.t("onramp.disclosure") })) : null] })) : (_jsx(c.ErrorMessage, {}))] }));
|
|
85
85
|
break;
|
|
86
86
|
case "crypto":
|
|
87
87
|
body = (_jsxs(ui.PayBody, { variant: "address", unstyled: isUnstyled, children: [_jsx(ui.Divider, { unstyled: isUnstyled }), _jsxs(ui.RouteGrid, { unstyled: isUnstyled, children: [_jsx(c.CurrencyPicker, {}), _jsx(c.NetworkPicker, {})] }), _jsx(c.ErrorMessage, {}), _jsx(c.CryptoAddress, {})] }));
|
package/dist/elements.css
CHANGED
|
@@ -2753,6 +2753,12 @@
|
|
|
2753
2753
|
animation: bp-content-enter 0.22s ease 0.06s both;
|
|
2754
2754
|
}
|
|
2755
2755
|
|
|
2756
|
+
.bp-onramp-frame {
|
|
2757
|
+
display: block;
|
|
2758
|
+
border-radius: var(--bp-radius-sm);
|
|
2759
|
+
background: var(--bp-color-surface);
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2756
2762
|
.bp-onramp-note {
|
|
2757
2763
|
margin: 0;
|
|
2758
2764
|
font-size: 11px;
|
package/dist/ui/fields.d.ts
CHANGED
|
@@ -42,12 +42,18 @@ export declare const SubmitButton: import("react").ForwardRefExoticComponent<Omi
|
|
|
42
42
|
part?: string;
|
|
43
43
|
pending?: boolean;
|
|
44
44
|
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
type AnchorProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "className" | "style"> & PartStyleProps & {
|
|
46
|
+
variant?: ButtonVariant;
|
|
47
|
+
part?: string;
|
|
48
|
+
};
|
|
45
49
|
export declare const SubmitLink: import("react").ForwardRefExoticComponent<Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "style" | "className"> & PartStyleProps & {
|
|
46
50
|
variant?: ButtonVariant;
|
|
47
51
|
part?: string;
|
|
48
52
|
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
49
53
|
export declare const RetryButton: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "pending" | "variant"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
50
54
|
export declare const LinkButton: import("react").ForwardRefExoticComponent<Omit<ButtonProps, "pending" | "variant"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
55
|
+
/** `LinkButton` as a link: the secondary action that opens `href` in a new tab. */
|
|
56
|
+
export declare const LinkAnchor: import("react").ForwardRefExoticComponent<Omit<AnchorProps, "variant"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
51
57
|
export type ErrorBoxVariant = "deposit" | "rail" | "withdraw";
|
|
52
58
|
export declare const ErrorBox: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "style" | "children" | "className"> & PartStyleProps & {
|
|
53
59
|
variant?: ErrorBoxVariant;
|
package/dist/ui/fields.js
CHANGED
|
@@ -48,6 +48,11 @@ export const LinkButton = forwardRef(function LinkButton({ part = "link-button",
|
|
|
48
48
|
const { off } = useClasses(unstyled);
|
|
49
49
|
return (_jsx("button", { type: type, ...rest, ref: ref, ...viewProps(part, "link-button", { className, style, unstyled }, off), children: children }));
|
|
50
50
|
});
|
|
51
|
+
/** `LinkButton` as a link: the secondary action that opens `href` in a new tab. */
|
|
52
|
+
export const LinkAnchor = forwardRef(function LinkAnchor({ part = "link-anchor", className, style, unstyled, children, ...rest }, ref) {
|
|
53
|
+
const { off } = useClasses(unstyled);
|
|
54
|
+
return (_jsx("a", { target: "_blank", rel: "noopener noreferrer", referrerPolicy: "no-referrer", ...rest, ref: ref, ...viewProps(part, "link-button", { className, style, unstyled }, off), children: children }));
|
|
55
|
+
});
|
|
51
56
|
export const ErrorBox = forwardRef(function ErrorBox({ variant = "deposit", part = "error-box", className, style, unstyled, children, ...rest }, ref) {
|
|
52
57
|
const { off } = useClasses(unstyled);
|
|
53
58
|
return (_jsx("div", { role: "alert", ...rest, ref: ref, ...viewProps(part, "error-box", { className, style, unstyled }, off), "data-variant": variant, children: children }));
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { CardTab, EntryOptions, EntryTabs, IconStack, cryptoStackIcons } from ".
|
|
|
6
6
|
export type { EntryOptionsProps, EntryTabsProps } from "./entry.js";
|
|
7
7
|
export { CountrySelect, Field, MethodGrid, MethodsNotice, RouteColumn, RouteGrid, RoutePicker } from "./pickers.js";
|
|
8
8
|
export type { CountrySelectProps, FieldProps, MethodGridProps, RouteColumnProps, RoutePickerProps } from "./pickers.js";
|
|
9
|
-
export { AmountField, ErrorBox, Hint, LinkButton, Loader, RetryButton, Notice, Skeleton, SubmitButton, SubmitLink, TextField, TwoFactorField, } from "./fields.js";
|
|
9
|
+
export { AmountField, ErrorBox, Hint, LinkAnchor, LinkButton, Loader, RetryButton, Notice, Skeleton, SubmitButton, SubmitLink, TextField, TwoFactorField, } from "./fields.js";
|
|
10
10
|
export type { AmountFieldProps, ButtonVariant, ErrorBoxVariant, FieldVariant, SkeletonProps, TextFieldProps, TwoFactorFieldProps, } from "./fields.js";
|
|
11
11
|
export { DetailsAccordion, QuoteRows, Summary } from "./summary.js";
|
|
12
12
|
export type { DetailsAccordionProps, QuoteRowsProps, SummaryProps } from "./summary.js";
|
package/dist/ui/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { DEFAULT_ASSET_BASE_URL, PayUiProvider, PayUiRoot, PayUiValueProvider, b
|
|
|
3
3
|
export { BackButton, BrandLogo, CloseButton, Divider, PayBody, PayCard, PayHeader } from "./layout.js";
|
|
4
4
|
export { CardTab, EntryOptions, EntryTabs, IconStack, cryptoStackIcons } from "./entry.js";
|
|
5
5
|
export { CountrySelect, Field, MethodGrid, MethodsNotice, RouteColumn, RouteGrid, RoutePicker } from "./pickers.js";
|
|
6
|
-
export { AmountField, ErrorBox, Hint, LinkButton, Loader, RetryButton, Notice, Skeleton, SubmitButton, SubmitLink, TextField, TwoFactorField, } from "./fields.js";
|
|
6
|
+
export { AmountField, ErrorBox, Hint, LinkAnchor, LinkButton, Loader, RetryButton, Notice, Skeleton, SubmitButton, SubmitLink, TextField, TwoFactorField, } from "./fields.js";
|
|
7
7
|
export { DetailsAccordion, QuoteRows, Summary } from "./summary.js";
|
|
8
8
|
export { CopyButton, CreditBanner, CryptoAddressCard, LTR_ISOLATE, QrCode, QrSvg, useCopy } from "./crypto.js";
|
|
9
9
|
export { ExpiresLine, GeoBlock, PanelAmount, PanelHint, PayActions, PayingPanel, PdfReceiptWarning, PollNotice, QrImageCard, RailForm, RECEIPT_MAX_BYTES, ReceiptAttached, ReceiptBlock, ReceiptForm, Requisites, StatusPanel, StatusPill, isPdfFile, } from "./fiat.js";
|