@shivaedev/access 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/package.json +5 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ ## 0.3.1 - 2026-10-31
4
+
5
+ ### Fixed
6
+
7
+ - Include `CHANGELOG.md` in published package contents so release notes are available in `node_modules`.
8
+ - Release checks reject published package `files` lists that omit `CHANGELOG.md`, naming the package and how to include it.
9
+
10
+ ## 0.3.0 - 2026-10-30
11
+
12
+ ### Added
13
+
14
+ - Access exports `AssignRoles` and `LastRoleAssigner` from `@shivaedev/access/roles.ts` for shared role policy declarations.
15
+ - Identity provides `assignRole(access, userId, role)` for trusted seeds and operator commands. Supply `SqlClient` and `Reactivity`; it returns whether storage changed and uses the Users page's PostgreSQL lock, last-role-assigner guard and commit invalidation.
16
+
17
+ ### Breaking
18
+
19
+ - Identity mounts with `roles` close Better Auth's `/admin/set-role`, `/admin/update-user` and `/admin/create-user` HTTP endpoints and set its admin plugin's `adminRoles` to `[]`. Remove that setup from applications. Use the admin Users page for authorized requests and identity's `assignRole` for trusted server commands.
20
+ - Admin consumers import `AssignRoles` and `LastRoleAssigner` from `@shivaedev/access/roles.ts` instead of `@shivaedev/admin/permissions.ts` and `@shivaedev/admin/users/roles.ts`. The Users page uses identity's shared assignment operation; its permission checks, typed refusal and audit log remain.
21
+
22
+ ## 0.2.0 - 2026-10-30
23
+
24
+ ### Added
25
+
26
+ - Access exports the `Permission` Schema and derives its type from it. Role resolution and identity session decoding use that Schema.
27
+ - Access exports `forbidden(permission)` and `unauthorized()` from `refusal.ts` for consistent permission refusals.
28
+
29
+ ### Breaking
30
+
31
+ - `roleSet` refuses a role name declared more than once with a compile error. Previously `hasPermission` granted the union of every declaration's grants while `resolve` returned only the first declaration's, so the two disagreed. Merge the grants of repeated roles into one `role(...)` declaration.
32
+ - `roleSet` now infers its type parameter from the tuple of roles instead of the union of their names, so `typeof roleSet<TName>` no longer names a role set. Replace `ReturnType<typeof roleSet<TName>>` with `AccessPolicy<TName>` from `@shivaedev/access/roleSet.ts`.
33
+ - Access, identity and React now share access's grant evaluator: an `any` grant covers an `own` check for the same permission name. An `own` grant still cannot cover an `any` check. Applications that need separate capabilities must declare separate permission names; record ownership checks still belong in `canAccess` or `requireAccess`.
34
+ - Replace `Access.requirePermission(user, permission)` with `requirePermission(yield* Access.resolve(user.role), permission)` from `@shivaedev/access/requirePermission.ts`. The new function takes a signed-in user; reject an absent session with `unauthorized()` from `@shivaedev/access/refusal.ts` before resolving its role. `requireAccess` continues to handle signed-out users itself.
35
+ - Replace identity's `requirePermission(permission)` with access's `requirePermission(yield* SessionUser, permission)`. There is no identity re-export. Admin's built-in handlers use this shared enforcement.
36
+ - Access's `requireAccess` now uses the shared permission refusal message, `Permission required: <name> (<strength>)`, instead of `Access denied: <name>`. Consumers should branch on the `Forbidden` tag.
37
+
38
+ ## 0.1.2 - 2026-10-30
39
+
40
+ ### Changed
41
+
42
+ - Require Effect 4.0.6 and align the Effect companion package peers and generated starter catalog to the same exact release. Install the 4.0.6 Effect stack together.
43
+
44
+ ### Fixed
45
+
46
+ - Register hosted RPC cache-control handling through Effect 4.0.6's request-scoped pre-response API so responses keep `private, no-store`.
47
+ - Accept native RPC's `application/x-ndjson` media type while preserving `application/ndjson` callers at the transport guard.
48
+ - Keep subscriptions open after their HTTP request body completes; closing the socket still cancels them.
49
+
50
+ ## 0.1.1 - 2026-10-27
51
+
52
+ ### Changed
53
+
54
+ - Read the shared expected failures from `@shivaedev/errors`, the package they moved to from `@shivaedev/contract`.
55
+
56
+ ## 0.1.0 - 2026-10-26
57
+
58
+ ### Added
59
+
60
+ - Declare application permissions, explicit role grants and a closed role-name Schema in the browser-safe `@shivaedev/access` package. Check exact permissions and record ownership with predicates or typed `Forbidden` and `Unauthorized` enforcement effects.
61
+ - Access role sets resolve stored role strings into their decoded role and declared permissions.
62
+ - Platform resolves application roles per request, exposes grants to handlers and the client session, and enforces declared permissions on RPCs and HTTP routes.
63
+
64
+ ### Breaking
65
+
66
+ - Platform removes `requireAdmin`, `hasRole`, `AuthenticatedAdmin`, `AuthenticatedOwner`, their Layers, and `adminRoute`. Declare roles and permissions with `@shivaedev/access`, pass the role set once in `betterAuthMount(options, { roles })` and reuse its returned `sessions`, or configure `sessions.roles` for another provider. Replace role middleware with a class extending `permissionMiddleware<Self>()(id, permission)`, provide `permissionLayer(Middleware, sessions)`, and use `permissionRoute(sessions, permission)` for HTTP routes. Read `SessionUser.permissions` or the client session's `user.permissions` with `hasPermission`; use the application's access policy for record ownership. Unknown stored roles fail visibly and must be migrated to declared strings.
67
+ - Admin pages require `AdminPermission` from `@shivaedev/admin/permissions.ts`. Grant its `OpenAdmin` permission to the application's operator roles and provide `permissionLayer(AdminPermission, sessions)`. User role writes and controls require Platform's `ChangeUserRoles` permission. The existing admin role-list editor and last-owner invariant retain their storage format; declare its stored combinations in the application role set until migrating that editor.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/access",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Browser-safe role declarations and permission checks for Effect applications",
5
5
  "homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/access#readme",
6
6
  "bugs": {
@@ -38,14 +38,15 @@
38
38
  "!src/**/*.spec.ts",
39
39
  "!src/**/*.spec.tsx",
40
40
  "!src/**/test-support",
41
+ "CHANGELOG.md",
41
42
  "README.md"
42
43
  ],
43
44
  "dependencies": {
44
- "@shivaedev/errors": "0.1.2"
45
+ "@shivaedev/errors": "0.1.3"
45
46
  },
46
47
  "devDependencies": {
47
- "@shivaedev/quality": "0.48.0",
48
- "@shivaedev/test-story": "0.26.2",
48
+ "@shivaedev/quality": "0.48.1",
49
+ "@shivaedev/test-story": "0.27.0",
49
50
  "@types/node": "24.19.2",
50
51
  "effect": "4.0.6",
51
52
  "typescript": "7.0.2",