vouchly 0.0.0 → 0.1.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 +323 -3
- package/dist/index.d.mts +365 -0
- package/dist/index.mjs +722 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +54 -4
package/README.md
CHANGED
|
@@ -1,5 +1,325 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/tada5hi/vouchly/master/.github/assets/logo.svg" alt="" width="96" height="96">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">vouchly</h1>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Verify OAuth2 and OIDC tokens against trusted issuers: JWT, introspection and certificate-bound tokens, on any Web runtime.</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
You list the issuers you trust. vouchly picks the right one per token, finds its key, checks the claims and tells you why a token was refused.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://npmjs.com/package/vouchly"><img src="https://badge.fury.io/js/vouchly.svg" alt="npm version"></a>
|
|
17
|
+
<a href="https://github.com/tada5hi/vouchly/actions/workflows/main.yml"><img src="https://github.com/tada5hi/vouchly/actions/workflows/main.yml/badge.svg" alt="CI"></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="#why-vouchly">Why</a> ·
|
|
22
|
+
<a href="#installation">Installation</a> ·
|
|
23
|
+
<a href="#usage">Usage</a> ·
|
|
24
|
+
<a href="#issuer-options">Options</a> ·
|
|
25
|
+
<a href="#errors">Errors</a> ·
|
|
26
|
+
<a href="#api">API</a> ·
|
|
27
|
+
<a href="#notes">Notes</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Why vouchly?
|
|
33
|
+
|
|
34
|
+
A service that accepts tokens from more than one place (your own identity provider, GitHub Actions, a partner's OIDC provider) ends up writing the same code each time: decode the token, look at `iss`, find the JWKS for that issuer, refuse a key that should never verify anything, check `aud` and `exp`, maybe ask an introspection endpoint instead, cache the answer, and turn a dozen library errors into something an HTTP handler can map. Each of those steps has a well-known way to get it wrong.
|
|
35
|
+
|
|
36
|
+
| Concern | Without it | With vouchly |
|
|
37
|
+
|---------|------------|-------------|
|
|
38
|
+
| Which issuer? | Read `iss` yourself and branch | An allowlist of `Issuer` configs; an unknown `iss` fails with `issuer_untrusted` before any request goes out |
|
|
39
|
+
| Where the keys come from | Wire `jwks_uri` per issuer by hand | `discovery()` reads it from the issuer's `/.well-known/openid-configuration`; `jwks()`, `staticKeys()` and `cachedKeys()` for everything else |
|
|
40
|
+
| Algorithm confusion | Hope the allowed algorithms are set everywhere | Symmetric keys and RSA keys under 2048 bits are refused; a JWK that names its `alg` decides the algorithm, one without is imported with the header's `alg`, restricted to what its key type supports, and `algorithms` pins it |
|
|
41
|
+
| Malformed input | Whatever the decoder tolerates | Exactly three base64url segments, no padding, no whitespace, checked before the cache or any key lookup |
|
|
42
|
+
| Opaque and revocable tokens | A second code path with its own HTTP client | `verification: 'remote'` per issuer (RFC 7662), with a cache bound you choose |
|
|
43
|
+
| Certificate-bound tokens | Compare `cnf.x5t#S256` yourself, and remember it on cache hits | RFC 8705 binding checked on every call, cache hits included, failing closed |
|
|
44
|
+
| Repeated verification | Cache the decoded payload and hope it expires | A bounded cache keyed by the token's SHA-256, never kept past `exp` |
|
|
45
|
+
| Errors | jose errors, `TypeError`s, fetch failures | One `VouchlyError` with one of nine codes, the original kept as `cause` |
|
|
46
|
+
|
|
47
|
+
The same verifier accepts tokens from GitHub Actions and from your own provider; each issuer keeps its own rules:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { createVerifier } from 'vouchly';
|
|
51
|
+
|
|
52
|
+
const verifier = createVerifier({
|
|
53
|
+
issuers: [
|
|
54
|
+
{
|
|
55
|
+
id: 'github',
|
|
56
|
+
issuer: 'https://token.actions.githubusercontent.com',
|
|
57
|
+
audience: 'https://api.example.com',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'internal',
|
|
61
|
+
issuer: 'https://id.example.com',
|
|
62
|
+
audience: 'api',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const { claims, issuer } = await verifier.verify(token);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
<p align="center">
|
|
71
|
+
<img src="https://raw.githubusercontent.com/tada5hi/vouchly/master/.github/assets/verify.svg" alt="verify(token) parses the token strictly, looks up its SHA-256 in the token cache, selects a trusted issuer from the unverified iss claim, verifies the token locally with the issuer's key source or by RFC 7662 introspection, and finally checks the RFC 8705 certificate binding. A cache hit skips the key lookup and the signature, not the verifier's claim rules, then goes on to the binding check. Each step fails with its own VouchlyError code: token_malformed, issuer_untrusted, key_unavailable or signature_invalid or claim_invalid or introspection_failed, and binding_mismatch. Nothing is fetched before an issuer is selected." width="100%">
|
|
72
|
+
</p>
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install vouchly
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- ESM only, with TypeScript declarations included.
|
|
81
|
+
- Node.js `>= 22`. The source uses Web APIs only (`fetch`, WebCrypto, `TextEncoder`) and imports no `node:*` module, so it also runs on other Web runtimes.
|
|
82
|
+
- One runtime dependency: [`jose`](https://github.com/panva/jose).
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
### GitHub Actions OIDC tokens
|
|
87
|
+
|
|
88
|
+
A string `issuer` is matched exactly against `iss`, and its keys are found through OIDC discovery. A `claims` predicate adds rules of your own; it runs after the signature and the standard claims were checked, so it only ever sees verified claims.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { createVerifier, isVouchlyError } from 'vouchly';
|
|
92
|
+
|
|
93
|
+
const verifier = createVerifier({
|
|
94
|
+
issuers: [
|
|
95
|
+
{
|
|
96
|
+
id: 'github',
|
|
97
|
+
issuer: 'https://token.actions.githubusercontent.com',
|
|
98
|
+
audience: 'https://deploy.example.com',
|
|
99
|
+
claims: (claims) => claims.repository === 'acme/website' &&
|
|
100
|
+
claims.ref === 'refs/heads/main',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const { claims } = await verifier.verify(token);
|
|
107
|
+
console.log(`deploy requested by ${claims.actor}`);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
if (isVouchlyError(e)) {
|
|
110
|
+
console.log(e.code); // e.g. 'claim_invalid'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
throw e;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- The predicate must return `true`. Anything else, or a throw, fails as `claim_invalid`.
|
|
118
|
+
- `audience` is passed to jose: some `aud` value must be one of the configured ones.
|
|
119
|
+
|
|
120
|
+
### Many issuers behind one pattern
|
|
121
|
+
|
|
122
|
+
When issuers appear at runtime (one per tenant or realm), match `iss` with a function and supply the keys yourself. The function sees **unverified** claims: it only selects this config and never replaces verification. Because a function issuer has no fixed URL, `discovery()` refuses it, and the constructor requires a `keys` source.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import type { JWK } from 'jose';
|
|
126
|
+
import { cachedKeys, createVerifier } from 'vouchly';
|
|
127
|
+
|
|
128
|
+
const baseUrl = 'https://auth.example.com';
|
|
129
|
+
|
|
130
|
+
const verifier = createVerifier({
|
|
131
|
+
issuers: [
|
|
132
|
+
{
|
|
133
|
+
id: 'realms',
|
|
134
|
+
issuer: (claims) => typeof claims.iss === 'string' &&
|
|
135
|
+
claims.iss.startsWith(`${baseUrl}/realms/`),
|
|
136
|
+
keys: cachedKeys(
|
|
137
|
+
async ({ token, fetch }) => {
|
|
138
|
+
const realm = String(token.claims.realm_id).toLowerCase();
|
|
139
|
+
const kid = String(token.header.kid).toLowerCase();
|
|
140
|
+
const response = await fetch(`${baseUrl}/realms/${encodeURIComponent(realm)}/jwks/${encodeURIComponent(kid)}`);
|
|
141
|
+
if (!response.ok) {
|
|
142
|
+
throw new Error(`The key endpoint answered ${response.status}.`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return await response.json() as JWK;
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
key: ({ token }) => `${String(token.claims.realm_id)}:${String(token.header.kid)}`,
|
|
149
|
+
ttl: 300,
|
|
150
|
+
},
|
|
151
|
+
),
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
- The loader only builds URLs from your own `baseUrl`. Never fetch from a URL taken out of the token.
|
|
158
|
+
- `cachedKeys` shares one in-flight load per cache key, keeps a key for `ttl` seconds (default 300), gives up after `timeout` seconds (default 10) and holds at most `max` keys (default 100, an integer of at least 1). A failed load is never cached.
|
|
159
|
+
- Whatever a key source returns still passes the key policy: a JWK with `kty: oct`, a `use` other than `sig`, or an RSA key under 2048 bits fails as `key_unavailable`.
|
|
160
|
+
|
|
161
|
+
### Key sources
|
|
162
|
+
|
|
163
|
+
| Source | Use it for |
|
|
164
|
+
|--------|------------|
|
|
165
|
+
| `discovery({ cacheMaxAge })` | Default for a string `issuer`. Reads `jwks_uri` from `<issuer>/.well-known/openid-configuration`, which must name the same `issuer`. Metadata is reused for `cacheMaxAge` seconds (default 600); after a failed fetch the issuer is not asked again for 30 seconds, and keys fail fast as `key_unavailable` meanwhile. |
|
|
166
|
+
| `jwks(url, { cacheMaxAge, cooldownDuration, timeoutDuration })` | A known JWKS URL. Wraps jose's `createRemoteJWKSet`; the three options are milliseconds, as in jose. |
|
|
167
|
+
| `staticKeys(keys)` | Keys you ship with the service, as JWKs. |
|
|
168
|
+
| `cachedKeys(load, { key, ttl, timeout, max })` | A custom loader, with a per-key TTL and shared in-flight loads. |
|
|
169
|
+
|
|
170
|
+
A key source is any `(context) => Promise<CryptoKey | JWK>`; `context` carries the parsed token, the matched issuer and the verifier's `fetch`.
|
|
171
|
+
|
|
172
|
+
### Introspection
|
|
173
|
+
|
|
174
|
+
Set `verification: 'remote'` to ask the issuer about each token (RFC 7662) instead of checking a signature. This is the way to notice a revoked token before it expires, and the only way to accept opaque tokens.
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { createVerifier } from 'vouchly';
|
|
178
|
+
|
|
179
|
+
const verifier = createVerifier({
|
|
180
|
+
issuers: [
|
|
181
|
+
{
|
|
182
|
+
id: 'id-provider',
|
|
183
|
+
issuer: 'https://id.example.com',
|
|
184
|
+
verification: 'remote',
|
|
185
|
+
introspection: {
|
|
186
|
+
authorization: { clientId: 'resource-server', clientSecret: process.env.CLIENT_SECRET! },
|
|
187
|
+
maxCacheTTL: 30,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
opaque: 'id-provider',
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
- The endpoint is `introspection.endpoint`, else the `introspection_endpoint` discovered for a string `issuer`. A function issuer needs an explicit `endpoint`.
|
|
196
|
+
- `authorization` is either client credentials, sent as HTTP Basic, or a function returning the whole `Authorization` header value (for a bearer token of your own). The function receives `{ retry }`: after a `401` it is called again with `retry: true`, so it can mint a fresh token, and the request is repeated once. Client credentials are not retried.
|
|
197
|
+
- `active` other than `true` fails as `token_inactive`; a failed request, a non-2xx answer or a body that is not a JSON object fails as `introspection_failed`. For a non-2xx answer the error carries the HTTP status as `error.status`.
|
|
198
|
+
- The issuer's `audience` and `claims` predicate apply to the introspection response too.
|
|
199
|
+
- `opaque` names the issuer that introspects tokens which are not JWTs at all. Without it, such a token fails as `token_malformed`.
|
|
200
|
+
- A result is cached for the shorter of `exp - now` and `maxCacheTTL` seconds; with neither, it is not cached.
|
|
201
|
+
|
|
202
|
+
### Certificate-bound tokens
|
|
203
|
+
|
|
204
|
+
A token carrying `cnf` is bound to a client certificate (RFC 8705). Pass the SHA-256 thumbprint of the certificate the caller presented, base64url encoded:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
const { claims } = await verifier.verify(token, {
|
|
208
|
+
certificateThumbprint: () => thumbprintOf(request),
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
- A token with `cnf` fails as `binding_mismatch` unless `cnf.x5t#S256` equals the thumbprint. That includes a `cnf` that carries no `x5t#S256` at all, such as a DPoP `jkt`.
|
|
213
|
+
- A function is only called for a bound token, so it costs nothing for the rest.
|
|
214
|
+
- The check runs on every call, also when the result comes from the cache.
|
|
215
|
+
- A JWT verified by introspection is held to its own `cnf` as well as the response's: the token's claims are unverified, so they can only add a requirement. When either carries a thumbprint, the presented one must match every thumbprint present.
|
|
216
|
+
|
|
217
|
+
### Caching
|
|
218
|
+
|
|
219
|
+
By default each verifier keeps its own `MemoryTokenCache` with up to 10000 entries (least recently used first out; `max` must be an integer of at least 1). Pass `cache: false` to turn it off, or your own `ITokenCache` to share results between processes, for example between replicas of one service. A cache you pass in needs a `cacheNamespace`, and every verifier using that namespace must have the same issuer configuration: a cache hit skips the key lookup and the signature check, so an entry is only as trustworthy as the configuration that wrote it.
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
import type { ITokenCache, TokenCacheEntry } from 'vouchly';
|
|
223
|
+
import { createVerifier } from 'vouchly';
|
|
224
|
+
|
|
225
|
+
declare const redis: {
|
|
226
|
+
get(key: string): Promise<string | null>,
|
|
227
|
+
set(key: string, value: string, options: { EX: number }): Promise<unknown>,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const cache: ITokenCache = {
|
|
231
|
+
async get(key) {
|
|
232
|
+
const value = await redis.get(`vouchly:${key}`);
|
|
233
|
+
return value ? JSON.parse(value) as TokenCacheEntry : undefined;
|
|
234
|
+
},
|
|
235
|
+
async set(key, entry, ttl) {
|
|
236
|
+
if (ttl > 0) {
|
|
237
|
+
await redis.set(`vouchly:${key}`, JSON.stringify(entry), { EX: Math.ceil(ttl) });
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const verifier = createVerifier({
|
|
243
|
+
issuers: [{ issuer: 'https://id.example.com' }],
|
|
244
|
+
cache,
|
|
245
|
+
cacheNamespace: 'orders-api',
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
- The key is the hex SHA-256 of the verifier's `cacheNamespace` (which may not contain NUL), a NUL character and the token, so the token itself is never stored as a key.
|
|
250
|
+
- `ttl` is in seconds, fractional, and never runs past the token's `exp`. A local token without `exp` is not cached. A cache that keeps an entry longer (one that rounds `ttl` up, say) still cannot serve it: a hit at or after `exp` (beyond the issuer's `clockTolerance`) fails as `token_expired`.
|
|
251
|
+
- A cache that throws counts as a miss on `get` and is ignored on `set`; it never fails a verification.
|
|
252
|
+
- A cache hit skips the key lookup and the signature check, so it cannot apply this verifier's key source, and the introspection settings of the verifier that wrote the entry are the ones that counted. That is why one namespace means one configuration.
|
|
253
|
+
- As a second line, a hit is still held to the rules that need no key: it is served only under the issuer this verifier would select for the token, and only after this verifier's `audience`, `requiredClaims`, `typ`, `algorithms`, `nbf` (with its `clockTolerance`), `exp` and `claims` predicate passed on the cached entry. A rule that fails gives the same error code as an uncached verify.
|
|
254
|
+
|
|
255
|
+
## Issuer options
|
|
256
|
+
|
|
257
|
+
| Option | Type | Default | Description |
|
|
258
|
+
|--------|------|---------|-------------|
|
|
259
|
+
| `id` | `string` | the issuer's index | Names the config. Required for `opaque`; must be unique. |
|
|
260
|
+
| `issuer` | `string \| (claims) => boolean` | | A string must equal `iss`. A function sees unverified claims and only selects the config; it matches only when it returns exactly `true`. |
|
|
261
|
+
| `keys` | `KeySource` | `discovery()` for a string issuer | Required for a function issuer verified locally. |
|
|
262
|
+
| `verification` | `'local' \| 'remote'` | `'local'` | Check the signature, or ask the introspection endpoint. |
|
|
263
|
+
| `introspection` | `{ endpoint?, authorization?, maxCacheTTL? }` | | See [Introspection](#introspection). `maxCacheTTL` is in seconds. |
|
|
264
|
+
| `audience` | `string \| string[]` | not checked | Some `aud` value must be in the list. |
|
|
265
|
+
| `algorithms` | `string[]` | what the resolved key implies | The key's own `alg` when the JWK names one. A JWK without `alg` is imported with the token header's `alg`, restricted to algorithms its key type supports (an RSA key can then verify `RS*` or `PS*`); set `algorithms` to pin it. |
|
|
266
|
+
| `typ` | `string` | not checked | The expected `typ` header, e.g. `at+jwt`. |
|
|
267
|
+
| `clockTolerance` | `number` | `0` | Seconds of leeway for `exp` and `nbf`. |
|
|
268
|
+
| `requiredClaims` | `string[]` | `['exp']` | Claims that must be present. |
|
|
269
|
+
| `claims` | `(claims) => boolean \| Promise<boolean>` | | Your own rules over the verified claims. |
|
|
270
|
+
|
|
271
|
+
The verifier itself takes `issuers`, `cache` (`ITokenCache` or `false`), `cacheNamespace` (see [Caching](#caching)), `fetch` (defaults to the global `fetch`) and `opaque` (the `id` of the issuer that introspects non-JWT tokens). The constructor throws a `TypeError` for a configuration that cannot work: no issuers, a duplicate `id`, a function issuer verified locally without `keys`, or an `opaque` id that names no issuer.
|
|
272
|
+
|
|
273
|
+
## Errors
|
|
274
|
+
|
|
275
|
+
Every error `verify` throws is a `VouchlyError` with a `code`. The underlying error, when there is one, is kept as `cause`.
|
|
276
|
+
|
|
277
|
+
| Code | When |
|
|
278
|
+
|------|------|
|
|
279
|
+
| `token_malformed` | Not exactly three base64url segments, or a header or payload that is not a JSON object. |
|
|
280
|
+
| `token_expired` | `exp` is in the past (beyond `clockTolerance`). |
|
|
281
|
+
| `token_inactive` | Introspection answered `active` other than `true`. |
|
|
282
|
+
| `issuer_untrusted` | No configured issuer matches `iss`. |
|
|
283
|
+
| `key_unavailable` | Discovery or the key fetch failed, no key matches the `kid`, or the key policy refused the key. |
|
|
284
|
+
| `signature_invalid` | The signature does not verify. |
|
|
285
|
+
| `claim_invalid` | `aud`, `iss`, `typ`, `nbf`, a required claim, the algorithm or the `claims` predicate. |
|
|
286
|
+
| `introspection_failed` | The introspection request failed, answered non-2xx (`error.status` holds the status), or did not answer a JSON object. |
|
|
287
|
+
| `binding_mismatch` | The token is certificate-bound and the presented thumbprint does not match. |
|
|
288
|
+
|
|
289
|
+
Use `isVouchlyError(error)` rather than `instanceof`: it checks a `Symbol.for('vouchly.error')` marker, so it still matches when two copies of vouchly are installed.
|
|
290
|
+
|
|
291
|
+
## API
|
|
292
|
+
|
|
293
|
+
| Export | Kind | Purpose |
|
|
294
|
+
|--------|------|---------|
|
|
295
|
+
| `createVerifier(options)`, `Verifier` | function, class | The verifier; `verify(token, options?)` answers `{ claims, issuer, source }`. |
|
|
296
|
+
| `discovery`, `jwks`, `staticKeys`, `cachedKeys` | functions | Key sources, see [Key sources](#key-sources). |
|
|
297
|
+
| `resolveVerificationKey(source, context)` | function | Runs a key source through the key policy; what the verifier uses. |
|
|
298
|
+
| `fetchProviderMetadata(issuer, fetch, options?)` | function | Reads and checks an issuer's OIDC discovery document. |
|
|
299
|
+
| `introspect(token, issuer, fetch)` | function | One RFC 7662 request; applies no claim rules of its own. |
|
|
300
|
+
| `assertCertificateBinding(claims, thumbprint)` | function | The RFC 8705 check on its own. |
|
|
301
|
+
| `MemoryTokenCache`, `ITokenCache`, `hashToken` | class, interface, function | The default cache, the cache port and the key derivation. |
|
|
302
|
+
| `parseToken`, `isCompactToken` | functions | Strict parsing without verification. |
|
|
303
|
+
| `matchIssuer`, `selectIssuer` | functions | The issuer allowlist on its own. |
|
|
304
|
+
| `VouchlyError`, `VouchlyErrorCode`, `isVouchlyError` | class, enum, function | Errors. |
|
|
305
|
+
|
|
306
|
+
## Notes
|
|
307
|
+
|
|
308
|
+
- **A locally verified token is valid until `exp`.** A signature cannot tell that the token was revoked. If revocation must take effect sooner, use introspection with a short `maxCacheTTL`, or keep access tokens short-lived.
|
|
309
|
+
- **Nothing is fetched from a URL inside the token.** Discovery, JWKS and introspection URLs come from your configuration; a function issuer therefore needs its own key source or an explicit introspection endpoint.
|
|
310
|
+
- **Keys stay in process memory.** `CryptoKey`s cannot be serialised, so key caches (`jwks`, `discovery`, `cachedKeys`) are per process even when the token cache is shared.
|
|
311
|
+
- **Key caches live on the key source instance.** Each `discovery()`, `jwks()` and `cachedKeys()` call creates its own cache, and a string issuer without `keys` gets a `discovery()` of its own per verifier. Discovery metadata is shared by every verifier using the default `fetch` (or the same `fetch` function), but the JWKS behind it is not. If you build verifiers at runtime (one per request, per tenant), create the key source once and pass the same instance to each of them, or every verifier fetches the keys again.
|
|
312
|
+
- **Results are copies.** Every result, including a cache hit, is a fresh `structuredClone`; changing it does not change the cached entry.
|
|
313
|
+
- **No permission model.** vouchly answers whether a token is genuine and which issuer it came from. Deciding what the caller may do is up to you.
|
|
314
|
+
|
|
315
|
+
## Contributing
|
|
316
|
+
|
|
317
|
+
Before starting to work on a pull request, it is important to review the guidelines for
|
|
318
|
+
[contributing](./CONTRIBUTING.md) and the [code of conduct](./CODE_OF_CONDUCT.md).
|
|
319
|
+
These guidelines will help to ensure that contributions are made effectively and are accepted.
|
|
320
|
+
|
|
321
|
+
## License
|
|
322
|
+
|
|
323
|
+
Made with 💚
|
|
324
|
+
|
|
325
|
+
Published under [Apache-2.0 License](./LICENSE).
|