@openreceive/http 0.2.4 → 0.3.1

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.
@@ -363,7 +363,7 @@ interface CreateOpenReceiveHostBaseOptions {
363
363
  * pay for (the request is answered 404). Called only where a price is
364
364
  * minted or quoted; the payer never sends an amount.
365
365
  */
366
- readonly amountFor: (reference: string, context: ResolveCheckoutContext) => CreateCheckoutAmount | null | Promise<CreateCheckoutAmount | null>;
366
+ readonly amountFor: (reference: string, context: ResolveCheckoutContext) => HostCheckoutPrice | null | Promise<HostCheckoutPrice | null>;
367
367
  readonly clock?: () => number;
368
368
  }
369
369
  /**
@@ -421,6 +421,14 @@ interface Host {
421
421
  * `db` mode.
422
422
  */
423
423
  declare function createHost(options: CreateHostOptions): Host;
424
+ /**
425
+ * What the payer is buying, in the host's own words — one optional display
426
+ * string returned beside the price by `amountFor`. It is peeled off here so the
427
+ * amount handed to the minting service stays exactly the price.
428
+ */
429
+ type HostCheckoutPrice = CreateCheckoutAmount & {
430
+ readonly description?: string;
431
+ };
424
432
 
425
433
  interface IpRateLimitConfig {
426
434
  /** Maximum invoice creations per IP per rolling hour. Default 60. */
@@ -516,6 +524,14 @@ interface ResolvedHostCheckout {
516
524
  * attempt never need (or wait for) host pricing.
517
525
  */
518
526
  readonly amount?: CreateCheckoutAmount;
527
+ /**
528
+ * What the payer is buying, in the host's own words — one display string,
529
+ * echoed on the prepare and create responses so the shipped checkout can show
530
+ * something other than a QR and a number. OpenReceive owns no line items and
531
+ * never will; this is the whole of what it carries. Response only: it is
532
+ * never read from a request body.
533
+ */
534
+ readonly description?: string;
519
535
  /** Return the selected host payment attempt's hash to reuse or inspect its checkout. */
520
536
  readonly paymentHash?: string;
521
537
  /** Host-persisted safe checkout snapshot used for retry without a wallet read. */
@@ -719,4 +735,4 @@ declare function createStack(options: CreateStackOptions): Stack;
719
735
  */
720
736
  declare function isStackOptions(options: CreateHttpHandlerOptions | CreateStackOptions): options is CreateStackOptions;
721
737
 
722
- export { hostError as $, type AttemptStatus as A, type SettlementEventHook as B, type CheckoutCreatedHook as C, type SettlementRecord as D, type SqlClient as E, type SqlDatabase as F, type SqlPaymentRepository as G, type Host as H, type IpRateLimitConfig as I, type SqlPaymentsOptions as J, type SqlQuery as K, type Stack as L, type StackStorage as M, type NotificationListener as N, OPENRECEIVE_ATTEMPT_EXPIRY_GRACE_SECONDS as O, type PaymentInsert as P, type StackWallet as Q, type ReconcilableAttempt as R, type SqlAdapter as S, createHost as T, createHttpHandler as U, createIpRateLimit as V, createProxyRateLimitingConfig as W, createRequestId as X, createSqlPayments as Y, createStack as Z, errorResponse as _, type Authorize as a, isServiceErrorShape as a0, isStackOptions as a1, jsonResponse as a2, mapHostRouteError as a3, paymentsSchemaSql as a4, resolveClientIp as a5, startNotificationListener as a6, startNotificationWorker as a7, type AuthorizeAction as b, type AuthorizeContext as c, type AuthorizeResource as d, type CheckoutCreatedInput as e, type CreateHostDbOptions as f, type CreateHostOptions as g, type CreateHostRepositoryOptions as h, type CreateHttpHandlerOptions as i, type CreateStackOptions as j, HostError as k, HttpError as l, type HttpHandler as m, type NotificationWorker as n, OPENRECEIVE_RECONCILE_BATCH_SIZE as o, type PaymentRecord as p, type PaymentRepository as q, type PaymentSettlement as r, type PaymentSettlementHook as s, type RateLimit as t, type ReconciliationTransition as u, type ResolveCheckoutContext as v, type ResolveCheckoutHook as w, type ResolvedHostCheckout as x, type ServiceErrorShape as y, type SettlementEvent as z };
738
+ export { errorResponse as $, type AttemptStatus as A, type SettlementEvent as B, type CheckoutCreatedHook as C, type SettlementEventHook as D, type SettlementRecord as E, type SqlClient as F, type SqlDatabase as G, type Host as H, type IpRateLimitConfig as I, type SqlPaymentRepository as J, type SqlPaymentsOptions as K, type SqlQuery as L, type Stack as M, type NotificationListener as N, OPENRECEIVE_ATTEMPT_EXPIRY_GRACE_SECONDS as O, type PaymentInsert as P, type StackStorage as Q, type ReconcilableAttempt as R, type SqlAdapter as S, type StackWallet as T, createHost as U, createHttpHandler as V, createIpRateLimit as W, createProxyRateLimitingConfig as X, createRequestId as Y, createSqlPayments as Z, createStack as _, type Authorize as a, hostError as a0, isServiceErrorShape as a1, isStackOptions as a2, jsonResponse as a3, mapHostRouteError as a4, paymentsSchemaSql as a5, resolveClientIp as a6, startNotificationListener as a7, startNotificationWorker as a8, type AuthorizeAction as b, type AuthorizeContext as c, type AuthorizeResource as d, type CheckoutCreatedInput as e, type CreateHostDbOptions as f, type CreateHostOptions as g, type CreateHostRepositoryOptions as h, type CreateHttpHandlerOptions as i, type CreateStackOptions as j, type HostCheckoutPrice as k, HostError as l, HttpError as m, type HttpHandler as n, type NotificationWorker as o, OPENRECEIVE_RECONCILE_BATCH_SIZE as p, type PaymentRecord as q, type PaymentRepository as r, type PaymentSettlement as s, type PaymentSettlementHook as t, type RateLimit as u, type ReconciliationTransition as v, type ResolveCheckoutContext as w, type ResolveCheckoutHook as x, type ResolvedHostCheckout as y, type ServiceErrorShape as z };
@@ -1,3 +1,3 @@
1
1
  export { Checkout, CreateCheckoutAmount, OpenReceive, PaymentCheck, SwapCheckout } from '@openreceive/node';
2
- export { a as Authorize, b as AuthorizeAction, c as AuthorizeContext, d as AuthorizeResource, C as CheckoutCreatedHook, e as CheckoutCreatedInput, i as CreateHttpHandlerOptions, j as CreateStackOptions, H as Host, k as HostError, l as HttpError, m as HttpHandler, I as IpRateLimitConfig, n as NotificationWorker, q as PaymentRepository, r as PaymentSettlement, s as PaymentSettlementHook, t as RateLimit, v as ResolveCheckoutContext, w as ResolveCheckoutHook, x as ResolvedHostCheckout, y as ServiceErrorShape, z as SettlementEvent, B as SettlementEventHook, L as Stack, M as StackStorage, Q as StackWallet, U as createHttpHandler, Z as createStack, $ as hostError, a0 as isServiceErrorShape, a3 as mapHostRouteError, a7 as startNotificationWorker } from './adapter-surface-BtXnvW2q.js';
2
+ export { a as Authorize, b as AuthorizeAction, c as AuthorizeContext, d as AuthorizeResource, C as CheckoutCreatedHook, e as CheckoutCreatedInput, i as CreateHttpHandlerOptions, j as CreateStackOptions, H as Host, l as HostError, m as HttpError, n as HttpHandler, I as IpRateLimitConfig, o as NotificationWorker, r as PaymentRepository, s as PaymentSettlement, t as PaymentSettlementHook, u as RateLimit, w as ResolveCheckoutContext, x as ResolveCheckoutHook, y as ResolvedHostCheckout, z as ServiceErrorShape, B as SettlementEvent, D as SettlementEventHook, M as Stack, Q as StackStorage, T as StackWallet, V as createHttpHandler, _ as createStack, a0 as hostError, a1 as isServiceErrorShape, a4 as mapHostRouteError, a8 as startNotificationWorker } from './adapter-surface-CanN2Y1N.js';
3
3
  import '@openreceive/core';
@@ -7,7 +7,7 @@ import {
7
7
  isServiceErrorShape,
8
8
  mapHostRouteError,
9
9
  startNotificationWorker
10
- } from "./chunk-SVRY37Z4.js";
10
+ } from "./chunk-EZAV3TC3.js";
11
11
  export {
12
12
  HostError,
13
13
  HttpError,
@@ -842,7 +842,7 @@ function createHost(options) {
842
842
  };
843
843
  const resolveCheckout = async (context) => {
844
844
  if (context.action === "swap.quote" || context.action === "checkout.prepare") {
845
- return { amount: await priceFor(context) };
845
+ return resolvedPrice(await priceFor(context));
846
846
  }
847
847
  const isCreate = context.action === "checkout.create" || context.action === "swap.create";
848
848
  const amount = isCreate ? await priceFor(context) : void 0;
@@ -884,8 +884,8 @@ function createHost(options) {
884
884
  );
885
885
  }
886
886
  const selected = matching[0];
887
- if (selected === void 0) return { amount };
888
- if (!isReusablePaymentAttempt(selected.expiresAt, now)) return { amount };
887
+ if (selected === void 0) return resolvedPrice(amount);
888
+ if (!isReusablePaymentAttempt(selected.expiresAt, now)) return resolvedPrice(amount);
889
889
  return resolvedPayment(amount, selected);
890
890
  }
891
891
  throw hostError("payment_hash is required for this action.", 400, "INVALID_REQUEST");
@@ -897,9 +897,20 @@ function createHost(options) {
897
897
  payments
898
898
  };
899
899
  }
900
+ function describePrice(price) {
901
+ const description = price.description?.trim();
902
+ return description === void 0 || description.length === 0 ? {} : { description };
903
+ }
904
+ function priceOnly(price) {
905
+ const { description: _description, ...amount } = price;
906
+ return amount;
907
+ }
908
+ function resolvedPrice(price) {
909
+ return price === void 0 ? {} : { amount: priceOnly(price), ...describePrice(price) };
910
+ }
900
911
  function resolvedPayment(amount, payment) {
901
912
  return {
902
- ...amount === void 0 ? {} : { amount },
913
+ ...resolvedPrice(amount),
903
914
  paymentHash: payment.paymentHash,
904
915
  checkout: structuredClone(payment.checkout),
905
916
  // Carried so `payments/check` can serve the row path without re-listing
@@ -1600,6 +1611,7 @@ async function dispatch(runtime, request, requestId, native) {
1600
1611
  {
1601
1612
  reference,
1602
1613
  amount_msats: prepared.amountMsats,
1614
+ ...resolved2.description === void 0 ? {} : { description: resolved2.description },
1603
1615
  fiat_quote: prepared.fiatQuote === null ? null : toSnakeCase(prepared.fiatQuote),
1604
1616
  payment_methods: toSnakeCase(swapOptions.options)
1605
1617
  },
@@ -1636,6 +1648,7 @@ async function dispatch(runtime, request, requestId, native) {
1636
1648
  201,
1637
1649
  {
1638
1650
  checkout: httpCheckout(checkout),
1651
+ ...resolved2.description === void 0 ? {} : { description: resolved2.description },
1639
1652
  payment_methods: await warmPaymentMethods(runtime, checkout.amountMsats)
1640
1653
  },
1641
1654
  requestId
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { OpenReceive, PaymentCheck } from '@openreceive/node';
2
2
  export { Checkout, CreateCheckoutAmount, OpenReceive, PaymentCheck, SwapCheckout } from '@openreceive/node';
3
- import { H as Host, R as ReconcilableAttempt, S as SqlAdapter } from './adapter-surface-BtXnvW2q.js';
4
- export { A as AttemptStatus, a as Authorize, b as AuthorizeAction, c as AuthorizeContext, d as AuthorizeResource, C as CheckoutCreatedHook, e as CheckoutCreatedInput, f as CreateHostDbOptions, g as CreateHostOptions, h as CreateHostRepositoryOptions, i as CreateHttpHandlerOptions, j as CreateStackOptions, k as HostError, l as HttpError, m as HttpHandler, I as IpRateLimitConfig, N as NotificationListener, n as NotificationWorker, O as OPENRECEIVE_ATTEMPT_EXPIRY_GRACE_SECONDS, o as OPENRECEIVE_RECONCILE_BATCH_SIZE, P as PaymentInsert, p as PaymentRecord, q as PaymentRepository, r as PaymentSettlement, s as PaymentSettlementHook, t as RateLimit, u as ReconciliationTransition, v as ResolveCheckoutContext, w as ResolveCheckoutHook, x as ResolvedHostCheckout, y as ServiceErrorShape, z as SettlementEvent, B as SettlementEventHook, D as SettlementRecord, E as SqlClient, F as SqlDatabase, G as SqlPaymentRepository, J as SqlPaymentsOptions, K as SqlQuery, L as Stack, M as StackStorage, Q as StackWallet, T as createHost, U as createHttpHandler, V as createIpRateLimit, W as createProxyRateLimitingConfig, X as createRequestId, Y as createSqlPayments, Z as createStack, _ as errorResponse, $ as hostError, a0 as isServiceErrorShape, a1 as isStackOptions, a2 as jsonResponse, a3 as mapHostRouteError, a4 as paymentsSchemaSql, a5 as resolveClientIp, a6 as startNotificationListener, a7 as startNotificationWorker } from './adapter-surface-BtXnvW2q.js';
3
+ import { H as Host, R as ReconcilableAttempt, S as SqlAdapter } from './adapter-surface-CanN2Y1N.js';
4
+ export { A as AttemptStatus, a as Authorize, b as AuthorizeAction, c as AuthorizeContext, d as AuthorizeResource, C as CheckoutCreatedHook, e as CheckoutCreatedInput, f as CreateHostDbOptions, g as CreateHostOptions, h as CreateHostRepositoryOptions, i as CreateHttpHandlerOptions, j as CreateStackOptions, k as HostCheckoutPrice, l as HostError, m as HttpError, n as HttpHandler, I as IpRateLimitConfig, N as NotificationListener, o as NotificationWorker, O as OPENRECEIVE_ATTEMPT_EXPIRY_GRACE_SECONDS, p as OPENRECEIVE_RECONCILE_BATCH_SIZE, P as PaymentInsert, q as PaymentRecord, r as PaymentRepository, s as PaymentSettlement, t as PaymentSettlementHook, u as RateLimit, v as ReconciliationTransition, w as ResolveCheckoutContext, x as ResolveCheckoutHook, y as ResolvedHostCheckout, z as ServiceErrorShape, B as SettlementEvent, D as SettlementEventHook, E as SettlementRecord, F as SqlClient, G as SqlDatabase, J as SqlPaymentRepository, K as SqlPaymentsOptions, L as SqlQuery, M as Stack, Q as StackStorage, T as StackWallet, U as createHost, V as createHttpHandler, W as createIpRateLimit, X as createProxyRateLimitingConfig, Y as createRequestId, Z as createSqlPayments, _ as createStack, $ as errorResponse, a0 as hostError, a1 as isServiceErrorShape, a2 as isStackOptions, a3 as jsonResponse, a4 as mapHostRouteError, a5 as paymentsSchemaSql, a6 as resolveClientIp, a7 as startNotificationListener, a8 as startNotificationWorker } from './adapter-surface-CanN2Y1N.js';
5
5
  export { OPENRECEIVE_PAYMENTS_SCHEMA_VERSION } from '@openreceive/core';
6
6
 
7
7
  /** The pieces of a framework request the bridge needs, framework-agnostic. */
@@ -32,6 +32,7 @@ type WirePrepareCheckoutRequest = {
32
32
  type WirePrepareCheckoutResponse = {
33
33
  readonly reference: string;
34
34
  readonly amount_msats: number;
35
+ readonly description?: string;
35
36
  readonly fiat_quote?: null | WireFiatQuote;
36
37
  readonly payment_methods: readonly WirePaymentMethod[];
37
38
  };
@@ -54,6 +55,7 @@ type WireCheckout = {
54
55
  /** Wire shape of the OpenAPI `CreateCheckoutResponse` schema (snake_case JSON body). */
55
56
  type WireCreateCheckoutResponse = {
56
57
  readonly checkout: WireCheckout;
58
+ readonly description?: string;
57
59
  readonly payment_methods: readonly WirePaymentMethod[];
58
60
  };
59
61
  /** Wire shape of the OpenAPI `PaymentCheckRequest` schema (snake_case JSON body). */
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  startReconciler,
35
35
  typeOrmDb,
36
36
  webRequest
37
- } from "./chunk-SVRY37Z4.js";
37
+ } from "./chunk-EZAV3TC3.js";
38
38
  export {
39
39
  HostError,
40
40
  HttpError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openreceive/http",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "description": "Framework-neutral (Web Request/Response) HTTP handler for OpenReceive checkout that builds on @openreceive/node and requires its Node runtime: request routing, host integration, and payment-attempt persistence.",
5
5
  "keywords": [
6
6
  "bitcoin",
@@ -17,8 +17,8 @@
17
17
  "main": "./dist/index.js",
18
18
  "types": "./dist/index.d.ts",
19
19
  "dependencies": {
20
- "@openreceive/core": "0.2.4",
21
- "@openreceive/node": "0.2.4"
20
+ "@openreceive/core": "0.3.1",
21
+ "@openreceive/node": "0.3.1"
22
22
  },
23
23
  "exports": {
24
24
  ".": {