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
--expiredputsexp. 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 tokensigns.
Functions§
- mint
- An HS256 JWT over
{sub, exp[, nbf]}. The header and claim order matchjwt_signer.ts’sJSON.stringifyoutput, so a token is byte-comparable with the test runtime’s. - mint_
with mintwith extra claims, appended afterexp/nbfin the order given.- run
bynk token: list the project’s Bearer actors, or mint one’s token.