@openreceive/browser 0.4.3 → 0.4.5
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 +21 -20
- package/dist/{chunk-VZ7M7ZUE.js → chunk-ZTB2TOBO.js} +41 -61
- package/dist/headless.d.ts +27 -38
- package/dist/headless.js +16 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{status-iwqocz21.d.ts → status-Doh8Wz4D.d.ts} +35 -33
- package/dist/styles.css +1 -1
- package/package.json +5 -6
- package/skills/integrate-openreceive/SKILL.md +16 -5
- package/skills/integrate-openreceive/references/btcpay.md +193 -0
- package/skills/integrate-openreceive/references/django.md +667 -0
- package/skills/integrate-openreceive/references/fastapi.md +537 -0
- package/skills/integrate-openreceive/references/fastify.md +529 -0
- package/skills/integrate-openreceive/references/laravel.md +658 -0
- package/skills/integrate-openreceive/references/next.md +580 -0
- package/skills/integrate-openreceive/references/node.md +33 -14
- package/skills/integrate-openreceive/references/php.md +598 -0
- package/skills/integrate-openreceive/references/rails.md +72 -27
- package/skills/integrate-openreceive/references/woocommerce.md +153 -0
- package/dist/assets/icons/btc.svg +0 -1
- package/dist/assets/icons/crypto.svg +0 -12
- package/dist/assets/icons/eth.svg +0 -1
- package/dist/assets/icons/lightning.svg +0 -11
- package/dist/assets/icons/ltc.svg +0 -1
- package/dist/assets/icons/sol.svg +0 -1
- package/dist/assets/icons/trx.svg +0 -1
- package/dist/assets/icons/usdc.svg +0 -1
- package/dist/assets/icons/usdt.svg +0 -1
- package/dist/assets/icons/xmr.svg +0 -1
- package/dist/assets/icons/xrp.svg +0 -1
package/dist/headless.js
CHANGED
|
@@ -75,7 +75,6 @@ import {
|
|
|
75
75
|
getNetworkIconId,
|
|
76
76
|
getPaymentMethodIcon,
|
|
77
77
|
getPaymentMethodIconId,
|
|
78
|
-
getRouteIconPath,
|
|
79
78
|
getRouteNetworkLabel,
|
|
80
79
|
getSwapOptionIcon,
|
|
81
80
|
getSwapOptionIconId,
|
|
@@ -100,7 +99,6 @@ import {
|
|
|
100
99
|
parseResolvedTheme,
|
|
101
100
|
parseThemePreference,
|
|
102
101
|
paymentAccentId,
|
|
103
|
-
paymentIconPaths,
|
|
104
102
|
paymentIconSvgs,
|
|
105
103
|
paymentIconUrls,
|
|
106
104
|
paymentMethods,
|
|
@@ -121,10 +119,14 @@ import {
|
|
|
121
119
|
swapOptionLimitSentence,
|
|
122
120
|
swapPickerKey,
|
|
123
121
|
updatePaymentWizardSelection
|
|
124
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-ZTB2TOBO.js";
|
|
125
123
|
|
|
126
124
|
// src/headless.ts
|
|
127
|
-
import {
|
|
125
|
+
import {
|
|
126
|
+
getPaymentWizardRoutes,
|
|
127
|
+
loadPayTutorialImages,
|
|
128
|
+
payTutorialImage
|
|
129
|
+
} from "@openreceive/provider-data";
|
|
128
130
|
|
|
129
131
|
// src/internal/checkout-props.ts
|
|
130
132
|
var CREATE_MODE_ONLY_PROPS = [
|
|
@@ -216,6 +218,7 @@ function createCheckoutSession(options) {
|
|
|
216
218
|
const selection = swap.selection;
|
|
217
219
|
const prefix = swap.prefix();
|
|
218
220
|
const fetcher = swap.fetch();
|
|
221
|
+
const csrfHeader = swap.csrfHeader?.();
|
|
219
222
|
const reference = options.reference();
|
|
220
223
|
if (prefix === void 0 || fetcher === void 0) {
|
|
221
224
|
const missing = [
|
|
@@ -236,11 +239,12 @@ function createCheckoutSession(options) {
|
|
|
236
239
|
swapStartError = void 0;
|
|
237
240
|
options.onChange();
|
|
238
241
|
try {
|
|
239
|
-
const quote = await quoteSwapAsset(payInAsset, prefix, fetcher, reference);
|
|
242
|
+
const quote = await quoteSwapAsset(payInAsset, prefix, fetcher, reference, csrfHeader);
|
|
240
243
|
if (quote !== void 0 && quote.available === false) return;
|
|
241
244
|
const started = await startSwapRequest({
|
|
242
245
|
fetch: fetcher,
|
|
243
246
|
prefix,
|
|
247
|
+
...csrfHeader === void 0 ? {} : { csrfHeader },
|
|
244
248
|
reference,
|
|
245
249
|
payInAsset,
|
|
246
250
|
...options.logger === void 0 ? {} : { logger: options.logger }
|
|
@@ -263,10 +267,11 @@ function createCheckoutSession(options) {
|
|
|
263
267
|
startingSwapAsset = null;
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
|
-
async function quoteSwapAsset(payInAsset, prefix, fetcher, reference) {
|
|
270
|
+
async function quoteSwapAsset(payInAsset, prefix, fetcher, reference, csrfHeader) {
|
|
267
271
|
const body = await postJson({
|
|
268
272
|
fetch: fetcher,
|
|
269
273
|
prefix,
|
|
274
|
+
...csrfHeader === void 0 ? {} : { csrfHeader },
|
|
270
275
|
...options.logger === void 0 ? {} : { logger: options.logger },
|
|
271
276
|
body: { reference, action: "swap_quote", pay_in_asset: payInAsset }
|
|
272
277
|
});
|
|
@@ -437,6 +442,9 @@ function sharedElementAttributes(options) {
|
|
|
437
442
|
if (isSet(options.prefix)) {
|
|
438
443
|
attributes[OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES.prefix] = options.prefix;
|
|
439
444
|
}
|
|
445
|
+
if (isSet(options.csrfHeader)) {
|
|
446
|
+
attributes[OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES.csrfHeader] = options.csrfHeader;
|
|
447
|
+
}
|
|
440
448
|
if (isSet(options.theme)) {
|
|
441
449
|
attributes[OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES.theme] = options.theme;
|
|
442
450
|
}
|
|
@@ -448,9 +456,6 @@ function sharedElementAttributes(options) {
|
|
|
448
456
|
if (options.decodeLinkUrl !== void 0) {
|
|
449
457
|
attributes[OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES.decodeLinkUrl] = options.decodeLinkUrl;
|
|
450
458
|
}
|
|
451
|
-
if (isSet(options.assetBaseUrl)) {
|
|
452
|
-
attributes[OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES.assetBaseUrl] = options.assetBaseUrl;
|
|
453
|
-
}
|
|
454
459
|
if (options.resumable !== void 0) {
|
|
455
460
|
attributes[OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES.resumable] = String(options.resumable);
|
|
456
461
|
}
|
|
@@ -648,7 +653,6 @@ export {
|
|
|
648
653
|
checkoutElementStyles,
|
|
649
654
|
checkoutLabels,
|
|
650
655
|
copyInvoice,
|
|
651
|
-
createAssetBaseUrlResolver,
|
|
652
656
|
createBlockExplorerUrl,
|
|
653
657
|
createCheckoutActionEvent,
|
|
654
658
|
createCheckoutController,
|
|
@@ -705,13 +709,13 @@ export {
|
|
|
705
709
|
getPaymentMethodIcon,
|
|
706
710
|
getPaymentMethodIconId,
|
|
707
711
|
getPaymentWizardRoutes,
|
|
708
|
-
getRouteIconPath,
|
|
709
712
|
getRouteNetworkLabel,
|
|
710
713
|
getSwapOptionIcon,
|
|
711
714
|
getSwapOptionIconId,
|
|
712
715
|
getSwapRefundFormError,
|
|
713
716
|
getWizardEmptyMessage,
|
|
714
717
|
isReusableLightningInvoice,
|
|
718
|
+
loadPayTutorialImages,
|
|
715
719
|
mergeAttemptIntoCheckout,
|
|
716
720
|
mergeAttemptIntoSnapshot,
|
|
717
721
|
networkButtonClasses,
|
|
@@ -727,8 +731,8 @@ export {
|
|
|
727
731
|
parsePaymentMethod,
|
|
728
732
|
parseResolvedTheme,
|
|
729
733
|
parseThemePreference,
|
|
734
|
+
payTutorialImage,
|
|
730
735
|
paymentAccentId,
|
|
731
|
-
paymentIconPaths,
|
|
732
736
|
paymentIconSvgs,
|
|
733
737
|
paymentIconUrls,
|
|
734
738
|
paymentMethods,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aW as BrowserLogLevel } from './status-
|
|
2
|
-
export { aX as BrowserLogEntry, X as BrowserLogger, B as BrowserLoggerOption, Y as BrowserRequestError, Z as CheckoutController, _ as CheckoutControllerOptions, h as CheckoutSnapshot, j as CheckoutState, aY as CopyInvoiceOptions, aZ as GuestCheckoutResumeController, a_ as GuestCheckoutResumeOptions, a$ as OpenWalletOptions, b0 as PrepareCheckoutOptions, b1 as QrOptions, b2 as RequestCheckoutOptions, ar as Status, b3 as StatusInvoiceLike, U as UnixSeconds, aw as copyInvoice, ay as createCheckoutController, b4 as createGuestCheckoutResume, b5 as createGuestOrderFetcher, b6 as createLightningUri, b7 as createQrPngDataUrl, aD as createQrSvg, aJ as deriveStatus, aK as enterCheckoutResumePath, aS as openWallet, aU as prepareCheckout, aV as requestCheckout } from './status-
|
|
1
|
+
import { aW as BrowserLogLevel } from './status-Doh8Wz4D.js';
|
|
2
|
+
export { aX as BrowserLogEntry, X as BrowserLogger, B as BrowserLoggerOption, Y as BrowserRequestError, Z as CheckoutController, _ as CheckoutControllerOptions, h as CheckoutSnapshot, j as CheckoutState, aY as CopyInvoiceOptions, aZ as GuestCheckoutResumeController, a_ as GuestCheckoutResumeOptions, a$ as OpenWalletOptions, b0 as PrepareCheckoutOptions, b1 as QrOptions, b2 as RequestCheckoutOptions, ar as Status, b3 as StatusInvoiceLike, U as UnixSeconds, aw as copyInvoice, ay as createCheckoutController, b4 as createGuestCheckoutResume, b5 as createGuestOrderFetcher, b6 as createLightningUri, b7 as createQrPngDataUrl, aD as createQrSvg, aJ as deriveStatus, aK as enterCheckoutResumePath, aS as openWallet, aU as prepareCheckout, aV as requestCheckout } from './status-Doh8Wz4D.js';
|
|
3
3
|
import '@openreceive/provider-data';
|
|
4
4
|
import '@openreceive/core';
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -248,6 +248,13 @@ declare const OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES: {
|
|
|
248
248
|
* attribute — see `checkoutRoutes` in ../internal/routes.ts.
|
|
249
249
|
*/
|
|
250
250
|
readonly prefix: "prefix";
|
|
251
|
+
/**
|
|
252
|
+
* Header name the page's `<meta name="csrf-token">` value is sent under on
|
|
253
|
+
* every request the element makes. Default `X-CSRF-Token` (Rails, Laravel);
|
|
254
|
+
* Django reads `X-CSRFToken`, WordPress REST reads `X-WP-Nonce`. The meta
|
|
255
|
+
* tag name is fixed; only the header name is the host's to choose.
|
|
256
|
+
*/
|
|
257
|
+
readonly csrfHeader: "csrf-header";
|
|
251
258
|
/** JSON-encoded create-time metadata forwarded to the create request. */
|
|
252
259
|
readonly metadata: "metadata";
|
|
253
260
|
readonly invoiceId: "invoice-id";
|
|
@@ -293,19 +300,6 @@ declare const OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES: {
|
|
|
293
300
|
* default), no decode link is rendered and the invoice never leaves the page.
|
|
294
301
|
*/
|
|
295
302
|
readonly decodeLinkUrl: "decode-link-url";
|
|
296
|
-
/**
|
|
297
|
-
* Where this app serves the packages' `dist/assets` trees, as one base URL —
|
|
298
|
-
* the string form of the `resolveAssetUrl` seam, so plain markup and the
|
|
299
|
-
* Vue/Svelte/Angular wrappers can reach it (a function cannot cross an HTML
|
|
300
|
-
* attribute). Every packaged key is a relative path under one `assets/` root,
|
|
301
|
-
* so the value is joined to it directly: `asset-base-url="/openreceive-assets"`
|
|
302
|
-
* makes `assets/provider-icons/strike.png` load from
|
|
303
|
-
* `/openreceive-assets/assets/provider-icons/strike.png`. Only the provider
|
|
304
|
-
* images need it; the payment-method icons are compiled in and drawn inline
|
|
305
|
-
* unless a base URL is set, in which case they are served as files too. A
|
|
306
|
-
* `resolveAssetUrl` passed to `defineElements` wins over it.
|
|
307
|
-
*/
|
|
308
|
-
readonly assetBaseUrl: "asset-base-url";
|
|
309
303
|
/** `polling="false"` renders the snapshot without status polling (no POST /payments/check). */
|
|
310
304
|
readonly polling: "polling";
|
|
311
305
|
/** Status poll cadence in milliseconds; defaults to OPENRECEIVE_DEFAULT_POLL_INTERVAL_MS. */
|
|
@@ -653,6 +647,13 @@ interface CheckoutElementAttributeOptions {
|
|
|
653
647
|
* routes without spelling them out.
|
|
654
648
|
*/
|
|
655
649
|
readonly prefix?: string;
|
|
650
|
+
/**
|
|
651
|
+
* Header name the page's `<meta name="csrf-token">` value is sent under on
|
|
652
|
+
* every request the element makes. Emitted as the element's `csrf-header`
|
|
653
|
+
* attribute. Default `X-CSRF-Token` (Rails, Laravel); Django reads
|
|
654
|
+
* `X-CSRFToken`, WordPress REST reads `X-WP-Nonce`.
|
|
655
|
+
*/
|
|
656
|
+
readonly csrfHeader?: string;
|
|
656
657
|
/**
|
|
657
658
|
* Optional create-time metadata (parity with the React `<Checkout metadata>`
|
|
658
659
|
* prop): JSON-encoded onto the element's `metadata` attribute and sent with
|
|
@@ -688,14 +689,6 @@ interface CheckoutElementAttributeOptions {
|
|
|
688
689
|
* renders no "Decode" link and the invoice is never sent to a third party.
|
|
689
690
|
*/
|
|
690
691
|
readonly decodeLinkUrl?: string;
|
|
691
|
-
/**
|
|
692
|
-
* Where this app serves the packages' `dist/assets` trees, as one base URL.
|
|
693
|
-
* The string form of the `resolveAssetUrl` seam: every packaged asset key is a
|
|
694
|
-
* relative path under one `assets/` root, so the value is joined to it
|
|
695
|
-
* directly. Emitted as the element's `asset-base-url` attribute, which is how
|
|
696
|
-
* the Vue/Svelte/Angular wrappers reach a seam a function cannot cross.
|
|
697
|
-
*/
|
|
698
|
-
readonly assetBaseUrl?: string;
|
|
699
692
|
/** False renders the snapshot without status polling (no POST /payments/check). */
|
|
700
693
|
readonly polling?: boolean;
|
|
701
694
|
/** Status poll cadence in milliseconds; defaults to OPENRECEIVE_DEFAULT_POLL_INTERVAL_MS. */
|
|
@@ -824,7 +817,7 @@ interface RequestCheckoutOptions extends RequestCheckoutBaseOptions {
|
|
|
824
817
|
* `prepareCheckout` posts only the order id — it locks the amount and lists
|
|
825
818
|
* payment methods without minting — so there is no memo or metadata to carry.
|
|
826
819
|
*/
|
|
827
|
-
type PrepareCheckoutOptions = Pick<RequestCheckoutBaseOptions, "prefix" | "reference" | "fetch" | "headers">;
|
|
820
|
+
type PrepareCheckoutOptions = Pick<RequestCheckoutBaseOptions, "prefix" | "reference" | "fetch" | "headers" | "csrfHeader">;
|
|
828
821
|
interface RequestCheckoutBaseOptions {
|
|
829
822
|
/**
|
|
830
823
|
* Base path the shipped router is mounted at (e.g. `/openreceive`). The create and
|
|
@@ -835,6 +828,12 @@ interface RequestCheckoutBaseOptions {
|
|
|
835
828
|
readonly reference: string;
|
|
836
829
|
readonly fetch?: typeof globalThis.fetch;
|
|
837
830
|
readonly headers?: Readonly<Record<string, string>>;
|
|
831
|
+
/**
|
|
832
|
+
* Header name the page's `<meta name="csrf-token">` value is sent under.
|
|
833
|
+
* Default `X-CSRF-Token` (Rails, Laravel); Django reads `X-CSRFToken`,
|
|
834
|
+
* WordPress REST reads `X-WP-Nonce`. The meta tag name itself is fixed.
|
|
835
|
+
*/
|
|
836
|
+
readonly csrfHeader?: string;
|
|
838
837
|
readonly memo?: string;
|
|
839
838
|
readonly metadata?: Record<string, unknown>;
|
|
840
839
|
}
|
|
@@ -848,6 +847,8 @@ interface CreateOpenReceiveStatusFetcherOptions {
|
|
|
848
847
|
readonly snapshot: CheckoutSnapshot;
|
|
849
848
|
readonly fetch?: typeof globalThis.fetch;
|
|
850
849
|
readonly headers?: Readonly<Record<string, string>>;
|
|
850
|
+
/** Header name the page's `<meta name="csrf-token">` is sent under; default `X-CSRF-Token`. */
|
|
851
|
+
readonly csrfHeader?: string;
|
|
851
852
|
}
|
|
852
853
|
interface CheckoutWatcherOptions {
|
|
853
854
|
readonly snapshot: CheckoutSnapshot;
|
|
@@ -878,6 +879,11 @@ interface CheckoutControllerOptions extends Omit<CheckoutWatcherOptions, "onStat
|
|
|
878
879
|
readonly polling?: boolean;
|
|
879
880
|
readonly fetch?: typeof globalThis.fetch;
|
|
880
881
|
readonly statusHeaders?: Readonly<Record<string, string>>;
|
|
882
|
+
/**
|
|
883
|
+
* Header name the page's `<meta name="csrf-token">` is sent under, on the
|
|
884
|
+
* status poll and the swap refund calls alike. Default `X-CSRF-Token`.
|
|
885
|
+
*/
|
|
886
|
+
readonly csrfHeader?: string;
|
|
881
887
|
readonly clipboard?: Pick<Clipboard, "writeText">;
|
|
882
888
|
readonly open?: (uri: string) => void;
|
|
883
889
|
}
|
|
@@ -1040,18 +1046,20 @@ interface WizardRouteAssetDisplay {
|
|
|
1040
1046
|
readonly id: string;
|
|
1041
1047
|
readonly label: string;
|
|
1042
1048
|
readonly subtitle: string;
|
|
1043
|
-
/** The icon as a
|
|
1049
|
+
/** The icon as a `data:` URI. */
|
|
1044
1050
|
readonly icon: string;
|
|
1045
1051
|
/** The key behind `icon`, into `paymentIconSvgs` for a renderer drawing it inline. */
|
|
1046
1052
|
readonly iconId: PaymentIconId;
|
|
1047
|
-
/** The packaged path behind `icon`, for a host serving the files itself. */
|
|
1048
|
-
readonly iconPath: string;
|
|
1049
1053
|
readonly selected: boolean;
|
|
1050
1054
|
}
|
|
1051
1055
|
interface WizardProviderTutorialDisplay {
|
|
1052
1056
|
readonly index: number;
|
|
1053
1057
|
readonly path: string;
|
|
1054
|
-
|
|
1058
|
+
/**
|
|
1059
|
+
* The screenshot as a `data:` URI, or `undefined` until
|
|
1060
|
+
* `loadPayTutorialImages()` has resolved (the caption renders alone until then).
|
|
1061
|
+
*/
|
|
1062
|
+
readonly image: string | undefined;
|
|
1055
1063
|
readonly caption: string;
|
|
1056
1064
|
}
|
|
1057
1065
|
interface WizardProviderDisplay {
|
|
@@ -1059,14 +1067,8 @@ interface WizardProviderDisplay {
|
|
|
1059
1067
|
readonly name: string;
|
|
1060
1068
|
readonly kind: string;
|
|
1061
1069
|
readonly url: string;
|
|
1070
|
+
/** The wallet logo as a `data:` URI. */
|
|
1062
1071
|
readonly icon: string;
|
|
1063
|
-
/**
|
|
1064
|
-
* The packaged path the icon came from (`assets/provider-icons/strike.png`).
|
|
1065
|
-
* `icon` is only loadable when the host's bundler resolved it; this is the
|
|
1066
|
-
* key a host that serves the files itself maps, without going back to
|
|
1067
|
-
* `providerRegistry` for `icon_path`.
|
|
1068
|
-
*/
|
|
1069
|
-
readonly iconPath: string;
|
|
1070
1072
|
readonly tutorials: readonly WizardProviderTutorialDisplay[];
|
|
1071
1073
|
readonly copyLabel: string;
|
|
1072
1074
|
readonly copiedLabel: string;
|