@hasna/capacity 0.1.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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6663 -0
- package/dist/domain/authority-evidence.d.ts +198 -0
- package/dist/domain/catalog.d.ts +65 -0
- package/dist/domain/counter.d.ts +7 -0
- package/dist/domain/eligibility.d.ts +4 -0
- package/dist/domain/ids.d.ts +47 -0
- package/dist/domain/invariants.d.ts +4 -0
- package/dist/domain/models.d.ts +300 -0
- package/dist/domain/native-subscription.d.ts +211 -0
- package/dist/domain/online-generation-receipt.d.ts +497 -0
- package/dist/domain/state.d.ts +19 -0
- package/dist/errors.d.ts +26 -0
- package/dist/http/handler.d.ts +3 -0
- package/dist/http/openapi.d.ts +1070 -0
- package/dist/http/stores.d.ts +20 -0
- package/dist/http/types.d.ts +141 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +14909 -0
- package/dist/sdk/index.d.ts +8 -0
- package/dist/sdk/local.d.ts +5 -0
- package/dist/sdk/remote.d.ts +2 -0
- package/dist/sdk/types.d.ts +107 -0
- package/dist/serialization/dto.d.ts +13 -0
- package/dist/serialization/json.d.ts +7 -0
- package/dist/storage/credential-use-authorizer.d.ts +9 -0
- package/dist/storage/credential-verifier.d.ts +13 -0
- package/dist/storage/effect-dispatch.d.ts +278 -0
- package/dist/storage/file-recovery-ledger.d.ts +66 -0
- package/dist/storage/memory.d.ts +47 -0
- package/dist/storage/native-revocation.d.ts +10 -0
- package/dist/storage/postgres-config.d.ts +25 -0
- package/dist/storage/postgres-migrations.d.ts +10 -0
- package/dist/storage/postgres-migrator.d.ts +12 -0
- package/dist/storage/postgres.d.ts +90 -0
- package/dist/storage/recovery.d.ts +11 -0
- package/dist/storage/repository.d.ts +310 -0
- package/dist/storage/shared.d.ts +18 -0
- package/dist/storage/sqlite-migrations.d.ts +11 -0
- package/dist/storage/sqlite.d.ts +51 -0
- package/dist/version.d.ts +2 -0
- package/package.json +49 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { type KeyObject } from "node:crypto";
|
|
2
|
+
import { type Counter } from "./counter";
|
|
3
|
+
export declare const ONLINE_GENERATION_CHECK_RECEIPT_SCHEMA_VERSION: "accounts.online-generation-check-receipt.v1";
|
|
4
|
+
export declare const ONLINE_GENERATION_RECEIPT_MAXIMUM_AGE_MS: 60000;
|
|
5
|
+
export declare const ONLINE_GENERATION_RECEIPT_MAXIMUM_LIFETIME_MS: 120000;
|
|
6
|
+
export declare const ONLINE_GENERATION_RECEIPT_MAXIMUM_CLOCK_SKEW_MS: 5000;
|
|
7
|
+
export declare const ONLINE_GENERATION_RECEIPT_MAX_USES: 1n;
|
|
8
|
+
export declare const CAPABILITY_USE_CONSUME_REQUEST_SCHEMA_VERSION: "accounts.capability-use-consume-request.v1";
|
|
9
|
+
export declare const CAPABILITY_USE_CONSUME_REQUEST_SCHEMA_DIGEST: "sha256:a7cdc1dfbebeaea3bad6a5014cfb5189be40fb010f57161b46437458492cd1bc";
|
|
10
|
+
export declare const CAPABILITY_USE_CONSUME_RECEIPT_SCHEMA_VERSION: "accounts.capability-use-consume-receipt.v1";
|
|
11
|
+
export declare const CAPABILITY_USE_CONSUME_RECEIPT_SCHEMA_DIGEST: "sha256:a0999ffabc197f46f6fdeb8a6b78521364b0f2153d52a0e6e63ee360bb408bce";
|
|
12
|
+
export type OnlineGenerationAccessTransport = "native_session" | "api_key" | "workload_identity";
|
|
13
|
+
export type OnlineGenerationAllowedChannelClass = "capsule_remote_tool" | "brokered_provider_proxy";
|
|
14
|
+
export interface ProviderDestinationPolicy {
|
|
15
|
+
readonly scheme: "https";
|
|
16
|
+
readonly normalized_host: string;
|
|
17
|
+
readonly port: string;
|
|
18
|
+
readonly operation_path: string;
|
|
19
|
+
readonly model: string;
|
|
20
|
+
readonly request_body_digest: string;
|
|
21
|
+
readonly tls_server_name: string;
|
|
22
|
+
readonly resolved_address_class: string;
|
|
23
|
+
readonly egress_policy_digest: string;
|
|
24
|
+
}
|
|
25
|
+
interface OnlineGenerationReceiptBaseDraft {
|
|
26
|
+
readonly schema_version: typeof ONLINE_GENERATION_CHECK_RECEIPT_SCHEMA_VERSION;
|
|
27
|
+
readonly schema_digest: string;
|
|
28
|
+
readonly receipt_id: string;
|
|
29
|
+
readonly issuer: string;
|
|
30
|
+
readonly issuer_incarnation: string;
|
|
31
|
+
readonly key_id: string;
|
|
32
|
+
readonly audience: string;
|
|
33
|
+
readonly nonce: string;
|
|
34
|
+
readonly issued_at: string;
|
|
35
|
+
readonly not_before: string;
|
|
36
|
+
readonly expires_at: string;
|
|
37
|
+
readonly capability_id: string;
|
|
38
|
+
readonly capability_digest: string;
|
|
39
|
+
readonly authority_epoch: Counter;
|
|
40
|
+
readonly route_lineage_id: string;
|
|
41
|
+
readonly route_id: string;
|
|
42
|
+
readonly route_epoch: Counter;
|
|
43
|
+
readonly run_id: string;
|
|
44
|
+
readonly attempt_id: string;
|
|
45
|
+
readonly attempt_lease_id: string;
|
|
46
|
+
readonly lease_epoch: Counter;
|
|
47
|
+
readonly resource_lease_id: string;
|
|
48
|
+
readonly resource_id: string;
|
|
49
|
+
readonly resource_lifecycle_generation: Counter;
|
|
50
|
+
readonly lease_expires_at: string;
|
|
51
|
+
readonly operation_id: string;
|
|
52
|
+
readonly operation_digest: string;
|
|
53
|
+
readonly operation_execution_epoch: Counter;
|
|
54
|
+
readonly operation_execution_expires_at: string;
|
|
55
|
+
readonly subject: string;
|
|
56
|
+
readonly actor_principal: string;
|
|
57
|
+
readonly lease_holder_principal: string;
|
|
58
|
+
readonly operation_executor_principal: string;
|
|
59
|
+
readonly sender_key_thumbprint: string;
|
|
60
|
+
readonly provider_account_id: string;
|
|
61
|
+
readonly account_lane_id: string;
|
|
62
|
+
readonly capacity_pool_id: string;
|
|
63
|
+
readonly capacity_domain_ref: string;
|
|
64
|
+
readonly access_transport: OnlineGenerationAccessTransport;
|
|
65
|
+
readonly credential_family_id: string;
|
|
66
|
+
readonly capacity_generation: Counter;
|
|
67
|
+
readonly deny_generation: Counter;
|
|
68
|
+
readonly credential_generation: Counter;
|
|
69
|
+
readonly accounts_revision_set_digest: string;
|
|
70
|
+
readonly allowed_channel_class: OnlineGenerationAllowedChannelClass;
|
|
71
|
+
readonly slot_eligibility_digest: string;
|
|
72
|
+
readonly approval_ref: string;
|
|
73
|
+
readonly policy_digest: string;
|
|
74
|
+
readonly canonical_request_digest: string;
|
|
75
|
+
readonly provider_destination_policy: ProviderDestinationPolicy;
|
|
76
|
+
readonly provider_destination_policy_digest: string;
|
|
77
|
+
readonly sender_constraint_confirmation: string;
|
|
78
|
+
readonly max_uses: Counter;
|
|
79
|
+
readonly use_count: Counter;
|
|
80
|
+
readonly catalog_incarnation: string;
|
|
81
|
+
readonly recovery_frontier_sequence: Counter;
|
|
82
|
+
readonly recovery_frontier_hash: string;
|
|
83
|
+
}
|
|
84
|
+
export type OnlineGenerationReceiptDecision = {
|
|
85
|
+
readonly allowed: true;
|
|
86
|
+
readonly deny_state: "allowed";
|
|
87
|
+
readonly reason_codes: readonly [];
|
|
88
|
+
readonly current_deny?: never;
|
|
89
|
+
} | {
|
|
90
|
+
readonly allowed: false;
|
|
91
|
+
readonly deny_state: "allowed";
|
|
92
|
+
readonly reason_codes: readonly string[];
|
|
93
|
+
readonly current_deny?: never;
|
|
94
|
+
} | {
|
|
95
|
+
readonly allowed: false;
|
|
96
|
+
readonly deny_state: "denied";
|
|
97
|
+
readonly reason_codes: readonly string[];
|
|
98
|
+
readonly current_deny: true;
|
|
99
|
+
};
|
|
100
|
+
export interface NativeOnlineGenerationReceiptTarget {
|
|
101
|
+
readonly access_transport: "native_session";
|
|
102
|
+
readonly allowed_channel_class: "capsule_remote_tool";
|
|
103
|
+
readonly auth_capsule_id: string;
|
|
104
|
+
readonly canonical_node_id: string;
|
|
105
|
+
readonly node_key_thumbprint: string;
|
|
106
|
+
readonly node_generation: Counter;
|
|
107
|
+
readonly placement_generation: Counter;
|
|
108
|
+
readonly auth_generation: Counter;
|
|
109
|
+
readonly auth_state_revision: Counter;
|
|
110
|
+
}
|
|
111
|
+
export interface BrokeredOnlineGenerationReceiptTarget {
|
|
112
|
+
readonly access_transport: "api_key" | "workload_identity";
|
|
113
|
+
readonly allowed_channel_class: "brokered_provider_proxy";
|
|
114
|
+
readonly credential_binding_id: string;
|
|
115
|
+
readonly broker_ref: string;
|
|
116
|
+
}
|
|
117
|
+
export type OnlineGenerationCheckReceiptDraft = OnlineGenerationReceiptBaseDraft & OnlineGenerationReceiptDecision & (NativeOnlineGenerationReceiptTarget | BrokeredOnlineGenerationReceiptTarget);
|
|
118
|
+
type OnlineGenerationCheckReceipt = OnlineGenerationCheckReceiptDraft & {
|
|
119
|
+
readonly signature: string;
|
|
120
|
+
};
|
|
121
|
+
declare const verifiedReceiptBrand: unique symbol;
|
|
122
|
+
declare const allowedReceiptBrand: unique symbol;
|
|
123
|
+
declare const projectedReceiptBrand: unique symbol;
|
|
124
|
+
declare const consumedReceiptUseBrand: unique symbol;
|
|
125
|
+
declare const verifiedConsumeReceiptBrand: unique symbol;
|
|
126
|
+
export type VerifiedOnlineGenerationCheckReceipt = OnlineGenerationCheckReceipt & {
|
|
127
|
+
readonly [verifiedReceiptBrand]: true;
|
|
128
|
+
};
|
|
129
|
+
export type VerifiedAllowedOnlineGenerationCheckReceipt = VerifiedOnlineGenerationCheckReceipt & {
|
|
130
|
+
readonly allowed: true;
|
|
131
|
+
readonly [allowedReceiptBrand]: true;
|
|
132
|
+
};
|
|
133
|
+
export interface OnlineGenerationCheckReceiptTrustRoot {
|
|
134
|
+
readonly schemaDigest: string;
|
|
135
|
+
readonly issuer: string;
|
|
136
|
+
readonly issuerIncarnation: string;
|
|
137
|
+
readonly keyId: string;
|
|
138
|
+
readonly audience: string;
|
|
139
|
+
readonly publicKey: KeyObject;
|
|
140
|
+
readonly revoked: boolean;
|
|
141
|
+
}
|
|
142
|
+
export type OnlineGenerationDecisionExpectation = {
|
|
143
|
+
readonly allowed: true;
|
|
144
|
+
readonly denyState: "allowed";
|
|
145
|
+
readonly reasonCodes: readonly [];
|
|
146
|
+
readonly currentDeny?: never;
|
|
147
|
+
} | {
|
|
148
|
+
readonly allowed: false;
|
|
149
|
+
readonly denyState: "allowed";
|
|
150
|
+
readonly reasonCodes: readonly string[];
|
|
151
|
+
readonly currentDeny?: never;
|
|
152
|
+
} | {
|
|
153
|
+
readonly allowed: false;
|
|
154
|
+
readonly denyState: "denied";
|
|
155
|
+
readonly reasonCodes: readonly string[];
|
|
156
|
+
readonly currentDeny: true;
|
|
157
|
+
};
|
|
158
|
+
export type OnlineGenerationTargetExpectation = {
|
|
159
|
+
readonly kind: "native";
|
|
160
|
+
readonly authCapsuleId: string;
|
|
161
|
+
readonly canonicalNodeId: string;
|
|
162
|
+
readonly nodeKeyThumbprint: string;
|
|
163
|
+
readonly nodeGeneration: Counter;
|
|
164
|
+
readonly placementGeneration: Counter;
|
|
165
|
+
readonly authGeneration: Counter;
|
|
166
|
+
readonly authStateRevision: Counter;
|
|
167
|
+
} | {
|
|
168
|
+
readonly kind: "brokered";
|
|
169
|
+
readonly credentialBindingId: string;
|
|
170
|
+
readonly brokerRef: string;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* The caller supplies the coherent live Infinity/Accounts tuple it is about to
|
|
174
|
+
* use. Verification compares every security-significant receipt member to this
|
|
175
|
+
* tuple; there is no partial/four-epoch verification mode.
|
|
176
|
+
*/
|
|
177
|
+
export interface OnlineGenerationCheckReceiptExpectation {
|
|
178
|
+
readonly now: Date;
|
|
179
|
+
readonly maximumAgeMs: number;
|
|
180
|
+
readonly maximumLifetimeMs: number;
|
|
181
|
+
readonly allowedClockSkewMs?: number;
|
|
182
|
+
/** Independently derived from the authenticated transport, never the receipt. */
|
|
183
|
+
readonly authenticatedActorPrincipal: string;
|
|
184
|
+
readonly receipt: {
|
|
185
|
+
readonly receiptId: string;
|
|
186
|
+
readonly nonce: string;
|
|
187
|
+
readonly issuedAt: string;
|
|
188
|
+
readonly notBefore: string;
|
|
189
|
+
readonly expiresAt: string;
|
|
190
|
+
};
|
|
191
|
+
readonly capability: {
|
|
192
|
+
readonly capabilityId: string;
|
|
193
|
+
readonly capabilityDigest: string;
|
|
194
|
+
};
|
|
195
|
+
readonly route: {
|
|
196
|
+
readonly authorityEpoch: Counter;
|
|
197
|
+
readonly routeLineageId: string;
|
|
198
|
+
readonly routeId: string;
|
|
199
|
+
readonly routeEpoch: Counter;
|
|
200
|
+
};
|
|
201
|
+
readonly attempt: {
|
|
202
|
+
readonly runId: string;
|
|
203
|
+
readonly attemptId: string;
|
|
204
|
+
readonly attemptLeaseId: string;
|
|
205
|
+
readonly leaseEpoch: Counter;
|
|
206
|
+
};
|
|
207
|
+
readonly resourceLease: {
|
|
208
|
+
readonly resourceLeaseId: string;
|
|
209
|
+
readonly resourceId: string;
|
|
210
|
+
readonly resourceLifecycleGeneration: Counter;
|
|
211
|
+
readonly leaseExpiresAt: string;
|
|
212
|
+
};
|
|
213
|
+
readonly operation: {
|
|
214
|
+
readonly operationId: string;
|
|
215
|
+
readonly operationDigest: string;
|
|
216
|
+
readonly operationExecutionEpoch: Counter;
|
|
217
|
+
readonly operationExecutionExpiresAt: string;
|
|
218
|
+
};
|
|
219
|
+
readonly principals: {
|
|
220
|
+
readonly subject: string;
|
|
221
|
+
readonly actorPrincipal: string;
|
|
222
|
+
readonly leaseHolderPrincipal: string;
|
|
223
|
+
readonly operationExecutorPrincipal: string;
|
|
224
|
+
readonly senderKeyThumbprint: string;
|
|
225
|
+
};
|
|
226
|
+
readonly account: {
|
|
227
|
+
readonly providerAccountId: string;
|
|
228
|
+
readonly accountLaneId: string;
|
|
229
|
+
readonly capacityPoolId: string;
|
|
230
|
+
readonly capacityDomainRef: string;
|
|
231
|
+
readonly accessTransport: OnlineGenerationAccessTransport;
|
|
232
|
+
readonly credentialFamilyId: string;
|
|
233
|
+
readonly allowedChannelClass: OnlineGenerationAllowedChannelClass;
|
|
234
|
+
};
|
|
235
|
+
readonly decision: OnlineGenerationDecisionExpectation;
|
|
236
|
+
readonly generations: {
|
|
237
|
+
readonly capacityGeneration: Counter;
|
|
238
|
+
readonly denyGeneration: Counter;
|
|
239
|
+
readonly credentialGeneration: Counter;
|
|
240
|
+
readonly accountsRevisionSetDigest: string;
|
|
241
|
+
};
|
|
242
|
+
readonly authorization: {
|
|
243
|
+
readonly slotEligibilityDigest: string;
|
|
244
|
+
readonly approvalRef: string;
|
|
245
|
+
readonly policyDigest: string;
|
|
246
|
+
readonly canonicalRequestDigest: string;
|
|
247
|
+
readonly senderConstraintConfirmation: string;
|
|
248
|
+
readonly maxUses: Counter;
|
|
249
|
+
readonly useCount: Counter;
|
|
250
|
+
};
|
|
251
|
+
readonly destination: {
|
|
252
|
+
readonly policy: ProviderDestinationPolicy;
|
|
253
|
+
readonly policyDigest: string;
|
|
254
|
+
};
|
|
255
|
+
readonly recovery: {
|
|
256
|
+
readonly catalogIncarnation: string;
|
|
257
|
+
readonly recoveryFrontierSequence: Counter;
|
|
258
|
+
readonly recoveryFrontierHash: string;
|
|
259
|
+
};
|
|
260
|
+
readonly target: OnlineGenerationTargetExpectation;
|
|
261
|
+
}
|
|
262
|
+
export interface ProviderDestinationPolicySdk {
|
|
263
|
+
readonly scheme: "https";
|
|
264
|
+
readonly normalizedHost: string;
|
|
265
|
+
readonly port: string;
|
|
266
|
+
readonly operationPath: string;
|
|
267
|
+
readonly model: string;
|
|
268
|
+
readonly requestBodyDigest: string;
|
|
269
|
+
readonly tlsServerName: string;
|
|
270
|
+
readonly resolvedAddressClass: string;
|
|
271
|
+
readonly egressPolicyDigest: string;
|
|
272
|
+
}
|
|
273
|
+
export type OnlineGenerationReceiptTargetSdk = {
|
|
274
|
+
readonly kind: "native";
|
|
275
|
+
readonly authCapsuleId: string;
|
|
276
|
+
readonly canonicalNodeId: string;
|
|
277
|
+
readonly nodeKeyThumbprint: string;
|
|
278
|
+
readonly nodeGeneration: Counter;
|
|
279
|
+
readonly placementGeneration: Counter;
|
|
280
|
+
readonly authGeneration: Counter;
|
|
281
|
+
readonly authStateRevision: Counter;
|
|
282
|
+
} | {
|
|
283
|
+
readonly kind: "brokered";
|
|
284
|
+
readonly credentialBindingId: string;
|
|
285
|
+
readonly brokerRef: string;
|
|
286
|
+
};
|
|
287
|
+
interface OnlineGenerationCheckReceiptSdk {
|
|
288
|
+
readonly schemaVersion: typeof ONLINE_GENERATION_CHECK_RECEIPT_SCHEMA_VERSION;
|
|
289
|
+
readonly schemaDigest: string;
|
|
290
|
+
readonly receiptId: string;
|
|
291
|
+
readonly issuer: string;
|
|
292
|
+
readonly issuerIncarnation: string;
|
|
293
|
+
readonly keyId: string;
|
|
294
|
+
readonly audience: string;
|
|
295
|
+
readonly nonce: string;
|
|
296
|
+
readonly issuedAt: string;
|
|
297
|
+
readonly notBefore: string;
|
|
298
|
+
readonly expiresAt: string;
|
|
299
|
+
readonly signature: string;
|
|
300
|
+
readonly capabilityId: string;
|
|
301
|
+
readonly capabilityDigest: string;
|
|
302
|
+
readonly authorityEpoch: Counter;
|
|
303
|
+
readonly routeLineageId: string;
|
|
304
|
+
readonly routeId: string;
|
|
305
|
+
readonly routeEpoch: Counter;
|
|
306
|
+
readonly runId: string;
|
|
307
|
+
readonly attemptId: string;
|
|
308
|
+
readonly attemptLeaseId: string;
|
|
309
|
+
readonly leaseEpoch: Counter;
|
|
310
|
+
readonly resourceLeaseId: string;
|
|
311
|
+
readonly resourceId: string;
|
|
312
|
+
readonly resourceLifecycleGeneration: Counter;
|
|
313
|
+
readonly leaseExpiresAt: string;
|
|
314
|
+
readonly operationId: string;
|
|
315
|
+
readonly operationDigest: string;
|
|
316
|
+
readonly operationExecutionEpoch: Counter;
|
|
317
|
+
readonly operationExecutionExpiresAt: string;
|
|
318
|
+
readonly subject: string;
|
|
319
|
+
readonly actorPrincipal: string;
|
|
320
|
+
readonly leaseHolderPrincipal: string;
|
|
321
|
+
readonly operationExecutorPrincipal: string;
|
|
322
|
+
readonly senderKeyThumbprint: string;
|
|
323
|
+
readonly providerAccountId: string;
|
|
324
|
+
readonly accountLaneId: string;
|
|
325
|
+
readonly capacityPoolId: string;
|
|
326
|
+
readonly capacityDomainRef: string;
|
|
327
|
+
readonly accessTransport: OnlineGenerationAccessTransport;
|
|
328
|
+
readonly credentialFamilyId: string;
|
|
329
|
+
readonly allowed: boolean;
|
|
330
|
+
readonly denyState: "allowed" | "denied";
|
|
331
|
+
readonly reasonCodes: readonly string[];
|
|
332
|
+
readonly currentDeny?: true;
|
|
333
|
+
readonly capacityGeneration: Counter;
|
|
334
|
+
readonly denyGeneration: Counter;
|
|
335
|
+
readonly credentialGeneration: Counter;
|
|
336
|
+
readonly accountsRevisionSetDigest: string;
|
|
337
|
+
readonly allowedChannelClass: OnlineGenerationAllowedChannelClass;
|
|
338
|
+
readonly slotEligibilityDigest: string;
|
|
339
|
+
readonly approvalRef: string;
|
|
340
|
+
readonly policyDigest: string;
|
|
341
|
+
readonly canonicalRequestDigest: string;
|
|
342
|
+
readonly providerDestinationPolicy: ProviderDestinationPolicySdk;
|
|
343
|
+
readonly providerDestinationPolicyDigest: string;
|
|
344
|
+
readonly senderConstraintConfirmation: string;
|
|
345
|
+
readonly maxUses: Counter;
|
|
346
|
+
readonly useCount: Counter;
|
|
347
|
+
readonly catalogIncarnation: string;
|
|
348
|
+
readonly recoveryFrontierSequence: Counter;
|
|
349
|
+
readonly recoveryFrontierHash: string;
|
|
350
|
+
readonly target: OnlineGenerationReceiptTargetSdk;
|
|
351
|
+
}
|
|
352
|
+
export type ProjectedOnlineGenerationCheckReceipt = OnlineGenerationCheckReceiptSdk & {
|
|
353
|
+
readonly [projectedReceiptBrand]: true;
|
|
354
|
+
};
|
|
355
|
+
export interface OnlineGenerationReceiptUseCasRequest {
|
|
356
|
+
readonly schema_version: typeof CAPABILITY_USE_CONSUME_REQUEST_SCHEMA_VERSION;
|
|
357
|
+
readonly schema_digest: typeof CAPABILITY_USE_CONSUME_REQUEST_SCHEMA_DIGEST;
|
|
358
|
+
readonly consume_request_id: string;
|
|
359
|
+
readonly capability_id: string;
|
|
360
|
+
readonly capability_digest: string;
|
|
361
|
+
readonly nonce: string;
|
|
362
|
+
readonly subject: string;
|
|
363
|
+
readonly actor_principal: string;
|
|
364
|
+
readonly account_lane_id: string;
|
|
365
|
+
readonly capacity_pool_id: string;
|
|
366
|
+
readonly capacity_domain_ref: string;
|
|
367
|
+
readonly credential_family_id: string;
|
|
368
|
+
readonly resource_lease_id: string;
|
|
369
|
+
readonly resource_id: string;
|
|
370
|
+
readonly resource_lifecycle_generation: Counter;
|
|
371
|
+
readonly operation_id: string;
|
|
372
|
+
readonly operation_digest: string;
|
|
373
|
+
readonly operation_execution_epoch: Counter;
|
|
374
|
+
readonly sender_key_thumbprint: string;
|
|
375
|
+
readonly channel_binding_digest: string;
|
|
376
|
+
readonly canonical_request_digest: string;
|
|
377
|
+
readonly provider_destination_policy_digest: string;
|
|
378
|
+
readonly online_receipt_id: string;
|
|
379
|
+
readonly online_receipt_digest: string;
|
|
380
|
+
readonly model_call_anchor_digest: string;
|
|
381
|
+
readonly expected_use_count: Counter;
|
|
382
|
+
readonly max_uses: Counter;
|
|
383
|
+
/** Earliest online-receipt, resource-lease, or operation-execution expiry. */
|
|
384
|
+
readonly not_after: string;
|
|
385
|
+
readonly idempotency_key_digest: string;
|
|
386
|
+
}
|
|
387
|
+
export type OnlineGenerationReceiptUseCasResult = {
|
|
388
|
+
readonly status: "consumed" | "replayed";
|
|
389
|
+
/** Canonical UTF-8 bytes of the exact signed consume receipt. */
|
|
390
|
+
readonly signedReceipt: Uint8Array;
|
|
391
|
+
} | {
|
|
392
|
+
readonly status: "idempotency_conflict" | "conflict" | "exhausted";
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Accounts-owned durable adapter. compareAndConsume MUST verify the coherent
|
|
396
|
+
* current Accounts tuple and atomically insert the one-use tombstone before it
|
|
397
|
+
* returns a signed receipt. The tombstone and idempotency record MUST survive
|
|
398
|
+
* database restore. An exact request replay returns the original receipt bytes;
|
|
399
|
+
* changed bytes under the same consume_request_id return idempotency_conflict.
|
|
400
|
+
* A restorable in-memory/request-local set is insufficient.
|
|
401
|
+
*/
|
|
402
|
+
export interface OnlineGenerationReceiptUseStore {
|
|
403
|
+
compareAndConsume(request: OnlineGenerationReceiptUseCasRequest): OnlineGenerationReceiptUseCasResult | Promise<OnlineGenerationReceiptUseCasResult>;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Effect-bound refresh hooks. The clock must be trusted process/deployment
|
|
407
|
+
* time, and refreshExpectation must directly re-read the coherent current
|
|
408
|
+
* Accounts deny/generation tuple; it must not return cached success.
|
|
409
|
+
*/
|
|
410
|
+
export interface OnlineGenerationReceiptUseGuard {
|
|
411
|
+
readonly clock: () => Date;
|
|
412
|
+
/** Independently derived from the authenticated sender channel. */
|
|
413
|
+
readonly authenticatedChannelBindingDigest: string;
|
|
414
|
+
readonly consumeRequestId: string;
|
|
415
|
+
/** Digest of the already durable PREPARED model-call anchor. */
|
|
416
|
+
readonly modelCallAnchorDigest: string;
|
|
417
|
+
readonly idempotencyKeyDigest: string;
|
|
418
|
+
readonly refreshExpectation: (receipt: VerifiedAllowedOnlineGenerationCheckReceipt, checkedAt: Date) => OnlineGenerationCheckReceiptExpectation | Promise<OnlineGenerationCheckReceiptExpectation>;
|
|
419
|
+
}
|
|
420
|
+
interface CapabilityUseConsumeReceipt {
|
|
421
|
+
readonly schema_version: typeof CAPABILITY_USE_CONSUME_RECEIPT_SCHEMA_VERSION;
|
|
422
|
+
readonly schema_digest: typeof CAPABILITY_USE_CONSUME_RECEIPT_SCHEMA_DIGEST;
|
|
423
|
+
readonly consume_request_id: string;
|
|
424
|
+
readonly consume_receipt_id: string;
|
|
425
|
+
readonly issuer: string;
|
|
426
|
+
readonly issuer_incarnation: string;
|
|
427
|
+
readonly key_id: string;
|
|
428
|
+
readonly audience: string;
|
|
429
|
+
readonly capability_id: string;
|
|
430
|
+
readonly capability_digest: string;
|
|
431
|
+
readonly nonce: string;
|
|
432
|
+
readonly subject: string;
|
|
433
|
+
readonly actor_principal: string;
|
|
434
|
+
readonly account_lane_id: string;
|
|
435
|
+
readonly capacity_pool_id: string;
|
|
436
|
+
readonly resource_lease_id: string;
|
|
437
|
+
readonly operation_id: string;
|
|
438
|
+
readonly operation_execution_epoch: Counter;
|
|
439
|
+
readonly sender_key_thumbprint: string;
|
|
440
|
+
readonly channel_binding_digest: string;
|
|
441
|
+
readonly canonical_request_digest: string;
|
|
442
|
+
readonly online_receipt_digest: string;
|
|
443
|
+
readonly model_call_anchor_digest: string;
|
|
444
|
+
readonly max_uses: Counter;
|
|
445
|
+
readonly prior_use_count: Counter;
|
|
446
|
+
readonly next_use_count: Counter;
|
|
447
|
+
readonly use_ordinal: Counter;
|
|
448
|
+
readonly use_id: string;
|
|
449
|
+
readonly committed_at: string;
|
|
450
|
+
readonly expires_at: string;
|
|
451
|
+
readonly catalog_incarnation: string;
|
|
452
|
+
readonly recovery_frontier_sequence: Counter;
|
|
453
|
+
readonly recovery_frontier_hash: string;
|
|
454
|
+
readonly signature: string;
|
|
455
|
+
}
|
|
456
|
+
export type VerifiedCapabilityUseConsumeReceipt = CapabilityUseConsumeReceipt & {
|
|
457
|
+
readonly [verifiedConsumeReceiptBrand]: true;
|
|
458
|
+
};
|
|
459
|
+
export interface ConsumedOnlineGenerationReceiptUse {
|
|
460
|
+
readonly receipt: VerifiedAllowedOnlineGenerationCheckReceipt;
|
|
461
|
+
readonly use: {
|
|
462
|
+
readonly request: OnlineGenerationReceiptUseCasRequest;
|
|
463
|
+
readonly consumeReceipt: VerifiedCapabilityUseConsumeReceipt;
|
|
464
|
+
readonly consumeReceiptDigest: string;
|
|
465
|
+
readonly useId: string;
|
|
466
|
+
readonly priorUseCount: Counter;
|
|
467
|
+
readonly nextUseCount: Counter;
|
|
468
|
+
readonly useOrdinal: Counter;
|
|
469
|
+
readonly committedAt: string;
|
|
470
|
+
readonly expiresAt: string;
|
|
471
|
+
readonly replayed: boolean;
|
|
472
|
+
};
|
|
473
|
+
readonly [consumedReceiptUseBrand]: true;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Parses canonical UTF-8/JCS bytes, validates the closed variant, verifies its
|
|
477
|
+
* Ed25519 signature and configured Accounts trust root, checks freshness using
|
|
478
|
+
* only the caller's trusted clock, and binds the complete live tuple.
|
|
479
|
+
*/
|
|
480
|
+
export declare function verifyOnlineGenerationCheckReceipt(source: Uint8Array, trust: OnlineGenerationCheckReceiptTrustRoot, expectation: OnlineGenerationCheckReceiptExpectation): VerifiedOnlineGenerationCheckReceipt;
|
|
481
|
+
/**
|
|
482
|
+
* Pure cryptographic/decision verification. It never returns negative evidence
|
|
483
|
+
* as allowed evidence, but it deliberately does not consume the nonce. Before
|
|
484
|
+
* any effect, call consumeOnlineGenerationCheckReceiptUse with the Accounts
|
|
485
|
+
* durable CAS store and compose that result with the execution-ledger protocol.
|
|
486
|
+
*/
|
|
487
|
+
export declare function verifyAllowedOnlineGenerationCheckReceipt(source: Uint8Array, trust: OnlineGenerationCheckReceiptTrustRoot, expectation: OnlineGenerationCheckReceiptExpectation): VerifiedAllowedOnlineGenerationCheckReceipt;
|
|
488
|
+
/**
|
|
489
|
+
* Atomically consumes the sole V1 use through the Accounts-owned durable CAS.
|
|
490
|
+
* Exact idempotent replay returns the original signed receipt; changed replay,
|
|
491
|
+
* exhaustion, adapter errors, and malformed or forged receipts fail closed
|
|
492
|
+
* before an external DISPATCHED anchor or provider effect can begin.
|
|
493
|
+
*/
|
|
494
|
+
export declare function consumeOnlineGenerationCheckReceiptUse(source: Uint8Array, trust: OnlineGenerationCheckReceiptTrustRoot, expectation: OnlineGenerationCheckReceiptExpectation, store: OnlineGenerationReceiptUseStore, guard: OnlineGenerationReceiptUseGuard): Promise<ConsumedOnlineGenerationReceiptUse>;
|
|
495
|
+
/** Explicit snake_case wire to camelCase SDK projection, after verification. */
|
|
496
|
+
export declare function projectOnlineGenerationCheckReceipt(receipt: VerifiedOnlineGenerationCheckReceipt): ProjectedOnlineGenerationCheckReceipt;
|
|
497
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AccessMethod, AnyEntity, AuthCapsule, CapacityPool, CredentialBinding, EntityKind, EntityMap } from "./models";
|
|
2
|
+
type EntityStatus<K extends EntityKind> = EntityMap[K]["status"];
|
|
3
|
+
export declare function assertTransition<K extends EntityKind>(kind: K, from: EntityStatus<K>, to: EntityStatus<K>): void;
|
|
4
|
+
export declare function transitionEntity<K extends EntityKind>(kind: K, entity: EntityMap[K], to: EntityStatus<K>, now: string): EntityMap[K];
|
|
5
|
+
export declare function assertBindingMayRetire(binding: CredentialBinding, method: AccessMethod, pool: CapacityPool): void;
|
|
6
|
+
/** Validates a proposed metadata update only. It does not prove zero live leases or authorize I/O. */
|
|
7
|
+
export declare function validateRoutineNativeRefreshCandidate(method: AccessMethod, pool: CapacityPool, beforeCapsule: AuthCapsule, afterCapsule: AuthCapsule, beforeBinding: Extract<CredentialBinding, {
|
|
8
|
+
readonly status: "pending" | "active" | "retiring";
|
|
9
|
+
}>, afterBinding: Extract<CredentialBinding, {
|
|
10
|
+
readonly status: "pending" | "active" | "retiring";
|
|
11
|
+
}>): void;
|
|
12
|
+
/** Validates a proposed metadata lineage only. Native execution remains unavailable in this slice. */
|
|
13
|
+
export declare function validateNativeReauthenticationCandidate(method: AccessMethod, pool: CapacityPool, beforeCapsule: AuthCapsule, afterCapsule: AuthCapsule, retiringBinding: Extract<CredentialBinding, {
|
|
14
|
+
readonly status: "pending" | "active" | "retiring";
|
|
15
|
+
}>, replacementBinding: Extract<CredentialBinding, {
|
|
16
|
+
readonly status: "pending" | "active" | "retiring";
|
|
17
|
+
}>): void;
|
|
18
|
+
export declare function entityStatus(entity: AnyEntity): string;
|
|
19
|
+
export {};
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const ACCOUNT_ERROR_CODES: readonly ["VALIDATION_FAILED", "NOT_FOUND", "FORBIDDEN", "IDEMPOTENCY_CONFLICT", "CONFLICT", "STALE_REVISION", "INVALID_TRANSITION", "TERMS_NOT_ALLOWED", "POLICY_DENIED", "CAPSULE_NOT_READY", "STALE_ATTESTATION", "STALE_CREDENTIAL_GENERATION", "STALE_AUTH_STATE_REVISION", "CAPACITY_DOMAIN_CONFLICT", "CURRENT_DENY", "INVALID_ACCESS_TARGET", "DEPENDENCY_UNAVAILABLE", "RECOVERY_HOLD", "COUNTER_EXHAUSTED", "SCHEMA_VERSION_UNSUPPORTED", "SCHEMA_CHECKSUM_MISMATCH", "DATABASE_PATH_UNSAFE", "NOT_IMPLEMENTED"];
|
|
2
|
+
export type AccountErrorCode = (typeof ACCOUNT_ERROR_CODES)[number];
|
|
3
|
+
export type SafeErrorDetail = string | boolean | readonly string[];
|
|
4
|
+
export type SafeErrorDetails = Readonly<Record<string, SafeErrorDetail>>;
|
|
5
|
+
export declare class AccountsError extends Error {
|
|
6
|
+
readonly code: AccountErrorCode;
|
|
7
|
+
readonly retryable: boolean;
|
|
8
|
+
readonly details: SafeErrorDetails;
|
|
9
|
+
constructor(code: AccountErrorCode, message: string, options?: {
|
|
10
|
+
retryable?: boolean;
|
|
11
|
+
details?: SafeErrorDetails;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export interface ErrorEnvelope {
|
|
15
|
+
readonly schemaVersion: "accounts.error.v1";
|
|
16
|
+
readonly error: {
|
|
17
|
+
readonly code: AccountErrorCode;
|
|
18
|
+
readonly message: string;
|
|
19
|
+
readonly requestId: string;
|
|
20
|
+
readonly retryable: boolean;
|
|
21
|
+
readonly details: SafeErrorDetails;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare function asAccountsError(error: unknown): AccountsError;
|
|
25
|
+
export declare function toErrorEnvelope(error: unknown, requestId: string): ErrorEnvelope;
|
|
26
|
+
export declare function exitCodeForError(error: AccountsError): number;
|