@forgezero/access 0.1.3 → 0.1.5
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/README.md +379 -52
- package/dist/ceremony-modes.d.ts +3 -42
- package/dist/ceremony-modes.js +45 -29
- package/dist/conditions.js +1 -1
- package/dist/effects.js +1 -1
- package/dist/elysia.js +1 -1
- package/dist/fetch.js +1 -1
- package/dist/header.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/pipeline.js +1 -1
- package/dist/principal-session.js +1 -1
- package/dist/principal.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
GENERATED FILE — do not edit.
|
|
3
3
|
|
|
4
|
-
Change
|
|
4
|
+
Change tools/generate-guides.ts or its typed sources, run `bun run guides`,
|
|
5
5
|
and commit the generator and rendered files together.
|
|
6
6
|
-->
|
|
7
7
|
|
|
@@ -9,14 +9,48 @@
|
|
|
9
9
|
|
|
10
10
|
Declare your security posture as seven lists. Handlers hold business logic only.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Package overview
|
|
13
13
|
|
|
14
|
-
Anyone building a service on our request shape: one declared matrix of routes and factors, enforced by one pipeline whatever the framework. Imports no sibling at all, so it can be adopted on its own. Supported runtimes: bun, node, workers, deno.
|
|
14
|
+
Anyone building a service on our request shape: one declared matrix of routes and factors, enforced by one pipeline whatever the framework. Imports no sibling at all, so it can be adopted on its own. Supported runtimes: bun, node, workers, deno. Package root: @forgezero/access. The sections below show the actual named imports emitted by each declaration entry point; wildcard imports are intentionally not used in the documentation.
|
|
15
15
|
|
|
16
16
|
```text
|
|
17
|
-
|
|
17
|
+
bun add @forgezero/access
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
## ForgeZero package family
|
|
21
|
+
|
|
22
|
+
The five packages are installation boundaries. Choose a package by who installs it; choose a subpath by the capability used in that file.
|
|
23
|
+
|
|
24
|
+
| package | short description | runtimes | documentation |
|
|
25
|
+
|---|---|---|---|
|
|
26
|
+
| @forgezero/vault | Scoped secret access with Agent, API-key and systemd-credential sources. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/vault-package) |
|
|
27
|
+
| @forgezero/access | Typed route, principal, factor, RBAC and request-pipeline contracts. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/access) |
|
|
28
|
+
| @forgezero/providers | Typed external providers with priority, health and classified fallback. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/providers) |
|
|
29
|
+
| @forgezero/runtime | Portable runtime primitives for queries, jobs, events, schemas and finance. | bun, node | [Open](https://www.forgezero.net/docs/runtime) |
|
|
30
|
+
| @forgezero/agent | Operator CLI and managed-node agent for bootstrap, deploy and lifecycle. | bun, node | [Open](https://www.forgezero.net/docs/agent) |
|
|
31
|
+
|
|
32
|
+
## @forgezero/access public imports and commands
|
|
33
|
+
|
|
34
|
+
Every row links to the detailed explanation and named-import/example area below. This table and those details are generated from the package inventory and emitted declarations.
|
|
35
|
+
|
|
36
|
+
| public entry | short description | runtime | details |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| @forgezero/access | Declare routes, factors and policies as orthogonal lists; authorise against them. | portable | [Details + example](#forgezero-access) |
|
|
39
|
+
| @forgezero/access/conditions | The twelve guards every project writes into `before`, each with the status its refusal deserves. | portable | [Details + example](#forgezero-access-conditions) |
|
|
40
|
+
| @forgezero/access/effects | Audit, emit, meter, invalidate and notify — what happens after a request is decided, never failing it. | portable | [Details + example](#forgezero-access-effects) |
|
|
41
|
+
| @forgezero/access/security | Constant-time comparison, CSPRNG tokens, HMAC, HKDF, AES-GCM sealing and redaction. Web Crypto only. | portable | [Details + example](#forgezero-access-security) |
|
|
42
|
+
| @forgezero/access/rate-limit | Request counters over a window — in memory, in Redis, or in a Durable Object. | portable | [Details + example](#forgezero-access-rate-limit) |
|
|
43
|
+
| @forgezero/access/fetch | A Fetch-native adapter over the declared access pipeline. | portable | [Details + example](#forgezero-access-fetch) |
|
|
44
|
+
| @forgezero/access/pipeline | The framework-neutral route, principal, factor, policy, rate-limit and effects pipeline. | portable | [Details + example](#forgezero-access-pipeline) |
|
|
45
|
+
| @forgezero/access/elysia | Elysia integration over the same access pipeline and route declarations. | portable | [Details + example](#forgezero-access-elysia) |
|
|
46
|
+
| @forgezero/access/client | Typed client helpers that fulfil factors without duplicating the security matrix. | portable | [Details + example](#forgezero-access-client) |
|
|
47
|
+
| @forgezero/access/testing | Deterministic access-pipeline fixtures and assertions for consumer tests. | portable | [Details + example](#forgezero-access-testing) |
|
|
48
|
+
| @forgezero/access/header | Strict configurable header-identity extraction with canonical names and bounded values. | portable | [Details + example](#forgezero-access-header) |
|
|
49
|
+
| @forgezero/access/principal | Generic principal-source resolution for browser, API-key, attestation or future identity adapters. | portable | [Details + example](#forgezero-access-principal) |
|
|
50
|
+
| @forgezero/access/principal-session | Short-lived scope-bound delegated-principal sessions with sliding and absolute expiry. | portable | [Details + example](#forgezero-access-principal-session) |
|
|
51
|
+
| @forgezero/access/authenticator | Authentication-source contracts for adding identity mechanisms without changing route policy. | portable | [Details + example](#forgezero-access-authenticator) |
|
|
52
|
+
| @forgezero/access/ceremony-modes | Named security-ceremony modes and their session/action fulfilment semantics. | portable | [Details + example](#forgezero-access-ceremony-modes) |
|
|
53
|
+
|
|
20
54
|
## Commands
|
|
21
55
|
|
|
22
56
|
bun add @forgezero/access — Install the framework-neutral access contracts and adapters.
|
|
@@ -25,137 +59,414 @@ bun add @forgezero/access — Install the framework-neutral access contracts and
|
|
|
25
59
|
bun add @forgezero/access
|
|
26
60
|
```
|
|
27
61
|
|
|
62
|
+
<a id="forgezero-access"></a>
|
|
28
63
|
## @forgezero/access
|
|
29
64
|
|
|
30
|
-
Declare routes, factors and policies as orthogonal lists; authorise against them.
|
|
65
|
+
Declare routes, factors and policies as orthogonal lists; authorise against them. This entry exposes 21 named value exports and 27 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
import {
|
|
69
|
+
AccessError,
|
|
70
|
+
Refusal,
|
|
71
|
+
SCHEMA_VERSION,
|
|
72
|
+
Settled,
|
|
73
|
+
VERSION,
|
|
74
|
+
action,
|
|
75
|
+
assertReadable,
|
|
76
|
+
authorise,
|
|
77
|
+
codePolicy,
|
|
78
|
+
defineAccessControl,
|
|
79
|
+
defineFactors,
|
|
80
|
+
defineRoutes,
|
|
81
|
+
externalPolicy,
|
|
82
|
+
fulfilledActionFactors,
|
|
83
|
+
grantsRoute,
|
|
84
|
+
impactOfDisabling,
|
|
85
|
+
isRefusal,
|
|
86
|
+
isSettled,
|
|
87
|
+
page,
|
|
88
|
+
resolveActionFactors,
|
|
89
|
+
stemOf,
|
|
90
|
+
} from '@forgezero/access';
|
|
91
|
+
|
|
92
|
+
import type {
|
|
93
|
+
AccessControl,
|
|
94
|
+
AccessControlConfig,
|
|
95
|
+
ActionPolicy,
|
|
96
|
+
ActionRoute,
|
|
97
|
+
AfterHandler,
|
|
98
|
+
BeforeHandler,
|
|
99
|
+
Binding,
|
|
100
|
+
FactorContext,
|
|
101
|
+
FactorKind,
|
|
102
|
+
FactorRegistry,
|
|
103
|
+
FactorSpec,
|
|
104
|
+
GrantOptions,
|
|
105
|
+
Method,
|
|
106
|
+
Outcome,
|
|
107
|
+
PageRoute,
|
|
108
|
+
PolicySource,
|
|
109
|
+
Problem,
|
|
110
|
+
RatePolicy,
|
|
111
|
+
RequestContext,
|
|
112
|
+
Role,
|
|
113
|
+
RouteBase,
|
|
114
|
+
RouteContract,
|
|
115
|
+
RouteRegistry,
|
|
116
|
+
RouteSpec,
|
|
117
|
+
SessionContext,
|
|
118
|
+
SessionPolicy,
|
|
119
|
+
Versioned,
|
|
120
|
+
} from '@forgezero/access';
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## @forgezero/access — Declare routes before handlers
|
|
124
|
+
|
|
125
|
+
Routes and their access policy are data; Fetch and Elysia adapters enforce the same declaration.
|
|
31
126
|
|
|
32
127
|
```text
|
|
33
|
-
import
|
|
128
|
+
import {
|
|
129
|
+
defineRoutes,
|
|
130
|
+
action,
|
|
131
|
+
page,
|
|
132
|
+
} from '@forgezero/access';
|
|
133
|
+
|
|
134
|
+
export const routes = defineRoutes({
|
|
135
|
+
orders: page('Orders'),
|
|
136
|
+
'api/orders': action('List orders', 'GET', { page: 'orders' })
|
|
137
|
+
});
|
|
34
138
|
```
|
|
35
139
|
|
|
140
|
+
<a id="forgezero-access-conditions"></a>
|
|
36
141
|
## @forgezero/access/conditions
|
|
37
142
|
|
|
38
|
-
The twelve guards every project writes into `before`, each with the status its refusal deserves.
|
|
143
|
+
The twelve guards every project writes into `before`, each with the status its refusal deserves. This entry exposes 14 named value exports and 16 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
39
144
|
|
|
40
145
|
```text
|
|
41
|
-
import
|
|
146
|
+
import {
|
|
147
|
+
assertDeclaredRefusals,
|
|
148
|
+
loadTarget,
|
|
149
|
+
refusalsFor,
|
|
150
|
+
requireApproval,
|
|
151
|
+
requireBalance,
|
|
152
|
+
requireIdempotency,
|
|
153
|
+
requireNotFrozen,
|
|
154
|
+
requireOwner,
|
|
155
|
+
requireQuota,
|
|
156
|
+
requireService,
|
|
157
|
+
requireState,
|
|
158
|
+
requireTier,
|
|
159
|
+
requireUnlocked,
|
|
160
|
+
requireVersion,
|
|
161
|
+
} from '@forgezero/access/conditions';
|
|
162
|
+
|
|
163
|
+
import type {
|
|
164
|
+
ApprovalState,
|
|
165
|
+
Condition,
|
|
166
|
+
IdempotencyStore,
|
|
167
|
+
LoadTargetOptions,
|
|
168
|
+
RefusalSpec,
|
|
169
|
+
RequireApprovalOptions,
|
|
170
|
+
RequireBalanceOptions,
|
|
171
|
+
RequireIdempotencyOptions,
|
|
172
|
+
RequireNotFrozenOptions,
|
|
173
|
+
RequireOwnerOptions,
|
|
174
|
+
RequireQuotaOptions,
|
|
175
|
+
RequireServiceOptions,
|
|
176
|
+
RequireStateOptions,
|
|
177
|
+
RequireTierOptions,
|
|
178
|
+
RequireUnlockedOptions,
|
|
179
|
+
RequireVersionOptions,
|
|
180
|
+
} from '@forgezero/access/conditions';
|
|
42
181
|
```
|
|
43
182
|
|
|
183
|
+
<a id="forgezero-access-effects"></a>
|
|
44
184
|
## @forgezero/access/effects
|
|
45
185
|
|
|
46
|
-
Audit, emit, meter, invalidate and notify — what happens after a request is decided, never failing it.
|
|
186
|
+
Audit, emit, meter, invalidate and notify — what happens after a request is decided, never failing it. This entry exposes 6 named value exports and 15 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
47
187
|
|
|
48
188
|
```text
|
|
49
|
-
import
|
|
189
|
+
import {
|
|
190
|
+
audit,
|
|
191
|
+
emit,
|
|
192
|
+
invalidate,
|
|
193
|
+
meter,
|
|
194
|
+
notify,
|
|
195
|
+
settlementOf,
|
|
196
|
+
} from '@forgezero/access/effects';
|
|
197
|
+
|
|
198
|
+
import type {
|
|
199
|
+
AuditOptions,
|
|
200
|
+
AuditRecord,
|
|
201
|
+
AuditSink,
|
|
202
|
+
CacheInvalidator,
|
|
203
|
+
Effect,
|
|
204
|
+
EmitOptions,
|
|
205
|
+
InvalidateOptions,
|
|
206
|
+
MeterOptions,
|
|
207
|
+
Notification,
|
|
208
|
+
Notifier,
|
|
209
|
+
NotifyOptions,
|
|
210
|
+
Outbox,
|
|
211
|
+
OutboxEvent,
|
|
212
|
+
Settlement,
|
|
213
|
+
UsageMeter,
|
|
214
|
+
} from '@forgezero/access/effects';
|
|
50
215
|
```
|
|
51
216
|
|
|
217
|
+
<a id="forgezero-access-security"></a>
|
|
52
218
|
## @forgezero/access/security
|
|
53
219
|
|
|
54
|
-
Constant-time comparison, CSPRNG tokens, HMAC, HKDF, AES-GCM sealing and redaction. Web Crypto only.
|
|
220
|
+
Constant-time comparison, CSPRNG tokens, HMAC, HKDF, AES-GCM sealing and redaction. Web Crypto only. This entry exposes 20 named value exports and 1 named type export. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
55
221
|
|
|
56
222
|
```text
|
|
57
|
-
import
|
|
223
|
+
import {
|
|
224
|
+
fromBase64Url,
|
|
225
|
+
fromHex,
|
|
226
|
+
hashToken,
|
|
227
|
+
hkdf,
|
|
228
|
+
hmacSha256,
|
|
229
|
+
isLive,
|
|
230
|
+
nowSeconds,
|
|
231
|
+
open,
|
|
232
|
+
randomDigits,
|
|
233
|
+
randomHex,
|
|
234
|
+
randomInt,
|
|
235
|
+
randomToken,
|
|
236
|
+
redact,
|
|
237
|
+
seal,
|
|
238
|
+
secretFieldPattern,
|
|
239
|
+
sha256,
|
|
240
|
+
timingSafeEqual,
|
|
241
|
+
toBase64Url,
|
|
242
|
+
toHex,
|
|
243
|
+
verifyHmac,
|
|
244
|
+
} from '@forgezero/access/security';
|
|
245
|
+
|
|
246
|
+
import type {
|
|
247
|
+
Sealed,
|
|
248
|
+
} from '@forgezero/access/security';
|
|
58
249
|
```
|
|
59
250
|
|
|
251
|
+
<a id="forgezero-access-rate-limit"></a>
|
|
60
252
|
## @forgezero/access/rate-limit
|
|
61
253
|
|
|
62
|
-
Request counters over a window — in memory, in Redis, or in a Durable Object.
|
|
254
|
+
Request counters over a window — in memory, in Redis, or in a Durable Object. This entry exposes 4 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
63
255
|
|
|
64
256
|
```text
|
|
65
|
-
import
|
|
257
|
+
import {
|
|
258
|
+
durableObjectStore,
|
|
259
|
+
memoryStore,
|
|
260
|
+
redisStore,
|
|
261
|
+
slidingWindowStore,
|
|
262
|
+
} from '@forgezero/access/rate-limit';
|
|
263
|
+
|
|
264
|
+
import type {
|
|
265
|
+
DurableStorageLike,
|
|
266
|
+
RedisLike,
|
|
267
|
+
} from '@forgezero/access/rate-limit';
|
|
66
268
|
```
|
|
67
269
|
|
|
270
|
+
<a id="forgezero-access-fetch"></a>
|
|
68
271
|
## @forgezero/access/fetch
|
|
69
272
|
|
|
70
|
-
A Fetch-native adapter over the declared access pipeline.
|
|
273
|
+
A Fetch-native adapter over the declared access pipeline. This entry exposes 3 named value exports and 1 named type export. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
71
274
|
|
|
72
275
|
```text
|
|
73
|
-
import
|
|
276
|
+
import {
|
|
277
|
+
compileRoute,
|
|
278
|
+
matchRoute,
|
|
279
|
+
toFetch,
|
|
280
|
+
} from '@forgezero/access/fetch';
|
|
281
|
+
|
|
282
|
+
import type {
|
|
283
|
+
FetchHandler,
|
|
284
|
+
} from '@forgezero/access/fetch';
|
|
74
285
|
```
|
|
75
286
|
|
|
287
|
+
<a id="forgezero-access-pipeline"></a>
|
|
76
288
|
## @forgezero/access/pipeline
|
|
77
289
|
|
|
78
|
-
The framework-neutral route, principal, factor, policy, rate-limit and effects pipeline.
|
|
290
|
+
The framework-neutral route, principal, factor, policy, rate-limit and effects pipeline. This entry exposes 3 named value exports and 9 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
79
291
|
|
|
80
292
|
```text
|
|
81
|
-
import
|
|
293
|
+
import {
|
|
294
|
+
createPipeline,
|
|
295
|
+
defineHandlers,
|
|
296
|
+
windowSeconds,
|
|
297
|
+
} from '@forgezero/access/pipeline';
|
|
298
|
+
|
|
299
|
+
import type {
|
|
300
|
+
Handler,
|
|
301
|
+
HandlerRegistry,
|
|
302
|
+
Pipeline,
|
|
303
|
+
PipelineOptions,
|
|
304
|
+
RateStore,
|
|
305
|
+
SessionResolver,
|
|
306
|
+
StepUpStore,
|
|
307
|
+
Telemetry,
|
|
308
|
+
Validator,
|
|
309
|
+
} from '@forgezero/access/pipeline';
|
|
82
310
|
```
|
|
83
311
|
|
|
312
|
+
<a id="forgezero-access-elysia"></a>
|
|
84
313
|
## @forgezero/access/elysia
|
|
85
314
|
|
|
86
|
-
Elysia integration over the same access pipeline and route declarations.
|
|
315
|
+
Elysia integration over the same access pipeline and route declarations. This entry exposes 4 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
87
316
|
|
|
88
317
|
```text
|
|
89
|
-
import
|
|
318
|
+
import {
|
|
319
|
+
elysia,
|
|
320
|
+
forbiddenTelemetryAttribute,
|
|
321
|
+
telemetryFrom,
|
|
322
|
+
toElysiaPath,
|
|
323
|
+
} from '@forgezero/access/elysia';
|
|
324
|
+
|
|
325
|
+
import type {
|
|
326
|
+
ElysiaAdapterOptions,
|
|
327
|
+
OtelTracer,
|
|
328
|
+
} from '@forgezero/access/elysia';
|
|
90
329
|
```
|
|
91
330
|
|
|
331
|
+
<a id="forgezero-access-client"></a>
|
|
92
332
|
## @forgezero/access/client
|
|
93
333
|
|
|
94
|
-
Typed client helpers that fulfil factors without duplicating the security matrix.
|
|
334
|
+
Typed client helpers that fulfil factors without duplicating the security matrix. This entry exposes 2 named value exports and 6 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
95
335
|
|
|
96
336
|
```text
|
|
97
|
-
import
|
|
337
|
+
import {
|
|
338
|
+
buildPath,
|
|
339
|
+
createClient,
|
|
340
|
+
} from '@forgezero/access/client';
|
|
341
|
+
|
|
342
|
+
import type {
|
|
343
|
+
ChallengeHandler,
|
|
344
|
+
ClientOptions,
|
|
345
|
+
ClientResult,
|
|
346
|
+
Problem,
|
|
347
|
+
RequestArgs,
|
|
348
|
+
SecurityChallenge,
|
|
349
|
+
} from '@forgezero/access/client';
|
|
98
350
|
```
|
|
99
351
|
|
|
352
|
+
<a id="forgezero-access-testing"></a>
|
|
100
353
|
## @forgezero/access/testing
|
|
101
354
|
|
|
102
|
-
Deterministic access-pipeline fixtures and assertions for consumer tests.
|
|
355
|
+
Deterministic access-pipeline fixtures and assertions for consumer tests. This entry exposes 3 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
103
356
|
|
|
104
357
|
```text
|
|
105
|
-
import
|
|
358
|
+
import {
|
|
359
|
+
reachableRoutes,
|
|
360
|
+
simulate,
|
|
361
|
+
unreachableRoutes,
|
|
362
|
+
} from '@forgezero/access/testing';
|
|
363
|
+
|
|
364
|
+
import type {
|
|
365
|
+
SimulateArgs,
|
|
366
|
+
Verdict,
|
|
367
|
+
} from '@forgezero/access/testing';
|
|
106
368
|
```
|
|
107
369
|
|
|
370
|
+
<a id="forgezero-access-header"></a>
|
|
108
371
|
## @forgezero/access/header
|
|
109
372
|
|
|
110
|
-
Strict configurable header-identity extraction with canonical names and bounded values.
|
|
373
|
+
Strict configurable header-identity extraction with canonical names and bounded values. This entry exposes 2 named value exports and 4 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
111
374
|
|
|
112
375
|
```text
|
|
113
|
-
import
|
|
376
|
+
import {
|
|
377
|
+
defineHeaderIdentitySources,
|
|
378
|
+
headerIdentityResolver,
|
|
379
|
+
} from '@forgezero/access/header';
|
|
380
|
+
|
|
381
|
+
import type {
|
|
382
|
+
HeaderAssignmentResolver,
|
|
383
|
+
HeaderIdentity,
|
|
384
|
+
HeaderIdentitySource,
|
|
385
|
+
HeaderPrincipal,
|
|
386
|
+
} from '@forgezero/access/header';
|
|
114
387
|
```
|
|
115
388
|
|
|
389
|
+
<a id="forgezero-access-principal"></a>
|
|
116
390
|
## @forgezero/access/principal
|
|
117
391
|
|
|
118
|
-
Generic principal-source resolution for browser, API-key, attestation or future identity adapters.
|
|
392
|
+
Generic principal-source resolution for browser, API-key, attestation or future identity adapters. This entry exposes 4 named value exports and 3 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
119
393
|
|
|
120
394
|
```text
|
|
121
|
-
import
|
|
395
|
+
import {
|
|
396
|
+
assignmentIsActive,
|
|
397
|
+
decidePrincipalAccess,
|
|
398
|
+
defineRbacPrincipal,
|
|
399
|
+
touchPrincipalAssignment,
|
|
400
|
+
} from '@forgezero/access/principal';
|
|
401
|
+
|
|
402
|
+
import type {
|
|
403
|
+
PrincipalAccessDecision,
|
|
404
|
+
PrincipalAssignment,
|
|
405
|
+
RbacPrincipal,
|
|
406
|
+
} from '@forgezero/access/principal';
|
|
122
407
|
```
|
|
123
408
|
|
|
409
|
+
<a id="forgezero-access-principal-session"></a>
|
|
124
410
|
## @forgezero/access/principal-session
|
|
125
411
|
|
|
126
|
-
Short-lived scope-bound delegated-principal sessions with sliding and absolute expiry.
|
|
412
|
+
Short-lived scope-bound delegated-principal sessions with sliding and absolute expiry. This entry exposes 8 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
127
413
|
|
|
128
414
|
```text
|
|
129
|
-
import
|
|
415
|
+
import {
|
|
416
|
+
DEFAULT_PRINCIPAL_ABSOLUTE_TTL_MS,
|
|
417
|
+
DEFAULT_PRINCIPAL_IDLE_TTL_MS,
|
|
418
|
+
MAX_PRINCIPAL_ABSOLUTE_TTL_MS,
|
|
419
|
+
MAX_PRINCIPAL_IDLE_TTL_MS,
|
|
420
|
+
authenticatePrincipalSession,
|
|
421
|
+
issuePrincipalSession,
|
|
422
|
+
principalSessionIsActive,
|
|
423
|
+
touchPrincipalSession,
|
|
424
|
+
} from '@forgezero/access/principal-session';
|
|
425
|
+
|
|
426
|
+
import type {
|
|
427
|
+
IssuedPrincipalSession,
|
|
428
|
+
PrincipalSessionRecord,
|
|
429
|
+
} from '@forgezero/access/principal-session';
|
|
130
430
|
```
|
|
131
431
|
|
|
432
|
+
<a id="forgezero-access-authenticator"></a>
|
|
132
433
|
## @forgezero/access/authenticator
|
|
133
434
|
|
|
134
|
-
Authentication-source contracts for adding identity mechanisms without changing route policy.
|
|
435
|
+
Authentication-source contracts for adding identity mechanisms without changing route policy. This entry exposes 2 named value exports and 7 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
135
436
|
|
|
136
437
|
```text
|
|
137
|
-
import
|
|
438
|
+
import {
|
|
439
|
+
createAuthenticator,
|
|
440
|
+
encoding,
|
|
441
|
+
} from '@forgezero/access/authenticator';
|
|
442
|
+
|
|
443
|
+
import type {
|
|
444
|
+
AuthenticationOptions,
|
|
445
|
+
AuthenticationResponse,
|
|
446
|
+
Authenticator,
|
|
447
|
+
AuthenticatorOptions,
|
|
448
|
+
Credential,
|
|
449
|
+
RegistrationOptions,
|
|
450
|
+
RegistrationResponse,
|
|
451
|
+
} from '@forgezero/access/authenticator';
|
|
138
452
|
```
|
|
139
453
|
|
|
454
|
+
<a id="forgezero-access-ceremony-modes"></a>
|
|
140
455
|
## @forgezero/access/ceremony-modes
|
|
141
456
|
|
|
142
|
-
Named security-ceremony modes and their session/action fulfilment semantics.
|
|
143
|
-
|
|
144
|
-
```text
|
|
145
|
-
import * as api from '@forgezero/access/ceremony-modes';
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## Declare routes before handlers
|
|
149
|
-
|
|
150
|
-
Routes and their access policy are data; Fetch and Elysia adapters enforce the same declaration.
|
|
457
|
+
Named security-ceremony modes and their session/action fulfilment semantics. This entry exposes 3 named value exports and 2 named type exports. The generated import block lists one name per line for scanning and copying; keep only the names used by your file.
|
|
151
458
|
|
|
152
459
|
```text
|
|
153
|
-
import {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
460
|
+
import {
|
|
461
|
+
MAX_CUSTODIANS,
|
|
462
|
+
THRESHOLD_MODES,
|
|
463
|
+
thresholdMode,
|
|
464
|
+
} from '@forgezero/access/ceremony-modes';
|
|
465
|
+
|
|
466
|
+
import type {
|
|
467
|
+
ThresholdMode,
|
|
468
|
+
ThresholdModeId,
|
|
469
|
+
} from '@forgezero/access/ceremony-modes';
|
|
159
470
|
```
|
|
160
471
|
|
|
161
472
|
## 1. Install
|
|
@@ -171,7 +482,12 @@ bun add @forgezero/access
|
|
|
171
482
|
Routes carry their contract — label, method, and the shapes they accept and return. WHO may reach them is a separate list, because the two change for different reasons and on different schedules.
|
|
172
483
|
|
|
173
484
|
```text
|
|
174
|
-
import {
|
|
485
|
+
import {
|
|
486
|
+
defineRoutes,
|
|
487
|
+
defineAccessControl,
|
|
488
|
+
page,
|
|
489
|
+
action,
|
|
490
|
+
} from '@forgezero/access';
|
|
175
491
|
|
|
176
492
|
export const ROUTES = defineRoutes({
|
|
177
493
|
orders: page('Orders'),
|
|
@@ -195,11 +511,15 @@ One line per runtime. The pipeline is written once and shared, so an adapter nev
|
|
|
195
511
|
|
|
196
512
|
```text
|
|
197
513
|
// anywhere fetch exists — Workers, Deno, Node, Bun
|
|
198
|
-
import {
|
|
514
|
+
import {
|
|
515
|
+
toFetch,
|
|
516
|
+
} from '@forgezero/access/fetch';
|
|
199
517
|
export default { fetch: toFetch({ access: ACCESS, handlers: HANDLERS }) };
|
|
200
518
|
|
|
201
519
|
// Elysia
|
|
202
|
-
import {
|
|
520
|
+
import {
|
|
521
|
+
elysia,
|
|
522
|
+
} from '@forgezero/access/elysia';
|
|
203
523
|
app.use(elysia({ access: ACCESS, handlers: HANDLERS, Elysia }));
|
|
204
524
|
```
|
|
205
525
|
|
|
@@ -245,7 +565,10 @@ impactOfDisabling(ACCESS, ['passkey'])
|
|
|
245
565
|
simulate() reports which policy decided, which a browser 403 never tells you. reachableRoutes() answers what a role can actually do — worth running, because stem inheritance grants more than a grant list reads like.
|
|
246
566
|
|
|
247
567
|
```text
|
|
248
|
-
import {
|
|
568
|
+
import {
|
|
569
|
+
simulate,
|
|
570
|
+
reachableRoutes,
|
|
571
|
+
} from '@forgezero/access/testing';
|
|
249
572
|
|
|
250
573
|
simulate(ACCESS, { route: 'api/settings', roles, as: 'member' });
|
|
251
574
|
// { allowed: false, status: 403, reason: 'ACCESS_DENIED', sessionPolicy: 'admin' }
|
|
@@ -296,7 +619,11 @@ assertDeclaredRefusals({ routes: ROUTES, conditions: CONDITIONS });
|
|
|
296
619
|
Audit, emit, meter, invalidate and notify. None can fail the request — a dead audit sink must not turn a completed transfer into a 500. Audit records denials as well as successes, because a run of 403s from one session is the signal an incident is reconstructed from. Every payload is redacted first.
|
|
297
620
|
|
|
298
621
|
```text
|
|
299
|
-
import {
|
|
622
|
+
import {
|
|
623
|
+
audit,
|
|
624
|
+
emit,
|
|
625
|
+
meter,
|
|
626
|
+
} from '@forgezero/access/effects';
|
|
300
627
|
|
|
301
628
|
afterHandlers: {
|
|
302
629
|
trail: audit({ routes: [...], sink }),
|
package/dist/ceremony-modes.d.ts
CHANGED
|
@@ -26,46 +26,7 @@ export interface ThresholdMode {
|
|
|
26
26
|
* cannot read it uniformly across the set. */
|
|
27
27
|
recommended: boolean;
|
|
28
28
|
}
|
|
29
|
-
export declare const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
readonly total: 2;
|
|
33
|
-
readonly label: "1 of 2";
|
|
34
|
-
readonly description: "Either custodian can unlock alone. Survives losing one person, but a single compromised custodian is enough to open the vault.";
|
|
35
|
-
readonly replicated: true;
|
|
36
|
-
readonly recommended: false;
|
|
37
|
-
}, {
|
|
38
|
-
readonly id: "1-of-3";
|
|
39
|
-
readonly threshold: 1;
|
|
40
|
-
readonly total: 3;
|
|
41
|
-
readonly label: "1 of 3";
|
|
42
|
-
readonly description: "Any custodian can unlock alone. Maximum availability, minimum protection against an insider.";
|
|
43
|
-
readonly replicated: true;
|
|
44
|
-
readonly recommended: false;
|
|
45
|
-
}, {
|
|
46
|
-
readonly id: "2-of-3";
|
|
47
|
-
readonly threshold: 2;
|
|
48
|
-
readonly total: 3;
|
|
49
|
-
readonly label: "2 of 3";
|
|
50
|
-
readonly description: "Two of three must convene. Survives losing one custodian, and no single person can unlock. The smallest genuinely split arrangement.";
|
|
51
|
-
readonly replicated: false;
|
|
52
|
-
readonly recommended: true;
|
|
53
|
-
}, {
|
|
54
|
-
readonly id: "3-of-5";
|
|
55
|
-
readonly threshold: 3;
|
|
56
|
-
readonly total: 5;
|
|
57
|
-
readonly label: "3 of 5";
|
|
58
|
-
readonly description: "Three of five must convene. Survives losing two custodians.";
|
|
59
|
-
readonly replicated: false;
|
|
60
|
-
readonly recommended: false;
|
|
61
|
-
}, {
|
|
62
|
-
readonly id: "4-of-7";
|
|
63
|
-
readonly threshold: 4;
|
|
64
|
-
readonly total: 7;
|
|
65
|
-
readonly label: "4 of 7";
|
|
66
|
-
readonly description: "Four of seven must convene. For larger governance groups.";
|
|
67
|
-
readonly replicated: false;
|
|
68
|
-
readonly recommended: false;
|
|
69
|
-
}];
|
|
70
|
-
export type ThresholdModeId = (typeof THRESHOLD_MODES)[number]['id'];
|
|
29
|
+
export declare const MAX_CUSTODIANS = 32;
|
|
30
|
+
export declare const THRESHOLD_MODES: readonly ThresholdMode[];
|
|
31
|
+
export type ThresholdModeId = `${number}-of-${number}`;
|
|
71
32
|
export declare function thresholdMode(id: string): ThresholdMode | undefined;
|
package/dist/ceremony-modes.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
// src/ceremony-modes.ts
|
|
2
|
+
var MAX_CUSTODIANS = 32;
|
|
3
|
+
var majorityPreset = (threshold) => {
|
|
4
|
+
const total = threshold * 2 - 1;
|
|
5
|
+
return {
|
|
6
|
+
id: `${threshold}-of-${total}`,
|
|
7
|
+
threshold,
|
|
8
|
+
total,
|
|
9
|
+
label: `${threshold} of ${total}`,
|
|
10
|
+
description: `${threshold} of ${total} custodians must convene. Survives losing ${total - threshold} custodians.`,
|
|
11
|
+
replicated: false,
|
|
12
|
+
recommended: threshold === 2
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
var MAJORITY_PRESETS = Array.from({ length: 15 }, (_, index) => majorityPreset(index + 2));
|
|
2
16
|
var THRESHOLD_MODES = [
|
|
17
|
+
{
|
|
18
|
+
id: "1-of-1",
|
|
19
|
+
threshold: 1,
|
|
20
|
+
total: 1,
|
|
21
|
+
label: "1 of 1",
|
|
22
|
+
description: "Bootstrap only: the first platform custodian brings custody online alone, then rotates to the long-term quorum.",
|
|
23
|
+
replicated: true,
|
|
24
|
+
recommended: false
|
|
25
|
+
},
|
|
3
26
|
{
|
|
4
27
|
id: "1-of-2",
|
|
5
28
|
threshold: 1,
|
|
@@ -18,38 +41,31 @@ var THRESHOLD_MODES = [
|
|
|
18
41
|
replicated: true,
|
|
19
42
|
recommended: false
|
|
20
43
|
},
|
|
21
|
-
|
|
22
|
-
id: "2-of-3",
|
|
23
|
-
threshold: 2,
|
|
24
|
-
total: 3,
|
|
25
|
-
label: "2 of 3",
|
|
26
|
-
description: "Two of three must convene. Survives losing one custodian, and no single person can unlock. The smallest genuinely split arrangement.",
|
|
27
|
-
replicated: false,
|
|
28
|
-
recommended: true
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: "3-of-5",
|
|
32
|
-
threshold: 3,
|
|
33
|
-
total: 5,
|
|
34
|
-
label: "3 of 5",
|
|
35
|
-
description: "Three of five must convene. Survives losing two custodians.",
|
|
36
|
-
replicated: false,
|
|
37
|
-
recommended: false
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
id: "4-of-7",
|
|
41
|
-
threshold: 4,
|
|
42
|
-
total: 7,
|
|
43
|
-
label: "4 of 7",
|
|
44
|
-
description: "Four of seven must convene. For larger governance groups.",
|
|
45
|
-
replicated: false,
|
|
46
|
-
recommended: false
|
|
47
|
-
}
|
|
44
|
+
...MAJORITY_PRESETS
|
|
48
45
|
];
|
|
49
46
|
function thresholdMode(id) {
|
|
50
|
-
|
|
47
|
+
const preset = THRESHOLD_MODES.find((mode) => mode.id === id);
|
|
48
|
+
if (preset)
|
|
49
|
+
return preset;
|
|
50
|
+
const match = /^(\d{1,2})-of-(\d{1,2})$/.exec(id);
|
|
51
|
+
if (!match)
|
|
52
|
+
return;
|
|
53
|
+
const threshold = Number(match[1]);
|
|
54
|
+
const total = Number(match[2]);
|
|
55
|
+
if (!Number.isSafeInteger(threshold) || !Number.isSafeInteger(total) || threshold < 1 || total < 1 || threshold > total || total > MAX_CUSTODIANS)
|
|
56
|
+
return;
|
|
57
|
+
return {
|
|
58
|
+
id: `${threshold}-of-${total}`,
|
|
59
|
+
threshold,
|
|
60
|
+
total,
|
|
61
|
+
label: `${threshold} of ${total}`,
|
|
62
|
+
description: threshold === 1 ? `Any one of ${total} custodians can unlock alone.` : `${threshold} of ${total} custodians must convene.`,
|
|
63
|
+
replicated: threshold === 1,
|
|
64
|
+
recommended: false
|
|
65
|
+
};
|
|
51
66
|
}
|
|
52
67
|
export {
|
|
53
68
|
thresholdMode,
|
|
54
|
-
THRESHOLD_MODES
|
|
69
|
+
THRESHOLD_MODES,
|
|
70
|
+
MAX_CUSTODIANS
|
|
55
71
|
};
|
package/dist/conditions.js
CHANGED
package/dist/effects.js
CHANGED
|
@@ -275,7 +275,7 @@ function impactOfDisabling(access, enabledAfter) {
|
|
|
275
275
|
}
|
|
276
276
|
return broken;
|
|
277
277
|
}
|
|
278
|
-
var VERSION = "0.1.
|
|
278
|
+
var VERSION = "0.1.5";
|
|
279
279
|
|
|
280
280
|
// src/security.ts
|
|
281
281
|
var HEX = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
|
package/dist/elysia.js
CHANGED
package/dist/fetch.js
CHANGED
package/dist/header.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/pipeline.js
CHANGED
|
@@ -275,7 +275,7 @@ function impactOfDisabling(access, enabledAfter) {
|
|
|
275
275
|
}
|
|
276
276
|
return broken;
|
|
277
277
|
}
|
|
278
|
-
var VERSION = "0.1.
|
|
278
|
+
var VERSION = "0.1.5";
|
|
279
279
|
|
|
280
280
|
// src/security.ts
|
|
281
281
|
var HEX = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
|
package/dist/principal.js
CHANGED
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgezero/access",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
|
-
"provenance":
|
|
7
|
+
"provenance": false
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
@@ -68,17 +68,16 @@
|
|
|
68
68
|
"default": "./dist/ceremony-modes.js"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"prepublishOnly": "bun run check && bun run build"
|
|
71
|
+
"scripts": {
|
|
72
|
+
"check": "tsc --noEmit",
|
|
73
|
+
"build": "bun ../tools/package-task.ts build access",
|
|
74
|
+
"prepublishOnly": "bun ../tools/package-task.ts prepublish access"
|
|
76
75
|
},
|
|
77
76
|
"devDependencies": {
|
|
78
77
|
"typescript": "^5.6.0",
|
|
79
78
|
"@types/bun": "latest"
|
|
80
79
|
},
|
|
81
|
-
"description": "Route matrix, RBAC and security factors. Zero runtime dependencies
|
|
80
|
+
"description": "Route matrix, RBAC and security factors. Zero runtime dependencies — runs anywhere fetch does.",
|
|
82
81
|
"keywords": [
|
|
83
82
|
"rbac",
|
|
84
83
|
"authorization",
|