@genesis-tech/genesispay-seller 0.13.0 → 0.13.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.2 — clean recovery package
4
+
5
+ No API or runtime behaviour change from `0.13.0`. This immutable patch release
6
+ replaces two unusable artifacts: `0.13.0` included stale legacy build output and
7
+ `0.13.1` omitted compiled `dist` entirely. Both versions are deprecated.
8
+
9
+ The release pipeline now clean/force-builds TypeScript project references,
10
+ repeats the forced build during `prepack`, and rejects a pack manifest that is
11
+ missing compiled exports or contains legacy artifact filenames.
12
+
3
13
  ## 0.13.0 — checkout return parameters and fulfilment DX
4
14
 
5
15
  Additive. Exports the return-parameter constants and a hint parser, and adds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genesis-tech/genesispay-seller",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "Framework-agnostic x402 payment gate for sellers, powered by GenesisPay.",
5
5
  "license": "MIT",
6
6
  "author": "GenesisTech",
@@ -46,6 +46,7 @@
46
46
  ],
47
47
  "scripts": {
48
48
  "build": "tsc -b",
49
+ "prepack": "npm run build -- --force",
49
50
  "typecheck": "tsc --noEmit"
50
51
  },
51
52
  "dependencies": {
@@ -1,27 +0,0 @@
1
- import type { VerifySettlement } from "./payment-gate.js";
2
- /**
3
- * Default GenesisPay app base URL — the public "development" facilitator. Used
4
- * when `facilitatorBaseUrl` is omitted so integrators don't have to configure a
5
- * URL in dev. Set `facilitatorBaseUrl` explicitly for production.
6
- */
7
- export declare const DEFAULT_FACILITATOR_BASE_URL = "https://peerpay-app-development.up.railway.app";
8
- export type PeerPaySettlementOptions = {
9
- /**
10
- * Base URL of the GenesisPay app, e.g. "https://genesispay.example". Defaults to
11
- * the public development facilitator (DEFAULT_FACILITATOR_BASE_URL) when
12
- * omitted; set it explicitly in production.
13
- */
14
- facilitatorBaseUrl?: string;
15
- /** GenesisPay seller API key ("pp_sk_..."). */
16
- apiKey: string;
17
- /** Override for testing; defaults to global fetch. */
18
- fetchFn?: typeof fetch;
19
- };
20
- /**
21
- * Built-in settlement hook that forwards the PAYMENT-SIGNATURE payload to the
22
- * GenesisPay facilitator (`POST /api/v1/facilitator/settle`). GenesisPay broadcasts
23
- * the EIP-3009 authorization on-chain (or verifies a payer-provided txHash)
24
- * and verifies the USDC transfer before reporting success.
25
- */
26
- export declare function peerPaySettlement(options: PeerPaySettlementOptions): VerifySettlement;
27
- //# sourceMappingURL=peerpay-settlement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"peerpay-settlement.d.ts","sourceRoot":"","sources":["../src/peerpay-settlement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,mDACS,CAAC;AAEnD,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC,gBAAgB,CA6DlB"}
@@ -1,100 +0,0 @@
1
- import { parseSettlementResponsePayload } from "@genesis-tech/genesispay-protocol";
2
- /**
3
- * Default GenesisPay app base URL — the public "development" facilitator. Used
4
- * when `facilitatorBaseUrl` is omitted so integrators don't have to configure a
5
- * URL in dev. Set `facilitatorBaseUrl` explicitly for production.
6
- */
7
- export const DEFAULT_FACILITATOR_BASE_URL = "https://peerpay-app-development.up.railway.app";
8
- /**
9
- * Built-in settlement hook that forwards the PAYMENT-SIGNATURE payload to the
10
- * GenesisPay facilitator (`POST /api/v1/facilitator/settle`). GenesisPay broadcasts
11
- * the EIP-3009 authorization on-chain (or verifies a payer-provided txHash)
12
- * and verifies the USDC transfer before reporting success.
13
- */
14
- export function peerPaySettlement(options) {
15
- const settleUrl = buildSettleUrl(options.facilitatorBaseUrl?.trim() || DEFAULT_FACILITATOR_BASE_URL);
16
- const apiKey = options.apiKey?.trim();
17
- if (!apiKey) {
18
- throw new Error("peerPaySettlement requires a GenesisPay seller API key (pp_sk_...).");
19
- }
20
- const fetchFn = options.fetchFn ?? fetch;
21
- return async (context) => {
22
- const { requirement } = context;
23
- let response;
24
- try {
25
- response = await fetchFn(settleUrl, {
26
- method: "POST",
27
- headers: {
28
- "Content-Type": "application/json",
29
- Authorization: `Bearer ${apiKey}`,
30
- },
31
- body: JSON.stringify({
32
- paymentSignature: context.paymentSignatureHeader,
33
- requirement: {
34
- resource: requirement.resource,
35
- network: requirement.network,
36
- chainId: requirement.chainId,
37
- assetAddress: requirement.assetAddress,
38
- amountUsdcMinor: requirement.maxAmountRequired,
39
- payTo: requirement.payTo,
40
- description: requirement.description || undefined,
41
- },
42
- }),
43
- });
44
- }
45
- catch (error) {
46
- return {
47
- ok: false,
48
- errorReason: `Failed to reach the GenesisPay facilitator: ${describeError(error)}`,
49
- };
50
- }
51
- const body = await readJsonBody(response);
52
- const settlement = tryParseSettlement(body);
53
- if (response.ok && settlement?.success) {
54
- return { ok: true, settlement };
55
- }
56
- return {
57
- ok: false,
58
- errorReason: settlement?.errorReason ??
59
- readErrorMessage(body) ??
60
- `GenesisPay facilitator settlement failed with status ${response.status}.`,
61
- ...(settlement ? { settlement } : {}),
62
- };
63
- };
64
- }
65
- function buildSettleUrl(facilitatorBaseUrl) {
66
- const trimmed = facilitatorBaseUrl?.trim().replace(/\/+$/, "");
67
- if (!trimmed || !/^https?:\/\//.test(trimmed)) {
68
- throw new Error(`Invalid facilitatorBaseUrl "${String(facilitatorBaseUrl)}": expected an http(s) URL like "https://genesispay.example".`);
69
- }
70
- return `${trimmed}/api/v1/facilitator/settle`;
71
- }
72
- async function readJsonBody(response) {
73
- try {
74
- return await response.json();
75
- }
76
- catch {
77
- return undefined;
78
- }
79
- }
80
- function tryParseSettlement(body) {
81
- try {
82
- return parseSettlementResponsePayload(body);
83
- }
84
- catch {
85
- return undefined;
86
- }
87
- }
88
- function readErrorMessage(body) {
89
- if (typeof body === "object" &&
90
- body !== null &&
91
- "error" in body &&
92
- typeof body.error === "string") {
93
- return body.error;
94
- }
95
- return undefined;
96
- }
97
- function describeError(error) {
98
- return error instanceof Error ? error.message : "unknown error";
99
- }
100
- //# sourceMappingURL=peerpay-settlement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"peerpay-settlement.js","sourceRoot":"","sources":["../src/peerpay-settlement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AASnF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GACvC,gDAAgD,CAAC;AAenD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAiC;IAEjC,MAAM,SAAS,GAAG,cAAc,CAC9B,OAAO,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,4BAA4B,CACnE,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IAEzC,OAAO,KAAK,EAAE,OAA0B,EAAmC,EAAE;QAC3E,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,IAAI,QAAkB,CAAC;QACvB,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE;gBAClC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,k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