Skip to content

feat(session): --scopes flag on create/authorize/revoke - #670

Open
jennijuju wants to merge 2 commits into
masterfrom
feat/session-scopes
Open

feat(session): --scopes flag on create/authorize/revoke#670
jennijuju wants to merge 2 commits into
masterfrom
feat/session-scopes

Conversation

@jennijuju

Copy link
Copy Markdown
Member

allow users to better control session key scopes and manage their operations respectively

Session create and authorize granted all four FWSS permissions and revoke
removed all of them, with no way to choose a subset from the CLI. Add
--scopes <ids> to all three (default unchanged: all permissions), so an
owner can mint or revoke a least-privilege key.

Canonical scope ids match FWSS scope (createDataSet, addPieces, schedulePieceRemovals, terminateService) with short aliases (create, add, remove/delete, terminate) are accepted as a typing shortcut. Parsing is case-insensitive, dedupes, rejects unknown tokens with the valid list, and the granted/revoked scopes are shown in the confirmation.
@jennijuju
jennijuju requested a review from SgtPooki as a code owner August 25, 2026 16:46
@jennijuju
jennijuju requested a review from BigLep August 25, 2026 16:46
@FilOzzy FilOzzy added team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board. labels Aug 25, 2026
@FilOzzy FilOzzy added this to FOC Aug 25, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 25, 2026
@FilOzzy FilOzzy moved this from 📌 Triage to 🔎 Awaiting review in FOC Aug 25, 2026
@BigLep
BigLep requested a lite review from Copilot August 26, 2026 04:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a --scopes flag to the session create, session authorize, and session revoke CLI flows so users can grant/revoke a subset of FWSS permissions instead of always using the full default set. This fits the codebase by extending the existing session CLI runners and core session permission model with a small parsing/normalization layer and corresponding unit tests.

Changes:

  • Introduces src/session/scopes.ts to define canonical scope IDs, aliases, and parsing/formatting helpers.
  • Plumbs optional parsed permissions into session create/authorize/revoke runners (and surfaces the chosen scopes in CLI output).
  • Adds unit tests for scope parsing/description, plus CLI/README documentation updates.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/test/unit/session-scopes.test.ts Adds unit coverage for scope parsing, ordering, aliasing, and rendering.
src/session/types.ts Extends session CLI option types with scopes?: string.
src/session/scopes.ts New scope registry + parseScopes/describeScopes helpers.
src/session/run-revoke.ts Parses --scopes and conditionally passes permissions to revocation.
src/session/run-create.ts Parses --scopes and conditionally passes permissions to session key creation/authorization.
src/session/run-authorize.ts Parses --scopes and conditionally passes permissions to authorization.
src/commands/session.ts Wires --scopes into commander options/help text for create/authorize/revoke.
README.md Documents scoped session keys and gives usage examples.
Suppressed comments (2)

src/commands/session.ts:42

  • The --scopes help text has inconsistent spacing (e.g. remove, delete,terminate) which is easy to misread/copy. Consider normalizing the comma/space formatting.
    'Comma-separated permissions to grant (default: all). Any of: createDataSet,addPieces,schedulePieceRemovals,terminateService (aliases: create,add,remove, delete,terminate)'

src/commands/session.ts:61

  • The --scopes help text has inconsistent spacing (e.g. remove, delete,terminate) which is easy to misread/copy. Consider normalizing the comma/space formatting.
    'Comma-separated permissions to revoke (default: all). Any of: createDataSet,addPieces,schedulePieceRemovals,terminateService (aliases: create,add,remove, delete,terminate)'

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/session/run-create.ts Outdated
Comment thread src/session/run-authorize.ts Outdated
Comment thread src/session/run-revoke.ts Outdated
Comment thread src/commands/session.ts Outdated

@BigLep BigLep left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually makes sense to me. I'll leave to agent and Russell to actually certify the code. Happy to spend more time on this though if useful.

Comment thread README.md
Comment on lines +196 to +197
# schedulePieceRemovals, terminateService (short aliases: create, add,
# remove, delete, terminate). E.g. --scopes add,create or --scopes remove.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the alias concept given this is a low-usage API (I assume). Your call, but I would simplify and not include it.

Also, it's not obvious to me how we have 4 verbose scopes:

createDataSet, addPieces, schedulePieceRemovals, terminateService

but 5 aliases:

create, add, remove, delete, terminate

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/filecoin-pin@670

commit: 360be6f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team/filecoin-pin "Filecoin Pin" project is a stakeholder for this work. team/fs-wg FOC working group is a stakeholder for this work, and thus wants to track it on their project board.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants