@fantastic.dev/better-stripe 0.90.0 → 0.92.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 +12 -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 +14 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js +444 -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/ownedContinuation.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js +61 -0
- package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.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 +383 -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 +216 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js +11 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.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 +84 -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/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +26 -8
- package/docs/renewal-material-observation.md +58 -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 +586 -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/ownedContinuation.ts +56 -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 +487 -0
- package/src/client/billing/renewalAttach/internal/observation/capture.ts +251 -0
- package/src/client/billing/renewalAttach/internal/observation/configureAcknowledgement.ts +20 -0
- package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +36 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +48 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +44 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +34 -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 +107 -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 +537 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +325 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +38 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +471 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +587 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +115 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +141 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +74 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +79 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +207 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +494 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +452 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +88 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +170 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +99 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +411 -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,207 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { it, vi } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
configureWriteFixture,
|
|
5
|
+
type ConfigureWriteFixture,
|
|
6
|
+
} from "../test-fixtures/configureWriteOperation.js";
|
|
7
|
+
import { data } from "../test-fixtures/configurePreflightControls.js";
|
|
8
|
+
import {
|
|
9
|
+
assertConfigureACK,
|
|
10
|
+
assertProviderFailure,
|
|
11
|
+
} from "../test-fixtures/configureWriteAssertions.js";
|
|
12
|
+
|
|
13
|
+
for (const name of [
|
|
14
|
+
"dispatch-send",
|
|
15
|
+
"dispatch-ack",
|
|
16
|
+
"response-send",
|
|
17
|
+
"response-ack",
|
|
18
|
+
"receipt-send",
|
|
19
|
+
"receipt-ack",
|
|
20
|
+
] as const)
|
|
21
|
+
it("writer waits for BOTH actual send and ACK: " + name, async () => {
|
|
22
|
+
const h = await configureWriteFixture(name),
|
|
23
|
+
pending = h.captureWriter().invoke();
|
|
24
|
+
const observed = pending.then(
|
|
25
|
+
(value: unknown) => ({ ok: true as const, value }),
|
|
26
|
+
(error: unknown) => ({ ok: false as const, error }),
|
|
27
|
+
);
|
|
28
|
+
try {
|
|
29
|
+
await h.writeGates.entered(name, pending);
|
|
30
|
+
assert.equal(
|
|
31
|
+
h.writeState.calls.filter((row) => row.method === "POST").length,
|
|
32
|
+
name.startsWith("dispatch") ? 0 : 1,
|
|
33
|
+
);
|
|
34
|
+
assert.equal(h.writeState.explicitC9, name.startsWith("receipt") ? 1 : 0);
|
|
35
|
+
const sequence = name.startsWith("dispatch")
|
|
36
|
+
? 1
|
|
37
|
+
: name.startsWith("response")
|
|
38
|
+
? 2
|
|
39
|
+
: 3;
|
|
40
|
+
assert.equal(h.writeState.records.length, sequence);
|
|
41
|
+
assert.equal(
|
|
42
|
+
h.writeState.trace.includes("ack:" + String(sequence)),
|
|
43
|
+
name.endsWith("send"),
|
|
44
|
+
);
|
|
45
|
+
h.writeGates.release(name);
|
|
46
|
+
const out = await observed;
|
|
47
|
+
assert.equal(out.ok, true);
|
|
48
|
+
if (out.ok) assertConfigureACK(h, out.value);
|
|
49
|
+
} finally {
|
|
50
|
+
h.writeGates.release(name);
|
|
51
|
+
await observed;
|
|
52
|
+
await h.cleanup();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
for (const name of ["wrong-ack", "duplicate-ack"] as const)
|
|
57
|
+
it(
|
|
58
|
+
"live dispatch ACK failure reports actual trusted NOT_STARTED: " + name,
|
|
59
|
+
async () => {
|
|
60
|
+
const h = await configureWriteFixture(name);
|
|
61
|
+
try {
|
|
62
|
+
assert.deepEqual(await h.captureWriter().invoke(), {
|
|
63
|
+
status: "not_dispatched",
|
|
64
|
+
reason: "post_not_started",
|
|
65
|
+
operationalAuthority: false,
|
|
66
|
+
});
|
|
67
|
+
assert.equal(h.writeState.records.length, 1);
|
|
68
|
+
assert.equal(
|
|
69
|
+
h.writeState.calls.filter((row) => row.method === "POST").length,
|
|
70
|
+
0,
|
|
71
|
+
);
|
|
72
|
+
assert.equal(h.writeState.explicitC9, 0);
|
|
73
|
+
assert.equal(h.OWNER.check().retired, false);
|
|
74
|
+
} finally {
|
|
75
|
+
await h.cleanup();
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
it("safe response2 is retained before actualC9 identity refusal", async () => {
|
|
81
|
+
const h = await configureWriteFixture("wrong-c9");
|
|
82
|
+
try {
|
|
83
|
+
assert.deepEqual(await h.captureWriter().invoke(), {
|
|
84
|
+
status: "configure_unknown",
|
|
85
|
+
reason: "post_unverified",
|
|
86
|
+
operationalAuthority: false,
|
|
87
|
+
});
|
|
88
|
+
assert.equal(h.writeState.records.length, 2);
|
|
89
|
+
assert.equal(h.writeState.explicitC9, 1);
|
|
90
|
+
assert.equal(h.writeState.compilerC9, 0);
|
|
91
|
+
assert.equal(
|
|
92
|
+
h.writeState.calls.filter((row) => row.method === "POST").length,
|
|
93
|
+
1,
|
|
94
|
+
);
|
|
95
|
+
assert.deepEqual(
|
|
96
|
+
data(h.writeState.records[1]!.data).body,
|
|
97
|
+
h.write.response,
|
|
98
|
+
);
|
|
99
|
+
} finally {
|
|
100
|
+
await h.cleanup();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
for (const fault of ["output-publication", "receipt-ack"] as const)
|
|
105
|
+
it(
|
|
106
|
+
"known actualC9 closes old unknown ancestor before failed " + fault,
|
|
107
|
+
async () => {
|
|
108
|
+
let h: ConfigureWriteFixture | undefined,
|
|
109
|
+
faults = 0;
|
|
110
|
+
if (fault === "output-publication")
|
|
111
|
+
vi.doMock("./output.js", async () => {
|
|
112
|
+
const actual =
|
|
113
|
+
await vi.importActual<typeof import("./output.js")>("./output.js");
|
|
114
|
+
return {
|
|
115
|
+
...actual,
|
|
116
|
+
admitConfigureACK(
|
|
117
|
+
...args: Parameters<typeof actual.admitConfigureACK>
|
|
118
|
+
) {
|
|
119
|
+
const admitted = Reflect.apply(
|
|
120
|
+
actual.admitConfigureACK,
|
|
121
|
+
actual,
|
|
122
|
+
args,
|
|
123
|
+
) as ReturnType<typeof actual.admitConfigureACK>;
|
|
124
|
+
assert(h);
|
|
125
|
+
assert.deepEqual(admitted, h.expectedACK);
|
|
126
|
+
faults++;
|
|
127
|
+
// Deliberate component abort after genuine admission, not a fabricated overflow claim.
|
|
128
|
+
throw Error("TEST_PUBLICATION_ABORT_AFTER_ACTUAL_ACK_ADMISSION");
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
else
|
|
133
|
+
vi.doMock("../c10/configureEvents.js", async () => {
|
|
134
|
+
const actual = await vi.importActual<
|
|
135
|
+
typeof import("../c10/configureEvents.js")
|
|
136
|
+
>("../c10/configureEvents.js");
|
|
137
|
+
return {
|
|
138
|
+
...actual,
|
|
139
|
+
createConfigureEventCompiler(
|
|
140
|
+
...args: Parameters<typeof actual.createConfigureEventCompiler>
|
|
141
|
+
) {
|
|
142
|
+
const options = data(args[1]),
|
|
143
|
+
send = options.send;
|
|
144
|
+
assert.equal(typeof send, "function");
|
|
145
|
+
const injected = {
|
|
146
|
+
...options,
|
|
147
|
+
send(record: unknown, acknowledge: (value: unknown) => void) {
|
|
148
|
+
const sequence = data(record).sequence;
|
|
149
|
+
const ack =
|
|
150
|
+
sequence === 3
|
|
151
|
+
? (value: unknown) => {
|
|
152
|
+
faults++;
|
|
153
|
+
acknowledge({ ...data(value), binding: "wrong" });
|
|
154
|
+
}
|
|
155
|
+
: acknowledge;
|
|
156
|
+
return Reflect.apply(
|
|
157
|
+
send as (...values: unknown[]) => unknown,
|
|
158
|
+
options,
|
|
159
|
+
[record, ack],
|
|
160
|
+
);
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
return Reflect.apply(
|
|
164
|
+
actual.createConfigureEventCompiler,
|
|
165
|
+
actual,
|
|
166
|
+
[args[0], injected],
|
|
167
|
+
) as ReturnType<typeof actual.createConfigureEventCompiler>;
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
try {
|
|
172
|
+
h = await configureWriteFixture("ack-closes-ancestor");
|
|
173
|
+
const original = await h
|
|
174
|
+
.captureWriter()
|
|
175
|
+
.invoke()
|
|
176
|
+
.then(
|
|
177
|
+
() => assert.fail("EXPECTED_A_UNKNOWN"),
|
|
178
|
+
(error: unknown) => error,
|
|
179
|
+
);
|
|
180
|
+
assertProviderFailure(h, original, "post");
|
|
181
|
+
assert.deepEqual(await h.captureReplayB().invoke(), {
|
|
182
|
+
status: "configure_unknown",
|
|
183
|
+
reason: "post_unverified",
|
|
184
|
+
operationalAuthority: false,
|
|
185
|
+
});
|
|
186
|
+
assert.equal(faults, 1);
|
|
187
|
+
assert.equal(h.replayStates.B.explicitC9, 1);
|
|
188
|
+
assert.equal(
|
|
189
|
+
h.replayStates.B.records.length,
|
|
190
|
+
fault === "receipt-ack" ? 3 : 2,
|
|
191
|
+
);
|
|
192
|
+
assert.equal(h.OWNER.check().retired, false);
|
|
193
|
+
assert.deepEqual(await h.captureReplayC().invoke(), {
|
|
194
|
+
status: "not_dispatched",
|
|
195
|
+
reason: "prior_attempt_not_replayable",
|
|
196
|
+
operationalAuthority: false,
|
|
197
|
+
});
|
|
198
|
+
assert.equal(h.replayStates.C.calls.length, 0);
|
|
199
|
+
assert.equal(h.replayStates.C.pairLoads, 0);
|
|
200
|
+
assert.deepEqual(h.expectedRecord.attachReceipt, h.acknowledgement);
|
|
201
|
+
} finally {
|
|
202
|
+
if (h) await h.cleanup();
|
|
203
|
+
vi.doUnmock("./output.js");
|
|
204
|
+
vi.doUnmock("../c10/configureEvents.js");
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
);
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { rejectProxyJSON } from "../acquisition/rawWireSource.js";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
4
|
+
import {
|
|
5
|
+
objectNode,
|
|
6
|
+
scalarNode,
|
|
7
|
+
encode,
|
|
8
|
+
materialize,
|
|
9
|
+
freeze,
|
|
10
|
+
type Node,
|
|
11
|
+
closed,
|
|
12
|
+
} from "../material/nodeKernel.js";
|
|
13
|
+
import { equal } from "../../../renewalAggregate/shared.js";
|
|
14
|
+
import { assertRequest, need, stop, seven } from "./request.js";
|
|
15
|
+
import { expectedSlots } from "../preflight/relations.js";
|
|
16
|
+
import { recordFamilies } from "../preflight/grammar.js";
|
|
17
|
+
import type { PreflightRecord } from "../preflight/grammar.js";
|
|
18
|
+
import type {
|
|
19
|
+
ProjectedRenewalConfigurationV2,
|
|
20
|
+
RenewalConfigurationReceiptV2,
|
|
21
|
+
ConstructRenewalConfigurationReceiptV2Options,
|
|
22
|
+
} from "../../../renewalV2/index.js";
|
|
23
|
+
import type { Diagnostics } from "../operations/providerFailure.js";
|
|
24
|
+
|
|
25
|
+
const requestFamilies = Object.fromEntries(
|
|
26
|
+
Object.entries(recordFamilies)
|
|
27
|
+
.filter(([key]) => key.startsWith("/request/"))
|
|
28
|
+
.map(([key, family]) => [key.slice(8), family]),
|
|
29
|
+
);
|
|
30
|
+
const has = (x: object, key: string) =>
|
|
31
|
+
Object.prototype.hasOwnProperty.call(x, key);
|
|
32
|
+
const pointer = (key: string) => key.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
33
|
+
/** Private full DATA walker. Only the fixed lexical entry points choose these tables. */
|
|
34
|
+
function capture(
|
|
35
|
+
raw: unknown,
|
|
36
|
+
families: Readonly<Record<string, string>>,
|
|
37
|
+
expected?: Readonly<Record<string, string>>,
|
|
38
|
+
) {
|
|
39
|
+
const active = new Set<object>(),
|
|
40
|
+
found = new Set<string>();
|
|
41
|
+
let count = 0;
|
|
42
|
+
function walk(x: unknown, path: string, depth: number): Node {
|
|
43
|
+
need(++count <= 10000 && depth <= 40 && !types.isProxy(x));
|
|
44
|
+
if (has(families, path)) {
|
|
45
|
+
need(
|
|
46
|
+
typeof x === "string" &&
|
|
47
|
+
new RegExp("^" + families[path] + ":v2:sha256:[0-9a-f]{64}$").test(x),
|
|
48
|
+
);
|
|
49
|
+
if (expected) need(x === expected[path]);
|
|
50
|
+
found.add(path);
|
|
51
|
+
return scalarNode(x);
|
|
52
|
+
}
|
|
53
|
+
if (x === null || typeof x !== "object") {
|
|
54
|
+
requiredJSONSnapshot(x);
|
|
55
|
+
return scalarNode(x);
|
|
56
|
+
}
|
|
57
|
+
need(!active.has(x));
|
|
58
|
+
active.add(x);
|
|
59
|
+
const array = Array.isArray(x),
|
|
60
|
+
proto = Object.getPrototypeOf(x);
|
|
61
|
+
need(
|
|
62
|
+
array
|
|
63
|
+
? proto === Array.prototype
|
|
64
|
+
: proto === Object.prototype || proto === null,
|
|
65
|
+
);
|
|
66
|
+
const keys = Reflect.ownKeys(x);
|
|
67
|
+
need(keys.length <= 10001);
|
|
68
|
+
const length = array ? Object.getOwnPropertyDescriptor(x, "length") : null,
|
|
69
|
+
n: unknown = length?.value;
|
|
70
|
+
if (array)
|
|
71
|
+
need(
|
|
72
|
+
length &&
|
|
73
|
+
"value" in length &&
|
|
74
|
+
typeof n === "number" &&
|
|
75
|
+
Number.isSafeInteger(n) &&
|
|
76
|
+
n >= 0 &&
|
|
77
|
+
n <= 10000,
|
|
78
|
+
);
|
|
79
|
+
const entries: [string, Node][] = [];
|
|
80
|
+
for (const key of keys) {
|
|
81
|
+
need(typeof key === "string");
|
|
82
|
+
if (array && key === "length") continue;
|
|
83
|
+
const d = Object.getOwnPropertyDescriptor(x, key);
|
|
84
|
+
need(d && d.enumerable && "value" in d);
|
|
85
|
+
requiredJSONSnapshot(key);
|
|
86
|
+
requiredJSONSnapshot({ [key]: d.value === null ? null : true });
|
|
87
|
+
need(
|
|
88
|
+
!array ||
|
|
89
|
+
(/^(0|[1-9][0-9]*)$/.test(key) &&
|
|
90
|
+
typeof n === "number" &&
|
|
91
|
+
Number(key) < n),
|
|
92
|
+
);
|
|
93
|
+
entries.push([key, walk(d.value, path + "/" + pointer(key), depth + 1)]);
|
|
94
|
+
}
|
|
95
|
+
active.delete(x);
|
|
96
|
+
if (array) {
|
|
97
|
+
need(entries.length === n);
|
|
98
|
+
entries.sort(([a], [b]) => Number(a) - Number(b));
|
|
99
|
+
return Object.freeze({
|
|
100
|
+
kind: "array" as const,
|
|
101
|
+
entries: Object.freeze(entries.map((e) => Object.freeze(e))),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return objectNode(entries);
|
|
105
|
+
}
|
|
106
|
+
const node = walk(raw, "", 0);
|
|
107
|
+
need(found.size === Object.keys(families).length);
|
|
108
|
+
encode(node);
|
|
109
|
+
return freeze(materialize(node));
|
|
110
|
+
}
|
|
111
|
+
function requestExpected(r: ProjectedRenewalConfigurationV2) {
|
|
112
|
+
return {
|
|
113
|
+
"/logicalBinding": r.logicalBinding,
|
|
114
|
+
"/attachReceiptBinding": r.attachReceiptBinding,
|
|
115
|
+
"/baselineBinding": r.baselineBinding,
|
|
116
|
+
"/defaultSettingsBinding": r.defaultSettingsBinding,
|
|
117
|
+
"/requestIdentity/binding": r.requestIdentity.binding,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export function captureConfigureRequest(
|
|
121
|
+
raw: unknown,
|
|
122
|
+
): ProjectedRenewalConfigurationV2 {
|
|
123
|
+
try {
|
|
124
|
+
const value = capture(raw, requestFamilies);
|
|
125
|
+
assertRequest(value);
|
|
126
|
+
return value;
|
|
127
|
+
} catch {
|
|
128
|
+
return stop();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function failure(
|
|
132
|
+
phase: "read" | "post",
|
|
133
|
+
resource: string,
|
|
134
|
+
ordinal: number,
|
|
135
|
+
request: ProjectedRenewalConfigurationV2,
|
|
136
|
+
diagnostics: Diagnostics,
|
|
137
|
+
) {
|
|
138
|
+
rejectProxyJSON(request);
|
|
139
|
+
rejectProxyJSON(diagnostics);
|
|
140
|
+
assertRequest(request);
|
|
141
|
+
need(
|
|
142
|
+
(phase === "read" &&
|
|
143
|
+
["subscription", "price", "customer", "coupon", "schedule"].includes(
|
|
144
|
+
resource,
|
|
145
|
+
)) ||
|
|
146
|
+
(phase === "post" && resource === "configure"),
|
|
147
|
+
);
|
|
148
|
+
need(
|
|
149
|
+
Number.isSafeInteger(ordinal) &&
|
|
150
|
+
ordinal >= 1 &&
|
|
151
|
+
ordinal <= (phase === "read" ? 44 : 45),
|
|
152
|
+
);
|
|
153
|
+
need(!types.isProxy(diagnostics));
|
|
154
|
+
const d = closed(
|
|
155
|
+
diagnostics,
|
|
156
|
+
[],
|
|
157
|
+
["type", "code", "statusCode", "requestId"],
|
|
158
|
+
);
|
|
159
|
+
for (const [key, value] of Object.entries(d))
|
|
160
|
+
need(
|
|
161
|
+
key === "statusCode"
|
|
162
|
+
? typeof value === "number" &&
|
|
163
|
+
Number.isInteger(value) &&
|
|
164
|
+
value >= 100 &&
|
|
165
|
+
value <= 599
|
|
166
|
+
: typeof value === "string" && value.length >= 1 && value.length <= 255,
|
|
167
|
+
);
|
|
168
|
+
const families = Object.fromEntries(
|
|
169
|
+
Object.entries(requestFamilies).map(([k, v]) => ["/request" + k, v]),
|
|
170
|
+
);
|
|
171
|
+
const expected = Object.fromEntries(
|
|
172
|
+
Object.entries(requestExpected(request)).map(([k, v]) => [
|
|
173
|
+
"/request" + k,
|
|
174
|
+
v,
|
|
175
|
+
]),
|
|
176
|
+
);
|
|
177
|
+
return capture(
|
|
178
|
+
{
|
|
179
|
+
category: "provider_rejected",
|
|
180
|
+
phase,
|
|
181
|
+
resource,
|
|
182
|
+
ordinal,
|
|
183
|
+
request,
|
|
184
|
+
diagnostics,
|
|
185
|
+
outcome: "unknown",
|
|
186
|
+
operationalAuthority: false,
|
|
187
|
+
},
|
|
188
|
+
families,
|
|
189
|
+
expected,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
function ack(
|
|
193
|
+
originalRecord: PreflightRecord,
|
|
194
|
+
rawReceipt: ConstructRenewalConfigurationReceiptV2Options,
|
|
195
|
+
actualReceipt: RenewalConfigurationReceiptV2,
|
|
196
|
+
) {
|
|
197
|
+
rejectProxyJSON(originalRecord);
|
|
198
|
+
rejectProxyJSON(rawReceipt);
|
|
199
|
+
rejectProxyJSON(actualReceipt);
|
|
200
|
+
need(
|
|
201
|
+
!types.isProxy(originalRecord) &&
|
|
202
|
+
!types.isProxy(rawReceipt) &&
|
|
203
|
+
!types.isProxy(actualReceipt),
|
|
204
|
+
);
|
|
205
|
+
closed(originalRecord, [
|
|
206
|
+
"configuration",
|
|
207
|
+
"request",
|
|
208
|
+
"attachReceipt",
|
|
209
|
+
"originalBundle",
|
|
210
|
+
]);
|
|
211
|
+
closed(rawReceipt, [
|
|
212
|
+
"configuration",
|
|
213
|
+
"actualDispatch",
|
|
214
|
+
"providerSnapshot",
|
|
215
|
+
"transport",
|
|
216
|
+
]);
|
|
217
|
+
closed(rawReceipt.actualDispatch, [
|
|
218
|
+
"scope",
|
|
219
|
+
"apiVersion",
|
|
220
|
+
"method",
|
|
221
|
+
"path",
|
|
222
|
+
"payload",
|
|
223
|
+
"key",
|
|
224
|
+
"firstDispatchedAt",
|
|
225
|
+
]);
|
|
226
|
+
assertRequest(originalRecord.request);
|
|
227
|
+
const r = actualReceipt;
|
|
228
|
+
closed(
|
|
229
|
+
r,
|
|
230
|
+
[
|
|
231
|
+
"version",
|
|
232
|
+
"stage",
|
|
233
|
+
"scope",
|
|
234
|
+
"verification",
|
|
235
|
+
"apiVersion",
|
|
236
|
+
"logicalBinding",
|
|
237
|
+
"request",
|
|
238
|
+
"attachReceiptBinding",
|
|
239
|
+
"scheduleId",
|
|
240
|
+
"subscriptionId",
|
|
241
|
+
"customerAccountId",
|
|
242
|
+
"billingCustomerId",
|
|
243
|
+
"livemode",
|
|
244
|
+
"providerSnapshot",
|
|
245
|
+
"transport",
|
|
246
|
+
"providerSnapshotBinding",
|
|
247
|
+
"binding",
|
|
248
|
+
],
|
|
249
|
+
["defaultSettingsBinding"],
|
|
250
|
+
);
|
|
251
|
+
need(
|
|
252
|
+
r.version === 2 &&
|
|
253
|
+
r.stage === "configure_acknowledged" &&
|
|
254
|
+
r.scope === "platform" &&
|
|
255
|
+
r.verification === "owned_response_only",
|
|
256
|
+
);
|
|
257
|
+
need(
|
|
258
|
+
equal(rawReceipt.configuration, originalRecord.configuration) &&
|
|
259
|
+
equal(rawReceipt.actualDispatch, seven(originalRecord.request)) &&
|
|
260
|
+
equal(r.request, originalRecord.request) &&
|
|
261
|
+
equal(rawReceipt.providerSnapshot, r.providerSnapshot) &&
|
|
262
|
+
equal(rawReceipt.transport, r.transport),
|
|
263
|
+
);
|
|
264
|
+
need(
|
|
265
|
+
r.apiVersion === originalRecord.request.apiVersion &&
|
|
266
|
+
r.scheduleId === originalRecord.request.scheduleId &&
|
|
267
|
+
r.scheduleId === originalRecord.attachReceipt.scheduleId &&
|
|
268
|
+
r.subscriptionId === originalRecord.attachReceipt.subscriptionId &&
|
|
269
|
+
r.customerAccountId === originalRecord.attachReceipt.customerAccountId &&
|
|
270
|
+
r.livemode === originalRecord.attachReceipt.livemode &&
|
|
271
|
+
r.billingCustomerId ===
|
|
272
|
+
originalRecord.originalBundle.wireBillingCustomer.id,
|
|
273
|
+
);
|
|
274
|
+
need(
|
|
275
|
+
originalRecord.request.attachReceiptBinding ===
|
|
276
|
+
originalRecord.attachReceipt.binding &&
|
|
277
|
+
originalRecord.attachReceipt.logicalBinding ===
|
|
278
|
+
originalRecord.request.logicalBinding &&
|
|
279
|
+
originalRecord.attachReceipt.request.logicalBinding ===
|
|
280
|
+
originalRecord.request.logicalBinding,
|
|
281
|
+
);
|
|
282
|
+
requiredJSONSnapshot(rawReceipt);
|
|
283
|
+
const t = closed(rawReceipt.transport, ["status"], ["requestId"]);
|
|
284
|
+
need(
|
|
285
|
+
typeof t.status === "number" &&
|
|
286
|
+
Number.isInteger(t.status) &&
|
|
287
|
+
t.status >= 200 &&
|
|
288
|
+
t.status < 300,
|
|
289
|
+
);
|
|
290
|
+
if (has(t, "requestId"))
|
|
291
|
+
need(
|
|
292
|
+
typeof t.requestId === "string" &&
|
|
293
|
+
t.requestId.length >= 1 &&
|
|
294
|
+
t.requestId.length <= 255,
|
|
295
|
+
);
|
|
296
|
+
const present = has(rawReceipt.providerSnapshot, "default_settings");
|
|
297
|
+
need(has(r, "defaultSettingsBinding") === present);
|
|
298
|
+
const families: Record<string, string> = Object.fromEntries(
|
|
299
|
+
Object.entries(recordFamilies).map(([k, v]) => ["/originalRecord" + k, v]),
|
|
300
|
+
);
|
|
301
|
+
const expected: Record<string, string> = Object.fromEntries(
|
|
302
|
+
Object.entries(
|
|
303
|
+
expectedSlots(
|
|
304
|
+
originalRecord.request,
|
|
305
|
+
originalRecord.attachReceipt,
|
|
306
|
+
false,
|
|
307
|
+
),
|
|
308
|
+
).map(([k, v]) => ["/originalRecord" + k, v]),
|
|
309
|
+
);
|
|
310
|
+
for (const [k, family] of Object.entries(requestFamilies)) {
|
|
311
|
+
families["/receipt/request" + k] = family;
|
|
312
|
+
expected["/receipt/request" + k] = requestExpected(originalRecord.request)[
|
|
313
|
+
k as keyof ReturnType<typeof requestExpected>
|
|
314
|
+
];
|
|
315
|
+
}
|
|
316
|
+
for (const [key, family, value] of [
|
|
317
|
+
["logicalBinding", "renewal", originalRecord.request.logicalBinding],
|
|
318
|
+
[
|
|
319
|
+
"attachReceiptBinding",
|
|
320
|
+
"renewal-attach-receipt",
|
|
321
|
+
originalRecord.attachReceipt.binding,
|
|
322
|
+
],
|
|
323
|
+
[
|
|
324
|
+
"providerSnapshotBinding",
|
|
325
|
+
"renewal-configured-baseline",
|
|
326
|
+
r.providerSnapshotBinding,
|
|
327
|
+
],
|
|
328
|
+
["binding", "renewal-configure-receipt", r.binding],
|
|
329
|
+
]) {
|
|
330
|
+
families["/receipt/" + key] = family;
|
|
331
|
+
expected["/receipt/" + key] = value;
|
|
332
|
+
}
|
|
333
|
+
if (present) {
|
|
334
|
+
need(typeof r.defaultSettingsBinding === "string");
|
|
335
|
+
families["/receipt/defaultSettingsBinding"] = "renewal-configured-defaults";
|
|
336
|
+
expected["/receipt/defaultSettingsBinding"] = r.defaultSettingsBinding;
|
|
337
|
+
}
|
|
338
|
+
need(Object.keys(families).length === (present ? 19 : 18));
|
|
339
|
+
return capture(
|
|
340
|
+
{
|
|
341
|
+
status: "configure_acknowledged",
|
|
342
|
+
originalRecord,
|
|
343
|
+
rawReceipt,
|
|
344
|
+
receipt: r,
|
|
345
|
+
operationalAuthority: false,
|
|
346
|
+
},
|
|
347
|
+
families,
|
|
348
|
+
expected,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
/** Fixed control output has no raw values and no operational capability. */
|
|
352
|
+
export function configureControl(
|
|
353
|
+
status: "not_dispatched" | "configure_unknown",
|
|
354
|
+
reason: string,
|
|
355
|
+
) {
|
|
356
|
+
return Object.freeze({ status, reason, operationalAuthority: false });
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export function admitConfigureFailure(...args: Parameters<typeof failure>) {
|
|
360
|
+
try {
|
|
361
|
+
return failure(...args);
|
|
362
|
+
} catch {
|
|
363
|
+
return stop();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
export function admitConfigureACK(...args: Parameters<typeof ack>) {
|
|
367
|
+
try {
|
|
368
|
+
return ack(...args);
|
|
369
|
+
} catch {
|
|
370
|
+
return stop();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { OWNER } from "../originalOwner.js";
|
|
2
|
+
|
|
3
|
+
/** Same original Owner subscription, with FIRST continuation guards on both outcomes. */
|
|
4
|
+
export function owned<T>(work: () => T | PromiseLike<T>): Promise<T> {
|
|
5
|
+
OWNER.check();
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
let done = false,
|
|
8
|
+
remove: (() => void) | null = null;
|
|
9
|
+
const finish = (ok: boolean, value: unknown) => {
|
|
10
|
+
if (done) return;
|
|
11
|
+
done = true;
|
|
12
|
+
remove?.();
|
|
13
|
+
if (ok) resolve(value as T);
|
|
14
|
+
else reject(value);
|
|
15
|
+
};
|
|
16
|
+
const retire = () => finish(false, Error("CONFIGURE_WRITE_STOP"));
|
|
17
|
+
remove = OWNER.subscribe(retire);
|
|
18
|
+
if (done) {
|
|
19
|
+
remove();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let pending: T | PromiseLike<T>;
|
|
23
|
+
try {
|
|
24
|
+
OWNER.check();
|
|
25
|
+
pending = work();
|
|
26
|
+
} catch (error) {
|
|
27
|
+
try {
|
|
28
|
+
OWNER.check();
|
|
29
|
+
finish(false, error);
|
|
30
|
+
} catch {
|
|
31
|
+
retire();
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
void Promise.resolve(pending).then(
|
|
36
|
+
(value) => {
|
|
37
|
+
if (done) return;
|
|
38
|
+
try {
|
|
39
|
+
OWNER.check();
|
|
40
|
+
finish(true, value);
|
|
41
|
+
} catch {
|
|
42
|
+
retire();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
(error) => {
|
|
46
|
+
if (done) return;
|
|
47
|
+
try {
|
|
48
|
+
OWNER.check();
|
|
49
|
+
finish(false, error);
|
|
50
|
+
} catch {
|
|
51
|
+
retire();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
}
|