@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.
Files changed (87) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts +564 -0
  4. package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/observation/freshActor.js +103 -21
  6. package/dist/client/billing/renewalAttach/internal/observation/freshActor.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts +18 -1
  8. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js +54 -1
  10. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts +4 -0
  12. package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts.map +1 -1
  13. package/dist/client/billing/renewalAttach/internal/observation/invocation.js +1 -0
  14. package/dist/client/billing/renewalAttach/internal/observation/invocation.js.map +1 -1
  15. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts +4 -0
  16. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts.map +1 -1
  17. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js +6 -1
  18. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js.map +1 -1
  19. package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.d.ts +38 -0
  20. package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.d.ts.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.js +172 -0
  22. package/dist/client/billing/renewalAttach/internal/observation/witnessAuthorization.js.map +1 -0
  23. package/dist/client/billing/renewalAttach/internal/observation/witnessData.d.ts +135 -0
  24. package/dist/client/billing/renewalAttach/internal/observation/witnessData.d.ts.map +1 -0
  25. package/dist/client/billing/renewalAttach/internal/observation/witnessData.js +143 -0
  26. package/dist/client/billing/renewalAttach/internal/observation/witnessData.js.map +1 -0
  27. package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.d.ts +85 -0
  28. package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.d.ts.map +1 -0
  29. package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.js +121 -0
  30. package/dist/client/billing/renewalAttach/internal/observation/witnessOperation.js.map +1 -0
  31. package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.d.ts +44 -0
  32. package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.d.ts.map +1 -0
  33. package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.js +4 -0
  34. package/dist/client/billing/renewalAttach/internal/operations/witnessProfiles.js.map +1 -0
  35. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts +1 -1
  36. package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts +21 -21
  37. package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.d.ts +3 -3
  38. package/dist/client/billing/renewalAttach/internal/producer/operationFactory.d.ts +1 -1
  39. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  40. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  41. package/dist/component/_generated/api.d.ts +24 -0
  42. package/dist/component/_generated/api.d.ts.map +1 -1
  43. package/dist/component/_generated/api.js.map +1 -1
  44. package/dist/component/_generated/component.d.ts +94 -10
  45. package/dist/component/_generated/component.d.ts.map +1 -1
  46. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  47. package/dist/component/balanceFunding/queries.d.ts +1 -1
  48. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  49. package/dist/component/renewalWitnesses/mutations.d.ts +45 -0
  50. package/dist/component/renewalWitnesses/mutations.d.ts.map +1 -0
  51. package/dist/component/renewalWitnesses/mutations.js +14 -0
  52. package/dist/component/renewalWitnesses/mutations.js.map +1 -0
  53. package/dist/component/renewalWitnesses/queries.d.ts +39 -0
  54. package/dist/component/renewalWitnesses/queries.d.ts.map +1 -0
  55. package/dist/component/renewalWitnesses/queries.js +11 -0
  56. package/dist/component/renewalWitnesses/queries.js.map +1 -0
  57. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  58. package/docs/renewal-example-authorization.md +74 -0
  59. package/docs/renewal-witness-protocol.md +61 -10
  60. package/package.json +1 -1
  61. package/src/client/billing/renewalAttach/internal/observation/freshActor.ts +142 -19
  62. package/src/client/billing/renewalAttach/internal/observation/freshTransport.ts +90 -1
  63. package/src/client/billing/renewalAttach/internal/observation/invocation.ts +2 -0
  64. package/src/client/billing/renewalAttach/internal/observation/readerAuthorization.ts +6 -1
  65. package/src/client/billing/renewalAttach/internal/observation/witnessAcquisition.integration.test.ts +348 -0
  66. package/src/client/billing/renewalAttach/internal/observation/witnessActor.integration.test.ts +204 -0
  67. package/src/client/billing/renewalAttach/internal/observation/witnessAuthorization.ts +239 -0
  68. package/src/client/billing/renewalAttach/internal/observation/witnessCapabilities.integration.test.ts +231 -0
  69. package/src/client/billing/renewalAttach/internal/observation/witnessData.ts +189 -0
  70. package/src/client/billing/renewalAttach/internal/observation/witnessHistorical.integration.test.ts +98 -0
  71. package/src/client/billing/renewalAttach/internal/observation/witnessImmutable.integration.test.ts +78 -0
  72. package/src/client/billing/renewalAttach/internal/observation/witnessInvoice.integration.test.ts +85 -0
  73. package/src/client/billing/renewalAttach/internal/observation/witnessLifecycle.integration.test.ts +264 -0
  74. package/src/client/billing/renewalAttach/internal/observation/witnessOperation.ts +205 -0
  75. package/src/client/billing/renewalAttach/internal/observation/witnessProfile.integration.test.ts +93 -0
  76. package/src/client/billing/renewalAttach/internal/observation/witnessRPCControls.integration.test.ts +256 -0
  77. package/src/client/billing/renewalAttach/internal/operations/witnessProfiles.ts +58 -0
  78. package/src/client/billing/renewalAttach/internal/test-fixtures/invoiceObservation.ts +3 -1
  79. package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +8 -0
  80. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +28 -11
  81. package/src/client/billing/renewalAttach/internal/test-fixtures/witnessHistory.ts +70 -0
  82. package/src/client/billing/renewalAttach/internal/test-fixtures/witnessObservation.ts +353 -0
  83. package/src/component/_generated/api.ts +24 -0
  84. package/src/component/_generated/component.ts +98 -10
  85. package/src/component/renewalWitnesses/mutations.ts +17 -0
  86. package/src/component/renewalWitnesses/queries.ts +11 -0
  87. package/src/component/renewalWitnesses/routes.test.ts +154 -0
@@ -0,0 +1,172 @@
1
+ import { types } from "node:util";
2
+ import { getFunctionAddress } from "convex/server";
3
+ import { COMPILED_WITNESS_CAPTURE_ENTRIES, COMPILED_WITNESS_READ_ENTRIES, } from "../operations/witnessProfiles.js";
4
+ import { COMPILED_FRESH_OBSERVATION_ENTRIES, COMPILED_OBSERVATION_HISTORY_ENTRIES, } from "../operations/sourceOperations.js";
5
+ import { readMaintainedRootComponent, readCheckedJournalActionRPC, } from "../producer/classOwnedActionRoot.js";
6
+ import { invoiceProfileGuard } from "./invoiceAuthorization.js";
7
+ import { closed, freeze } from "../c10/ownData.js";
8
+ import { matchConfigureDATA } from "../producer/configureJournalData.js";
9
+ import { captureReaderQueryDATA, readerText as text, } from "./readerAuthorization.js";
10
+ import { witnessIdentity, witnessNeed as need, } from "../../../../../shared/renewalWitness.js";
11
+ const nativeThen = Promise.prototype.then;
12
+ export const witnessAddress = (ref) => JSON.stringify(getFunctionAddress(ref));
13
+ export function witnessProfileGuard(profile, mode) {
14
+ const entries = mode === "retain"
15
+ ? COMPILED_WITNESS_CAPTURE_ENTRIES
16
+ : COMPILED_WITNESS_READ_ENTRIES;
17
+ need(!types.isProxy(profile));
18
+ closed(profile, ["freshProfile", "invoiceProfile", "authorizationQuery"]);
19
+ need(Object.isFrozen(profile) && entries.includes(profile));
20
+ const fresh = profile.freshProfile;
21
+ need(COMPILED_FRESH_OBSERVATION_ENTRIES.includes(fresh) &&
22
+ COMPILED_OBSERVATION_HISTORY_ENTRIES.includes(fresh.historyEntry));
23
+ need(entries.filter((entry) => entry.freshProfile.historyEntry.component ===
24
+ fresh.historyEntry.component).length === 1);
25
+ if (profile.invoiceProfile !== null) {
26
+ invoiceProfileGuard(profile.invoiceProfile);
27
+ need(profile.invoiceProfile.freshProfile === fresh);
28
+ }
29
+ }
30
+ /** The EMPTY check precedes root/input reflection, clocks and SDK selection. */
31
+ export function captureWitnessProfile(root, mode) {
32
+ const entries = mode === "retain"
33
+ ? COMPILED_WITNESS_CAPTURE_ENTRIES
34
+ : COMPILED_WITNESS_READ_ENTRIES;
35
+ if (entries.length === 0)
36
+ throw Error("RENEWAL_WITNESS_UNBOUND");
37
+ const component = readMaintainedRootComponent(root);
38
+ const matches = entries.filter((profile) => {
39
+ need(!types.isProxy(profile));
40
+ closed(profile, ["freshProfile", "invoiceProfile", "authorizationQuery"]);
41
+ return profile.freshProfile.historyEntry.component === component;
42
+ });
43
+ need(matches.length === 1);
44
+ witnessProfileGuard(matches[0], mode);
45
+ return matches[0];
46
+ }
47
+ /** Brand and settle the original RPC Promise without adopting a public .then substitute. */
48
+ export function witnessRPC(state, work, guard) {
49
+ return state.owned(() => {
50
+ const pending = work();
51
+ need(types.isPromise(pending));
52
+ return new Promise((resolve, reject) => {
53
+ Reflect.apply(nativeThen, pending, [resolve, reject]);
54
+ });
55
+ }, guard);
56
+ }
57
+ function checkedScope(raw) {
58
+ const scope = closed(raw, [
59
+ "identity",
60
+ "providerScope",
61
+ "configureRequestBinding",
62
+ "observedItemId",
63
+ "nativePeriod",
64
+ ]);
65
+ const provider = closed(scope.providerScope, [
66
+ "mode",
67
+ "stripeAccount",
68
+ "livemode",
69
+ "customerAccountId",
70
+ "customerId",
71
+ "subscriptionId",
72
+ "scheduleId",
73
+ ]);
74
+ need(provider.mode === "platform" &&
75
+ provider.stripeAccount === null &&
76
+ typeof provider.livemode === "boolean");
77
+ const period = closed(scope.nativePeriod, ["start", "end"]);
78
+ need(typeof period.start === "number" &&
79
+ Number.isSafeInteger(period.start) &&
80
+ period.start >= 0 &&
81
+ typeof period.end === "number" &&
82
+ Number.isSafeInteger(period.end) &&
83
+ period.end > period.start);
84
+ return freeze({
85
+ identity: witnessIdentity(scope.identity),
86
+ providerScope: {
87
+ mode: "platform",
88
+ stripeAccount: null,
89
+ livemode: provider.livemode,
90
+ customerAccountId: text(provider.customerAccountId),
91
+ customerId: text(provider.customerId),
92
+ subscriptionId: text(provider.subscriptionId),
93
+ scheduleId: text(provider.scheduleId),
94
+ },
95
+ configureRequestBinding: text(scope.configureRequestBinding),
96
+ observedItemId: text(scope.observedItemId),
97
+ nativePeriod: { start: period.start, end: period.end },
98
+ });
99
+ }
100
+ export function createWitnessAuthorization(state, profile, mode, identity, expectedScope) {
101
+ const rpc = readCheckedJournalActionRPC(state.binding), query = profile.authorizationQuery;
102
+ const address = witnessAddress(query), base = state.readCaptured().authorization;
103
+ const args = mode === "retain"
104
+ ? {
105
+ capability: "renewal_witness_retain_v1",
106
+ scope: expectedScope,
107
+ }
108
+ : { capability: "renewal_witness_read_v1", identity };
109
+ need(mode !== "retain" || expectedScope);
110
+ let grant = null;
111
+ let expiry = null;
112
+ function guard() {
113
+ state.guard();
114
+ witnessProfileGuard(profile, mode);
115
+ need(profile.authorizationQuery === query &&
116
+ witnessAddress(query) === address &&
117
+ profile.freshProfile.historyEntry === state.historyEntry &&
118
+ readCheckedJournalActionRPC(state.binding) === rpc);
119
+ if (expiry !== null)
120
+ need(state.check().wallMs < expiry);
121
+ }
122
+ return Object.freeze({
123
+ guard,
124
+ async authorize() {
125
+ guard();
126
+ await state.authorizeUnchanged();
127
+ guard();
128
+ const raw = await witnessRPC(state, () => rpc.runQuery.call(rpc.receiver, query, args), guard);
129
+ const reply = captureReaderQueryDATA(raw);
130
+ need(new TextEncoder().encode(JSON.stringify(reply)).length <= 8192);
131
+ const data = closed(reply, [
132
+ "capability",
133
+ "scope",
134
+ "tokenIdentifier",
135
+ "authorizationId",
136
+ "authorizationRevision",
137
+ "expiresAtMs",
138
+ ...(mode === "read" ? ["witnessRowId", "payloadBinding"] : []),
139
+ ]);
140
+ const scope = checkedScope(data.scope);
141
+ need(data.capability === args.capability &&
142
+ data.tokenIdentifier === base.tokenIdentifier);
143
+ matchConfigureDATA(scope.identity, identity);
144
+ if (expectedScope)
145
+ matchConfigureDATA(scope, expectedScope);
146
+ text(data.authorizationId);
147
+ need(typeof data.authorizationRevision === "number" &&
148
+ Number.isSafeInteger(data.authorizationRevision) &&
149
+ data.authorizationRevision > 0);
150
+ need(typeof data.expiresAtMs === "number" &&
151
+ Number.isSafeInteger(data.expiresAtMs) &&
152
+ data.expiresAtMs > state.check().wallMs);
153
+ if (mode === "read") {
154
+ text(data.witnessRowId);
155
+ need(/^renewal-witness:v1:sha256:[0-9a-f]{64}$/.test(text(data.payloadBinding)));
156
+ }
157
+ if (grant)
158
+ matchConfigureDATA(data, grant);
159
+ else {
160
+ grant = freeze(data);
161
+ expiry = data.expiresAtMs;
162
+ }
163
+ guard();
164
+ return freeze({
165
+ scope,
166
+ witnessRowId: mode === "read" ? text(data.witnessRowId) : null,
167
+ payloadBinding: mode === "read" ? text(data.payloadBinding) : null,
168
+ });
169
+ },
170
+ });
171
+ }
172
+ //# sourceMappingURL=witnessAuthorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"witnessAuthorization.js","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/witnessAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,gCAAgC,EAChC,6BAA6B,GAI9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,kCAAkC,EAClC,oCAAoC,GACrC,MAAM,mCAAmC,CA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,KAAK,EAAE,CAAC;YACR,OAAO,MAAM,CAAC;gBACZ,KAAK;gBACL,YAAY,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI;gBAC9D,cAAc,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI;aACnE,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,135 @@
1
+ import { type WitnessIdentity, type WitnessPayload } from "../../../../../shared/renewalWitness.js";
2
+ import type { ObservationInvocationState } from "./invocation.js";
3
+ import type { ObservationReads } from "./types.js";
4
+ import type { InvoiceContextV1 } from "../../../renewalObservation/evidence-v1-types.js";
5
+ /** Called only inside the actual fresh actor, before its original lifetime closes. */
6
+ export declare function captureWitnessPayload(state: ObservationInvocationState, identity: WitnessIdentity, reads: ObservationReads, invoiceContext: InvoiceContextV1 | null): string;
7
+ /** Recompute complete unsigned material and digest; a stored hash is not its own proof. */
8
+ export declare function inspectWitnessPayload(raw: string): Promise<{
9
+ identity: Readonly<{
10
+ scope: "platform";
11
+ customerAccountId: string;
12
+ customerId: string;
13
+ livemode: boolean;
14
+ scheduleId: string;
15
+ subscriptionId: string;
16
+ originalItemId: string;
17
+ targetPriceId: string;
18
+ targetProductId: string;
19
+ originalNativePeriod: import("../../../renewalObservation/evidence-v1-types.js").Period;
20
+ targetBoundary: number;
21
+ }>;
22
+ payload: Readonly<{
23
+ version: 1;
24
+ kind: "renewal_witness_payload";
25
+ identity: WitnessIdentity;
26
+ capturedSubject: string;
27
+ acquisition: Readonly<{
28
+ observedAtMs: number;
29
+ elapsedWallMs: number;
30
+ elapsedNsDecimal: string;
31
+ apiVersion: "2026-09-30.endive";
32
+ baseReadProfile: "endive-schedule-first-44-v1";
33
+ invoiceReadProfile: "endive-pinned-invoices-fence-7-v1" | null;
34
+ }>;
35
+ source: Readonly<{
36
+ parent: import("../../../../../shared/renewalWitness.js").WitnessStage & Readonly<{
37
+ initialBasis: Record<string, unknown>;
38
+ }>;
39
+ configure: import("../../../../../shared/renewalWitness.js").WitnessStage;
40
+ }>;
41
+ reads: ObservationReads;
42
+ invoiceContext: InvoiceContextV1 | null;
43
+ }>;
44
+ payloadJSON: string;
45
+ scope: Readonly<{
46
+ identity: WitnessIdentity;
47
+ providerScope: Readonly<{
48
+ mode: "platform";
49
+ stripeAccount: null;
50
+ livemode: boolean;
51
+ customerAccountId: string;
52
+ customerId: string;
53
+ subscriptionId: string;
54
+ scheduleId: string;
55
+ }>;
56
+ configureRequestBinding: string;
57
+ observedItemId: string;
58
+ nativePeriod: Readonly<{
59
+ start: number;
60
+ end: number;
61
+ }>;
62
+ }>;
63
+ fields: {
64
+ version: number;
65
+ identity: Readonly<{
66
+ componentScope: string;
67
+ witnessId: string;
68
+ parentOperationId: string;
69
+ operationId: string;
70
+ }>;
71
+ payloadBinding: string;
72
+ capturedSubject: string;
73
+ observedAtMs: number;
74
+ customerAccountId: string;
75
+ customerId: string;
76
+ livemode: boolean;
77
+ subscriptionId: string;
78
+ scheduleId: string;
79
+ observedItemId: string;
80
+ nativePeriod: Readonly<{
81
+ start: number;
82
+ end: number;
83
+ }>;
84
+ operationalAuthority: boolean;
85
+ authenticationEstablished: boolean;
86
+ publicDeliveryEstablished: boolean;
87
+ providerQualificationRequired: boolean;
88
+ };
89
+ historicalInput: {
90
+ configuration: unknown;
91
+ configureReceipt: {
92
+ configuration: unknown;
93
+ actualDispatch: unknown;
94
+ providerSnapshot: unknown;
95
+ transport: unknown;
96
+ } | null;
97
+ historicalSnapshot: {
98
+ reads: ObservationReads;
99
+ invoiceContext: Readonly<{
100
+ original: import("../../../renewalObservation/evidence-v1-types.js").InvoiceInventoryV1;
101
+ current: import("../../../renewalObservation/evidence-v1-types.js").InvoiceInventoryV1;
102
+ }> | null;
103
+ };
104
+ };
105
+ }>;
106
+ export type InspectedWitness = Awaited<ReturnType<typeof inspectWitnessPayload>>;
107
+ export declare function checkedWitnessDescriptor(raw: unknown, admitted: InspectedWitness): {
108
+ version: number;
109
+ identity: Readonly<{
110
+ componentScope: string;
111
+ witnessId: string;
112
+ parentOperationId: string;
113
+ operationId: string;
114
+ }>;
115
+ payloadBinding: string;
116
+ capturedSubject: string;
117
+ observedAtMs: number;
118
+ customerAccountId: string;
119
+ customerId: string;
120
+ livemode: boolean;
121
+ subscriptionId: string;
122
+ scheduleId: string;
123
+ observedItemId: string;
124
+ nativePeriod: Readonly<{
125
+ start: number;
126
+ end: number;
127
+ }>;
128
+ operationalAuthority: boolean;
129
+ authenticationEstablished: boolean;
130
+ publicDeliveryEstablished: boolean;
131
+ providerQualificationRequired: boolean;
132
+ witnessRowId: string;
133
+ };
134
+ export declare function checkWitnessC7(payload: WitnessPayload, state: ObservationInvocationState): void;
135
+ //# sourceMappingURL=witnessData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"witnessData.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/witnessData.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,yCAAyC,CAAC;AAMjD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAyBzF,sFAAsF;AACtF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,EACjC,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,gBAAgB,EACvB,cAAc,EAAE,gBAAgB,GAAG,IAAI,UA2BxC;AAED,2FAA2F;AAC3F,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoF/C,KAAK;YACL,cAAc;;;;;;GAIrB;AACD,MAAM,MAAM,gBAAgB,GAAG,OAAO,CACpC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CACzC,CAAC;AACF,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;EAS3B;AACD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,0BAA0B,QAMlC"}
@@ -0,0 +1,143 @@
1
+ import { canonicalWitnessJSON, witnessNeed as need, witnessObject as object, witnessText as text, } from "../../../../../shared/renewalWitness.js";
2
+ import { renewalSnapshot } from "../../../renewalReplacementSnapshot.js";
3
+ import { inspectRenewalEvidenceV1 } from "../../../renewalObservation/evidence-v1.js";
4
+ import { closed, freeze } from "../c10/ownData.js";
5
+ import { matchConfigureDATA } from "../producer/configureJournalData.js";
6
+ function capturedStage(raw, parent) {
7
+ const stage = object(raw), load = object(stage.operation);
8
+ const reservation = object(object(stage.attempt).reservation);
9
+ const { recordJSON: _recordJSON, ...summary } = reservation;
10
+ void _recordJSON;
11
+ const known = stage.acknowledgement;
12
+ return {
13
+ record: object(JSON.parse(text(load.recordJSON, 500000))),
14
+ reservation: summary,
15
+ acknowledgement: known === null
16
+ ? null
17
+ : {
18
+ retention: object(object(known).retention),
19
+ receipt: object(JSON.parse(text(object(known).receiptJSON, 500000))),
20
+ },
21
+ ...(parent ? { initialBasis: object(load.initialBasis) } : {}),
22
+ };
23
+ }
24
+ /** Called only inside the actual fresh actor, before its original lifetime closes. */
25
+ export function captureWitnessPayload(state, identity, reads, invoiceContext) {
26
+ const captured = state.readCaptured(), sample = state.check();
27
+ const snapshot = captured.history.snapshot;
28
+ const payload = renewalSnapshot({
29
+ version: 1,
30
+ kind: "renewal_witness_payload",
31
+ identity,
32
+ capturedSubject: captured.authorization.tokenIdentifier,
33
+ acquisition: {
34
+ observedAtMs: sample.wallMs,
35
+ elapsedWallMs: sample.wallMs - state.startedAt.wallMs,
36
+ elapsedNsDecimal: (sample.ns - state.startedAt.ns).toString(),
37
+ apiVersion: "2026-09-30.endive",
38
+ baseReadProfile: "endive-schedule-first-44-v1",
39
+ invoiceReadProfile: invoiceContext === null ? null : "endive-pinned-invoices-fence-7-v1",
40
+ },
41
+ source: {
42
+ parent: capturedStage(snapshot.parent, true),
43
+ configure: capturedStage(snapshot.configure, false),
44
+ },
45
+ reads,
46
+ invoiceContext,
47
+ });
48
+ return canonicalWitnessJSON(JSON.stringify(payload)).json;
49
+ }
50
+ /** Recompute complete unsigned material and digest; a stored hash is not its own proof. */
51
+ export async function inspectWitnessPayload(raw) {
52
+ const canonical = canonicalWitnessJSON(raw), payload = canonical.value;
53
+ const record = object(payload.source.configure.record.configureRecord);
54
+ const known = payload.source.configure.acknowledgement;
55
+ const configureReceipt = known === null
56
+ ? null
57
+ : {
58
+ configuration: record.configuration,
59
+ actualDispatch: payload.source.configure.record.dispatch,
60
+ providerSnapshot: known.receipt.providerSnapshot,
61
+ transport: known.receipt.transport,
62
+ };
63
+ const evidence = await inspectRenewalEvidenceV1({
64
+ version: 1,
65
+ apiVersion: "2026-09-30.endive",
66
+ configuration: record.configuration,
67
+ configureReceipt,
68
+ reads: payload.reads,
69
+ invoiceContext: payload.invoiceContext,
70
+ historicalSnapshot: null,
71
+ });
72
+ need(evidence.identity &&
73
+ evidence.currentMaterial.predicate === "current_target_material_match");
74
+ if (payload.invoiceContext !== null)
75
+ need(evidence.invoiceEvidence.predicate === "invoice_lines_correlated");
76
+ const { identity } = evidence, material = evidence.currentMaterial;
77
+ const scope = freeze({
78
+ identity: payload.identity,
79
+ providerScope: {
80
+ mode: "platform",
81
+ stripeAccount: null,
82
+ livemode: identity.livemode,
83
+ customerAccountId: identity.customerAccountId,
84
+ customerId: identity.customerId,
85
+ subscriptionId: identity.subscriptionId,
86
+ scheduleId: identity.scheduleId,
87
+ },
88
+ configureRequestBinding: text(object(object(record.request).requestIdentity).binding),
89
+ observedItemId: material.observedItemId,
90
+ nativePeriod: material.nativePeriod,
91
+ });
92
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode("renewal-witness:v1\u0000" + canonical.json));
93
+ const hex = [...new Uint8Array(digest)]
94
+ .map((n) => n.toString(16).padStart(2, "0"))
95
+ .join("");
96
+ const payloadBinding = "renewal-witness:v1:sha256:" + hex;
97
+ const fields = freeze({
98
+ version: 1,
99
+ identity: payload.identity,
100
+ payloadBinding,
101
+ capturedSubject: payload.capturedSubject,
102
+ observedAtMs: payload.acquisition.observedAtMs,
103
+ customerAccountId: identity.customerAccountId,
104
+ customerId: identity.customerId,
105
+ livemode: identity.livemode,
106
+ subscriptionId: identity.subscriptionId,
107
+ scheduleId: identity.scheduleId,
108
+ observedItemId: material.observedItemId,
109
+ nativePeriod: material.nativePeriod,
110
+ operationalAuthority: false,
111
+ authenticationEstablished: false,
112
+ publicDeliveryEstablished: false,
113
+ providerQualificationRequired: true,
114
+ });
115
+ return {
116
+ identity: freeze(evidence.identity),
117
+ payload,
118
+ payloadJSON: canonical.json,
119
+ scope,
120
+ fields,
121
+ historicalInput: {
122
+ configuration: record.configuration,
123
+ configureReceipt,
124
+ historicalSnapshot: {
125
+ reads: payload.reads,
126
+ invoiceContext: payload.invoiceContext,
127
+ },
128
+ },
129
+ };
130
+ }
131
+ export function checkedWitnessDescriptor(raw, admitted) {
132
+ const descriptor = closed(raw, [
133
+ ...Object.keys(admitted.fields),
134
+ "witnessRowId",
135
+ ]);
136
+ const witnessRowId = text(descriptor.witnessRowId);
137
+ matchConfigureDATA(descriptor, { ...admitted.fields, witnessRowId });
138
+ return freeze({ ...admitted.fields, witnessRowId });
139
+ }
140
+ export function checkWitnessC7(payload, state) {
141
+ matchConfigureDATA(payload.source.configure.record.configureRecord, state.readCaptured().history.record);
142
+ }
143
+ //# sourceMappingURL=witnessData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"witnessData.js","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/witnessData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,WAAW,IAAI,IAAI,EACnB,aAAa,IAAI,MAAM,EACvB,WAAW,IAAI,IAAI,GAGpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAKzE,SAAS,aAAa,CAAC,GAAY,EAAE,MAAe;IAClD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,EACvB,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;IAC9D,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,GAAG,WAAW,CAAC;IAC5D,KAAK,WAAW,CAAC;IACjB,MAAM,KAAK,GAAG,KAAK,CAAC,eAAe,CAAC;IACpC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QACzD,WAAW,EAAE,OAAO;QACpB,eAAe,EACb,KAAK,KAAK,IAAI;YACZ,CAAC,CAAC,IAAI;YACN,CAAC,CAAC;gBACE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC;gBAC1C,OAAO,EAAE,MAAM,CACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAA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AC5B,OAAuB,EACvB,KAAiC;IAEjC,kBAAkB,CAChB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,EAC/C,KAAK,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,MAAM,CACpC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { type WitnessMode, type WitnessProfile } from "./witnessAuthorization.js";
2
+ import { type WitnessIdentity } from "../../../../../shared/renewalWitness.js";
3
+ /** Actor-private protocol. Caller DATA cannot register a token, grant or returned ACK. */
4
+ export declare function createWitnessOperation(token: object, profile: WitnessProfile, mode: WitnessMode, identity: WitnessIdentity): Readonly<{
5
+ guard: () => void;
6
+ retain(): Promise<{
7
+ status: "conflict";
8
+ reason: "identity_changed";
9
+ } | {
10
+ status: "retained";
11
+ descriptor: {
12
+ version: number;
13
+ identity: Readonly<{
14
+ componentScope: string;
15
+ witnessId: string;
16
+ parentOperationId: string;
17
+ operationId: string;
18
+ }>;
19
+ payloadBinding: string;
20
+ capturedSubject: string;
21
+ observedAtMs: number;
22
+ customerAccountId: string;
23
+ customerId: string;
24
+ livemode: boolean;
25
+ subscriptionId: string;
26
+ scheduleId: string;
27
+ observedItemId: string;
28
+ nativePeriod: Readonly<{
29
+ start: number;
30
+ end: number;
31
+ }>;
32
+ operationalAuthority: boolean;
33
+ authenticationEstablished: boolean;
34
+ publicDeliveryEstablished: boolean;
35
+ providerQualificationRequired: boolean;
36
+ witnessRowId: string;
37
+ };
38
+ }>;
39
+ load(): Promise<void>;
40
+ historicalEvidence(): Promise<{
41
+ identity: Readonly<{
42
+ scope: "platform";
43
+ customerAccountId: string;
44
+ customerId: string;
45
+ livemode: boolean;
46
+ scheduleId: string;
47
+ subscriptionId: string;
48
+ originalItemId: string;
49
+ targetPriceId: string;
50
+ targetProductId: string;
51
+ originalNativePeriod: import("../../../renewalObservation/evidence-v1-types.js").Period;
52
+ targetBoundary: number;
53
+ }>;
54
+ material: import("../../../renewalObservation/evidence-v1-types.js").HistoricalMaterialV1;
55
+ }>;
56
+ descriptor(): {
57
+ version: number;
58
+ identity: Readonly<{
59
+ componentScope: string;
60
+ witnessId: string;
61
+ parentOperationId: string;
62
+ operationId: string;
63
+ }>;
64
+ payloadBinding: string;
65
+ capturedSubject: string;
66
+ observedAtMs: number;
67
+ customerAccountId: string;
68
+ customerId: string;
69
+ livemode: boolean;
70
+ subscriptionId: string;
71
+ scheduleId: string;
72
+ observedItemId: string;
73
+ nativePeriod: Readonly<{
74
+ start: number;
75
+ end: number;
76
+ }>;
77
+ operationalAuthority: boolean;
78
+ authenticationEstablished: boolean;
79
+ publicDeliveryEstablished: boolean;
80
+ providerQualificationRequired: boolean;
81
+ witnessRowId: string;
82
+ };
83
+ finalize(): Promise<void>;
84
+ }>;
85
+ //# sourceMappingURL=witnessOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"witnessOperation.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/witnessOperation.ts"],"names":[],"mappings":"AAYA,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AASnC,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,yCAAyC,CAAC;AAEjD,0FAA0F;AAC1F,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,eAAe;;;gBAkGT,UAAU;gBACV,kBAAkB;;gBAaN,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDvC"}