@fantastic.dev/better-stripe 0.101.0 → 0.102.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/producer/classOwnedActionRoot.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +16 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.js +117 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts +53 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js +198 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts +959 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.js +115 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +4 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
- package/dist/component/earnings/triggers.d.ts +16 -16
- 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 +45 -3
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +21 -0
- package/src/client/billing/renewalAttach/internal/producer/configureAdmission.ts +179 -0
- package/src/client/billing/renewalAttach/internal/producer/configureJournalData.ts +248 -0
- package/src/client/billing/renewalAttach/internal/producer/configureLineage.ts +166 -0
- package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +13 -0
- package/src/client/billing/renewalAttach/internal/producer/lineageAuthority.ts +2 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureAdmission.integration.test.ts +203 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureControls.integration.test.ts +566 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +316 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +61 -3
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { consumeInitialClassReservation } from "../operationJournal.js";
|
|
2
|
+
import { readInitialLineage } from "./lineageAuthority.js";
|
|
3
|
+
import { readAttachAcknowledgementForLineage } from "./attachAcknowledgement.js";
|
|
4
|
+
import { ownerForInitialLineage } from "./ownerFactory.js";
|
|
5
|
+
import { journalWorkForInitialLineage } from "./journalWorkFactory.js";
|
|
6
|
+
import { checkConfigureJournalAssociation } from "./classOwnedActionRoot.js";
|
|
7
|
+
import { captureConfigureSource } from "../c10/eventCapture.js";
|
|
8
|
+
import { canonicalInitialBasis } from "../../../../../shared/renewalOperationJournal.js";
|
|
9
|
+
import { closed } from "../operations/types.js";
|
|
10
|
+
import {
|
|
11
|
+
captureOperationalReservation,
|
|
12
|
+
matchConfigureDATA,
|
|
13
|
+
requireConfigure,
|
|
14
|
+
object,
|
|
15
|
+
text,
|
|
16
|
+
} from "./configureJournalData.js";
|
|
17
|
+
|
|
18
|
+
type Parent = ReturnType<typeof readInitialLineage>;
|
|
19
|
+
export type ConfigureAdmission = Readonly<{
|
|
20
|
+
owner: ReturnType<typeof ownerForInitialLineage>;
|
|
21
|
+
basisJSON: string;
|
|
22
|
+
operationalAuthority: false;
|
|
23
|
+
}>;
|
|
24
|
+
type State = {
|
|
25
|
+
phase: "pending" | "ready" | "failed";
|
|
26
|
+
parentToken: object;
|
|
27
|
+
parent: Parent;
|
|
28
|
+
owner: ConfigureAdmission["owner"];
|
|
29
|
+
acknowledgement: ReturnType<typeof readAttachAcknowledgementForLineage>;
|
|
30
|
+
consumed: ReturnType<typeof consumeInitialClassReservation>;
|
|
31
|
+
reservation: ReturnType<typeof captureOperationalReservation>;
|
|
32
|
+
parentReservation: ReturnType<typeof captureOperationalReservation>;
|
|
33
|
+
configuration: ReturnType<typeof captureConfigureSource>;
|
|
34
|
+
source: Record<string, unknown>;
|
|
35
|
+
original: Record<string, unknown>;
|
|
36
|
+
receiptJSON: string;
|
|
37
|
+
receiptBinding: string;
|
|
38
|
+
};
|
|
39
|
+
const lineages = new WeakMap<object, State>();
|
|
40
|
+
|
|
41
|
+
/** Original fresh CAS custody is spent before admission reflection or awaits. */
|
|
42
|
+
export function consumeConfigureLineage(
|
|
43
|
+
parentToken: object,
|
|
44
|
+
call: unknown,
|
|
45
|
+
journal: unknown,
|
|
46
|
+
arity: number,
|
|
47
|
+
): ConfigureAdmission {
|
|
48
|
+
const consumed = consumeInitialClassReservation(call, journal);
|
|
49
|
+
requireConfigure(arity === 2);
|
|
50
|
+
const parent = readInitialLineage(parentToken);
|
|
51
|
+
const acknowledgement = readAttachAcknowledgementForLineage(parentToken);
|
|
52
|
+
const owner = ownerForInitialLineage(parentToken);
|
|
53
|
+
owner.check();
|
|
54
|
+
checkConfigureJournalAssociation(parent.binding, consumed.binding);
|
|
55
|
+
const reservation = captureOperationalReservation(
|
|
56
|
+
consumed.reservation,
|
|
57
|
+
"configure",
|
|
58
|
+
);
|
|
59
|
+
const parentReservation = captureOperationalReservation(
|
|
60
|
+
parent.reservation,
|
|
61
|
+
"attach",
|
|
62
|
+
);
|
|
63
|
+
const original = object(JSON.parse(reservation.recordJSON));
|
|
64
|
+
const parentOriginal = object(JSON.parse(parentReservation.recordJSON));
|
|
65
|
+
const source = closed(original.configureRecord, [
|
|
66
|
+
"configuration",
|
|
67
|
+
"request",
|
|
68
|
+
"attachReceipt",
|
|
69
|
+
"originalBundle",
|
|
70
|
+
]);
|
|
71
|
+
const configuration = captureConfigureSource(source.configuration);
|
|
72
|
+
matchConfigureDATA(source.configuration, configuration);
|
|
73
|
+
const receipt = object(acknowledgement.receipt);
|
|
74
|
+
const receiptJSON = JSON.stringify(acknowledgement.receipt);
|
|
75
|
+
const receiptBinding = text(receipt.binding);
|
|
76
|
+
matchConfigureDATA(original.parentAttachment, {
|
|
77
|
+
operationId: parentReservation.operationId,
|
|
78
|
+
attemptId: parentReservation.attemptId,
|
|
79
|
+
sourcePayloadId: parentReservation.payloadId,
|
|
80
|
+
receiptBinding,
|
|
81
|
+
});
|
|
82
|
+
matchConfigureDATA(source.attachReceipt, acknowledgement.receipt);
|
|
83
|
+
matchConfigureDATA(
|
|
84
|
+
configuration.attachReceipt.attachRequest,
|
|
85
|
+
parentOriginal.attachRequest,
|
|
86
|
+
);
|
|
87
|
+
matchConfigureDATA(source.originalBundle, parentOriginal.originalBundle);
|
|
88
|
+
matchConfigureDATA(original.account, parentOriginal.account);
|
|
89
|
+
requireConfigure(original.apiVersion === parentOriginal.apiVersion);
|
|
90
|
+
const policy = object(JSON.parse(reservation.timingPolicyJSON));
|
|
91
|
+
const parentPolicy = object(JSON.parse(parentReservation.timingPolicyJSON));
|
|
92
|
+
for (const key of ["workEndWallMs", "endWallMs", "periodStart", "periodEnd"])
|
|
93
|
+
requireConfigure(policy[key] === parentPolicy[key]);
|
|
94
|
+
const basis = canonicalInitialBasis(
|
|
95
|
+
reservation.timingPolicyJSON,
|
|
96
|
+
parent.basisJSON,
|
|
97
|
+
);
|
|
98
|
+
requireConfigure(basis.basisJSON === parent.basisJSON);
|
|
99
|
+
const token = Object.freeze({
|
|
100
|
+
owner,
|
|
101
|
+
basisJSON: parent.basisJSON,
|
|
102
|
+
operationalAuthority: false as const,
|
|
103
|
+
});
|
|
104
|
+
lineages.set(token, {
|
|
105
|
+
phase: "pending",
|
|
106
|
+
parentToken,
|
|
107
|
+
parent,
|
|
108
|
+
owner,
|
|
109
|
+
acknowledgement,
|
|
110
|
+
consumed,
|
|
111
|
+
reservation,
|
|
112
|
+
parentReservation,
|
|
113
|
+
configuration,
|
|
114
|
+
source,
|
|
115
|
+
original,
|
|
116
|
+
receiptJSON,
|
|
117
|
+
receiptBinding,
|
|
118
|
+
});
|
|
119
|
+
checkConfigureLineage(token);
|
|
120
|
+
return token;
|
|
121
|
+
}
|
|
122
|
+
/** Identity checks do not select a client, create an Owner or capture an origin. */
|
|
123
|
+
export function checkConfigureLineage(token: object) {
|
|
124
|
+
const state = lineages.get(token);
|
|
125
|
+
requireConfigure(state && state.phase !== "failed");
|
|
126
|
+
requireConfigure(readInitialLineage(state.parentToken) === state.parent);
|
|
127
|
+
state.owner.check();
|
|
128
|
+
checkConfigureJournalAssociation(
|
|
129
|
+
state.parent.binding,
|
|
130
|
+
state.consumed.binding,
|
|
131
|
+
);
|
|
132
|
+
const actual = readAttachAcknowledgementForLineage(state.parentToken);
|
|
133
|
+
requireConfigure(
|
|
134
|
+
actual === state.acknowledgement &&
|
|
135
|
+
actual.receipt === state.acknowledgement.receipt &&
|
|
136
|
+
actual.output === state.acknowledgement.output,
|
|
137
|
+
);
|
|
138
|
+
requireConfigure(journalWorkForInitialLineage(state.parentToken).idle());
|
|
139
|
+
return state;
|
|
140
|
+
}
|
|
141
|
+
export function finishConfigureLineage(
|
|
142
|
+
token: ConfigureAdmission,
|
|
143
|
+
): ConfigureAdmission {
|
|
144
|
+
const state = checkConfigureLineage(token);
|
|
145
|
+
requireConfigure(state.phase === "pending");
|
|
146
|
+
state.phase = "ready";
|
|
147
|
+
return token;
|
|
148
|
+
}
|
|
149
|
+
export function closeConfigureLineage(token: object): void {
|
|
150
|
+
const state = lineages.get(token);
|
|
151
|
+
if (state) state.phase = "failed";
|
|
152
|
+
}
|
|
153
|
+
/** Trusted private consumers can only read a fully admitted original token. */
|
|
154
|
+
export function readConfigureLineage(token: object) {
|
|
155
|
+
const state = checkConfigureLineage(token);
|
|
156
|
+
requireConfigure(state.phase === "ready");
|
|
157
|
+
return Object.freeze({
|
|
158
|
+
parentToken: state.parentToken,
|
|
159
|
+
owner: state.owner,
|
|
160
|
+
parent: state.parent,
|
|
161
|
+
reservation: state.reservation,
|
|
162
|
+
originalReservation: state.consumed.reservation,
|
|
163
|
+
journal: state.consumed.journal,
|
|
164
|
+
configuration: state.configuration,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { captureConfigureAdmission } from "./configureAdmission.js";
|
|
1
2
|
import { mintInitialLineage, readInitialLineage } from "./lineageAuthority.js";
|
|
2
3
|
import { captureLiveAttachRecovery } from "./recoveryEntry.js";
|
|
3
4
|
import { readAttachAcknowledgementForLineage } from "./attachAcknowledgement.js";
|
|
@@ -28,6 +29,10 @@ export type InitialInvocationCore = Readonly<{
|
|
|
28
29
|
attachAcknowledgement(): ReturnType<
|
|
29
30
|
typeof readAttachAcknowledgementForLineage
|
|
30
31
|
>;
|
|
32
|
+
admitConfigure(
|
|
33
|
+
call: unknown,
|
|
34
|
+
journal: unknown,
|
|
35
|
+
): ReturnType<typeof captureConfigureAdmission>;
|
|
31
36
|
operationalAuthority: false;
|
|
32
37
|
}>;
|
|
33
38
|
|
|
@@ -98,6 +103,14 @@ export async function captureInitialInvocationCore(
|
|
|
98
103
|
if (arguments.length !== 0) throw Error("INITIAL_OPERATION_UNBOUND");
|
|
99
104
|
return readAttachAcknowledgementForLineage(token);
|
|
100
105
|
},
|
|
106
|
+
admitConfigure(call: unknown, journal: unknown) {
|
|
107
|
+
return captureConfigureAdmission(
|
|
108
|
+
token,
|
|
109
|
+
call,
|
|
110
|
+
journal,
|
|
111
|
+
arguments.length,
|
|
112
|
+
);
|
|
113
|
+
},
|
|
101
114
|
operationalAuthority: false,
|
|
102
115
|
});
|
|
103
116
|
} catch (error) {
|
|
@@ -19,6 +19,7 @@ class InitialLineage {}
|
|
|
19
19
|
class InitialOrigin {}
|
|
20
20
|
type Lineage = Readonly<{
|
|
21
21
|
originAssociation: object;
|
|
22
|
+
binding: object;
|
|
22
23
|
journal: ReturnType<typeof consumeInitialClassReservation>["journal"];
|
|
23
24
|
reservation: ReturnType<typeof consumeInitialClassReservation>["reservation"];
|
|
24
25
|
selection: ReturnType<typeof captureInitialJournalSelection>;
|
|
@@ -128,6 +129,7 @@ export function mintInitialLineage(
|
|
|
128
129
|
token,
|
|
129
130
|
Object.freeze({
|
|
130
131
|
originAssociation: Object.freeze(new InitialOrigin()),
|
|
132
|
+
binding,
|
|
131
133
|
journal: originalJournal,
|
|
132
134
|
reservation,
|
|
133
135
|
selection,
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { expect, it, vi } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
admissionControls,
|
|
4
|
+
configureAdmissionFixture,
|
|
5
|
+
} from "../test-fixtures/producerConfigureAdmission.js";
|
|
6
|
+
import { data } from "../test-fixtures/attachScenarioBarriers.js";
|
|
7
|
+
import { readConfigureLineage } from "./configureLineage.js";
|
|
8
|
+
|
|
9
|
+
it.each(["initial", "replay", "resume"] as const)(
|
|
10
|
+
"admits an actual configure CAS against the actual %s parent and binds its original basis",
|
|
11
|
+
async (path) => {
|
|
12
|
+
await configureAdmissionFixture(async (h) => {
|
|
13
|
+
const output = await h.complete(path);
|
|
14
|
+
expect(data(output).status).toBe("attach_acknowledged");
|
|
15
|
+
const actualACK = h.core.attachAcknowledgement();
|
|
16
|
+
expect(actualACK.output).toBe(output);
|
|
17
|
+
const child = await h.child();
|
|
18
|
+
const before = await child.journal.loadAuthorizedOperation();
|
|
19
|
+
expect(
|
|
20
|
+
before && "initialBasis" in before ? before.initialBasis : "missing",
|
|
21
|
+
).toBeNull();
|
|
22
|
+
const admit = Reflect.get(h.core, "admitConfigure");
|
|
23
|
+
expect(typeof admit).toBe("function");
|
|
24
|
+
const selectors = admissionControls.selectors;
|
|
25
|
+
const calls = h.calls.length;
|
|
26
|
+
const admitted = data(
|
|
27
|
+
await Reflect.apply(admit, h.core, [child.fresh.call, child.journal]),
|
|
28
|
+
);
|
|
29
|
+
expect(admitted.owner).toBe(h.core.owner);
|
|
30
|
+
expect(admitted.basisJSON).toBe(h.core.basisJSON);
|
|
31
|
+
expect(admitted.operationalAuthority).toBe(false);
|
|
32
|
+
expect(Object.keys(admitted).sort()).toEqual([
|
|
33
|
+
"basisJSON",
|
|
34
|
+
"operationalAuthority",
|
|
35
|
+
"owner",
|
|
36
|
+
]);
|
|
37
|
+
const bound = await child.journal.loadAuthorizedOperation();
|
|
38
|
+
expect(
|
|
39
|
+
bound && "initialBasis" in bound ? bound.initialBasis : "missing",
|
|
40
|
+
).toEqual({
|
|
41
|
+
version: 1,
|
|
42
|
+
stage: "configure",
|
|
43
|
+
attemptId:
|
|
44
|
+
child.fresh.result.disposition === "acquired"
|
|
45
|
+
? child.fresh.result.reservation.attemptId
|
|
46
|
+
: "invalid",
|
|
47
|
+
sourcePayloadId:
|
|
48
|
+
child.fresh.result.disposition === "acquired"
|
|
49
|
+
? child.fresh.result.reservation.payloadId
|
|
50
|
+
: "invalid",
|
|
51
|
+
policyJSON: JSON.stringify(
|
|
52
|
+
child.record.timingPolicy,
|
|
53
|
+
Object.keys(child.record.timingPolicy).sort(),
|
|
54
|
+
),
|
|
55
|
+
basisJSON: h.core.basisJSON,
|
|
56
|
+
});
|
|
57
|
+
expect(admissionControls.selectors).toBe(selectors);
|
|
58
|
+
expect(h.calls).toHaveLength(calls);
|
|
59
|
+
expect(admissionControls.legacy).toBe(0);
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
it("admits a child through a different actual Action receiver on the same checked SDK root", async () => {
|
|
65
|
+
await configureAdmissionFixture(async (h) => {
|
|
66
|
+
await h.complete();
|
|
67
|
+
const selectors = admissionControls.selectors;
|
|
68
|
+
await h.inAnotherAction(async (ctx) => {
|
|
69
|
+
expect(ctx).not.toBe(h.ctx);
|
|
70
|
+
const child = await h.child({ ctx });
|
|
71
|
+
const admitted = await h.core.admitConfigure(
|
|
72
|
+
child.fresh.call,
|
|
73
|
+
child.journal,
|
|
74
|
+
);
|
|
75
|
+
expect(admitted.owner).toBe(h.core.owner);
|
|
76
|
+
expect(admitted.basisJSON).toBe(h.core.basisJSON);
|
|
77
|
+
});
|
|
78
|
+
expect(admissionControls.selectors).toBe(selectors);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
it("keeps concurrent children distinct while retaining exact parent Owner and selected client", async () => {
|
|
82
|
+
await configureAdmissionFixture(async (h) => {
|
|
83
|
+
await h.complete();
|
|
84
|
+
const [one, two] = await Promise.all([h.child(), h.child()]);
|
|
85
|
+
const selectors = admissionControls.selectors;
|
|
86
|
+
const calls = h.calls.length;
|
|
87
|
+
const [first, second] = await Promise.all([
|
|
88
|
+
h.core.admitConfigure(one.fresh.call, one.journal),
|
|
89
|
+
h.core.admitConfigure(two.fresh.call, two.journal),
|
|
90
|
+
]);
|
|
91
|
+
expect(first).not.toBe(second);
|
|
92
|
+
expect(() => readConfigureLineage({ ...first })).toThrow(
|
|
93
|
+
"CONFIGURE_ADMISSION_UNBOUND",
|
|
94
|
+
);
|
|
95
|
+
expect(first.owner).toBe(h.core.owner);
|
|
96
|
+
expect(second.owner).toBe(h.core.owner);
|
|
97
|
+
const a = readConfigureLineage(first),
|
|
98
|
+
b = readConfigureLineage(second);
|
|
99
|
+
expect(a.parent).toBe(b.parent);
|
|
100
|
+
expect(a.parent.client).toBe(b.parent.client);
|
|
101
|
+
expect(a.parent.originAssociation).toBe(b.parent.originAssociation);
|
|
102
|
+
expect(a.reservation.operationId).not.toBe(b.reservation.operationId);
|
|
103
|
+
expect(a.reservation.attemptId).not.toBe(b.reservation.attemptId);
|
|
104
|
+
expect(a.reservation.key).not.toBe(b.reservation.key);
|
|
105
|
+
expect(a.originalReservation).toBe(
|
|
106
|
+
one.fresh.result.disposition === "acquired"
|
|
107
|
+
? one.fresh.result.reservation
|
|
108
|
+
: null,
|
|
109
|
+
);
|
|
110
|
+
expect(b.originalReservation).toBe(
|
|
111
|
+
two.fresh.result.disposition === "acquired"
|
|
112
|
+
? two.fresh.result.reservation
|
|
113
|
+
: null,
|
|
114
|
+
);
|
|
115
|
+
expect(a.journal).toBe(one.journal);
|
|
116
|
+
expect(b.journal).toBe(two.journal);
|
|
117
|
+
expect(h.calls).toHaveLength(calls);
|
|
118
|
+
expect(admissionControls.selectors).toBe(selectors);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("isolates concurrent configure admission and retirement across two actual SDK roots", async () => {
|
|
123
|
+
const states = new Map<number, ReturnType<typeof readConfigureLineage>>();
|
|
124
|
+
let release!: () => void, retired!: () => void;
|
|
125
|
+
const ready = new Promise<void>((resolve) => {
|
|
126
|
+
release = resolve;
|
|
127
|
+
});
|
|
128
|
+
const closed = new Promise<void>((resolve) => {
|
|
129
|
+
retired = resolve;
|
|
130
|
+
});
|
|
131
|
+
await configureAdmissionFixture(
|
|
132
|
+
async (h) => {
|
|
133
|
+
await h.complete();
|
|
134
|
+
const child = await h.child();
|
|
135
|
+
const admitted = await h.core.admitConfigure(
|
|
136
|
+
child.fresh.call,
|
|
137
|
+
child.journal,
|
|
138
|
+
);
|
|
139
|
+
states.set(h.index, readConfigureLineage(admitted));
|
|
140
|
+
if (states.size === 2) release();
|
|
141
|
+
await ready;
|
|
142
|
+
const own = states.get(h.index)!,
|
|
143
|
+
other = states.get(1 - h.index)!;
|
|
144
|
+
expect(own.owner).toBe(h.core.owner);
|
|
145
|
+
expect(own.owner === other.owner).toBe(false);
|
|
146
|
+
expect(own.parent.client === other.parent.client).toBe(false);
|
|
147
|
+
expect(
|
|
148
|
+
own.parent.originAssociation === other.parent.originAssociation,
|
|
149
|
+
).toBe(false);
|
|
150
|
+
expect(own.parentToken === other.parentToken).toBe(false);
|
|
151
|
+
expect(own.reservation.operationId).not.toBe(
|
|
152
|
+
other.reservation.operationId,
|
|
153
|
+
);
|
|
154
|
+
if (h.index === 0) {
|
|
155
|
+
h.core.owner.retire();
|
|
156
|
+
retired();
|
|
157
|
+
} else {
|
|
158
|
+
await closed;
|
|
159
|
+
expect(() => h.core.owner.check()).not.toThrow();
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
count: 2,
|
|
164
|
+
keys: [
|
|
165
|
+
"sk_test_invalid_configure_root_a",
|
|
166
|
+
"sk_test_invalid_configure_root_b",
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("refuses forged child calls before clock reads and preserves the genuine unspent handle", async () => {
|
|
173
|
+
await configureAdmissionFixture(async (h) => {
|
|
174
|
+
await h.complete();
|
|
175
|
+
const child = await h.child();
|
|
176
|
+
const wall = vi.spyOn(Date, "now");
|
|
177
|
+
const monotonic = vi.mocked(process.hrtime.bigint);
|
|
178
|
+
let traps = 0;
|
|
179
|
+
for (const call of [
|
|
180
|
+
null,
|
|
181
|
+
{},
|
|
182
|
+
new Proxy(child.fresh.call!, {
|
|
183
|
+
get() {
|
|
184
|
+
traps++;
|
|
185
|
+
throw Error("PROXY_INVOKED");
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
]) {
|
|
189
|
+
const beforeWall = wall.mock.calls.length,
|
|
190
|
+
beforeMono = monotonic.mock.calls.length;
|
|
191
|
+
const pending = h.core.admitConfigure(call, child.journal);
|
|
192
|
+
const afterWall = wall.mock.calls.length,
|
|
193
|
+
afterMono = monotonic.mock.calls.length;
|
|
194
|
+
await expect(pending).rejects.toThrow("CLASS_JOURNAL_CALL_UNBOUND");
|
|
195
|
+
expect(afterWall - beforeWall).toBe(0);
|
|
196
|
+
expect(afterMono - beforeMono).toBe(0);
|
|
197
|
+
}
|
|
198
|
+
expect(traps).toBe(0);
|
|
199
|
+
const before = monotonic.mock.calls.length;
|
|
200
|
+
await h.core.admitConfigure(child.fresh.call, child.journal);
|
|
201
|
+
expect(monotonic.mock.calls.length).toBeGreaterThan(before);
|
|
202
|
+
});
|
|
203
|
+
});
|