openpay-x402-sdk 0.1.0 → 0.2.0

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - Trust query-string variants of a query-free catalog URL after the live
6
+ challenge passes the same catalog money-field verification.
7
+ - Keep exact catalog URL matches, explicit host allowlisting, resource matching,
8
+ and public API declarations unchanged.
9
+
3
10
  ## 0.1.0
4
11
 
5
12
  - Add the ESM `createOpenPayClient` API for discovery, free shop lookup, quotes,
package/README.md CHANGED
@@ -39,9 +39,12 @@ concurrent calls so every call sees the latest session total.
39
39
  | `maxPerCallJpyc` | `10` | Upper bound for the caller-provided `maxTotalJpyc`. |
40
40
  | `maxSessionJpyc` | `100` | Cumulative cap for successful payments made by this client instance. |
41
41
  | `allowedHosts` | `open-pay.jp` | Comma-separated bare host allowlist. |
42
- | `catalogTrust` | `true` | Also allows exact URLs in the discovery catalog after the live challenge matches the catalog challenge. |
42
+ | `catalogTrust` | `true` | Also allows catalog URLs after the live challenge matches the catalog challenge. |
43
43
  | `discoveryUrl` | `https://open-pay.jp/api/discovery` | Catalog and OpenPay origin used by the client. |
44
44
 
45
+ Query string variants of a query-free listed URL are trusted after the same
46
+ money-field verification. Exact query-bearing catalog entries remain exact-only.
47
+
45
48
  `pay(url, { maxTotalJpyc })` always requires `maxTotalJpyc`. It is the maximum
46
49
  total—including the resource price and x402 fee—that this individual call is
47
50
  authorized to pay. It does not disable or raise `maxPerCallJpyc` or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openpay-x402-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Guarded Node.js buyer SDK for OpenPay x402 JPYC resources",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/guards.mjs CHANGED
@@ -366,11 +366,19 @@ export function evaluatePaymentGuards({
366
366
  reasons.push(REASONS.invalidUrl);
367
367
  } else {
368
368
  const hostAllowed = config.allowedHosts.includes(parsedUrl.hostname.toLowerCase());
369
- // カタログ信頼はホストでなく **URL 完全一致** allowlist より狭い単位で許可する。
370
- const listedAccept =
371
- config.catalogTrust && catalogListings instanceof Map
372
- ? catalogListings.get(parsedUrl.toString())
373
- : undefined;
369
+ // 完全一致を先に維持し、miss 時だけ query/hash を除いた同一 origin+pathname を引く。
370
+ // userinfo は origin に含まれないため、query variant ではない credential 付き URL へは緩和しない。
371
+ let listedAccept;
372
+ if (config.catalogTrust && catalogListings instanceof Map) {
373
+ listedAccept = catalogListings.get(parsedUrl.toString());
374
+ if (
375
+ listedAccept === undefined &&
376
+ parsedUrl.username === '' &&
377
+ parsedUrl.password === ''
378
+ ) {
379
+ listedAccept = catalogListings.get(`${parsedUrl.origin}${parsedUrl.pathname}`);
380
+ }
381
+ }
374
382
  const catalogListed = listedAccept !== undefined;
375
383
  if (!hostAllowed && !catalogListed) {
376
384
  reasons.push(REASONS.hostNotAllowed);