@fantastic.dev/better-stripe 0.111.0 → 0.112.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/observation/freshActor.d.ts +564 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js +103 -21
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts +18 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js +54 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/invocation.js +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invocation.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js +6 -1
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.d.ts +38 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.js +172 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessData.d.ts +135 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessData.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessData.js +143 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessData.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.d.ts +85 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.js +121 -0
- package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.d.ts +44 -0
- package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.js +4 -0
- package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts +21 -21
- package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.d.ts +3 -3
- package/dist/client/billing/renewalAttach/internal/producer/operationFactory.d.ts +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/component/_generated/api.d.ts +24 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +94 -10
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- package/dist/component/renewalWitnesses/mutations.d.ts +45 -0
- package/dist/component/renewalWitnesses/mutations.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/mutations.js +14 -0
- package/dist/component/renewalWitnesses/mutations.js.map +1 -0
- package/dist/component/renewalWitnesses/queries.d.ts +39 -0
- package/dist/component/renewalWitnesses/queries.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/queries.js +11 -0
- package/dist/component/renewalWitnesses/queries.js.map +1 -0
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-witness-protocol.md +61 -10
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/observation/freshActor.ts +142 -19
- package/src/client/billing/renewalAttach/internal/observation/freshTransport.ts +90 -1
- package/src/client/billing/renewalAttach/internal/observation/invocation.ts +2 -0
- package/src/client/billing/renewalAttach/internal/observation/readerAuthorization.ts +6 -1
- package/src/client/billing/renewalAttach/internal/observation/witnessAcquisition.integration.test.ts +348 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessActor.integration.test.ts +204 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessAuthorization.ts +239 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessCapabilities.integration.test.ts +231 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessData.ts +189 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessHistorical.integration.test.ts +98 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessImmutable.integration.test.ts +78 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessInvoice.integration.test.ts +85 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessLifecycle.integration.test.ts +264 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessOperation.ts +205 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessProfile.integration.test.ts +93 -0
- package/src/client/billing/renewalAttach/internal/observation/witnessRPCControls.integration.test.ts +256 -0
- package/src/client/billing/renewalAttach/internal/operations/witnessProfiles.ts +58 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/invoiceObservation.ts +3 -1
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +8 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +18 -7
- package/src/client/billing/renewalAttach/internal/test-fixtures/witnessHistory.ts +70 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/witnessObservation.ts +353 -0
- package/src/component/_generated/api.ts +24 -0
- package/src/component/_generated/component.ts +98 -10
- package/src/component/renewalWitnesses/mutations.ts +17 -0
- package/src/component/renewalWitnesses/queries.ts +11 -0
- package/src/component/renewalWitnesses/routes.test.ts +154 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { makeFunctionReference } from "convex/server";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { witnessFixture } from "../../../tests/renewalObservation/witnessFixtures.js";
|
|
4
|
+
import { canonicalConfigure } from "../renewalOperations/configureJournal.fixtures.js";
|
|
5
|
+
|
|
6
|
+
// Test-only routing names do not stand in for genuine generated production references.
|
|
7
|
+
const retain = makeFunctionReference<"mutation">(
|
|
8
|
+
"renewalWitnesses/mutations:retainAuthorizedWitness",
|
|
9
|
+
);
|
|
10
|
+
const read = makeFunctionReference<"query">(
|
|
11
|
+
"renewalWitnesses/queries:readAuthorizedWitness",
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
describe("registered renewal witness component boundaries", () => {
|
|
15
|
+
it.each([false, true])(
|
|
16
|
+
"retains and reads complete immutable material with captured C9 %s",
|
|
17
|
+
async (retained) => {
|
|
18
|
+
const h = await witnessFixture(retained);
|
|
19
|
+
const payloadJSON = canonicalConfigure(h.payload);
|
|
20
|
+
const args = { identity: h.identity, payloadJSON };
|
|
21
|
+
const first = await h.t.mutation(retain, args);
|
|
22
|
+
expect(first.status).toBe("retained");
|
|
23
|
+
expect(first.descriptor.identity).toEqual(h.identity);
|
|
24
|
+
expect(first.descriptor.publicDeliveryEstablished).toBe(false);
|
|
25
|
+
expect(await h.t.mutation(retain, args)).toEqual(first);
|
|
26
|
+
expect(await h.t.query(read, { identity: h.identity })).toEqual({
|
|
27
|
+
descriptor: first.descriptor,
|
|
28
|
+
payloadJSON,
|
|
29
|
+
});
|
|
30
|
+
const altered = structuredClone(h.payload);
|
|
31
|
+
altered.capturedSubject = "another-captured-subject";
|
|
32
|
+
expect(
|
|
33
|
+
await h.t.mutation(retain, {
|
|
34
|
+
identity: h.identity,
|
|
35
|
+
payloadJSON: canonicalConfigure(altered),
|
|
36
|
+
}),
|
|
37
|
+
).toEqual({ status: "conflict", reason: "identity_changed" });
|
|
38
|
+
expect(await h.t.query(read, { identity: h.identity })).toEqual({
|
|
39
|
+
descriptor: first.descriptor,
|
|
40
|
+
payloadJSON,
|
|
41
|
+
});
|
|
42
|
+
expect(h.fetches()).toBe(0);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
it("rejects unknown identity fields and malformed operation IDs before storage", async () => {
|
|
47
|
+
const h = await witnessFixture();
|
|
48
|
+
const payloadJSON = canonicalConfigure(h.payload);
|
|
49
|
+
await expect(
|
|
50
|
+
h.t.mutation(retain, {
|
|
51
|
+
identity: { ...h.identity, extra: "not-admitted" },
|
|
52
|
+
payloadJSON,
|
|
53
|
+
}),
|
|
54
|
+
).rejects.toThrow(/Validator error/);
|
|
55
|
+
await expect(
|
|
56
|
+
h.t.mutation(retain, {
|
|
57
|
+
identity: { ...h.identity, operationId: "not-a-convex-id" },
|
|
58
|
+
payloadJSON,
|
|
59
|
+
}),
|
|
60
|
+
).rejects.toThrow(/Validator error/);
|
|
61
|
+
expect(
|
|
62
|
+
await h.t.run((ctx) =>
|
|
63
|
+
ctx.db.query("renewalObservationWitnesses").take(2),
|
|
64
|
+
),
|
|
65
|
+
).toEqual([]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("rejects unknown outer arguments and noncanonical payloads without inserting", async () => {
|
|
69
|
+
const h = await witnessFixture();
|
|
70
|
+
const args = {
|
|
71
|
+
identity: h.identity,
|
|
72
|
+
payloadJSON: canonicalConfigure(h.payload),
|
|
73
|
+
};
|
|
74
|
+
await expect(
|
|
75
|
+
h.t.mutation(retain, { ...args, extra: true }),
|
|
76
|
+
).rejects.toThrow(/Validator error/);
|
|
77
|
+
await expect(
|
|
78
|
+
h.t.mutation(retain, {
|
|
79
|
+
...args,
|
|
80
|
+
payloadJSON: JSON.stringify(h.payload, null, 2),
|
|
81
|
+
}),
|
|
82
|
+
).rejects.toThrow("RENEWAL_WITNESS_INVALID");
|
|
83
|
+
expect(
|
|
84
|
+
await h.t.run((ctx) =>
|
|
85
|
+
ctx.db.query("renewalObservationWitnesses").take(2),
|
|
86
|
+
),
|
|
87
|
+
).toEqual([]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("releases no payload for another installation or operation identity", async () => {
|
|
91
|
+
const h = await witnessFixture();
|
|
92
|
+
await h.t.mutation(retain, {
|
|
93
|
+
identity: h.identity,
|
|
94
|
+
payloadJSON: canonicalConfigure(h.payload),
|
|
95
|
+
});
|
|
96
|
+
for (const identity of [
|
|
97
|
+
{ ...h.identity, componentScope: "another-installation" },
|
|
98
|
+
{
|
|
99
|
+
...h.identity,
|
|
100
|
+
operationId: h.identity.parentOperationId,
|
|
101
|
+
parentOperationId: h.identity.operationId,
|
|
102
|
+
},
|
|
103
|
+
{ ...h.identity, witnessId: "another-witness" },
|
|
104
|
+
]) {
|
|
105
|
+
expect(await h.t.query(read, { identity })).toBeNull();
|
|
106
|
+
}
|
|
107
|
+
await expect(
|
|
108
|
+
h.t.query(read, { identity: { ...h.identity, extra: true } }),
|
|
109
|
+
).rejects.toThrow(/Validator error/);
|
|
110
|
+
await expect(
|
|
111
|
+
h.t.query(read, { identity: h.identity, extra: true }),
|
|
112
|
+
).rejects.toThrow(/Validator error/);
|
|
113
|
+
expect(h.fetches()).toBe(0);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("revalidates material behind a rehashed corrupt row without repairing it", async () => {
|
|
117
|
+
const h = await witnessFixture();
|
|
118
|
+
const args = {
|
|
119
|
+
identity: h.identity,
|
|
120
|
+
payloadJSON: canonicalConfigure(h.payload),
|
|
121
|
+
};
|
|
122
|
+
const first = await h.t.mutation(retain, args);
|
|
123
|
+
const changed = structuredClone(h.payload);
|
|
124
|
+
Object.assign(changed.reads.subscription, { cancel_at_period_end: true });
|
|
125
|
+
const payloadJSON = canonicalConfigure(changed);
|
|
126
|
+
const hash = await crypto.subtle.digest(
|
|
127
|
+
"SHA-256",
|
|
128
|
+
new TextEncoder().encode("renewal-witness:v1\u0000" + payloadJSON),
|
|
129
|
+
);
|
|
130
|
+
const hex = [...new Uint8Array(hash)]
|
|
131
|
+
.map((n) => n.toString(16).padStart(2, "0"))
|
|
132
|
+
.join("");
|
|
133
|
+
const payloadBinding = "renewal-witness:v1:sha256:" + hex;
|
|
134
|
+
await h.t.run((ctx) =>
|
|
135
|
+
ctx.db.patch(
|
|
136
|
+
"renewalObservationWitnesses",
|
|
137
|
+
first.descriptor.witnessRowId,
|
|
138
|
+
{ payloadJSON, payloadBinding },
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
await expect(h.t.query(read, { identity: h.identity })).rejects.toThrow(
|
|
142
|
+
"RENEWAL_WITNESS_INVALID",
|
|
143
|
+
);
|
|
144
|
+
await expect(h.t.mutation(retain, args)).rejects.toThrow(
|
|
145
|
+
"RENEWAL_WITNESS_INVALID",
|
|
146
|
+
);
|
|
147
|
+
const row = await h.t.run((ctx) =>
|
|
148
|
+
ctx.db.get("renewalObservationWitnesses", first.descriptor.witnessRowId),
|
|
149
|
+
);
|
|
150
|
+
expect(row?.payloadJSON).toBe(payloadJSON);
|
|
151
|
+
expect(row?.payloadBinding).toBe(payloadBinding);
|
|
152
|
+
expect(h.fetches()).toBe(0);
|
|
153
|
+
});
|
|
154
|
+
});
|