@forgezero/access 0.1.9 → 0.1.11
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 +1 -1
- package/dist/conditions.d.ts +6 -6
- package/dist/conditions.js +1 -1
- package/dist/effects.d.ts +2 -2
- 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 +2 -2
- 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 +1 -1
package/README.md
CHANGED
|
@@ -555,7 +555,7 @@ Each condition knows which statuses it can produce, so the set a route can answe
|
|
|
555
555
|
```text
|
|
556
556
|
assertDeclaredRefusals({ routes: ROUTES, conditions: CONDITIONS });
|
|
557
557
|
// Undeclared refusals:
|
|
558
|
-
// api/
|
|
558
|
+
// api/compute/allocate can 409 (requireQuota) but does not declare it
|
|
559
559
|
```
|
|
560
560
|
|
|
561
561
|
## Effects: what happens once it is decided
|
package/dist/conditions.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export interface RequireStateOptions<K extends string> extends Routes<K> {
|
|
|
88
88
|
/**
|
|
89
89
|
* The record is in a status this transition accepts, or 409.
|
|
90
90
|
*
|
|
91
|
-
* The guard that stops a
|
|
91
|
+
* The guard that stops a allocation being approved twice, an invoice being
|
|
92
92
|
* settled after it was voided, a ceremony activating from a state it never
|
|
93
93
|
* reached. Checking status inside the handler works right up to the second
|
|
94
94
|
* concurrent request, and this at least fails them both loudly and with the
|
|
@@ -139,7 +139,7 @@ export interface RequireIdempotencyOptions<K extends string> extends Routes<K> {
|
|
|
139
139
|
*
|
|
140
140
|
* A retry after a timeout is not a client bug — it is what every HTTP client and
|
|
141
141
|
* every mobile network does. Without a claim the second attempt places a second
|
|
142
|
-
* order, and the user sees one confirmation for two
|
|
142
|
+
* order, and the user sees one confirmation for two allocations.
|
|
143
143
|
*
|
|
144
144
|
* A replay throws `Settled`, so the caller gets the ORIGINAL answer rather than
|
|
145
145
|
* an error. A 409 would be defensible and useless: a retrying client still would
|
|
@@ -217,7 +217,7 @@ export interface RequireBalanceOptions<K extends string> extends Routes<K> {
|
|
|
217
217
|
* finding that later.
|
|
218
218
|
*
|
|
219
219
|
* This checks AVAILABLE — free of holds — not total. A balance check against
|
|
220
|
-
* total lets two concurrent
|
|
220
|
+
* total lets two concurrent allocations each pass and the second overdraws.
|
|
221
221
|
*/
|
|
222
222
|
export declare function requireBalance<K extends string>(options: RequireBalanceOptions<K>): Condition<K>;
|
|
223
223
|
export interface RequireQuotaOptions<K extends string> extends Routes<K> {
|
|
@@ -232,7 +232,7 @@ export interface RequireQuotaOptions<K extends string> extends Routes<K> {
|
|
|
232
232
|
* A value cap over a window, which is NOT a rate limit.
|
|
233
233
|
*
|
|
234
234
|
* Rate limiting counts requests and protects the service; a quota counts value
|
|
235
|
-
* and protects the account. One
|
|
235
|
+
* and protects the account. One allocation of the entire balance passes every
|
|
236
236
|
* rate limit ever written. They also fail differently — 429 means slow down,
|
|
237
237
|
* this means the answer will be the same until the window rolls — so they get
|
|
238
238
|
* different codes and the reset time is in the payload.
|
|
@@ -252,7 +252,7 @@ export interface RequireApprovalOptions<K extends string> extends Routes<K> {
|
|
|
252
252
|
*
|
|
253
253
|
* Action factors make the actor prove themselves freshly. This makes a second
|
|
254
254
|
* party sign off, and no amount of the first kind substitutes for the second:
|
|
255
|
-
* that is the entire point of four-eyes on a large
|
|
255
|
+
* that is the entire point of four-eyes on a large allocation or a custodian
|
|
256
256
|
* change. Two mechanisms because they answer different questions, and merging
|
|
257
257
|
* them would let a sufficiently authenticated operator approve their own move.
|
|
258
258
|
*/
|
|
@@ -260,7 +260,7 @@ export declare function requireApproval<K extends string>(options: RequireApprov
|
|
|
260
260
|
/**
|
|
261
261
|
* Every status a route's conditions can throw is declared in its contract.
|
|
262
262
|
*
|
|
263
|
-
* The drift this catches: somebody adds `requireQuota` to a
|
|
263
|
+
* The drift this catches: somebody adds `requireQuota` to a allocation route,
|
|
264
264
|
* the generated client never learns 409 is possible, and the UI renders "an
|
|
265
265
|
* unexpected error occurred" for the one refusal a user can actually act on.
|
|
266
266
|
* Cheap to check, invisible until a customer hits it.
|
package/dist/conditions.js
CHANGED
package/dist/effects.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type AfterHandler, type RequestContext } from './index';
|
|
|
10
10
|
*
|
|
11
11
|
* 1. **It cannot fail the request.** The pipeline queues after-handlers and
|
|
12
12
|
* swallows throws, and these swallow their own too. An audit sink being down
|
|
13
|
-
* must not turn a successful
|
|
13
|
+
* must not turn a successful allocation into a 500 — the money already moved.
|
|
14
14
|
*
|
|
15
15
|
* 2. **It runs on refusals as well.** The pipeline calls the chain even when a
|
|
16
16
|
* `before` threw, because a log missing every denied request is missing
|
|
@@ -160,7 +160,7 @@ export interface NotifyOptions<K extends string> extends Routes<K> {
|
|
|
160
160
|
/**
|
|
161
161
|
* Tell somebody. Queued like every effect, never awaited.
|
|
162
162
|
*
|
|
163
|
-
* `onDenied` exists for one real case: a failed sign-in or a refused
|
|
163
|
+
* `onDenied` exists for one real case: a failed sign-in or a refused allocation
|
|
164
164
|
* is exactly what the account holder wants to hear about, and it is the only
|
|
165
165
|
* signal they get that somebody else has their password.
|
|
166
166
|
*/
|
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.11";
|
|
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
|
@@ -49,7 +49,7 @@ export declare class AccessError extends Error {
|
|
|
49
49
|
* A condition refusing the request, with the status it deserves.
|
|
50
50
|
*
|
|
51
51
|
* Without this every guard in a `before` chain collapsed to 500, which is a lie:
|
|
52
|
-
* "this
|
|
52
|
+
* "this allocation is already approved" is a 409 the client can act on, and a
|
|
53
53
|
* 500 tells it to retry — which is precisely the wrong thing to do with money.
|
|
54
54
|
*
|
|
55
55
|
* `retryable` is stated rather than inferred from the status. 409 is permanent
|
|
@@ -379,4 +379,4 @@ export declare function impactOfDisabling<R extends RouteRegistry>(access: Acces
|
|
|
379
379
|
available: number;
|
|
380
380
|
required: number;
|
|
381
381
|
}[];
|
|
382
|
-
export declare const VERSION = "0.1.
|
|
382
|
+
export declare const VERSION = "0.1.11";
|
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.11";
|
|
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