@fantastic.dev/better-stripe 0.109.1 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts +41 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js +40 -3
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts +10 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js +162 -57
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.d.ts +14 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.js +109 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.d.ts +20 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.js +176 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +24 -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/renewalObservation/evidence-invoice.d.ts.map +1 -1
- package/dist/client/billing/renewalObservation/evidence-invoice.js +3 -0
- package/dist/client/billing/renewalObservation/evidence-invoice.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +84 -32
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +42 -16
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +52 -0
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +26 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +27 -27
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/earnings/triggers.d.ts +44 -0
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/renewalWitnesses/eligibility.d.ts +36 -0
- package/dist/component/renewalWitnesses/eligibility.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/eligibility.js +60 -0
- package/dist/component/renewalWitnesses/eligibility.js.map +1 -0
- package/dist/component/renewalWitnesses/protocol.d.ts +75 -0
- package/dist/component/renewalWitnesses/protocol.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/protocol.js +82 -0
- package/dist/component/renewalWitnesses/protocol.js.map +1 -0
- package/dist/component/renewalWitnesses/schema.d.ts +99 -0
- package/dist/component/renewalWitnesses/schema.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/schema.js +36 -0
- package/dist/component/renewalWitnesses/schema.js.map +1 -0
- package/dist/component/renewalWitnesses/source.d.ts +22 -0
- package/dist/component/renewalWitnesses/source.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/source.js +108 -0
- package/dist/component/renewalWitnesses/source.js.map +1 -0
- package/dist/component/schema.d.ts +42 -16
- package/dist/component/schema.js +2 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +26 -0
- package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +42 -16
- package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
- package/dist/shared/renewalWitness.d.ts +51 -0
- package/dist/shared/renewalWitness.d.ts.map +1 -0
- package/dist/shared/renewalWitness.js +127 -0
- package/dist/shared/renewalWitness.js.map +1 -0
- package/docs/renewal-invoice-reads.md +85 -0
- package/docs/renewal-witness-protocol.md +88 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/observation/freshActor.ts +69 -3
- package/src/client/billing/renewalAttach/internal/observation/freshTransport.ts +189 -59
- package/src/client/billing/renewalAttach/internal/observation/invoiceActor.integration.test.ts +142 -0
- package/src/client/billing/renewalAttach/internal/observation/invoiceActorControls.integration.test.ts +495 -0
- package/src/client/billing/renewalAttach/internal/observation/invoiceAuthorization.ts +145 -0
- package/src/client/billing/renewalAttach/internal/observation/invoicePlan.ts +284 -0
- package/src/client/billing/renewalAttach/internal/observation/profile.ts +1 -1
- package/src/client/billing/renewalAttach/internal/observation/types.ts +7 -1
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +30 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureWriteControls.integration.test.ts +74 -62
- package/src/client/billing/renewalAttach/internal/test-fixtures/invoiceObservation.ts +158 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +11 -1
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +4 -0
- package/src/client/billing/renewalObservation/evidence-invoice-identity.test.ts +13 -0
- package/src/client/billing/renewalObservation/evidence-invoice.ts +8 -0
- package/src/component/renewalOperations/configureJournal.fixtures.ts +25 -3
- package/src/component/renewalWitnesses/bounds.test.ts +204 -0
- package/src/component/renewalWitnesses/codec.test.ts +84 -0
- package/src/component/renewalWitnesses/controls.test.ts +250 -0
- package/src/component/renewalWitnesses/eligibility.ts +78 -0
- package/src/component/renewalWitnesses/protocol.test.ts +63 -0
- package/src/component/renewalWitnesses/protocol.ts +103 -0
- package/src/component/renewalWitnesses/schema.ts +36 -0
- package/src/component/renewalWitnesses/source.ts +157 -0
- package/src/component/schema.ts +2 -0
- package/src/shared/renewalWitness.ts +179 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { renewalSnapshot } from "../client/billing/renewalReplacementSnapshot.js";
|
|
2
|
+
export function witnessStop() {
|
|
3
|
+
throw Error("RENEWAL_WITNESS_INVALID");
|
|
4
|
+
}
|
|
5
|
+
export function witnessNeed(value) {
|
|
6
|
+
if (!value)
|
|
7
|
+
witnessStop();
|
|
8
|
+
}
|
|
9
|
+
export function witnessObject(raw) {
|
|
10
|
+
witnessNeed(raw !== null && typeof raw === "object" && !Array.isArray(raw));
|
|
11
|
+
return raw;
|
|
12
|
+
}
|
|
13
|
+
export function witnessClosed(raw, keys) {
|
|
14
|
+
const value = witnessObject(raw), actual = Object.keys(value);
|
|
15
|
+
witnessNeed(actual.length === keys.length && actual.every((key) => keys.includes(key)));
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export function witnessText(raw, max = 255) {
|
|
19
|
+
witnessNeed(typeof raw === "string" && raw.length > 0 && raw.length <= max);
|
|
20
|
+
return raw;
|
|
21
|
+
}
|
|
22
|
+
export function witnessIdentity(raw) {
|
|
23
|
+
const value = witnessClosed(raw, [
|
|
24
|
+
"componentScope",
|
|
25
|
+
"witnessId",
|
|
26
|
+
"parentOperationId",
|
|
27
|
+
"operationId",
|
|
28
|
+
]);
|
|
29
|
+
const identity = {
|
|
30
|
+
componentScope: witnessText(value.componentScope),
|
|
31
|
+
witnessId: witnessText(value.witnessId),
|
|
32
|
+
parentOperationId: witnessText(value.parentOperationId),
|
|
33
|
+
operationId: witnessText(value.operationId),
|
|
34
|
+
};
|
|
35
|
+
witnessNeed(identity.operationId !== identity.parentOperationId);
|
|
36
|
+
return identity;
|
|
37
|
+
}
|
|
38
|
+
function acknowledgement(raw) {
|
|
39
|
+
if (raw === null)
|
|
40
|
+
return null;
|
|
41
|
+
const value = witnessClosed(raw, ["retention", "receipt"]);
|
|
42
|
+
return {
|
|
43
|
+
retention: witnessObject(value.retention),
|
|
44
|
+
receipt: witnessObject(value.receipt),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function stage(raw, parent) {
|
|
48
|
+
const value = witnessClosed(raw, [
|
|
49
|
+
"record",
|
|
50
|
+
"reservation",
|
|
51
|
+
"acknowledgement",
|
|
52
|
+
...(parent ? ["initialBasis"] : []),
|
|
53
|
+
]);
|
|
54
|
+
return {
|
|
55
|
+
record: witnessObject(value.record),
|
|
56
|
+
reservation: witnessObject(value.reservation),
|
|
57
|
+
acknowledgement: acknowledgement(value.acknowledgement),
|
|
58
|
+
...(parent ? { initialBasis: witnessObject(value.initialBasis) } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Complete canonical JSON only. This admits DATA, not capture/authentication authority. */
|
|
62
|
+
export function canonicalWitnessJSON(raw) {
|
|
63
|
+
witnessNeed(typeof raw === "string" &&
|
|
64
|
+
raw.length <= 500000 &&
|
|
65
|
+
new TextEncoder().encode(raw).length <= 500000);
|
|
66
|
+
const copy = renewalSnapshot(JSON.parse(raw));
|
|
67
|
+
witnessNeed(JSON.stringify(copy) === raw);
|
|
68
|
+
const value = witnessClosed(copy, [
|
|
69
|
+
"version",
|
|
70
|
+
"kind",
|
|
71
|
+
"identity",
|
|
72
|
+
"capturedSubject",
|
|
73
|
+
"acquisition",
|
|
74
|
+
"source",
|
|
75
|
+
"reads",
|
|
76
|
+
"invoiceContext",
|
|
77
|
+
]);
|
|
78
|
+
witnessNeed(value.version === 1 && value.kind === "renewal_witness_payload");
|
|
79
|
+
witnessIdentity(value.identity);
|
|
80
|
+
witnessText(value.capturedSubject, 2048);
|
|
81
|
+
const acquired = witnessClosed(value.acquisition, [
|
|
82
|
+
"observedAtMs",
|
|
83
|
+
"elapsedWallMs",
|
|
84
|
+
"elapsedNsDecimal",
|
|
85
|
+
"apiVersion",
|
|
86
|
+
"baseReadProfile",
|
|
87
|
+
"invoiceReadProfile",
|
|
88
|
+
]);
|
|
89
|
+
witnessNeed(typeof acquired.observedAtMs === "number" &&
|
|
90
|
+
Number.isSafeInteger(acquired.observedAtMs) &&
|
|
91
|
+
acquired.observedAtMs >= 0);
|
|
92
|
+
witnessNeed(typeof acquired.elapsedWallMs === "number" &&
|
|
93
|
+
Number.isSafeInteger(acquired.elapsedWallMs) &&
|
|
94
|
+
acquired.elapsedWallMs >= 0 &&
|
|
95
|
+
acquired.elapsedWallMs < 30000 &&
|
|
96
|
+
acquired.observedAtMs - acquired.elapsedWallMs >= 0);
|
|
97
|
+
witnessNeed(typeof acquired.elapsedNsDecimal === "string" &&
|
|
98
|
+
/^(0|[1-9][0-9]{0,10})$/.test(acquired.elapsedNsDecimal) &&
|
|
99
|
+
BigInt(acquired.elapsedNsDecimal) < 30000000000n);
|
|
100
|
+
witnessNeed(acquired.apiVersion === "2026-09-30.endive" &&
|
|
101
|
+
acquired.baseReadProfile === "endive-schedule-first-44-v1");
|
|
102
|
+
witnessNeed(value.invoiceContext === null
|
|
103
|
+
? acquired.invoiceReadProfile === null
|
|
104
|
+
: acquired.invoiceReadProfile === "endive-pinned-invoices-fence-7-v1");
|
|
105
|
+
const source = witnessClosed(value.source, ["parent", "configure"]);
|
|
106
|
+
witnessNeed(stage(source.parent, true).acknowledgement !== null);
|
|
107
|
+
stage(source.configure, false);
|
|
108
|
+
const reads = witnessClosed(value.reads, [
|
|
109
|
+
"schedule",
|
|
110
|
+
"subscription",
|
|
111
|
+
"targetPrice",
|
|
112
|
+
"billingCustomer",
|
|
113
|
+
"coupons",
|
|
114
|
+
]);
|
|
115
|
+
for (const name of [
|
|
116
|
+
"schedule",
|
|
117
|
+
"subscription",
|
|
118
|
+
"targetPrice",
|
|
119
|
+
"billingCustomer",
|
|
120
|
+
])
|
|
121
|
+
witnessObject(reads[name]);
|
|
122
|
+
witnessNeed(Array.isArray(reads.coupons));
|
|
123
|
+
if (value.invoiceContext !== null)
|
|
124
|
+
witnessClosed(value.invoiceContext, ["original", "current"]);
|
|
125
|
+
return Object.freeze({ json: raw, value: copy });
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=renewalWitness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renewalWitness.js","sourceRoot":"","sources":["../../src/shared/renewalWitness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAIlF,MAAM,UAAU,WAAW;IACzB,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACzC,CAAC;AACD,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,CAAC,KAAK;QAAE,WAAW,EAAE,CAAC;AAC5B,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,WAAW,CAAC,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5E,OAAO,GAA8B,CAAC;AACxC,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,GAAY,EAAE,IAAuB;IACjE,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,EAC9B,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,WAAW,CACT,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC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IAAI,CAAC,CAAC,eAAe,KAAK,IAAI,CAAC,CAAC;IACjE,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE;QACvC,UAAU;QACV,cAAc;QACd,aAAa;QACb,iBAAiB;QACjB,SAAS;KACV,CAAC,CAAC;IACH,KAAK,MAAM,IAAI,IAAI;QACjB,UAAU;QACV,cAAc;QACd,aAAa;QACb,iBAAiB;KAClB;QACC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,IAAI,KAAK,CAAC,cAAc,KAAK,IAAI;QAC/B,aAAa,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAsB,EAAE,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Private renewal invoice acquisition
|
|
2
|
+
|
|
3
|
+
The private invoice observer extends fresh renewal evidence with a separately
|
|
4
|
+
authorized invoice pair. It has no public SDK export. Both production profiles
|
|
5
|
+
remain empty; implementing the private path does not activate provider access.
|
|
6
|
+
The original schedule-first 44-GET observer keeps its existing result layout and
|
|
7
|
+
does not fetch invoices.
|
|
8
|
+
|
|
9
|
+
The invoice wrapper uses the same actual Action invocation, selected SDK client
|
|
10
|
+
and original 30-second lifetime as its base observation. Base reads still acquire
|
|
11
|
+
the retained owned schedule, original subscription, target price, billing
|
|
12
|
+
customer and bounded coupon inventory. Invoice acquisition adds at most seven
|
|
13
|
+
GETs, giving a maximum of 51 provider calls. Requests have no body, no idempotency
|
|
14
|
+
key, zero retries and the fixed `2026-09-30.endive` API version.
|
|
15
|
+
|
|
16
|
+
## Dedicated invoice permission
|
|
17
|
+
|
|
18
|
+
A fixed host query authenticates its own `ctx.auth` and authorizes the exact
|
|
19
|
+
`renewal_invoice_evidence_v1` capability. Its closed arguments bind the trusted
|
|
20
|
+
installation scope, parent/configure operation IDs, platform mode, null connected
|
|
21
|
+
account, livemode, customer account, billing Customer ID, original subscription,
|
|
22
|
+
owned schedule and the two pinned invoice IDs. The Customer ID comes from the
|
|
23
|
+
retained billing customer and must match fresh customer relations. An account ID
|
|
24
|
+
alone does not grant access to its customers' invoice bodies.
|
|
25
|
+
|
|
26
|
+
The response repeats these arguments with the authenticated token identifier,
|
|
27
|
+
authorization ID, positive revision and expiration. Both the original operation
|
|
28
|
+
grant and dedicated invoice grant are rechecked before each additional GET and
|
|
29
|
+
before releasing protected output. Each response must remain equal to its own
|
|
30
|
+
first captured grant. Generated Convex query references are bound by their fixed
|
|
31
|
+
Source association and captured semantic address.
|
|
32
|
+
|
|
33
|
+
The earliest original lifetime, base expiration or invoice expiration wins.
|
|
34
|
+
There is no new timer or renewed expiration. Revocation, context/profile/address
|
|
35
|
+
drift, changed SDK configuration and timeout refuse protected output. The actor
|
|
36
|
+
can be consumed once. Late completion cannot authorize a new read or release.
|
|
37
|
+
|
|
38
|
+
## Pinned requests and complete inventories
|
|
39
|
+
|
|
40
|
+
The original invoice ID comes only from the retained original subscription's
|
|
41
|
+
`latest_invoice`. The current ID comes only from the first fresh original
|
|
42
|
+
subscription response. Missing pointers leave invoice evidence unavailable.
|
|
43
|
+
Equal IDs cannot establish a distinct-period pair; this does not turn an
|
|
44
|
+
ordinary pending observation into a broader conflict. No search, date inference,
|
|
45
|
+
matching-resource adoption or replacement pointer is used.
|
|
46
|
+
|
|
47
|
+
Malformed, deleted or foreign expanded references refuse without fallback.
|
|
48
|
+
Rich expansions retain all fields and must match the separately fetched complete
|
|
49
|
+
invoice; they do not skip that GET. Each invoice body must match its pinned ID,
|
|
50
|
+
mode, account, customer and original subscription before requesting its lines.
|
|
51
|
+
|
|
52
|
+
For each invoice, the plan fetches the fixed body path and
|
|
53
|
+
`/v1/invoices/{id}/lines?limit=100`. A second page is allowed only when the first
|
|
54
|
+
declares `has_more:true`. Its cursor is the last validated line ID. The plan never
|
|
55
|
+
follows `page.url`; that field must match the fixed invoice-lines pathname.
|
|
56
|
+
Line object, mode and invoice ownership are checked before cursor adoption.
|
|
57
|
+
Duplicate IDs, including aliases across the two invoices, invalid cursors,
|
|
58
|
+
oversize pages, empty continuations and a second page with more data refuse the
|
|
59
|
+
pair. There is no third page or truncation.
|
|
60
|
+
|
|
61
|
+
One final subscription GET must equal the complete earlier fresh subscription
|
|
62
|
+
response. Pointer or material drift refuses the pair; the observer does not
|
|
63
|
+
adopt the fence response or restart acquisition. Partial inventories never enter
|
|
64
|
+
the analyzer as a complete `invoiceContext`.
|
|
65
|
+
|
|
66
|
+
## Result meaning
|
|
67
|
+
|
|
68
|
+
The invoice wrapper adds `invoiceContext`, `invoiceInventory` and `invoiceReason`
|
|
69
|
+
to its private DATA output. A complete inventory means the bounded resources were
|
|
70
|
+
acquired, not that their billing material qualifies. The existing seven-input,
|
|
71
|
+
twelve-result analyzer checks item/successor identity, native periods, exact
|
|
72
|
+
price/product/currency, non-proration and decimal strings. It preserves full raw
|
|
73
|
+
resources and wire decimal text. Invoice status does not establish payment,
|
|
74
|
+
entitlement, consent or exclusive causality.
|
|
75
|
+
|
|
76
|
+
Actual SDK rejection returns bounded diagnostics and retained receipts only
|
|
77
|
+
after both final grants succeed. Authorization and decoding failures propagate;
|
|
78
|
+
they do not become fabricated provider rejections. No protected DATA is released
|
|
79
|
+
after timeout or revocation.
|
|
80
|
+
|
|
81
|
+
The final authorization and subscription fence are checked points. Sequential
|
|
82
|
+
invoice bodies and line pages do not form an atomic snapshot or prove
|
|
83
|
+
uninterrupted permission. Historical native witness acquisition remains a
|
|
84
|
+
separate requirement. Live provider qualification, genuine generation, deployed
|
|
85
|
+
compatibility, operational binding and Dojo acceptance are still required.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Immutable renewal witness protocol
|
|
2
|
+
|
|
3
|
+
This component protocol stores complete unsigned renewal snapshot DATA. It is
|
|
4
|
+
the persistence prerequisite for historical acquisition, not an activated
|
|
5
|
+
capture or authorization API. It adds a table and ordinary transactional helpers,
|
|
6
|
+
with no registered production query or mutation. Live capture, separate host
|
|
7
|
+
retain/read capabilities, actual returned acknowledgement custody and genuine
|
|
8
|
+
generated routes remain required before runtime activation.
|
|
9
|
+
|
|
10
|
+
## Payload and source checks
|
|
11
|
+
|
|
12
|
+
The canonical envelope contains exact installation/witness/parent/configure
|
|
13
|
+
identity, captured subject, bounded acquisition metadata, complete source records
|
|
14
|
+
and reservations, retained attachment receipt, optional retained configure
|
|
15
|
+
receipt, full raw reads and optional complete invoice context. Unknown resource
|
|
16
|
+
fields, own null values and wire decimal strings remain intact.
|
|
17
|
+
|
|
18
|
+
Acquisition metadata names the base 44-read profile and a separate nullable
|
|
19
|
+
seven-extra-read invoice profile. Wall and canonical decimal nanosecond durations
|
|
20
|
+
must fit the original 30-second profile; the derived wall start is nonnegative.
|
|
21
|
+
These are unsigned metadata checks. They establish neither an actual invocation
|
|
22
|
+
nor provider historical time.
|
|
23
|
+
|
|
24
|
+
At both retain and read boundaries, validation reloads the actual original
|
|
25
|
+
component records, payload owners, active reservations, parent basis, complete
|
|
26
|
+
event chains and retained acknowledgements. It checks the parent link and full
|
|
27
|
+
stored source against those records. Configure events must match the complete
|
|
28
|
+
C7 request; response2 is reconstructed even without retained C9. Opaque generic
|
|
29
|
+
journal events do not qualify this protocol. Full stage events need not be
|
|
30
|
+
duplicated in each witness because their actual immutable records are checked.
|
|
31
|
+
|
|
32
|
+
Configuration comes from the complete C7 record. Captured-present C9 must match
|
|
33
|
+
its full retained counterpart; raw constructor input is reconstructed from exact
|
|
34
|
+
dispatch, provider snapshot and transport. Captured-null C9 remains null even if
|
|
35
|
+
a valid C9 is retained later. Later journal integrity is checked without
|
|
36
|
+
injecting the newer receipt into the stored snapshot.
|
|
37
|
+
|
|
38
|
+
The existing evidence analyzer must recompute `current_target_material_match`.
|
|
39
|
+
If invoice context is included, it must also supply complete paired correlation.
|
|
40
|
+
Stored analysis flags and hashes alone do not qualify material. Descriptor
|
|
41
|
+
scope, successor item and native period derive from the complete admitted
|
|
42
|
+
evidence. No live provider resource is fetched during persistence or retrieval.
|
|
43
|
+
|
|
44
|
+
## Immutable transactions and bounds
|
|
45
|
+
|
|
46
|
+
The logical uniqueness key is installation `componentScope` plus `witnessId`.
|
|
47
|
+
The complete identity additionally binds parent and configure operation IDs.
|
|
48
|
+
Indexed lookups use `take(2)` to detect duplicate rows. First identity wins:
|
|
49
|
+
identical canonical payloads return the same descriptor, while a changed payload
|
|
50
|
+
or operation under that key conflicts. The protocol never overwrites, repairs
|
|
51
|
+
or chooses a new identity automatically.
|
|
52
|
+
|
|
53
|
+
A read checks the full requested identity before releasing content. Wrong
|
|
54
|
+
installation, witness or operation returns no payload. The stored payload is
|
|
55
|
+
revalidated against original component context and its full digest; corrupted,
|
|
56
|
+
missing or duplicate source/storage rows refuse. Later live resource drift does
|
|
57
|
+
not replace the earlier snapshot.
|
|
58
|
+
|
|
59
|
+
The complete canonical envelope keeps the existing 500,000-byte, 10,000-node and
|
|
60
|
+
40-depth bounds. Before insertion, the protocol also charges the complete stored
|
|
61
|
+
value and full read reply, reserving the admitted maximum opaque ID length for
|
|
62
|
+
its future descriptor. It never crops resources to fit. Transactional helpers
|
|
63
|
+
are intended for one retain operation per registered transaction; normal Convex
|
|
64
|
+
transaction concurrency provides the first-wins behavior across calls.
|
|
65
|
+
|
|
66
|
+
## Retention and historical meaning
|
|
67
|
+
|
|
68
|
+
A successful transaction returns a row descriptor and full payload binding. It
|
|
69
|
+
does not prove that an external caller received that result. A lost response can
|
|
70
|
+
leave a durable row with no returned public acknowledgement. An explicit later
|
|
71
|
+
identical request can recover the same descriptor, subject to the separate host
|
|
72
|
+
policy and runtime custody checks required for historical acquisition.
|
|
73
|
+
|
|
74
|
+
Descriptors always report false authentication, operational authority and public
|
|
75
|
+
delivery, with provider qualification still required. The captured subject is
|
|
76
|
+
immutable DATA, not permission for a later reader. A later host authorization
|
|
77
|
+
may permit a different subject without rewriting the capture.
|
|
78
|
+
|
|
79
|
+
Stored raw material may supply `{reads, invoiceContext}` to the historical
|
|
80
|
+
evidence axis, independently of later live settings or terminal drift. It does
|
|
81
|
+
not revive a write Owner, manufacture a native past observation, prove atomic
|
|
82
|
+
acquisition or establish exclusive causality. Fetching an old invoice later is
|
|
83
|
+
not a substitute for the complete active snapshot.
|
|
84
|
+
|
|
85
|
+
The controlled tests exercise real component transaction helpers and journal
|
|
86
|
+
records. Production route generation, deployment, native/provider qualification,
|
|
87
|
+
actual capture/read integration, release acceptance and Dojo adoption remain
|
|
88
|
+
separate requirements. Existing execution holds remain in force.
|
package/package.json
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { getFunctionAddress } from "convex/server";
|
|
2
|
+
import {
|
|
3
|
+
captureInvoiceObservationProfile,
|
|
4
|
+
invoiceProfileGuard,
|
|
5
|
+
} from "./invoiceAuthorization.js";
|
|
6
|
+
import type { InvoiceObservationProfile } from "../operations/sourceOperations.js";
|
|
1
7
|
import {
|
|
2
8
|
captureObservationInvocation,
|
|
3
9
|
readObservationInvocation,
|
|
@@ -28,10 +34,42 @@ export async function captureFreshRenewalObservation(
|
|
|
28
34
|
raw: unknown,
|
|
29
35
|
) {
|
|
30
36
|
need(arguments.length === 2);
|
|
37
|
+
return captureFreshObservation(root, raw, null);
|
|
38
|
+
}
|
|
39
|
+
/** Separate qualified invoice capability; EMPTY before any input reflection. */
|
|
40
|
+
export async function captureFreshInvoiceRenewalObservation(
|
|
41
|
+
root: object,
|
|
42
|
+
raw: unknown,
|
|
43
|
+
) {
|
|
44
|
+
need(arguments.length === 2);
|
|
45
|
+
const profile = captureInvoiceObservationProfile(root);
|
|
46
|
+
return captureFreshObservation(root, raw, profile);
|
|
47
|
+
}
|
|
48
|
+
async function captureFreshObservation(
|
|
49
|
+
root: object,
|
|
50
|
+
raw: unknown,
|
|
51
|
+
invoiceProfile: InvoiceObservationProfile | null,
|
|
52
|
+
) {
|
|
31
53
|
const profile = captureFreshObservationProfile(root);
|
|
54
|
+
const invoiceAddress =
|
|
55
|
+
invoiceProfile &&
|
|
56
|
+
JSON.stringify(getFunctionAddress(invoiceProfile.authorizationQuery));
|
|
57
|
+
const invoiceGuard = () => {
|
|
58
|
+
if (invoiceProfile) {
|
|
59
|
+
invoiceProfileGuard(invoiceProfile);
|
|
60
|
+
need(
|
|
61
|
+
invoiceProfile.freshProfile === profile &&
|
|
62
|
+
JSON.stringify(
|
|
63
|
+
getFunctionAddress(invoiceProfile.authorizationQuery),
|
|
64
|
+
) === invoiceAddress,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
invoiceGuard();
|
|
32
69
|
const token = await captureObservationInvocation(root, raw);
|
|
33
70
|
let state: ObservationInvocationState;
|
|
34
71
|
try {
|
|
72
|
+
invoiceGuard();
|
|
35
73
|
state = readObservationInvocation(token);
|
|
36
74
|
need(state.historyEntry === profile.historyEntry);
|
|
37
75
|
} catch (error) {
|
|
@@ -44,8 +82,17 @@ export async function captureFreshRenewalObservation(
|
|
|
44
82
|
need(arguments.length === 0 && !used);
|
|
45
83
|
used = true;
|
|
46
84
|
try {
|
|
85
|
+
invoiceGuard();
|
|
47
86
|
const captured = await state.captureHistory();
|
|
48
|
-
|
|
87
|
+
invoiceGuard();
|
|
88
|
+
const transport = captureFreshGetTransport(
|
|
89
|
+
token,
|
|
90
|
+
profile,
|
|
91
|
+
invoiceProfile,
|
|
92
|
+
);
|
|
93
|
+
let invoiceResult: Awaited<
|
|
94
|
+
ReturnType<typeof transport.acquireInvoices>
|
|
95
|
+
> | null = null;
|
|
49
96
|
async function release(
|
|
50
97
|
status:
|
|
51
98
|
| "fresh_observation_data"
|
|
@@ -58,10 +105,17 @@ export async function captureFreshRenewalObservation(
|
|
|
58
105
|
reason: string | null,
|
|
59
106
|
failure: ReadFailure | null = null,
|
|
60
107
|
) {
|
|
61
|
-
await
|
|
108
|
+
await transport.finalizeInvoices();
|
|
62
109
|
transport.guard();
|
|
63
110
|
const output = captureReaderQueryDATA({
|
|
64
111
|
status,
|
|
112
|
+
...(invoiceProfile
|
|
113
|
+
? {
|
|
114
|
+
invoiceContext: invoiceResult?.context ?? null,
|
|
115
|
+
invoiceInventory: invoiceResult?.status ?? "not_acquired",
|
|
116
|
+
invoiceReason: invoiceResult?.reason ?? null,
|
|
117
|
+
}
|
|
118
|
+
: {}),
|
|
65
119
|
...captured,
|
|
66
120
|
reads,
|
|
67
121
|
evidence,
|
|
@@ -119,7 +173,7 @@ export async function captureFreshRenewalObservation(
|
|
|
119
173
|
configuration: captured.history.record.configuration,
|
|
120
174
|
configureReceipt: captured.history.rawConfigureReceipt,
|
|
121
175
|
reads,
|
|
122
|
-
invoiceContext: null,
|
|
176
|
+
invoiceContext: invoiceResult?.context ?? null,
|
|
123
177
|
historicalSnapshot: null,
|
|
124
178
|
});
|
|
125
179
|
} catch {
|
|
@@ -159,6 +213,18 @@ export async function captureFreshRenewalObservation(
|
|
|
159
213
|
validateCoupon(captured.history.record, id, result.body);
|
|
160
214
|
reads.coupons.push(result.body);
|
|
161
215
|
}
|
|
216
|
+
if (invoiceProfile) {
|
|
217
|
+
invoiceResult = await transport.acquireInvoices();
|
|
218
|
+
if (invoiceResult.status === "provider_rejected")
|
|
219
|
+
return await release(
|
|
220
|
+
"observation_provider_rejected",
|
|
221
|
+
null,
|
|
222
|
+
null,
|
|
223
|
+
"complete",
|
|
224
|
+
null,
|
|
225
|
+
invoiceResult.failure,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
162
228
|
const evidence = await analyze();
|
|
163
229
|
return await release(
|
|
164
230
|
"fresh_observation_data",
|