@pithy-sh/payments 0.2.1 → 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.
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
+ import type { JwksCache } from "@pithy-sh/core/src/http/oidcWebhook";
4
5
  import type { PaymentsConfig } from "../config/config";
5
6
  import { productForProviderSku, railEnabled } from "../config/config";
6
7
  import type { PaymentsRail } from "../data/rail";
@@ -66,6 +67,20 @@ export interface RailTrustOptions {
66
67
  googleTransport?: GoogleHttpFetch;
67
68
  /** A Play access token already minted, so a batch of Google refreshes pays for one. */
68
69
  googleAccessToken?: string;
70
+ /**
71
+ * Where the Google rail holds Google's published verification keys between deliveries.
72
+ *
73
+ * **The third kind of seam, and the only one that is about availability rather than trust or cost.** A rail
74
+ * is built per request, so it cannot own a store that outlives one; the webhook path resolves a key before
75
+ * it can check a signature; and therefore with no store an anonymous POST buys a round trip to Google,
76
+ * 1:1 — whether it names a `kid` Google publishes, which the held keys answer, or one nobody ever
77
+ * published, which only the store's refresh window does. `registerPaymentsRoutes` supplies one per
78
+ * registered route tree when a caller gives none; this parameter is for the caller that wants a harder
79
+ * bound than an isolate's memory, a store over KV or the Cache API that every isolate shares — and sharing
80
+ * it shares the window with it. Additive to nothing and narrowing nothing: core still fetches for a `kid`
81
+ * the store does not hold once the window is over, which is how key rotation stays invisible.
82
+ */
83
+ googleJwksCache?: JwksCache;
69
84
  /** The HTTP transport the Stripe rail reaches Stripe's API through. Defaults to `fetch`. */
70
85
  stripeTransport?: StripeHttpFetch;
71
86
  /** The HTTP transport the Lemon Squeezy rail reaches its API through. Defaults to `fetch`. */
@@ -98,6 +113,7 @@ const RAIL_FACTORIES: Partial<Record<PaymentsRail, RailFactory>> = {
98
113
  trustedKeys: trust.googleTrustedKeys,
99
114
  transport: trust.googleTransport,
100
115
  accessToken: trust.googleAccessToken,
116
+ jwksCache: trust.googleJwksCache,
101
117
  }),
102
118
  stripe: (credentials, trust) =>
103
119
  stripeRail(railCredentials(credentials, "stripe"), { transport: trust.stripeTransport }),
@@ -26,3 +26,23 @@ import { PAYMENTS_PROVIDER_SECRET } from "./registry";
26
26
  export function paymentsSecretBranches(rails: PaymentsRailToggles): SecretBranchSeam {
27
27
  return { [PAYMENTS_PROVIDER_SECRET]: PAYMENTS_RAILS.filter((rail) => rails[rail]) };
28
28
  }
29
+
30
+ /**
31
+ * **The same question one level up: is the secret reachable at all (#541).**
32
+ *
33
+ * {@link paymentsSecretBranches} says which *blocks* of the bundle a project will be asked for. With
34
+ * every rail off there are none — and the bundle itself is then a value nothing will ever read, because
35
+ * every read of it is behind a rail: the checkout routes, the webhook guard, and the reconciliation
36
+ * Workflow each refuse before they reach the store. Every toggle defaults `false`, so this is the state
37
+ * `pithy add payments` leaves a project in until a rail is named, and `pithy doctor` listed the
38
+ * credential as outstanding work under *"fine to leave until you need it"* for the whole of it.
39
+ *
40
+ * Declared here rather than derived by the CLI from an empty branch list, for
41
+ * {@link paymentsSecretBranches}' own reason: an empty list is *no blocks to ask for*, which is not the
42
+ * same claim as *nothing reads this*, and a reporting command that conflated the two would be right by
43
+ * luck. The capability holds the toggles, so the capability answers.
44
+ */
45
+ export function paymentsInapplicableSecrets(rails: PaymentsRailToggles): Record<string, string> {
46
+ if (PAYMENTS_RAILS.some((rail) => rails[rail])) return {};
47
+ return { [PAYMENTS_PROVIDER_SECRET]: "payments() enables no rail, so no code path reads a credential" };
48
+ }
@@ -13,4 +13,4 @@
13
13
  export const PACKAGE_NAME = "@pithy-sh/payments";
14
14
 
15
15
  /** This package's version, stamped from its own package.json at generation time. */
16
- export const PACKAGE_VERSION = "0.2.1";
16
+ export const PACKAGE_VERSION = "0.3.1";