@fantastic.dev/better-stripe 0.111.0 → 0.113.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/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-example-authorization.md +74 -0
- 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 +28 -11
- 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
|
@@ -8392,7 +8392,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8392
8392
|
recordJSON: string;
|
|
8393
8393
|
recordVersion: 2;
|
|
8394
8394
|
requestBinding: string;
|
|
8395
|
-
stage: "attach";
|
|
8395
|
+
stage: "attach" | "configure";
|
|
8396
8396
|
timingPolicyJSON: string;
|
|
8397
8397
|
};
|
|
8398
8398
|
},
|
|
@@ -8441,7 +8441,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8441
8441
|
recordJSON: string;
|
|
8442
8442
|
recordVersion: 2;
|
|
8443
8443
|
requestBinding: string;
|
|
8444
|
-
stage: "attach";
|
|
8444
|
+
stage: "attach" | "configure";
|
|
8445
8445
|
timingPolicyJSON: string;
|
|
8446
8446
|
};
|
|
8447
8447
|
sequence: 1 | 2 | 3;
|
|
@@ -8465,7 +8465,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8465
8465
|
basisJSON: string;
|
|
8466
8466
|
policyJSON: string;
|
|
8467
8467
|
sourcePayloadId: string;
|
|
8468
|
-
stage: "attach";
|
|
8468
|
+
stage: "attach" | "configure";
|
|
8469
8469
|
version: 1;
|
|
8470
8470
|
};
|
|
8471
8471
|
operationId: string;
|
|
@@ -8540,7 +8540,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8540
8540
|
recordJSON: string;
|
|
8541
8541
|
recordVersion: 2;
|
|
8542
8542
|
requestBinding: string;
|
|
8543
|
-
stage: "attach";
|
|
8543
|
+
stage: "attach" | "configure";
|
|
8544
8544
|
timingPolicyJSON: string;
|
|
8545
8545
|
};
|
|
8546
8546
|
}
|
|
@@ -8586,7 +8586,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8586
8586
|
recordJSON: string;
|
|
8587
8587
|
recordVersion: 2;
|
|
8588
8588
|
requestBinding: string;
|
|
8589
|
-
stage: "attach";
|
|
8589
|
+
stage: "attach" | "configure";
|
|
8590
8590
|
timingPolicyJSON: string;
|
|
8591
8591
|
};
|
|
8592
8592
|
}
|
|
@@ -8613,7 +8613,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8613
8613
|
responsePayloadId: string;
|
|
8614
8614
|
schemaVersion: 1;
|
|
8615
8615
|
sourcePayloadId: string;
|
|
8616
|
-
stage: "attach";
|
|
8616
|
+
stage: "attach" | "configure";
|
|
8617
8617
|
status: "retained";
|
|
8618
8618
|
},
|
|
8619
8619
|
Name
|
|
@@ -8651,7 +8651,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8651
8651
|
preparedRevision: 0;
|
|
8652
8652
|
recordVersion: 2;
|
|
8653
8653
|
requestBinding: string;
|
|
8654
|
-
stage: "attach";
|
|
8654
|
+
stage: "attach" | "configure";
|
|
8655
8655
|
timingPolicyJSON: string;
|
|
8656
8656
|
};
|
|
8657
8657
|
initialBasis: null | {
|
|
@@ -8659,7 +8659,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8659
8659
|
basisJSON: string;
|
|
8660
8660
|
policyJSON: string;
|
|
8661
8661
|
sourcePayloadId: string;
|
|
8662
|
-
stage: "attach";
|
|
8662
|
+
stage: "attach" | "configure";
|
|
8663
8663
|
version: 1;
|
|
8664
8664
|
};
|
|
8665
8665
|
operationId: string;
|
|
@@ -8747,7 +8747,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8747
8747
|
recordJSON: string;
|
|
8748
8748
|
recordVersion: 2;
|
|
8749
8749
|
requestBinding: string;
|
|
8750
|
-
stage: "attach";
|
|
8750
|
+
stage: "attach" | "configure";
|
|
8751
8751
|
timingPolicyJSON: string;
|
|
8752
8752
|
};
|
|
8753
8753
|
},
|
|
@@ -8770,7 +8770,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8770
8770
|
responsePayloadId: string;
|
|
8771
8771
|
schemaVersion: 1;
|
|
8772
8772
|
sourcePayloadId: string;
|
|
8773
|
-
stage: "attach";
|
|
8773
|
+
stage: "attach" | "configure";
|
|
8774
8774
|
status: "retained";
|
|
8775
8775
|
};
|
|
8776
8776
|
},
|
|
@@ -8795,6 +8795,94 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
8795
8795
|
>;
|
|
8796
8796
|
};
|
|
8797
8797
|
};
|
|
8798
|
+
renewalWitnesses: {
|
|
8799
|
+
mutations: {
|
|
8800
|
+
retainAuthorizedWitness: FunctionReference<
|
|
8801
|
+
"mutation",
|
|
8802
|
+
"internal",
|
|
8803
|
+
{
|
|
8804
|
+
identity: {
|
|
8805
|
+
componentScope: string;
|
|
8806
|
+
operationId: string;
|
|
8807
|
+
parentOperationId: string;
|
|
8808
|
+
witnessId: string;
|
|
8809
|
+
};
|
|
8810
|
+
payloadJSON: string;
|
|
8811
|
+
},
|
|
8812
|
+
| {
|
|
8813
|
+
descriptor: {
|
|
8814
|
+
authenticationEstablished: false;
|
|
8815
|
+
capturedSubject: string;
|
|
8816
|
+
customerAccountId: string;
|
|
8817
|
+
customerId: string;
|
|
8818
|
+
identity: {
|
|
8819
|
+
componentScope: string;
|
|
8820
|
+
operationId: string;
|
|
8821
|
+
parentOperationId: string;
|
|
8822
|
+
witnessId: string;
|
|
8823
|
+
};
|
|
8824
|
+
livemode: boolean;
|
|
8825
|
+
nativePeriod: { end: number; start: number };
|
|
8826
|
+
observedAtMs: number;
|
|
8827
|
+
observedItemId: string;
|
|
8828
|
+
operationalAuthority: false;
|
|
8829
|
+
payloadBinding: string;
|
|
8830
|
+
providerQualificationRequired: true;
|
|
8831
|
+
publicDeliveryEstablished: false;
|
|
8832
|
+
scheduleId: string;
|
|
8833
|
+
subscriptionId: string;
|
|
8834
|
+
version: 1;
|
|
8835
|
+
witnessRowId: string;
|
|
8836
|
+
};
|
|
8837
|
+
status: "retained";
|
|
8838
|
+
}
|
|
8839
|
+
| { reason: "identity_changed"; status: "conflict" },
|
|
8840
|
+
Name
|
|
8841
|
+
>;
|
|
8842
|
+
};
|
|
8843
|
+
queries: {
|
|
8844
|
+
readAuthorizedWitness: FunctionReference<
|
|
8845
|
+
"query",
|
|
8846
|
+
"internal",
|
|
8847
|
+
{
|
|
8848
|
+
identity: {
|
|
8849
|
+
componentScope: string;
|
|
8850
|
+
operationId: string;
|
|
8851
|
+
parentOperationId: string;
|
|
8852
|
+
witnessId: string;
|
|
8853
|
+
};
|
|
8854
|
+
},
|
|
8855
|
+
null | {
|
|
8856
|
+
descriptor: {
|
|
8857
|
+
authenticationEstablished: false;
|
|
8858
|
+
capturedSubject: string;
|
|
8859
|
+
customerAccountId: string;
|
|
8860
|
+
customerId: string;
|
|
8861
|
+
identity: {
|
|
8862
|
+
componentScope: string;
|
|
8863
|
+
operationId: string;
|
|
8864
|
+
parentOperationId: string;
|
|
8865
|
+
witnessId: string;
|
|
8866
|
+
};
|
|
8867
|
+
livemode: boolean;
|
|
8868
|
+
nativePeriod: { end: number; start: number };
|
|
8869
|
+
observedAtMs: number;
|
|
8870
|
+
observedItemId: string;
|
|
8871
|
+
operationalAuthority: false;
|
|
8872
|
+
payloadBinding: string;
|
|
8873
|
+
providerQualificationRequired: true;
|
|
8874
|
+
publicDeliveryEstablished: false;
|
|
8875
|
+
scheduleId: string;
|
|
8876
|
+
subscriptionId: string;
|
|
8877
|
+
version: 1;
|
|
8878
|
+
witnessRowId: string;
|
|
8879
|
+
};
|
|
8880
|
+
payloadJSON: string;
|
|
8881
|
+
},
|
|
8882
|
+
Name
|
|
8883
|
+
>;
|
|
8884
|
+
};
|
|
8885
|
+
};
|
|
8798
8886
|
reversalObservations: {
|
|
8799
8887
|
mutations: {
|
|
8800
8888
|
resume: FunctionReference<
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { mutation } from "../_generated/server.js";
|
|
3
|
+
import { descriptor, identity } from "./schema.js";
|
|
4
|
+
import { retainWitness } from "./protocol.js";
|
|
5
|
+
|
|
6
|
+
/** Trusted host component API. Host authorization and live capture remain separate requirements. */
|
|
7
|
+
export const retainAuthorizedWitness = mutation({
|
|
8
|
+
args: { identity, payloadJSON: v.string() },
|
|
9
|
+
returns: v.union(
|
|
10
|
+
v.object({ status: v.literal("retained"), descriptor }),
|
|
11
|
+
v.object({
|
|
12
|
+
status: v.literal("conflict"),
|
|
13
|
+
reason: v.literal("identity_changed"),
|
|
14
|
+
}),
|
|
15
|
+
),
|
|
16
|
+
handler: retainWitness,
|
|
17
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { query } from "../_generated/server.js";
|
|
3
|
+
import { descriptor, identity } from "./schema.js";
|
|
4
|
+
import { readWitness } from "./protocol.js";
|
|
5
|
+
|
|
6
|
+
/** Trusted host component API. A fresh host read grant must precede any external release. */
|
|
7
|
+
export const readAuthorizedWitness = query({
|
|
8
|
+
args: { identity },
|
|
9
|
+
returns: v.union(v.null(), v.object({ descriptor, payloadJSON: v.string() })),
|
|
10
|
+
handler: (ctx, args) => readWitness(ctx, args.identity),
|
|
11
|
+
});
|
|
@@ -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
|
+
});
|