Skip to main content

Module token

Module token 

Source
Expand description

bynk token (#2869): mint a credential for the project’s own Bearer actor, for calling a guarded route by hand — curl under bynk dev, or a smoke test against a deployment.

The actor declares everything a minter needs: auth = Bearer(secret = "<ENV>"), HS256, and sub as the identity. This signs the token exactly as the emitted verifier (bynk-emit/src/emitter/runtime/auth.ts) and the test runtime’s signer (runtime/src/testing/jwt_signer.ts) do — the same header, the same sub/exp claims, the same unpadded base64url — so the actor’s seam accepts it. It is a different command from bynk org token mint, which mints a registry publish token.

The secret is read from the environment, under the name the actor declares, and nowhere else: it is never an argument (it would show in a process listing), and it is never printed or put in an error. Only the token goes to stdout, so $(bynk token Reader --sub me) works.

Structs§

Request
What the user asked for, as the CLI parsed it.

Constants§

DEFAULT_LIFETIME_SECS
The default lifetime, in seconds: short, so a hand-minted token is not a long-lived credential by accident.
EXPIRED_BY_SECS
How far in the past --expired puts exp. The emitted verifier allows no clock skew, but a deployment’s clock may differ from this machine’s, so the token is expired by a margin no reasonable skew closes.
MAX_LIFETIME_SECS
The longest lifetime (and the furthest --not-before) bynk token signs.

Functions§

mint
An HS256 JWT over {sub, exp[, nbf]}. The header and claim order match jwt_signer.ts’s JSON.stringify output, so a token is byte-comparable with the test runtime’s.
mint_with
mint with extra claims, appended after exp/nbf in the order given.
run
bynk token: list the project’s Bearer actors, or mint one’s token.