@fantastic.dev/better-stripe 0.106.0 → 0.108.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/history.d.ts +41 -0
- package/dist/client/billing/renewalAttach/internal/observation/history.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/history.js +161 -0
- package/dist/client/billing/renewalAttach/internal/observation/history.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/historyEvents.d.ts +55 -0
- package/dist/client/billing/renewalAttach/internal/observation/historyEvents.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/historyEvents.js +83 -0
- package/dist/client/billing/renewalAttach/internal/observation/historyEvents.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/reader.d.ts +64 -0
- package/dist/client/billing/renewalAttach/internal/observation/reader.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/reader.js +170 -0
- package/dist/client/billing/renewalAttach/internal/observation/reader.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts +44 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js +145 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +9 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
- package/docs/renewal-context-reads.md +87 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/observation/history.integration.test.ts +79 -0
- package/src/client/billing/renewalAttach/internal/observation/history.ts +200 -0
- package/src/client/billing/renewalAttach/internal/observation/historyControls.integration.test.ts +238 -0
- package/src/client/billing/renewalAttach/internal/observation/historyEvents.ts +114 -0
- package/src/client/billing/renewalAttach/internal/observation/reader.integration.test.ts +93 -0
- package/src/client/billing/renewalAttach/internal/observation/reader.ts +241 -0
- package/src/client/billing/renewalAttach/internal/observation/readerAuthorization.ts +179 -0
- package/src/client/billing/renewalAttach/internal/observation/readerControls.integration.test.ts +553 -0
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +3 -0
- package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +12 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/historySnapshot.ts +47 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationReader.ts +100 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +9 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,18 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.108.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.107.0...v0.108.0) (2026-10-31)
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- bind observation history reads to fresh host authorization ([#458](https://github.com/FantasticDevHQ/better-stripe/issues/458)) ([455ccaf](https://github.com/FantasticDevHQ/better-stripe/commit/455ccaf9c64709c8e5d61eb9017a89891c3beeb6))
|
|
34
|
+
|
|
35
|
+
## [0.107.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.106.0...v0.107.0) (2026-10-31)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
- reconstruct retained renewal observation history ([#456](https://github.com/FantasticDevHQ/better-stripe/issues/456)) ([0d42eb5](https://github.com/FantasticDevHQ/better-stripe/commit/0d42eb5573c661b376f2dcf824441d92e1fb1b61))
|
|
40
|
+
|
|
29
41
|
## [0.106.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.105.0...v0.106.0) (2026-10-31)
|
|
30
42
|
|
|
31
43
|
### Features
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ billing, and Connect marketplaces. It provides checkout, subscriptions, webhook
|
|
|
5
5
|
syncing, marketplace fees and splits, payouts, refunds, and disputes, with React
|
|
6
6
|
hooks and headless UI components.
|
|
7
7
|
|
|
8
|
-
**Version**: `0.
|
|
8
|
+
**Version**: `0.108.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
|
|
9
9
|
|
|
10
10
|
Connect platforms use the default GA API version. Non-Connect merchants using
|
|
11
11
|
customer-only Accounts v2 need preview access and an explicit preview version.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Pure retained DATA. No Source, actual returned ACK, authorization or execution grant. */
|
|
2
|
+
export declare function captureRetainedObservationHistory(raw: unknown): Promise<{
|
|
3
|
+
status: "retained_observation_history_data";
|
|
4
|
+
record: import("../preflight/grammar.js").PreflightRecord;
|
|
5
|
+
configureHead: number;
|
|
6
|
+
configureReceipt: import("../../../renewalV2/index.js").RenewalConfigurationReceiptV2 | null;
|
|
7
|
+
rawConfigureReceipt: {
|
|
8
|
+
configuration: import("../preflight/grammar.js").Configuration;
|
|
9
|
+
actualDispatch: Pick<import("../../../renewalV2/index.js").ProjectedRenewalConfigurationV2, keyof {
|
|
10
|
+
scope: string;
|
|
11
|
+
apiVersion: string;
|
|
12
|
+
method: string;
|
|
13
|
+
path: string;
|
|
14
|
+
payload: unknown;
|
|
15
|
+
key: string;
|
|
16
|
+
firstDispatchedAt: number;
|
|
17
|
+
}>;
|
|
18
|
+
providerSnapshot: Record<string, unknown>;
|
|
19
|
+
transport: {
|
|
20
|
+
status: number;
|
|
21
|
+
requestId?: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
} | null;
|
|
24
|
+
attachmentReceipt: import("../../../renewalV2/index.js").RenewalScheduleAttachmentReceiptV2;
|
|
25
|
+
attachmentRetention: {
|
|
26
|
+
retention: unknown;
|
|
27
|
+
receiptJSON: string;
|
|
28
|
+
};
|
|
29
|
+
configureRetention: {
|
|
30
|
+
retention: unknown;
|
|
31
|
+
receiptJSON: string;
|
|
32
|
+
} | null;
|
|
33
|
+
snapshot: {
|
|
34
|
+
parent: unknown;
|
|
35
|
+
configure: unknown;
|
|
36
|
+
};
|
|
37
|
+
operationalAuthority: false;
|
|
38
|
+
authenticationEstablished: false;
|
|
39
|
+
publicDeliveryEstablished: false;
|
|
40
|
+
}>;
|
|
41
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/history.ts"],"names":[],"mappings":"AAuBA,4FAA4F;AAC5F,wBAAsB,iCAAiC,CAAC,GAAG,EAAE,OAAO;YAkKxD,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAQ/B,MAAM;QAAmB,SAAS;;;;;GAKjD"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { rejectProxyJSON } from "../acquisition/rawWireSource.js";
|
|
2
|
+
import { renewalSnapshot } from "../../../renewalReplacementSnapshot.js";
|
|
3
|
+
import { closed, freeze, sevenWire } from "../c10/ownData.js";
|
|
4
|
+
import { canonicalInitialBasis } from "../../../../../shared/renewalOperationJournal.js";
|
|
5
|
+
import { reconstructConfigurationV2, constructRenewalConfigurationReceiptV2, } from "../../../renewalV2/index.js";
|
|
6
|
+
import { captureObservationRecord, verifyObservationRecord } from "./record.js";
|
|
7
|
+
import { admitConfigureACK } from "../configure/output.js";
|
|
8
|
+
import { checkOperationLoad, matchConfigureDATA, object, text, requireConfigure as need, } from "../producer/configureJournalData.js";
|
|
9
|
+
import { captureHistoryStage, verifyHistoryEvents, verifyHistoryRetention, } from "./historyEvents.js";
|
|
10
|
+
/** Pure retained DATA. No Source, actual returned ACK, authorization or execution grant. */
|
|
11
|
+
export async function captureRetainedObservationHistory(raw) {
|
|
12
|
+
need(arguments.length === 1);
|
|
13
|
+
// Capture the complete graph before the first await, including opaque JSON strings.
|
|
14
|
+
rejectProxyJSON(raw);
|
|
15
|
+
const copy = renewalSnapshot(raw);
|
|
16
|
+
need(new TextEncoder().encode(JSON.stringify(copy)).length <= 500000);
|
|
17
|
+
matchConfigureDATA(raw, copy);
|
|
18
|
+
freeze(copy);
|
|
19
|
+
const snapshot = closed(copy, ["parent", "configure"]);
|
|
20
|
+
const parent = captureHistoryStage(snapshot.parent, "attach");
|
|
21
|
+
const child = captureHistoryStage(snapshot.configure, "configure");
|
|
22
|
+
need(parent.reservation.operationId !== child.reservation.operationId &&
|
|
23
|
+
parent.reservation.attemptId !== child.reservation.attemptId);
|
|
24
|
+
const original = object(JSON.parse(child.reservation.recordJSON));
|
|
25
|
+
const parentOriginal = object(JSON.parse(parent.reservation.recordJSON));
|
|
26
|
+
const captured = captureObservationRecord(original.configureRecord);
|
|
27
|
+
const record = captured.record;
|
|
28
|
+
const rebuilt = await reconstructConfigurationV2(record.configuration);
|
|
29
|
+
need(rebuilt.material && "requestIdentity" in rebuilt.result);
|
|
30
|
+
verifyObservationRecord(captured, rebuilt.result, rebuilt.material.receipt);
|
|
31
|
+
const receipt = rebuilt.material.receipt, request = rebuilt.result;
|
|
32
|
+
matchConfigureDATA(original.parentAttachment, {
|
|
33
|
+
operationId: parent.reservation.operationId,
|
|
34
|
+
attemptId: parent.reservation.attemptId,
|
|
35
|
+
sourcePayloadId: parent.reservation.payloadId,
|
|
36
|
+
receiptBinding: receipt.binding,
|
|
37
|
+
});
|
|
38
|
+
matchConfigureDATA(record.configuration.attachReceipt.attachRequest, parentOriginal.attachRequest);
|
|
39
|
+
matchConfigureDATA(record.originalBundle, parentOriginal.originalBundle);
|
|
40
|
+
matchConfigureDATA(original.account, parentOriginal.account);
|
|
41
|
+
matchConfigureDATA(original.account, {
|
|
42
|
+
mode: "platform",
|
|
43
|
+
stripeAccount: null,
|
|
44
|
+
livemode: receipt.livemode,
|
|
45
|
+
});
|
|
46
|
+
need(original.apiVersion === parentOriginal.apiVersion &&
|
|
47
|
+
original.apiVersion === request.apiVersion);
|
|
48
|
+
matchConfigureDATA(original.dispatch, sevenWire(request));
|
|
49
|
+
matchConfigureDATA(parentOriginal.dispatch, sevenWire(receipt.request));
|
|
50
|
+
need(child.reservation.requestBinding === request.requestIdentity.binding &&
|
|
51
|
+
parent.reservation.requestBinding ===
|
|
52
|
+
receipt.request.requestIdentity.binding);
|
|
53
|
+
const policy = object(original.timingPolicy), parentPolicy = object(parentOriginal.timingPolicy);
|
|
54
|
+
for (const key of ["workEndWallMs", "endWallMs", "periodStart", "periodEnd"])
|
|
55
|
+
need(policy[key] === parentPolicy[key]);
|
|
56
|
+
const parentLoad = object(parent.operation), basis = object(parentLoad.initialBasis);
|
|
57
|
+
const basisJSON = text(basis.basisJSON);
|
|
58
|
+
need(canonicalInitialBasis(parent.reservation.timingPolicyJSON, basisJSON)
|
|
59
|
+
.basisJSON === basisJSON);
|
|
60
|
+
need(canonicalInitialBasis(child.reservation.timingPolicyJSON, basisJSON)
|
|
61
|
+
.basisJSON === basisJSON);
|
|
62
|
+
checkOperationLoad(parent.operation, parent.reservation, basisJSON);
|
|
63
|
+
checkOperationLoad(child.operation, child.reservation, basisJSON, child.events.length === 0);
|
|
64
|
+
await verifyHistoryEvents(parent, [
|
|
65
|
+
{ event: "dispatch", stage: "attach", request: receipt.request },
|
|
66
|
+
{
|
|
67
|
+
event: "response",
|
|
68
|
+
stage: "attach",
|
|
69
|
+
request: receipt.request,
|
|
70
|
+
body: receipt.providerSnapshot,
|
|
71
|
+
status: parent.events[1].data.status,
|
|
72
|
+
},
|
|
73
|
+
{ event: "receipt", stage: "attach", request: receipt.request, receipt },
|
|
74
|
+
]);
|
|
75
|
+
const attachmentRetention = verifyHistoryRetention(parent, receipt);
|
|
76
|
+
const expected = [];
|
|
77
|
+
if (child.events.length >= 1)
|
|
78
|
+
expected.push({ event: "dispatch", stage: "configure", request });
|
|
79
|
+
const response = child.events[1]?.data;
|
|
80
|
+
if (response)
|
|
81
|
+
expected.push({
|
|
82
|
+
event: "response",
|
|
83
|
+
stage: "configure",
|
|
84
|
+
request,
|
|
85
|
+
body: response.body,
|
|
86
|
+
transport: response.transport,
|
|
87
|
+
});
|
|
88
|
+
let configureReceipt = null, rawConfigureReceipt = null, configureRetention = null;
|
|
89
|
+
if (response) {
|
|
90
|
+
const t = closed(response.transport, ["status"], ["requestId"]);
|
|
91
|
+
need(typeof t.status === "number");
|
|
92
|
+
need(t.requestId === undefined || typeof t.requestId === "string");
|
|
93
|
+
const rawResponse = {
|
|
94
|
+
configuration: record.configuration,
|
|
95
|
+
actualDispatch: sevenWire(request),
|
|
96
|
+
providerSnapshot: object(response.body),
|
|
97
|
+
transport: {
|
|
98
|
+
status: t.status,
|
|
99
|
+
...(typeof t.requestId === "string" ? { requestId: t.requestId } : {}),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const reconstructed = await constructRenewalConfigurationReceiptV2(rawResponse);
|
|
103
|
+
admitConfigureACK(record, rawResponse, reconstructed);
|
|
104
|
+
// Response2 may be valid without durable C9. Reconstruction does not retain it.
|
|
105
|
+
if (child.acknowledgement !== null) {
|
|
106
|
+
rawConfigureReceipt = rawResponse;
|
|
107
|
+
configureReceipt = reconstructed;
|
|
108
|
+
configureRetention = verifyHistoryRetention(child, configureReceipt);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
|
+
need(child.acknowledgement === null);
|
|
113
|
+
if (child.events.length === 3) {
|
|
114
|
+
need(configureReceipt);
|
|
115
|
+
expected.push({
|
|
116
|
+
event: "receipt",
|
|
117
|
+
stage: "configure",
|
|
118
|
+
request,
|
|
119
|
+
receipt: configureReceipt,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
await verifyHistoryEvents(child, expected);
|
|
123
|
+
// IDs remain opaque DATA. Even equal complete records never become runtime tokens.
|
|
124
|
+
const payloads = [
|
|
125
|
+
parent.reservation.payloadId,
|
|
126
|
+
child.reservation.payloadId,
|
|
127
|
+
...parent.events.map((e) => e.descriptor.payloadId),
|
|
128
|
+
...child.events.map((e) => e.descriptor.payloadId),
|
|
129
|
+
object(attachmentRetention.retention).receiptPayloadId,
|
|
130
|
+
...(configureRetention
|
|
131
|
+
? [object(configureRetention.retention).receiptPayloadId]
|
|
132
|
+
: []),
|
|
133
|
+
];
|
|
134
|
+
const eventIds = [...parent.events, ...child.events].map((e) => e.descriptor.eventId);
|
|
135
|
+
need(new Set(payloads).size === payloads.length &&
|
|
136
|
+
new Set(eventIds).size === eventIds.length);
|
|
137
|
+
const ids = [
|
|
138
|
+
parent.reservation.operationId,
|
|
139
|
+
child.reservation.operationId,
|
|
140
|
+
parent.reservation.attemptId,
|
|
141
|
+
child.reservation.attemptId,
|
|
142
|
+
...payloads,
|
|
143
|
+
...eventIds,
|
|
144
|
+
];
|
|
145
|
+
need(new Set(ids).size === ids.length);
|
|
146
|
+
return freeze({
|
|
147
|
+
status: "retained_observation_history_data",
|
|
148
|
+
record,
|
|
149
|
+
configureHead: child.events.length,
|
|
150
|
+
configureReceipt,
|
|
151
|
+
rawConfigureReceipt,
|
|
152
|
+
attachmentReceipt: receipt,
|
|
153
|
+
attachmentRetention,
|
|
154
|
+
configureRetention,
|
|
155
|
+
snapshot: { parent: snapshot.parent, configure: snapshot.configure },
|
|
156
|
+
operationalAuthority: false,
|
|
157
|
+
authenticationEstablished: false,
|
|
158
|
+
publicDeliveryEstablished: false,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,EACL,0BAA0B,EAC1B,sCAAsC,GACvC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EACN,IAAI,EACJ,gBAAgB,IAAI,IAAI,GACzB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,GAAY;IAClE,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;IAC7B,oFAAoF;IACpF,eAAe,CAAC,GAAG,CAAC,CAAC;IACrB,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC;IACtE,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,CAAC;IACb,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|
+
/** Complete bounded query DATA, never a class journal or actual ACK. */
|
|
2
|
+
export declare function captureHistoryStage(raw: unknown, stage: "attach" | "configure"): {
|
|
3
|
+
operation: unknown;
|
|
4
|
+
reservation: Readonly<{
|
|
5
|
+
key: string;
|
|
6
|
+
apiVersion: string;
|
|
7
|
+
firstDispatchedAt: number;
|
|
8
|
+
accountJSON: string;
|
|
9
|
+
recordVersion: 2;
|
|
10
|
+
timingPolicyJSON: string;
|
|
11
|
+
operationId: string;
|
|
12
|
+
attemptId: string;
|
|
13
|
+
payloadId: string;
|
|
14
|
+
authorizationScope: string;
|
|
15
|
+
authorizationId: string;
|
|
16
|
+
authorizationRevision: number;
|
|
17
|
+
logicalOperationId: string;
|
|
18
|
+
requestBinding: string;
|
|
19
|
+
ordinal: 1;
|
|
20
|
+
preparedRevision: 0;
|
|
21
|
+
committedRevision: 1;
|
|
22
|
+
recordJSON: string;
|
|
23
|
+
stage: "attach" | "configure";
|
|
24
|
+
}>;
|
|
25
|
+
events: {
|
|
26
|
+
descriptor: {
|
|
27
|
+
operationId: string;
|
|
28
|
+
attemptId: string;
|
|
29
|
+
stage: "attach";
|
|
30
|
+
sourcePayloadId: string;
|
|
31
|
+
sequence: 1 | 2 | 3;
|
|
32
|
+
binding: string;
|
|
33
|
+
payloadId: string;
|
|
34
|
+
eventId: string;
|
|
35
|
+
} | {
|
|
36
|
+
operationId: string;
|
|
37
|
+
attemptId: string;
|
|
38
|
+
stage: "configure";
|
|
39
|
+
sourcePayloadId: string;
|
|
40
|
+
sequence: number;
|
|
41
|
+
binding: string;
|
|
42
|
+
payloadId: string;
|
|
43
|
+
eventId: string;
|
|
44
|
+
};
|
|
45
|
+
dataJSON: string;
|
|
46
|
+
data: Record<string, unknown>;
|
|
47
|
+
}[];
|
|
48
|
+
acknowledgement: unknown;
|
|
49
|
+
};
|
|
50
|
+
export declare function verifyHistoryEvents(stage: ReturnType<typeof captureHistoryStage>, expected: readonly unknown[]): Promise<void>;
|
|
51
|
+
export declare function verifyHistoryRetention(stage: ReturnType<typeof captureHistoryStage>, receipt: unknown): {
|
|
52
|
+
retention: unknown;
|
|
53
|
+
receiptJSON: string;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=historyEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historyEvents.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/historyEvents.ts"],"names":[],"mappings":"AAqBA,wEAAwE;AACxE,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,QAAQ,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0C9B;AACD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,EAC7C,QAAQ,EAAE,SAAS,OAAO,EAAE,iBAY7B;AACD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,EAC7C,OAAO,EAAE,OAAO;;;EA6BjB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { canonicalJournalEvent } from "../../../../../shared/renewalOperationJournal.js";
|
|
2
|
+
import { renewalSnapshot } from "../../../renewalReplacementSnapshot.js";
|
|
3
|
+
import { closed, freeze } from "../c10/ownData.js";
|
|
4
|
+
import { captureAttachDispatch, captureAttachResponse, captureAttachReceipt, captureConfigureDispatch, captureConfigureResponse, captureConfigureReceipt, } from "../c10/eventCapture.js";
|
|
5
|
+
import { captureOperationalReservation, captureParentHistory, captureConfigureHistory, matchConfigureDATA, object, text, requireConfigure as need, } from "../producer/configureJournalData.js";
|
|
6
|
+
/** Complete bounded query DATA, never a class journal or actual ACK. */
|
|
7
|
+
export function captureHistoryStage(raw, stage) {
|
|
8
|
+
const x = closed(raw, ["operation", "attempt", "events", "acknowledgement"]);
|
|
9
|
+
const attempt = closed(x.attempt, ["reservation", "events"]);
|
|
10
|
+
const reservation = captureOperationalReservation(attempt.reservation, stage);
|
|
11
|
+
need(Array.isArray(attempt.events) && Array.isArray(x.events));
|
|
12
|
+
const count = attempt.events.length;
|
|
13
|
+
need(count <= 3 && x.events.length === count);
|
|
14
|
+
const descriptors = stage === "attach"
|
|
15
|
+
? captureParentHistory(x.attempt, reservation)
|
|
16
|
+
: count === 0
|
|
17
|
+
? (matchConfigureDATA(x.attempt, { reservation, events: [] }), [])
|
|
18
|
+
: captureConfigureHistory(x.attempt, reservation, count);
|
|
19
|
+
const allPayloads = [
|
|
20
|
+
reservation.payloadId,
|
|
21
|
+
...descriptors.map((e) => e.payloadId),
|
|
22
|
+
];
|
|
23
|
+
need(new Set(allPayloads).size === allPayloads.length);
|
|
24
|
+
const events = x.events.map((raw, index) => {
|
|
25
|
+
const event = closed(raw, [...Object.keys(descriptors[index]), "dataJSON"]);
|
|
26
|
+
const dataJSON = text(event.dataJSON);
|
|
27
|
+
need(dataJSON.length <= 500000);
|
|
28
|
+
const parsed = JSON.parse(dataJSON);
|
|
29
|
+
const captures = stage === "attach"
|
|
30
|
+
? [captureAttachDispatch, captureAttachResponse, captureAttachReceipt]
|
|
31
|
+
: [
|
|
32
|
+
captureConfigureDispatch,
|
|
33
|
+
captureConfigureResponse,
|
|
34
|
+
captureConfigureReceipt,
|
|
35
|
+
];
|
|
36
|
+
captures[index](parsed);
|
|
37
|
+
matchConfigureDATA(raw, { ...descriptors[index], dataJSON });
|
|
38
|
+
return { descriptor: descriptors[index], dataJSON, data: object(parsed) };
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
operation: x.operation,
|
|
42
|
+
reservation,
|
|
43
|
+
events,
|
|
44
|
+
acknowledgement: x.acknowledgement,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export async function verifyHistoryEvents(stage, expected) {
|
|
48
|
+
need(stage.events.length === expected.length);
|
|
49
|
+
for (let index = 0; index < expected.length; index++) {
|
|
50
|
+
const event = stage.events[index];
|
|
51
|
+
matchConfigureDATA(event.data, expected[index]);
|
|
52
|
+
const canonical = await canonicalJournalEvent(index + 1, event.dataJSON);
|
|
53
|
+
need(canonical.json === event.dataJSON &&
|
|
54
|
+
canonical.binding === event.descriptor.binding);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function verifyHistoryRetention(stage, receipt) {
|
|
58
|
+
need(stage.events.length >= 2);
|
|
59
|
+
const ack = closed(stage.acknowledgement, ["retention", "receiptJSON"]);
|
|
60
|
+
const retention = object(ack.retention), r = object(receipt);
|
|
61
|
+
const receiptPayloadId = text(retention.receiptPayloadId);
|
|
62
|
+
need(receiptPayloadId !== stage.reservation.payloadId &&
|
|
63
|
+
stage.events.every((e) => e.descriptor.payloadId !== receiptPayloadId));
|
|
64
|
+
const [dispatch, response] = stage.events;
|
|
65
|
+
matchConfigureDATA(JSON.parse(text(ack.receiptJSON)), receipt);
|
|
66
|
+
need(JSON.stringify(renewalSnapshot(receipt)) === ack.receiptJSON);
|
|
67
|
+
matchConfigureDATA(ack.retention, {
|
|
68
|
+
status: "retained",
|
|
69
|
+
operationId: stage.reservation.operationId,
|
|
70
|
+
schemaVersion: 1,
|
|
71
|
+
stage: stage.reservation.stage,
|
|
72
|
+
attemptId: stage.reservation.attemptId,
|
|
73
|
+
sourcePayloadId: stage.reservation.payloadId,
|
|
74
|
+
dispatchEventId: dispatch.descriptor.eventId,
|
|
75
|
+
dispatchPayloadId: dispatch.descriptor.payloadId,
|
|
76
|
+
responseEventId: response.descriptor.eventId,
|
|
77
|
+
responsePayloadId: response.descriptor.payloadId,
|
|
78
|
+
receiptPayloadId,
|
|
79
|
+
receiptBinding: r.binding,
|
|
80
|
+
});
|
|
81
|
+
return freeze({ retention: ack.retention, receiptJSON: ack.receiptJSON });
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=historyEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historyEvents.js","sourceRoot":"","sources":["../../../../../../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B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Fresh host authorization for four fixed DATA queries. No client or write authority. */
|
|
2
|
+
export declare function captureAuthorizedObservationHistoryReader(actualRoot: object, raw: unknown): Promise<Readonly<{
|
|
3
|
+
read(): Promise<{
|
|
4
|
+
status: "authorized_observation_history_data";
|
|
5
|
+
history: {
|
|
6
|
+
status: "retained_observation_history_data";
|
|
7
|
+
record: import("../preflight/grammar.js").PreflightRecord;
|
|
8
|
+
configureHead: number;
|
|
9
|
+
configureReceipt: import("../../../renewalV2/index.js").RenewalConfigurationReceiptV2 | null;
|
|
10
|
+
rawConfigureReceipt: {
|
|
11
|
+
configuration: import("../preflight/grammar.js").Configuration;
|
|
12
|
+
actualDispatch: Pick<import("../../../renewalV2/index.js").ProjectedRenewalConfigurationV2, keyof {
|
|
13
|
+
scope: string;
|
|
14
|
+
apiVersion: string;
|
|
15
|
+
method: string;
|
|
16
|
+
path: string;
|
|
17
|
+
payload: unknown;
|
|
18
|
+
key: string;
|
|
19
|
+
firstDispatchedAt: number;
|
|
20
|
+
}>;
|
|
21
|
+
providerSnapshot: Record<string, unknown>;
|
|
22
|
+
transport: {
|
|
23
|
+
status: number;
|
|
24
|
+
requestId?: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
} | null;
|
|
27
|
+
attachmentReceipt: import("../../../renewalV2/index.js").RenewalScheduleAttachmentReceiptV2;
|
|
28
|
+
attachmentRetention: {
|
|
29
|
+
retention: unknown;
|
|
30
|
+
receiptJSON: string;
|
|
31
|
+
};
|
|
32
|
+
configureRetention: {
|
|
33
|
+
retention: unknown;
|
|
34
|
+
receiptJSON: string;
|
|
35
|
+
} | null;
|
|
36
|
+
snapshot: {
|
|
37
|
+
parent: unknown;
|
|
38
|
+
configure: unknown;
|
|
39
|
+
};
|
|
40
|
+
operationalAuthority: false;
|
|
41
|
+
authenticationEstablished: false;
|
|
42
|
+
publicDeliveryEstablished: false;
|
|
43
|
+
};
|
|
44
|
+
authorization: {
|
|
45
|
+
componentScope: string;
|
|
46
|
+
parentOperationId: string;
|
|
47
|
+
operationId: string;
|
|
48
|
+
tokenIdentifier: string;
|
|
49
|
+
providerScope: {
|
|
50
|
+
mode: "platform";
|
|
51
|
+
stripeAccount: null;
|
|
52
|
+
livemode: boolean;
|
|
53
|
+
customerAccountId: string;
|
|
54
|
+
subscriptionId: string;
|
|
55
|
+
scheduleId: string;
|
|
56
|
+
};
|
|
57
|
+
authorizationId: string;
|
|
58
|
+
authorizationRevision: number;
|
|
59
|
+
expiresAtMs: number;
|
|
60
|
+
};
|
|
61
|
+
operationalAuthority: false;
|
|
62
|
+
}>;
|
|
63
|
+
}>>;
|
|
64
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/reader.ts"],"names":[],"mappings":"AA2BA,0FAA0F;AAC1F,wBAAsB,yCAAyC,CAC7D,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,OAAO;;gBAwMI,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUtD"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { getFunctionAddress, } from "convex/server";
|
|
3
|
+
import { COMPILED_OBSERVATION_HISTORY_ENTRIES } from "../operations/sourceOperations.js";
|
|
4
|
+
import { readMaintainedRootComponent, captureMaintainedJournalBinding, readCheckedJournalActionRPC, } from "../producer/classOwnedActionRoot.js";
|
|
5
|
+
import { closed, freeze } from "../c10/ownData.js";
|
|
6
|
+
import { object, matchConfigureDATA, } from "../producer/configureJournalData.js";
|
|
7
|
+
import { captureRetainedObservationHistory } from "./history.js";
|
|
8
|
+
import { readerNeed as need, readerText as text, readerStop, captureReaderAuthorization, createObservationReaderLifetime, captureReaderQueryDATA, } from "./readerAuthorization.js";
|
|
9
|
+
/** Fresh host authorization for four fixed DATA queries. No client or write authority. */
|
|
10
|
+
export async function captureAuthorizedObservationHistoryReader(actualRoot, raw) {
|
|
11
|
+
need(arguments.length === 2);
|
|
12
|
+
if (COMPILED_OBSERVATION_HISTORY_ENTRIES.length === 0)
|
|
13
|
+
readerStop();
|
|
14
|
+
const component = readMaintainedRootComponent(actualRoot);
|
|
15
|
+
const matches = COMPILED_OBSERVATION_HISTORY_ENTRIES.filter((e) => e.component === component);
|
|
16
|
+
need(matches.length === 1);
|
|
17
|
+
const entry = matches[0];
|
|
18
|
+
closed(entry, ["component", "componentScope", "authorizationQuery"]);
|
|
19
|
+
need(Object.isFrozen(entry));
|
|
20
|
+
need(!types.isProxy(raw));
|
|
21
|
+
const input = closed(raw, [
|
|
22
|
+
"actualActionCtx",
|
|
23
|
+
"operationId",
|
|
24
|
+
"parentOperationId",
|
|
25
|
+
]);
|
|
26
|
+
const args = freeze({
|
|
27
|
+
componentScope: text(entry.componentScope),
|
|
28
|
+
operationId: text(input.operationId),
|
|
29
|
+
parentOperationId: text(input.parentOperationId),
|
|
30
|
+
});
|
|
31
|
+
need(args.operationId !== args.parentOperationId);
|
|
32
|
+
need(input.actualActionCtx &&
|
|
33
|
+
typeof input.actualActionCtx === "object" &&
|
|
34
|
+
!types.isProxy(input.actualActionCtx));
|
|
35
|
+
const ctx = input.actualActionCtx;
|
|
36
|
+
const auth = ctx.auth, getIdentity = auth?.getUserIdentity;
|
|
37
|
+
need(auth &&
|
|
38
|
+
!types.isProxy(auth) &&
|
|
39
|
+
typeof getIdentity === "function" &&
|
|
40
|
+
!types.isProxy(getIdentity));
|
|
41
|
+
const captured = {
|
|
42
|
+
query: ctx.runQuery,
|
|
43
|
+
mutation: ctx.runMutation,
|
|
44
|
+
meta: ctx.meta,
|
|
45
|
+
metadata: ctx.meta?.getFunctionMetadata,
|
|
46
|
+
};
|
|
47
|
+
const q = component.renewalOperations.queries;
|
|
48
|
+
const references = () => {
|
|
49
|
+
const current = component.renewalOperations.queries;
|
|
50
|
+
return [
|
|
51
|
+
current.loadAuthorizedOperation,
|
|
52
|
+
current.readAttempt,
|
|
53
|
+
current.readStageEvent,
|
|
54
|
+
current.readProviderAcknowledgement,
|
|
55
|
+
];
|
|
56
|
+
};
|
|
57
|
+
const refs = {
|
|
58
|
+
load: q.loadAuthorizedOperation,
|
|
59
|
+
attempt: q.readAttempt,
|
|
60
|
+
event: q.readStageEvent,
|
|
61
|
+
acknowledgement: q.readProviderAcknowledgement,
|
|
62
|
+
};
|
|
63
|
+
const addresses = references().map((ref) => JSON.stringify(getFunctionAddress(ref)));
|
|
64
|
+
const authAddress = JSON.stringify(getFunctionAddress(entry.authorizationQuery));
|
|
65
|
+
const lifetime = createObservationReaderLifetime();
|
|
66
|
+
let binding = null;
|
|
67
|
+
let authorizedUntil = null;
|
|
68
|
+
function guard() {
|
|
69
|
+
if (authorizedUntil !== null)
|
|
70
|
+
need(lifetime.check().wallMs < authorizedUntil);
|
|
71
|
+
need(readMaintainedRootComponent(actualRoot) === component);
|
|
72
|
+
need(COMPILED_OBSERVATION_HISTORY_ENTRIES.filter((e) => e.component === component).length === 1 && COMPILED_OBSERVATION_HISTORY_ENTRIES.includes(entry));
|
|
73
|
+
need(ctx.auth === auth &&
|
|
74
|
+
auth.getUserIdentity === getIdentity &&
|
|
75
|
+
ctx.runQuery === captured.query &&
|
|
76
|
+
ctx.runMutation === captured.mutation &&
|
|
77
|
+
ctx.meta === captured.meta &&
|
|
78
|
+
ctx.meta.getFunctionMetadata === captured.metadata);
|
|
79
|
+
need(JSON.stringify(getFunctionAddress(entry.authorizationQuery)) ===
|
|
80
|
+
authAddress);
|
|
81
|
+
references().forEach((ref, index) => need(JSON.stringify(getFunctionAddress(ref)) === addresses[index]));
|
|
82
|
+
if (binding) {
|
|
83
|
+
const rpc = readCheckedJournalActionRPC(binding);
|
|
84
|
+
need(rpc.receiver === ctx &&
|
|
85
|
+
rpc.component === component &&
|
|
86
|
+
rpc.operationId === args.operationId &&
|
|
87
|
+
rpc.runQuery === captured.query &&
|
|
88
|
+
rpc.runMutation === captured.mutation);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const owned = (work) => lifetime.owned(work, guard);
|
|
92
|
+
try {
|
|
93
|
+
binding = await owned(() => captureMaintainedJournalBinding(actualRoot, {
|
|
94
|
+
actualActionCtx: ctx,
|
|
95
|
+
operationId: args.operationId,
|
|
96
|
+
}));
|
|
97
|
+
guard();
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
lifetime.close();
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
async function authorize() {
|
|
104
|
+
const who = await owned(() => getIdentity.call(auth));
|
|
105
|
+
need(who && !types.isProxy(who));
|
|
106
|
+
const token = Object.getOwnPropertyDescriptor(who, "tokenIdentifier");
|
|
107
|
+
need(token && token.enumerable && "value" in token);
|
|
108
|
+
const tokenIdentifier = text(token.value, 2048);
|
|
109
|
+
const reply = await owned(() => captured.query.call(ctx, entry.authorizationQuery, args));
|
|
110
|
+
return captureReaderAuthorization(reply, args, tokenIdentifier, lifetime.check().wallMs);
|
|
111
|
+
}
|
|
112
|
+
async function stage(operationId) {
|
|
113
|
+
const operation = captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.load, { operationId })));
|
|
114
|
+
const load = object(operation), active = object(load.activeAttempt);
|
|
115
|
+
const attemptId = text(active.attemptId);
|
|
116
|
+
const attempt = captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.attempt, { operationId, attemptId })));
|
|
117
|
+
const manifest = closed(attempt, ["reservation", "events"]);
|
|
118
|
+
need(Array.isArray(manifest.events) && manifest.events.length <= 3);
|
|
119
|
+
const count = manifest.events.length;
|
|
120
|
+
const events = [];
|
|
121
|
+
for (let index = 0; index < count; index++) {
|
|
122
|
+
const sequence = index === 0 ? 1 : index === 1 ? 2 : 3;
|
|
123
|
+
events.push(captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.event, {
|
|
124
|
+
operationId,
|
|
125
|
+
attemptId,
|
|
126
|
+
sequence,
|
|
127
|
+
}))));
|
|
128
|
+
}
|
|
129
|
+
const acknowledgement = captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.acknowledgement, { operationId })));
|
|
130
|
+
return { operation, attempt, events, acknowledgement };
|
|
131
|
+
}
|
|
132
|
+
let used = false;
|
|
133
|
+
return Object.freeze({
|
|
134
|
+
async read() {
|
|
135
|
+
need(arguments.length === 0 && !used);
|
|
136
|
+
used = true;
|
|
137
|
+
try {
|
|
138
|
+
lifetime.check();
|
|
139
|
+
guard();
|
|
140
|
+
const authorization = await authorize();
|
|
141
|
+
authorizedUntil = authorization.expiresAtMs;
|
|
142
|
+
const parent = await stage(args.parentOperationId), configure = await stage(args.operationId);
|
|
143
|
+
const history = await owned(() => captureRetainedObservationHistory({ parent, configure }));
|
|
144
|
+
const receipt = history.attachmentReceipt;
|
|
145
|
+
matchConfigureDATA(authorization.providerScope, {
|
|
146
|
+
mode: "platform",
|
|
147
|
+
stripeAccount: null,
|
|
148
|
+
livemode: receipt.livemode,
|
|
149
|
+
customerAccountId: receipt.customerAccountId,
|
|
150
|
+
subscriptionId: receipt.subscriptionId,
|
|
151
|
+
scheduleId: receipt.scheduleId,
|
|
152
|
+
});
|
|
153
|
+
const final = await authorize();
|
|
154
|
+
matchConfigureDATA(final, authorization);
|
|
155
|
+
need(lifetime.check().wallMs < authorization.expiresAtMs);
|
|
156
|
+
guard();
|
|
157
|
+
return freeze({
|
|
158
|
+
status: "authorized_observation_history_data",
|
|
159
|
+
history,
|
|
160
|
+
authorization,
|
|
161
|
+
operationalAuthority: false,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
lifetime.close();
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=reader.js.map
|