Skip to content

feat(permission): add schemas for permissions, role mappings and token claims - #154

Merged
Bccorb merged 1 commit into
mainfrom
feat/permission-schemas
Nov 6, 2026
Merged

Bccorb merged 1 commit into
mainfrom
feat/permission-schemas

Conversation

@Bccorb

@Bccorb Bccorb commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Closes #98. Part of the v0.23 Wave 3 work on fells-code/seamless-auth-api#415 and #416.

Why this lands first

The API re-exports its route schemas from this package and parses responses through them, so it cannot build the new routes, or return the new /users/me fields, until this is published. The API PRs follow on the published version.

What

  • Schemas for permissions, role mappings and the organization role catalogue, in schemas/permission
  • AccessTokenClaimsSchema: permissions, org_roles, org_permissions and permissions_omitted beside the existing claims. It is a loose object, so a verifier does not refuse a claim added later
  • EffectivePermissionsResponseSchema for GET /users/me/permissions
  • hasPermission (any of) and hasAllPermissions (all of), matching exactly. Both refuse an empty requirement, so a guard built from an empty list cannot open a route. Also available without Zod from @seamless-auth/types/permission/matching
  • Optional permission and organization role fields on MeUserSchema and SeamlessAuthUserSchema, which an older API does not send
  • New audit event types in AUTH_EVENT_TYPES

Permission names use the role alphabet, which has no *, so a wildcard cannot be stored as a grant that exact matching would never honor. RoleDefinitionSchema and the role path params accept any membership role string, because the migration keeps legacy names like Team Lead as they are. New organization roles are held to the role name pattern.

Testing

npm test (27 files, all passing), typecheck, lint, format:check, build and test:zod-floor all passed locally.

The API branch was also built against a tarball of this package, and its unit and Postgres suites pass against it. That tarball predates one comment-only edit to AccessTokenClaimsSchema. The API branch is not pushed yet because it needs the published version.

After merge

Merging this and its Version Packages PR publishes the version the API PRs pin. AUTH_EVENT_TYPES gains values, so an exhaustive switch over AuthEventType has to handle them. No system config key is added, so the CLI WRITABLE_KEYS test does not trip.

…n claims

Adds the contract for permissions and organization roles: the catalogue and
mapping requests and responses, the access token's authorization claims, the
live permissions response, and exact permission matching with a Zod-free
subpath. MeUser and SeamlessAuthUser gain optional fields for the same data.

Closes #98.
@Bccorb Bccorb added this to the v0.23 milestone Nov 6, 2026
@Bccorb
Bccorb merged commit 06ec50c into main Nov 6, 2026
5 checks passed
@Bccorb
Bccorb deleted the feat/permission-schemas branch November 6, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: schemas for permissions and role mappings

1 participant