@forgezero/access 0.1.3 → 0.1.4
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 +130 -47
- 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,186 @@ 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. Named value imports: AccessError, Refusal, SCHEMA_VERSION, Settled, VERSION, action, assertReadable, authorise, codePolicy, defineAccessControl, defineFactors, defineRoutes, externalPolicy, fulfilledActionFactors, grantsRoute, impactOfDisabling, isRefusal, isSettled, page, resolveActionFactors, stemOf. Named type imports: AccessControl, AccessControlConfig, ActionPolicy, ActionRoute, AfterHandler, BeforeHandler, Binding, FactorContext, FactorKind, FactorRegistry, FactorSpec, GrantOptions, Method, Outcome, PageRoute, PolicySource, Problem, RatePolicy, RequestContext, Role, RouteBase, RouteContract, RouteRegistry, RouteSpec, SessionContext, SessionPolicy, Versioned. Import only the names used by this file.
|
|
31
66
|
|
|
32
67
|
```text
|
|
33
|
-
import
|
|
68
|
+
import { AccessError, Refusal, SCHEMA_VERSION, Settled, VERSION, action } from '@forgezero/access';
|
|
69
|
+
import { assertReadable, authorise, codePolicy, defineAccessControl, defineFactors, defineRoutes } from '@forgezero/access';
|
|
70
|
+
import { externalPolicy, fulfilledActionFactors, grantsRoute, impactOfDisabling, isRefusal, isSettled } from '@forgezero/access';
|
|
71
|
+
import { page, resolveActionFactors, stemOf } from '@forgezero/access';
|
|
72
|
+
import type { AccessControl, AccessControlConfig, ActionPolicy, ActionRoute, AfterHandler, BeforeHandler } from '@forgezero/access';
|
|
73
|
+
import type { Binding, FactorContext, FactorKind, FactorRegistry, FactorSpec, GrantOptions } from '@forgezero/access';
|
|
74
|
+
import type { Method, Outcome, PageRoute, PolicySource, Problem, RatePolicy } from '@forgezero/access';
|
|
75
|
+
import type { RequestContext, Role, RouteBase, RouteContract, RouteRegistry, RouteSpec } from '@forgezero/access';
|
|
76
|
+
import type { SessionContext, SessionPolicy, Versioned } from '@forgezero/access';
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## @forgezero/access — Declare routes before handlers
|
|
80
|
+
|
|
81
|
+
Routes and their access policy are data; Fetch and Elysia adapters enforce the same declaration.
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
import { defineRoutes, action, page } from '@forgezero/access';
|
|
85
|
+
|
|
86
|
+
export const routes = defineRoutes({
|
|
87
|
+
orders: page('Orders'),
|
|
88
|
+
'api/orders': action('List orders', 'GET', { page: 'orders' })
|
|
89
|
+
});
|
|
34
90
|
```
|
|
35
91
|
|
|
92
|
+
<a id="forgezero-access-conditions"></a>
|
|
36
93
|
## @forgezero/access/conditions
|
|
37
94
|
|
|
38
|
-
The twelve guards every project writes into `before`, each with the status its refusal deserves.
|
|
95
|
+
The twelve guards every project writes into `before`, each with the status its refusal deserves. Named value imports: assertDeclaredRefusals, loadTarget, refusalsFor, requireApproval, requireBalance, requireIdempotency, requireNotFrozen, requireOwner, requireQuota, requireService, requireState, requireTier, requireUnlocked, requireVersion. Named type imports: ApprovalState, Condition, IdempotencyStore, LoadTargetOptions, RefusalSpec, RequireApprovalOptions, RequireBalanceOptions, RequireIdempotencyOptions, RequireNotFrozenOptions, RequireOwnerOptions, RequireQuotaOptions, RequireServiceOptions, RequireStateOptions, RequireTierOptions, RequireUnlockedOptions, RequireVersionOptions. Import only the names used by this file.
|
|
39
96
|
|
|
40
97
|
```text
|
|
41
|
-
import
|
|
98
|
+
import { assertDeclaredRefusals, loadTarget, refusalsFor, requireApproval, requireBalance, requireIdempotency } from '@forgezero/access/conditions';
|
|
99
|
+
import { requireNotFrozen, requireOwner, requireQuota, requireService, requireState, requireTier } from '@forgezero/access/conditions';
|
|
100
|
+
import { requireUnlocked, requireVersion } from '@forgezero/access/conditions';
|
|
101
|
+
import type { ApprovalState, Condition, IdempotencyStore, LoadTargetOptions, RefusalSpec, RequireApprovalOptions } from '@forgezero/access/conditions';
|
|
102
|
+
import type { RequireBalanceOptions, RequireIdempotencyOptions, RequireNotFrozenOptions, RequireOwnerOptions, RequireQuotaOptions, RequireServiceOptions } from '@forgezero/access/conditions';
|
|
103
|
+
import type { RequireStateOptions, RequireTierOptions, RequireUnlockedOptions, RequireVersionOptions } from '@forgezero/access/conditions';
|
|
42
104
|
```
|
|
43
105
|
|
|
106
|
+
<a id="forgezero-access-effects"></a>
|
|
44
107
|
## @forgezero/access/effects
|
|
45
108
|
|
|
46
|
-
Audit, emit, meter, invalidate and notify — what happens after a request is decided, never failing it.
|
|
109
|
+
Audit, emit, meter, invalidate and notify — what happens after a request is decided, never failing it. Named value imports: audit, emit, invalidate, meter, notify, settlementOf. Named type imports: AuditOptions, AuditRecord, AuditSink, CacheInvalidator, Effect, EmitOptions, InvalidateOptions, MeterOptions, Notification, Notifier, NotifyOptions, Outbox, OutboxEvent, Settlement, UsageMeter. Import only the names used by this file.
|
|
47
110
|
|
|
48
111
|
```text
|
|
49
|
-
import
|
|
112
|
+
import { audit, emit, invalidate, meter, notify, settlementOf } from '@forgezero/access/effects';
|
|
113
|
+
import type { AuditOptions, AuditRecord, AuditSink, CacheInvalidator, Effect, EmitOptions } from '@forgezero/access/effects';
|
|
114
|
+
import type { InvalidateOptions, MeterOptions, Notification, Notifier, NotifyOptions, Outbox } from '@forgezero/access/effects';
|
|
115
|
+
import type { OutboxEvent, Settlement, UsageMeter } from '@forgezero/access/effects';
|
|
50
116
|
```
|
|
51
117
|
|
|
118
|
+
<a id="forgezero-access-security"></a>
|
|
52
119
|
## @forgezero/access/security
|
|
53
120
|
|
|
54
|
-
Constant-time comparison, CSPRNG tokens, HMAC, HKDF, AES-GCM sealing and redaction. Web Crypto only.
|
|
121
|
+
Constant-time comparison, CSPRNG tokens, HMAC, HKDF, AES-GCM sealing and redaction. Web Crypto only. Named value imports: fromBase64Url, fromHex, hashToken, hkdf, hmacSha256, isLive, nowSeconds, open, randomDigits, randomHex, randomInt, randomToken, redact, seal, secretFieldPattern, sha256, timingSafeEqual, toBase64Url, toHex, verifyHmac. Named type imports: Sealed. Import only the names used by this file.
|
|
55
122
|
|
|
56
123
|
```text
|
|
57
|
-
import
|
|
124
|
+
import { fromBase64Url, fromHex, hashToken, hkdf, hmacSha256, isLive } from '@forgezero/access/security';
|
|
125
|
+
import { nowSeconds, open, randomDigits, randomHex, randomInt, randomToken } from '@forgezero/access/security';
|
|
126
|
+
import { redact, seal, secretFieldPattern, sha256, timingSafeEqual, toBase64Url } from '@forgezero/access/security';
|
|
127
|
+
import { toHex, verifyHmac } from '@forgezero/access/security';
|
|
128
|
+
import type { Sealed } from '@forgezero/access/security';
|
|
58
129
|
```
|
|
59
130
|
|
|
131
|
+
<a id="forgezero-access-rate-limit"></a>
|
|
60
132
|
## @forgezero/access/rate-limit
|
|
61
133
|
|
|
62
|
-
Request counters over a window — in memory, in Redis, or in a Durable Object.
|
|
134
|
+
Request counters over a window — in memory, in Redis, or in a Durable Object. Named value imports: durableObjectStore, memoryStore, redisStore, slidingWindowStore. Named type imports: DurableStorageLike, RedisLike. Import only the names used by this file.
|
|
63
135
|
|
|
64
136
|
```text
|
|
65
|
-
import
|
|
137
|
+
import { durableObjectStore, memoryStore, redisStore, slidingWindowStore } from '@forgezero/access/rate-limit';
|
|
138
|
+
import type { DurableStorageLike, RedisLike } from '@forgezero/access/rate-limit';
|
|
66
139
|
```
|
|
67
140
|
|
|
141
|
+
<a id="forgezero-access-fetch"></a>
|
|
68
142
|
## @forgezero/access/fetch
|
|
69
143
|
|
|
70
|
-
A Fetch-native adapter over the declared access pipeline.
|
|
144
|
+
A Fetch-native adapter over the declared access pipeline. Named value imports: compileRoute, matchRoute, toFetch. Named type imports: FetchHandler. Import only the names used by this file.
|
|
71
145
|
|
|
72
146
|
```text
|
|
73
|
-
import
|
|
147
|
+
import { compileRoute, matchRoute, toFetch } from '@forgezero/access/fetch';
|
|
148
|
+
import type { FetchHandler } from '@forgezero/access/fetch';
|
|
74
149
|
```
|
|
75
150
|
|
|
151
|
+
<a id="forgezero-access-pipeline"></a>
|
|
76
152
|
## @forgezero/access/pipeline
|
|
77
153
|
|
|
78
|
-
The framework-neutral route, principal, factor, policy, rate-limit and effects pipeline.
|
|
154
|
+
The framework-neutral route, principal, factor, policy, rate-limit and effects pipeline. Named value imports: createPipeline, defineHandlers, windowSeconds. Named type imports: Handler, HandlerRegistry, Pipeline, PipelineOptions, RateStore, SessionResolver, StepUpStore, Telemetry, Validator. Import only the names used by this file.
|
|
79
155
|
|
|
80
156
|
```text
|
|
81
|
-
import
|
|
157
|
+
import { createPipeline, defineHandlers, windowSeconds } from '@forgezero/access/pipeline';
|
|
158
|
+
import type { Handler, HandlerRegistry, Pipeline, PipelineOptions, RateStore, SessionResolver } from '@forgezero/access/pipeline';
|
|
159
|
+
import type { StepUpStore, Telemetry, Validator } from '@forgezero/access/pipeline';
|
|
82
160
|
```
|
|
83
161
|
|
|
162
|
+
<a id="forgezero-access-elysia"></a>
|
|
84
163
|
## @forgezero/access/elysia
|
|
85
164
|
|
|
86
|
-
Elysia integration over the same access pipeline and route declarations.
|
|
165
|
+
Elysia integration over the same access pipeline and route declarations. Named value imports: elysia, forbiddenTelemetryAttribute, telemetryFrom, toElysiaPath. Named type imports: ElysiaAdapterOptions, OtelTracer. Import only the names used by this file.
|
|
87
166
|
|
|
88
167
|
```text
|
|
89
|
-
import
|
|
168
|
+
import { elysia, forbiddenTelemetryAttribute, telemetryFrom, toElysiaPath } from '@forgezero/access/elysia';
|
|
169
|
+
import type { ElysiaAdapterOptions, OtelTracer } from '@forgezero/access/elysia';
|
|
90
170
|
```
|
|
91
171
|
|
|
172
|
+
<a id="forgezero-access-client"></a>
|
|
92
173
|
## @forgezero/access/client
|
|
93
174
|
|
|
94
|
-
Typed client helpers that fulfil factors without duplicating the security matrix.
|
|
175
|
+
Typed client helpers that fulfil factors without duplicating the security matrix. Named value imports: buildPath, createClient. Named type imports: ChallengeHandler, ClientOptions, ClientResult, Problem, RequestArgs, SecurityChallenge. Import only the names used by this file.
|
|
95
176
|
|
|
96
177
|
```text
|
|
97
|
-
import
|
|
178
|
+
import { buildPath, createClient } from '@forgezero/access/client';
|
|
179
|
+
import type { ChallengeHandler, ClientOptions, ClientResult, Problem, RequestArgs, SecurityChallenge } from '@forgezero/access/client';
|
|
98
180
|
```
|
|
99
181
|
|
|
182
|
+
<a id="forgezero-access-testing"></a>
|
|
100
183
|
## @forgezero/access/testing
|
|
101
184
|
|
|
102
|
-
Deterministic access-pipeline fixtures and assertions for consumer tests.
|
|
185
|
+
Deterministic access-pipeline fixtures and assertions for consumer tests. Named value imports: reachableRoutes, simulate, unreachableRoutes. Named type imports: SimulateArgs, Verdict. Import only the names used by this file.
|
|
103
186
|
|
|
104
187
|
```text
|
|
105
|
-
import
|
|
188
|
+
import { reachableRoutes, simulate, unreachableRoutes } from '@forgezero/access/testing';
|
|
189
|
+
import type { SimulateArgs, Verdict } from '@forgezero/access/testing';
|
|
106
190
|
```
|
|
107
191
|
|
|
192
|
+
<a id="forgezero-access-header"></a>
|
|
108
193
|
## @forgezero/access/header
|
|
109
194
|
|
|
110
|
-
Strict configurable header-identity extraction with canonical names and bounded values.
|
|
195
|
+
Strict configurable header-identity extraction with canonical names and bounded values. Named value imports: defineHeaderIdentitySources, headerIdentityResolver. Named type imports: HeaderAssignmentResolver, HeaderIdentity, HeaderIdentitySource, HeaderPrincipal. Import only the names used by this file.
|
|
111
196
|
|
|
112
197
|
```text
|
|
113
|
-
import
|
|
198
|
+
import { defineHeaderIdentitySources, headerIdentityResolver } from '@forgezero/access/header';
|
|
199
|
+
import type { HeaderAssignmentResolver, HeaderIdentity, HeaderIdentitySource, HeaderPrincipal } from '@forgezero/access/header';
|
|
114
200
|
```
|
|
115
201
|
|
|
202
|
+
<a id="forgezero-access-principal"></a>
|
|
116
203
|
## @forgezero/access/principal
|
|
117
204
|
|
|
118
|
-
Generic principal-source resolution for browser, API-key, attestation or future identity adapters.
|
|
205
|
+
Generic principal-source resolution for browser, API-key, attestation or future identity adapters. Named value imports: assignmentIsActive, decidePrincipalAccess, defineRbacPrincipal, touchPrincipalAssignment. Named type imports: PrincipalAccessDecision, PrincipalAssignment, RbacPrincipal. Import only the names used by this file.
|
|
119
206
|
|
|
120
207
|
```text
|
|
121
|
-
import
|
|
208
|
+
import { assignmentIsActive, decidePrincipalAccess, defineRbacPrincipal, touchPrincipalAssignment } from '@forgezero/access/principal';
|
|
209
|
+
import type { PrincipalAccessDecision, PrincipalAssignment, RbacPrincipal } from '@forgezero/access/principal';
|
|
122
210
|
```
|
|
123
211
|
|
|
212
|
+
<a id="forgezero-access-principal-session"></a>
|
|
124
213
|
## @forgezero/access/principal-session
|
|
125
214
|
|
|
126
|
-
Short-lived scope-bound delegated-principal sessions with sliding and absolute expiry.
|
|
215
|
+
Short-lived scope-bound delegated-principal sessions with sliding and absolute expiry. Named value imports: DEFAULT_PRINCIPAL_ABSOLUTE_TTL_MS, DEFAULT_PRINCIPAL_IDLE_TTL_MS, MAX_PRINCIPAL_ABSOLUTE_TTL_MS, MAX_PRINCIPAL_IDLE_TTL_MS, authenticatePrincipalSession, issuePrincipalSession, principalSessionIsActive, touchPrincipalSession. Named type imports: IssuedPrincipalSession, PrincipalSessionRecord. Import only the names used by this file.
|
|
127
216
|
|
|
128
217
|
```text
|
|
129
|
-
import
|
|
218
|
+
import { DEFAULT_PRINCIPAL_ABSOLUTE_TTL_MS, DEFAULT_PRINCIPAL_IDLE_TTL_MS, MAX_PRINCIPAL_ABSOLUTE_TTL_MS, MAX_PRINCIPAL_IDLE_TTL_MS, authenticatePrincipalSession, issuePrincipalSession } from '@forgezero/access/principal-session';
|
|
219
|
+
import { principalSessionIsActive, touchPrincipalSession } from '@forgezero/access/principal-session';
|
|
220
|
+
import type { IssuedPrincipalSession, PrincipalSessionRecord } from '@forgezero/access/principal-session';
|
|
130
221
|
```
|
|
131
222
|
|
|
223
|
+
<a id="forgezero-access-authenticator"></a>
|
|
132
224
|
## @forgezero/access/authenticator
|
|
133
225
|
|
|
134
|
-
Authentication-source contracts for adding identity mechanisms without changing route policy.
|
|
226
|
+
Authentication-source contracts for adding identity mechanisms without changing route policy. Named value imports: createAuthenticator, encoding. Named type imports: AuthenticationOptions, AuthenticationResponse, Authenticator, AuthenticatorOptions, Credential, RegistrationOptions, RegistrationResponse. Import only the names used by this file.
|
|
135
227
|
|
|
136
228
|
```text
|
|
137
|
-
import
|
|
229
|
+
import { createAuthenticator, encoding } from '@forgezero/access/authenticator';
|
|
230
|
+
import type { AuthenticationOptions, AuthenticationResponse, Authenticator, AuthenticatorOptions, Credential, RegistrationOptions } from '@forgezero/access/authenticator';
|
|
231
|
+
import type { RegistrationResponse } from '@forgezero/access/authenticator';
|
|
138
232
|
```
|
|
139
233
|
|
|
234
|
+
<a id="forgezero-access-ceremony-modes"></a>
|
|
140
235
|
## @forgezero/access/ceremony-modes
|
|
141
236
|
|
|
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.
|
|
237
|
+
Named security-ceremony modes and their session/action fulfilment semantics. Named value imports: MAX_CUSTODIANS, THRESHOLD_MODES, thresholdMode. Named type imports: ThresholdMode, ThresholdModeId. Import only the names used by this file.
|
|
151
238
|
|
|
152
239
|
```text
|
|
153
|
-
import {
|
|
154
|
-
|
|
155
|
-
export const routes = defineRoutes({
|
|
156
|
-
orders: page('Orders'),
|
|
157
|
-
'api/orders': action('List orders', 'GET', { page: 'orders' })
|
|
158
|
-
});
|
|
240
|
+
import { MAX_CUSTODIANS, THRESHOLD_MODES, thresholdMode } from '@forgezero/access/ceremony-modes';
|
|
241
|
+
import type { ThresholdMode, ThresholdModeId } from '@forgezero/access/ceremony-modes';
|
|
159
242
|
```
|
|
160
243
|
|
|
161
244
|
## 1. Install
|
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.4";
|
|
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.4";
|
|
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.4",
|
|
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",
|