@pithy-sh/payments 0.1.4 → 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/dist/admin/coverage.d.ts +2 -0
- package/dist/admin/coverage.js +2 -0
- package/dist/admin/read.d.ts +2 -0
- package/dist/admin/read.js +2 -0
- package/dist/audit/actions.d.ts +2 -0
- package/dist/audit/actions.js +2 -0
- package/dist/capability.d.ts +2 -0
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +14 -0
- package/dist/client/api.d.ts +2 -0
- package/dist/client/api.js +2 -0
- package/dist/client/checkout.d.ts +2 -0
- package/dist/client/checkout.js +2 -0
- package/dist/client/fixtures/price-preview-de.js +2 -0
- package/dist/client/fixtures/price-preview-gb.js +2 -0
- package/dist/client/fixtures/price-preview-jp-yen.js +2 -0
- package/dist/client/fixtures/price-preview-us-country-only.js +2 -0
- package/dist/client/fixtures/price-preview-us-new-york.js +2 -0
- package/dist/client/fixtures/pricePreview.d.ts +2 -0
- package/dist/client/fixtures/pricePreview.js +2 -0
- package/dist/client/hooks.d.ts +2 -0
- package/dist/client/hooks.js +2 -0
- package/dist/client/paddle.d.ts +2 -0
- package/dist/client/paddle.js +2 -0
- package/dist/client/paddleCache.d.ts +2 -0
- package/dist/client/paddleCache.js +2 -0
- package/dist/client/paddlePrices.d.ts +2 -0
- package/dist/client/paddlePrices.js +2 -0
- package/dist/client/paddlePricesTag.d.ts +2 -0
- package/dist/client/paddlePricesTag.js +2 -0
- package/dist/client/projection.d.ts +2 -0
- package/dist/client/projection.js +2 -0
- package/dist/client/test-utils/cacheStore.d.ts +2 -0
- package/dist/client/test-utils/cacheStore.js +2 -0
- package/dist/client/wholeUnits.d.ts +2 -0
- package/dist/client/wholeUnits.js +2 -0
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +2 -0
- package/dist/data/discount.d.ts +2 -0
- package/dist/data/discount.js +2 -0
- package/dist/data/entitlement.d.ts +2 -0
- package/dist/data/entitlement.js +2 -0
- package/dist/data/money.d.ts +2 -0
- package/dist/data/money.js +2 -0
- package/dist/data/pause.d.ts +2 -0
- package/dist/data/pause.js +2 -0
- package/dist/data/providerAccount.d.ts +2 -0
- package/dist/data/providerAccount.js +2 -0
- package/dist/data/purchase.d.ts +2 -0
- package/dist/data/purchase.js +2 -0
- package/dist/data/rail.d.ts +2 -0
- package/dist/data/rail.js +2 -0
- package/dist/data/reconcileRun.d.ts +2 -0
- package/dist/data/reconcileRun.js +2 -0
- package/dist/data/renderMoney.d.ts +2 -0
- package/dist/data/renderMoney.js +2 -0
- package/dist/data/status.d.ts +2 -0
- package/dist/data/status.js +2 -0
- package/dist/data/subject.d.ts +2 -0
- package/dist/data/subject.js +2 -0
- package/dist/data/subscription.d.ts +2 -0
- package/dist/data/subscription.js +2 -0
- package/dist/data/syncCursor.d.ts +2 -0
- package/dist/data/syncCursor.js +2 -0
- package/dist/data/tables.d.ts +2 -0
- package/dist/data/tables.js +2 -0
- package/dist/data/webhookEvent.d.ts +2 -0
- package/dist/data/webhookEvent.js +2 -0
- package/dist/entitlement/manual.d.ts +2 -0
- package/dist/entitlement/manual.js +2 -0
- package/dist/entitlement/resolver.d.ts +2 -0
- package/dist/entitlement/resolver.js +2 -0
- package/dist/entitlement/subjectSeam.d.ts +2 -0
- package/dist/entitlement/subjectSeam.js +2 -0
- package/dist/entitlement/unimplementedSubject.d.ts +25 -0
- package/dist/entitlement/unimplementedSubject.d.ts.map +1 -0
- package/dist/entitlement/unimplementedSubject.js +78 -0
- package/dist/error/errors.d.ts +2 -0
- package/dist/error/errors.js +2 -0
- package/dist/grants/apply.d.ts +2 -0
- package/dist/grants/apply.js +2 -0
- package/dist/grants/clawback.d.ts +2 -0
- package/dist/grants/clawback.js +2 -0
- package/dist/grants/ledgerSeam.d.ts +2 -0
- package/dist/grants/ledgerSeam.js +2 -0
- package/dist/http/dispatch.d.ts +2 -0
- package/dist/http/dispatch.js +2 -0
- package/dist/http/guards.d.ts +2 -0
- package/dist/http/guards.js +2 -0
- package/dist/http/manifestConfig.d.ts +2 -0
- package/dist/http/manifestConfig.js +2 -0
- package/dist/http/responses.d.ts +2 -0
- package/dist/http/responses.js +2 -0
- package/dist/http/routes.d.ts +2 -0
- package/dist/http/routes.js +2 -0
- package/dist/http/schemas.d.ts +2 -0
- package/dist/http/schemas.js +2 -0
- package/dist/http/scopes.d.ts +2 -0
- package/dist/http/scopes.js +2 -0
- package/dist/http/view.d.ts +2 -0
- package/dist/http/view.js +2 -0
- package/dist/http/webhookGuard.d.ts +2 -0
- package/dist/http/webhookGuard.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/migrations/0001_purchases.d.ts +2 -0
- package/dist/migrations/0001_purchases.js +2 -0
- package/dist/paddle-prices.iife.js +1 -0
- package/dist/pricing/location.d.ts +2 -0
- package/dist/pricing/location.js +2 -0
- package/dist/pricing/visitor.d.ts +2 -0
- package/dist/pricing/visitor.js +2 -0
- package/dist/projection/event.d.ts +2 -0
- package/dist/projection/event.js +2 -0
- package/dist/projection/orphans.d.ts +2 -0
- package/dist/projection/orphans.js +2 -0
- package/dist/projection/owner.d.ts +2 -0
- package/dist/projection/owner.js +2 -0
- package/dist/projection/resolve.d.ts +2 -0
- package/dist/projection/resolve.js +2 -0
- package/dist/projection/writer.d.ts +2 -0
- package/dist/projection/writer.js +2 -0
- package/dist/provision/resolvePaymentsConfig.d.ts +2 -0
- package/dist/provision/resolvePaymentsConfig.js +2 -0
- package/dist/rails/apple/certs.d.ts +2 -0
- package/dist/rails/apple/certs.js +2 -0
- package/dist/rails/apple/der.d.ts +2 -0
- package/dist/rails/apple/der.js +2 -0
- package/dist/rails/apple/fixtures/chain.d.ts +2 -0
- package/dist/rails/apple/fixtures/chain.js +2 -0
- package/dist/rails/apple/http.d.ts +2 -0
- package/dist/rails/apple/http.js +2 -0
- package/dist/rails/apple/jws.d.ts +2 -0
- package/dist/rails/apple/jws.js +2 -0
- package/dist/rails/apple/notification.d.ts +2 -0
- package/dist/rails/apple/notification.js +2 -0
- package/dist/rails/apple/rail.d.ts +2 -0
- package/dist/rails/apple/rail.js +2 -0
- package/dist/rails/apple/serverApi.d.ts +2 -0
- package/dist/rails/apple/serverApi.js +2 -0
- package/dist/rails/apple/verify.d.ts +2 -0
- package/dist/rails/apple/verify.js +2 -0
- package/dist/rails/apple/x509.d.ts +2 -0
- package/dist/rails/apple/x509.js +2 -0
- package/dist/rails/contract.d.ts +2 -0
- package/dist/rails/contract.js +2 -0
- package/dist/rails/google/fixtures/push.d.ts +2 -0
- package/dist/rails/google/fixtures/push.js +2 -0
- package/dist/rails/google/http.d.ts +2 -0
- package/dist/rails/google/http.js +2 -0
- package/dist/rails/google/jwt.d.ts +2 -0
- package/dist/rails/google/jwt.js +2 -0
- package/dist/rails/google/oidc.d.ts +2 -0
- package/dist/rails/google/oidc.js +2 -0
- package/dist/rails/google/playApi.d.ts +2 -0
- package/dist/rails/google/playApi.js +2 -0
- package/dist/rails/google/rail.d.ts +2 -0
- package/dist/rails/google/rail.js +2 -0
- package/dist/rails/google/rtdn.d.ts +2 -0
- package/dist/rails/google/rtdn.js +2 -0
- package/dist/rails/google/verify.d.ts +2 -0
- package/dist/rails/google/verify.js +2 -0
- package/dist/rails/lemonSqueezy/api.d.ts +2 -0
- package/dist/rails/lemonSqueezy/api.js +2 -0
- package/dist/rails/lemonSqueezy/checkout.d.ts +2 -0
- package/dist/rails/lemonSqueezy/checkout.js +2 -0
- package/dist/rails/lemonSqueezy/discounts.d.ts +2 -0
- package/dist/rails/lemonSqueezy/discounts.js +2 -0
- package/dist/rails/lemonSqueezy/fixtures/events.d.ts +2 -0
- package/dist/rails/lemonSqueezy/fixtures/events.js +2 -0
- package/dist/rails/lemonSqueezy/objects.d.ts +2 -0
- package/dist/rails/lemonSqueezy/objects.js +2 -0
- package/dist/rails/lemonSqueezy/portal.d.ts +2 -0
- package/dist/rails/lemonSqueezy/portal.js +2 -0
- package/dist/rails/lemonSqueezy/pricing.d.ts +2 -0
- package/dist/rails/lemonSqueezy/pricing.js +2 -0
- package/dist/rails/lemonSqueezy/rail.d.ts +2 -0
- package/dist/rails/lemonSqueezy/rail.js +2 -0
- package/dist/rails/lemonSqueezy/read.d.ts +2 -0
- package/dist/rails/lemonSqueezy/read.js +2 -0
- package/dist/rails/lemonSqueezy/refresh.d.ts +2 -0
- package/dist/rails/lemonSqueezy/refresh.js +2 -0
- package/dist/rails/lemonSqueezy/signature.d.ts +2 -0
- package/dist/rails/lemonSqueezy/signature.js +2 -0
- package/dist/rails/lemonSqueezy/verify.d.ts +2 -0
- package/dist/rails/lemonSqueezy/verify.js +2 -0
- package/dist/rails/lemonSqueezy/webhook.d.ts +2 -0
- package/dist/rails/lemonSqueezy/webhook.js +2 -0
- package/dist/rails/paddle/adjustments.d.ts +2 -0
- package/dist/rails/paddle/adjustments.js +2 -0
- package/dist/rails/paddle/api.d.ts +2 -0
- package/dist/rails/paddle/api.js +2 -0
- package/dist/rails/paddle/checkout.d.ts +2 -0
- package/dist/rails/paddle/checkout.js +2 -0
- package/dist/rails/paddle/discounts.d.ts +2 -0
- package/dist/rails/paddle/discounts.js +2 -0
- package/dist/rails/paddle/events.d.ts +2 -0
- package/dist/rails/paddle/events.js +2 -0
- package/dist/rails/paddle/fixtures/browserForged.d.ts +2 -0
- package/dist/rails/paddle/fixtures/browserForged.js +2 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.d.ts +2 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.js +2 -0
- package/dist/rails/paddle/objects.d.ts +2 -0
- package/dist/rails/paddle/objects.js +2 -0
- package/dist/rails/paddle/portal.d.ts +2 -0
- package/dist/rails/paddle/portal.js +2 -0
- package/dist/rails/paddle/rail.d.ts +2 -0
- package/dist/rails/paddle/rail.js +2 -0
- package/dist/rails/paddle/read.d.ts +2 -0
- package/dist/rails/paddle/read.js +2 -0
- package/dist/rails/paddle/recorded.d.ts +2 -0
- package/dist/rails/paddle/recorded.js +2 -0
- package/dist/rails/paddle/refresh.d.ts +2 -0
- package/dist/rails/paddle/refresh.js +2 -0
- package/dist/rails/paddle/refund.d.ts +2 -0
- package/dist/rails/paddle/refund.js +2 -0
- package/dist/rails/paddle/signature.d.ts +2 -0
- package/dist/rails/paddle/signature.js +2 -0
- package/dist/rails/paddle/subscription.d.ts +2 -0
- package/dist/rails/paddle/subscription.js +2 -0
- package/dist/rails/paddle/verify.d.ts +2 -0
- package/dist/rails/paddle/verify.js +2 -0
- package/dist/rails/paddle/webhook.d.ts +2 -0
- package/dist/rails/paddle/webhook.js +2 -0
- package/dist/rails/providers.d.ts +2 -0
- package/dist/rails/providers.js +2 -0
- package/dist/rails/stripe/api.d.ts +2 -0
- package/dist/rails/stripe/api.js +2 -0
- package/dist/rails/stripe/checkout.d.ts +2 -0
- package/dist/rails/stripe/checkout.js +2 -0
- package/dist/rails/stripe/discounts.d.ts +2 -0
- package/dist/rails/stripe/discounts.js +2 -0
- package/dist/rails/stripe/fixtures/events.d.ts +2 -0
- package/dist/rails/stripe/fixtures/events.js +2 -0
- package/dist/rails/stripe/objects.d.ts +2 -0
- package/dist/rails/stripe/objects.js +2 -0
- package/dist/rails/stripe/portal.d.ts +2 -0
- package/dist/rails/stripe/portal.js +2 -0
- package/dist/rails/stripe/pricing.d.ts +2 -0
- package/dist/rails/stripe/pricing.js +2 -0
- package/dist/rails/stripe/rail.d.ts +2 -0
- package/dist/rails/stripe/rail.js +2 -0
- package/dist/rails/stripe/refresh.d.ts +2 -0
- package/dist/rails/stripe/refresh.js +2 -0
- package/dist/rails/stripe/signature.d.ts +2 -0
- package/dist/rails/stripe/signature.js +2 -0
- package/dist/rails/stripe/verify.d.ts +2 -0
- package/dist/rails/stripe/verify.js +2 -0
- package/dist/rails/stripe/webhook.d.ts +2 -0
- package/dist/rails/stripe/webhook.js +2 -0
- package/dist/secret/registry.d.ts +2 -0
- package/dist/secret/registry.js +2 -0
- package/dist/seeds/example.d.ts +2 -0
- package/dist/seeds/example.js +2 -0
- package/dist/version.generated.d.ts +3 -1
- package/dist/version.generated.js +3 -1
- package/dist/workflows/paddleSweep.d.ts +2 -0
- package/dist/workflows/paddleSweep.js +2 -0
- package/dist/workflows/railAccess.d.ts +2 -0
- package/dist/workflows/railAccess.js +2 -0
- package/dist/workflows/reconcile.d.ts +2 -0
- package/dist/workflows/reconcile.js +2 -0
- package/dist/workflows/report.d.ts +2 -0
- package/dist/workflows/report.js +2 -0
- package/dist/workflows/retryPolicy.d.ts +2 -0
- package/dist/workflows/retryPolicy.js +2 -0
- package/dist/workflows/specs.d.ts +2 -0
- package/dist/workflows/specs.js +2 -0
- package/dist/workflows/worker.d.ts +2 -0
- package/dist/workflows/worker.js +2 -0
- package/dist/workflows/workerConfig.d.ts +2 -0
- package/dist/workflows/workerConfig.js +2 -0
- package/package.json +5 -5
- package/pithy.manifest.json +2 -2
- package/src/capability.ts +16 -0
- package/src/entitlement/unimplementedSubject.ts +89 -0
- package/src/index.ts +8 -0
- package/src/version.generated.ts +1 -1
- package/src/workflows/paddleSweep.ts +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { InternalError, ValidationError } from "@pithy-sh/core/src/error/pithyError";
|
|
4
|
+
//#region src/entitlement/unimplementedSubject.ts
|
|
5
|
+
/**
|
|
6
|
+
* The placeholder `pithy add payments --set billingSubject=organization` scaffolds, and the brand that
|
|
7
|
+
* makes it recognizably unfinished.
|
|
8
|
+
*
|
|
9
|
+
* ## Why a placeholder is safe here and a stub never is
|
|
10
|
+
*
|
|
11
|
+
* A stub is a resolver that *answers*. Returning `undefined` composes cleanly, satisfies every check the
|
|
12
|
+
* capability can make, and then denies every entitlement gate and raises `payments/subject_unresolved` on
|
|
13
|
+
* every write — which is indistinguishable from a customer who has not paid, and whose first symptom is a
|
|
14
|
+
* support ticket from a paying company. That is strictly worse than refusing to write the config at all,
|
|
15
|
+
* and it is why `pithy add` refused `organization` outright for as long as a stub was the only thing it
|
|
16
|
+
* could have written (#483).
|
|
17
|
+
*
|
|
18
|
+
* This answers nothing. It is a **marked absence**: a function carrying {@link UNIMPLEMENTED_SUBJECT},
|
|
19
|
+
* which `payments()` reads at the Worker's entrypoint and refuses to boot on. So the two facts that used
|
|
20
|
+
* to be in tension both hold — the adopter states `organization`, which is what they mean, and the Worker
|
|
21
|
+
* still will not serve a request until somebody has written the resolver (#500).
|
|
22
|
+
*
|
|
23
|
+
* ## Why the check is at the entrypoint and not at composition
|
|
24
|
+
*
|
|
25
|
+
* `payments()` runs whenever a Worker's `pithy.config.ts` is *evaluated*, and the CLI evaluates that
|
|
26
|
+
* module on nearly every command — `loadWorkerConfig` is how `migrate`, `deploy`, `doctor`, `upgrade` and
|
|
27
|
+
* `add` itself learn what a Worker composes. A refusal at composition would therefore brick the whole CLI
|
|
28
|
+
* in the adopter's project the moment the scaffold landed, which is exactly the #483 regression turned
|
|
29
|
+
* inside out. `createEntrypoint` is the one seam the CLI never crosses: only the Worker's own
|
|
30
|
+
* `src/index.ts` calls it. So the composition check stays what it was — an **absent** resolver is refused,
|
|
31
|
+
* unchanged — and the unimplemented one is refused one seam later, where the audience is a request.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* The brand. `Symbol.for` rather than a module-local symbol or function identity: a project that ends up
|
|
35
|
+
* with two copies of `@pithy-sh/payments` resolved (a transitive range that did not dedupe) would compare
|
|
36
|
+
* a placeholder from one copy against the marker from the other, and identity would answer no — booting a
|
|
37
|
+
* Worker that denies every gate, which is the one outcome this file exists to prevent. A registered symbol
|
|
38
|
+
* is the same symbol in both copies.
|
|
39
|
+
*/
|
|
40
|
+
const UNIMPLEMENTED_SUBJECT = Symbol.for("@pithy-sh/payments/unimplemented-subject");
|
|
41
|
+
/**
|
|
42
|
+
* The scaffolded resolver: branded unimplemented, and a throw if anything ever calls it.
|
|
43
|
+
*
|
|
44
|
+
* A throw rather than `undefined`, and it is belt and braces rather than the mechanism — {@link
|
|
45
|
+
* requireImplementedSubject} means a deployed Worker never gets here. What it covers is every other way
|
|
46
|
+
* this function could be reached: a test composing the capability directly, a tool that assembles a
|
|
47
|
+
* backend without an entrypoint (`pithy ui` reads the composed route tree that way), an adopter who
|
|
48
|
+
* imported the placeholder somewhere of their own. In all of them a loud failure is the right answer and a
|
|
49
|
+
* quiet `undefined` is the failure mode of the stub this replaces.
|
|
50
|
+
*/
|
|
51
|
+
const unimplementedSubject = Object.defineProperty(async () => {
|
|
52
|
+
throw new InternalError({
|
|
53
|
+
message: "The subject resolver for this project has not been written.",
|
|
54
|
+
action: "Implement resolveSubject in this Worker's src/billing/subject.ts.",
|
|
55
|
+
detail: "pithy add scaffolded an unimplemented resolveSubject and it is still the one composed. Under billingSubject: \"organization\" only the application can say which organization a caller is acting for."
|
|
56
|
+
});
|
|
57
|
+
}, UNIMPLEMENTED_SUBJECT, { value: true });
|
|
58
|
+
/** Whether this resolver is the scaffolded placeholder rather than something the adopter wrote. */
|
|
59
|
+
function isUnimplementedSubject(resolver) {
|
|
60
|
+
return resolver !== void 0 && resolver[UNIMPLEMENTED_SUBJECT] === true;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Refuse a Worker whose subject resolver is still the scaffolded placeholder.
|
|
64
|
+
*
|
|
65
|
+
* Called from the capability's `boot` hook, which `createEntrypoint` runs and nothing else does. The
|
|
66
|
+
* message is the adopter's next action and nothing else: the file is named, the question it has to answer
|
|
67
|
+
* is stated, and the alternative is the other billing mode.
|
|
68
|
+
*/
|
|
69
|
+
function requireImplementedSubject(resolver) {
|
|
70
|
+
if (!isUnimplementedSubject(resolver)) return;
|
|
71
|
+
throw new ValidationError({
|
|
72
|
+
message: "This project bills organizations, and its subject resolver is still the scaffolded placeholder.",
|
|
73
|
+
action: "Implement resolveSubject in this Worker's src/billing/subject.ts, or set `billingSubject: \"user\"` in pithy.config.ts.",
|
|
74
|
+
detail: "pithy add wrote src/billing/subject.ts exporting an unimplemented resolveSubject, and it is unchanged. Payments has no members table and never guesses a holder, so booting on it would deny every entitlement gate and raise payments/subject_unresolved on every write, for every caller, forever."
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { isUnimplementedSubject, requireImplementedSubject, unimplementedSubject };
|
package/dist/error/errors.d.ts
CHANGED
package/dist/error/errors.js
CHANGED
package/dist/grants/apply.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import type { D1Database } from "@cloudflare/workers-types";
|
|
2
4
|
import { type AuditEmit } from "@pithy-sh/core/src/audit/recorder";
|
|
3
5
|
import type { PaymentsConfig, PaymentsLedgerGrant } from "../config/config";
|
package/dist/grants/apply.js
CHANGED
package/dist/grants/clawback.js
CHANGED
package/dist/http/dispatch.d.ts
CHANGED
package/dist/http/dispatch.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PAYMENTS_CAPABILITY, paymentsWorkflowRegistry } from "../workflows/specs.js";
|
|
2
4
|
import { triggerWorkflow } from "@pithy-sh/core/src/workflow/dispatch";
|
|
3
5
|
import { workflowKey } from "@pithy-sh/core/src/workflow/naming";
|
package/dist/http/guards.d.ts
CHANGED
package/dist/http/guards.js
CHANGED
package/dist/http/responses.d.ts
CHANGED
package/dist/http/responses.js
CHANGED
package/dist/http/routes.d.ts
CHANGED
package/dist/http/routes.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PAYMENTS_HOSTED_RAILS } from "../data/rail.js";
|
|
2
4
|
import { decodeSubjectReference, encodeSubjectReference, sameSubject } from "../data/subject.js";
|
|
3
5
|
import { providerProductId, railEnabled, resolveProduct } from "../config/config.js";
|
package/dist/http/schemas.d.ts
CHANGED
package/dist/http/schemas.js
CHANGED
package/dist/http/scopes.d.ts
CHANGED
package/dist/http/scopes.js
CHANGED
package/dist/http/view.d.ts
CHANGED
package/dist/http/view.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import type { D1Database } from "@cloudflare/workers-types";
|
|
2
4
|
import type { PithyHonoEnv } from "@pithy-sh/core/src/capability/capability";
|
|
3
5
|
import type { Context, MiddlewareHandler } from "hono";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PaymentsWebhookEvent, isWebhookEventFinished, webhookEventState } from "../data/webhookEvent.js";
|
|
2
4
|
import { PAYMENTS_WEBHOOK_EVENTS_TABLE, paymentsDatabase } from "../data/tables.js";
|
|
3
5
|
import { PaymentsWebhookUnverifiedError } from "../error/errors.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
/**
|
|
2
4
|
* The package entrypoint — the surface `pithy add payments` wires into `pithy.config.ts`. Deliberately
|
|
3
5
|
* narrow: the capability factory, its catalog types and lookups, the four table schemas, and the projection
|
|
@@ -33,6 +35,7 @@ export { PaymentsWebhookEvent, WEBHOOK_EVENT_ORPHANED, webhookEventAwaitsOwner }
|
|
|
33
35
|
export { grantEntitlement, type ManualEntitlementInput, type ManualEntitlementOptions, revokeEntitlement, } from "./entitlement/manual";
|
|
34
36
|
export { createPaymentsEntitlementResolver, installEntitlementResolver, PAYMENTS_ENTITLEMENT_PROVIDER, } from "./entitlement/resolver";
|
|
35
37
|
export { authenticatedUserSubject, type PaymentsSubjectResolver, type PaymentsSubjectSeam, requirePaymentsSubject, resolvePaymentsSubject, } from "./entitlement/subjectSeam";
|
|
38
|
+
export { isUnimplementedSubject, requireImplementedSubject, unimplementedSubject, } from "./entitlement/unimplementedSubject";
|
|
36
39
|
export { type AppliedGrant, applyGrants, type FulfillmentReport, type FulfillPurchaseOptions, fulfillPurchase, type GrantOptions, grantRef, ledgerGrantFor, purchaseIsPaid, } from "./grants/apply";
|
|
37
40
|
export { type ClawbackOutcome, clawbackGrants, clawbackRef } from "./grants/clawback";
|
|
38
41
|
export { type OpenPaymentsLedgerOptions, openPaymentsLedger, type PaymentsLedger, type PaymentsLedgerLoader, } from "./grants/ledgerSeam";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,cAAc,EACd,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,eAAe,EACf,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,cAAc,GACf,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kB,EACvB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iCAAiC,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PAYMENTS_RAILS, PaymentsRail } from "./data/rail.js";
|
|
2
4
|
import { PaymentsSubject, PaymentsSubjectType, decodeSubjectReference, encodeSubjectReference, sameSubject } from "./data/subject.js";
|
|
3
5
|
import { PaymentsAppleProduct, PaymentsConfig, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsRailToggles, PaymentsStripeProduct, PaymentsStripeSettings, entitlementsForProduct, grantableEntitlements, productForProviderSku, providerProductId, railEnabled, resolveProduct } from "./config/config.js";
|
|
@@ -11,6 +13,7 @@ import { PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS
|
|
|
11
13
|
import { resolveEntitlements } from "./projection/resolve.js";
|
|
12
14
|
import { authenticatedUserSubject, requirePaymentsSubject, resolvePaymentsSubject } from "./entitlement/subjectSeam.js";
|
|
13
15
|
import { PAYMENTS_ENTITLEMENT_PROVIDER, createPaymentsEntitlementResolver, installEntitlementResolver } from "./entitlement/resolver.js";
|
|
16
|
+
import { isUnimplementedSubject, requireImplementedSubject, unimplementedSubject } from "./entitlement/unimplementedSubject.js";
|
|
14
17
|
import { PaymentsAuditActions } from "./audit/actions.js";
|
|
15
18
|
import { grantEntitlement, revokeEntitlement } from "./entitlement/manual.js";
|
|
16
19
|
import { openPaymentsLedger } from "./grants/ledgerSeam.js";
|
|
@@ -40,4 +43,4 @@ import { PAYMENTS_RECONCILE_KEY, triggerPaymentsReconcile } from "./http/dispatc
|
|
|
40
43
|
import { paymentsWorkerName, resolvePaymentsConfig } from "./provision/resolvePaymentsConfig.js";
|
|
41
44
|
import { batchedRailAccess } from "./workflows/railAccess.js";
|
|
42
45
|
import { reconcilePayments } from "./workflows/reconcile.js";
|
|
43
|
-
export { ACCESS_GRANTING_STATUSES, APPLE_API_AUDIENCE, APPLE_API_BASES, APPLE_ROOT_CERTIFICATES, AppleSubscriptionStatuses, AppleWebhookNotification, CheckoutRequest, DEFAULT_EXPIRING_WITHIN_SECONDS, DEFAULT_STALE_AFTER_SECONDS, EntitlementGrantRequest, EntitlementRevokeRequest, GOOGLE_JWKS_URL, GOOGLE_OIDC_ISSUERS, GoogleJwk, GoogleJwks, GoogleWebhookNotification, ORPHAN_REPAIR_LIMIT, PAYMENTS_CAPABILITY, PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_PROVIDER, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_MIGRATION_ORDER, PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS_PROVIDER_SECRET, PAYMENTS_PURCHASES_TABLE, PAYMENTS_RAILS, PAYMENTS_RECONCILE_KEY, PAYMENTS_RECONCILE_RUNS_TABLE, PAYMENTS_WEBHOOK_EVENTS_TABLE, PaymentsAppleCredentials, PaymentsAppleProduct, PaymentsAuditActions, PaymentsConfig, PaymentsEntitlement, PaymentsGoogleCredentials, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsProviderAccount, PaymentsProviderCredentials, PaymentsPurchase, PaymentsRail, PaymentsRailToggles, PaymentsReconcileParams, PaymentsReconcileRun, PaymentsStripeCredentials, PaymentsStripeProduct, PaymentsStripeSettings, PaymentsSubject, PaymentsSubjectType, PaymentsWebhookEvent, ProviderEvent, PurchaseEnvironment, PurchaseStatus, PurchaseSubmission, RECONCILE_RUN_RETENTION_DAYS, RestoreRequest, STRIPE_API_VERSION, STRIPE_METADATA_ACCOUNT_REFERENCE, STRIPE_METADATA_PRICE, StripeWebhookNotification, WEBHOOK_EVENT_ORPHANED, appleSubscriptionStatus, applyGrants, authenticatedUserSubject, batchedRailAccess, clawbackGrants, clawbackRef, createPaymentsEntitlementResolver, decodeSubjectReference, encodeSubjectReference, entitlementsForProduct, fulfillPurchase, grantEntitlement, grantRef, grantableEntitlements, grantingStatuses, implementedRails, installEntitlementResolver, isCheckoutRail, isPaymentsCapability, ledgerGrantFor, linkProviderAccount, minorUnitDigits, minorUnitsFromScaled, mintAppleApiToken, noteIsRepairable, noteText, openPaymentsLedger, payments, paymentsDatabase, paymentsExampleSeed, paymentsSecretsRegistry, paymentsTables, paymentsWorkerName, paymentsWorkflowRegistry, paymentsWorkflows, productForProviderSku, projectPurchase, providerAccountForSubject, providerProductId, purchaseIsPaid, railCredentials, railEnabled, reconcilePayments, recordReconcileRun, registerPaymentsRoutes, repairOrphanedEvents, requireAuth, requirePaymentsSubject, resolveEntitlements, resolveNotificationOwner, resolvePaymentsConfig, resolvePaymentsSubject, resolveProduct, resolveRailProvider, revokeEntitlement, sameSubject, statusGrantsAccess, triggerPaymentsReconcile, webhookEventAwaitsOwner };
|
|
46
|
+
export { ACCESS_GRANTING_STATUSES, APPLE_API_AUDIENCE, APPLE_API_BASES, APPLE_ROOT_CERTIFICATES, AppleSubscriptionStatuses, AppleWebhookNotification, CheckoutRequest, DEFAULT_EXPIRING_WITHIN_SECONDS, DEFAULT_STALE_AFTER_SECONDS, EntitlementGrantRequest, EntitlementRevokeRequest, GOOGLE_JWKS_URL, GOOGLE_OIDC_ISSUERS, GoogleJwk, GoogleJwks, GoogleWebhookNotification, ORPHAN_REPAIR_LIMIT, PAYMENTS_CAPABILITY, PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_PROVIDER, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_MIGRATION_ORDER, PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS_PROVIDER_SECRET, PAYMENTS_PURCHASES_TABLE, PAYMENTS_RAILS, PAYMENTS_RECONCILE_KEY, PAYMENTS_RECONCILE_RUNS_TABLE, PAYMENTS_WEBHOOK_EVENTS_TABLE, PaymentsAppleCredentials, PaymentsAppleProduct, PaymentsAuditActions, PaymentsConfig, PaymentsEntitlement, PaymentsGoogleCredentials, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsProviderAccount, PaymentsProviderCredentials, PaymentsPurchase, PaymentsRail, PaymentsRailToggles, PaymentsReconcileParams, PaymentsReconcileRun, PaymentsStripeCredentials, PaymentsStripeProduct, PaymentsStripeSettings, PaymentsSubject, PaymentsSubjectType, PaymentsWebhookEvent, ProviderEvent, PurchaseEnvironment, PurchaseStatus, PurchaseSubmission, RECONCILE_RUN_RETENTION_DAYS, RestoreRequest, STRIPE_API_VERSION, STRIPE_METADATA_ACCOUNT_REFERENCE, STRIPE_METADATA_PRICE, StripeWebhookNotification, WEBHOOK_EVENT_ORPHANED, appleSubscriptionStatus, applyGrants, authenticatedUserSubject, batchedRailAccess, clawbackGrants, clawbackRef, createPaymentsEntitlementResolver, decodeSubjectReference, encodeSubjectReference, entitlementsForProduct, fulfillPurchase, grantEntitlement, grantRef, grantableEntitlements, grantingStatuses, implementedRails, installEntitlementResolver, isCheckoutRail, isPaymentsCapability, isUnimplementedSubject, ledgerGrantFor, linkProviderAccount, minorUnitDigits, minorUnitsFromScaled, mintAppleApiToken, noteIsRepairable, noteText, openPaymentsLedger, payments, paymentsDatabase, paymentsExampleSeed, paymentsSecretsRegistry, paymentsTables, paymentsWorkerName, paymentsWorkflowRegistry, paymentsWorkflows, productForProviderSku, projectPurchase, providerAccountForSubject, providerProductId, purchaseIsPaid, railCredentials, railEnabled, reconcilePayments, recordReconcileRun, registerPaymentsRoutes, repairOrphanedEvents, requireAuth, requireImplementedSubject, requirePaymentsSubject, resolveEntitlements, resolveNotificationOwner, resolvePaymentsConfig, resolvePaymentsSubject, resolveProduct, resolveRailProvider, revokeEntitlement, sameSubject, statusGrantsAccess, triggerPaymentsReconcile, unimplementedSubject, webhookEventAwaitsOwner };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
/*! SPDX-FileCopyrightText: 2026 Pithy | SPDX-License-Identifier: MIT */
|
|
1
2
|
(function(){function e(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.getItem==`function`&&typeof t.setItem==`function`&&typeof t.removeItem==`function`}function t(t){let n=typeof t.key==`string`?t.key.trim():``,r=e(t.store)?t.store:null,i=typeof t.ttlMs==`number`&&Number.isFinite(t.ttlMs)&&t.ttlMs>0?t.ttlMs:null;if(n!==``&&r!==null&&i!==null)return{key:n,store:r,ttlMs:i};if((t.key??t.store??t.ttlMs)==null)return null;let a=[n===``?`key`:null,r===null?`store`:null,i===null?`ttlMs`:null].filter(e=>e!==null).join(`, `);return console.warn(`Paddle price cache ignored. Missing: ${a}. A cache needs key, store and ttlMs together, so that where a customer's price rests and how long it stands are both stated. Pass all three, or none.`),null}function n(e){return`pithy.paddle.price.${e.key}.`}function r(e,t){return`${n(e)}${t}`}function i(e){if(e===null)return null;let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t;return typeof n.at!=`number`||!(`answer`in n)?null:{at:n.at,answer:n.answer}}function a(e,t){let n=Date.now()-e;return n<0||n>t}function o(e,t){try{e.store.removeItem(r(e,t))}catch{}}function s(e,t){let n;try{n=e.store.getItem(r(e,t))}catch{return null}if(n===null)return null;let s=i(n);return s===null||a(s.at,e.ttlMs)?(o(e,t),null):s.answer}function c(e){let t=e.store;if(typeof t.key==`function`&&typeof t.length==`number`)try{let r=[],o=n(e);for(let n=0;n<t.length;n+=1){let s=t.key(n);if(s==null||!s.startsWith(o))continue;let c=i(t.getItem(s));(c===null||a(c.at,e.ttlMs))&&r.push(s)}for(let e of r)t.removeItem(e)}catch{}}function l(e,t,n){c(e);let i;try{i=JSON.stringify({at:Date.now(),answer:n})}catch{return}try{e.store.setItem(r(e,t),i)}catch{}}function u(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){u(a,r,i,o,s,`next`,e)}function s(e){u(a,r,i,o,s,`throw`,e)}o(void 0)})}}function f(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?p(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(e,t){if(e==null)return{};var n,r,i=g(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function _(){_=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},a=typeof Symbol==`function`?Symbol:{},o=a.iterator||`@@iterator`,s=a.asyncIterator||`@@asyncIterator`,c=a.toStringTag||`@@toStringTag`;function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},``)}catch{l=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype);return i(o,`_invoke`,{value:D(e,n,new j(r||[]))}),o}function d(e,t,n){try{return{type:`normal`,arg:e.call(t,n)}}catch(e){return{type:`throw`,arg:e}}}t.wrap=u;var f=`suspendedStart`,p=`suspendedYield`,m=`executing`,h=`completed`,g={};function v(){}function y(){}function b(){}var x={};l(x,o,function(){return this});var S=Object.getPrototypeOf,C=S&&S(S(M([])));C&&C!==n&&r.call(C,o)&&(x=C);var w=b.prototype=v.prototype=Object.create(x);function T(e){[`next`,`throw`,`return`].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function E(e,t){function n(i,a,o,s){var c=d(e[i],e,a);if(c.type!==`throw`){var l=c.arg,u=l.value;return u&&typeof u==`object`&&r.call(u,`__await`)?t.resolve(u.__await).then(function(e){n(`next`,e,o,s)},function(e){n(`throw`,e,o,s)}):t.resolve(u).then(function(e){l.value=e,o(l)},function(e){return n(`throw`,e,o,s)})}s(c.arg)}var a;i(this,`_invoke`,{value:function(e,r){function i(){return new t(function(t,i){n(e,r,t,i)})}return a=a?a.then(i,i):i()}})}function D(t,n,r){var i=f;return function(a,o){if(i===m)throw Error(`Generator is already running`);if(i===h){if(a===`throw`)throw o;return{value:e,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var c=O(s,r);if(c){if(c===g)continue;return c}}if(r.method===`next`)r.sent=r._sent=r.arg;else if(r.method===`throw`){if(i===f)throw i=h,r.arg;r.dispatchException(r.arg)}else r.method===`return`&&r.abrupt(`return`,r.arg);i=m;var l=d(t,n,r);if(l.type===`normal`){if(i=r.done?h:p,l.arg===g)continue;return{value:l.arg,done:r.done}}l.type===`throw`&&(i=h,r.method=`throw`,r.arg=l.arg)}}}function O(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,r===`throw`&&t.iterator.return&&(n.method=`return`,n.arg=e,O(t,n),n.method===`throw`)||r!==`return`&&(n.method=`throw`,n.arg=TypeError(`The iterator does not provide a '`+r+`' method`)),g;var a=d(i,t.iterator,n.arg);if(a.type===`throw`)return n.method=`throw`,n.arg=a.arg,n.delegate=null,g;var o=a.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,n.method!==`return`&&(n.method=`next`,n.arg=e),n.delegate=null,g):o:(n.method=`throw`,n.arg=TypeError(`iterator result is not an object`),n.delegate=null,g)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type=`normal`,delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:`root`}],e.forEach(k,this),this.reset(!0)}function M(t){if(t||t===``){var n=t[o];if(n)return n.call(t);if(typeof t.next==`function`)return t;if(!isNaN(t.length)){var i=-1,a=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw TypeError(typeof t+` is not iterable`)}return y.prototype=b,i(w,`constructor`,{value:b,configurable:!0}),i(b,`constructor`,{value:y,configurable:!0}),y.displayName=l(b,c,`GeneratorFunction`),t.isGeneratorFunction=function(e){var t=typeof e==`function`&&e.constructor;return!!t&&(t===y||(t.displayName||t.name)===`GeneratorFunction`)},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,l(e,c,`GeneratorFunction`)),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},T(E.prototype),l(E.prototype,s,function(){return this}),t.AsyncIterator=E,t.async=function(e,n,r,i,a){a===void 0&&(a=Promise);var o=new E(u(e,n,r,i),a);return t.isGeneratorFunction(n)?o:o.next().then(function(e){return e.done?e.value:o.next()})},T(w),l(w,c,`Generator`),l(w,o,function(){return this}),l(w,`toString`,function(){return`[object Generator]`}),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=M,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method=`next`,this.arg=e,this.tryEntries.forEach(A),!t)for(var n in this)n.charAt(0)===`t`&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if(e.type===`throw`)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type=`throw`,s.arg=t,n.next=r,i&&(n.method=`next`,n.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if(o.tryLoc===`root`)return i(`end`);if(o.tryLoc<=this.prev){var c=r.call(o,`catchLoc`),l=r.call(o,`finallyLoc`);if(c&&l){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!l)throw Error(`try statement without catch or finally`);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,`finallyLoc`)&&this.prev<i.finallyLoc){var a=i;break}}a&&(e===`break`||e===`continue`)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method=`next`,this.next=a.finallyLoc,g):this.complete(o)},complete:function(e,t){if(e.type===`throw`)throw e.arg;return e.type===`break`||e.type===`continue`?this.next=e.arg:e.type===`return`?(this.rval=this.arg=e.arg,this.method=`return`,this.next=`end`):e.type===`normal`&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if(r.type===`throw`){var i=r.arg;A(n)}return i}}throw Error(`illegal catch attempt`)},delegateYield:function(t,n,r){return this.delegate={iterator:M(t),resultName:n,nextLoc:r},this.method===`next`&&(this.arg=e),g}},t}function v(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return typeof t==`symbol`?t:t+``}var b={CLASSIC:`classic`,V1:`v1`},x=b.V1,S=`https://cdn.paddle.com/paddle/paddle.js`,C=`https://cdn.paddle.com/paddle/v2/paddle.js`,w={url:S},T={url:C};function E(e){return document.querySelector(`script[src="${e}"]`)||void 0}function D(e){var t=document.createElement(`script`);t.src=e;var n=document.head||document.body;if(!n)throw Error(`Cannot inject Paddle.js. It needs a <head> or <body> element.`);return n.appendChild(t),t}var O={classic:void 0,v1:void 0},k={classic:`PaddleClassic`,v1:`PaddleBillingV1`};function A(e){var t=j(e)?.url;if(t){var n=O[e],r=k[e];return n===void 0?(O[e]=new Promise(function(n,i){if(typeof window>`u`){n(void 0);return}if(window[r]){n(window[r]);return}try{var a=E(t);a||=D(t),a.addEventListener(`load`,function(){window[r]?n(window[r]):i(Error(`Paddle.js not available`))}),a.addEventListener(`error`,function(){i(Error(`Failed to load Paddle.js - ${e}`))})}catch(e){i(e);return}}),O[e]):n}}function j(e){if(e===b.CLASSIC)return w;if(e===b.V1)return T;console.error(`[Paddle] Unknown Paddle Version`)}var M=[`environment`,`version`],ee=[`environment`,`version`];function N(e,t){var n=e.environment;e.version;var r=h(e,M);try{n&&t.Environment.set(n),t.Initialized?t.Update(m({},r)):t.Initialize(m({},r))}catch(e){console.warn(`[Paddle] Paddle Initialization failed. Please check the inputs`,e)}}function te(e,t){var n=e.environment;e.version;var r=h(e,ee);try{n&&t.Environment.set(n),t.Setup(m({},r))}catch(e){console.warn(`[Paddle] Paddle Initialization failed. Please check the inputs`,e)}}var ne;(function(e){e.CHECKOUT_LOADED=`checkout.loaded`,e.CHECKOUT_CLOSED=`checkout.closed`,e.CHECKOUT_UPDATED=`checkout.updated`,e.CHECKOUT_COMPLETED=`checkout.completed`,e.CHECKOUT_ERROR=`checkout.error`,e.CHECKOUT_FAILED=`checkout.failed`,e.CHECKOUT_ITEMS_UPDATED=`checkout.items.updated`,e.CHECKOUT_ITEMS_REMOVED=`checkout.items.removed`,e.CHECKOUT_CUSTOMER_CREATED=`checkout.customer.created`,e.CHECKOUT_CUSTOMER_UPDATED=`checkout.customer.updated`,e.CHECKOUT_CUSTOMER_REMOVED=`checkout.customer.removed`,e.CHECKOUT_PAYMENT_SELECTED=`checkout.payment.selected`,e.CHECKOUT_PAYMENT_INITIATED=`checkout.payment.initiated`,e.CHECKOUT_PAYMENT_FAILED=`checkout.payment.failed`,e.CHECKOUT_PAYMENT_ERROR=`checkout.payment.error`,e.CHECKOUT_DISCOUNT_APPLIED=`checkout.discount.applied`,e.CHECKOUT_DISCOUNT_REMOVED=`checkout.discount.removed`,e.CHECKOUT_UPSELL_CANCELED=`checkout.upsell.canceled`})(ne||={});var re;(function(e){e.DAY=`day`,e.WEEK=`week`,e.MONTH=`month`,e.YEAR=`year`})(re||={});var ie;(function(e){e.ALIPAY=`alipay`,e.APPLE_PAY=`apple-pay`,e.CARD=`card`,e.GOOGLE_PAY=`google-pay`,e.IDEAL=`ideal`,e.PAYPAL=`paypal`,e.WECHAT_PAY=`wechat-pay`,e.WIRE_TRANSFER=`wire-transfer`,e.NONE=`none`})(ie||={});var ae;(function(e){e.AMERICAN_EXPRESS=`american_express`,e.DINERS_CLUB=`diners_club`,e.DISCOVER=`discover`,e.JCB=`jcb`,e.MADA=`mada`,e.MAESTRO=`maestro`,e.MASTER_CARD=`mastercard`,e.UNION_PAY=`union_pay`,e.VISA=`visa`,e.UNKNOWN=`unknown`})(ae||={});var oe;(function(e){e.DRAFT=`draft`,e.READY=`ready`,e.COMPLETED=`completed`,e.BILLED=`billed`,e.canceled=`canceled`,e.PAST_DUE=`past_due`})(oe||={});function se(e){return P.apply(this,arguments)}function P(){return P=d(_().mark(function e(t){var n,r;return _().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t?.version||x,e.next=3,A(n);case 3:if(r=e.sent,!r){e.next=9;break}return t&&(n===b.V1?N(t,r):n===b.CLASSIC&&te(t,r)),e.abrupt(`return`,r);case 9:return console.error(`[Paddle] Error Loading Paddle`),e.abrupt(`return`);case 11:case`end`:return e.stop()}},e)})),P.apply(this,arguments)}let ce={code:`client/unreadable`,message:`The store answered with something we couldn't read.`,action:`Try again. If it keeps happening, the app and the backend are out of step.`},le={code:`client/no_browser`,message:`There's no browser to send you to the payment page.`,action:`Start checkout from the page in the browser, not before it has loaded.`},ue=new Set([`BIF`,`CLP`,`DJF`,`GNF`,`ISK`,`JPY`,`KMF`,`KRW`,`PYG`,`RWF`,`UGX`,`UYI`,`VND`,`VUV`,`XAF`,`XOF`,`XPF`]),F=new Set([`BHD`,`IQD`,`JOD`,`KWD`,`LYD`,`OMR`,`TND`]);function I(e){let t=e.toUpperCase();return ue.has(t)?0:F.has(t)?3:2}let L=/\p{Nd}/u,R=/^-?[0-9]+$/;function z(e){return e!==void 0&&L.test(e)}function B(e){if(e===void 0||!z(e))return!1;let t=e.codePointAt(0);return t!==void 0&&!z(String.fromCodePoint(t-1))}function V(e,t){let n=[...e],r=n.length;for(;r>0&&!z(n[r-1]);)--r;let i=r-t;if(i<2)return e;for(let t=i;t<r;t+=1)if(!B(n[t]))return e;return z(n[i-1])||!z(n[i-2])?e:[...n.slice(0,i-1),...n.slice(r)].join(``)}function H(e){let t=I(e.currency);if(t===0||!R.test(e.minorAmount))return e.formatted;let n=Number(e.minorAmount);return!Number.isSafeInteger(n)||n%10**t!=0?e.formatted:V(e.formatted,t)}let U={code:`client/paddle_unavailable`,message:`We couldn't load the payment provider.`,action:`Check your connection or any content blockers, then reload.`},de={code:`client/paddle_not_initialized`,message:`The payment provider wouldn't start.`,action:`Reload. If it keeps happening, this project's payment settings are wrong.`},fe={code:`client/paddle_account_conflict`,message:`The payment provider is already running for a different account.`,action:`One page serves one Paddle account. Reload before switching.`},pe={code:`client/paddle_preview_refused`,message:`We couldn't get a price for you.`,action:`Try again in a moment.`},me={};function W(e){return`${e.environment}:${e.clientToken}`}let he=e=>se(e);function ge(e,t){let n=t?.registry??me,r=W(e),i=n.current;if(i)return i.key===r?i.paddle:Promise.resolve({ok:!1,failure:fe});let a=t?.initialize??he,o=new Promise(t=>{t(a({token:e.clientToken,environment:e.environment}))}).then(e=>e?e.Initialized?{ok:!0,value:e}:{ok:!1,failure:de}:{ok:!1,failure:le},()=>({ok:!1,failure:U})).then(e=>(!e.ok&&n.current?.key===r&&(n.current=void 0),e));return n.current={key:r,paddle:o},o}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){if(!G(e))return null;let{subtotal:t,discount:n,tax:r,total:i}=e;return typeof t!=`string`||typeof n!=`string`||typeof r!=`string`||typeof i!=`string`?null:{subtotal:t,discount:n,tax:r,total:i}}function q(e){return typeof e==`string`&&e.length>0?e:null}function _e(e,t){let n=e.unitPriceOverrides;if(t!==null&&Array.isArray(n))for(let e of n){if(!G(e)||!Array.isArray(e.countryCodes)||!e.countryCodes.includes(t))continue;let n=e.unitPrice;return!G(n)||typeof n.amount!=`string`||typeof n.currencyCode!=`string`?null:{amount:n.amount,currency:n.currencyCode}}let r=e.unitPrice;return!G(r)||typeof r.amount!=`string`||typeof r.currencyCode!=`string`?null:{amount:r.amount,currency:r.currencyCode}}function ve(e,t,n,r){if(e.tax===`0`)return`none`;let i=_e(t,r);return i===null||i.currency!==n?`unknown`:e.subtotal===i.amount?`added`:e.total===i.amount?`included`:`unknown`}function ye(e,t,n){if(!G(e))return null;let r=e.price,i=e.product;if(!G(r)||!G(i)||typeof r.id!=`string`||typeof i.name!=`string`||typeof e.quantity!=`number`||typeof e.taxRate!=`string`)return null;let a=K(e.unitTotals),o=K(e.totals),s=K(e.formattedUnitTotals),c=K(e.formattedTotals);if(!a||!o||!s||!c)return null;let l=r.billingCycle,u=G(l)&&typeof l.interval==`string`&&typeof l.frequency==`number`?{interval:l.interval,frequency:l.frequency}:null;return{priceId:r.id,productName:i.name,priceName:q(r.name),quantity:e.quantity,taxRate:e.taxRate,billingCycle:u,unitTotals:a,totals:o,formattedUnitTotals:s,formattedTotals:c,taxTreatment:ve(a,r,t,n)}}function J(e){if(!G(e))return null;let t=G(e.data)?e.data:e;if(typeof t.currencyCode!=`string`)return null;let n=t.details;if(!G(n)||!Array.isArray(n.lineItems))return null;let r=G(t.address)?t.address:null,i=r?q(r.countryCode):null,a=r?q(r.postalCode):null,o=[];for(let e of n.lineItems){let n=ye(e,t.currencyCode,i);if(n===null)return null;o.push(n)}return{currencyCode:t.currencyCode,countryCode:i,postalCode:a,lines:o}}async function be(e,n,r){let i=r?.cache===void 0?null:t(r.cache),a=i===null?``:`${W(e)}|${Se(n)}`;if(i!==null){let e=s(i,a),t=e===null?null:J(e);if(t!==null)return{ok:!0,value:t}}let o=await ge(e,r);if(!o.ok)return o;let c=await new Promise(e=>e(o.value.PricePreview(n))).then(e=>({answered:!0,value:e}),()=>({answered:!1,value:void 0}));if(!c.answered)return{ok:!1,failure:pe};let u=J(c.value);return u===null?{ok:!1,failure:ce}:(i!==null&&l(i,a,c.value),{ok:!0,value:u})}function xe(e,t,n){let r=e.postalCode===null,i=t.formattedUnitTotals,a=r=>n?.wholeUnits===!0?H({formatted:i[r],minorAmount:t.unitTotals[r],currency:e.currencyCode}):i[r];return t.taxTreatment===`added`?{headline:a(`subtotal`),note:`Plus ${i.tax} tax.`,estimated:r}:t.taxTreatment===`included`?{headline:a(`total`),note:`Includes ${i.tax} tax.`,estimated:r}:t.taxTreatment===`none`?{headline:a(`total`),note:r?`Tax is settled at checkout.`:null,estimated:r}:{headline:a(`total`),note:`Includes ${i.tax} tax.`,estimated:r}}function Se(e){return JSON.stringify([e.items.map(e=>[e.priceId,e.quantity]),e.address?[e.address.countryCode,e.address.postalCode??null]:null,e.customerId??null,e.customerIpAddress??null,e.currencyCode??null,e.discountId??null])}async function Ce(e,t,n){let r=Object.entries(t);if(r.length===0)return{ok:!0,value:[]};let i=[...new Set(r.map(([,e])=>e))],a=await be(e,{...n?.query,items:i.map(e=>({priceId:e,quantity:1}))},n);if(!a.ok)return a;let o=[];for(let[e,t]of r){let r=a.value.lines.find(e=>e.priceId===t);if(r===void 0)continue;let i=xe(a.value,r,{wholeUnits:n?.wholeUnits});o.push({plan:e,priceId:t,headline:i.headline,note:i.note,estimated:i.estimated,currency:a.value.currencyCode})}return{ok:!0,value:o}}let we={code:`client/paddle_prices_not_configured`,message:`Prices aren't available right now.`,action:`Set data-paddle-env, data-paddle-token and every data-paddle-price-<name> id on the paddle-prices script tag.`},Y={sandbox:`test_`,production:`live_`},Te=/^pri_/,Ee=/^ctm_/;function X(e){try{return globalThis[e]??null}catch{return null}}function De(e,t){return e===`local`?t?.local===void 0?X(`localStorage`)??e:t.local:e===`session`?t?.session===void 0?X(`sessionStorage`)??e:t.session:e}function Oe(e){if(e===null)return null;let t=Number(e);return Number.isFinite(t)?t*1e3:NaN}function ke(e,n){if(e===null)return null;let r=e.getAttribute(`data-paddle-env`);if(r!==`sandbox`&&r!==`production`)return null;let i=e.getAttribute(`data-paddle-token`);if(i===null||!i.startsWith(Y[r]))return null;let a={};for(let t of e.getAttributeNames()){if(!t.startsWith(`data-paddle-price-`))continue;let n=e.getAttribute(t);if(n===null||!Te.test(n))return null;a[t.slice(18)]=n}if(Object.keys(a).length===0)return null;let o=e.getAttribute(`data-paddle-customer`)?.trim()??``,s=Ee.test(o)?{customerId:o}:{},c=t({key:e.getAttribute(`data-paddle-cache`),store:De(e.getAttribute(`data-paddle-cache-store`),n),ttlMs:Oe(e.getAttribute(`data-paddle-cache-ttl`))});return{setup:{clientToken:i,environment:r},plans:a,paint:e.getAttribute(`data-paddle-paint`)!==`off`,wholeUnits:e.getAttribute(`data-paddle-whole-units`)===`on`,query:s,cache:c}}let Z=`data-price-plan`,Q=`data-price-note`;function $(e,t){return e!==null&&e.toLowerCase()===t.toLowerCase()}function Ae(e,t){for(let n of Array.from(e.querySelectorAll(`[${Z}]`))){let e=t.find(e=>$(n.getAttribute(Z),e.plan));e!==void 0&&(n.textContent=e.headline)}for(let n of Array.from(e.querySelectorAll(`[${Q}]`))){let e=t.find(e=>$(n.getAttribute(Q),e.plan));e!==void 0&&e.note!==null&&(n.textContent=e.note)}}function je(e){return e.readyState===`loading`?new Promise(t=>{e.addEventListener(`DOMContentLoaded`,()=>t(),{once:!0})}):Promise.resolve()}async function Me(e,t,n){let{stores:r,...i}=n??{},a=ke(t,r);if(a===null)return{ok:!1,failure:we};let o=await Ce(a.setup,a.plans,{...i,query:{...a.query,...i.query},cache:i.cache??a.cache??void 0,wholeUnits:i.wholeUnits??a.wholeUnits});return!o.ok||!a.paint?o:(await je(e),Ae(e,o.value),o)}globalThis.pithyPaddlePrices={quotes:Me(document,document.currentScript)}})();
|
package/dist/pricing/location.js
CHANGED
package/dist/pricing/visitor.js
CHANGED
package/dist/projection/event.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PaymentsWebhookEvent, WEBHOOK_EVENT_ORPHANED, webhookEventAwaitsOwner } from "../data/webhookEvent.js";
|
|
2
4
|
import { PAYMENTS_WEBHOOK_EVENTS_TABLE, paymentsDatabase } from "../data/tables.js";
|
|
3
5
|
import { resolveNotificationOwner } from "./owner.js";
|
package/dist/projection/owner.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PaymentsSubject } from "../data/subject.js";
|
|
2
4
|
import { PaymentsProviderAccount } from "../data/providerAccount.js";
|
|
3
5
|
import { PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS_PURCHASES_TABLE, paymentsDatabase } from "../data/tables.js";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import type { D1Database, D1PreparedStatement } from "@cloudflare/workers-types";
|
|
2
4
|
import { type PaymentsConfig } from "../config/config";
|
|
3
5
|
import { PaymentsEntitlement } from "../data/entitlement";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { encodeSubjectReference, sameSubject } from "../data/subject.js";
|
|
2
4
|
import { entitlementsForProduct, productForProviderSku } from "../config/config.js";
|
|
3
5
|
import { PaymentsEntitlement } from "../data/entitlement.js";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { type WorkflowHostTemplate } from "@pithy-sh/core/src/workflow/host";
|
|
2
4
|
import type { ManagedEnvironment } from "@pithy-sh/secrets/src/scope";
|
|
3
5
|
import type { PaymentsConfig } from "../config/config";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PAYMENTS_CAPABILITY, paymentsWorkflowRegistry } from "../workflows/specs.js";
|
|
2
4
|
import { resourceNames } from "@pithy-sh/core/src/naming/resourceNames";
|
|
3
5
|
import { hostWorkflowsFor, resolveWorkflowHost } from "@pithy-sh/core/src/workflow/host";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
/**
|
|
2
4
|
* Every Apple root a chain may terminate in, base64 DER. The last certificate in a JWS `x5c` must be
|
|
3
5
|
* byte-identical to one of these — a stronger check than re-verifying a self-signature, which only proves
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
/**
|
|
2
4
|
* Every Apple root a chain may terminate in, base64 DER. The last certificate in a JWS `x5c` must be
|
|
3
5
|
* byte-identical to one of these — a stronger check than re-verifying a self-signature, which only proves
|
package/dist/rails/apple/der.js
CHANGED
package/dist/rails/apple/http.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PaymentsProviderUnavailableError, PaymentsRailNotConfiguredError } from "../../error/errors.js";
|
|
2
4
|
//#region src/rails/apple/http.ts
|
|
3
5
|
/** The default transport: the runtime's own `fetch`. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
/** Which roots to trust and what clock to judge certificate validity against. */
|
|
2
4
|
export interface VerifyAppleJwsOptions {
|
|
3
5
|
/** base64 DER of every acceptable root. Defaults to the pinned Apple roots. */
|
package/dist/rails/apple/jws.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { PaymentsInvalidReceiptError, PaymentsVerificationFailedError } from "../../error/errors.js";
|
|
2
4
|
import { APPLE_ROOT_CERTIFICATES } from "./certs.js";
|
|
3
5
|
import { decodeBase64, decodeBase64Url } from "./der.js";
|