@substrat-run/kernel 0.8.0 → 0.10.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/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/permission-checker.d.ts +9 -2
- package/dist/permission-checker.d.ts.map +1 -1
- package/dist/permission-checker.js +2 -0
- package/dist/permission-checker.js.map +1 -1
- package/dist/scope-host.d.ts +262 -2
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js +25 -1
- package/dist/scope-host.js.map +1 -1
- package/dist/secret-box.d.ts +54 -0
- package/dist/secret-box.d.ts.map +1 -0
- package/dist/secret-box.js +84 -0
- package/dist/secret-box.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
export type { AccessLogFilter, AuditLogFilter, ConsumerHandler, ExecutorHandler, GuardPredicate, HostAdmin, ModuleRegistration, OperationContext, OperationHandler, ProvisionScopeInput, RoleFilter, ScopedSql, ScopeFilter, ScopeHost, ScopeStub, SqlMigration, SqlValue, } from './scope-host.js';
|
|
1
|
+
export type { AccessLogFilter, AuditLogFilter, ConsumerHandler, ExecutorDeadLetter, ExecutorDrainReport, ExecutorHandler, ExecutorRetryPolicy, ConnectorConnection, ConnectorContext, ConnectorHandler, ConnectorOptions, ConnectorRequestInit, ConnectorResponse, FetchLike, GuardPredicate, HostAdmin, ModuleRegistration, OperationContext, OperationHandler, ProvisionScopeInput, RoleFilter, ScopedSql, ScopeFilter, ScopeHost, ScopeStub, SqlMigration, SqlValue, } from './scope-host.js';
|
|
2
|
+
export { backoffAt, resolveRetryPolicy } from './scope-host.js';
|
|
3
|
+
export { unconfiguredSecretBox, webCryptoSecretBox } from './secret-box.js';
|
|
4
|
+
export type { SealedSecret, SecretBox } from './secret-box.js';
|
|
2
5
|
export { resolveScopeRecord } from './scope-record.js';
|
|
3
6
|
export type { ResolvedScopeRecord } from './scope-record.js';
|
|
4
7
|
export { assertAllowed, denyAllChecker, PermissionDenied, UNSAFE_allowAllChecker, } from './permission-checker.js';
|
|
8
|
+
export { asPrincipal } from './permission-checker.js';
|
|
5
9
|
export type { PermissionChecker } from './permission-checker.js';
|
|
6
10
|
export { ulid } from './ulid.js';
|
|
7
11
|
export { readRoutedNode, RouterAssertionError } from './routed-node.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC5E,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export { backoffAt, resolveRetryPolicy } from './scope-host.js';
|
|
2
|
+
export { unconfiguredSecretBox, webCryptoSecretBox } from './secret-box.js';
|
|
1
3
|
export { resolveScopeRecord } from './scope-record.js';
|
|
2
4
|
export { assertAllowed, denyAllChecker, PermissionDenied, UNSAFE_allowAllChecker, } from './permission-checker.js';
|
|
5
|
+
export { asPrincipal } from './permission-checker.js';
|
|
3
6
|
export { ulid } from './ulid.js';
|
|
4
7
|
export { readRoutedNode, RouterAssertionError } from './routed-node.js';
|
|
5
8
|
export { assertPlatformCall, PlatformCallError, PLATFORM_SECRET_HEADER, } from './platform-call.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Decision, type EntityRef, type Node, type PermissionKey, type PrincipalId } from '@substrat-run/contracts';
|
|
1
|
+
import { type Decision, type EntityRef, type Node, type PermissionKey, type CheckSubject, type PrincipalId } from '@substrat-run/contracts';
|
|
2
2
|
/**
|
|
3
3
|
* The evaluation seam (D-16): the MODEL is kernel-owned, the evaluation engine
|
|
4
4
|
* is an adapter — the built-in default is a constrained relationship-tuple
|
|
@@ -10,8 +10,15 @@ import { type Decision, type EntityRef, type Node, type PermissionKey, type Prin
|
|
|
10
10
|
* against entity-narrowed grants (§4.2 rule 3).
|
|
11
11
|
*/
|
|
12
12
|
export interface PermissionChecker {
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* `subject` rather than `principal` since #97: a connection can hold a grant,
|
|
15
|
+
* and must not be laundered through a principal to do it. Every existing
|
|
16
|
+
* caller passes `{ kind: 'principal', id }` and behaves exactly as before.
|
|
17
|
+
*/
|
|
18
|
+
check(subject: CheckSubject, permission: PermissionKey, node: Node, entity?: EntityRef): Promise<Decision>;
|
|
14
19
|
}
|
|
20
|
+
/** Convenience for the overwhelmingly common case. */
|
|
21
|
+
export declare const asPrincipal: (id: PrincipalId) => CheckSubject;
|
|
15
22
|
export declare class PermissionDenied extends Error {
|
|
16
23
|
constructor(message: string);
|
|
17
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-checker.d.ts","sourceRoot":"","sources":["../src/permission-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CACH,
|
|
1
|
+
{"version":3,"file":"permission-checker.d.ts","sourceRoot":"","sources":["../src/permission-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,KAAK,CACH,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,aAAa,EACzB,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,SAAS,GACjB,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtB;AAED,sDAAsD;AACtD,eAAO,MAAM,WAAW,GAAI,IAAI,WAAW,KAAG,YAA2C,CAAC;AAE1F,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAC5E,QAAQ,EACR;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAClB,CAIA;AAED,4FAA4F;AAC5F,eAAO,MAAM,cAAc,EAAE,iBAM5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,iBAapC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-checker.js","sourceRoot":"","sources":["../src/permission-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"permission-checker.js","sourceRoot":"","sources":["../src/permission-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAOV,MAAM,yBAAyB,CAAC;AA0BjC,sDAAsD;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAe,EAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1F,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,sFAAsF;AACtF,MAAM,UAAU,aAAa,CAAC,QAAkB;IAI9C,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,gBAAgB,CAAC,sBAAsB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9C,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,UAAU;QACnB,IAAI;KACL,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC7C,OAAO,EAAE,IAAI;QACb,KAAK,EAAE;YACL;gBACE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,aAAa,SAAS,EAAE,CAAC;gBAClD,QAAQ,EAAE,WAAW,UAAU,EAAE;gBACjC,MAAM,EAAE,SAAS,CAAC,KAAK,CACrB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,QAAQ,EAAE,CACnE;aACF;SACF;KACF,CAAC;CACH,CAAC"}
|
package/dist/scope-host.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminAction, AccessLogEntry, BindHostnameInput, AdminLogEntry, CapabilityGrant, CreateTenantInput, Decision, DomainEvent, DomainEventInput, EntityRef, IdentityLink, IdentityPool, Jurisdiction, ModuleManifest, CreateOrgInput, Node, Org, OrgId, OrgMembership, PermissionKey, PlatformActorId, ChannelName, HostnameBinding, HostnameStatus, PromotionAcknowledgement, PublishVersionInput, RegisterVerticalInput, RouteTarget, PrincipalId, ResolvedIdentity, RoleAssignment, RoleDefinition, Scope, ScopeId, ScopeStatus, StorageShape, Tenant, TenantId, TenantRole, Vertical, VerticalChannel, VerticalVersion, TenantStatus } from '@substrat-run/contracts';
|
|
1
|
+
import type { AdminAction, Connection, ConnectionFilter, ConnectionId, ConnectionGrant, ConnectionSecret, CreateConnectionInput, OpenConnection, AccessLogEntry, BindHostnameInput, AdminLogEntry, CapabilityGrant, CreateTenantInput, Decision, DomainEvent, DomainEventInput, EntityRef, IdentityLink, IdentityPool, Jurisdiction, ModuleManifest, CreateOrgInput, Node, Org, OrgId, OrgMembership, PermissionKey, PlatformActorId, ChannelName, HostnameBinding, HostnameStatus, PromotionAcknowledgement, PublishVersionInput, RegisterVerticalInput, RouteTarget, PrincipalId, ResolvedIdentity, RoleAssignment, RoleDefinition, Scope, ScopeId, ScopeStatus, StorageShape, Tenant, TenantId, TenantRole, Vertical, VerticalChannel, VerticalVersion, TenantStatus } from '@substrat-run/contracts';
|
|
2
2
|
/**
|
|
3
3
|
* The scope-host contract — the adapter seam (§5.1 of the design doc).
|
|
4
4
|
*
|
|
@@ -86,6 +86,138 @@ export type ConsumerHandler = (ctx: OperationContext, event: DomainEvent) => voi
|
|
|
86
86
|
* the causing event's id (`causedBy`), so the split trail joins.
|
|
87
87
|
*/
|
|
88
88
|
export type ExecutorHandler = (admin: HostAdmin, event: DomainEvent) => void | Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* How hard the host tries before it gives up on one delivery (#100).
|
|
91
|
+
*
|
|
92
|
+
* Defaults suit a directory write. A connector making an outbound HTTP call
|
|
93
|
+
* wants a longer tail — that is the whole reason this is per-executor rather
|
|
94
|
+
* than a host-wide constant.
|
|
95
|
+
*/
|
|
96
|
+
export interface ExecutorRetryPolicy {
|
|
97
|
+
/** Total attempts including the first. Reaching it dead-letters. Default 5. */
|
|
98
|
+
maxAttempts?: number;
|
|
99
|
+
/** First backoff step; doubles per attempt. Default 1000ms. `0` retries at once. */
|
|
100
|
+
baseDelayMs?: number;
|
|
101
|
+
/** Ceiling on the doubling. Default 300_000ms (5 min). */
|
|
102
|
+
maxDelayMs?: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* What one drain pass did. `retrying` and `deadLettered` are the numbers a
|
|
106
|
+
* health surface reports; a caller that ignores them learns nothing, which is
|
|
107
|
+
* the failure mode the old silent path had.
|
|
108
|
+
*/
|
|
109
|
+
export interface ExecutorDrainReport {
|
|
110
|
+
attempted: number;
|
|
111
|
+
delivered: number;
|
|
112
|
+
/** Failed, still under `maxAttempts` — scheduled for a later pass. */
|
|
113
|
+
retrying: number;
|
|
114
|
+
/** Failed at `maxAttempts` — terminal, and the row keeps the last error. */
|
|
115
|
+
deadLettered: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The web-standard fetch surface, structurally typed.
|
|
119
|
+
*
|
|
120
|
+
* Declared rather than imported: the kernel depends on no platform typings, and
|
|
121
|
+
* `RequestInit`/`Response` come from DOM lib in Node and from workers-types in
|
|
122
|
+
* Workers. Structural typing means both satisfy this without either being
|
|
123
|
+
* required — the same reason `crypto` and `TextEncoder` are declared locally.
|
|
124
|
+
*/
|
|
125
|
+
export interface FetchLike {
|
|
126
|
+
(input: string, init?: ConnectorRequestInit): Promise<ConnectorResponse>;
|
|
127
|
+
}
|
|
128
|
+
export interface ConnectorRequestInit {
|
|
129
|
+
method?: string;
|
|
130
|
+
headers?: Record<string, string>;
|
|
131
|
+
/**
|
|
132
|
+
* `Uint8Array` as well as `string` because a real provider upload is binary:
|
|
133
|
+
* Scrive's `setfile` is `multipart/form-data`, whose body is a byte sequence a
|
|
134
|
+
* string cannot carry without corrupting the file. Web `fetch` accepts both, so
|
|
135
|
+
* this only widens the declared surface — the adapter passes it straight
|
|
136
|
+
* through.
|
|
137
|
+
*/
|
|
138
|
+
body?: string | Uint8Array;
|
|
139
|
+
signal?: unknown;
|
|
140
|
+
}
|
|
141
|
+
export interface ConnectorResponse {
|
|
142
|
+
readonly ok: boolean;
|
|
143
|
+
readonly status: number;
|
|
144
|
+
text(): Promise<string>;
|
|
145
|
+
json(): Promise<unknown>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A connection with its credential opened, plus egress bound to it.
|
|
149
|
+
*
|
|
150
|
+
* `fetch` is bound to the connection rather than sitting on the context because
|
|
151
|
+
* health has to land on the right row by construction. An ambient
|
|
152
|
+
* `ctx.fetch` would need the runtime to guess which connection a call belonged
|
|
153
|
+
* to, and it would guess wrong the first time a connector talked to two.
|
|
154
|
+
*/
|
|
155
|
+
export interface ConnectorConnection extends OpenConnection {
|
|
156
|
+
/**
|
|
157
|
+
* Sanctioned egress: a timeout, and success/failure recorded against THIS
|
|
158
|
+
* connection.
|
|
159
|
+
*
|
|
160
|
+
* The connector is handed its `fetch` rather than importing one — the same
|
|
161
|
+
* move `ctx.sql` makes for module code, and for the same reason. Egress
|
|
162
|
+
* policy, timeouts and health become properties of the seam instead of
|
|
163
|
+
* conventions a connector author has to remember. Module code still cannot
|
|
164
|
+
* reach any of this: boundary-lint R3 bans `fetch` outright, and a connector
|
|
165
|
+
* is host code.
|
|
166
|
+
*/
|
|
167
|
+
fetch(input: string, init?: ConnectorRequestInit): Promise<ConnectorResponse>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* What a connector sees. Strictly more than an executor: an executor effects
|
|
171
|
+
* something in the DIRECTORY, a connector effects something in the OUTSIDE
|
|
172
|
+
* WORLD, and only the second needs a per-tenant credential and egress.
|
|
173
|
+
*/
|
|
174
|
+
export interface ConnectorContext {
|
|
175
|
+
readonly admin: HostAdmin;
|
|
176
|
+
readonly tenantId: TenantId;
|
|
177
|
+
readonly scopeId: ScopeId;
|
|
178
|
+
/** The scope's vertical — half the key a connection is stored under. */
|
|
179
|
+
readonly vertical: string;
|
|
180
|
+
/**
|
|
181
|
+
* The live connection for this provider, opened.
|
|
182
|
+
*
|
|
183
|
+
* Resolved as (this event's tenant, this scope's vertical, provider), so a
|
|
184
|
+
* connector cannot reach a credential another vertical connected even by
|
|
185
|
+
* accident — the tenant and vertical are ambient, not arguments. Throws when
|
|
186
|
+
* there is none: a connector that runs without a credential would otherwise
|
|
187
|
+
* fail later, further from the cause.
|
|
188
|
+
*/
|
|
189
|
+
connection(provider: string): Promise<ConnectorConnection>;
|
|
190
|
+
}
|
|
191
|
+
export type ConnectorHandler = (ctx: ConnectorContext, event: DomainEvent) => void | Promise<void>;
|
|
192
|
+
/** Tuning for one connector's egress. */
|
|
193
|
+
export interface ConnectorOptions extends ExecutorRetryPolicy {
|
|
194
|
+
/** Per-request timeout. Default 30s. */
|
|
195
|
+
timeoutMs?: number;
|
|
196
|
+
}
|
|
197
|
+
/** A delivery that exhausted its attempts. The evidence, not a silent drop. */
|
|
198
|
+
export interface ExecutorDeadLetter {
|
|
199
|
+
eventId: string;
|
|
200
|
+
executorId: string;
|
|
201
|
+
eventType: string;
|
|
202
|
+
attempts: number;
|
|
203
|
+
error: string;
|
|
204
|
+
lastAttemptAt: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Retry defaults (#100). Tuned for the directory write the first executor does;
|
|
208
|
+
* a connector making an outbound call should raise `maxAttempts` explicitly,
|
|
209
|
+
* which is why the policy is per-executor rather than a host constant.
|
|
210
|
+
*/
|
|
211
|
+
export declare function resolveRetryPolicy(retry?: ExecutorRetryPolicy): Required<ExecutorRetryPolicy>;
|
|
212
|
+
/**
|
|
213
|
+
* When attempt `attempts` should next be tried: exponential, capped, jittered.
|
|
214
|
+
*
|
|
215
|
+
* Jitter is ±20% and is skipped entirely at zero delay, so a test setting
|
|
216
|
+
* `baseDelayMs: 0` gets deterministic immediate retries rather than a race. It
|
|
217
|
+
* matters at real delays because every scope in a fleet retries a downed
|
|
218
|
+
* provider on the same schedule otherwise.
|
|
219
|
+
*/
|
|
220
|
+
export declare function backoffAt(attempts: number, retry: Required<ExecutorRetryPolicy>, from: Date): string;
|
|
89
221
|
/**
|
|
90
222
|
* A named, manifest-wired pre-condition on an operation (K-17; engine-protocol
|
|
91
223
|
* §6, open question 11). One module CONTRIBUTES a predicate under a name; a
|
|
@@ -157,6 +289,17 @@ export interface HostAdmin {
|
|
|
157
289
|
assignRole(actor: PlatformActorId, assignment: RoleAssignment): Promise<void>;
|
|
158
290
|
grant(actor: PlatformActorId, grant: CapabilityGrant): Promise<void>;
|
|
159
291
|
/** Grant to an organization (portal customers); members reach it via membership tuples. */
|
|
292
|
+
/**
|
|
293
|
+
* Grant a permission to a CONNECTION (#97) — how a connector is allowed to
|
|
294
|
+
* write back into a scope.
|
|
295
|
+
*
|
|
296
|
+
* Deliberately the same shape as every other grant: tuples, tombstoned on
|
|
297
|
+
* revoke (K-21), visible to `listRoles`-style reads and to the permission
|
|
298
|
+
* diff. A separate "allowed operations" list on the connection was the
|
|
299
|
+
* alternative and was rejected — two mechanisms for one gate is worse than
|
|
300
|
+
* either, and only one of them would have shown up in a review.
|
|
301
|
+
*/
|
|
302
|
+
grantToConnection(actor: PlatformActorId, grant: ConnectionGrant): Promise<void>;
|
|
160
303
|
grantToOrg(actor: PlatformActorId, orgId: OrgId, permission: PermissionKey, node: Node, entity?: EntityRef): Promise<void>;
|
|
161
304
|
addMember(actor: PlatformActorId, tenantId: TenantId, principal: PrincipalId, orgId: OrgId): Promise<void>;
|
|
162
305
|
/**
|
|
@@ -294,6 +437,18 @@ export interface HostAdmin {
|
|
|
294
437
|
* grants no execution.
|
|
295
438
|
*/
|
|
296
439
|
getScopeRecord(actor: PlatformActorId, tenantId: TenantId, scopeId: ScopeId): Promise<Scope | undefined>;
|
|
440
|
+
/**
|
|
441
|
+
* provisioning → active. The vertical's confirmation that a scope exists (K-31).
|
|
442
|
+
*
|
|
443
|
+
* `provisionScope` writes the directory row as `provisioning`, and nothing may use
|
|
444
|
+
* it until this runs — `getScope` fails closed on any non-active scope, so a row
|
|
445
|
+
* whose vertical never provisioned is inert rather than misleading.
|
|
446
|
+
*
|
|
447
|
+
* Deliberately a separate call rather than a flag on `provisionScope`: the two
|
|
448
|
+
* happen against DIFFERENT systems, and the gap between them is a real state that
|
|
449
|
+
* something has to be able to observe and retry.
|
|
450
|
+
*/
|
|
451
|
+
activateScope(actor: PlatformActorId, tenantId: TenantId, scopeId: ScopeId): Promise<void>;
|
|
297
452
|
/** active → suspended. Reversible containment (incident, dispute). */
|
|
298
453
|
suspendScope(actor: PlatformActorId, tenantId: TenantId, scopeId: ScopeId): Promise<void>;
|
|
299
454
|
/** suspended → active. */
|
|
@@ -325,6 +480,54 @@ export interface HostAdmin {
|
|
|
325
480
|
* DIFFERENT principal **throws** — it means two subjects collided, and silently
|
|
326
481
|
* ignoring it would resolve the second person as the first.
|
|
327
482
|
*/
|
|
483
|
+
/**
|
|
484
|
+
* Store a tenant's authorization for one provider, held by one vertical.
|
|
485
|
+
*
|
|
486
|
+
* The credential is sealed by the host's `SecretBox` before it touches the
|
|
487
|
+
* directory, and the admin-log row carries **metadata only** — provider,
|
|
488
|
+
* label, scopes. That is structural, not careful: `_substrat_admin_log` is
|
|
489
|
+
* append-only, so a secret written into it could never be removed.
|
|
490
|
+
*
|
|
491
|
+
* Takes a `PlatformActorId` today. Connecting a provider is really a tenant
|
|
492
|
+
* admin's act, and routing it through a platform actor is the same defect
|
|
493
|
+
* D-31 named for `addMember` — so this is a deliberate deferral, recorded in
|
|
494
|
+
* connections.md §3.5, not an answer. No console flow should be built on this
|
|
495
|
+
* signature until the question is settled together with membership's.
|
|
496
|
+
*/
|
|
497
|
+
createConnection(actor: PlatformActorId, input: CreateConnectionInput): Promise<void>;
|
|
498
|
+
/** Metadata only — never the credential, at any privilege level. */
|
|
499
|
+
listConnections(actor: PlatformActorId, filter?: ConnectionFilter): Promise<Connection[]>;
|
|
500
|
+
/** Replace the sealed credential — the OAuth refresh path. */
|
|
501
|
+
updateConnectionSecret(actor: PlatformActorId, id: ConnectionId, secret: ConnectionSecret, expiresAt?: string): Promise<void>;
|
|
502
|
+
/**
|
|
503
|
+
* Withdraw a connection. Tombstones like K-21 rather than deleting: a
|
|
504
|
+
* credential that once had access is evidence of why an access was allowed.
|
|
505
|
+
* Terminal — a replacement is a new connection, which is why the uniqueness
|
|
506
|
+
* constraint ignores revoked rows.
|
|
507
|
+
*/
|
|
508
|
+
revokeConnection(actor: PlatformActorId, id: ConnectionId): Promise<void>;
|
|
509
|
+
/**
|
|
510
|
+
* Open the credential for one (tenant, vertical, provider) — the connector's
|
|
511
|
+
* read, and the only path in the system that yields plaintext.
|
|
512
|
+
*
|
|
513
|
+
* **Takes no actor and is not audited**, the same exemption `resolveHostname`
|
|
514
|
+
* and `resolveIdentity` hold and for the same reason: it is a machine read on
|
|
515
|
+
* the request path, and an audit row per outbound HTTP call would drown the
|
|
516
|
+
* log that matters. What *is* recorded is health — `recordConnectionUse` below
|
|
517
|
+
* — which is the signal an operator can actually act on.
|
|
518
|
+
*/
|
|
519
|
+
openConnection(tenantId: TenantId, vertical: string, provider: string): Promise<OpenConnection | undefined>;
|
|
520
|
+
/**
|
|
521
|
+
* Record that a connection worked, or did not (§3.7). Written by the connector
|
|
522
|
+
* runtime; read by a console. Not audited — it is telemetry about a machine
|
|
523
|
+
* read, not a control-plane mutation.
|
|
524
|
+
*/
|
|
525
|
+
recordConnectionUse(id: ConnectionId, outcome: {
|
|
526
|
+
ok: true;
|
|
527
|
+
} | {
|
|
528
|
+
ok: false;
|
|
529
|
+
error: string;
|
|
530
|
+
}): Promise<void>;
|
|
328
531
|
linkIdentity(actor: PlatformActorId, input: IdentityLink): Promise<void>;
|
|
329
532
|
/**
|
|
330
533
|
* Register an identity pool and its topology (K-23). A provider must be registered
|
|
@@ -486,8 +689,65 @@ export interface ScopeHost {
|
|
|
486
689
|
* is what makes it correct under crash — but the common case completes inside the
|
|
487
690
|
* originating request, so "requested but not yet effected" is a rare-case fallback
|
|
488
691
|
* rather than the normal experience.
|
|
692
|
+
*
|
|
693
|
+
* **A failing handler never fails the operation** (#100). The operation already
|
|
694
|
+
* committed; the delivery did not. Those are different facts, and reporting the
|
|
695
|
+
* second as the first told a caller their work had been rolled back when it had
|
|
696
|
+
* not. A failure is retried with backoff, dead-lettered at `maxAttempts`, and
|
|
697
|
+
* surfaced through `drainDue`/`executorDeadLetters` — never thrown at whoever happened
|
|
698
|
+
* to be holding the request.
|
|
699
|
+
*/
|
|
700
|
+
registerExecutor(id: string, eventType: string, handler: ExecutorHandler, retry?: ExecutorRetryPolicy): void;
|
|
701
|
+
/**
|
|
702
|
+
* A scope stub whose authority is a CONNECTION rather than a person (#97).
|
|
703
|
+
*
|
|
704
|
+
* This is the inbound half of the connector seam: the path by which a
|
|
705
|
+
* provider's callback, or a poll of a provider's state, writes back into a
|
|
706
|
+
* scope. `getScope` demands a `PrincipalId` and a provider is not one, which
|
|
707
|
+
* is why a connector could dispatch a document and then not record that it
|
|
708
|
+
* had — and why an at-least-once retry would send a second copy.
|
|
709
|
+
*
|
|
710
|
+
* **Authority is inherited, not re-declared.** A connection is keyed
|
|
711
|
+
* (tenant, vertical, provider), so this refuses any scope outside that
|
|
712
|
+
* tenant, and any scope not running that vertical. What the connection may
|
|
713
|
+
* then DO is an ordinary permission check against `connection:<id>` grants —
|
|
714
|
+
* one enforcement path, one place to read, one way to revoke.
|
|
715
|
+
*
|
|
716
|
+
* `ctx.principal` on the resulting stub carries the connection id so the type
|
|
717
|
+
* holds, but it is **not a person**: an operation invoked this way should read
|
|
718
|
+
* the event actor (`{ connection }`), and a module that attributes domain
|
|
719
|
+
* data to `ctx.principal` will be recording a connector.
|
|
720
|
+
*/
|
|
721
|
+
getConnectorScope(connectionId: ConnectionId, scopeId: ScopeId): Promise<ScopeStub>;
|
|
722
|
+
/**
|
|
723
|
+
* Register a connector — an executor that also gets a per-tenant credential
|
|
724
|
+
* and sanctioned egress (#101, design/connections.md §4.1).
|
|
725
|
+
*
|
|
726
|
+
* Rides the same hardened dispatch, journal and retry policy as
|
|
727
|
+
* `registerExecutor`; the difference is only what the handler is handed. Kept
|
|
728
|
+
* as a second registration rather than widening `ExecutorHandler` because the
|
|
729
|
+
* two really are different capabilities, and a membership executor should not
|
|
730
|
+
* be handed the machinery to call the internet.
|
|
731
|
+
*/
|
|
732
|
+
registerConnector(id: string, eventType: string, handler: ConnectorHandler, options?: ConnectorOptions): void;
|
|
733
|
+
/**
|
|
734
|
+
* Run every executor delivery that is due for this scope — the retry driver.
|
|
735
|
+
*
|
|
736
|
+
* Inline dispatch after an operation covers the common case, but a delivery
|
|
737
|
+
* that failed has no way back on its own: before this existed, retry happened
|
|
738
|
+
* only if someone happened to invoke another operation on the same scope, so a
|
|
739
|
+
* quiet scope could hold a failed effect forever with nothing reporting it.
|
|
740
|
+
*
|
|
741
|
+
* Call it from whatever scheduling the deployment has — a cron trigger, a
|
|
742
|
+
* Durable Object alarm, a dev-server timer. Idempotent and safe to call when
|
|
743
|
+
* nothing is due.
|
|
744
|
+
*/
|
|
745
|
+
drainDue(tenantId: TenantId, scopeId: ScopeId): Promise<ExecutorDrainReport>;
|
|
746
|
+
/**
|
|
747
|
+
* Executor deliveries that exhausted their attempts, oldest first — the evidence a
|
|
748
|
+
* dead-letter is a decision rather than a disappearance.
|
|
489
749
|
*/
|
|
490
|
-
|
|
750
|
+
executorDeadLetters(tenantId: TenantId, scopeId: ScopeId): Promise<ExecutorDeadLetter[]>;
|
|
491
751
|
/** Bare operation registration (tests, glue). Names are module-namespaced: 'workorder/create'. */
|
|
492
752
|
defineOperation<I, O>(name: string, handler: OperationHandler<I, O>): void;
|
|
493
753
|
close(): Promise<void>;
|
package/dist/scope-host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-host.d.ts","sourceRoot":"","sources":["../src/scope-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,IAAI,EACJ,GAAG,EACH,KAAK,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX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AAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IAE3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
package/dist/scope-host.js
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Retry defaults (#100). Tuned for the directory write the first executor does;
|
|
3
|
+
* a connector making an outbound call should raise `maxAttempts` explicitly,
|
|
4
|
+
* which is why the policy is per-executor rather than a host constant.
|
|
5
|
+
*/
|
|
6
|
+
export function resolveRetryPolicy(retry) {
|
|
7
|
+
return {
|
|
8
|
+
maxAttempts: retry?.maxAttempts ?? 5,
|
|
9
|
+
baseDelayMs: retry?.baseDelayMs ?? 1_000,
|
|
10
|
+
maxDelayMs: retry?.maxDelayMs ?? 300_000,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* When attempt `attempts` should next be tried: exponential, capped, jittered.
|
|
15
|
+
*
|
|
16
|
+
* Jitter is ±20% and is skipped entirely at zero delay, so a test setting
|
|
17
|
+
* `baseDelayMs: 0` gets deterministic immediate retries rather than a race. It
|
|
18
|
+
* matters at real delays because every scope in a fleet retries a downed
|
|
19
|
+
* provider on the same schedule otherwise.
|
|
20
|
+
*/
|
|
21
|
+
export function backoffAt(attempts, retry, from) {
|
|
22
|
+
const raw = Math.min(retry.baseDelayMs * 2 ** (attempts - 1), retry.maxDelayMs);
|
|
23
|
+
const jittered = raw === 0 ? 0 : raw * (0.8 + Math.random() * 0.4);
|
|
24
|
+
return new Date(from.getTime() + jittered).toISOString();
|
|
25
|
+
}
|
|
2
26
|
//# sourceMappingURL=scope-host.js.map
|
package/dist/scope-host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-host.js","sourceRoot":"","sources":["../src/scope-host.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"scope-host.js","sourceRoot":"","sources":["../src/scope-host.ts"],"names":[],"mappings":"AAmRA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA2B;IAC5D,OAAO;QACL,WAAW,EAAE,KAAK,EAAE,WAAW,IAAI,CAAC;QACpC,WAAW,EAAE,KAAK,EAAE,WAAW,IAAI,KAAK;QACxC,UAAU,EAAE,KAAK,EAAE,UAAU,IAAI,OAAO;KACzC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,QAAgB,EAChB,KAAoC,EACpC,IAAU;IAEV,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAChF,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IACnE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `SecretBox` — the seal/open adapter the connection store rests on (#101,
|
|
3
|
+
* design/connections.md §3.3).
|
|
4
|
+
*
|
|
5
|
+
* **Bucket 2 in D-18's triage**, which names the KMS as an adapter explicitly.
|
|
6
|
+
* The kernel decides that per-tenant credentials are encrypted at rest and that
|
|
7
|
+
* plaintext never touches the directory; *what* does the encrypting is swappable
|
|
8
|
+
* — Web Crypto locally, a Cloudflare Secrets Store binding or an external KMS
|
|
9
|
+
* when hosted.
|
|
10
|
+
*
|
|
11
|
+
* Before this existed there was no encryption primitive in the codebase at all:
|
|
12
|
+
* every `crypto.subtle` call was a one-way digest, and every secret was a
|
|
13
|
+
* plaintext Worker binding. Nothing was per-tenant, nothing was rotatable.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Sealed bytes plus the id of the key that sealed them.
|
|
17
|
+
*
|
|
18
|
+
* `keyId` is what makes rotation possible: a new key seals new writes while old
|
|
19
|
+
* blobs stay openable, so re-sealing is a background sweep rather than a
|
|
20
|
+
* flag-day. A `SecretBox` that cannot name its key can only ever have one.
|
|
21
|
+
*/
|
|
22
|
+
export interface SealedSecret {
|
|
23
|
+
keyId: string;
|
|
24
|
+
/** Opaque to everything above this interface. Base64 for the Web Crypto impl. */
|
|
25
|
+
ciphertext: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SecretBox {
|
|
28
|
+
seal(plaintext: string): Promise<SealedSecret>;
|
|
29
|
+
/** Throws if the blob was sealed by a key this box does not hold. */
|
|
30
|
+
open(sealed: SealedSecret): Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* AES-256-GCM over Web Crypto — the default for dev, CI and self-hosting.
|
|
34
|
+
*
|
|
35
|
+
* `key` is 32 raw bytes. A fresh 96-bit IV per seal is prepended to the
|
|
36
|
+
* ciphertext, which is what makes it safe to seal the same credential twice;
|
|
37
|
+
* GCM with a reused IV is catastrophic rather than merely weak.
|
|
38
|
+
*
|
|
39
|
+
* **Fails closed when unconfigured.** A host built without a `SecretBox` cannot
|
|
40
|
+
* store a credential at all, rather than storing one in the clear. That is the
|
|
41
|
+
* rule `assertPlatformCall` already states — *"an unset secret is a failure, not
|
|
42
|
+
* a bypass"* — applied to the thing it most obviously protects. Note the router
|
|
43
|
+
* secret does the opposite; it is not a precedent to copy here.
|
|
44
|
+
*/
|
|
45
|
+
export declare function webCryptoSecretBox(keyId: string, key: Uint8Array): SecretBox;
|
|
46
|
+
/**
|
|
47
|
+
* The box a host gets when none was configured: every call throws.
|
|
48
|
+
*
|
|
49
|
+
* Deliberately not "store it in the clear" and not "silently disable
|
|
50
|
+
* connections" — either would make a misconfiguration invisible until a
|
|
51
|
+
* credential leaked. Reading the error tells an operator exactly what to set.
|
|
52
|
+
*/
|
|
53
|
+
export declare const unconfiguredSecretBox: SecretBox;
|
|
54
|
+
//# sourceMappingURL=secret-box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-box.d.ts","sourceRoot":"","sources":["../src/secret-box.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/C,qEAAqE;IACrE,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C;AAkDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,SAAS,CAqC5E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAanC,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `SecretBox` — the seal/open adapter the connection store rests on (#101,
|
|
3
|
+
* design/connections.md §3.3).
|
|
4
|
+
*
|
|
5
|
+
* **Bucket 2 in D-18's triage**, which names the KMS as an adapter explicitly.
|
|
6
|
+
* The kernel decides that per-tenant credentials are encrypted at rest and that
|
|
7
|
+
* plaintext never touches the directory; *what* does the encrypting is swappable
|
|
8
|
+
* — Web Crypto locally, a Cloudflare Secrets Store binding or an external KMS
|
|
9
|
+
* when hosted.
|
|
10
|
+
*
|
|
11
|
+
* Before this existed there was no encryption primitive in the codebase at all:
|
|
12
|
+
* every `crypto.subtle` call was a one-way digest, and every secret was a
|
|
13
|
+
* plaintext Worker binding. Nothing was per-tenant, nothing was rotatable.
|
|
14
|
+
*/
|
|
15
|
+
const toBase64 = (bytes) => {
|
|
16
|
+
let s = '';
|
|
17
|
+
for (const b of bytes)
|
|
18
|
+
s += String.fromCharCode(b);
|
|
19
|
+
return btoa(s);
|
|
20
|
+
};
|
|
21
|
+
const fromBase64 = (b64) => {
|
|
22
|
+
const s = atob(b64);
|
|
23
|
+
const out = new Uint8Array(s.length);
|
|
24
|
+
for (let i = 0; i < s.length; i += 1)
|
|
25
|
+
out[i] = s.charCodeAt(i);
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* AES-256-GCM over Web Crypto — the default for dev, CI and self-hosting.
|
|
30
|
+
*
|
|
31
|
+
* `key` is 32 raw bytes. A fresh 96-bit IV per seal is prepended to the
|
|
32
|
+
* ciphertext, which is what makes it safe to seal the same credential twice;
|
|
33
|
+
* GCM with a reused IV is catastrophic rather than merely weak.
|
|
34
|
+
*
|
|
35
|
+
* **Fails closed when unconfigured.** A host built without a `SecretBox` cannot
|
|
36
|
+
* store a credential at all, rather than storing one in the clear. That is the
|
|
37
|
+
* rule `assertPlatformCall` already states — *"an unset secret is a failure, not
|
|
38
|
+
* a bypass"* — applied to the thing it most obviously protects. Note the router
|
|
39
|
+
* secret does the opposite; it is not a precedent to copy here.
|
|
40
|
+
*/
|
|
41
|
+
export function webCryptoSecretBox(keyId, key) {
|
|
42
|
+
if (key.length !== 32) {
|
|
43
|
+
throw new Error(`SecretBox key must be 32 bytes (AES-256), got ${key.length}`);
|
|
44
|
+
}
|
|
45
|
+
const imported = crypto.subtle.importKey('raw', key, 'AES-GCM', false, ['encrypt', 'decrypt']);
|
|
46
|
+
return {
|
|
47
|
+
async seal(plaintext) {
|
|
48
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
49
|
+
const body = new Uint8Array(await crypto.subtle.encrypt({ name: 'AES-GCM', iv }, await imported, new TextEncoder().encode(plaintext)));
|
|
50
|
+
const joined = new Uint8Array(iv.length + body.length);
|
|
51
|
+
joined.set(iv, 0);
|
|
52
|
+
joined.set(body, iv.length);
|
|
53
|
+
return { keyId, ciphertext: toBase64(joined) };
|
|
54
|
+
},
|
|
55
|
+
async open(sealed) {
|
|
56
|
+
if (sealed.keyId !== keyId) {
|
|
57
|
+
// Naming the ids is safe and is the only way an operator can tell
|
|
58
|
+
// "wrong key configured" from "corrupt blob".
|
|
59
|
+
throw new Error(`SecretBox cannot open a secret sealed by key '${sealed.keyId}' (holding '${keyId}')`);
|
|
60
|
+
}
|
|
61
|
+
const joined = fromBase64(sealed.ciphertext);
|
|
62
|
+
const plain = await crypto.subtle.decrypt({ name: 'AES-GCM', iv: joined.slice(0, 12) }, await imported, joined.slice(12));
|
|
63
|
+
return new TextDecoder().decode(new Uint8Array(plain));
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The box a host gets when none was configured: every call throws.
|
|
69
|
+
*
|
|
70
|
+
* Deliberately not "store it in the clear" and not "silently disable
|
|
71
|
+
* connections" — either would make a misconfiguration invisible until a
|
|
72
|
+
* credential leaked. Reading the error tells an operator exactly what to set.
|
|
73
|
+
*/
|
|
74
|
+
export const unconfiguredSecretBox = {
|
|
75
|
+
seal() {
|
|
76
|
+
return Promise.reject(new Error('no SecretBox configured: this host cannot store credentials. ' +
|
|
77
|
+
'Pass one to the host (webCryptoSecretBox with a 32-byte key) — ' +
|
|
78
|
+
'storing a credential unsealed is not an option.'));
|
|
79
|
+
},
|
|
80
|
+
open() {
|
|
81
|
+
return Promise.reject(new Error('no SecretBox configured: cannot open a stored credential'));
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=secret-box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-box.js","sourceRoot":"","sources":["../src/secret-box.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;A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;YACjE,iDAAiD,CACpD,CACF,CAAC;IACJ,CAAC;IACD,IAAI;QACF,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/kernel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Substrat kernel contracts and services — pure TypeScript, no platform imports (D-14)",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@substrat-run/contracts": "^0.
|
|
25
|
+
"@substrat-run/contracts": "^0.10.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"typescript": "^5.6.0",
|