@itpay/cli 2.1.58 → 2.1.59

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/dist/src/main.js CHANGED
@@ -16671,6 +16671,17 @@ function assertCheckoutCreation(checkout, cartID, sourceExecutionID) {
16671
16671
  }
16672
16672
  }
16673
16673
  __name(assertCheckoutCreation, "assertCheckoutCreation");
16674
+ function assertAccountCheckout(checkout, cartID, sourceExecutionID) {
16675
+ const current = checkout.checkout;
16676
+ const expiry = Date.parse(current.expires_at ?? "");
16677
+ const entryExpiry = checkout.official_entry?.expires_at;
16678
+ const bound = entryExpiry === void 0 ? expiry : Date.parse(entryExpiry);
16679
+ const closed = !Number.isFinite(expiry) || !Number.isFinite(bound) || Math.min(expiry, bound) <= Date.now();
16680
+ if (!current.checkout_id || current.cart_id !== cartID || !payableStates.includes(current.status) || closed || bound > expiry) {
16681
+ throw checkoutNotPayable(current, cartID, sourceExecutionID, closed);
16682
+ }
16683
+ }
16684
+ __name(assertAccountCheckout, "assertAccountCheckout");
16674
16685
  function assertCheckoutPayable(checkout, authoritative, cartID, sourceExecutionID) {
16675
16686
  const current = authoritative?.checkout ?? checkout.checkout;
16676
16687
  const deadlineClosed = authoritative?.payment_remaining_seconds === 0 || current.expires_at !== void 0 && (!authoritative?.server_now || Date.parse(current.expires_at) <= Date.parse(authoritative.server_now));
@@ -19369,17 +19380,6 @@ async function presentServiceCheckout(backend, config, serviceExecutionID, respo
19369
19380
  const host = options.host ?? "terminal";
19370
19381
  const currentModel = options.readModel;
19371
19382
  const checkout = response.checkout;
19372
- assertCheckoutCreation(checkout, response.cart.cart_id, serviceExecutionID);
19373
- options.persistHandoff?.({
19374
- serviceExecutionID,
19375
- cartID: response.cart.cart_id,
19376
- checkoutID: checkout.checkout.checkout_id,
19377
- displayToken: checkout.display_token,
19378
- checkoutURL: tokenizedCheckoutURL(checkout.checkout_url, checkout.display_token, checkout.qr_payload)
19379
- });
19380
- const authoritative = checkout.display_token ? await backend.getCheckoutPresentation(checkout.checkout.checkout_id, checkout.display_token, void 0, { deadline }) : void 0;
19381
- assertCheckoutPayable(checkout, authoritative, response.cart.cart_id, serviceExecutionID);
19382
- if (authoritative) response.cart.items = authoritative.items;
19383
19383
  const checkoutID = checkout.checkout.checkout_id;
19384
19384
  const agentType = options.agentType ?? config.agentType;
19385
19385
  if (agentType === "dot" || agentType === "muse") {
@@ -19390,14 +19390,25 @@ async function presentServiceCheckout(backend, config, serviceExecutionID, respo
19390
19390
  } catch {
19391
19391
  }
19392
19392
  const readOriginal = { command: `itpay --agent-type ${agentType} services get ${serviceExecutionID} --json`, reason: "\u7528\u6237\u5B8C\u6210\u9875\u9762\u64CD\u4F5C\u540E\u8BFB\u53D6\u539F\u4EFB\u52A1\u4E8B\u5B9E" };
19393
- if (!entry || entry.access !== "account_session" || entry.url !== checkout.checkout_url || !url || !isPresentableURL(entry.url, config.baseURL) || url.protocol !== "https:" || url.username || url.password || url.search || url.hash || url.pathname !== `/checkout/${encodeURIComponent(checkoutID)}`) {
19393
+ if (!entry || entry.access !== "account_session" || entry.purpose !== "checkout" || entry.url !== checkout.checkout_url || !url || !isPresentableURL(entry.url, config.baseURL) || url.protocol !== "https:" || url.username || url.password || url.search || url.hash || url.pathname !== `/checkout/${encodeURIComponent(checkoutID)}`) {
19394
19394
  throw new CommandContractError("secure_handoff_unavailable", "original purchase has no verified account-session entry", "\u4FDD\u7559\u539F\u8D2D\u4E70\uFF1B\u5F53\u524D\u8D26\u53F7\u5B89\u5168\u5165\u53E3\u4E0D\u53EF\u7528\uFF0C\u4E0D\u5C55\u793A\u6216\u62FC\u63A5 bearer \u94FE\u63A5\uFF0C\u4E0D\u6362\u8EAB\u4EFD\u6216\u91CD\u5EFA\u8D2D\u4E70\u3002", [readOriginal], void 0, { service_execution_id: serviceExecutionID, checkout_id: checkoutID });
19395
19395
  }
19396
- const { itinerary: itinerary2 } = authoritative ? projectCheckoutPresentation(authoritative, currentModel) : {};
19396
+ assertAccountCheckout(checkout, response.cart.cart_id, serviceExecutionID);
19397
19397
  const effects = { page_created: !response.handoff_reissued, page_reused: response.handoff_reissued === true, payment_requested: false, charged: false, human_page_action_required: true };
19398
- writeCommandEnvelope2({ status: "human_checkout_required", result: { service_execution_id: serviceExecutionID, checkout_id: checkoutID, amount: formatMoney(checkout.checkout.amount_minor, checkout.checkout.currency), effects, ...itinerary2 ? { itinerary: itinerary2 } : {}, agent_facts: presentAgent({ service_execution_id: serviceExecutionID, checkout_id: checkoutID, status: "human_checkout_required", checkout: { official_entry: entry }, effects }, { allowedOrigins: OFFICIAL_BACKEND_URLS }) }, handoff: { url: entry.url, purpose: entry.purpose, access: entry.access, ...entry.expires_at ? { expires_at: entry.expires_at } : {} }, instruction: "\u7ACB\u5373\u5C55\u793A\u5B98\u65B9\u94FE\u63A5\u53CA\u91D1\u989D\uFF1B\u7528\u6237\u767B\u5F55\u53D1\u8D77\u8FDE\u63A5\u7684\u8D26\u53F7\u5B8C\u6210\u5F53\u524D\u6B65\u9AA4\u3002\u4E8C\u7EF4\u7801\u4E0D\u662F\u524D\u7F6E\u6761\u4EF6\uFF0C\u6253\u5F00\u94FE\u63A5\u4E0D\u4EE3\u8868\u4ED8\u6B3E\u6216\u51FA\u7968\u3002\u7528\u6237\u8868\u793A\u5B8C\u6210\u540E\u8BFB\u53D6\u539F\u4EFB\u52A1\u4E8B\u5B9E\uFF0C\u4E0D\u91CD\u590D\u786E\u8BA4\u3001\u6362\u5355\u6216\u81EA\u52A8\u4ED8\u6B3E\u3002", next: readOriginal, recovery: [] }, { ...options.jsonOutput !== void 0 ? { jsonOutput: options.jsonOutput } : {}, ...options.output ? { output: options.output } : {} });
19398
+ writeCommandEnvelope2({ status: "human_checkout_required", result: { service_execution_id: serviceExecutionID, checkout_id: checkoutID, amount: formatMoney(checkout.checkout.amount_minor, checkout.checkout.currency), effects, agent_facts: presentAgent({ service_execution_id: serviceExecutionID, checkout_id: checkoutID, status: "human_checkout_required", checkout: { official_entry: entry }, effects }, { allowedOrigins: OFFICIAL_BACKEND_URLS }) }, handoff: { url: entry.url, purpose: entry.purpose, access: entry.access, ...entry.expires_at ? { expires_at: entry.expires_at } : {} }, instruction: "\u7ACB\u5373\u5C55\u793A\u5B98\u65B9\u94FE\u63A5\u53CA\u91D1\u989D\uFF1B\u7528\u6237\u767B\u5F55\u53D1\u8D77\u8FDE\u63A5\u7684\u8D26\u53F7\u5B8C\u6210\u5F53\u524D\u6B65\u9AA4\u3002\u4E8C\u7EF4\u7801\u4E0D\u662F\u524D\u7F6E\u6761\u4EF6\uFF0C\u6253\u5F00\u94FE\u63A5\u4E0D\u4EE3\u8868\u4ED8\u6B3E\u6216\u51FA\u7968\u3002\u7528\u6237\u8868\u793A\u5B8C\u6210\u540E\u8BFB\u53D6\u539F\u4EFB\u52A1\u4E8B\u5B9E\uFF0C\u4E0D\u91CD\u590D\u786E\u8BA4\u3001\u6362\u5355\u6216\u81EA\u52A8\u4ED8\u6B3E\u3002", next: readOriginal, recovery: [] }, { ...options.jsonOutput !== void 0 ? { jsonOutput: options.jsonOutput } : {}, ...options.output ? { output: options.output } : {} });
19399
19399
  return;
19400
19400
  }
19401
+ assertCheckoutCreation(checkout, response.cart.cart_id, serviceExecutionID);
19402
+ options.persistHandoff?.({
19403
+ serviceExecutionID,
19404
+ cartID: response.cart.cart_id,
19405
+ checkoutID: checkout.checkout.checkout_id,
19406
+ displayToken: checkout.display_token,
19407
+ checkoutURL: tokenizedCheckoutURL(checkout.checkout_url, checkout.display_token, checkout.qr_payload)
19408
+ });
19409
+ const authoritative = checkout.display_token ? await backend.getCheckoutPresentation(checkout.checkout.checkout_id, checkout.display_token, void 0, { deadline }) : void 0;
19410
+ assertCheckoutPayable(checkout, authoritative, response.cart.cart_id, serviceExecutionID);
19411
+ if (authoritative) response.cart.items = authoritative.items;
19401
19412
  const displayToken = checkout.display_token;
19402
19413
  const locale = normalizeCardLocale(options.locale);
19403
19414
  const checkoutURL = tokenizedCheckoutURL(checkout.checkout_url, displayToken, checkout.qr_payload);
@@ -1,4 +1,4 @@
1
- const CLI_VERSION = "2.1.58";
1
+ const CLI_VERSION = "2.1.59";
2
2
  const API_CONTRACT_REVISION = "sha256:f20af3780a0e12a79a6ca9507ba65167a4018338495af66d87931e55619b618a";
3
3
  export {
4
4
  API_CONTRACT_REVISION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itpay/cli",
3
- "version": "2.1.58",
3
+ "version": "2.1.59",
4
4
  "description": "The ItPay CLI for services, orders, and human-authorized purchased content.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -148,5 +148,5 @@
148
148
  "services",
149
149
  "api"
150
150
  ],
151
- "gitHead": "d58a8dd40dffb30430dd3af4246dd04194388336"
151
+ "gitHead": "59b0086e1133b9d10a26ee3703ce7591d3bee825"
152
152
  }