@dudousxd/nestjs-authz 0.6.2 → 0.6.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @dudousxd/nestjs-authz
2
2
 
3
+ ## 0.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c4a1fe8`](https://github.com/DavideCarvalho/nestjs-authz/commit/c4a1fe876f6539446a1dec3bc241164058045bcb) - Derive authz's own DI tokens (`AUTHZ_MODULE_OPTIONS`, `RESOURCE_RESOLVER`, `RESOURCE_HYDRATOR`, `PERMISSION_PROVIDER`, `ROLE_PROVIDER`) from the `capability()` factory instead of hand-rolled `Symbol.for` strings, and add a conformance test (`assertCapabilityNaming`) that locks their canonical naming. Resolves to byte-identical symbols — fully non-breaking.
8
+
3
9
  ## 0.6.2
4
10
 
5
11
  ### Patch Changes
package/dist/tokens.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** Injection token holding the resolved {@link AuthzModuleOptions}. */
2
- export declare const AUTHZ_MODULE_OPTIONS: unique symbol;
2
+ export declare const AUTHZ_MODULE_OPTIONS: symbol;
3
3
  /** Injection token for the optional {@link ResourceResolver} registered by the app. */
4
- export declare const RESOURCE_RESOLVER: unique symbol;
4
+ export declare const RESOURCE_RESOLVER: symbol;
5
5
  /**
6
6
  * Injection token holding the optional resource-loader map consulted by the opt-in
7
7
  * `POST /authz/can` endpoint to rehydrate a `{ type, id }` shim into the REAL entity
@@ -16,7 +16,7 @@ export declare const RESOURCE_RESOLVER: unique symbol;
16
16
  * same key resolves to the SAME symbol instance. Consulted with `@Optional()` — absent
17
17
  * or empty, the endpoint behaves exactly as before (class-level / ad-hoc only).
18
18
  */
19
- export declare const RESOURCE_HYDRATOR: unique symbol;
19
+ export declare const RESOURCE_HYDRATOR: symbol;
20
20
  /** Metadata key for `@Policy(Resource)` — stores the resource class on the policy. */
21
21
  export declare const POLICY_RESOURCE_METADATA = "nestjs-authz:policy-resource";
22
22
  /** Metadata key for `@Can(ability, Resource?)` — stores the ability descriptor on a route. */
@@ -34,7 +34,7 @@ export declare const ROLES_METADATA = "nestjs-authz:roles";
34
34
  * The token is consulted with `@Optional()` — when absent, the Gate behaves exactly
35
35
  * as before (backward-compatible: unknown abilities still throw).
36
36
  */
37
- export declare const PERMISSION_PROVIDER: unique symbol;
37
+ export declare const PERMISSION_PROVIDER: symbol;
38
38
  /**
39
39
  * Cross-lib injection token for an optional {@link RoleProvider} — the seam an RBAC
40
40
  * adapter (`@dudousxd/nestjs-authz-typeorm`) registers so coarse role-checks
@@ -46,7 +46,7 @@ export declare const PERMISSION_PROVIDER: unique symbol;
46
46
  * `@Optional()`: when absent, only the default {@link RoleResolver} (roles read off
47
47
  * the user object) supplies roles. When BOTH yield roles, the Gate unions them.
48
48
  */
49
- export declare const ROLE_PROVIDER: unique symbol;
49
+ export declare const ROLE_PROVIDER: symbol;
50
50
  /**
51
51
  * Cross-lib injection token for the current-request context accessor, owned by
52
52
  * `@dudousxd/nestjs-context`. Resolved via the ecosystem protocol's typed
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,eAAO,MAAM,oBAAoB,eAA+C,CAAC;AAEjF,uFAAuF;AACvF,eAAO,MAAM,iBAAiB,eAAyD,CAAC;AAExF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,eAAyD,CAAC;AAExF,sFAAsF;AACtF,eAAO,MAAM,wBAAwB,iCAAiC,CAAC;AAEvE,8FAA8F;AAC9F,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAE/C,sFAAsF;AACtF,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,eAA2D,CAAC;AAE5F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,eAAqD,CAAC;AAEhF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,QAAoC,CAAC"}
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,eAAO,MAAM,oBAAoB,QAAiC,CAAC;AAEnE,uFAAuF;AACvF,eAAO,MAAM,iBAAiB,QAA2C,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,QAA2C,CAAC;AAE1E,sFAAsF;AACtF,eAAO,MAAM,wBAAwB,iCAAiC,CAAC;AAEvE,8FAA8F;AAC9F,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAE/C,sFAAsF;AACtF,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,QAA6C,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,QAAuC,CAAC;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,QAAoC,CAAC"}
package/dist/tokens.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { capability } from '@dudousxd/nestjs-diagnostics';
2
2
  /** Injection token holding the resolved {@link AuthzModuleOptions}. */
3
- export const AUTHZ_MODULE_OPTIONS = Symbol.for('@dudousxd/nestjs-authz:options');
3
+ export const AUTHZ_MODULE_OPTIONS = capability('authz', 'options');
4
4
  /** Injection token for the optional {@link ResourceResolver} registered by the app. */
5
- export const RESOURCE_RESOLVER = Symbol.for('@dudousxd/nestjs-authz:resource-resolver');
5
+ export const RESOURCE_RESOLVER = capability('authz', 'resource-resolver');
6
6
  /**
7
7
  * Injection token holding the optional resource-loader map consulted by the opt-in
8
8
  * `POST /authz/can` endpoint to rehydrate a `{ type, id }` shim into the REAL entity
@@ -17,7 +17,7 @@ export const RESOURCE_RESOLVER = Symbol.for('@dudousxd/nestjs-authz:resource-res
17
17
  * same key resolves to the SAME symbol instance. Consulted with `@Optional()` — absent
18
18
  * or empty, the endpoint behaves exactly as before (class-level / ad-hoc only).
19
19
  */
20
- export const RESOURCE_HYDRATOR = Symbol.for('@dudousxd/nestjs-authz:resource-hydrator');
20
+ export const RESOURCE_HYDRATOR = capability('authz', 'resource-hydrator');
21
21
  /** Metadata key for `@Policy(Resource)` — stores the resource class on the policy. */
22
22
  export const POLICY_RESOURCE_METADATA = 'nestjs-authz:policy-resource';
23
23
  /** Metadata key for `@Can(ability, Resource?)` — stores the ability descriptor on a route. */
@@ -35,7 +35,7 @@ export const ROLES_METADATA = 'nestjs-authz:roles';
35
35
  * The token is consulted with `@Optional()` — when absent, the Gate behaves exactly
36
36
  * as before (backward-compatible: unknown abilities still throw).
37
37
  */
38
- export const PERMISSION_PROVIDER = Symbol.for('@dudousxd/nestjs-authz:permission-provider');
38
+ export const PERMISSION_PROVIDER = capability('authz', 'permission-provider');
39
39
  /**
40
40
  * Cross-lib injection token for an optional {@link RoleProvider} — the seam an RBAC
41
41
  * adapter (`@dudousxd/nestjs-authz-typeorm`) registers so coarse role-checks
@@ -47,7 +47,7 @@ export const PERMISSION_PROVIDER = Symbol.for('@dudousxd/nestjs-authz:permission
47
47
  * `@Optional()`: when absent, only the default {@link RoleResolver} (roles read off
48
48
  * the user object) supplies roles. When BOTH yield roles, the Gate unions them.
49
49
  */
50
- export const ROLE_PROVIDER = Symbol.for('@dudousxd/nestjs-authz:role-provider');
50
+ export const ROLE_PROVIDER = capability('authz', 'role-provider');
51
51
  /**
52
52
  * Cross-lib injection token for the current-request context accessor, owned by
53
53
  * `@dudousxd/nestjs-context`. Resolved via the ecosystem protocol's typed
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;A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MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,sFAAsF;AACtF,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-authz",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "NestJS authorization — Laravel-style Gates & Policies, @Can guard, resource resolver (zero DB).",
5
5
  "license": "MIT",
6
6
  "repository": {