@fantastic.dev/better-stripe 0.101.0 → 0.103.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/c10/appendAck.d.ts +7 -0
  4. package/dist/client/billing/renewalAttach/internal/c10/appendAck.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/c10/appendAck.js +13 -1
  6. package/dist/client/billing/renewalAttach/internal/c10/appendAck.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts +23 -0
  8. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js +34 -2
  10. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +2 -0
  12. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
  13. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +16 -0
  14. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
  15. package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.d.ts +7 -0
  16. package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.d.ts.map +1 -0
  17. package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.js +117 -0
  18. package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.js.map +1 -0
  19. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts +53 -0
  20. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js +198 -0
  22. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js.map +1 -0
  23. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts +6 -0
  24. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts.map +1 -0
  25. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js +49 -0
  26. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js.map +1 -0
  27. package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts +959 -0
  28. package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts.map +1 -0
  29. package/dist/client/billing/renewalAttach/internal/producer/configureLineage.js +115 -0
  30. package/dist/client/billing/renewalAttach/internal/producer/configureLineage.js.map +1 -0
  31. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +2 -0
  32. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
  33. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +4 -0
  34. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
  35. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts +1 -0
  36. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts.map +1 -1
  37. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js +1 -0
  38. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js.map +1 -1
  39. package/docs/renewal-context-reads.md +81 -3
  40. package/package.json +1 -1
  41. package/src/client/billing/renewalAttach/internal/c10/appendAck.ts +17 -0
  42. package/src/client/billing/renewalAttach/internal/c10/configureEvents.ts +45 -2
  43. package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +21 -0
  44. package/src/client/billing/renewalAttach/internal/producer/configureAdmission.ts +179 -0
  45. package/src/client/billing/renewalAttach/internal/producer/configureJournalData.ts +248 -0
  46. package/src/client/billing/renewalAttach/internal/producer/configureJournalWork.ts +53 -0
  47. package/src/client/billing/renewalAttach/internal/producer/configureLineage.ts +166 -0
  48. package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +13 -0
  49. package/src/client/billing/renewalAttach/internal/producer/lineageAuthority.ts +2 -0
  50. package/src/client/billing/renewalAttach/internal/producer/producerConfigureAdmission.integration.test.ts +203 -0
  51. package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannelControls.integration.test.ts +542 -0
  52. package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannels.integration.test.ts +321 -0
  53. package/src/client/billing/renewalAttach/internal/producer/producerConfigureControls.integration.test.ts +566 -0
  54. package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +353 -0
  55. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +61 -3
@@ -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
+ });