openvibers/openvibe.sdk Commits
openvibe-sdk 0.40.0: createNetworkKeys (the Network signing keys every verifier reads) (#36)
OP OpenVibers committed 10 Oct 2026 · tag v0.40. · 0 files, +0 −0
Plan T1: delete hand-rolled copies. Every service that receives Network tokens had its own key store: one PEM, no kid, a retry timer and a 6 h refresh. Events and OpenRestream had the same code, as do Chat, Live, Media and Bot. This adds the one that stays.
- **New: `createNetworkKeys({ network | jwksUrl, publicKey, fetch, log, retryMs, refreshMs })`** in `openvibe-sdk/auth` (`src/auth/keys.js`).
- **Sources:** a pinned key (`OV_NETWORK_PUBLIC_KEY`) is used as is and never fetched. Otherwise Network's JWKS goes through the process-wide JWKS client: a token naming an unknown kid verifies after one throttled refetch (key rotation), and the last good keys are kept through an outage.
- **Lifecycle:** `start()` fetches at once and retries every 30 s until the first load, because Network may still be booting and the client's backoff would wait minutes. After that it refreshes every 15 minutes. `stop()` clears both timers.
- **Use:** spread `keys.verifyOptions` into `verifyUserToken`, `verifyAppToken` and `verifyServiceToken`. `keys.loaded()` is the readiness check. `keys.keysFor(kid)` returns the keys for a token type a service checks itself, such as Events' realtime tickets; it never throws.
- `verifyUserToken` and `verifyAppToken` accept a JWKS client as `jwks`, as `verifyServiceToken` already did.
- 0.40.0: version, `SDK_VERSION`, changelog, STATUS, README (with an example), types, esm and the browser bundle. The changelog also gets back its missing 0.38.1 heading.
Test: `test/network-keys.test.js` covers:
- a pinned key: loaded at once, never fetched, read by every verifier;
- no source at all: a TypeError;
- retry until loaded, and `token.unavailable` (not a bad token) before then;
- user, app and service tokens all verifying through `verifyOptions`;
- a typed token refused as a session;
- a rotation: one refetch, and `keysFor` sees the new key;
- a rogue key under a published kid: `token.bad_signature`;
- `stop()` ending the retry.
`ov test` is green.
This commit has no diff to show.