@fantastic.dev/better-stripe 0.90.0 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts +41 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +187 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts +2 -23
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js +1 -112
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts +8 -3
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js +454 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js +99 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js +274 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js +362 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js +215 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +79 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +26 -8
- package/docs/renewal-material-observation.md +37 -0
- package/docs/renewal-phase-assembly.md +68 -0
- package/docs/renewal-raw-acquisition.md +19 -5
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
- package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
- package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
- package/src/client/billing/renewalAttach/internal/configure/actor.ts +575 -0
- package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
- package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
- package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
- package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
- package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
- package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
- package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
- package/src/client/billing/renewalAttach/internal/observation/actor.ts +444 -0
- package/src/client/billing/renewalAttach/internal/observation/capture.ts +250 -0
- package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
- package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
- package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
- package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
- package/src/client/billing/renewalAttach/internal/observation/types.ts +102 -0
- package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
- package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
- package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
- package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
- package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
- package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
- package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
- package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
- package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
- package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
- package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
- package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
- package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
- package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
- package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
- package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
- package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
- package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
- package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +533 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +314 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +463 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +600 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import type { constructRenewalScheduleAttachmentReceiptV2 } from "../../../renewalV2/index.js";
|
|
3
|
+
import { closed } from "../operations/types.js";
|
|
4
|
+
import { equal } from "../../../renewalAggregate/shared.js";
|
|
5
|
+
import type { AttachRaw } from "../material/capture.js";
|
|
6
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
7
|
+
import {
|
|
8
|
+
objectNode,
|
|
9
|
+
scalarNode,
|
|
10
|
+
encode,
|
|
11
|
+
materialize,
|
|
12
|
+
need,
|
|
13
|
+
freeze,
|
|
14
|
+
type Node,
|
|
15
|
+
} from "../material/nodeKernel.js";
|
|
16
|
+
import type {
|
|
17
|
+
prepareRenewalPriceReplacementV2,
|
|
18
|
+
prepareRenewalScheduleAttachmentV2,
|
|
19
|
+
} from "../../../renewalV2/index.js";
|
|
20
|
+
type Receipt = Awaited<
|
|
21
|
+
ReturnType<typeof constructRenewalScheduleAttachmentReceiptV2>
|
|
22
|
+
>;
|
|
23
|
+
type Prepared = Awaited<ReturnType<typeof prepareRenewalPriceReplacementV2>>;
|
|
24
|
+
type Request = Awaited<ReturnType<typeof prepareRenewalScheduleAttachmentV2>>;
|
|
25
|
+
const PREFIX = "/material/";
|
|
26
|
+
/** Bounded DATA admission only; the caller retains its own record and Source relation. */
|
|
27
|
+
export function admitReplayMaterial<T>(
|
|
28
|
+
material: T,
|
|
29
|
+
prepared: Prepared,
|
|
30
|
+
request: Request,
|
|
31
|
+
): {
|
|
32
|
+
status: "classified";
|
|
33
|
+
kind: "RENEWAL_MATERIAL_V2_DATA_CONSISTENCY_ONLY";
|
|
34
|
+
material: T;
|
|
35
|
+
} {
|
|
36
|
+
const slots = new Map([
|
|
37
|
+
[
|
|
38
|
+
PREFIX + "originalPrepared/requestIdentity/binding",
|
|
39
|
+
prepared.requestIdentity.binding,
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
PREFIX + "completeRequest/logicalBinding",
|
|
43
|
+
prepared.requestIdentity.binding,
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
PREFIX + "completeRequest/requestIdentity/binding",
|
|
47
|
+
request.requestIdentity.binding,
|
|
48
|
+
],
|
|
49
|
+
]);
|
|
50
|
+
need(slots.size === 3);
|
|
51
|
+
let nodes = 0,
|
|
52
|
+
raw = 0;
|
|
53
|
+
const seen = new Set<object>(),
|
|
54
|
+
found = new Set<string>();
|
|
55
|
+
function walk(x: unknown, path: string, depth: number): Node {
|
|
56
|
+
need(++nodes <= 10000 && depth <= 40);
|
|
57
|
+
if (slots.has(path)) {
|
|
58
|
+
need(
|
|
59
|
+
typeof x === "string" &&
|
|
60
|
+
x === slots.get(path) &&
|
|
61
|
+
/^(?:renewal|renewal-attach|renewal-attach-receipt|renewal-baseline|renewal-defaults|renewal-configure):v2:sha256:[0-9a-f]{64}$/.test(
|
|
62
|
+
x,
|
|
63
|
+
),
|
|
64
|
+
);
|
|
65
|
+
found.add(path);
|
|
66
|
+
raw += x.length;
|
|
67
|
+
need(raw <= 500000);
|
|
68
|
+
return scalarNode(x);
|
|
69
|
+
}
|
|
70
|
+
if (x === null || typeof x !== "object") {
|
|
71
|
+
requiredJSONSnapshot(x);
|
|
72
|
+
if (typeof x === "string") raw += x.length;
|
|
73
|
+
need(raw <= 500000);
|
|
74
|
+
return scalarNode(x);
|
|
75
|
+
}
|
|
76
|
+
need(!seen.has(x));
|
|
77
|
+
seen.add(x);
|
|
78
|
+
const array = Array.isArray(x),
|
|
79
|
+
keys = Reflect.ownKeys(x),
|
|
80
|
+
entries: [string, Node][] = [];
|
|
81
|
+
const proto = Object.getPrototypeOf(x);
|
|
82
|
+
need(
|
|
83
|
+
array
|
|
84
|
+
? proto === Array.prototype
|
|
85
|
+
: proto === Object.prototype || proto === null,
|
|
86
|
+
);
|
|
87
|
+
const length = array ? Object.getOwnPropertyDescriptor(x, "length") : null;
|
|
88
|
+
if (array)
|
|
89
|
+
need(
|
|
90
|
+
length &&
|
|
91
|
+
"value" in length &&
|
|
92
|
+
Number.isSafeInteger(length.value) &&
|
|
93
|
+
length.value <= 10000,
|
|
94
|
+
);
|
|
95
|
+
for (const key of keys) {
|
|
96
|
+
need(typeof key === "string");
|
|
97
|
+
if (array && key === "length") continue;
|
|
98
|
+
const d = Object.getOwnPropertyDescriptor(x, key);
|
|
99
|
+
need(d && d.enumerable && "value" in d);
|
|
100
|
+
requiredJSONSnapshot(key);
|
|
101
|
+
requiredJSONSnapshot({ [key]: d.value === null ? null : true });
|
|
102
|
+
raw += key.length;
|
|
103
|
+
need(raw <= 500000);
|
|
104
|
+
need(
|
|
105
|
+
!array ||
|
|
106
|
+
(/^(0|[1-9][0-9]*)$/.test(key) && Number(key) < length!.value),
|
|
107
|
+
);
|
|
108
|
+
entries.push([key, walk(d.value, path + "/" + key, depth + 1)]);
|
|
109
|
+
}
|
|
110
|
+
seen.delete(x);
|
|
111
|
+
if (array) {
|
|
112
|
+
need(entries.length === length!.value);
|
|
113
|
+
entries.sort(([a], [b]) => Number(a) - Number(b));
|
|
114
|
+
return Object.freeze({
|
|
115
|
+
kind: "array" as const,
|
|
116
|
+
entries: Object.freeze(
|
|
117
|
+
entries.map(
|
|
118
|
+
Object.freeze as (
|
|
119
|
+
entry: [string, Node],
|
|
120
|
+
) => Readonly<[string, Node]>,
|
|
121
|
+
),
|
|
122
|
+
),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return objectNode(entries);
|
|
126
|
+
}
|
|
127
|
+
const node = walk(
|
|
128
|
+
{
|
|
129
|
+
status: "classified",
|
|
130
|
+
kind: "RENEWAL_MATERIAL_V2_DATA_CONSISTENCY_ONLY",
|
|
131
|
+
material,
|
|
132
|
+
},
|
|
133
|
+
"",
|
|
134
|
+
0,
|
|
135
|
+
);
|
|
136
|
+
need(found.size === slots.size);
|
|
137
|
+
encode(node);
|
|
138
|
+
return freeze(materialize(node)) as {
|
|
139
|
+
status: "classified";
|
|
140
|
+
kind: "RENEWAL_MATERIAL_V2_DATA_CONSISTENCY_ONLY";
|
|
141
|
+
material: T;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Full replay DATA equality; no Source, Owner, class or record context is accepted. */
|
|
146
|
+
export function assertReplayMaterial(
|
|
147
|
+
value: unknown,
|
|
148
|
+
prepared: Prepared,
|
|
149
|
+
request: Request,
|
|
150
|
+
raw: AttachRaw,
|
|
151
|
+
current: Readonly<{
|
|
152
|
+
wireSubscription: Record<string, unknown>;
|
|
153
|
+
wireTargetPrice: Record<string, unknown>;
|
|
154
|
+
wireBillingCustomer: Record<string, unknown>;
|
|
155
|
+
}>,
|
|
156
|
+
originalSubscription: unknown,
|
|
157
|
+
observedAt: number,
|
|
158
|
+
): void {
|
|
159
|
+
const material = closed(value, [
|
|
160
|
+
"classificationRevision",
|
|
161
|
+
"protocolRevision",
|
|
162
|
+
"stage",
|
|
163
|
+
"intent",
|
|
164
|
+
"scope",
|
|
165
|
+
"apiVersion",
|
|
166
|
+
"profile",
|
|
167
|
+
"quantity",
|
|
168
|
+
"currentPrice",
|
|
169
|
+
"targetPrice",
|
|
170
|
+
"source",
|
|
171
|
+
"nativeItem",
|
|
172
|
+
"billingCustomer",
|
|
173
|
+
"subscriptionDiscounts",
|
|
174
|
+
"itemDiscounts",
|
|
175
|
+
"settings",
|
|
176
|
+
"originalPrepared",
|
|
177
|
+
"completeRequest",
|
|
178
|
+
"stageEvidence",
|
|
179
|
+
"rawSources",
|
|
180
|
+
"freshness",
|
|
181
|
+
]);
|
|
182
|
+
need(
|
|
183
|
+
material.classificationRevision === "renewal-material-v2" &&
|
|
184
|
+
material.protocolRevision === "renewal-stage-protocol-v1" &&
|
|
185
|
+
material.stage === "attach" &&
|
|
186
|
+
material.intent === "replay_unknown" &&
|
|
187
|
+
material.freshness === "fresh" &&
|
|
188
|
+
material.scope === request.scope &&
|
|
189
|
+
material.apiVersion === request.apiVersion,
|
|
190
|
+
);
|
|
191
|
+
need(
|
|
192
|
+
equal(material.originalPrepared, prepared) &&
|
|
193
|
+
equal(material.completeRequest, request),
|
|
194
|
+
);
|
|
195
|
+
need(
|
|
196
|
+
equal(material.rawSources, {
|
|
197
|
+
attachRequest: raw,
|
|
198
|
+
intent: "replay_unknown",
|
|
199
|
+
freshSubscription: current.wireSubscription,
|
|
200
|
+
targetPrice: current.wireTargetPrice,
|
|
201
|
+
billingCustomer: current.wireBillingCustomer,
|
|
202
|
+
observedAt: observedAt,
|
|
203
|
+
}),
|
|
204
|
+
);
|
|
205
|
+
need(
|
|
206
|
+
equal(material.stageEvidence, {
|
|
207
|
+
actualFreshSubscription: current.wireSubscription,
|
|
208
|
+
historicalOriginalSubscription: originalSubscription,
|
|
209
|
+
}),
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Full initial ACK wrapper DATA admission before final Owner and quarantine discard. */
|
|
214
|
+
export function admitInitialOutput(
|
|
215
|
+
receipt: Receipt,
|
|
216
|
+
prepared: Prepared,
|
|
217
|
+
request: Request,
|
|
218
|
+
) {
|
|
219
|
+
const output = {
|
|
220
|
+
status: "attach_acknowledged",
|
|
221
|
+
operationalAuthority: false,
|
|
222
|
+
receipt,
|
|
223
|
+
};
|
|
224
|
+
const slots = new Map([
|
|
225
|
+
["/receipt/logicalBinding", prepared.requestIdentity.binding],
|
|
226
|
+
["/receipt/request/logicalBinding", prepared.requestIdentity.binding],
|
|
227
|
+
[
|
|
228
|
+
"/receipt/request/requestIdentity/binding",
|
|
229
|
+
request.requestIdentity.binding,
|
|
230
|
+
],
|
|
231
|
+
["/receipt/binding", receipt.binding],
|
|
232
|
+
]),
|
|
233
|
+
found = new Set<string>(),
|
|
234
|
+
active = new Set<object>();
|
|
235
|
+
let nodes = 0,
|
|
236
|
+
rawCharacters = 0;
|
|
237
|
+
function walk(value: unknown, path: string, depth: number): Node {
|
|
238
|
+
need(++nodes <= 10000 && depth <= 40 && !types.isProxy(value));
|
|
239
|
+
if (slots.has(path)) {
|
|
240
|
+
const expected = slots.get(path),
|
|
241
|
+
family =
|
|
242
|
+
path === "/receipt/binding"
|
|
243
|
+
? "renewal-attach-receipt"
|
|
244
|
+
: path === "/receipt/request/requestIdentity/binding"
|
|
245
|
+
? "renewal-attach"
|
|
246
|
+
: "renewal";
|
|
247
|
+
need(
|
|
248
|
+
value === expected &&
|
|
249
|
+
typeof value === "string" &&
|
|
250
|
+
new RegExp("^" + family + ":v2:sha256:[0-9a-f]{64}$").test(value),
|
|
251
|
+
);
|
|
252
|
+
rawCharacters += value.length;
|
|
253
|
+
need(rawCharacters <= 500000);
|
|
254
|
+
found.add(path);
|
|
255
|
+
return scalarNode(value);
|
|
256
|
+
}
|
|
257
|
+
if (value === null || typeof value !== "object") {
|
|
258
|
+
requiredJSONSnapshot(value);
|
|
259
|
+
if (typeof value === "string") rawCharacters += value.length;
|
|
260
|
+
need(rawCharacters <= 500000);
|
|
261
|
+
return scalarNode(value);
|
|
262
|
+
}
|
|
263
|
+
need(!active.has(value));
|
|
264
|
+
active.add(value);
|
|
265
|
+
const array = Array.isArray(value),
|
|
266
|
+
proto = Object.getPrototypeOf(value);
|
|
267
|
+
need(
|
|
268
|
+
array
|
|
269
|
+
? proto === Array.prototype
|
|
270
|
+
: proto === Object.prototype || proto === null,
|
|
271
|
+
);
|
|
272
|
+
const keys = Reflect.ownKeys(value),
|
|
273
|
+
entries: [string, Node][] = [],
|
|
274
|
+
length = array ? Object.getOwnPropertyDescriptor(value, "length") : null;
|
|
275
|
+
if (array)
|
|
276
|
+
need(
|
|
277
|
+
length &&
|
|
278
|
+
"value" in length &&
|
|
279
|
+
Number.isSafeInteger(length.value) &&
|
|
280
|
+
length.value >= 0 &&
|
|
281
|
+
length.value <= 10000,
|
|
282
|
+
);
|
|
283
|
+
for (const key of keys) {
|
|
284
|
+
need(typeof key === "string");
|
|
285
|
+
if (array && key === "length") continue;
|
|
286
|
+
const d = Object.getOwnPropertyDescriptor(value, key);
|
|
287
|
+
need(d && d.enumerable && "value" in d);
|
|
288
|
+
requiredJSONSnapshot(key);
|
|
289
|
+
requiredJSONSnapshot({ [key]: d.value === null ? null : true });
|
|
290
|
+
rawCharacters += key.length;
|
|
291
|
+
need(rawCharacters <= 500000);
|
|
292
|
+
if (array)
|
|
293
|
+
need(/^(0|[1-9][0-9]*)$/.test(key) && Number(key) < length!.value);
|
|
294
|
+
entries.push([key, walk(d.value, path + "/" + key, depth + 1)]);
|
|
295
|
+
}
|
|
296
|
+
active.delete(value);
|
|
297
|
+
if (array) {
|
|
298
|
+
need(entries.length === length!.value);
|
|
299
|
+
entries.sort(([a], [b]) => Number(a) - Number(b));
|
|
300
|
+
return Object.freeze({
|
|
301
|
+
kind: "array",
|
|
302
|
+
entries: Object.freeze(entries.map((e) => Object.freeze(e))),
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return objectNode(entries);
|
|
306
|
+
}
|
|
307
|
+
const node = walk(output, "", 0);
|
|
308
|
+
need(found.size === 4);
|
|
309
|
+
encode(node);
|
|
310
|
+
return freeze(materialize(node));
|
|
311
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
3
|
+
import {
|
|
4
|
+
objectNode,
|
|
5
|
+
scalarNode,
|
|
6
|
+
encode,
|
|
7
|
+
materialize,
|
|
8
|
+
need,
|
|
9
|
+
freeze,
|
|
10
|
+
type Node,
|
|
11
|
+
} from "../material/nodeKernel.js";
|
|
12
|
+
import type {
|
|
13
|
+
constructRenewalScheduleAttachmentReceiptV2,
|
|
14
|
+
prepareRenewalPriceReplacementV2,
|
|
15
|
+
} from "../../../renewalV2/index.js";
|
|
16
|
+
import type { AttachRequest } from "../operations/types.js";
|
|
17
|
+
|
|
18
|
+
type Receipt = Awaited<
|
|
19
|
+
ReturnType<typeof constructRenewalScheduleAttachmentReceiptV2>
|
|
20
|
+
>;
|
|
21
|
+
type Prepared = Awaited<ReturnType<typeof prepareRenewalPriceReplacementV2>>;
|
|
22
|
+
/** Full result admission; caller must retain its own Source association and final Owner gate. */
|
|
23
|
+
export function admitRecoveryOutput(
|
|
24
|
+
receipt: Receipt,
|
|
25
|
+
observed: unknown,
|
|
26
|
+
prepared: Prepared,
|
|
27
|
+
request: AttachRequest,
|
|
28
|
+
) {
|
|
29
|
+
need(!types.isProxy(observed));
|
|
30
|
+
const observedID =
|
|
31
|
+
typeof observed === "string"
|
|
32
|
+
? observed
|
|
33
|
+
: (() => {
|
|
34
|
+
need(observed !== null && typeof observed === "object");
|
|
35
|
+
return Object.getOwnPropertyDescriptor(observed, "id")
|
|
36
|
+
?.value as unknown;
|
|
37
|
+
})();
|
|
38
|
+
const output = {
|
|
39
|
+
kind: "EXPLICIT_ATTACH_RECOVERY_V2_DATA_ONLY",
|
|
40
|
+
status: "attach_acknowledged",
|
|
41
|
+
operationalAuthority: false,
|
|
42
|
+
receipt,
|
|
43
|
+
observation: {
|
|
44
|
+
schedule: observed,
|
|
45
|
+
conflict: observedID !== receipt.scheduleId,
|
|
46
|
+
authority: "unowned_prepost_observation_only",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const slots = new Map([
|
|
50
|
+
["/receipt/logicalBinding", prepared.requestIdentity.binding],
|
|
51
|
+
["/receipt/request/logicalBinding", prepared.requestIdentity.binding],
|
|
52
|
+
[
|
|
53
|
+
"/receipt/request/requestIdentity/binding",
|
|
54
|
+
request.requestIdentity.binding,
|
|
55
|
+
],
|
|
56
|
+
["/receipt/binding", receipt.binding],
|
|
57
|
+
]),
|
|
58
|
+
found = new Set<string>(),
|
|
59
|
+
active = new Set<object>();
|
|
60
|
+
let nodes = 0,
|
|
61
|
+
rawCharacters = 0;
|
|
62
|
+
function walk(value: unknown, path: string, depth: number): Node {
|
|
63
|
+
need(++nodes <= 10000 && depth <= 40 && !types.isProxy(value));
|
|
64
|
+
if (slots.has(path)) {
|
|
65
|
+
const expected = slots.get(path),
|
|
66
|
+
family =
|
|
67
|
+
path === "/receipt/binding"
|
|
68
|
+
? "renewal-attach-receipt"
|
|
69
|
+
: path === "/receipt/request/requestIdentity/binding"
|
|
70
|
+
? "renewal-attach"
|
|
71
|
+
: "renewal";
|
|
72
|
+
need(
|
|
73
|
+
value === expected &&
|
|
74
|
+
typeof value === "string" &&
|
|
75
|
+
new RegExp("^" + family + ":v2:sha256:[0-9a-f]{64}$").test(value),
|
|
76
|
+
);
|
|
77
|
+
rawCharacters += value.length;
|
|
78
|
+
need(rawCharacters <= 500000);
|
|
79
|
+
found.add(path);
|
|
80
|
+
return scalarNode(value);
|
|
81
|
+
}
|
|
82
|
+
if (value === null || typeof value !== "object") {
|
|
83
|
+
requiredJSONSnapshot(value);
|
|
84
|
+
if (typeof value === "string") rawCharacters += value.length;
|
|
85
|
+
need(rawCharacters <= 500000);
|
|
86
|
+
return scalarNode(value);
|
|
87
|
+
}
|
|
88
|
+
need(!active.has(value));
|
|
89
|
+
active.add(value);
|
|
90
|
+
const array = Array.isArray(value),
|
|
91
|
+
proto = Object.getPrototypeOf(value);
|
|
92
|
+
need(
|
|
93
|
+
array
|
|
94
|
+
? proto === Array.prototype
|
|
95
|
+
: proto === Object.prototype || proto === null,
|
|
96
|
+
);
|
|
97
|
+
const keys = Reflect.ownKeys(value),
|
|
98
|
+
entries: [string, Node][] = [],
|
|
99
|
+
length = array ? Object.getOwnPropertyDescriptor(value, "length") : null;
|
|
100
|
+
if (array)
|
|
101
|
+
need(
|
|
102
|
+
length &&
|
|
103
|
+
"value" in length &&
|
|
104
|
+
Number.isSafeInteger(length.value) &&
|
|
105
|
+
length.value >= 0 &&
|
|
106
|
+
length.value <= 10000,
|
|
107
|
+
);
|
|
108
|
+
for (const key of keys) {
|
|
109
|
+
need(typeof key === "string");
|
|
110
|
+
if (array && key === "length") continue;
|
|
111
|
+
const d = Object.getOwnPropertyDescriptor(value, key);
|
|
112
|
+
need(d && d.enumerable && "value" in d);
|
|
113
|
+
requiredJSONSnapshot(key);
|
|
114
|
+
requiredJSONSnapshot({ [key]: d.value === null ? null : true });
|
|
115
|
+
rawCharacters += key.length;
|
|
116
|
+
need(rawCharacters <= 500000);
|
|
117
|
+
if (array)
|
|
118
|
+
need(/^(0|[1-9][0-9]*)$/.test(key) && Number(key) < length!.value);
|
|
119
|
+
entries.push([key, walk(d.value, path + "/" + key, depth + 1)]);
|
|
120
|
+
}
|
|
121
|
+
active.delete(value);
|
|
122
|
+
if (array) {
|
|
123
|
+
need(entries.length === length!.value);
|
|
124
|
+
entries.sort(([a], [b]) => Number(a) - Number(b));
|
|
125
|
+
return Object.freeze({
|
|
126
|
+
kind: "array",
|
|
127
|
+
entries: Object.freeze(entries.map((e) => Object.freeze(e))),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return objectNode(entries);
|
|
131
|
+
}
|
|
132
|
+
const node = walk(output, "", 0);
|
|
133
|
+
need(found.size === 4);
|
|
134
|
+
encode(node);
|
|
135
|
+
return freeze(materialize(node));
|
|
136
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { OWNER } from "../originalOwner.js";
|
|
3
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
4
|
+
import {
|
|
5
|
+
closed,
|
|
6
|
+
need,
|
|
7
|
+
freeze,
|
|
8
|
+
objectNode,
|
|
9
|
+
scalarNode,
|
|
10
|
+
encode,
|
|
11
|
+
materialize,
|
|
12
|
+
type Node,
|
|
13
|
+
} from "../material/nodeKernel.js";
|
|
14
|
+
import { equal } from "../../../renewalAggregate/shared.js";
|
|
15
|
+
import type { prepareRenewalPriceReplacementV2 } from "../../../renewalV2/index.js";
|
|
16
|
+
import type { AttachRequest } from "../operations/types.js";
|
|
17
|
+
|
|
18
|
+
const materialKeys = [
|
|
19
|
+
"classificationRevision",
|
|
20
|
+
"protocolRevision",
|
|
21
|
+
"stage",
|
|
22
|
+
"intent",
|
|
23
|
+
"scope",
|
|
24
|
+
"apiVersion",
|
|
25
|
+
"profile",
|
|
26
|
+
"quantity",
|
|
27
|
+
"currentPrice",
|
|
28
|
+
"targetPrice",
|
|
29
|
+
"source",
|
|
30
|
+
"nativeItem",
|
|
31
|
+
"billingCustomer",
|
|
32
|
+
"subscriptionDiscounts",
|
|
33
|
+
"itemDiscounts",
|
|
34
|
+
"settings",
|
|
35
|
+
"originalPrepared",
|
|
36
|
+
"completeRequest",
|
|
37
|
+
"stageEvidence",
|
|
38
|
+
"rawSources",
|
|
39
|
+
"freshness",
|
|
40
|
+
];
|
|
41
|
+
const preparedKeys = [
|
|
42
|
+
"version",
|
|
43
|
+
"scope",
|
|
44
|
+
"expected",
|
|
45
|
+
"quantity",
|
|
46
|
+
"providerSnapshot",
|
|
47
|
+
"status",
|
|
48
|
+
"preservation",
|
|
49
|
+
"requestIdentity",
|
|
50
|
+
];
|
|
51
|
+
const requestKeys = [
|
|
52
|
+
"version",
|
|
53
|
+
"stage",
|
|
54
|
+
"scope",
|
|
55
|
+
"apiVersion",
|
|
56
|
+
"logicalBinding",
|
|
57
|
+
"method",
|
|
58
|
+
"path",
|
|
59
|
+
"payload",
|
|
60
|
+
"key",
|
|
61
|
+
"firstDispatchedAt",
|
|
62
|
+
"requestIdentity",
|
|
63
|
+
];
|
|
64
|
+
const slotPaths = [
|
|
65
|
+
"/originalPrepared/requestIdentity/binding",
|
|
66
|
+
"/completeRequest/logicalBinding",
|
|
67
|
+
"/completeRequest/requestIdentity/binding",
|
|
68
|
+
"/retainedMaterial/originalPrepared/requestIdentity/binding",
|
|
69
|
+
"/retainedMaterial/completeRequest/logicalBinding",
|
|
70
|
+
"/retainedMaterial/completeRequest/requestIdentity/binding",
|
|
71
|
+
];
|
|
72
|
+
const attachSlots = new Set([slotPaths[2], slotPaths[5]]);
|
|
73
|
+
export type CapturedRecord = Readonly<{
|
|
74
|
+
node: Node;
|
|
75
|
+
slots: ReadonlyMap<string, string>;
|
|
76
|
+
originalRaw: unknown;
|
|
77
|
+
}>;
|
|
78
|
+
|
|
79
|
+
/** Detached unverified data only. The actor retains and proves its own record. */
|
|
80
|
+
export function captureRecoveryRecord(live: unknown): CapturedRecord {
|
|
81
|
+
OWNER.check();
|
|
82
|
+
const slots = new Map<string, string>(),
|
|
83
|
+
active = new Set<object>();
|
|
84
|
+
let nodes = 0,
|
|
85
|
+
rawChars = 0,
|
|
86
|
+
rawNode: Node | undefined;
|
|
87
|
+
function walk(x: unknown, path: string, depth: number): Node {
|
|
88
|
+
need(++nodes <= 10000 && depth <= 40 && !types.isProxy(x));
|
|
89
|
+
if (slotPaths.includes(path)) {
|
|
90
|
+
need(
|
|
91
|
+
typeof x === "string" &&
|
|
92
|
+
new RegExp(
|
|
93
|
+
"^" +
|
|
94
|
+
(attachSlots.has(path) ? "renewal-attach" : "renewal") +
|
|
95
|
+
":v2:sha256:[0-9a-f]{64}$",
|
|
96
|
+
).test(x),
|
|
97
|
+
);
|
|
98
|
+
slots.set(path, x);
|
|
99
|
+
rawChars += x.length;
|
|
100
|
+
need(rawChars <= 500000);
|
|
101
|
+
return scalarNode(x);
|
|
102
|
+
}
|
|
103
|
+
if (x === null || typeof x !== "object") {
|
|
104
|
+
requiredJSONSnapshot(x);
|
|
105
|
+
if (typeof x === "string") rawChars += x.length;
|
|
106
|
+
need(rawChars <= 500000);
|
|
107
|
+
return scalarNode(x);
|
|
108
|
+
}
|
|
109
|
+
need(!active.has(x));
|
|
110
|
+
active.add(x);
|
|
111
|
+
const array = Array.isArray(x),
|
|
112
|
+
proto = Object.getPrototypeOf(x);
|
|
113
|
+
need(
|
|
114
|
+
array
|
|
115
|
+
? proto === Array.prototype
|
|
116
|
+
: proto === Object.prototype || proto === null,
|
|
117
|
+
);
|
|
118
|
+
const keys = Reflect.ownKeys(x),
|
|
119
|
+
entries: [string, Node][] = [];
|
|
120
|
+
need(keys.length <= 10001);
|
|
121
|
+
if (path === "")
|
|
122
|
+
closed(x, [
|
|
123
|
+
"originalRaw",
|
|
124
|
+
"originalPrepared",
|
|
125
|
+
"completeRequest",
|
|
126
|
+
"retainedMaterial",
|
|
127
|
+
]);
|
|
128
|
+
if (path === "/originalRaw") closed(x, ["attachRequest", "originalBundle"]);
|
|
129
|
+
if (
|
|
130
|
+
path === "/originalPrepared" ||
|
|
131
|
+
path === "/retainedMaterial/originalPrepared"
|
|
132
|
+
)
|
|
133
|
+
closed(x, preparedKeys);
|
|
134
|
+
if (
|
|
135
|
+
path === "/completeRequest" ||
|
|
136
|
+
path === "/retainedMaterial/completeRequest"
|
|
137
|
+
)
|
|
138
|
+
closed(x, requestKeys);
|
|
139
|
+
if (path === "/retainedMaterial") closed(x, materialKeys);
|
|
140
|
+
if (path === "/retainedMaterial/rawSources")
|
|
141
|
+
closed(x, ["attachRequest", "intent"]);
|
|
142
|
+
if (path === "/retainedMaterial/stageEvidence")
|
|
143
|
+
closed(x, ["actualFreshSubscription"]);
|
|
144
|
+
if (
|
|
145
|
+
[
|
|
146
|
+
"/originalPrepared/requestIdentity",
|
|
147
|
+
"/completeRequest/requestIdentity",
|
|
148
|
+
"/retainedMaterial/originalPrepared/requestIdentity",
|
|
149
|
+
"/retainedMaterial/completeRequest/requestIdentity",
|
|
150
|
+
].includes(path)
|
|
151
|
+
)
|
|
152
|
+
closed(x, ["key", "binding"]);
|
|
153
|
+
const length = array ? Object.getOwnPropertyDescriptor(x, "length") : null;
|
|
154
|
+
if (array)
|
|
155
|
+
need(
|
|
156
|
+
length &&
|
|
157
|
+
"value" in length &&
|
|
158
|
+
Number.isSafeInteger(length.value) &&
|
|
159
|
+
length.value <= 10000,
|
|
160
|
+
);
|
|
161
|
+
for (const key of keys) {
|
|
162
|
+
need(typeof key === "string");
|
|
163
|
+
if (array && key === "length") continue;
|
|
164
|
+
const d = Object.getOwnPropertyDescriptor(x, key);
|
|
165
|
+
need(d && d.enumerable && "value" in d);
|
|
166
|
+
requiredJSONSnapshot(key);
|
|
167
|
+
requiredJSONSnapshot({ [key]: d.value === null ? null : true });
|
|
168
|
+
rawChars += key.length;
|
|
169
|
+
need(rawChars <= 500000);
|
|
170
|
+
need(
|
|
171
|
+
!array ||
|
|
172
|
+
(/^(0|[1-9][0-9]*)$/.test(key) && Number(key) < length!.value),
|
|
173
|
+
);
|
|
174
|
+
const child = walk(d.value, path + "/" + key, depth + 1);
|
|
175
|
+
entries.push([key, child]);
|
|
176
|
+
if (path === "" && key === "originalRaw") rawNode = child;
|
|
177
|
+
}
|
|
178
|
+
active.delete(x);
|
|
179
|
+
if (array) {
|
|
180
|
+
need(entries.length === length!.value);
|
|
181
|
+
entries.sort(([a], [b]) => Number(a) - Number(b));
|
|
182
|
+
return Object.freeze({
|
|
183
|
+
kind: "array",
|
|
184
|
+
entries: Object.freeze(entries.map((e) => Object.freeze(e))),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return objectNode(entries);
|
|
188
|
+
}
|
|
189
|
+
const node = walk(live, "", 0);
|
|
190
|
+
need(slots.size === 6 && rawNode);
|
|
191
|
+
encode(node);
|
|
192
|
+
OWNER.check();
|
|
193
|
+
return Object.freeze({
|
|
194
|
+
node,
|
|
195
|
+
slots,
|
|
196
|
+
originalRaw: freeze(materialize(rawNode)),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function verifyRecoveryRecord(
|
|
201
|
+
captured: CapturedRecord,
|
|
202
|
+
prepared: Awaited<ReturnType<typeof prepareRenewalPriceReplacementV2>>,
|
|
203
|
+
request: AttachRequest,
|
|
204
|
+
retained: unknown,
|
|
205
|
+
original: unknown,
|
|
206
|
+
): void {
|
|
207
|
+
const expected = [
|
|
208
|
+
prepared.requestIdentity.binding,
|
|
209
|
+
prepared.requestIdentity.binding,
|
|
210
|
+
request.requestIdentity.binding,
|
|
211
|
+
prepared.requestIdentity.binding,
|
|
212
|
+
prepared.requestIdentity.binding,
|
|
213
|
+
request.requestIdentity.binding,
|
|
214
|
+
];
|
|
215
|
+
slotPaths.forEach((path, i) =>
|
|
216
|
+
need(captured.slots.get(path) === expected[i]),
|
|
217
|
+
);
|
|
218
|
+
const record = closed(materialize(captured.node), [
|
|
219
|
+
"originalRaw",
|
|
220
|
+
"originalPrepared",
|
|
221
|
+
"completeRequest",
|
|
222
|
+
"retainedMaterial",
|
|
223
|
+
]);
|
|
224
|
+
need(
|
|
225
|
+
equal(record.originalRaw, original) &&
|
|
226
|
+
equal(record.originalPrepared, prepared) &&
|
|
227
|
+
equal(record.completeRequest, request) &&
|
|
228
|
+
equal(record.retainedMaterial, retained),
|
|
229
|
+
);
|
|
230
|
+
}
|