@openreceive/browser 0.2.1 → 0.2.3

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.
@@ -1,5 +1,5 @@
1
- import { P as ParseOpenReceiveOptionalIntegerOptions, a as PaymentMethod, R as ResolvedTheme, T as ThemePreference, b as PaymentMethodOption, c as TickingValueOptions, d as TickingValueController, e as TransientFeedbackOptions, f as TransientFeedbackController, C as CheckoutInvoiceSnapshot, S as SwapDisplayModel, g as CheckoutInvoiceSwapSnapshot, h as CheckoutState, i as TransactionDetailsInput, j as TransactionDetailRow, k as CheckoutSnapshot, l as CreateCheckoutStateOptions, m as CheckoutStatusModelInput, n as CheckoutStatusModel, o as CheckoutPaymentMethod, B as BrowserLoggerOption, p as ThemeAttributeTarget, q as CheckoutElementAttributes, r as CheckoutElementAttributeOptions, s as CheckoutElementEventHandlers, t as CheckoutElementListeners, u as CreateCheckoutShellOptions, v as CheckoutShellElements, w as CheckoutShellOptions, x as CheckoutShellModel, y as CreateOpenReceiveThemeToggleElementOptions, z as ThemeToggleElementAttributeOptions, A as ThemeToggleElementAttributes, D as StoredThemeModelOptions, E as ThemeModel, F as ThemeModelOptions, G as ReadThemePreferenceOptions, H as ThemeControlTargets, I as ThemeStorageOptions, J as PaymentWizardControllerOptions, K as PaymentWizardController, L as PaymentWizardSelection, M as PaymentWizardModel, W as WizardRouteAssetDisplay, N as WizardRouteDisplay, O as PaymentWizardSelectionAction } from './status-CLCX5lfx.js';
2
- export { Q as BrowserLogContext, U as BrowserLogger, V as BrowserRequestError, X as CheckoutController, Y as CheckoutControllerOptions, Z as CheckoutPhase, _ as CheckoutStatusRefresh, $ as OPENRECEIVE_CHECKOUT_DATA_ATTRIBUTES, a0 as OPENRECEIVE_CHECKOUT_DATA_SELECTORS, a1 as OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES, a2 as OPENRECEIVE_CHECKOUT_ELEMENT_EVENTS, a3 as OPENRECEIVE_CHECKOUT_ELEMENT_PARTS, a4 as OPENRECEIVE_CHECKOUT_ELEMENT_PART_SELECTORS, a5 as OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME, a6 as OPENRECEIVE_COPY_FEEDBACK_MS, a7 as OPENRECEIVE_DEFAULT_POLL_INTERVAL_MS, a8 as OPENRECEIVE_DEFAULT_PREFIX, a9 as OPENRECEIVE_PAYMENT_WIZARD_ATTRIBUTES, aa as OPENRECEIVE_PAYMENT_WIZARD_SELECTORS, ab as OPENRECEIVE_THEME_STORAGE_KEY, ac as OPENRECEIVE_THEME_TOGGLE_ELEMENT_ATTRIBUTES, ad as OPENRECEIVE_THEME_TOGGLE_ELEMENT_EVENTS, ae as OPENRECEIVE_THEME_TOGGLE_ELEMENT_PARTS, af as OPENRECEIVE_THEME_TOGGLE_ELEMENT_PART_SELECTORS, ag as OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME, ah as QrEncoder, ai as Status, aj as WizardProviderDisplay, ak as assertDisplayInvoice, al as copyInvoice, am as createCheckoutActionEvent, an as createCheckoutController, ao as createCheckoutErrorEvent, ap as createCheckoutProviderCopyEvent, aq as createCheckoutStateEvent, ar as createQrPayloadSvg, as as createQrSvg, at as createStatusFetcher, au as createThemeChangeEvent, av as deriveCheckoutStateLabels, aw as deriveStatus, ax as enterCheckoutResumePath, ay as escapeHtml, az as formatAmountCaption, aA as formatDepositAmount, aB as formatFiatAmount, aC as formatMsats, aD as formatSwapLimit, aE as formatUnixTime, aF as openWallet, aG as prepareCheckout, aH as requestCheckout } from './status-CLCX5lfx.js';
1
+ import { P as ParseOpenReceiveOptionalIntegerOptions, a as PaymentMethod, R as ResolvedTheme, T as ThemePreference, b as PaymentMethodOption, c as TickingValueOptions, d as TickingValueController, e as TransientFeedbackOptions, f as TransientFeedbackController, C as CheckoutInvoiceSnapshot, U as UnixSeconds, S as SwapDisplayModel, g as CheckoutInvoiceSwapSnapshot, h as CheckoutState, i as TransactionDetailsInput, j as TransactionDetailRow, k as CheckoutSnapshot, l as CreateCheckoutStateOptions, m as CheckoutStatusModelInput, n as CheckoutStatusModel, o as CheckoutPaymentMethod, B as BrowserLoggerOption, p as ThemeAttributeTarget, q as CheckoutElementAttributes, r as CheckoutElementAttributeOptions, s as CheckoutElementEventHandlers, t as CheckoutElementListeners, u as CreateCheckoutShellOptions, v as CheckoutShellElements, w as CheckoutShellOptions, x as CheckoutShellModel, y as CreateOpenReceiveThemeToggleElementOptions, z as ThemeToggleElementAttributeOptions, A as ThemeToggleElementAttributes, D as StoredThemeModelOptions, E as ThemeModel, F as ThemeModelOptions, G as ReadThemePreferenceOptions, H as ThemeControlTargets, I as ThemeStorageOptions, J as PaymentWizardControllerOptions, K as PaymentWizardController, L as PaymentWizardSelection, M as PaymentWizardModel, W as WizardRouteAssetDisplay, N as WizardRouteDisplay, O as PaymentWizardSelectionAction } from './status-B1vDOhvh.js';
2
+ export { Q as BrowserLogContext, V as BrowserLogger, X as BrowserRequestError, Y as CheckoutController, Z as CheckoutControllerOptions, _ as CheckoutPhase, $ as CheckoutStatusRefresh, a0 as OPENRECEIVE_CHECKOUT_DATA_ATTRIBUTES, a1 as OPENRECEIVE_CHECKOUT_DATA_SELECTORS, a2 as OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES, a3 as OPENRECEIVE_CHECKOUT_ELEMENT_EVENTS, a4 as OPENRECEIVE_CHECKOUT_ELEMENT_PARTS, a5 as OPENRECEIVE_CHECKOUT_ELEMENT_PART_SELECTORS, a6 as OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME, a7 as OPENRECEIVE_COPY_FEEDBACK_MS, a8 as OPENRECEIVE_DEFAULT_POLL_INTERVAL_MS, a9 as OPENRECEIVE_DEFAULT_PREFIX, aa as OPENRECEIVE_PAYMENT_WIZARD_ATTRIBUTES, ab as OPENRECEIVE_PAYMENT_WIZARD_SELECTORS, ac as OPENRECEIVE_THEME_STORAGE_KEY, ad as OPENRECEIVE_THEME_TOGGLE_ELEMENT_ATTRIBUTES, ae as OPENRECEIVE_THEME_TOGGLE_ELEMENT_EVENTS, af as OPENRECEIVE_THEME_TOGGLE_ELEMENT_PARTS, ag as OPENRECEIVE_THEME_TOGGLE_ELEMENT_PART_SELECTORS, ah as OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME, ai as QrEncoder, aj as Status, ak as WizardProviderDisplay, al as assertDisplayInvoice, am as copyInvoice, an as createCheckoutActionEvent, ao as createCheckoutController, ap as createCheckoutErrorEvent, aq as createCheckoutProviderCopyEvent, ar as createCheckoutStateEvent, as as createQrPayloadSvg, at as createQrSvg, au as createStatusFetcher, av as createThemeChangeEvent, aw as deriveCheckoutStateLabels, ax as deriveStatus, ay as enterCheckoutResumePath, az as escapeHtml, aA as formatAmountCaption, aB as formatDepositAmount, aC as formatFiatAmount, aD as formatMsats, aE as formatSwapLimit, aF as formatUnixTime, aG as openWallet, aH as prepareCheckout, aI as requestCheckout } from './status-B1vDOhvh.js';
3
3
  import { AssetIndexEntry, PaymentWizardRoute } from '@openreceive/provider-data';
4
4
  import '@openreceive/core';
5
5
 
@@ -258,8 +258,13 @@ declare function parsePaymentMethod(value: string | null): PaymentMethod | null;
258
258
  declare function createTransientFeedbackController<T>(options: TransientFeedbackOptions<T>): TransientFeedbackController<T>;
259
259
  declare function createTickingValueController(options: TickingValueOptions): TickingValueController;
260
260
 
261
+ /**
262
+ * @param options.now Unix timestamp in **seconds** ({@link UnixSeconds}); the
263
+ * provider countdown is measured against it. Milliseconds (`Date.now()`)
264
+ * throw rather than pinning every deposit window at zero.
265
+ */
261
266
  declare function createSwapDisplayModel(invoice: CheckoutInvoiceSnapshot, options?: {
262
- readonly now?: number;
267
+ readonly now?: UnixSeconds;
263
268
  }): SwapDisplayModel | undefined;
264
269
  /**
265
270
  * Poll snapshots omit the locally staged refund address/nonce. Overlay them so
@@ -379,7 +384,7 @@ declare function selectCheckoutDisplayInvoice(snapshot: CheckoutSnapshot): Check
379
384
  * seconds remaining. Pass an optional `now` (Unix seconds) for deterministic tests; defaults to the
380
385
  * current clock.
381
386
  */
382
- declare function isReusableLightningInvoice(expiresAt: number, now?: number): boolean;
387
+ declare function isReusableLightningInvoice(expiresAt: number, now?: UnixSeconds): boolean;
383
388
  declare function createCheckoutState(snapshot: CheckoutSnapshot, options?: CreateCheckoutStateOptions): CheckoutState;
384
389
  /**
385
390
  * Wrap ONE payment attempt as a whole checkout snapshot.
@@ -399,7 +404,7 @@ declare function createCheckoutSnapshotFromInvoice(attempt: CheckoutInvoiceSnaps
399
404
  readonly reference?: string;
400
405
  }): CheckoutSnapshot;
401
406
  declare function createCheckoutStatusModel(source?: CheckoutState | CheckoutStatusModelInput, options?: {
402
- readonly now?: number;
407
+ readonly now?: UnixSeconds;
403
408
  }): CheckoutStatusModel;
404
409
 
405
410
  /**
@@ -796,4 +801,4 @@ declare function createPaymentWizardModel(selection: PaymentWizardSelection): Pa
796
801
  declare function updatePaymentWizardSelection(selection: PaymentWizardSelection, action: PaymentWizardSelectionAction): PaymentWizardSelection;
797
802
  declare function createPaymentWizardController(options?: PaymentWizardControllerOptions): PaymentWizardController;
798
803
 
799
- export { BrowserLoggerOption, type CheckoutComponentProps, CheckoutElementAttributeOptions, CheckoutElementAttributes, CheckoutElementEventHandlers, CheckoutElementListeners, CheckoutInvoiceSnapshot, CheckoutPaymentMethod, type CheckoutPropsValidation, type CheckoutSession, type CheckoutSessionOptions, CheckoutShellElements, CheckoutShellModel, CheckoutShellOptions, CheckoutSnapshot, CheckoutState, CheckoutStatusModel, CreateCheckoutShellOptions, type DetailLinkKind, type MethodGridEntry, type PaymentDataSource, PaymentMethod, PaymentWizardController, PaymentWizardModel, PaymentWizardSelection, ResolvedTheme, StoredThemeModelOptions, SwapDisplayModel, type SwapLimitContext, type SwapMethodGroup, type SwapSelection, type SwapUnavailableModel, ThemeModel, ThemeModelOptions, ThemePreference, ThemeToggleElementAttributeOptions, ThemeToggleElementAttributes, TransactionDetailRow, TransactionDetailsInput, type TransactionDetailsSource, TransientFeedbackController, WizardRouteAssetDisplay, WizardRouteDisplay, applyCheckoutElementAttributes, assetButtonClasses, buildMethodGridEntries, checkoutElementStyles, checkoutLabels, createBlockExplorerUrl, createCheckoutElementAttributes, createCheckoutElementListeners, createCheckoutSession, createCheckoutShell, createCheckoutShellModel, createCheckoutSnapshotFromInvoice, createCheckoutState, createCheckoutStatusModel, createDetailExternalLink, createLightningInvoiceDecodeUrl, createPaymentDataEntries, createPaymentWizardController, createPaymentWizardModel, createPaymentWizardSelection, createStoredThemeModel, createSwapDisplayModel, createSwapUnavailableModel, createThemeModel, createThemeToggleElement, createThemeToggleElementAttributes, createTickingValueController, createTransactionDetails, createTransactionDetailsFromState, createTransientFeedbackController, createWizardRouteAssetDisplays, createWizardRouteDisplays, findSwapGridGroup, formatChooseNetworkHeading, formatNetworkSummary, getExplorerNetwork, getNetworkIcon, getPaymentMethodIcon, getRouteNetworkLabel, getSwapOptionIcon, getSwapRefundFormError, getWizardEmptyMessage, isReusableLightningInvoice, mergeAttemptIntoCheckout, mergeAttemptIntoSnapshot, networkButtonClasses, networkCheckClasses, networkMobileRevealClasses, networkSummaryIconClasses, normalizeSwapStartInvoice, orClasses, overlaySwapRefundStaging, parseBooleanAttribute, parseMethodPickerKey, parseOptionalInteger, parsePaymentMethod, parseResolvedTheme, parseThemePreference, paymentAccentId, paymentIconUrls, paymentMethods, postJson, readThemePreference, requestSwapRefund, resolvePreservedNetworkSelection, resolveTransactionDetailRows, selectCheckoutDisplayInvoice, startSwapRequest, swapAssetMatchesRoute, swapGroupLimitOption, swapOptionLimitMessage, swapPickerKey, syncStoredThemeControls, toggleStoredThemeControls, updatePaymentWizardSelection, updateSelectedSwapNetworks, validateCheckoutProps, wizardNetworkGroupIds, writeThemePreference };
804
+ export { BrowserLoggerOption, type CheckoutComponentProps, CheckoutElementAttributeOptions, CheckoutElementAttributes, CheckoutElementEventHandlers, CheckoutElementListeners, CheckoutInvoiceSnapshot, CheckoutPaymentMethod, type CheckoutPropsValidation, type CheckoutSession, type CheckoutSessionOptions, CheckoutShellElements, CheckoutShellModel, CheckoutShellOptions, CheckoutSnapshot, CheckoutState, CheckoutStatusModel, CreateCheckoutShellOptions, type DetailLinkKind, type MethodGridEntry, type PaymentDataSource, PaymentMethod, PaymentWizardController, PaymentWizardModel, PaymentWizardSelection, ResolvedTheme, StoredThemeModelOptions, SwapDisplayModel, type SwapLimitContext, type SwapMethodGroup, type SwapSelection, type SwapUnavailableModel, ThemeModel, ThemeModelOptions, ThemePreference, ThemeToggleElementAttributeOptions, ThemeToggleElementAttributes, TransactionDetailRow, TransactionDetailsInput, type TransactionDetailsSource, TransientFeedbackController, UnixSeconds, WizardRouteAssetDisplay, WizardRouteDisplay, applyCheckoutElementAttributes, assetButtonClasses, buildMethodGridEntries, checkoutElementStyles, checkoutLabels, createBlockExplorerUrl, createCheckoutElementAttributes, createCheckoutElementListeners, createCheckoutSession, createCheckoutShell, createCheckoutShellModel, createCheckoutSnapshotFromInvoice, createCheckoutState, createCheckoutStatusModel, createDetailExternalLink, createLightningInvoiceDecodeUrl, createPaymentDataEntries, createPaymentWizardController, createPaymentWizardModel, createPaymentWizardSelection, createStoredThemeModel, createSwapDisplayModel, createSwapUnavailableModel, createThemeModel, createThemeToggleElement, createThemeToggleElementAttributes, createTickingValueController, createTransactionDetails, createTransactionDetailsFromState, createTransientFeedbackController, createWizardRouteAssetDisplays, createWizardRouteDisplays, findSwapGridGroup, formatChooseNetworkHeading, formatNetworkSummary, getExplorerNetwork, getNetworkIcon, getPaymentMethodIcon, getRouteNetworkLabel, getSwapOptionIcon, getSwapRefundFormError, getWizardEmptyMessage, isReusableLightningInvoice, mergeAttemptIntoCheckout, mergeAttemptIntoSnapshot, networkButtonClasses, networkCheckClasses, networkMobileRevealClasses, networkSummaryIconClasses, normalizeSwapStartInvoice, orClasses, overlaySwapRefundStaging, parseBooleanAttribute, parseMethodPickerKey, parseOptionalInteger, parsePaymentMethod, parseResolvedTheme, parseThemePreference, paymentAccentId, paymentIconUrls, paymentMethods, postJson, readThemePreference, requestSwapRefund, resolvePreservedNetworkSelection, resolveTransactionDetailRows, selectCheckoutDisplayInvoice, startSwapRequest, swapAssetMatchesRoute, swapGroupLimitOption, swapOptionLimitMessage, swapPickerKey, syncStoredThemeControls, toggleStoredThemeControls, updatePaymentWizardSelection, updateSelectedSwapNetworks, validateCheckoutProps, wizardNetworkGroupIds, writeThemePreference };
package/dist/headless.js CHANGED
@@ -56,6 +56,7 @@ import {
56
56
  deriveStatus,
57
57
  enterCheckoutResumePath,
58
58
  escapeHtml,
59
+ findReusableLightningInvoice,
59
60
  findSwapGridGroup,
60
61
  formatAmountCaption,
61
62
  formatChooseNetworkHeading,
@@ -74,6 +75,9 @@ import {
74
75
  getWizardEmptyMessage,
75
76
  isPaidCheckoutSnapshot,
76
77
  isReusableLightningInvoice,
78
+ mergeAttemptIntoCheckout,
79
+ mergeAttemptIntoSnapshot,
80
+ mergeMintedCheckout,
77
81
  networkButtonClasses,
78
82
  networkCheckClasses,
79
83
  networkMobileRevealClasses,
@@ -107,52 +111,7 @@ import {
107
111
  updatePaymentWizardSelection,
108
112
  updateSelectedSwapNetworks,
109
113
  wizardNetworkGroupIds
110
- } from "./chunk-V7C55QB2.js";
111
-
112
- // src/internal/checkout-merge.ts
113
- function findReusableLightningInvoice(snapshot, now) {
114
- return snapshot.invoices.find(
115
- (invoice) => invoice.rail === "lightning" && typeof invoice.invoice === "string" && invoice.invoice.length > 0 && invoice.expires_at !== void 0 && isReusableLightningInvoice(invoice.expires_at, now)
116
- );
117
- }
118
- function mergeAttemptIntoSnapshot(invoice, base) {
119
- const withoutSame = base.invoices.filter(
120
- (entry) => entry.invoice_id !== invoice.invoice_id && entry.rail !== "checkout_lock"
121
- );
122
- return {
123
- ...base,
124
- checkout_id: invoice.invoice_id,
125
- active: invoice,
126
- invoices: [invoice, ...withoutSame],
127
- ...invoice.amount_msats === void 0 ? {} : { amount_msats: invoice.amount_msats }
128
- };
129
- }
130
- function mergeAttemptIntoCheckout(invoice, previous, reference) {
131
- const base = previous ?? {
132
- checkout_id: invoice.invoice_id,
133
- reference,
134
- status: "open",
135
- amount_msats: invoice.amount_msats ?? 0,
136
- invoices: []
137
- };
138
- return mergeAttemptIntoSnapshot(invoice, base);
139
- }
140
- function mergeMintedCheckout(checkout, previous) {
141
- const minted = selectCheckoutDisplayInvoice(checkout) ?? checkout.active;
142
- if (minted === void 0) {
143
- return {
144
- ...checkout,
145
- ...previous?.payment_methods === void 0 ? {} : { payment_methods: previous.payment_methods }
146
- };
147
- }
148
- if (previous === void 0) return mergeAttemptIntoSnapshot(minted, checkout);
149
- return mergeAttemptIntoSnapshot(minted, {
150
- ...previous,
151
- ...checkout,
152
- invoices: previous.invoices,
153
- payment_methods: previous.payment_methods ?? checkout.payment_methods
154
- });
155
- }
114
+ } from "./chunk-JFJBHGR4.js";
156
115
 
157
116
  // src/internal/checkout-props.ts
158
117
  var CREATE_MODE_ONLY_PROPS = [
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { aI as BrowserLogLevel } from './status-CLCX5lfx.js';
2
- export { aJ as BrowserLogEntry, U as BrowserLogger, B as BrowserLoggerOption, V as BrowserRequestError, X as CheckoutController, Y as CheckoutControllerOptions, k as CheckoutSnapshot, h as CheckoutState, aK as CopyInvoiceOptions, aL as GuestCheckoutResumeController, aM as GuestCheckoutResumeOptions, aN as OpenWalletOptions, aO as PrepareCheckoutOptions, aP as QrOptions, aQ as RequestCheckoutOptions, ai as Status, aR as StatusInvoiceLike, al as copyInvoice, an as createCheckoutController, aS as createGuestCheckoutResume, aT as createGuestOrderFetcher, aU as createLightningUri, aV as createQrPngDataUrl, as as createQrSvg, aw as deriveStatus, ax as enterCheckoutResumePath, aF as openWallet, aG as prepareCheckout, aH as requestCheckout } from './status-CLCX5lfx.js';
1
+ import { aJ as BrowserLogLevel } from './status-B1vDOhvh.js';
2
+ export { aK as BrowserLogEntry, V as BrowserLogger, B as BrowserLoggerOption, X as BrowserRequestError, Y as CheckoutController, Z as CheckoutControllerOptions, k as CheckoutSnapshot, h as CheckoutState, aL as CopyInvoiceOptions, aM as GuestCheckoutResumeController, aN as GuestCheckoutResumeOptions, aO as OpenWalletOptions, aP as PrepareCheckoutOptions, aQ as QrOptions, aR as RequestCheckoutOptions, aj as Status, aS as StatusInvoiceLike, U as UnixSeconds, am as copyInvoice, ao as createCheckoutController, aT as createGuestCheckoutResume, aU as createGuestOrderFetcher, aV as createLightningUri, aW as createQrPngDataUrl, at as createQrSvg, ax as deriveStatus, ay as enterCheckoutResumePath, aG as openWallet, aH as prepareCheckout, aI as requestCheckout } from './status-B1vDOhvh.js';
3
3
  import '@openreceive/provider-data';
4
4
  import '@openreceive/core';
5
5
 
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  openWallet,
14
14
  prepareCheckout,
15
15
  requestCheckout
16
- } from "./chunk-V7C55QB2.js";
16
+ } from "./chunk-JFJBHGR4.js";
17
17
  export {
18
18
  BrowserRequestError,
19
19
  copyInvoice,
@@ -1,6 +1,18 @@
1
1
  import { PaymentWizardRoute, AssetIndexEntry } from '@openreceive/provider-data';
2
2
  import { TransactionSettlementStatus } from '@openreceive/core';
3
3
 
4
+ /**
5
+ * A unix timestamp in **seconds** — the unit every OpenReceive wire field uses
6
+ * (`expires_at`, `provider_expires_at`, `settled_at`, `paid_at`) and therefore
7
+ * the unit every `now` option compares against.
8
+ *
9
+ * It is a plain `number`; the alias exists so the unit shows up where the
10
+ * option does. `Date.now()` is MILLISECONDS and is the wrong value here —
11
+ * {@link resolveNow} rejects it rather than letting every invoice read as
12
+ * expired. Use `Math.floor(Date.now() / 1000)`.
13
+ */
14
+ type UnixSeconds = number;
15
+
4
16
  /**
5
17
  * Trim insignificant trailing zeros from a decimal crypto amount for display,
6
18
  * e.g. "12.25900000" -> "12.259" and "5.000" -> "5". Only fractional digits are
@@ -273,7 +285,8 @@ interface TransientFeedbackController<T> {
273
285
  interface TickingValueOptions {
274
286
  readonly active?: boolean;
275
287
  readonly intervalMs?: number;
276
- readonly now?: () => number;
288
+ /** Clock returning unix **seconds** ({@link UnixSeconds}), not milliseconds. */
289
+ readonly now?: () => UnixSeconds;
277
290
  readonly setInterval?: typeof globalThis.setInterval;
278
291
  readonly clearInterval?: typeof globalThis.clearInterval;
279
292
  readonly onValue: (value: number) => void;
@@ -611,7 +624,20 @@ interface CheckoutStatusModel {
611
624
  readonly countdownLabel?: string;
612
625
  }
613
626
  type CheckoutStatusRefresh = (reference: string) => Promise<CheckoutSnapshot | null>;
614
- type RequestCheckoutOptions = RequestCheckoutBaseOptions;
627
+ interface RequestCheckoutOptions extends RequestCheckoutBaseOptions {
628
+ /**
629
+ * The snapshot already on screen — normally what {@link prepareCheckout}
630
+ * returned, or the running snapshot after an earlier attempt.
631
+ *
632
+ * `POST /checkouts` answers with the minted bolt11 alone; it does NOT carry
633
+ * the warmed `payment_methods` catalog that prepare returned. Without this,
634
+ * minting Lightning ERASES the method list a picker renders from: the payer
635
+ * selects Bitcoin, changes their mind, and the swap options are gone.
636
+ * Passing the previous snapshot folds the mint into it, keeping
637
+ * `payment_methods` and any sibling attempts.
638
+ */
639
+ readonly previous?: CheckoutSnapshot;
640
+ }
615
641
  /**
616
642
  * `prepareCheckout` posts only the order id — it locks the amount and lists
617
643
  * payment methods without minting — so there is no memo or metadata to carry.
@@ -645,7 +671,8 @@ interface CheckoutWatcherOptions {
645
671
  readonly snapshot: CheckoutSnapshot;
646
672
  readonly refreshStatus?: CheckoutStatusRefresh;
647
673
  readonly pollIntervalMs?: number;
648
- readonly now?: () => number;
674
+ /** Clock returning unix **seconds** ({@link UnixSeconds}), not milliseconds. */
675
+ readonly now?: () => UnixSeconds;
649
676
  readonly setInterval?: typeof globalThis.setInterval;
650
677
  readonly clearInterval?: typeof globalThis.clearInterval;
651
678
  readonly logger?: BrowserLoggerOption;
@@ -680,7 +707,12 @@ interface CheckoutController {
680
707
  openWallet(): string;
681
708
  }
682
709
  interface CreateCheckoutStateOptions {
683
- readonly now?: number;
710
+ /**
711
+ * Unix timestamp in **seconds** ({@link UnixSeconds}) the expiry clock is
712
+ * measured against; defaults to the current time. Milliseconds
713
+ * (`Date.now()`) throw a RangeError — see the type.
714
+ */
715
+ readonly now?: UnixSeconds;
684
716
  readonly logger?: BrowserLoggerOption;
685
717
  /**
686
718
  * How this state was produced. Controls which browser log events fire:
@@ -956,8 +988,14 @@ interface StatusInvoiceLike {
956
988
  readonly transaction_state?: string;
957
989
  readonly expires_at?: number | string | null;
958
990
  }
991
+ /**
992
+ * @param options.now Unix timestamp in **seconds** ({@link UnixSeconds}) to
993
+ * compare `expires_at` against; defaults to the current time. Milliseconds
994
+ * (`Date.now()`) throw a RangeError rather than reading every invoice as
995
+ * expired.
996
+ */
959
997
  declare function deriveStatus(invoice: StatusInvoiceLike, options?: {
960
- readonly now?: number;
998
+ readonly now?: UnixSeconds;
961
999
  }): Status;
962
1000
 
963
- export { OPENRECEIVE_CHECKOUT_DATA_ATTRIBUTES as $, type ThemeToggleElementAttributes as A, type BrowserLoggerOption as B, type CheckoutInvoiceSnapshot as C, type StoredThemeModelOptions as D, type ThemeModel as E, type ThemeModelOptions as F, type ReadThemePreferenceOptions as G, type ThemeControlTargets as H, type ThemeStorageOptions as I, type PaymentWizardControllerOptions as J, type PaymentWizardController as K, type PaymentWizardSelection as L, type PaymentWizardModel as M, type WizardRouteDisplay as N, type PaymentWizardSelectionAction as O, type ParseOpenReceiveOptionalIntegerOptions as P, type BrowserLogContext as Q, type ResolvedTheme as R, type SwapDisplayModel as S, type ThemePreference as T, type BrowserLogger as U, BrowserRequestError as V, type WizardRouteAssetDisplay as W, type CheckoutController as X, type CheckoutControllerOptions as Y, type CheckoutPhase as Z, type CheckoutStatusRefresh as _, type PaymentMethod as a, OPENRECEIVE_CHECKOUT_DATA_SELECTORS as a0, OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES as a1, OPENRECEIVE_CHECKOUT_ELEMENT_EVENTS as a2, OPENRECEIVE_CHECKOUT_ELEMENT_PARTS as a3, OPENRECEIVE_CHECKOUT_ELEMENT_PART_SELECTORS as a4, OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME as a5, OPENRECEIVE_COPY_FEEDBACK_MS as a6, OPENRECEIVE_DEFAULT_POLL_INTERVAL_MS as a7, OPENRECEIVE_DEFAULT_PREFIX as a8, OPENRECEIVE_PAYMENT_WIZARD_ATTRIBUTES as a9, formatDepositAmount as aA, formatFiatAmount as aB, formatMsats as aC, formatSwapLimit as aD, formatUnixTime as aE, openWallet as aF, prepareCheckout as aG, requestCheckout as aH, type BrowserLogLevel as aI, type BrowserLogEntry as aJ, type CopyInvoiceOptions as aK, type GuestCheckoutResumeController as aL, type GuestCheckoutResumeOptions as aM, type OpenWalletOptions as aN, type PrepareCheckoutOptions as aO, type QrOptions as aP, type RequestCheckoutOptions as aQ, type StatusInvoiceLike as aR, createGuestCheckoutResume as aS, createGuestOrderFetcher as aT, createLightningUri as aU, createQrPngDataUrl as aV, OPENRECEIVE_PAYMENT_WIZARD_SELECTORS as aa, OPENRECEIVE_THEME_STORAGE_KEY as ab, OPENRECEIVE_THEME_TOGGLE_ELEMENT_ATTRIBUTES as ac, OPENRECEIVE_THEME_TOGGLE_ELEMENT_EVENTS as ad, OPENRECEIVE_THEME_TOGGLE_ELEMENT_PARTS as ae, OPENRECEIVE_THEME_TOGGLE_ELEMENT_PART_SELECTORS as af, OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME as ag, type QrEncoder as ah, type Status as ai, type WizardProviderDisplay as aj, assertDisplayInvoice as ak, copyInvoice as al, createCheckoutActionEvent as am, createCheckoutController as an, createCheckoutErrorEvent as ao, createCheckoutProviderCopyEvent as ap, createCheckoutStateEvent as aq, createQrPayloadSvg as ar, createQrSvg as as, createStatusFetcher as at, createThemeChangeEvent as au, deriveCheckoutStateLabels as av, deriveStatus as aw, enterCheckoutResumePath as ax, escapeHtml as ay, formatAmountCaption as az, type PaymentMethodOption as b, type TickingValueOptions as c, type TickingValueController as d, type TransientFeedbackOptions as e, type TransientFeedbackController as f, type CheckoutInvoiceSwapSnapshot as g, type CheckoutState as h, type TransactionDetailsInput as i, type TransactionDetailRow as j, type CheckoutSnapshot as k, type CreateCheckoutStateOptions as l, type CheckoutStatusModelInput as m, type CheckoutStatusModel as n, type CheckoutPaymentMethod as o, type ThemeAttributeTarget as p, type CheckoutElementAttributes as q, type CheckoutElementAttributeOptions as r, type CheckoutElementEventHandlers as s, type CheckoutElementListeners as t, type CreateCheckoutShellOptions as u, type CheckoutShellElements as v, type CheckoutShellOptions as w, type CheckoutShellModel as x, type CreateOpenReceiveThemeToggleElementOptions as y, type ThemeToggleElementAttributeOptions as z };
1001
+ export { type CheckoutStatusRefresh as $, type ThemeToggleElementAttributes as A, type BrowserLoggerOption as B, type CheckoutInvoiceSnapshot as C, type StoredThemeModelOptions as D, type ThemeModel as E, type ThemeModelOptions as F, type ReadThemePreferenceOptions as G, type ThemeControlTargets as H, type ThemeStorageOptions as I, type PaymentWizardControllerOptions as J, type PaymentWizardController as K, type PaymentWizardSelection as L, type PaymentWizardModel as M, type WizardRouteDisplay as N, type PaymentWizardSelectionAction as O, type ParseOpenReceiveOptionalIntegerOptions as P, type BrowserLogContext as Q, type ResolvedTheme as R, type SwapDisplayModel as S, type ThemePreference as T, type UnixSeconds as U, type BrowserLogger as V, type WizardRouteAssetDisplay as W, BrowserRequestError as X, type CheckoutController as Y, type CheckoutControllerOptions as Z, type CheckoutPhase as _, type PaymentMethod as a, OPENRECEIVE_CHECKOUT_DATA_ATTRIBUTES as a0, OPENRECEIVE_CHECKOUT_DATA_SELECTORS as a1, OPENRECEIVE_CHECKOUT_ELEMENT_ATTRIBUTES as a2, OPENRECEIVE_CHECKOUT_ELEMENT_EVENTS as a3, OPENRECEIVE_CHECKOUT_ELEMENT_PARTS as a4, OPENRECEIVE_CHECKOUT_ELEMENT_PART_SELECTORS as a5, OPENRECEIVE_CHECKOUT_ELEMENT_TAG_NAME as a6, OPENRECEIVE_COPY_FEEDBACK_MS as a7, OPENRECEIVE_DEFAULT_POLL_INTERVAL_MS as a8, OPENRECEIVE_DEFAULT_PREFIX as a9, formatAmountCaption as aA, formatDepositAmount as aB, formatFiatAmount as aC, formatMsats as aD, formatSwapLimit as aE, formatUnixTime as aF, openWallet as aG, prepareCheckout as aH, requestCheckout as aI, type BrowserLogLevel as aJ, type BrowserLogEntry as aK, type CopyInvoiceOptions as aL, type GuestCheckoutResumeController as aM, type GuestCheckoutResumeOptions as aN, type OpenWalletOptions as aO, type PrepareCheckoutOptions as aP, type QrOptions as aQ, type RequestCheckoutOptions as aR, type StatusInvoiceLike as aS, createGuestCheckoutResume as aT, createGuestOrderFetcher as aU, createLightningUri as aV, createQrPngDataUrl as aW, OPENRECEIVE_PAYMENT_WIZARD_ATTRIBUTES as aa, OPENRECEIVE_PAYMENT_WIZARD_SELECTORS as ab, OPENRECEIVE_THEME_STORAGE_KEY as ac, OPENRECEIVE_THEME_TOGGLE_ELEMENT_ATTRIBUTES as ad, OPENRECEIVE_THEME_TOGGLE_ELEMENT_EVENTS as ae, OPENRECEIVE_THEME_TOGGLE_ELEMENT_PARTS as af, OPENRECEIVE_THEME_TOGGLE_ELEMENT_PART_SELECTORS as ag, OPENRECEIVE_THEME_TOGGLE_ELEMENT_TAG_NAME as ah, type QrEncoder as ai, type Status as aj, type WizardProviderDisplay as ak, assertDisplayInvoice as al, copyInvoice as am, createCheckoutActionEvent as an, createCheckoutController as ao, createCheckoutErrorEvent as ap, createCheckoutProviderCopyEvent as aq, createCheckoutStateEvent as ar, createQrPayloadSvg as as, createQrSvg as at, createStatusFetcher as au, createThemeChangeEvent as av, deriveCheckoutStateLabels as aw, deriveStatus as ax, enterCheckoutResumePath as ay, escapeHtml as az, type PaymentMethodOption as b, type TickingValueOptions as c, type TickingValueController as d, type TransientFeedbackOptions as e, type TransientFeedbackController as f, type CheckoutInvoiceSwapSnapshot as g, type CheckoutState as h, type TransactionDetailsInput as i, type TransactionDetailRow as j, type CheckoutSnapshot as k, type CreateCheckoutStateOptions as l, type CheckoutStatusModelInput as m, type CheckoutStatusModel as n, type CheckoutPaymentMethod as o, type ThemeAttributeTarget as p, type CheckoutElementAttributes as q, type CheckoutElementAttributeOptions as r, type CheckoutElementEventHandlers as s, type CheckoutElementListeners as t, type CreateCheckoutShellOptions as u, type CheckoutShellElements as v, type CheckoutShellOptions as w, type CheckoutShellModel as x, type CreateOpenReceiveThemeToggleElementOptions as y, type ThemeToggleElementAttributeOptions as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openreceive/browser",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Framework-free browser helpers for OpenReceive checkout: prepare/create calls, status polling, QR and wallet helpers.",
5
5
  "keywords": [
6
6
  "bitcoin",
@@ -31,8 +31,8 @@
31
31
  "./assets/*": "./dist/assets/*"
32
32
  },
33
33
  "dependencies": {
34
- "@openreceive/core": "0.2.1",
35
- "@openreceive/provider-data": "0.2.1",
34
+ "@openreceive/core": "0.2.3",
35
+ "@openreceive/provider-data": "0.2.3",
36
36
  "qrcode": "^1.5.4"
37
37
  },
38
38
  "devDependencies": {