@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,535 @@
|
|
|
1
|
+
import { admitInitialOutput } from "../recovery/material.js";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import { OWNER } from "../originalOwner.js";
|
|
4
|
+
import {
|
|
5
|
+
prepareRenewalPriceReplacementV2 as c1,
|
|
6
|
+
prepareRenewalScheduleAttachmentV2 as c2,
|
|
7
|
+
constructRenewalScheduleAttachmentReceiptV2 as c3,
|
|
8
|
+
} from "../../../renewalV2/index.js";
|
|
9
|
+
import {
|
|
10
|
+
classifyOwnedRetainedInitialAttachment,
|
|
11
|
+
classifyOwnedInitialAttachment,
|
|
12
|
+
} from "../material/classifiers.js";
|
|
13
|
+
import { captureRetainedInput } from "../material/capture.js";
|
|
14
|
+
import {
|
|
15
|
+
closed,
|
|
16
|
+
type AttachRequest,
|
|
17
|
+
type SourceMethod,
|
|
18
|
+
type FailureControl,
|
|
19
|
+
} from "./types.js";
|
|
20
|
+
import { equal } from "../../../renewalAggregate/shared.js";
|
|
21
|
+
import { owned } from "./ownedAwait.js";
|
|
22
|
+
import type { Diagnostics } from "./providerFailure.js";
|
|
23
|
+
import { bindRawAcquisitionFromSource } from "../acquisition/ownedAcquisition.js";
|
|
24
|
+
import { createAttachEventCompiler } from "../c10/attachEvents.js";
|
|
25
|
+
import {
|
|
26
|
+
COMPILED_INITIAL_ENTRIES as ENTRIES,
|
|
27
|
+
loadFixedInitialOperation,
|
|
28
|
+
ORIGINAL_ORIGIN_ASSOCIATION,
|
|
29
|
+
} from "./sourceOperations.js";
|
|
30
|
+
import { createInitialOwnedTransportWithAttemptCapability as createPair } from "./fixedTransport.js";
|
|
31
|
+
|
|
32
|
+
type Pair = ReturnType<typeof createPair>;
|
|
33
|
+
|
|
34
|
+
function sourceMethod(object: unknown, name: string): SourceMethod {
|
|
35
|
+
need(object !== null && typeof object === "object" && !types.isProxy(object));
|
|
36
|
+
const d = Object.getOwnPropertyDescriptor(object, name);
|
|
37
|
+
need(
|
|
38
|
+
d &&
|
|
39
|
+
d.enumerable &&
|
|
40
|
+
"value" in d &&
|
|
41
|
+
typeof d.value === "function" &&
|
|
42
|
+
!types.isProxy(d.value),
|
|
43
|
+
);
|
|
44
|
+
return d.value as SourceMethod;
|
|
45
|
+
}
|
|
46
|
+
const stop = (): never => {
|
|
47
|
+
throw Error("INITIAL_ACTOR_STOP");
|
|
48
|
+
};
|
|
49
|
+
function need(value: unknown): asserts value {
|
|
50
|
+
if (!value) stop();
|
|
51
|
+
}
|
|
52
|
+
function seven(request: AttachRequest) {
|
|
53
|
+
const { scope, apiVersion, method, path, payload, key, firstDispatchedAt } =
|
|
54
|
+
request;
|
|
55
|
+
return Object.freeze({
|
|
56
|
+
scope,
|
|
57
|
+
apiVersion,
|
|
58
|
+
method,
|
|
59
|
+
path,
|
|
60
|
+
payload,
|
|
61
|
+
key,
|
|
62
|
+
firstDispatchedAt,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const refuse = (reason: string) =>
|
|
67
|
+
Object.freeze({
|
|
68
|
+
status: "not_dispatched",
|
|
69
|
+
reason,
|
|
70
|
+
operationalAuthority: false,
|
|
71
|
+
});
|
|
72
|
+
/** Internal single-use actor. Empty class registry precedes every Source side effect. */
|
|
73
|
+
export function captureInitialAttach() {
|
|
74
|
+
need(arguments.length === 0);
|
|
75
|
+
return captureOwnedInitialAttachV2();
|
|
76
|
+
}
|
|
77
|
+
export function captureOwnedInitialAttachV2() {
|
|
78
|
+
need(arguments.length === 0);
|
|
79
|
+
let consumed = false;
|
|
80
|
+
return Object.freeze({
|
|
81
|
+
async invoke() {
|
|
82
|
+
need(arguments.length === 0);
|
|
83
|
+
if (consumed) return refuse("invocation_consumed");
|
|
84
|
+
consumed = true;
|
|
85
|
+
need(!types.isProxy(ENTRIES) && Array.isArray(ENTRIES));
|
|
86
|
+
if (ENTRIES.length === 0) return refuse("no_qualified_native_class");
|
|
87
|
+
let pair: Pair | null = null,
|
|
88
|
+
failureControl: FailureControl | null = null,
|
|
89
|
+
postEligible = false;
|
|
90
|
+
const uncertain = () => {
|
|
91
|
+
need(pair);
|
|
92
|
+
const state = pair.transport.postDisposition();
|
|
93
|
+
need(state === "FULFILLED_SAFE" || state === "FULFILLED_UNVERIFIED");
|
|
94
|
+
const q =
|
|
95
|
+
failureControl === null ? null : failureControl.takePostQuarantine();
|
|
96
|
+
return Object.freeze(
|
|
97
|
+
q === null
|
|
98
|
+
? { status: "fulfilled_unverified", operationalAuthority: false }
|
|
99
|
+
: {
|
|
100
|
+
status: "fulfilled_unverified",
|
|
101
|
+
operationalAuthority: false,
|
|
102
|
+
quarantine: q,
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
try {
|
|
107
|
+
OWNER.check();
|
|
108
|
+
const live = loadFixedInitialOperation();
|
|
109
|
+
OWNER.check();
|
|
110
|
+
if (live === null) return refuse("original_slot_unbound");
|
|
111
|
+
const op = closed(live, [
|
|
112
|
+
"owner",
|
|
113
|
+
"originAssociation",
|
|
114
|
+
"slot",
|
|
115
|
+
"readPlan",
|
|
116
|
+
"delegate",
|
|
117
|
+
"sink",
|
|
118
|
+
]);
|
|
119
|
+
need(
|
|
120
|
+
op.owner === OWNER &&
|
|
121
|
+
op.originAssociation !== null &&
|
|
122
|
+
typeof op.originAssociation === "object" &&
|
|
123
|
+
!types.isProxy(op.originAssociation) &&
|
|
124
|
+
op.originAssociation === ORIGINAL_ORIGIN_ASSOCIATION,
|
|
125
|
+
);
|
|
126
|
+
const takeOnce = sourceMethod(op.slot, "takeOnce");
|
|
127
|
+
OWNER.check();
|
|
128
|
+
const slot = Reflect.apply(takeOnce, op.slot, [OWNER]);
|
|
129
|
+
OWNER.check();
|
|
130
|
+
if (!slot) return refuse("original_slot_unbound");
|
|
131
|
+
const selected = closed(slot, ["rawAttachRequest", "originalBundle"]);
|
|
132
|
+
const original = captureRetainedInput({
|
|
133
|
+
attachRequest: selected.rawAttachRequest,
|
|
134
|
+
originalBundle: selected.originalBundle,
|
|
135
|
+
});
|
|
136
|
+
OWNER.check();
|
|
137
|
+
const raw = original.attachRequest;
|
|
138
|
+
const prepared = await owned(() => c1(raw.preparation));
|
|
139
|
+
OWNER.check();
|
|
140
|
+
const request = await owned(() =>
|
|
141
|
+
c2({
|
|
142
|
+
prepared,
|
|
143
|
+
apiVersion: raw.apiVersion,
|
|
144
|
+
attachKey: raw.attachKey,
|
|
145
|
+
firstDispatchedAt: raw.firstDispatchedAt,
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
OWNER.check();
|
|
149
|
+
const retained = await owned(() =>
|
|
150
|
+
classifyOwnedRetainedInitialAttachment(original),
|
|
151
|
+
);
|
|
152
|
+
OWNER.check();
|
|
153
|
+
if (retained.status !== "classified")
|
|
154
|
+
return refuse("retained_material_unsupported");
|
|
155
|
+
const matches: { raw: unknown; fresh: SourceMethod }[] = [];
|
|
156
|
+
for (const entry of ENTRIES) {
|
|
157
|
+
OWNER.check();
|
|
158
|
+
const retainedPredicate = sourceMethod(entry, "coversRetained"),
|
|
159
|
+
freshPredicate = sourceMethod(entry, "coversFresh");
|
|
160
|
+
if (
|
|
161
|
+
Reflect.apply(retainedPredicate, entry, [
|
|
162
|
+
retained.material,
|
|
163
|
+
original.originalBundle,
|
|
164
|
+
]) === true
|
|
165
|
+
)
|
|
166
|
+
matches.push({ raw: entry, fresh: freshPredicate });
|
|
167
|
+
OWNER.check();
|
|
168
|
+
}
|
|
169
|
+
if (matches.length !== 1) return refuse("retained_class_not_unique");
|
|
170
|
+
const entry = matches[0];
|
|
171
|
+
OWNER.check();
|
|
172
|
+
pair = createPair();
|
|
173
|
+
OWNER.check();
|
|
174
|
+
need(
|
|
175
|
+
pair.capability.assertSourceOperationBinding(
|
|
176
|
+
live,
|
|
177
|
+
request,
|
|
178
|
+
op.readPlan,
|
|
179
|
+
op.delegate,
|
|
180
|
+
),
|
|
181
|
+
);
|
|
182
|
+
OWNER.check();
|
|
183
|
+
|
|
184
|
+
const activePair = pair;
|
|
185
|
+
// Only this invocation's pair and actual locally rebuilt C2 enter this capsule.
|
|
186
|
+
const control = (() => {
|
|
187
|
+
const capability = activePair.capability,
|
|
188
|
+
takeQuarantine = capability.takeFulfilledQuarantine;
|
|
189
|
+
Object.freeze(request.payload);
|
|
190
|
+
Object.freeze(request.requestIdentity);
|
|
191
|
+
Object.freeze(request);
|
|
192
|
+
OWNER.check();
|
|
193
|
+
type Token = {
|
|
194
|
+
invocation: object;
|
|
195
|
+
phase: "read" | "post";
|
|
196
|
+
ordinal: number;
|
|
197
|
+
request: AttachRequest;
|
|
198
|
+
diagnostics: Diagnostics;
|
|
199
|
+
};
|
|
200
|
+
const tokens = new WeakMap<object, Token>(),
|
|
201
|
+
invocation = Object.freeze({});
|
|
202
|
+
let phase = "unused";
|
|
203
|
+
const tokenValue = (error: unknown) =>
|
|
204
|
+
error !== null &&
|
|
205
|
+
(typeof error === "object" || typeof error === "function")
|
|
206
|
+
? tokens.get(error)
|
|
207
|
+
: undefined;
|
|
208
|
+
function consume(error: unknown, kind: "read" | "post") {
|
|
209
|
+
OWNER.check();
|
|
210
|
+
const value = tokenValue(error);
|
|
211
|
+
if (
|
|
212
|
+
error !== null &&
|
|
213
|
+
(typeof error === "object" || typeof error === "function")
|
|
214
|
+
)
|
|
215
|
+
tokens.delete(error);
|
|
216
|
+
if (
|
|
217
|
+
!value ||
|
|
218
|
+
value.invocation !== invocation ||
|
|
219
|
+
value.phase !== kind ||
|
|
220
|
+
phase !== (kind === "read" ? "failed" : "failed_post")
|
|
221
|
+
)
|
|
222
|
+
return null;
|
|
223
|
+
phase = kind === "read" ? "consumed" : "consumed_post";
|
|
224
|
+
const failure = Object.freeze({
|
|
225
|
+
category: "provider_rejected",
|
|
226
|
+
phase: kind,
|
|
227
|
+
ordinal: value.ordinal,
|
|
228
|
+
request: value.request,
|
|
229
|
+
diagnostics: value.diagnostics,
|
|
230
|
+
outcome: "unknown",
|
|
231
|
+
operationalAuthority: false,
|
|
232
|
+
});
|
|
233
|
+
const out = Error("INITIAL_PROVIDER_REJECTED");
|
|
234
|
+
Object.defineProperty(out, "failure", {
|
|
235
|
+
value: failure,
|
|
236
|
+
enumerable: false,
|
|
237
|
+
writable: false,
|
|
238
|
+
configurable: false,
|
|
239
|
+
});
|
|
240
|
+
return out;
|
|
241
|
+
}
|
|
242
|
+
return Object.freeze({
|
|
243
|
+
takePostQuarantine(...args: unknown[]) {
|
|
244
|
+
if (args.length !== 0) return null;
|
|
245
|
+
return Reflect.apply(takeQuarantine, capability, []) as
|
|
246
|
+
object | null;
|
|
247
|
+
},
|
|
248
|
+
begin() {
|
|
249
|
+
OWNER.check();
|
|
250
|
+
if (phase !== "unused") stop();
|
|
251
|
+
if (capability.assertVirginAcquisition() !== true) {
|
|
252
|
+
phase = "closed";
|
|
253
|
+
stop();
|
|
254
|
+
}
|
|
255
|
+
OWNER.check();
|
|
256
|
+
phase = "acquiring";
|
|
257
|
+
},
|
|
258
|
+
complete() {
|
|
259
|
+
OWNER.check();
|
|
260
|
+
if (phase !== "acquiring") stop();
|
|
261
|
+
phase = "complete";
|
|
262
|
+
},
|
|
263
|
+
takeReadFailure() {
|
|
264
|
+
OWNER.check();
|
|
265
|
+
if (phase !== "acquiring") stop();
|
|
266
|
+
const record = capability.consumeReadCatch();
|
|
267
|
+
OWNER.check();
|
|
268
|
+
if (record === null) {
|
|
269
|
+
phase = "unsupported";
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
need(
|
|
273
|
+
record.phase === "read" &&
|
|
274
|
+
Number.isSafeInteger(record.ordinal) &&
|
|
275
|
+
record.ordinal >= 1 &&
|
|
276
|
+
record.ordinal <= 43,
|
|
277
|
+
);
|
|
278
|
+
const token = Object.freeze(Object.create(null)) as object;
|
|
279
|
+
tokens.set(
|
|
280
|
+
token,
|
|
281
|
+
Object.freeze({
|
|
282
|
+
invocation,
|
|
283
|
+
phase: "read",
|
|
284
|
+
ordinal: record.ordinal,
|
|
285
|
+
request,
|
|
286
|
+
diagnostics: record.diagnostics,
|
|
287
|
+
}),
|
|
288
|
+
);
|
|
289
|
+
phase = "failed";
|
|
290
|
+
return token;
|
|
291
|
+
},
|
|
292
|
+
beginPost() {
|
|
293
|
+
OWNER.check();
|
|
294
|
+
if (phase !== "complete") stop();
|
|
295
|
+
phase = "posting";
|
|
296
|
+
},
|
|
297
|
+
takePostFailure(actualReply: unknown) {
|
|
298
|
+
OWNER.check();
|
|
299
|
+
if (phase !== "posting") stop();
|
|
300
|
+
const record = capability.consumePostCatch(actualReply);
|
|
301
|
+
OWNER.check();
|
|
302
|
+
if (record === null) {
|
|
303
|
+
phase = "post_without_token";
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
need(
|
|
307
|
+
record.phase === "post" &&
|
|
308
|
+
Number.isSafeInteger(record.ordinal) &&
|
|
309
|
+
record.ordinal >= 1 &&
|
|
310
|
+
record.ordinal <= 44,
|
|
311
|
+
);
|
|
312
|
+
const token = Object.freeze(Object.create(null)) as object;
|
|
313
|
+
tokens.set(
|
|
314
|
+
token,
|
|
315
|
+
Object.freeze({
|
|
316
|
+
invocation,
|
|
317
|
+
phase: "post",
|
|
318
|
+
ordinal: record.ordinal,
|
|
319
|
+
request,
|
|
320
|
+
diagnostics: record.diagnostics,
|
|
321
|
+
}),
|
|
322
|
+
);
|
|
323
|
+
phase = "failed_post";
|
|
324
|
+
return token;
|
|
325
|
+
},
|
|
326
|
+
forward(error: unknown) {
|
|
327
|
+
OWNER.check();
|
|
328
|
+
const value = tokenValue(error);
|
|
329
|
+
return value &&
|
|
330
|
+
value.invocation === invocation &&
|
|
331
|
+
(phase === "failed" || phase === "failed_post")
|
|
332
|
+
? (error as object)
|
|
333
|
+
: null;
|
|
334
|
+
},
|
|
335
|
+
consume(error: unknown) {
|
|
336
|
+
return consume(error, "read");
|
|
337
|
+
},
|
|
338
|
+
consumePost(error: unknown) {
|
|
339
|
+
return consume(error, "post");
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
})();
|
|
343
|
+
OWNER.check();
|
|
344
|
+
failureControl = control;
|
|
345
|
+
const reader = bindRawAcquisitionFromSource(
|
|
346
|
+
OWNER,
|
|
347
|
+
activePair.transport.readTransport,
|
|
348
|
+
);
|
|
349
|
+
OWNER.check();
|
|
350
|
+
let acquiredOnce = false;
|
|
351
|
+
const acquire = async () => {
|
|
352
|
+
OWNER.check();
|
|
353
|
+
if (acquiredOnce) stop();
|
|
354
|
+
acquiredOnce = true;
|
|
355
|
+
control.begin();
|
|
356
|
+
OWNER.check();
|
|
357
|
+
const result = await reader.acquire(prepared.expected);
|
|
358
|
+
OWNER.check();
|
|
359
|
+
if (result.ok) {
|
|
360
|
+
control.complete();
|
|
361
|
+
return result;
|
|
362
|
+
}
|
|
363
|
+
const token = control.takeReadFailure();
|
|
364
|
+
OWNER.check();
|
|
365
|
+
if (token !== null) throw token;
|
|
366
|
+
return result;
|
|
367
|
+
};
|
|
368
|
+
const acquired = await owned(acquire, control);
|
|
369
|
+
OWNER.check();
|
|
370
|
+
if (!acquired.ok) return refuse("current_read_unsupported");
|
|
371
|
+
|
|
372
|
+
const fresh = await owned(() =>
|
|
373
|
+
classifyOwnedInitialAttachment({
|
|
374
|
+
attachRequest: raw,
|
|
375
|
+
originalBundle: original.originalBundle,
|
|
376
|
+
currentBundle: acquired.bundle,
|
|
377
|
+
observedAt: acquired.observedAt,
|
|
378
|
+
}),
|
|
379
|
+
);
|
|
380
|
+
OWNER.check();
|
|
381
|
+
if (fresh.status !== "classified")
|
|
382
|
+
return refuse("fresh_material_unsupported");
|
|
383
|
+
const covered = Reflect.apply(entry.fresh, entry.raw, [
|
|
384
|
+
fresh.material,
|
|
385
|
+
original.originalBundle,
|
|
386
|
+
acquired.bundle,
|
|
387
|
+
]);
|
|
388
|
+
OWNER.check();
|
|
389
|
+
if (covered !== true)
|
|
390
|
+
return refuse("same_entry_fresh_coverage_missing");
|
|
391
|
+
const material = closed(fresh.material, [
|
|
392
|
+
"classificationRevision",
|
|
393
|
+
"protocolRevision",
|
|
394
|
+
"stage",
|
|
395
|
+
"intent",
|
|
396
|
+
"scope",
|
|
397
|
+
"apiVersion",
|
|
398
|
+
"profile",
|
|
399
|
+
"quantity",
|
|
400
|
+
"currentPrice",
|
|
401
|
+
"targetPrice",
|
|
402
|
+
"source",
|
|
403
|
+
"nativeItem",
|
|
404
|
+
"billingCustomer",
|
|
405
|
+
"subscriptionDiscounts",
|
|
406
|
+
"itemDiscounts",
|
|
407
|
+
"settings",
|
|
408
|
+
"originalPrepared",
|
|
409
|
+
"completeRequest",
|
|
410
|
+
"stageEvidence",
|
|
411
|
+
"rawSources",
|
|
412
|
+
"freshness",
|
|
413
|
+
]);
|
|
414
|
+
need(
|
|
415
|
+
material.classificationRevision === "renewal-material-v2" &&
|
|
416
|
+
material.protocolRevision === "renewal-stage-protocol-v1" &&
|
|
417
|
+
material.stage === "attach" &&
|
|
418
|
+
material.intent === "initial" &&
|
|
419
|
+
material.freshness === "fresh" &&
|
|
420
|
+
material.scope === request.scope &&
|
|
421
|
+
material.apiVersion === request.apiVersion,
|
|
422
|
+
);
|
|
423
|
+
need(
|
|
424
|
+
equal(material.originalPrepared, prepared) &&
|
|
425
|
+
equal(material.completeRequest, request),
|
|
426
|
+
);
|
|
427
|
+
need(
|
|
428
|
+
equal(material.rawSources, {
|
|
429
|
+
attachRequest: raw,
|
|
430
|
+
intent: "initial",
|
|
431
|
+
freshSubscription: acquired.bundle.wireSubscription,
|
|
432
|
+
targetPrice: acquired.bundle.wireTargetPrice,
|
|
433
|
+
billingCustomer: acquired.bundle.wireBillingCustomer,
|
|
434
|
+
observedAt: acquired.observedAt,
|
|
435
|
+
}),
|
|
436
|
+
);
|
|
437
|
+
OWNER.check();
|
|
438
|
+
closed(op.sink, ["send"]);
|
|
439
|
+
const send = sourceMethod(op.sink, "send");
|
|
440
|
+
const sourceSend = (record: unknown, ack: unknown) => {
|
|
441
|
+
OWNER.check();
|
|
442
|
+
return Reflect.apply(send, op.sink, [record, ack]);
|
|
443
|
+
};
|
|
444
|
+
const compiler = createAttachEventCompiler(raw, {
|
|
445
|
+
send: sourceSend,
|
|
446
|
+
timeoutMs: 5000,
|
|
447
|
+
});
|
|
448
|
+
OWNER.check();
|
|
449
|
+
await owned(() =>
|
|
450
|
+
compiler.dispatch({ event: "dispatch", stage: "attach", request }),
|
|
451
|
+
);
|
|
452
|
+
OWNER.check();
|
|
453
|
+
postEligible = true;
|
|
454
|
+
let postedOnce = false;
|
|
455
|
+
const post = async () => {
|
|
456
|
+
OWNER.check();
|
|
457
|
+
if (postedOnce) stop();
|
|
458
|
+
postedOnce = true;
|
|
459
|
+
control.beginPost();
|
|
460
|
+
OWNER.check();
|
|
461
|
+
const reply = await activePair.transport.postAttach();
|
|
462
|
+
OWNER.check();
|
|
463
|
+
const token = control.takePostFailure(reply);
|
|
464
|
+
OWNER.check();
|
|
465
|
+
if (token !== null) throw token;
|
|
466
|
+
return reply;
|
|
467
|
+
};
|
|
468
|
+
const reply = await owned(post, control);
|
|
469
|
+
OWNER.check();
|
|
470
|
+
if (reply.outcome === "not_started") return refuse("post_not_started");
|
|
471
|
+
if (reply.outcome === "provider_rejected") stop();
|
|
472
|
+
if (reply.outcome !== "fulfilled_safe") return uncertain();
|
|
473
|
+
const body = reply.body;
|
|
474
|
+
await owned(() =>
|
|
475
|
+
compiler.response({
|
|
476
|
+
event: "response",
|
|
477
|
+
stage: "attach",
|
|
478
|
+
request,
|
|
479
|
+
body,
|
|
480
|
+
status: reply.statusCode,
|
|
481
|
+
}),
|
|
482
|
+
);
|
|
483
|
+
OWNER.check();
|
|
484
|
+
const receipt = await owned(() =>
|
|
485
|
+
c3({
|
|
486
|
+
attachRequest: raw,
|
|
487
|
+
actualDispatch: seven(request),
|
|
488
|
+
providerSnapshot: body as Record<string, unknown>,
|
|
489
|
+
}),
|
|
490
|
+
);
|
|
491
|
+
OWNER.check();
|
|
492
|
+
await owned(() =>
|
|
493
|
+
compiler.receipt({
|
|
494
|
+
event: "receipt",
|
|
495
|
+
stage: "attach",
|
|
496
|
+
request,
|
|
497
|
+
receipt,
|
|
498
|
+
}),
|
|
499
|
+
);
|
|
500
|
+
OWNER.check();
|
|
501
|
+
const result = admitInitialOutput(receipt, prepared, request);
|
|
502
|
+
OWNER.check();
|
|
503
|
+
control.takePostQuarantine();
|
|
504
|
+
return result;
|
|
505
|
+
} catch (error) {
|
|
506
|
+
let live = false;
|
|
507
|
+
try {
|
|
508
|
+
OWNER.check();
|
|
509
|
+
live = true;
|
|
510
|
+
} catch {}
|
|
511
|
+
if (live && !postEligible && failureControl) {
|
|
512
|
+
const failure = failureControl.consume(error);
|
|
513
|
+
if (failure !== null) throw failure;
|
|
514
|
+
}
|
|
515
|
+
if (
|
|
516
|
+
live &&
|
|
517
|
+
postEligible &&
|
|
518
|
+
pair &&
|
|
519
|
+
failureControl &&
|
|
520
|
+
pair.transport.postDisposition() === "REJECTED"
|
|
521
|
+
) {
|
|
522
|
+
const failure = failureControl.consumePost(error);
|
|
523
|
+
if (failure !== null) throw failure;
|
|
524
|
+
}
|
|
525
|
+
if (postEligible && pair) {
|
|
526
|
+
const state = pair.transport.postDisposition();
|
|
527
|
+
if (state === "FULFILLED_SAFE" || state === "FULFILLED_UNVERIFIED")
|
|
528
|
+
return uncertain();
|
|
529
|
+
if (state === "NOT_STARTED") return refuse("post_not_started");
|
|
530
|
+
}
|
|
531
|
+
return stop();
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
});
|
|
535
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { OWNER } from "../originalOwner.js";
|
|
2
|
+
|
|
3
|
+
export interface FailureForwarder {
|
|
4
|
+
forward(error: unknown): object | null;
|
|
5
|
+
}
|
|
6
|
+
/** Same original owner around each actor continuation; no new timer or origin. */
|
|
7
|
+
export function owned<T>(
|
|
8
|
+
work: () => T | PromiseLike<T>,
|
|
9
|
+
failureControl: FailureForwarder | null = null,
|
|
10
|
+
): Promise<T> {
|
|
11
|
+
OWNER.check();
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
let done = false,
|
|
14
|
+
remove: (() => void) | null = null;
|
|
15
|
+
const finish = (ok: boolean, value: unknown) => {
|
|
16
|
+
if (done) return;
|
|
17
|
+
done = true;
|
|
18
|
+
if (remove) remove();
|
|
19
|
+
if (ok) resolve(value as T);
|
|
20
|
+
else reject(value);
|
|
21
|
+
};
|
|
22
|
+
const retire = () => finish(false, Error("INITIAL_ACTOR_STOP"));
|
|
23
|
+
remove = OWNER.subscribe(retire);
|
|
24
|
+
if (done) {
|
|
25
|
+
remove();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
let pending: T | PromiseLike<T>;
|
|
29
|
+
try {
|
|
30
|
+
OWNER.check();
|
|
31
|
+
pending = work();
|
|
32
|
+
} catch {
|
|
33
|
+
finish(false, Error("INITIAL_ACTOR_STOP"));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
void Promise.resolve(pending).then(
|
|
37
|
+
(value) => {
|
|
38
|
+
if (done) return;
|
|
39
|
+
try {
|
|
40
|
+
OWNER.check();
|
|
41
|
+
finish(true, value);
|
|
42
|
+
} catch {
|
|
43
|
+
retire();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
(error: unknown) => {
|
|
47
|
+
if (done) return;
|
|
48
|
+
try {
|
|
49
|
+
OWNER.check();
|
|
50
|
+
const forwarded = failureControl
|
|
51
|
+
? failureControl.forward(error)
|
|
52
|
+
: null;
|
|
53
|
+
finish(
|
|
54
|
+
false,
|
|
55
|
+
forwarded === null ? Error("INITIAL_ACTOR_STOP") : forwarded,
|
|
56
|
+
);
|
|
57
|
+
} catch {
|
|
58
|
+
retire();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
}
|
package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { it } from "vitest";
|
|
3
|
+
import { declaredInputs } from "../test-fixtures/attachEntries.js";
|
|
4
|
+
import { metrics, data } from "../test-fixtures/attachScenarioBarriers.js";
|
|
5
|
+
import {
|
|
6
|
+
prepareRenewalPriceReplacementV2,
|
|
7
|
+
prepareRenewalScheduleAttachmentV2,
|
|
8
|
+
constructRenewalScheduleAttachmentReceiptV2,
|
|
9
|
+
} from "../../../renewalV2/index.js";
|
|
10
|
+
import { admitInitialOutput } from "../recovery/material.js";
|
|
11
|
+
|
|
12
|
+
it("initial ACK whole DATA wrapper enforces exact receipt slots, bounds and freezing", async () => {
|
|
13
|
+
const raw = declaredInputs("INITIAL-ACK"),
|
|
14
|
+
prepared = await prepareRenewalPriceReplacementV2(
|
|
15
|
+
raw.original.attachRequest.preparation,
|
|
16
|
+
);
|
|
17
|
+
const request = await prepareRenewalScheduleAttachmentV2({
|
|
18
|
+
prepared,
|
|
19
|
+
apiVersion: raw.original.attachRequest.apiVersion,
|
|
20
|
+
attachKey: raw.original.attachRequest.attachKey,
|
|
21
|
+
firstDispatchedAt: raw.original.attachRequest.firstDispatchedAt,
|
|
22
|
+
});
|
|
23
|
+
const receipt = await constructRenewalScheduleAttachmentReceiptV2({
|
|
24
|
+
attachRequest: raw.original.attachRequest,
|
|
25
|
+
actualDispatch: {
|
|
26
|
+
scope: request.scope,
|
|
27
|
+
apiVersion: request.apiVersion,
|
|
28
|
+
method: request.method,
|
|
29
|
+
path: request.path,
|
|
30
|
+
payload: request.payload,
|
|
31
|
+
key: request.key,
|
|
32
|
+
firstDispatchedAt: request.firstDispatchedAt,
|
|
33
|
+
},
|
|
34
|
+
providerSnapshot: raw.post,
|
|
35
|
+
});
|
|
36
|
+
const admitted = admitInitialOutput(receipt, prepared, request);
|
|
37
|
+
assert(Object.isFrozen(admitted));
|
|
38
|
+
assert(Object.isFrozen(data(admitted).receipt));
|
|
39
|
+
const fit = metrics(admitted);
|
|
40
|
+
assert(
|
|
41
|
+
fit.chars <= 500000 &&
|
|
42
|
+
fit.bytes <= 500000 &&
|
|
43
|
+
fit.nodes <= 10000 &&
|
|
44
|
+
fit.depth <= 40,
|
|
45
|
+
);
|
|
46
|
+
// DATA-helper boundary only: a caller's extended receipt-shaped input is not C3 custody.
|
|
47
|
+
const overflow = { ...receipt, opaque: "x".repeat(500001) };
|
|
48
|
+
assert(
|
|
49
|
+
metrics({
|
|
50
|
+
status: "attach_acknowledged",
|
|
51
|
+
operationalAuthority: false,
|
|
52
|
+
receipt: overflow,
|
|
53
|
+
}).chars > 500000,
|
|
54
|
+
);
|
|
55
|
+
assert.throws(() => admitInitialOutput(overflow, prepared, request));
|
|
56
|
+
const wrong = {
|
|
57
|
+
...receipt,
|
|
58
|
+
logicalBinding: "renewal:v2:sha256:" + "0".repeat(64),
|
|
59
|
+
};
|
|
60
|
+
assert.throws(() => admitInitialOutput(wrong, prepared, request));
|
|
61
|
+
});
|