@fantastic.dev/better-stripe 0.88.0 → 0.88.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.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAggregate/readMaterial.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/readMaterial.js +4 -3
- package/dist/client/billing/renewalAggregate/readMaterial.js.map +1 -1
- package/dist/client/billing/renewalPriceReplacement.d.ts.map +1 -1
- package/dist/client/billing/renewalPriceReplacement.js +7 -3
- package/dist/client/billing/renewalPriceReplacement.js.map +1 -1
- package/docs/renewal-context-reads.md +10 -0
- package/docs/renewal-phase-assembly.md +7 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAggregate/readMaterial.ts +5 -3
- package/src/client/billing/renewalPriceReplacement.ts +7 -3
- package/src/client/billing/renewalV2/rawRetention.test.ts +293 -0
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,12 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.88.1](https://github.com/FantasticDevHQ/better-stripe/compare/v0.88.0...v0.88.1) (2026-10-29)
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
- **renewal:** retain complete raw provider snapshots ([#414](https://github.com/FantasticDevHQ/better-stripe/issues/414)) ([f963edc](https://github.com/FantasticDevHQ/better-stripe/commit/f963edc18512adf733872fe574a4f487237861a5))
|
|
34
|
+
|
|
29
35
|
## [0.88.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.87.0...v0.88.0) (2026-10-29)
|
|
30
36
|
|
|
31
37
|
### Features
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ billing, and Connect marketplaces. It provides checkout, subscriptions, webhook
|
|
|
5
5
|
syncing, marketplace fees and splits, payouts, refunds, and disputes, with React
|
|
6
6
|
hooks and headless UI components.
|
|
7
7
|
|
|
8
|
-
**Version**: `0.88.
|
|
8
|
+
**Version**: `0.88.1` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
|
|
9
9
|
|
|
10
10
|
Connect platforms use the default GA API version. Non-Connect merchants using
|
|
11
11
|
customer-only Accounts v2 need preview access and an explicit preview version.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readMaterial.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/readMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAMrF,OAAO,EACL,SAAS,EASV,MAAM,aAAa,CAAC;AAKrB,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,+BAA+B,EAC/B,UAAU,GAAG,UAAU,GAAG,kBAAkB,CAC7C,CAAC;AAcF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,EAAE,UAAU,CAAC,EACjD,QAAQ,EAAE,0BAA0B,EACpC,UAAU,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"readMaterial.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/readMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAMrF,OAAO,EACL,SAAS,EASV,MAAM,aAAa,CAAC;AAKrB,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,+BAA+B,EAC/B,UAAU,GAAG,UAAU,GAAG,kBAAkB,CAC7C,CAAC;AAcF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,EAAE,UAAU,CAAC,EACjD,QAAQ,EAAE,0BAA0B,EACpC,UAAU,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkIpB;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -38,7 +38,8 @@ export function validateReadMaterial(args, prepared, scheduleId) {
|
|
|
38
38
|
conflict("schedule_association_mismatch");
|
|
39
39
|
}
|
|
40
40
|
const { schedule: originalSchedule, ...original } = prepared.providerSnapshot.subscription;
|
|
41
|
-
|
|
41
|
+
// Compare complete captured bodies, not parser outputs that may omit own keys.
|
|
42
|
+
const { schedule: freshSchedule, ...fresh } = args.freshSubscription;
|
|
42
43
|
if (scheduleId ? originalSchedule !== null : freshSchedule !== null)
|
|
43
44
|
conflict("schedule_association_mismatch");
|
|
44
45
|
if (!equal(original, fresh))
|
|
@@ -46,7 +47,7 @@ export function validateReadMaterial(args, prepared, scheduleId) {
|
|
|
46
47
|
const target = renewalPrice.safeParse(args.targetPrice);
|
|
47
48
|
if (!target.success || !target.data.active)
|
|
48
49
|
unsupported("unsupported_target_price");
|
|
49
|
-
if (!equal(
|
|
50
|
+
if (!equal(args.targetPrice, prepared.providerSnapshot.targetPrice))
|
|
50
51
|
conflict("target_price_drift");
|
|
51
52
|
if (prepared.providerSnapshot.billingCustomer === undefined ||
|
|
52
53
|
args.billingCustomer === undefined)
|
|
@@ -54,7 +55,7 @@ export function validateReadMaterial(args, prepared, scheduleId) {
|
|
|
54
55
|
const customer = renewalBillingCustomer.safeParse(args.billingCustomer);
|
|
55
56
|
if (!customer.success)
|
|
56
57
|
unsupported("unsupported_billing_customer");
|
|
57
|
-
if (!equal(
|
|
58
|
+
if (!equal(args.billingCustomer, prepared.providerSnapshot.billingCustomer))
|
|
58
59
|
conflict("billing_customer_drift");
|
|
59
60
|
const referenceContext = {
|
|
60
61
|
customerAccountId: prepared.expected.customerAccountId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readMaterial.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/readMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MA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AC;IACF,MAAM,aAAa,GAAG,sBAAsB,CAC1C,IAAI,CAAC,SAAS,EACd,MAAM,EACN,QAAQ,CAAC,QAAQ,EACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAChB,IAAI,CAAC,UAAU,CAChB,CAAC;IACF,OAAO;QACL,QAAQ;QACR,YAAY,EAAE,MAAM;QACpB,IAAI;QACJ,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,WAAW,EAAE,MAAM,CAAC,IAAI;QACxB,OAAO;QACP,SAAS;QACT,aAAa;QACb,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewalPriceReplacement.d.ts","sourceRoot":"","sources":["../../../src/client/billing/renewalPriceReplacement.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,+BAA+B,EACrC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,qCAAqC,GAAG;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qCAAqC;
|
|
1
|
+
{"version":3,"file":"renewalPriceReplacement.d.ts","sourceRoot":"","sources":["../../../src/client/billing/renewalPriceReplacement.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,+BAA+B,EACrC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,qCAAqC,GAAG;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qCAAqC;aAsFnC,CAAC;WACH,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAOT,UAAU;kBACJ,8BAA8B;;;;;EAM/C;AAED,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,8BAA8B,CACtC,CAAC"}
|
|
@@ -66,9 +66,13 @@ export function prepareRenewalPriceReplacement(options) {
|
|
|
66
66
|
if (subscription[field] != null)
|
|
67
67
|
throw new Error(`Renewal replacement does not support ${field}.`);
|
|
68
68
|
const providerSnapshot = renewalSnapshot({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
// Validation supplies semantic types; retain the complete detached bodies.
|
|
70
|
+
// Passthrough parsers can omit safe own JSON keys such as __proto__.
|
|
71
|
+
subscription: source.subscription,
|
|
72
|
+
targetPrice: source.targetPrice,
|
|
73
|
+
...(billingCustomer === undefined
|
|
74
|
+
? {}
|
|
75
|
+
: { billingCustomer: args.billingCustomer }),
|
|
72
76
|
});
|
|
73
77
|
const bound = {
|
|
74
78
|
version: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renewalPriceReplacement.js","sourceRoot":"","sources":["../../../src/client/billing/renewalPriceReplacement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAUlE;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAA8C;IAE9C,MAAM,IAAI,GAAG,uBAAuB,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CA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C,KAAK,GAAG,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,eAAe,CAAC;QACvC,2EAA2E;QAC3E,qEAAqE;QACrE,YAAY,EAAE,MAAM,CAAC,YAAmC;QACxD,WAAW,EAAE,MAAM,CAAC,WAAiC;QACrD,GAAG,CAAC,eAAe,KAAK,SAAS;YAC/B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,eAAyC,EAAE,CAAC;KACzE,CAAC,CAAC;IACH,MAAM,KAAK,GAAG;QACZ,OAAO,EAAE,CAAU;QACnB,KAAK,EAAE,UAAmB;QAC1B,QAAQ;QACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,gBAAgB;KACjB,CAAC;IACF,OAAO;QACL,GAAG,KAAK;QACR,MAAM,EAAE,UAAmB;QAC3B,YAAY,EAAE,8BAAuC;QACrD,eAAe,EAAE;YACf,GAAG;YACH,OAAO,EAAE,cAAc,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE;SAChE;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -31,6 +31,16 @@ and complete records under immutable authorization. An explicitly chosen attach
|
|
|
31
31
|
key may equal the logical key; no key is silently reused, derived or generated.
|
|
32
32
|
A future configure key must differ from the attachment key.
|
|
33
33
|
|
|
34
|
+
Preparation validates the original Subscription, target Price and optional
|
|
35
|
+
billing Customer, then retains their complete captured JSON bodies. Eligible
|
|
36
|
+
unknown fields, including own JSON keys such as `__proto__`, remain in the
|
|
37
|
+
snapshot and binding; validation does not replace the retained body with a
|
|
38
|
+
selected-field view. Unsupported fields in strict schemas still reject.
|
|
39
|
+
|
|
40
|
+
Older snapshots that already omitted a field cannot recover it or establish
|
|
41
|
+
retroactive full-record provenance. Reconstructing a changed full record does
|
|
42
|
+
not migrate its old binding or authorize a retry.
|
|
43
|
+
|
|
34
44
|
## Fixed acquisition profile
|
|
35
45
|
|
|
36
46
|
The initial profile supports platform requests using the configured
|
|
@@ -60,6 +60,13 @@ full-baseline and default-preservation checks apply. Actual subscription
|
|
|
60
60
|
association is required; the constructor does not replace it with null to pass
|
|
61
61
|
the original preparation checks.
|
|
62
62
|
|
|
63
|
+
Fresh Subscription, target Price and billing Customer comparisons use their
|
|
64
|
+
complete captured JSON bodies, including eligible unknown fields. Only the
|
|
65
|
+
Subscription's root Schedule association is handled separately by the existing
|
|
66
|
+
ownership checks. Parsed semantic views do not permit unknown-field drift or
|
|
67
|
+
replace the retained raw baseline. Unsupported strict-schema fields still
|
|
68
|
+
reject, and snapshot equality remains an unsigned data comparison.
|
|
69
|
+
|
|
63
70
|
Success is `projected_configure_request`, with version `2`, the complete
|
|
64
71
|
normalized two-phase payload and `providerQualification: "required"`. C4
|
|
65
72
|
(`renewal-baseline`) binds the entire original Schedule body. C5
|
package/package.json
CHANGED
|
@@ -68,14 +68,16 @@ export function validateReadMaterial(
|
|
|
68
68
|
}
|
|
69
69
|
const { schedule: originalSchedule, ...original } =
|
|
70
70
|
prepared.providerSnapshot.subscription;
|
|
71
|
-
|
|
71
|
+
// Compare complete captured bodies, not parser outputs that may omit own keys.
|
|
72
|
+
const { schedule: freshSchedule, ...fresh } =
|
|
73
|
+
args.freshSubscription as typeof source;
|
|
72
74
|
if (scheduleId ? originalSchedule !== null : freshSchedule !== null)
|
|
73
75
|
conflict("schedule_association_mismatch");
|
|
74
76
|
if (!equal(original, fresh)) conflict("original_source_drift");
|
|
75
77
|
const target = renewalPrice.safeParse(args.targetPrice);
|
|
76
78
|
if (!target.success || !target.data.active)
|
|
77
79
|
unsupported("unsupported_target_price");
|
|
78
|
-
if (!equal(
|
|
80
|
+
if (!equal(args.targetPrice, prepared.providerSnapshot.targetPrice))
|
|
79
81
|
conflict("target_price_drift");
|
|
80
82
|
if (
|
|
81
83
|
prepared.providerSnapshot.billingCustomer === undefined ||
|
|
@@ -84,7 +86,7 @@ export function validateReadMaterial(
|
|
|
84
86
|
unsupported("missing_retained_billing_customer");
|
|
85
87
|
const customer = renewalBillingCustomer.safeParse(args.billingCustomer);
|
|
86
88
|
if (!customer.success) unsupported("unsupported_billing_customer");
|
|
87
|
-
if (!equal(
|
|
89
|
+
if (!equal(args.billingCustomer, prepared.providerSnapshot.billingCustomer))
|
|
88
90
|
conflict("billing_customer_drift");
|
|
89
91
|
const referenceContext = {
|
|
90
92
|
customerAccountId: prepared.expected.customerAccountId,
|
|
@@ -100,9 +100,13 @@ export function prepareRenewalPriceReplacement(
|
|
|
100
100
|
if (subscription[field] != null)
|
|
101
101
|
throw new Error(`Renewal replacement does not support ${field}.`);
|
|
102
102
|
const providerSnapshot = renewalSnapshot({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
// Validation supplies semantic types; retain the complete detached bodies.
|
|
104
|
+
// Passthrough parsers can omit safe own JSON keys such as __proto__.
|
|
105
|
+
subscription: source.subscription as typeof subscription,
|
|
106
|
+
targetPrice: source.targetPrice as typeof targetPrice,
|
|
107
|
+
...(billingCustomer === undefined
|
|
108
|
+
? {}
|
|
109
|
+
: { billingCustomer: args.billingCustomer as typeof billingCustomer }),
|
|
106
110
|
});
|
|
107
111
|
const bound = {
|
|
108
112
|
version: 1 as const,
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
2
|
+
import { webcrypto } from "node:crypto";
|
|
3
|
+
import * as sdk from "./index.js";
|
|
4
|
+
import { prepareRenewalPriceReplacement as legacy } from "../renewalPriceReplacement.js";
|
|
5
|
+
import { validateReadMaterial } from "../renewalAggregate/readMaterial.js";
|
|
6
|
+
import { fixture } from "../../../../tests/renewalAggregate/fixtures.js";
|
|
7
|
+
import {
|
|
8
|
+
at,
|
|
9
|
+
binding,
|
|
10
|
+
bound,
|
|
11
|
+
configuration,
|
|
12
|
+
expandedInput,
|
|
13
|
+
hash,
|
|
14
|
+
input,
|
|
15
|
+
own,
|
|
16
|
+
owns,
|
|
17
|
+
paths,
|
|
18
|
+
} from "../../../../tests/renewalAggregate/rawRetention.js";
|
|
19
|
+
|
|
20
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
21
|
+
it("records unaffected normal full-output vectors and independent C1 oracle", async () => {
|
|
22
|
+
const raw = input(),
|
|
23
|
+
old = legacy(raw),
|
|
24
|
+
p = await sdk.prepareRenewalPriceReplacementV2(raw);
|
|
25
|
+
expect(p.requestIdentity.binding).toBe(
|
|
26
|
+
binding("renewal", { ...bound(old), version: 2 }),
|
|
27
|
+
);
|
|
28
|
+
const c = configuration(),
|
|
29
|
+
receipt = await sdk.constructRenewalScheduleAttachmentReceiptV2(
|
|
30
|
+
c.attachReceipt,
|
|
31
|
+
),
|
|
32
|
+
projected = await sdk.projectRenewalConfigurationV2(c);
|
|
33
|
+
expect(projected.status).toBe("projected_configure_request");
|
|
34
|
+
expect({
|
|
35
|
+
legacy: hash(old),
|
|
36
|
+
prepared: hash(p),
|
|
37
|
+
receipt: hash(receipt),
|
|
38
|
+
configuration: hash(projected),
|
|
39
|
+
}).toEqual({
|
|
40
|
+
legacy: "ed0e7fe3641e216caf66fd225b1a7366a4a3ab7f2825448ec9fbbf697621e150",
|
|
41
|
+
prepared:
|
|
42
|
+
"4c27c7f4c0f4743d6a5ff3c76da42c024c4f2e29f6bc65b4ad29bb21dfdbc8d3",
|
|
43
|
+
receipt: "dd79636e1248efc8efad99737bcd156d322f3078aea7ecebf007f0d1d953b01c",
|
|
44
|
+
configuration:
|
|
45
|
+
"ef08ad09044c32eaa3152b3a7fe058a68f77edf704c3176ada86cd5c5c6179d8",
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it.each(paths.map((path) => ({ path })))(
|
|
49
|
+
"retains and binds safe own proto at passthrough body $path",
|
|
50
|
+
async ({ path }) => {
|
|
51
|
+
const raw = expandedInput(),
|
|
52
|
+
body = at(raw, path as (string | number)[]);
|
|
53
|
+
own(body, "__proto__", { safe: "retained" });
|
|
54
|
+
const expected = {
|
|
55
|
+
subscription: raw.subscription,
|
|
56
|
+
targetPrice: raw.targetPrice,
|
|
57
|
+
billingCustomer: raw.billingCustomer,
|
|
58
|
+
};
|
|
59
|
+
const old = legacy(raw),
|
|
60
|
+
p = await sdk.prepareRenewalPriceReplacementV2(raw);
|
|
61
|
+
expect(old.providerSnapshot).toEqual(expected);
|
|
62
|
+
expect(p.providerSnapshot).toEqual(expected);
|
|
63
|
+
expect(
|
|
64
|
+
owns(at(p.providerSnapshot, path as (string | number)[]), "__proto__"),
|
|
65
|
+
).toBe(true);
|
|
66
|
+
expect(p.requestIdentity.binding).toBe(
|
|
67
|
+
binding("renewal", {
|
|
68
|
+
version: 2,
|
|
69
|
+
scope: "platform",
|
|
70
|
+
expected: raw.expected,
|
|
71
|
+
quantity: raw.subscription.items.data[0].quantity,
|
|
72
|
+
providerSnapshot: expected,
|
|
73
|
+
}),
|
|
74
|
+
);
|
|
75
|
+
own(body, "__proto__", { safe: "changed" });
|
|
76
|
+
expect(
|
|
77
|
+
(await sdk.prepareRenewalPriceReplacementV2(raw)).requestIdentity.binding,
|
|
78
|
+
).not.toBe(p.requestIdentity.binding);
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
it.each(["subscription", "targetPrice", "billingCustomer"])(
|
|
82
|
+
"same raw %s special key passes internal read eligibility",
|
|
83
|
+
(field) => {
|
|
84
|
+
const raw: any = input();
|
|
85
|
+
own(raw[field], "__proto__", { safe: "same" });
|
|
86
|
+
const f = fixture();
|
|
87
|
+
const prepared: any = {
|
|
88
|
+
expected: raw.expected,
|
|
89
|
+
quantity: raw.subscription.items.data[0].quantity,
|
|
90
|
+
providerSnapshot: {
|
|
91
|
+
subscription: raw.subscription,
|
|
92
|
+
targetPrice: raw.targetPrice,
|
|
93
|
+
billingCustomer: raw.billingCustomer,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
const args = {
|
|
97
|
+
freshSubscription: structuredClone(raw.subscription),
|
|
98
|
+
targetPrice: structuredClone(raw.targetPrice),
|
|
99
|
+
billingCustomer: structuredClone(raw.billingCustomer),
|
|
100
|
+
apiVersion: f.preflightInput.apiVersion,
|
|
101
|
+
observedAt: f.preflightInput.observedAt,
|
|
102
|
+
};
|
|
103
|
+
expect(() => validateReadMaterial(args, prepared)).not.toThrow();
|
|
104
|
+
own(
|
|
105
|
+
(args as any)[field === "subscription" ? "freshSubscription" : field],
|
|
106
|
+
"__proto__",
|
|
107
|
+
{ safe: "drift" },
|
|
108
|
+
);
|
|
109
|
+
expect(() => validateReadMaterial(args, prepared)).toThrow();
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
it.each(["subscription", "targetPrice", "billingCustomer"])(
|
|
113
|
+
"C1 C3 C6 uses identical full raw %s and rejects fresh drift",
|
|
114
|
+
async (field) => {
|
|
115
|
+
const raw: any = input();
|
|
116
|
+
own(raw[field], "__proto__", { safe: "same" });
|
|
117
|
+
const c = configuration(raw);
|
|
118
|
+
expect((await sdk.projectRenewalConfigurationV2(c)).status).toBe(
|
|
119
|
+
"projected_configure_request",
|
|
120
|
+
);
|
|
121
|
+
own(
|
|
122
|
+
c[field === "subscription" ? "freshSubscription" : field],
|
|
123
|
+
"__proto__",
|
|
124
|
+
{ safe: "drift" },
|
|
125
|
+
);
|
|
126
|
+
expect((await sdk.projectRenewalConfigurationV2(c)).status).toBe(
|
|
127
|
+
"conflict",
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
it.each(["constructor", "prototype"])(
|
|
132
|
+
"retains safe own %s without prototype pollution",
|
|
133
|
+
async (key) => {
|
|
134
|
+
const raw: any = input();
|
|
135
|
+
for (const body of [raw.subscription, raw.targetPrice, raw.billingCustomer])
|
|
136
|
+
own(body, key, { prototype: { BTS313_POLLUTED: true } });
|
|
137
|
+
const p = await sdk.prepareRenewalPriceReplacementV2(raw);
|
|
138
|
+
expect(p.providerSnapshot.subscription[key]).toEqual(raw.subscription[key]);
|
|
139
|
+
expect(Object.getPrototypeOf(p.providerSnapshot.subscription)).toBe(
|
|
140
|
+
Object.prototype,
|
|
141
|
+
);
|
|
142
|
+
expect((Object.prototype as any).BTS313_POLLUTED).toBeUndefined();
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
it("keeps opaque unknown nested raw JSON and strict eligibility distinct", async () => {
|
|
146
|
+
const raw: any = input();
|
|
147
|
+
own(raw.subscription.metadata, "__proto__", { opaque: true });
|
|
148
|
+
raw.subscription.items.data[0].plan = { opaque: true };
|
|
149
|
+
own(raw.subscription.items.data[0].plan, "__proto__", { nested: true });
|
|
150
|
+
const p = await sdk.prepareRenewalPriceReplacementV2(raw);
|
|
151
|
+
expect(p.providerSnapshot.subscription.metadata).toEqual(
|
|
152
|
+
raw.subscription.metadata,
|
|
153
|
+
);
|
|
154
|
+
expect((p.providerSnapshot.subscription.items.data[0] as any).plan).toEqual(
|
|
155
|
+
raw.subscription.items.data[0].plan,
|
|
156
|
+
);
|
|
157
|
+
for (const key of ["__proto__", "constructor", "prototype"]) {
|
|
158
|
+
const invalid: any = input();
|
|
159
|
+
own(invalid.subscription.payment_settings, key, { extra: true });
|
|
160
|
+
await expect(
|
|
161
|
+
sdk.prepareRenewalPriceReplacementV2(invalid),
|
|
162
|
+
).rejects.toThrow();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
it("preserves Customer absence and rejects invalid present Customer", async () => {
|
|
166
|
+
const raw: any = input();
|
|
167
|
+
delete raw.billingCustomer;
|
|
168
|
+
expect(
|
|
169
|
+
owns(
|
|
170
|
+
(await sdk.prepareRenewalPriceReplacementV2(raw)).providerSnapshot,
|
|
171
|
+
"billingCustomer",
|
|
172
|
+
),
|
|
173
|
+
).toBe(false);
|
|
174
|
+
raw.billingCustomer = null;
|
|
175
|
+
await expect(sdk.prepareRenewalPriceReplacementV2(raw)).rejects.toThrow();
|
|
176
|
+
});
|
|
177
|
+
it("keeps C3 C4 complete Schedule bodies and C5 raw default preimage", async () => {
|
|
178
|
+
const c = configuration();
|
|
179
|
+
own(c.attachReceipt.providerSnapshot, "__proto__", { schedule: true });
|
|
180
|
+
own(c.schedule, "__proto__", { schedule: true });
|
|
181
|
+
const r = await sdk.constructRenewalScheduleAttachmentReceiptV2(
|
|
182
|
+
c.attachReceipt,
|
|
183
|
+
);
|
|
184
|
+
expect(owns(r.providerSnapshot, "__proto__")).toBe(true);
|
|
185
|
+
expect(r.providerSnapshot).toEqual(c.attachReceipt.providerSnapshot);
|
|
186
|
+
const projected = await sdk.projectRenewalConfigurationV2(c);
|
|
187
|
+
expect(projected.status).toBe("projected_configure_request");
|
|
188
|
+
if (projected.status !== "projected_configure_request")
|
|
189
|
+
throw Error("fixture");
|
|
190
|
+
expect(projected.baselineBinding).toBe(
|
|
191
|
+
binding("renewal-baseline", c.attachReceipt.providerSnapshot),
|
|
192
|
+
);
|
|
193
|
+
expect(projected.defaultSettingsBinding).toBe(
|
|
194
|
+
binding("renewal-defaults", c.schedule.default_settings),
|
|
195
|
+
);
|
|
196
|
+
own(c.schedule.default_settings, "__proto__", { unsupported: true });
|
|
197
|
+
c.attachReceipt.providerSnapshot = structuredClone(c.schedule);
|
|
198
|
+
expect((await sdk.projectRenewalConfigurationV2(c)).status).toBe(
|
|
199
|
+
"attached_unconfigured",
|
|
200
|
+
);
|
|
201
|
+
});
|
|
202
|
+
it("captures retained raw keys before WebCrypto await and leaves no live alias", async () => {
|
|
203
|
+
const raw: any = input();
|
|
204
|
+
own(raw.subscription, "__proto__", { value: "before" });
|
|
205
|
+
let release!: () => void, entered!: () => void;
|
|
206
|
+
const hold = new Promise<void>((r) => (release = r)),
|
|
207
|
+
started = new Promise<void>((r) => (entered = r));
|
|
208
|
+
vi.stubGlobal("crypto", {
|
|
209
|
+
subtle: {
|
|
210
|
+
digest: async (n: any, b: any) => {
|
|
211
|
+
entered();
|
|
212
|
+
await hold;
|
|
213
|
+
return webcrypto.subtle.digest(n, b);
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
const pending = sdk.prepareRenewalPriceReplacementV2(raw);
|
|
218
|
+
await Promise.race([started, pending]);
|
|
219
|
+
raw.subscription.__proto__.value = "after";
|
|
220
|
+
release();
|
|
221
|
+
const p = await pending;
|
|
222
|
+
expect((p.providerSnapshot.subscription as any).__proto__).toEqual({
|
|
223
|
+
value: "before",
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
it("does not turn custom prototypes/accessors or overbudget raw data into retained JSON", async () => {
|
|
227
|
+
for (const kind of ["prototype", "accessor", "budget"]) {
|
|
228
|
+
const raw: any = input();
|
|
229
|
+
if (kind === "prototype")
|
|
230
|
+
Object.setPrototypeOf(raw.subscription, { foreign: true });
|
|
231
|
+
else if (kind === "accessor")
|
|
232
|
+
Object.defineProperty(raw.subscription, "bad", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get() {
|
|
235
|
+
throw Error("must not invoke getter");
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
else own(raw.subscription, "__proto__", { pad: "x".repeat(500001) });
|
|
239
|
+
await expect(sdk.prepareRenewalPriceReplacementV2(raw)).rejects.toThrow();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
it("retained restored fields keep UTF8 hash caps and cannot adopt a stale binding", async () => {
|
|
243
|
+
const raw: any = input();
|
|
244
|
+
own(raw.subscription, "__proto__", { pad: "雪".repeat(170000) });
|
|
245
|
+
expect(legacy(raw).providerSnapshot.subscription).toEqual(raw.subscription);
|
|
246
|
+
const spy = vi.fn();
|
|
247
|
+
vi.stubGlobal("crypto", { subtle: { digest: spy } });
|
|
248
|
+
await expect(sdk.prepareRenewalPriceReplacementV2(raw)).rejects.toThrow();
|
|
249
|
+
expect(spy).not.toHaveBeenCalled();
|
|
250
|
+
vi.unstubAllGlobals();
|
|
251
|
+
const p: any = await sdk.prepareRenewalPriceReplacementV2(input());
|
|
252
|
+
own(p.providerSnapshot.subscription, "__proto__", { newRaw: true });
|
|
253
|
+
await expect(
|
|
254
|
+
sdk.prepareRenewalScheduleAttachmentV2({
|
|
255
|
+
prepared: p,
|
|
256
|
+
apiVersion: "2026-09-30.endive",
|
|
257
|
+
attachKey: "explicit:attach",
|
|
258
|
+
firstDispatchedAt: 1768867200,
|
|
259
|
+
}),
|
|
260
|
+
).rejects.toThrow();
|
|
261
|
+
});
|
|
262
|
+
it("C5 retains eligible opaque special keys inside validated expanded defaults", async () => {
|
|
263
|
+
const p: any = input();
|
|
264
|
+
p.subscription.default_payment_method = {
|
|
265
|
+
id: "pm_retained",
|
|
266
|
+
object: "payment_method",
|
|
267
|
+
customer: "cus_buyer",
|
|
268
|
+
customer_account: "acct_buyer",
|
|
269
|
+
livemode: false,
|
|
270
|
+
};
|
|
271
|
+
const c = configuration(p);
|
|
272
|
+
c.schedule.default_settings.default_payment_method = structuredClone(
|
|
273
|
+
p.subscription.default_payment_method,
|
|
274
|
+
);
|
|
275
|
+
own(c.schedule.default_settings.default_payment_method, "__proto__", {
|
|
276
|
+
safe: "one",
|
|
277
|
+
});
|
|
278
|
+
c.attachReceipt.providerSnapshot = structuredClone(c.schedule);
|
|
279
|
+
const first = await sdk.projectRenewalConfigurationV2(c);
|
|
280
|
+
expect(first.status).toBe("projected_configure_request");
|
|
281
|
+
if (first.status !== "projected_configure_request") throw Error("fixture");
|
|
282
|
+
expect(first.defaultSettingsBinding).toBe(
|
|
283
|
+
binding("renewal-defaults", c.schedule.default_settings),
|
|
284
|
+
);
|
|
285
|
+
own(c.schedule.default_settings.default_payment_method, "__proto__", {
|
|
286
|
+
safe: "two",
|
|
287
|
+
});
|
|
288
|
+
c.attachReceipt.providerSnapshot = structuredClone(c.schedule);
|
|
289
|
+
const second = await sdk.projectRenewalConfigurationV2(c);
|
|
290
|
+
expect(second.status).toBe("projected_configure_request");
|
|
291
|
+
if (second.status !== "projected_configure_request") throw Error("fixture");
|
|
292
|
+
expect(second.defaultSettingsBinding).not.toBe(first.defaultSettingsBinding);
|
|
293
|
+
});
|