Repository navigation
Conversation
Support for new HA Database node
alexcos20
requested review from
bogdanfazakas,
eduard813 and
giurgiur99
as code owners
November 27, 2026 12:02
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scoped auth tokens in the CLI (ocean.js PR #2214)
Brings the scoped auth tokens feature from ocean.js PR #2214
(Feat/scoped auth tokens + OJ-03 issuer verification) to
ocean-cli.Why
In ocean.js v11,
ProviderInstance.generateAuthTokenis a breaking change: it now mints anode-scoped, self-expiring v2 token by default and requires an explicit
validUntil(epochms). The CLI's current call —
— would throw under v11. This PR fixes that (required) and also surfaces the new scoping /
discovery surface to CLI users (optional, additive).
package.jsonpins@oceanprotocol/libto11.0.0-next.2(published on npm; an exactprerelease pin — a
^11.0.0range would not resolve a-nextprerelease).Aquarius→ProviderInstancemigration (ocean.js v11 removedthe
Aquariusclass). That migration landed in ocean-cli Support for new HA Database node #215 (merged torc_3.0.0), so thisbranch must sit on top of
rc_3.0.0.rc_3.0.0(post-Support for new HA Database node #215). When ocean.js cuts the final v11 release, bump thepin from
11.0.0-next.2to it.Validated against published
11.0.0-next.2Verified against the real npm-published
@oceanprotocol/lib@11.0.0-next.2, stacked on the #215migration. Procedure: merge
rc_3.0.0into this branch (onlyCLAUDE.mdconflicts — a doc-onlymerge;
commands.ts/helpers.tsauto-merge), install11.0.0-next.2, runtsc+ the no-infrasuites under Node 24. Results:
tsc --noEmit: clean (exit 0) on the whole project against11.0.0-next.2with the migrationin place (
AuthTokenOptions,AuthTokenPolicy,UNRESTRICTED_AUDIENCE,decodeJwt,listScopableCommands,getNodeAuthTokenPolicyall resolve).parseAuthTokenOptions) + 7 CLI-levelrunRepl(node-freelistScopableCommands/decodeAuthToken, aliases, unsigned-JWT decode, expired/missing/garbagetoken + REPL survival, node-gated
getNodeAuthTokenPolicyrefusal).An earlier build against the pre-release
feat/scoped-auth-tokensbranch also caught two real issuesa diff-only review missed, now fixed: (a)
decodeJwtthrows"Error decoding JWT"(and requires astring
addressclaim) rather than returningnull, sodecodeAuthTokenwraps it in try/catch; (b) astale epoch-ms example value that was already in the past (now a clearly-future value in README/tests).
What changed
generateAuthToken(fixed + extended)Now mints a node-scoped, self-expiring token and exposes the scoping options as flags:
--ttl <seconds>maxTokenLifetime)--valid-until <epochMs>--ttl. Rejected if non-integer, ≤0, or in the past (catches the epoch-seconds-vs-ms footgun)--audience <peerIds>anyfor an unrestricted (reusable, network-wide) token. Omit ⇒ node-scoped (lib defaults to the verified issuer)--scope <commands>--allow-unverified-issuerThe CLI supplies a sensible default
validUntil(ocean.js deliberately refuses to default it), so thebare
generateAuthTokencommand keeps working. It reads the node'sauthTokenPolicy(best-effort)to clamp only the default TTL to the node cap; an explicit
--ttl/--valid-untilis passedthrough verbatim (the lib/node surfaces a precise cap error). The token prints to stdout; the
expiry/audience/scope summary and all warnings go to stderr, so piping captures only the token.
New commands
getNodeAuthTokenPolicy(authTokenPolicy)listScopableCommands(scopableCommands)--scope(static lib catalog)decodeAuthToken(decodeToken)Files
package.json— lib^10.1.0→ pinned11.0.0-next.2(published prerelease).src/helpers.ts— new pureparseAuthTokenOptions(raw, maxTokenLifetimeSeconds?)→AuthTokenOptions, plus theAuthTokenCliOptionstype andDEFAULT_AUTH_TOKEN_TTL_SECONDS = 3600.Handles validUntil/ttl precedence, default-only clamping, audience/scope CSV parsing,
any(case-insensitive), and all the reject cases.
src/commands.ts— rewroteCommands.generateAuthToken(rawOptions)(best-effort policy read→ clamp default TTL → warn on unrestricted /
--allow-unverified-issuer→ mint → summary), addedprivate
printAuthTokenSummary(stderr) andCommands.getNodeAuthTokenPolicy(). New lib imports:AuthTokenOptions,AuthTokenPolicy,UNRESTRICTED_AUDIENCE,decodeJwt.src/cli.ts— added the flags above togenerateAuthToken; registeredgetNodeAuthTokenPolicy,listScopableCommands,decodeAuthToken. The two pure commands are added toNODE_FREE_COMMANDSand
CONFIG_BOOTSTRAP_COMMANDS(names + aliases, so they run with no RPC/signer); all three newcanonical names are added to the
HELP_GROUPS"Tokens & auth" group (required byassertHelpGroupsCoverAll). New lib imports:decodeJwt,listScopableCommands.README.md— rewrote the "Auth tokens" section (new flags, breaking-change note, discoverycommands, stdout/stderr contract, decode≠verify caveat) and the per-command options table.
test/authTokenOptions.test.ts(new, no-infra) — 20 unit tests forparseAuthTokenOptions(precedence, default-only clamp boundaries, audience/scope parsing + throw branches, blank inputs,
integer-floor, past/seconds rejection, full-object build).
test/authTokenCommands.test.ts(new, no-infra,runRepl) — CLI-level tests: node-freelistScopableCommands/decodeAuthToken(incl. bootstrap env-free, aliases, unsigned-JWT decode,expired, missing/garbage token + REPL survival), node-gated
getNodeAuthTokenPolicyrefusalwithout a node, and
generateAuthTokenflag→option wiring validating before any network call.Security notes
--audience any) and--allow-unverified-issuereach print anexplicit
stderrwarning at mint time (not just help text), since both are footguns (a reusablebearer, and trusting a possibly-spoofed node, respectively).
decodeAuthTokenlabels its output "signature NOT verified; treat these claims as untrusted" andguards the
validUntil→Dateconversion against missing/malformed/out-of-range values.input; the token itself is necessarily printed (to stdout) for the user to use.