@softistx/alxia-clavix 0.3.3 → 0.4.1
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 +34 -3
- package/dist/env/env.d.ts +99 -0
- package/dist/env/env.d.ts.map +1 -0
- package/dist/env/index.d.ts +2 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/index.js +142 -0
- package/dist/env/index.js.map +11 -0
- package/dist/env/secret-file.d.ts +8 -0
- package/dist/env/secret-file.d.ts.map +1 -0
- package/dist/guard.d.ts +9 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +163 -6
- package/dist/index.js.map +7 -5
- package/dist/principal.d.ts +6 -2
- package/dist/principal.d.ts.map +1 -1
- package/dist/resource/index.d.ts +3 -0
- package/dist/resource/index.d.ts.map +1 -0
- package/dist/resource/resource.d.ts +20 -0
- package/dist/resource/resource.d.ts.map +1 -0
- package/dist/resource/types.d.ts +100 -0
- package/dist/resource/types.d.ts.map +1 -0
- package/dist/resource/viewer.d.ts +5 -0
- package/dist/resource/viewer.d.ts.map +1 -0
- package/docs/README.md +1 -0
- package/docs/guide/principal-and-scopes.md +6 -0
- package/docs/guide/wiring-an-api.md +145 -0
- package/docs/roadmap.md +2 -0
- package/docs/troubleshooting.md +43 -0
- package/package.json +17 -4
package/docs/troubleshooting.md
CHANGED
|
@@ -21,6 +21,8 @@ startup (`verify` never throws), or the body of a 401 or 403.
|
|
|
21
21
|
- [`TypeError: clavix: dpop.clockSkewSec must be a finite number, 0 or more`](#typeerror-clavix-dpopclockskewsec-must-be-a-finite-number-0-or-more)
|
|
22
22
|
- [`TypeError: clavix: the dpop nonce secret needs 16 characters`](#typeerror-clavix-the-dpop-nonce-secret-needs-16-characters)
|
|
23
23
|
- [`TypeError: clavix: the dpop nonce ttlMs must be a finite number above 0`](#typeerror-clavix-the-dpop-nonce-ttlms-must-be-a-finite-number-above-0)
|
|
24
|
+
- [`Invalid CLAVIX_* environment`](#invalid-clavix_-environment)
|
|
25
|
+
- [`TypeError: clavixResource: scope is one token, without spaces or quotes`](#typeerror-clavixresource-scope-is-one-token-without-spaces-or-quotes)
|
|
24
26
|
- [`TypeError: requireScope: give scopes, each a non-empty token without spaces or quotes`](#typeerror-requirescope-give-scopes-each-a-non-empty-token-without-spaces-or-quotes)
|
|
25
27
|
|
|
26
28
|
**Responses**
|
|
@@ -38,6 +40,8 @@ startup (`verify` never throws), or the body of a 401 or 403.
|
|
|
38
40
|
- [`401 … "reason": "dpop_proof_*"`](#401-reason-dpop_proof_)
|
|
39
41
|
- [`401 … "reason": "dpop_nonce"`](#401-reason-dpop_nonce)
|
|
40
42
|
- [`500` on a request with a DPoP proof](#500-on-a-request-with-a-dpop-proof)
|
|
43
|
+
- [`503 { "error": "unavailable", "reason": "unavailable" }` from `clavixResource().viewer`](#503-unavailable-from-clavixresourceviewer)
|
|
44
|
+
- [`401 … "reason": "inactive"` from `clavixResource().viewer`](#401-inactive-from-clavixresourceviewer)
|
|
41
45
|
- [`403 { "error": "forbidden", "reason": "insufficient_scope" }`](#403-insufficient_scope)
|
|
42
46
|
|
|
43
47
|
**Traps**
|
|
@@ -148,6 +152,30 @@ Give `dpop.replay`: `redisDpopReplayStore(connection.client, { name: 'dpop' })`
|
|
|
148
152
|
|
|
149
153
|
`hmacDpopNonce({ ttlMs })` takes a finite number of milliseconds above 0 (default 300000, 5 minutes).
|
|
150
154
|
|
|
155
|
+
### `Invalid CLAVIX_* environment`
|
|
156
|
+
|
|
157
|
+
`clavixEnv()` (from `@softistx/alxia-clavix/env`) throws a `ClavixEnvError` at start-up, one line per
|
|
158
|
+
refused variable, never a value or a path:
|
|
159
|
+
|
|
160
|
+
| Line | Fix |
|
|
161
|
+
| --- | --- |
|
|
162
|
+
| `CLAVIX_ISSUER: …` | an `https` URL (`http` on localhost outside production) |
|
|
163
|
+
| `CLAVIX_API_ORIGIN: …` | scheme and host only, no path or trailing slash; `https` in production |
|
|
164
|
+
| `CLAVIX_ISSUER`, `CLAVIX_AUDIENCE` or `CLAVIX_API_ORIGIN`: `required` | set it: the API verifies Clavix tokens (`resource: true`) |
|
|
165
|
+
| `CLAVIX_*_SECRET_FILE points at a directory, not a file` | the variable holds the path of the secret file; mount the file, not its folder |
|
|
166
|
+
| `… is readable by group or others (mode 644); restrict it to its owner, such as chmod 600` | `chmod 600` the file; Kubernetes: `defaultMode: 0400` on the secret volume; Compose or Swarm: `mode: 0400` on the secret |
|
|
167
|
+
| `… points at an empty file` | the secret file has no content: write the secret to it |
|
|
168
|
+
| `… points at a file that does not exist or cannot be reached` or `cannot be read` | check the path and the file's owner and mode |
|
|
169
|
+
| `CLAVIX_ISSUER: required when … are set` | a client id or machine client needs the issuer it registered with |
|
|
170
|
+
| `… unset while … is set` | the client id and its secret file go together, as do the machine client's |
|
|
171
|
+
|
|
172
|
+
### `TypeError: clavixResource: scope is one token, without spaces or quotes`
|
|
173
|
+
|
|
174
|
+
`clavixResource({ scope })` takes one scope, such as `'api'`: a token the OAuth grammar allows (RFC 6749
|
|
175
|
+
section 3.3), with no space, quote or backslash. A value like `'read write'` is two scopes and would never
|
|
176
|
+
match one entry of the token's `scope`. Ask for several scopes with `requireScope('read', 'write')` on the
|
|
177
|
+
routes that need them, and keep `scope` for the one scope every token must carry.
|
|
178
|
+
|
|
151
179
|
### `TypeError: requireScope: give scopes, each a non-empty token without spaces or quotes`
|
|
152
180
|
|
|
153
181
|
`requireScope()` got no scope, or one with a space, a quote or a backslash. One argument per scope:
|
|
@@ -253,6 +281,21 @@ Check the Redis connection (`/ready`, the `connectRedis` handle); `Bearer` token
|
|
|
253
281
|
are not affected. `memoryDpopReplayStore` throws `memoryDpopReplayStore: full (use a shared store)`
|
|
254
282
|
past `maxEntries` live proofs: use a shared store.
|
|
255
283
|
|
|
284
|
+
### 503 `unavailable` from `clavixResource().viewer`
|
|
285
|
+
|
|
286
|
+
```json
|
|
287
|
+
{ "error": "unavailable", "reason": "unavailable" }
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The replay store (Redis) or the app's `viewerOf` threw, so the request was not judged. It is an
|
|
291
|
+
outage, not a refusal: check the store, and the `onError` log. With the bare `bearer()` guard the same
|
|
292
|
+
failure is a 500; `clavixResource` answers a 503. A 503 `keys_unavailable` is the issuer's keys.
|
|
293
|
+
|
|
294
|
+
### 401 `inactive` from `clavixResource().viewer`
|
|
295
|
+
|
|
296
|
+
`viewerOf` returned `null`: the token is valid but the app's account is disabled or erased. There is
|
|
297
|
+
no `WWW-Authenticate`, since a new token would not help.
|
|
298
|
+
|
|
256
299
|
### 403 `insufficient_scope`
|
|
257
300
|
|
|
258
301
|
```json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softistx/alxia-clavix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Verify the access tokens an OpenID Connect identity provider issues in an alxia API: a multi-tenant issuer allow-list on the RFC 9068 profile of @softistx/alxia-jwt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"default": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./env": {
|
|
23
|
+
"types": "./dist/env/index.d.ts",
|
|
24
|
+
"import": "./dist/env/index.js",
|
|
25
|
+
"default": "./dist/env/index.js"
|
|
26
|
+
},
|
|
22
27
|
"./package.json": "./package.json"
|
|
23
28
|
},
|
|
24
29
|
"repository": {
|
|
@@ -37,17 +42,25 @@
|
|
|
37
42
|
},
|
|
38
43
|
"alxia": {
|
|
39
44
|
"entrypoints": [
|
|
40
|
-
"src/index.ts"
|
|
45
|
+
"src/index.ts",
|
|
46
|
+
"src/env/index.ts"
|
|
41
47
|
]
|
|
42
48
|
},
|
|
43
49
|
"devDependencies": {
|
|
44
50
|
"@softistx/alxia": "^0.29.1",
|
|
45
51
|
"@softistx/alxia-jwt": "^0.11.0",
|
|
46
|
-
"@types/bun": "^1.4.5"
|
|
52
|
+
"@types/bun": "^1.4.5",
|
|
53
|
+
"zod": "^4.2.0"
|
|
47
54
|
},
|
|
48
55
|
"peerDependencies": {
|
|
49
56
|
"@softistx/alxia": "^0.29.1",
|
|
50
57
|
"@softistx/alxia-jwt": "^0.11.0",
|
|
51
|
-
"typescript": "^6.0.3 || ^7.0.0"
|
|
58
|
+
"typescript": "^6.0.3 || ^7.0.0",
|
|
59
|
+
"zod": "^4.2.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"zod": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
52
65
|
}
|
|
53
66
|
}
|