@fantastic.dev/better-stripe 0.99.0 → 0.101.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 (111) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
  4. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +27 -1
  6. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.d.ts +10 -0
  8. package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.d.ts.map +1 -0
  9. package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js +49 -0
  10. package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js.map +1 -0
  11. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +2 -0
  12. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
  13. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +6 -0
  14. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
  15. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.d.ts +9 -0
  16. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.d.ts.map +1 -1
  17. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.js +22 -0
  18. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.js.map +1 -1
  19. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +9 -0
  20. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -1
  21. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +27 -0
  22. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -1
  23. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +18 -18
  24. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +9 -9
  25. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +50 -50
  26. package/dist/client/connect/payoutSyncTestHelpers.d.ts +25 -25
  27. package/dist/component/balanceFunding/queries.d.ts +1 -1
  28. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  29. package/dist/component/earnings/triggers.d.ts +22 -22
  30. package/dist/component/payoutRelease/queries.d.ts +2 -2
  31. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  32. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  33. package/dist/component/renewalOperations/attachValidation.d.ts +19 -0
  34. package/dist/component/renewalOperations/attachValidation.d.ts.map +1 -0
  35. package/dist/component/renewalOperations/attachValidation.js +167 -0
  36. package/dist/component/renewalOperations/attachValidation.js.map +1 -0
  37. package/dist/component/renewalOperations/configureAcknowledgement.d.ts +13 -0
  38. package/dist/component/renewalOperations/configureAcknowledgement.d.ts.map +1 -0
  39. package/dist/component/renewalOperations/configureAcknowledgement.js +108 -0
  40. package/dist/component/renewalOperations/configureAcknowledgement.js.map +1 -0
  41. package/dist/component/renewalOperations/configureParent.d.ts +10 -0
  42. package/dist/component/renewalOperations/configureParent.d.ts.map +1 -0
  43. package/dist/component/renewalOperations/configureParent.js +62 -0
  44. package/dist/component/renewalOperations/configureParent.js.map +1 -0
  45. package/dist/component/renewalOperations/configureValidation.d.ts +12 -0
  46. package/dist/component/renewalOperations/configureValidation.d.ts.map +1 -0
  47. package/dist/component/renewalOperations/configureValidation.js +64 -0
  48. package/dist/component/renewalOperations/configureValidation.js.map +1 -0
  49. package/dist/component/renewalOperations/helpers.d.ts +16 -21
  50. package/dist/component/renewalOperations/helpers.d.ts.map +1 -1
  51. package/dist/component/renewalOperations/helpers.js +13 -169
  52. package/dist/component/renewalOperations/helpers.js.map +1 -1
  53. package/dist/component/renewalOperations/mutations.d.ts +6 -6
  54. package/dist/component/renewalOperations/mutations.d.ts.map +1 -1
  55. package/dist/component/renewalOperations/mutations.js +14 -7
  56. package/dist/component/renewalOperations/mutations.js.map +1 -1
  57. package/dist/component/renewalOperations/operationContext.d.ts +12 -0
  58. package/dist/component/renewalOperations/operationContext.d.ts.map +1 -0
  59. package/dist/component/renewalOperations/operationContext.js +14 -0
  60. package/dist/component/renewalOperations/operationContext.js.map +1 -0
  61. package/dist/component/renewalOperations/queries.d.ts +4 -4
  62. package/dist/component/renewalOperations/queries.js +2 -1
  63. package/dist/component/renewalOperations/queries.js.map +1 -1
  64. package/dist/component/renewalOperations/schema.d.ts +59 -59
  65. package/dist/component/renewalOperations/schema.js +3 -3
  66. package/dist/component/renewalOperations/schema.js.map +1 -1
  67. package/dist/component/renewalOperations/stageAcknowledgement.d.ts +15 -0
  68. package/dist/component/renewalOperations/stageAcknowledgement.d.ts.map +1 -0
  69. package/dist/component/renewalOperations/stageAcknowledgement.js +20 -0
  70. package/dist/component/renewalOperations/stageAcknowledgement.js.map +1 -0
  71. package/dist/component/renewalOperations/validationTypes.d.ts +9 -0
  72. package/dist/component/renewalOperations/validationTypes.d.ts.map +1 -0
  73. package/dist/component/renewalOperations/validationTypes.js +2 -0
  74. package/dist/component/renewalOperations/validationTypes.js.map +1 -0
  75. package/dist/component/schema.d.ts +9 -9
  76. package/dist/component/usage/allowance.fixtures.d.ts +9 -9
  77. package/dist/component/usageCredits/accounting.fixtures.d.ts +9 -9
  78. package/dist/shared/renewalOperationJournal.d.ts +1 -1
  79. package/dist/shared/renewalOperationJournal.d.ts.map +1 -1
  80. package/dist/shared/renewalOperationJournal.js +41 -9
  81. package/dist/shared/renewalOperationJournal.js.map +1 -1
  82. package/docs/renewal-context-reads.md +59 -8
  83. package/package.json +1 -1
  84. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +28 -1
  85. package/src/client/billing/renewalAttach/internal/producer/attachAcknowledgement.ts +65 -0
  86. package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +8 -0
  87. package/src/client/billing/renewalAttach/internal/producer/producerAcknowledgement.integration.test.ts +320 -0
  88. package/src/client/billing/renewalAttach/internal/producer/producerAcknowledgementControls.integration.test.ts +411 -0
  89. package/src/client/billing/renewalAttach/internal/producer/recoveryEntry.ts +35 -1
  90. package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +39 -0
  91. package/src/component/renewalOperations/attachValidation.ts +203 -0
  92. package/src/component/renewalOperations/configureAcknowledgement.test.ts +30 -0
  93. package/src/component/renewalOperations/configureAcknowledgement.ts +182 -0
  94. package/src/component/renewalOperations/configureAcknowledgementControls.test.ts +96 -0
  95. package/src/component/renewalOperations/configureBasis.test.ts +77 -0
  96. package/src/component/renewalOperations/configureCreation.test.ts +75 -0
  97. package/src/component/renewalOperations/configureJournal.fixtures.ts +385 -0
  98. package/src/component/renewalOperations/configureParent.ts +71 -0
  99. package/src/component/renewalOperations/configurePolicy.test.ts +105 -0
  100. package/src/component/renewalOperations/configurePublication.test.ts +85 -0
  101. package/src/component/renewalOperations/configureReceiptBounds.test.ts +39 -0
  102. package/src/component/renewalOperations/configureSourceControls.test.ts +65 -0
  103. package/src/component/renewalOperations/configureValidation.ts +70 -0
  104. package/src/component/renewalOperations/helpers.ts +21 -204
  105. package/src/component/renewalOperations/mutations.ts +16 -7
  106. package/src/component/renewalOperations/operationContext.ts +21 -0
  107. package/src/component/renewalOperations/queries.ts +1 -1
  108. package/src/component/renewalOperations/schema.ts +3 -3
  109. package/src/component/renewalOperations/stageAcknowledgement.ts +45 -0
  110. package/src/component/renewalOperations/validationTypes.ts +9 -0
  111. package/src/shared/renewalOperationJournal.ts +49 -8
@@ -0,0 +1,108 @@
1
+ import { constructRenewalConfigurationReceiptV2 } from "../../client/billing/renewalV2/index.js";
2
+ import { captureConfigureDispatch, captureConfigureResponse, captureConfigureReceipt, } from "../../client/billing/renewalAttach/internal/c10/eventCapture.js";
3
+ import { requiredJSONSnapshot } from "../../client/billing/renewalAttach/internal/material/requiredJson.js";
4
+ import { renewalSnapshot } from "../../client/billing/renewalReplacementSnapshot.js";
5
+ import { equal } from "../../client/billing/renewalAggregate/shared.js";
6
+ import { validateOperationalConfigureSource, configureConflict, jsonObject, } from "./configureValidation.js";
7
+ function admitReceipt(receiptJSON, rebuilt) {
8
+ if (receiptJSON.length > 500000 ||
9
+ new TextEncoder().encode(receiptJSON).length > 500000)
10
+ configureConflict();
11
+ const parsed = JSON.parse(receiptJSON);
12
+ if (!equal(parsed, rebuilt))
13
+ configureConflict();
14
+ const output = renewalSnapshot({
15
+ status: "configure_acknowledged",
16
+ operationalAuthority: false,
17
+ receipt: parsed,
18
+ });
19
+ const slots = new Map();
20
+ const add = (path, expected, family) => slots.set(JSON.stringify(["receipt", ...path]), { expected, family });
21
+ add(["logicalBinding"], rebuilt.logicalBinding, "renewal");
22
+ add(["attachReceiptBinding"], rebuilt.attachReceiptBinding, "renewal-attach-receipt");
23
+ add(["providerSnapshotBinding"], rebuilt.providerSnapshotBinding, "renewal-configured-baseline");
24
+ add(["binding"], rebuilt.binding, "renewal-configure-receipt");
25
+ if (rebuilt.defaultSettingsBinding !== undefined)
26
+ add(["defaultSettingsBinding"], rebuilt.defaultSettingsBinding, "renewal-configured-defaults");
27
+ add(["request", "logicalBinding"], rebuilt.request.logicalBinding, "renewal");
28
+ add(["request", "attachReceiptBinding"], rebuilt.request.attachReceiptBinding, "renewal-attach-receipt");
29
+ add(["request", "baselineBinding"], rebuilt.request.baselineBinding, "renewal-baseline");
30
+ add(["request", "defaultSettingsBinding"], rebuilt.request.defaultSettingsBinding, "renewal-defaults");
31
+ add(["request", "requestIdentity", "binding"], rebuilt.request.requestIdentity.binding, "renewal-configure");
32
+ const found = new Set();
33
+ function walk(value, path) {
34
+ const key = JSON.stringify(path), slot = slots.get(key);
35
+ if (slot) {
36
+ if (value !== slot.expected ||
37
+ typeof value !== "string" ||
38
+ !new RegExp("^" + slot.family + ":v2:sha256:[0-9a-f]{64}$").test(value))
39
+ configureConflict();
40
+ found.add(key);
41
+ return;
42
+ }
43
+ if (value === null || typeof value !== "object") {
44
+ requiredJSONSnapshot(value);
45
+ return;
46
+ }
47
+ for (const [name, child] of Object.entries(value)) {
48
+ requiredJSONSnapshot(name);
49
+ requiredJSONSnapshot({ [name]: child === null ? null : true });
50
+ walk(child, [...path, name]);
51
+ }
52
+ }
53
+ walk(output, []);
54
+ if (found.size !== slots.size ||
55
+ new TextEncoder().encode(JSON.stringify(output)).length > 500000)
56
+ configureConflict();
57
+ return JSON.stringify(output.receipt);
58
+ }
59
+ /** Complete C9 DATA against checked C3/C6/C7 source and actual stored events. */
60
+ export async function validateConfigureAcknowledgement(full, reservation, events, receiptJSON) {
61
+ if (!("recordVersion" in reservation) ||
62
+ reservation.stage !== "configure" ||
63
+ (events.length !== 2 && events.length !== 3) ||
64
+ events[0].sequence !== 1 ||
65
+ events[1].sequence !== 2)
66
+ configureConflict();
67
+ const checked = await validateOperationalConfigureSource(full);
68
+ const dispatch = JSON.parse(events[0].dataJSON), response = JSON.parse(events[1].dataJSON);
69
+ captureConfigureDispatch(dispatch);
70
+ captureConfigureResponse(response);
71
+ const sent = jsonObject(dispatch), received = jsonObject(response);
72
+ if (!equal(sent.request, checked.request) ||
73
+ !equal(received.request, checked.request) ||
74
+ reservation.requestBinding !== checked.request.requestIdentity.binding ||
75
+ reservation.key !== checked.request.key ||
76
+ reservation.apiVersion !== checked.request.apiVersion ||
77
+ reservation.firstDispatchedAt !== checked.request.firstDispatchedAt ||
78
+ !equal(JSON.parse(reservation.accountJSON), checked.original.account) ||
79
+ !equal(JSON.parse(reservation.timingPolicyJSON), checked.original.timingPolicy))
80
+ configureConflict();
81
+ const rebuilt = await constructRenewalConfigurationReceiptV2({
82
+ configuration: checked.configuration,
83
+ actualDispatch: checked.original.dispatch,
84
+ providerSnapshot: received.body,
85
+ transport: received.transport,
86
+ });
87
+ const admittedJSON = admitReceipt(receiptJSON, rebuilt);
88
+ // Retention at head2 never models a prospective, potentially larger event3.
89
+ if (events.length === 3)
90
+ validateConfigureReceiptEventDATA(events[2].dataJSON, rebuilt);
91
+ return {
92
+ receiptJSON: admittedJSON,
93
+ receiptBinding: rebuilt.binding,
94
+ receipt: rebuilt,
95
+ };
96
+ }
97
+ export function validateConfigureReceiptEventDATA(raw, receipt) {
98
+ const parsed = JSON.parse(raw);
99
+ captureConfigureReceipt(parsed);
100
+ if (!equal(parsed, {
101
+ event: "receipt",
102
+ stage: "configure",
103
+ request: receipt.request,
104
+ receipt,
105
+ }))
106
+ configureConflict();
107
+ }
108
+ //# sourceMappingURL=configureAcknowledgement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configureAcknowledgement.js","sourceRoot":"","sources":["../../../src/component/renewalOperations/configureAcknowledgement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,MAAM,yCAAyC,CAAC;AACjG,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iEAAiE,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sEAAsE,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,iDAAiD,CAAC;AAGxE,OAAO,EACL,kCAAkC,EAClC,iBAAiB,EACjB,UAAU,GACX,MAAM,0BAA0B,CAAC;AAKlC,SAAS,YAAY,CAAC,WAAmB,EAAE,OAAgB;IACzD,IACE,WAAW,CAAC,MAAM,GAAG,MAAM;QAC3B,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,MAAM;QAErD,iBAAiB,EAAE,CAAC;IACtB,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAChD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC;QAAE,iBAAiB,EAAE,CAAC;IACjD,MAAM,MAAM,GAAG,eAAe,CAAC;QAC7B,MAAM,EAAE,w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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChC,IACE,CAAC,KAAK,CAAC,MAAM,EAAE;QACb,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO;KACR,CAAC;QAEF,iBAAiB,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { QueryCtx } from "../_generated/server.js";
2
+ import { canonicalJournalRecord } from "../../shared/renewalOperationJournal.js";
3
+ type Reader = Pick<QueryCtx, "db">;
4
+ /** Parent linkage is checked DATA; host authorization and live custody remain separate. */
5
+ export declare function validateConfigureParent(ctx: Reader, full: ReturnType<typeof canonicalJournalRecord>): Promise<{
6
+ basisJSON: string;
7
+ parentOperationId: import("convex/values").GenericId<"renewalOperations">;
8
+ } | null>;
9
+ export {};
10
+ //# sourceMappingURL=configureParent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configureParent.d.ts","sourceRoot":"","sources":["../../../src/component/renewalOperations/configureParent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAWjF,KAAK,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACnC,2FAA2F;AAC3F,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC;;;UAsDhD"}
@@ -0,0 +1,62 @@
1
+ import { equal } from "../../client/billing/renewalAggregate/shared.js";
2
+ import { originalRecord, currentReservation, eventChain, checkedInitialBasis, validateV2KnownAcknowledgement, } from "./helpers.js";
3
+ import { configureConflict, jsonObject } from "./configureValidation.js";
4
+ /** Parent linkage is checked DATA; host authorization and live custody remain separate. */
5
+ export async function validateConfigureParent(ctx, full) {
6
+ if (!("recordVersion" in full))
7
+ return null;
8
+ const child = jsonObject(JSON.parse(full.json));
9
+ if (child.stage !== "configure")
10
+ return null;
11
+ try {
12
+ const link = jsonObject(child.parentAttachment);
13
+ if (typeof link.operationId !== "string")
14
+ configureConflict();
15
+ const parentId = ctx.db.normalizeId("renewalOperations", link.operationId);
16
+ if (!parentId)
17
+ configureConflict();
18
+ const row = await ctx.db.get("renewalOperations", parentId);
19
+ if (!row || row.recordVersion !== 2)
20
+ configureConflict();
21
+ const parentFull = await originalRecord(ctx, row);
22
+ const parent = jsonObject(JSON.parse(parentFull.json));
23
+ if (parent.stage !== "attach")
24
+ configureConflict();
25
+ const reservation = await currentReservation(ctx, row, parentFull);
26
+ if (!reservation || reservation.stage !== "attach")
27
+ configureConflict();
28
+ const basis = checkedInitialBasis(row, reservation.attemptId, reservation);
29
+ if (!basis)
30
+ configureConflict();
31
+ const events = await eventChain(ctx, reservation);
32
+ if (events.length !== 3)
33
+ configureConflict();
34
+ const known = await validateV2KnownAcknowledgement(ctx, row, parentFull, reservation, events);
35
+ if (!known)
36
+ configureConflict();
37
+ const source = jsonObject(child.configureRecord);
38
+ const configuration = jsonObject(source.configuration);
39
+ const rawReceipt = jsonObject(configuration.attachReceipt);
40
+ const policy = jsonObject(child.timingPolicy);
41
+ const parentPolicy = jsonObject(parent.timingPolicy);
42
+ if (link.operationId !== row._id ||
43
+ link.attemptId !== reservation.attemptId ||
44
+ link.sourcePayloadId !== reservation.payloadId ||
45
+ link.receiptBinding !== known.admitted.receiptBinding ||
46
+ !equal(source.attachReceipt, JSON.parse(known.admitted.receiptJSON)) ||
47
+ !equal(rawReceipt.attachRequest, parent.attachRequest) ||
48
+ !equal(source.originalBundle, parent.originalBundle) ||
49
+ !equal(child.account, parent.account) ||
50
+ child.apiVersion !== parent.apiVersion ||
51
+ policy.workEndWallMs !== parentPolicy.workEndWallMs ||
52
+ policy.endWallMs !== parentPolicy.endWallMs ||
53
+ policy.periodStart !== parentPolicy.periodStart ||
54
+ policy.periodEnd !== parentPolicy.periodEnd)
55
+ configureConflict();
56
+ return { basisJSON: basis.basisJSON, parentOperationId: row._id };
57
+ }
58
+ catch {
59
+ return configureConflict();
60
+ }
61
+ }
62
+ //# sourceMappingURL=configureParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configureParent.js","sourceRoot":"","sources":["../../../src/component/renewalOperations/configureParent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,iDAAiD,CAAC;AACxE,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,8BAA8B,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGzE,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,GAAW,EACX,IAA+C;IAE/C,IAAI,CAAC,CAAC,eAAe,IAAI,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,IAAI,KAAK,CAAC,KAAK,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAChD,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ;YAAE,iBAAiB,EAAE,CAAC;QAC9D,MAAM,QAAQ,GAAG,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3E,IAAI,CAAC,QAAQ;YAAE,iBAAiB,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAA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G,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACrD,IACE,IAAI,CAAC,WAAW,KAAK,GAAG,CAAC,GAAG;YAC5B,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC,SAAS;YACxC,IAAI,CAAC,eAAe,KAAK,WAAW,CAAC,SAAS;YAC9C,IAAI,CAAC,cAAc,KAAK,KAAK,CAAC,QAAQ,CAAC,cAAc;YACrD,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACpE,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC;YACtD,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC;YACpD,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;YACrC,KAAK,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU;YACtC,MAAM,CAAC,aAAa,KAAK,YAAY,CAAC,aAAa;YACnD,MAAM,CAAC,SAAS,KAAK,YAAY,CAAC,SAAS;YAC3C,MAAM,CAAC,WAAW,KAAK,YAAY,CAAC,WAAW;YAC/C,MAAM,CAAC,SAAS,KAAK,YAAY,CAAC,SAAS;YAE3C,iBAAiB,EAAE,CAAC;QACtB,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,iBAAiB,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { canonicalJournalRecord } from "../../shared/renewalOperationJournal.js";
2
+ export declare function configureConflict(): never;
3
+ export declare function jsonObject(value: unknown): Record<string, unknown>;
4
+ /** Complete C3/C6/C7 reconstruction of unsigned configure DATA. */
5
+ export declare function validateOperationalConfigureSource(full: ReturnType<typeof canonicalJournalRecord>): Promise<{
6
+ original: Record<string, unknown>;
7
+ source: Record<string, unknown>;
8
+ configuration: import("../../client/renewal.js").ProjectRenewalConfigurationV2Options;
9
+ request: import("../../client/renewal.js").ProjectedRenewalConfigurationV2;
10
+ receipt: import("../../client/renewal.js").RenewalScheduleAttachmentReceiptV2;
11
+ }>;
12
+ //# sourceMappingURL=configureValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configureValidation.d.ts","sourceRoot":"","sources":["../../../src/component/renewalOperations/configureValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAKjF,wBAAgB,iBAAiB,IAAI,KAAK,CAEzC;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIlE;AACD,mEAAmE;AACnE,wBAAsB,kCAAkC,CACtD,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC;;;;;;GAsDhD"}
@@ -0,0 +1,64 @@
1
+ import { captureConfigureSource } from "../../client/billing/renewalAttach/internal/c10/eventCapture.js";
2
+ import { reconstructConfigurationV2 } from "../../client/billing/renewalV2/index.js";
3
+ import { equal } from "../../client/billing/renewalAggregate/shared.js";
4
+ export function configureConflict() {
5
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
6
+ }
7
+ export function jsonObject(value) {
8
+ if (!value || typeof value !== "object" || Array.isArray(value))
9
+ configureConflict();
10
+ return value;
11
+ }
12
+ /** Complete C3/C6/C7 reconstruction of unsigned configure DATA. */
13
+ export async function validateOperationalConfigureSource(full) {
14
+ try {
15
+ const original = jsonObject(JSON.parse(full.json));
16
+ const source = jsonObject(original.configureRecord);
17
+ const keys = [
18
+ "configuration",
19
+ "request",
20
+ "attachReceipt",
21
+ "originalBundle",
22
+ ];
23
+ if (Object.keys(source).length !== keys.length ||
24
+ Object.keys(source).some((key) => !keys.includes(key)))
25
+ configureConflict();
26
+ const configuration = captureConfigureSource(source.configuration);
27
+ // The constructor revalidates all semantic fields of this captured JSON DATA.
28
+ const rebuilt = await reconstructConfigurationV2(configuration);
29
+ if (!rebuilt.material || !("requestIdentity" in rebuilt.result))
30
+ configureConflict();
31
+ const { prepared, receipt } = rebuilt.material;
32
+ const request = rebuilt.result;
33
+ const account = jsonObject(original.account);
34
+ const policy = jsonObject(original.timingPolicy);
35
+ const seven = {
36
+ scope: request.scope,
37
+ apiVersion: request.apiVersion,
38
+ method: request.method,
39
+ path: request.path,
40
+ payload: request.payload,
41
+ key: request.key,
42
+ firstDispatchedAt: request.firstDispatchedAt,
43
+ };
44
+ if (original.stage !== "configure" ||
45
+ original.apiVersion !== request.apiVersion ||
46
+ !equal(source.configuration, configuration) ||
47
+ !equal(source.request, request) ||
48
+ !equal(source.attachReceipt, receipt) ||
49
+ !equal(original.dispatch, seven) ||
50
+ full.requestBinding !== request.requestIdentity.binding ||
51
+ account.mode !== "platform" ||
52
+ account.stripeAccount !== null ||
53
+ account.livemode !== prepared.expected.livemode ||
54
+ policy.firstDispatchedAt !== request.firstDispatchedAt ||
55
+ policy.periodStart !== prepared.expected.periodStart ||
56
+ policy.periodEnd !== prepared.expected.periodEnd)
57
+ configureConflict();
58
+ return { original, source, configuration, request, receipt };
59
+ }
60
+ catch {
61
+ return configureConflict();
62
+ }
63
+ }
64
+ //# sourceMappingURL=configureValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configureValidation.js","sourceRoot":"","sources":["../../../src/component/renewalOperations/configureValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAC;AACzG,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,iDAAiD,CAAC;AAExE,MAAM,UAAU,iBAAiB;IAC/B,MAAM,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC1C,CA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AAC;QACP,OAAO,iBAAiB,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
@@ -1,4 +1,5 @@
1
- import { constructRenewalScheduleAttachmentReceiptV2 } from "../../client/billing/renewalV2/index.js";
1
+ import { validateAttachAcknowledgement } from "./attachValidation.js";
2
+ export { validateAttachAcknowledgement, validateAttachReceiptEventDATA, admitAttachReceiptOutputDATA, } from "./attachValidation.js";
2
3
  import type { Doc } from "../_generated/dataModel.js";
3
4
  import type { QueryCtx } from "../_generated/server.js";
4
5
  import { canonicalJournalRecord } from "../../shared/renewalOperationJournal.js";
@@ -15,7 +16,7 @@ export declare function findOperation(ctx: Reader, authorizationScope: string, l
15
16
  basisJSON: string;
16
17
  policyJSON: string;
17
18
  sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
18
- stage: "attach";
19
+ stage: "attach" | "configure";
19
20
  version: 1;
20
21
  } | undefined;
21
22
  knownAcknowledgement?: {
@@ -28,7 +29,7 @@ export declare function findOperation(ctx: Reader, authorizationScope: string, l
28
29
  responsePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
29
30
  schemaVersion: 1;
30
31
  sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
31
- stage: "attach";
32
+ stage: "attach" | "configure";
32
33
  } | undefined;
33
34
  logicalOperationId: string;
34
35
  payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
@@ -48,11 +49,11 @@ export declare function originalRecord(ctx: Reader, row: Doc<"renewalOperations"
48
49
  /** V2 unsigned full C1/C2 consistency, never operational qualification. */
49
50
  export declare function validateOperationalAttachSource(full: ReturnType<typeof canonicalJournalRecord>): Promise<void>;
50
51
  export declare function reservationFields(row: Doc<"renewalOperations">, full: ReturnType<typeof canonicalJournalRecord>): {
52
+ stage: "attach" | "configure";
51
53
  key: string;
52
54
  apiVersion: string;
53
55
  firstDispatchedAt: number;
54
56
  accountJSON: string;
55
- stage: "attach";
56
57
  recordVersion: 2;
57
58
  timingPolicyJSON: string;
58
59
  operationId: import("convex/values").GenericId<"renewalOperations">;
@@ -89,7 +90,7 @@ export declare function checkedInitialBasis(row: Doc<"renewalOperations">, attem
89
90
  basisJSON: string;
90
91
  policyJSON: string;
91
92
  sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
92
- stage: "attach";
93
+ stage: "attach" | "configure";
93
94
  version: 1;
94
95
  } | null;
95
96
  export declare function attemptRows(ctx: Reader, operationId: Doc<"renewalOperations">["_id"]): Promise<({
@@ -131,15 +132,15 @@ export declare function attemptRows(ctx: Reader, operationId: Doc<"renewalOperat
131
132
  preparedRevision: 0;
132
133
  recordVersion: 2;
133
134
  requestBinding: string;
134
- stage: "attach";
135
+ stage: "attach" | "configure";
135
136
  timingPolicyJSON: string;
136
137
  })[]>;
137
138
  export declare function currentReservation(ctx: Reader, row: Doc<"renewalOperations">, full: ReturnType<typeof canonicalJournalRecord>): Promise<{
139
+ stage: "attach" | "configure";
138
140
  key: string;
139
141
  apiVersion: string;
140
142
  firstDispatchedAt: number;
141
143
  accountJSON: string;
142
- stage: "attach";
143
144
  recordVersion: 2;
144
145
  timingPolicyJSON: string;
145
146
  operationId: import("convex/values").GenericId<"renewalOperations">;
@@ -188,17 +189,6 @@ export declare function eventChain(ctx: Reader, reservation: Reservation): Promi
188
189
  eventId: import("convex/values").GenericId<"renewalOperationEvents">;
189
190
  dataJSON: string;
190
191
  }[]>;
191
- type AttachReceipt = Awaited<ReturnType<typeof constructRenewalScheduleAttachmentReceiptV2>>;
192
- /** Parsed JSON DATA admission only; no caller-object or provider provenance. */
193
- export declare function admitAttachReceiptOutputDATA(receiptJSON: string, rebuilt: AttachReceipt): string;
194
- /** Full stored-source/event/C3 consistency; these are unsigned DATA checks. */
195
- export declare function validateAttachAcknowledgement(full: ReturnType<typeof canonicalJournalRecord>, reservation: Reservation, events: Awaited<ReturnType<typeof eventChain>>, receiptJSON: string): Promise<{
196
- receiptJSON: string;
197
- receiptBinding: string;
198
- receipt: import("../../client/renewal.js").RenewalScheduleAttachmentReceiptV2;
199
- }>;
200
- /** Whole typed C10 DATA and full request/receipt equality, never ACK authority. */
201
- export declare function validateAttachReceiptEventDATA(raw: string, receipt: AttachReceipt): void;
202
192
  /** Optional stored known DATA; every reference, owner and full JSON is checked. */
203
193
  export declare function validateKnownAcknowledgement(ctx: Reader, row: Doc<"renewalOperations">, reservation: Reservation, events: Awaited<ReturnType<typeof eventChain>>, admitted: Pick<Awaited<ReturnType<typeof validateAttachAcknowledgement>>, "receiptJSON" | "receiptBinding">): Promise<{
204
194
  attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
@@ -210,7 +200,7 @@ export declare function validateKnownAcknowledgement(ctx: Reader, row: Doc<"rene
210
200
  responsePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
211
201
  schemaVersion: 1;
212
202
  sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
213
- stage: "attach";
203
+ stage: "attach" | "configure";
214
204
  } | null>;
215
205
  /** Leaf over an already checked chain; never creates lineage or reloads history. */
216
206
  export declare function validateV2KnownAcknowledgement(ctx: Reader, row: Doc<"renewalOperations">, full: ReturnType<typeof canonicalJournalRecord>, reservation: Reservation, events: Awaited<ReturnType<typeof eventChain>>): Promise<{
@@ -224,13 +214,18 @@ export declare function validateV2KnownAcknowledgement(ctx: Reader, row: Doc<"re
224
214
  responsePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
225
215
  schemaVersion: 1;
226
216
  sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
227
- stage: "attach";
217
+ stage: "attach" | "configure";
228
218
  };
229
219
  admitted: {
220
+ receiptJSON: string;
221
+ receiptBinding: string;
222
+ receipt: import("../../client/renewal.js").RenewalConfigurationReceiptV2;
223
+ stage: "configure";
224
+ } | {
230
225
  receiptJSON: string;
231
226
  receiptBinding: string;
232
227
  receipt: import("../../client/renewal.js").RenewalScheduleAttachmentReceiptV2;
228
+ stage: "attach";
233
229
  };
234
230
  } | null>;
235
- export {};
236
231
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/component/renewalOperations/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2CAA2C,EAG5C,MAAM,yCAAyC,CAAC;AASjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAGL,sBAAsB,EAEvB,MAAM,yCAAyC,CAAC;AAEjD,KAAK,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACnC,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,kBAAkB,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAY3B;AACD,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC;;;;;;;IAwB9B;AAED,2EAA2E;AAC3E,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC,EAC7B,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC;;;;;;;;;;;;;;;aAYpC,CAAC;sBACQ,CAAC;uBACA,CAAC;;;;;;;;;;;;;;;aAFX,CAAC;sBACQ,CAAC;uBACA,CAAC;EAEvB;AACD,wEAAwE;AACxE,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC,EAC7B,SAAS,EAAE,GAAG,CAAC,0BAA0B,CAAC,CAAC,KAAK,CAAC,EACjD,MAAM,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC;;;;;;;SAuB7C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ACD,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW;;;;;;;;;;KAwDrE;AAED,mFAAmF;AACnF,wBAAsB,4BAA4B,CAChD,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC,EAC7B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,EAC9C,QAAQ,EAAE,IAAI,CACZ,OAAO,CAAC,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,EACzD,aAAa,GAAG,gBAAgB,CACjC;;;;;;;;;;;UAkCF;AAED,oFAAoF;AACpF,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC,EAC7B,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,EAC/C,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;UA+B/C"}
@@ -1,8 +1,9 @@
1
- import { renewalSnapshot } from "../../client/billing/renewalReplacementSnapshot.js";
2
- import { constructRenewalScheduleAttachmentReceiptV2, prepareRenewalPriceReplacementV2, prepareRenewalScheduleAttachmentV2, } from "../../client/billing/renewalV2/index.js";
3
- import { captureAttachmentReceipt } from "../../client/billing/renewalV2/receipt.js";
4
- import { captureAttachSource, captureAttachDispatch, captureAttachResponse, captureAttachReceipt, } from "../../client/billing/renewalAttach/internal/c10/eventCapture.js";
5
- import { requiredJSONSnapshot } from "../../client/billing/renewalAttach/internal/material/requiredJson.js";
1
+ import { validateStageAcknowledgement } from "./stageAcknowledgement.js";
2
+ import { acknowledgementConflict, jsonObject, sameJSON, } from "./attachValidation.js";
3
+ export { validateAttachAcknowledgement, validateAttachReceiptEventDATA, admitAttachReceiptOutputDATA, } from "./attachValidation.js";
4
+ import { validateOperationalConfigureSource } from "./configureValidation.js";
5
+ import { prepareRenewalPriceReplacementV2, prepareRenewalScheduleAttachmentV2, } from "../../client/billing/renewalV2/index.js";
6
+ import { captureAttachSource } from "../../client/billing/renewalAttach/internal/c10/eventCapture.js";
6
7
  import { canonicalJournalEvent, canonicalInitialBasis, canonicalJournalRecord, journalReservationMaterial, } from "../../shared/renewalOperationJournal.js";
7
8
  export async function findOperation(ctx, authorizationScope, logicalOperationId) {
8
9
  const rows = await ctx.db
@@ -41,6 +42,10 @@ export async function originalRecord(ctx, row) {
41
42
  export async function validateOperationalAttachSource(full) {
42
43
  if (!("recordVersion" in full))
43
44
  return;
45
+ if (JSON.parse(full.json).stage === "configure") {
46
+ await validateOperationalConfigureSource(full);
47
+ return;
48
+ }
44
49
  try {
45
50
  const parsed = JSON.parse(full.json);
46
51
  const original = jsonObject(parsed);
@@ -245,167 +250,6 @@ export async function eventChain(ctx, reservation) {
245
250
  }
246
251
  return events;
247
252
  }
248
- function acknowledgementConflict() {
249
- throw Error("RENEWAL_JOURNAL_CONFLICT");
250
- }
251
- function isJSONObject(value) {
252
- return value !== null && typeof value === "object" && !Array.isArray(value);
253
- }
254
- function jsonObject(value) {
255
- if (!isJSONObject(value))
256
- acknowledgementConflict();
257
- return value;
258
- }
259
- function sameJSON(left, right) {
260
- return (JSON.stringify(renewalSnapshot(left)) ===
261
- JSON.stringify(renewalSnapshot(right)));
262
- }
263
- /** Parsed JSON DATA admission only; no caller-object or provider provenance. */
264
- export function admitAttachReceiptOutputDATA(receiptJSON, rebuilt) {
265
- if (typeof receiptJSON !== "string" ||
266
- receiptJSON.length > 500000 ||
267
- new TextEncoder().encode(receiptJSON).length > 500000)
268
- acknowledgementConflict();
269
- const parsed = JSON.parse(receiptJSON);
270
- if (!sameJSON(parsed, rebuilt))
271
- acknowledgementConflict();
272
- const output = renewalSnapshot({
273
- status: "attach_acknowledged",
274
- operationalAuthority: false,
275
- receipt: parsed,
276
- });
277
- const slots = new Map([
278
- [
279
- JSON.stringify(["receipt", "logicalBinding"]),
280
- { expected: rebuilt.logicalBinding, family: "renewal" },
281
- ],
282
- [
283
- JSON.stringify(["receipt", "request", "logicalBinding"]),
284
- { expected: rebuilt.request.logicalBinding, family: "renewal" },
285
- ],
286
- [
287
- JSON.stringify(["receipt", "request", "requestIdentity", "binding"]),
288
- {
289
- expected: rebuilt.request.requestIdentity.binding,
290
- family: "renewal-attach",
291
- },
292
- ],
293
- [
294
- JSON.stringify(["receipt", "binding"]),
295
- { expected: rebuilt.binding, family: "renewal-attach-receipt" },
296
- ],
297
- ]);
298
- const found = new Set();
299
- function walk(value, path) {
300
- const key = JSON.stringify(path);
301
- const slot = slots.get(key);
302
- if (slot) {
303
- if (value !== slot.expected ||
304
- typeof value !== "string" ||
305
- !new RegExp("^" + slot.family + ":v2:sha256:[0-9a-f]{64}$").test(value))
306
- acknowledgementConflict();
307
- found.add(key);
308
- return;
309
- }
310
- if (value === null || typeof value !== "object") {
311
- requiredJSONSnapshot(value);
312
- return;
313
- }
314
- for (const [name, child] of Object.entries(value)) {
315
- requiredJSONSnapshot(name);
316
- requiredJSONSnapshot({ [name]: child === null ? null : true });
317
- walk(child, [...path, name]);
318
- }
319
- }
320
- walk(output, []);
321
- if (found.size !== 4 ||
322
- new TextEncoder().encode(JSON.stringify(output)).length > 500000)
323
- acknowledgementConflict();
324
- return JSON.stringify(output.receipt);
325
- }
326
- /** Full stored-source/event/C3 consistency; these are unsigned DATA checks. */
327
- export async function validateAttachAcknowledgement(full, reservation, events, receiptJSON) {
328
- if (reservation.stage !== "attach" ||
329
- (events.length !== 2 && events.length !== 3) ||
330
- events[0].sequence !== 1 ||
331
- events[1].sequence !== 2)
332
- acknowledgementConflict();
333
- const parsedOriginal = JSON.parse(full.json);
334
- const original = jsonObject(parsedOriginal);
335
- const account = jsonObject(original.account);
336
- const source = captureAttachSource(original.attachRequest);
337
- if (!sameJSON(original.attachRequest, source))
338
- acknowledgementConflict();
339
- const parsedDispatch = JSON.parse(events[0].dataJSON);
340
- const parsedResponse = JSON.parse(events[1].dataJSON);
341
- captureAttachDispatch(parsedDispatch);
342
- captureAttachResponse(parsedResponse);
343
- const dispatch = jsonObject(parsedDispatch);
344
- const response = jsonObject(parsedResponse);
345
- const raw = captureAttachmentReceipt({
346
- attachRequest: source,
347
- actualDispatch: original.dispatch,
348
- providerSnapshot: response.body,
349
- });
350
- // C3 internally rebuilds C1/C2 and compares the entire closed seven-wire input.
351
- const rebuilt = await constructRenewalScheduleAttachmentReceiptV2({
352
- attachRequest: source,
353
- actualDispatch: raw.actualDispatch,
354
- providerSnapshot: raw.providerSnapshot,
355
- });
356
- const request = rebuilt.request;
357
- const seven = {
358
- scope: request.scope,
359
- apiVersion: request.apiVersion,
360
- method: request.method,
361
- path: request.path,
362
- payload: request.payload,
363
- key: request.key,
364
- firstDispatchedAt: request.firstDispatchedAt,
365
- };
366
- if (!sameJSON(original.dispatch, seven) ||
367
- !sameJSON(dispatch.request, request) ||
368
- !sameJSON(response.request, request) ||
369
- original.stage !== "attach" ||
370
- original.apiVersion !== request.apiVersion ||
371
- full.requestBinding !== request.requestIdentity.binding ||
372
- reservation.key !== request.key ||
373
- reservation.apiVersion !== request.apiVersion ||
374
- reservation.firstDispatchedAt !== request.firstDispatchedAt ||
375
- account.mode !== "platform" ||
376
- account.stripeAccount !== null ||
377
- account.livemode !== rebuilt.livemode ||
378
- !sameJSON(JSON.parse(reservation.accountJSON), account))
379
- acknowledgementConflict();
380
- if ("recordVersion" in reservation) {
381
- if (!sameJSON(JSON.parse(reservation.timingPolicyJSON), original.timingPolicy))
382
- acknowledgementConflict();
383
- }
384
- else if (!sameJSON(JSON.parse(reservation.basisJSON), original.basis))
385
- acknowledgementConflict();
386
- const admittedJSON = admitAttachReceiptOutputDATA(receiptJSON, rebuilt);
387
- // Only ACTUAL published event3 is checked. A head2 retention does not model
388
- // or require a prospective receipt-event envelope to pass another cap.
389
- if (events.length === 3)
390
- validateAttachReceiptEventDATA(events[2].dataJSON, rebuilt);
391
- return {
392
- receiptJSON: admittedJSON,
393
- receiptBinding: rebuilt.binding,
394
- receipt: rebuilt,
395
- };
396
- }
397
- /** Whole typed C10 DATA and full request/receipt equality, never ACK authority. */
398
- export function validateAttachReceiptEventDATA(raw, receipt) {
399
- const parsed = JSON.parse(raw);
400
- captureAttachReceipt(parsed);
401
- if (!sameJSON(parsed, {
402
- event: "receipt",
403
- stage: "attach",
404
- request: receipt.request,
405
- receipt,
406
- }))
407
- acknowledgementConflict();
408
- }
409
253
  /** Optional stored known DATA; every reference, owner and full JSON is checked. */
410
254
  export async function validateKnownAcknowledgement(ctx, row, reservation, events, admitted) {
411
255
  const retained = row.knownAcknowledgement;
@@ -413,7 +257,7 @@ export async function validateKnownAcknowledgement(ctx, row, reservation, events
413
257
  return null;
414
258
  if (events.length < 2 ||
415
259
  retained.schemaVersion !== 1 ||
416
- retained.stage !== "attach" ||
260
+ retained.stage !== reservation.stage ||
417
261
  retained.attemptId !== reservation.attemptId ||
418
262
  retained.sourcePayloadId !== reservation.payloadId ||
419
263
  retained.dispatchEventId !== events[0].eventId ||
@@ -431,7 +275,7 @@ export async function validateKnownAcknowledgement(ctx, row, reservation, events
431
275
  owner.kind !== "receipt" ||
432
276
  owner.operationId !== row._id ||
433
277
  owner.attemptId !== reservation.attemptId ||
434
- owner.stage !== "attach")
278
+ owner.stage !== reservation.stage)
435
279
  acknowledgementConflict();
436
280
  return retained;
437
281
  }
@@ -444,7 +288,7 @@ export async function validateV2KnownAcknowledgement(ctx, row, full, reservation
444
288
  const payload = await ctx.db.get("renewalOperationPayloads", row.knownAcknowledgement.receiptPayloadId);
445
289
  if (!payload)
446
290
  acknowledgementConflict();
447
- const admitted = await validateAttachAcknowledgement(full, reservation, events, payload.json);
291
+ const admitted = await validateStageAcknowledgement(full, reservation, events, payload.json);
448
292
  const retained = await validateKnownAcknowledgement(ctx, row, reservation, events, admitted);
449
293
  if (retained === null)
450
294
  acknowledgementConflict();