@spinajs/rbac-http-token 2.0.507

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 (198) hide show
  1. package/README.md +152 -0
  2. package/lib/cjs/actions.d.ts +119 -0
  3. package/lib/cjs/actions.d.ts.map +1 -0
  4. package/lib/cjs/actions.js +257 -0
  5. package/lib/cjs/actions.js.map +1 -0
  6. package/lib/cjs/cli/CreateToken.d.ts +13 -0
  7. package/lib/cjs/cli/CreateToken.d.ts.map +1 -0
  8. package/lib/cjs/cli/CreateToken.js +56 -0
  9. package/lib/cjs/cli/CreateToken.js.map +1 -0
  10. package/lib/cjs/cli/DeleteExpiredTokens.d.ts +11 -0
  11. package/lib/cjs/cli/DeleteExpiredTokens.d.ts.map +1 -0
  12. package/lib/cjs/cli/DeleteExpiredTokens.js +39 -0
  13. package/lib/cjs/cli/DeleteExpiredTokens.js.map +1 -0
  14. package/lib/cjs/cli/DeleteToken.d.ts +7 -0
  15. package/lib/cjs/cli/DeleteToken.d.ts.map +1 -0
  16. package/lib/cjs/cli/DeleteToken.js +36 -0
  17. package/lib/cjs/cli/DeleteToken.js.map +1 -0
  18. package/lib/cjs/cli/GrantTokenRole.d.ts +7 -0
  19. package/lib/cjs/cli/GrantTokenRole.d.ts.map +1 -0
  20. package/lib/cjs/cli/GrantTokenRole.js +37 -0
  21. package/lib/cjs/cli/GrantTokenRole.js.map +1 -0
  22. package/lib/cjs/cli/RevokeTokenRole.d.ts +12 -0
  23. package/lib/cjs/cli/RevokeTokenRole.d.ts.map +1 -0
  24. package/lib/cjs/cli/RevokeTokenRole.js +42 -0
  25. package/lib/cjs/cli/RevokeTokenRole.js.map +1 -0
  26. package/lib/cjs/config/rbac-http-token.d.ts +71 -0
  27. package/lib/cjs/config/rbac-http-token.d.ts.map +1 -0
  28. package/lib/cjs/config/rbac-http-token.js +98 -0
  29. package/lib/cjs/config/rbac-http-token.js.map +1 -0
  30. package/lib/cjs/controllers/AccessTokenController.d.ts +139 -0
  31. package/lib/cjs/controllers/AccessTokenController.d.ts.map +1 -0
  32. package/lib/cjs/controllers/AccessTokenController.js +264 -0
  33. package/lib/cjs/controllers/AccessTokenController.js.map +1 -0
  34. package/lib/cjs/dto/create-token-dto.d.ts +34 -0
  35. package/lib/cjs/dto/create-token-dto.d.ts.map +1 -0
  36. package/lib/cjs/dto/create-token-dto.js +35 -0
  37. package/lib/cjs/dto/create-token-dto.js.map +1 -0
  38. package/lib/cjs/events/AccessTokenCreated.d.ts +4 -0
  39. package/lib/cjs/events/AccessTokenCreated.d.ts.map +1 -0
  40. package/lib/cjs/events/AccessTokenCreated.js +18 -0
  41. package/lib/cjs/events/AccessTokenCreated.js.map +1 -0
  42. package/lib/cjs/events/AccessTokenDeleted.d.ts +4 -0
  43. package/lib/cjs/events/AccessTokenDeleted.d.ts.map +1 -0
  44. package/lib/cjs/events/AccessTokenDeleted.js +18 -0
  45. package/lib/cjs/events/AccessTokenDeleted.js.map +1 -0
  46. package/lib/cjs/events/AccessTokenEvent.d.ts +10 -0
  47. package/lib/cjs/events/AccessTokenEvent.d.ts.map +1 -0
  48. package/lib/cjs/events/AccessTokenEvent.js +26 -0
  49. package/lib/cjs/events/AccessTokenEvent.js.map +1 -0
  50. package/lib/cjs/events/AccessTokenRoleGranted.d.ts +7 -0
  51. package/lib/cjs/events/AccessTokenRoleGranted.d.ts.map +1 -0
  52. package/lib/cjs/events/AccessTokenRoleGranted.js +27 -0
  53. package/lib/cjs/events/AccessTokenRoleGranted.js.map +1 -0
  54. package/lib/cjs/events/AccessTokenRoleRevoked.d.ts +7 -0
  55. package/lib/cjs/events/AccessTokenRoleRevoked.d.ts.map +1 -0
  56. package/lib/cjs/events/AccessTokenRoleRevoked.js +27 -0
  57. package/lib/cjs/events/AccessTokenRoleRevoked.js.map +1 -0
  58. package/lib/cjs/events/index.d.ts +6 -0
  59. package/lib/cjs/events/index.d.ts.map +1 -0
  60. package/lib/cjs/events/index.js +22 -0
  61. package/lib/cjs/events/index.js.map +1 -0
  62. package/lib/cjs/generator.d.ts +12 -0
  63. package/lib/cjs/generator.d.ts.map +1 -0
  64. package/lib/cjs/generator.js +42 -0
  65. package/lib/cjs/generator.js.map +1 -0
  66. package/lib/cjs/index.d.ts +20 -0
  67. package/lib/cjs/index.d.ts.map +1 -0
  68. package/lib/cjs/index.js +39 -0
  69. package/lib/cjs/index.js.map +1 -0
  70. package/lib/cjs/interfaces.d.ts +57 -0
  71. package/lib/cjs/interfaces.d.ts.map +1 -0
  72. package/lib/cjs/interfaces.js +11 -0
  73. package/lib/cjs/interfaces.js.map +1 -0
  74. package/lib/cjs/middlewares.d.ts +76 -0
  75. package/lib/cjs/middlewares.d.ts.map +1 -0
  76. package/lib/cjs/middlewares.js +181 -0
  77. package/lib/cjs/middlewares.js.map +1 -0
  78. package/lib/cjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.d.ts +6 -0
  79. package/lib/cjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.d.ts.map +1 -0
  80. package/lib/cjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.js +38 -0
  81. package/lib/cjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.js.map +1 -0
  82. package/lib/cjs/models/AccessToken.d.ts +55 -0
  83. package/lib/cjs/models/AccessToken.d.ts.map +1 -0
  84. package/lib/cjs/models/AccessToken.js +73 -0
  85. package/lib/cjs/models/AccessToken.js.map +1 -0
  86. package/lib/cjs/package.json +1 -0
  87. package/lib/cjs/policies/NoImpersonationPolicy.d.ts +28 -0
  88. package/lib/cjs/policies/NoImpersonationPolicy.d.ts.map +1 -0
  89. package/lib/cjs/policies/NoImpersonationPolicy.js +45 -0
  90. package/lib/cjs/policies/NoImpersonationPolicy.js.map +1 -0
  91. package/lib/cjs/policies/NoTokenAuthPolicy.d.ts +12 -0
  92. package/lib/cjs/policies/NoTokenAuthPolicy.d.ts.map +1 -0
  93. package/lib/cjs/policies/NoTokenAuthPolicy.js +24 -0
  94. package/lib/cjs/policies/NoTokenAuthPolicy.js.map +1 -0
  95. package/lib/cjs/policies/TokenPolicy.d.ts +49 -0
  96. package/lib/cjs/policies/TokenPolicy.d.ts.map +1 -0
  97. package/lib/cjs/policies/TokenPolicy.js +79 -0
  98. package/lib/cjs/policies/TokenPolicy.js.map +1 -0
  99. package/lib/mjs/actions.d.ts +119 -0
  100. package/lib/mjs/actions.d.ts.map +1 -0
  101. package/lib/mjs/actions.js +242 -0
  102. package/lib/mjs/actions.js.map +1 -0
  103. package/lib/mjs/cli/CreateToken.d.ts +13 -0
  104. package/lib/mjs/cli/CreateToken.d.ts.map +1 -0
  105. package/lib/mjs/cli/CreateToken.js +53 -0
  106. package/lib/mjs/cli/CreateToken.js.map +1 -0
  107. package/lib/mjs/cli/DeleteExpiredTokens.d.ts +11 -0
  108. package/lib/mjs/cli/DeleteExpiredTokens.d.ts.map +1 -0
  109. package/lib/mjs/cli/DeleteExpiredTokens.js +36 -0
  110. package/lib/mjs/cli/DeleteExpiredTokens.js.map +1 -0
  111. package/lib/mjs/cli/DeleteToken.d.ts +7 -0
  112. package/lib/mjs/cli/DeleteToken.d.ts.map +1 -0
  113. package/lib/mjs/cli/DeleteToken.js +33 -0
  114. package/lib/mjs/cli/DeleteToken.js.map +1 -0
  115. package/lib/mjs/cli/GrantTokenRole.d.ts +7 -0
  116. package/lib/mjs/cli/GrantTokenRole.d.ts.map +1 -0
  117. package/lib/mjs/cli/GrantTokenRole.js +34 -0
  118. package/lib/mjs/cli/GrantTokenRole.js.map +1 -0
  119. package/lib/mjs/cli/RevokeTokenRole.d.ts +12 -0
  120. package/lib/mjs/cli/RevokeTokenRole.d.ts.map +1 -0
  121. package/lib/mjs/cli/RevokeTokenRole.js +39 -0
  122. package/lib/mjs/cli/RevokeTokenRole.js.map +1 -0
  123. package/lib/mjs/config/rbac-http-token.d.ts +71 -0
  124. package/lib/mjs/config/rbac-http-token.d.ts.map +1 -0
  125. package/lib/mjs/config/rbac-http-token.js +96 -0
  126. package/lib/mjs/config/rbac-http-token.js.map +1 -0
  127. package/lib/mjs/controllers/AccessTokenController.d.ts +139 -0
  128. package/lib/mjs/controllers/AccessTokenController.d.ts.map +1 -0
  129. package/lib/mjs/controllers/AccessTokenController.js +261 -0
  130. package/lib/mjs/controllers/AccessTokenController.js.map +1 -0
  131. package/lib/mjs/dto/create-token-dto.d.ts +34 -0
  132. package/lib/mjs/dto/create-token-dto.d.ts.map +1 -0
  133. package/lib/mjs/dto/create-token-dto.js +32 -0
  134. package/lib/mjs/dto/create-token-dto.js.map +1 -0
  135. package/lib/mjs/events/AccessTokenCreated.d.ts +4 -0
  136. package/lib/mjs/events/AccessTokenCreated.d.ts.map +1 -0
  137. package/lib/mjs/events/AccessTokenCreated.js +15 -0
  138. package/lib/mjs/events/AccessTokenCreated.js.map +1 -0
  139. package/lib/mjs/events/AccessTokenDeleted.d.ts +4 -0
  140. package/lib/mjs/events/AccessTokenDeleted.d.ts.map +1 -0
  141. package/lib/mjs/events/AccessTokenDeleted.js +15 -0
  142. package/lib/mjs/events/AccessTokenDeleted.js.map +1 -0
  143. package/lib/mjs/events/AccessTokenEvent.d.ts +10 -0
  144. package/lib/mjs/events/AccessTokenEvent.d.ts.map +1 -0
  145. package/lib/mjs/events/AccessTokenEvent.js +23 -0
  146. package/lib/mjs/events/AccessTokenEvent.js.map +1 -0
  147. package/lib/mjs/events/AccessTokenRoleGranted.d.ts +7 -0
  148. package/lib/mjs/events/AccessTokenRoleGranted.d.ts.map +1 -0
  149. package/lib/mjs/events/AccessTokenRoleGranted.js +24 -0
  150. package/lib/mjs/events/AccessTokenRoleGranted.js.map +1 -0
  151. package/lib/mjs/events/AccessTokenRoleRevoked.d.ts +7 -0
  152. package/lib/mjs/events/AccessTokenRoleRevoked.d.ts.map +1 -0
  153. package/lib/mjs/events/AccessTokenRoleRevoked.js +24 -0
  154. package/lib/mjs/events/AccessTokenRoleRevoked.js.map +1 -0
  155. package/lib/mjs/events/index.d.ts +6 -0
  156. package/lib/mjs/events/index.d.ts.map +1 -0
  157. package/lib/mjs/events/index.js +6 -0
  158. package/lib/mjs/events/index.js.map +1 -0
  159. package/lib/mjs/generator.d.ts +12 -0
  160. package/lib/mjs/generator.d.ts.map +1 -0
  161. package/lib/mjs/generator.js +39 -0
  162. package/lib/mjs/generator.js.map +1 -0
  163. package/lib/mjs/index.d.ts +20 -0
  164. package/lib/mjs/index.d.ts.map +1 -0
  165. package/lib/mjs/index.js +23 -0
  166. package/lib/mjs/index.js.map +1 -0
  167. package/lib/mjs/interfaces.d.ts +57 -0
  168. package/lib/mjs/interfaces.d.ts.map +1 -0
  169. package/lib/mjs/interfaces.js +7 -0
  170. package/lib/mjs/interfaces.js.map +1 -0
  171. package/lib/mjs/middlewares.d.ts +76 -0
  172. package/lib/mjs/middlewares.d.ts.map +1 -0
  173. package/lib/mjs/middlewares.js +178 -0
  174. package/lib/mjs/middlewares.js.map +1 -0
  175. package/lib/mjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.d.ts +6 -0
  176. package/lib/mjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.d.ts.map +1 -0
  177. package/lib/mjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.js +35 -0
  178. package/lib/mjs/migrations/RbacHttpTokenInitial_2026_08_11_01_00_00.js.map +1 -0
  179. package/lib/mjs/models/AccessToken.d.ts +55 -0
  180. package/lib/mjs/models/AccessToken.d.ts.map +1 -0
  181. package/lib/mjs/models/AccessToken.js +70 -0
  182. package/lib/mjs/models/AccessToken.js.map +1 -0
  183. package/lib/mjs/package.json +1 -0
  184. package/lib/mjs/policies/NoImpersonationPolicy.d.ts +28 -0
  185. package/lib/mjs/policies/NoImpersonationPolicy.d.ts.map +1 -0
  186. package/lib/mjs/policies/NoImpersonationPolicy.js +41 -0
  187. package/lib/mjs/policies/NoImpersonationPolicy.js.map +1 -0
  188. package/lib/mjs/policies/NoTokenAuthPolicy.d.ts +12 -0
  189. package/lib/mjs/policies/NoTokenAuthPolicy.d.ts.map +1 -0
  190. package/lib/mjs/policies/NoTokenAuthPolicy.js +20 -0
  191. package/lib/mjs/policies/NoTokenAuthPolicy.js.map +1 -0
  192. package/lib/mjs/policies/TokenPolicy.d.ts +49 -0
  193. package/lib/mjs/policies/TokenPolicy.d.ts.map +1 -0
  194. package/lib/mjs/policies/TokenPolicy.js +75 -0
  195. package/lib/mjs/policies/TokenPolicy.js.map +1 -0
  196. package/lib/tsconfig.cjs.tsbuildinfo +1 -0
  197. package/lib/tsconfig.mjs.tsbuildinfo +1 -0
  198. package/package.json +78 -0
@@ -0,0 +1,96 @@
1
+ import { join, normalize, resolve } from 'path';
2
+ function dir(path) {
3
+ const inCommonJs = typeof module !== 'undefined';
4
+ return [
5
+ resolve(normalize(join(process.env.WORKSPACE_ROOT_PATH ?? process.cwd(), 'node_modules', '@spinajs', 'rbac-http-token', 'lib', inCommonJs ? 'cjs' : 'mjs', path))),
6
+ // one up if we run from app or build folder
7
+ resolve(normalize(join(process.env.WORKSPACE_ROOT_PATH ?? process.cwd(), '../', 'node_modules', '@spinajs', 'rbac-http-token', 'lib', inCommonJs ? 'cjs' : 'mjs', path))),
8
+ ];
9
+ }
10
+ const rbacHttpToken = {
11
+ system: {
12
+ dirs: {
13
+ // CLI commands and controllers are found by a filesystem scan
14
+ // ( `@ListFromFiles` ), so without these entries the shipped commands and
15
+ // the AccessToken controller are unreachable in a consuming app.
16
+ cli: [...dir('cli')],
17
+ controllers: [...dir('controllers')],
18
+ // `migrations` is DELIBERATELY not shipped here, and neither is `models`.
19
+ //
20
+ // Package configs merge into an app's config by ARRAY CONCAT, and
21
+ // `FilesystemMigrationSource` treats a non-empty `system.dirs.migrations`
22
+ // as "the operator configured the scan set": it then REPLACES the build
23
+ // layout defaults instead of adding to them, and turns a failed `.js`
24
+ // import from a warning into a throw ( `orm/src/migration-sources.ts`,
25
+ // and the docblock on `orm/src/config/orm.ts` which ships the key empty
26
+ // for exactly this reason ). A single line here would therefore silently
27
+ // switch off migration discovery in every application that installs this
28
+ // package. `RbacHttpTokenInitial_...` needs no scan anyway - it carries
29
+ // `@Migration`, is exported from the package index, and is picked up from
30
+ // the DI registry by `DiRegistryMigrationSource`. `@spinajs/rbac` ships
31
+ // `cli` only for the same reason.
32
+ //
33
+ // Nothing in the framework reads `system.dirs.models` - models register
34
+ // themselves through the `@Model` decorator when their file is imported.
35
+ },
36
+ },
37
+ queue: {
38
+ // All events emitted by this package go to the black hole connection
39
+ // declared by @spinajs/rbac ( `rbac-user-empty-queue` ). Without the
40
+ // routing they would fall back to the application's DEFAULT connection -
41
+ // a real broker - and every token operation would publish to it.
42
+ routing: {
43
+ AccessTokenCreated: { connection: 'rbac-user-empty-queue' },
44
+ AccessTokenDeleted: { connection: 'rbac-user-empty-queue' },
45
+ AccessTokenRoleGranted: { connection: 'rbac-user-empty-queue' },
46
+ AccessTokenRoleRevoked: { connection: 'rbac-user-empty-queue' },
47
+ },
48
+ },
49
+ rbac: {
50
+ token: {
51
+ /**
52
+ * Token generation algorithm. Swap for your own implementation of
53
+ * AccessTokenGenerationProvider registered under this name.
54
+ */
55
+ generation: {
56
+ service: 'SecureRandomTokenProvider',
57
+ },
58
+ /**
59
+ * Stable plaintext prefix - lets secret scanners recognise leaked tokens.
60
+ */
61
+ prefix: 'spt_',
62
+ /**
63
+ * Random bytes per token ( 32 = 256 bit entropy ).
64
+ */
65
+ length: 32,
66
+ /**
67
+ * Fallback header checked when no `Authorization: Bearer` is present.
68
+ */
69
+ headerName: 'x-api-key',
70
+ /**
71
+ * Seconds between LastUsedAt writes for a busy token.
72
+ */
73
+ lastUsedUpdateInterval: 60,
74
+ },
75
+ grants: {
76
+ user: {
77
+ 'user.tokens': { 'create:own': ['*'], 'read:own': ['*'], 'update:own': ['*'], 'delete:own': ['*'] },
78
+ },
79
+ // RESERVED - nothing shipped in this package enforces or consumes these.
80
+ //
81
+ // `AccessTokenController` is self-service by construction: every one of
82
+ // its routes declares an `*Own` permission and additionally constrains
83
+ // its query by the caller's id ( `own()` ), so an `*:any` grant changes
84
+ // nothing about what that controller lets through. The entry is here so
85
+ // the role's grant map is complete ahead of an admin-scope controller -
86
+ // "list / revoke the tokens of any user" is the obvious next addition -
87
+ // and so an application that writes such a controller itself finds the
88
+ // grants already declared under the resource name it must use.
89
+ 'admin.users': {
90
+ 'user.tokens': { 'create:any': ['*'], 'read:any': ['*'], 'update:any': ['*'], 'delete:any': ['*'] },
91
+ },
92
+ },
93
+ },
94
+ };
95
+ export default rbacHttpToken;
96
+ //# sourceMappingURL=rbac-http-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rbac-http-token.js","sourceRoot":"","sources":["../../../src/config/rbac-http-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEhD,SAAS,GAAG,CAAC,IAAY;IACvB,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;IACjD,OAAO;QACL,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QAElK,4CAA4C;QAC5C,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;KAC1K,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,8DA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,uEAAuE;YACvE,wEAAwE;YACxE,wEAAwE;YACxE,wEAAwE;YACxE,wEAAwE;YACxE,uEAAuE;YACvE,+DAA+D;YAC/D,aAAa,EAAE;gBACb,aAAa,EAAE,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE;aACpG;SACF;KACF;CACF,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,139 @@
1
+ import { BadRequestResponse, BaseController, NotFound, Ok } from '@spinajs/http';
2
+ import { User as UserModel } from '@spinajs/rbac';
3
+ import { AccessToken } from '../models/AccessToken.js';
4
+ import { CreateTokenDto } from '../dto/create-token-dto.js';
5
+ /**
6
+ * Self-service management of own access tokens.
7
+ *
8
+ * SELF-service in the strict sense: the caller must be the account owner,
9
+ * present in person. Two ways of acting *as* somebody are refused outright -
10
+ * an access token ( which must never mint another token ) and an impersonated
11
+ * session ( which must never mint a credential that outlives it ). Every query
12
+ * is additionally constrained by the calling user's id, so a foreign uuid is
13
+ * simply not found.
14
+ *
15
+ * WIRING - the decorator layout below is load bearing. The two guards share ONE
16
+ * `@Policy([...])` group so they are ANDed; splitting them into two `@Policy()`
17
+ * calls would OR them and each would become optional. And do NOT add a class
18
+ * level `@Policy(RbacPolicy)` alongside:
19
+ *
20
+ * `@spinajs/http` combines policies at three levels ( see `createPolicyGate` in
21
+ * `http/src/route-builder.ts` ): AND inside one `@Policy()` group, OR between
22
+ * the groups declared at one scope, AND between the controller scope and the
23
+ * route scope. `@Permission()` already pushes `RbacPolicy` as a group on the
24
+ * ROUTE ( `rbac-http/src/decorators.ts` ), so:
25
+ *
26
+ * - controller scope holds exactly ONE group,
27
+ * `[NoTokenAuthPolicy, NoImpersonationPolicy]`. A lone group cannot be ORed
28
+ * away, so both are a hard requirement of EVERY route on this controller,
29
+ * including any route added later.
30
+ * - route scope holds `[RbacPolicy]` from `@Permission`, which demands an
31
+ * authorized session AND the declared grant.
32
+ *
33
+ * Adding `@Policy(RbacPolicy)` at class level would make the controller scope
34
+ * `[NoTokenAuthPolicy, NoImpersonationPolicy] OR [RbacPolicy]`, and satisfying
35
+ * `RbacPolicy` alone would then discharge the whole scope - both invariants
36
+ * would rest on nothing but RbacPolicy's own session check, which does not look
37
+ * at impersonation at all.
38
+ *
39
+ * @tags AccessTokens
40
+ */
41
+ export declare class AccessTokenController extends BaseController {
42
+ /**
43
+ * List own access tokens
44
+ * Hashes are never returned - `Token` is `@Hidden()` on the model, so the
45
+ * dehydrated rows carry the uuid, label, roles and timestamps only.
46
+ * @security cookieAuth
47
+ * @response 200 Own tokens
48
+ * @response 401 Unauthorized - valid session required
49
+ * @response 403 Forbidden - access tokens cannot be used on this route
50
+ */
51
+ list(user: UserModel): Promise<Ok<unknown>>;
52
+ /**
53
+ * Create an access token
54
+ * The plaintext appears in this response only and cannot be retrieved again.
55
+ * Roles must be a subset of the caller's own roles.
56
+ * @security cookieAuth
57
+ * @response 200 Token created, `Plaintext` returned once
58
+ * @response 400 Requested roles are not held by the caller
59
+ * @response 401 Unauthorized - valid session required
60
+ * @response 403 Forbidden - access tokens cannot be used on this route
61
+ */
62
+ create(user: UserModel, dto: CreateTokenDto): Promise<Ok<unknown> | BadRequestResponse>;
63
+ /**
64
+ * Delete ( revoke ) an own token
65
+ * @security cookieAuth
66
+ * @param uuid Public identifier of the token
67
+ * @response 200 Token deleted
68
+ * @response 401 Unauthorized - valid session required
69
+ * @response 403 Forbidden - access tokens cannot be used on this route
70
+ * @response 404 No such token for this user
71
+ */
72
+ delete(user: UserModel, uuid: string): Promise<Ok | NotFound>;
73
+ /**
74
+ * Grant a role to an own token
75
+ * The role must be held by the caller - a token can never carry more than its
76
+ * owner does.
77
+ * @security cookieAuth
78
+ * @param uuid Public identifier of the token
79
+ * @param role Role name to grant
80
+ * @response 200 Updated token
81
+ * @response 400 Role is not held by the caller
82
+ * @response 401 Unauthorized - valid session required
83
+ * @response 403 Forbidden - access tokens cannot be used on this route
84
+ * @response 404 No such token for this user
85
+ */
86
+ grantRole(user: UserModel, uuid: string, role: string): Promise<Ok<unknown> | NotFound | BadRequestResponse>;
87
+ /**
88
+ * Revoke a role from an own token
89
+ * A token must keep at least one role; dropping the last one is refused with
90
+ * 400 - deleting the token is the way to revoke it entirely.
91
+ * @security cookieAuth
92
+ * @param uuid Public identifier of the token
93
+ * @param role Role name to revoke
94
+ * @response 200 Updated token
95
+ * @response 400 Cannot revoke the token's last role
96
+ * @response 401 Unauthorized - valid session required
97
+ * @response 403 Forbidden - access tokens cannot be used on this route
98
+ * @response 404 No such token for this user
99
+ */
100
+ revokeRole(user: UserModel, uuid: string, role: string): Promise<Ok<unknown> | NotFound | BadRequestResponse>;
101
+ /**
102
+ * Resolves a token by uuid WITHIN the caller's own tokens - the ownership
103
+ * boundary of this whole controller.
104
+ */
105
+ protected own(user: UserModel, uuid: string): Promise<AccessToken | undefined>;
106
+ /**
107
+ * Wire shape of one token: the dehydrated row, with timestamps as ISO
108
+ * instants and `Roles` put back as a real array.
109
+ *
110
+ * `dehydrate()` runs every column through its converter's `toDB` direction -
111
+ * the STORAGE encoding, which is not the API contract in two places:
112
+ *
113
+ * - `dateTimeFormat: 'iso'` is what turns `CreatedAt` / `ExpiresAt` /
114
+ * `LastUsedAt` into offset-carrying ISO strings. Without it the sql
115
+ * converter emits its driver format ( `"2026-08-11 10:00:00"` ), which
116
+ * names no offset at all, so a client has to guess the zone. Every other
117
+ * user-bearing response in the repo dehydrates with this option - see
118
+ * `rbac-http-user/src/controllers/UserController.ts` - and a plain
119
+ * `toJSON()` is exactly `dehydrate()` with the option missing.
120
+ * - `@Set()`'s converter joins the role list into `"user,admin"`. Left
121
+ * alone, `Roles` reaches clients as a string that only looks like a list,
122
+ * which no generated client parses back.
123
+ *
124
+ * `@Hidden()` columns ( `Token`, `Id` ) are dropped by `dehydrate` itself and
125
+ * `user_id` is skipped as the `User` relation's foreign key, so the hash still
126
+ * never leaves here.
127
+ */
128
+ protected toWire(token: AccessToken): Record<string, unknown>;
129
+ /**
130
+ * Turns the actions layer's role refusals into a 400.
131
+ *
132
+ * `ErrorCode` has no entry in the http error map, so an uncaught one leaves as
133
+ * a 500 - and "you asked for a role you do not have" / "a token must keep one
134
+ * role" are the caller's mistakes, not the server's. Anything else is rethrown
135
+ * untouched so a genuine failure still reaches the error handler.
136
+ */
137
+ protected roleError(err: unknown): BadRequestResponse;
138
+ }
139
+ //# sourceMappingURL=AccessTokenController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessTokenController.d.ts","sourceRoot":"","sources":["../../../src/controllers/AccessTokenController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAA4B,QAAQ,EAAE,EAAE,EAA4B,MAAM,eAAe,CAAC;AACrI,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,eAAe,CAAC;AAKlD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAGa,qBAAsB,SAAQ,cAAc;IACvD;;;;;;;;OAQG;IAGU,IAAI,CAAS,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAG/D;IAED;;;;;;;;;OASG;IAGU,MAAM,CAAS,IAAI,EAAE,SAAS,EAAU,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,CASnH;IAED;;;;;;;;OAQG;IAGU,MAAM,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC,CAQ1F;IAED;;;;;;;;;;;;OAYG;IAGU,SAAS,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,QAAQ,GAAG,kBAAkB,CAAC,CAYlJ;IAED;;;;;;;;;;;;OAYG;IAGU,UAAU,CAAS,IAAI,EAAE,SAAS,EAAW,IAAI,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,QAAQ,GAAG,kBAAkB,CAAC,CAYnJ;IAED;;;OAGG;IACH,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAE7E;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE5D;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CAMpD;CACF"}
@@ -0,0 +1,261 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { BadRequestResponse, BaseController, BasePath, Body, Del, Get, NotFound, Ok, Param, Policy, Post, Put } from '@spinajs/http';
14
+ import { User as UserModel } from '@spinajs/rbac';
15
+ import { Permission, Resource, User } from '@spinajs/rbac-http';
16
+ import { ErrorCode } from '@spinajs/exceptions';
17
+ import { DateTime } from 'luxon';
18
+ import { AccessToken } from '../models/AccessToken.js';
19
+ import { E_TOKEN_CODES, createToken, deleteToken, grantTokenRole, revokeTokenRole } from '../actions.js';
20
+ import { CreateTokenDto } from '../dto/create-token-dto.js';
21
+ import { NoTokenAuthPolicy } from '../policies/NoTokenAuthPolicy.js';
22
+ import { NoImpersonationPolicy } from '../policies/NoImpersonationPolicy.js';
23
+ /**
24
+ * Self-service management of own access tokens.
25
+ *
26
+ * SELF-service in the strict sense: the caller must be the account owner,
27
+ * present in person. Two ways of acting *as* somebody are refused outright -
28
+ * an access token ( which must never mint another token ) and an impersonated
29
+ * session ( which must never mint a credential that outlives it ). Every query
30
+ * is additionally constrained by the calling user's id, so a foreign uuid is
31
+ * simply not found.
32
+ *
33
+ * WIRING - the decorator layout below is load bearing. The two guards share ONE
34
+ * `@Policy([...])` group so they are ANDed; splitting them into two `@Policy()`
35
+ * calls would OR them and each would become optional. And do NOT add a class
36
+ * level `@Policy(RbacPolicy)` alongside:
37
+ *
38
+ * `@spinajs/http` combines policies at three levels ( see `createPolicyGate` in
39
+ * `http/src/route-builder.ts` ): AND inside one `@Policy()` group, OR between
40
+ * the groups declared at one scope, AND between the controller scope and the
41
+ * route scope. `@Permission()` already pushes `RbacPolicy` as a group on the
42
+ * ROUTE ( `rbac-http/src/decorators.ts` ), so:
43
+ *
44
+ * - controller scope holds exactly ONE group,
45
+ * `[NoTokenAuthPolicy, NoImpersonationPolicy]`. A lone group cannot be ORed
46
+ * away, so both are a hard requirement of EVERY route on this controller,
47
+ * including any route added later.
48
+ * - route scope holds `[RbacPolicy]` from `@Permission`, which demands an
49
+ * authorized session AND the declared grant.
50
+ *
51
+ * Adding `@Policy(RbacPolicy)` at class level would make the controller scope
52
+ * `[NoTokenAuthPolicy, NoImpersonationPolicy] OR [RbacPolicy]`, and satisfying
53
+ * `RbacPolicy` alone would then discharge the whole scope - both invariants
54
+ * would rest on nothing but RbacPolicy's own session check, which does not look
55
+ * at impersonation at all.
56
+ *
57
+ * @tags AccessTokens
58
+ */
59
+ let AccessTokenController = class AccessTokenController extends BaseController {
60
+ /**
61
+ * List own access tokens
62
+ * Hashes are never returned - `Token` is `@Hidden()` on the model, so the
63
+ * dehydrated rows carry the uuid, label, roles and timestamps only.
64
+ * @security cookieAuth
65
+ * @response 200 Own tokens
66
+ * @response 401 Unauthorized - valid session required
67
+ * @response 403 Forbidden - access tokens cannot be used on this route
68
+ */
69
+ async list(user) {
70
+ const tokens = await AccessToken.where('user_id', user.Id);
71
+ return new Ok(tokens.map((t) => this.toWire(t)));
72
+ }
73
+ /**
74
+ * Create an access token
75
+ * The plaintext appears in this response only and cannot be retrieved again.
76
+ * Roles must be a subset of the caller's own roles.
77
+ * @security cookieAuth
78
+ * @response 200 Token created, `Plaintext` returned once
79
+ * @response 400 Requested roles are not held by the caller
80
+ * @response 401 Unauthorized - valid session required
81
+ * @response 403 Forbidden - access tokens cannot be used on this route
82
+ */
83
+ async create(user, dto) {
84
+ const expiresAt = dto.ExpiresAt ? DateTime.fromISO(dto.ExpiresAt) : null;
85
+ try {
86
+ const { Token, Plaintext } = await createToken(user, dto.Name, dto.Roles, expiresAt);
87
+ return new Ok({ Token: this.toWire(Token), Plaintext }, { Headers: [{ Name: 'Cache-Control', Value: 'no-store' }] });
88
+ }
89
+ catch (err) {
90
+ return this.roleError(err);
91
+ }
92
+ }
93
+ /**
94
+ * Delete ( revoke ) an own token
95
+ * @security cookieAuth
96
+ * @param uuid Public identifier of the token
97
+ * @response 200 Token deleted
98
+ * @response 401 Unauthorized - valid session required
99
+ * @response 403 Forbidden - access tokens cannot be used on this route
100
+ * @response 404 No such token for this user
101
+ */
102
+ async delete(user, uuid) {
103
+ const token = await this.own(user, uuid);
104
+ if (!token) {
105
+ return new NotFound({ error: { code: 'E_TOKEN_NOT_FOUND', message: 'No such token' } });
106
+ }
107
+ await deleteToken(token);
108
+ return new Ok();
109
+ }
110
+ /**
111
+ * Grant a role to an own token
112
+ * The role must be held by the caller - a token can never carry more than its
113
+ * owner does.
114
+ * @security cookieAuth
115
+ * @param uuid Public identifier of the token
116
+ * @param role Role name to grant
117
+ * @response 200 Updated token
118
+ * @response 400 Role is not held by the caller
119
+ * @response 401 Unauthorized - valid session required
120
+ * @response 403 Forbidden - access tokens cannot be used on this route
121
+ * @response 404 No such token for this user
122
+ */
123
+ async grantRole(user, uuid, role) {
124
+ const token = await this.own(user, uuid);
125
+ if (!token) {
126
+ return new NotFound({ error: { code: 'E_TOKEN_NOT_FOUND', message: 'No such token' } });
127
+ }
128
+ try {
129
+ const updated = await grantTokenRole(token, role);
130
+ return new Ok(this.toWire(updated));
131
+ }
132
+ catch (err) {
133
+ return this.roleError(err);
134
+ }
135
+ }
136
+ /**
137
+ * Revoke a role from an own token
138
+ * A token must keep at least one role; dropping the last one is refused with
139
+ * 400 - deleting the token is the way to revoke it entirely.
140
+ * @security cookieAuth
141
+ * @param uuid Public identifier of the token
142
+ * @param role Role name to revoke
143
+ * @response 200 Updated token
144
+ * @response 400 Cannot revoke the token's last role
145
+ * @response 401 Unauthorized - valid session required
146
+ * @response 403 Forbidden - access tokens cannot be used on this route
147
+ * @response 404 No such token for this user
148
+ */
149
+ async revokeRole(user, uuid, role) {
150
+ const token = await this.own(user, uuid);
151
+ if (!token) {
152
+ return new NotFound({ error: { code: 'E_TOKEN_NOT_FOUND', message: 'No such token' } });
153
+ }
154
+ try {
155
+ const updated = await revokeTokenRole(token, role);
156
+ return new Ok(this.toWire(updated));
157
+ }
158
+ catch (err) {
159
+ return this.roleError(err);
160
+ }
161
+ }
162
+ /**
163
+ * Resolves a token by uuid WITHIN the caller's own tokens - the ownership
164
+ * boundary of this whole controller.
165
+ */
166
+ own(user, uuid) {
167
+ return AccessToken.where({ Uuid: uuid, user_id: user.Id }).first();
168
+ }
169
+ /**
170
+ * Wire shape of one token: the dehydrated row, with timestamps as ISO
171
+ * instants and `Roles` put back as a real array.
172
+ *
173
+ * `dehydrate()` runs every column through its converter's `toDB` direction -
174
+ * the STORAGE encoding, which is not the API contract in two places:
175
+ *
176
+ * - `dateTimeFormat: 'iso'` is what turns `CreatedAt` / `ExpiresAt` /
177
+ * `LastUsedAt` into offset-carrying ISO strings. Without it the sql
178
+ * converter emits its driver format ( `"2026-08-11 10:00:00"` ), which
179
+ * names no offset at all, so a client has to guess the zone. Every other
180
+ * user-bearing response in the repo dehydrates with this option - see
181
+ * `rbac-http-user/src/controllers/UserController.ts` - and a plain
182
+ * `toJSON()` is exactly `dehydrate()` with the option missing.
183
+ * - `@Set()`'s converter joins the role list into `"user,admin"`. Left
184
+ * alone, `Roles` reaches clients as a string that only looks like a list,
185
+ * which no generated client parses back.
186
+ *
187
+ * `@Hidden()` columns ( `Token`, `Id` ) are dropped by `dehydrate` itself and
188
+ * `user_id` is skipped as the `User` relation's foreign key, so the hash still
189
+ * never leaves here.
190
+ */
191
+ toWire(token) {
192
+ return { ...token.dehydrate({ dateTimeFormat: 'iso' }), Roles: [...token.Roles] };
193
+ }
194
+ /**
195
+ * Turns the actions layer's role refusals into a 400.
196
+ *
197
+ * `ErrorCode` has no entry in the http error map, so an uncaught one leaves as
198
+ * a 500 - and "you asked for a role you do not have" / "a token must keep one
199
+ * role" are the caller's mistakes, not the server's. Anything else is rethrown
200
+ * untouched so a genuine failure still reaches the error handler.
201
+ */
202
+ roleError(err) {
203
+ if (err instanceof ErrorCode && err.code === E_TOKEN_CODES.E_TOKEN_ROLE_NOT_ALLOWED) {
204
+ return new BadRequestResponse({ error: { code: 'E_TOKEN_ROLE_NOT_ALLOWED', message: err.message } });
205
+ }
206
+ throw err;
207
+ }
208
+ };
209
+ __decorate([
210
+ Get('tokens'),
211
+ Permission(['readOwn']),
212
+ __param(0, User()),
213
+ __metadata("design:type", Function),
214
+ __metadata("design:paramtypes", [UserModel]),
215
+ __metadata("design:returntype", Promise)
216
+ ], AccessTokenController.prototype, "list", null);
217
+ __decorate([
218
+ Post('tokens'),
219
+ Permission(['createOwn']),
220
+ __param(0, User()),
221
+ __param(1, Body()),
222
+ __metadata("design:type", Function),
223
+ __metadata("design:paramtypes", [UserModel, CreateTokenDto]),
224
+ __metadata("design:returntype", Promise)
225
+ ], AccessTokenController.prototype, "create", null);
226
+ __decorate([
227
+ Del('tokens/:uuid'),
228
+ Permission(['deleteOwn']),
229
+ __param(0, User()),
230
+ __param(1, Param()),
231
+ __metadata("design:type", Function),
232
+ __metadata("design:paramtypes", [UserModel, String]),
233
+ __metadata("design:returntype", Promise)
234
+ ], AccessTokenController.prototype, "delete", null);
235
+ __decorate([
236
+ Put('tokens/:uuid/roles/:role'),
237
+ Permission(['updateOwn']),
238
+ __param(0, User()),
239
+ __param(1, Param()),
240
+ __param(2, Param()),
241
+ __metadata("design:type", Function),
242
+ __metadata("design:paramtypes", [UserModel, String, String]),
243
+ __metadata("design:returntype", Promise)
244
+ ], AccessTokenController.prototype, "grantRole", null);
245
+ __decorate([
246
+ Del('tokens/:uuid/roles/:role'),
247
+ Permission(['updateOwn']),
248
+ __param(0, User()),
249
+ __param(1, Param()),
250
+ __param(2, Param()),
251
+ __metadata("design:type", Function),
252
+ __metadata("design:paramtypes", [UserModel, String, String]),
253
+ __metadata("design:returntype", Promise)
254
+ ], AccessTokenController.prototype, "revokeRole", null);
255
+ AccessTokenController = __decorate([
256
+ BasePath('user'),
257
+ Resource('user.tokens'),
258
+ Policy([NoTokenAuthPolicy, NoImpersonationPolicy])
259
+ ], AccessTokenController);
260
+ export { AccessTokenController };
261
+ //# sourceMappingURL=AccessTokenController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessTokenController.js","sourceRoot":"","sources":["../../../src/controllers/AccessTokenController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA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;;qCAA1C,SAAS;;sDAY7C;AAiBY;IAFZ,GAAG,CAAC,0BAA0B,CAAC;IAC/B,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACD,WAAA,IAAI,EAAE,CAAA;IAAmB,WAAA,KAAK,EAAE,CAAA;IAAgB,WAAA,KAAK,EAAE,CAAA;;qCAA1C,SAAS;;uDAY9C;AArHU,qBAAqB;IAHjC,QAAQ,CAAC,MAAM,CAAC;IAChB,QAAQ,CAAC,aAAa,CAAC;IACvB,MAAM,CAAC,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;GACtC,qBAAqB,CAwKjC"}
@@ -0,0 +1,34 @@
1
+ export declare const CreateTokenDtoSchema: {
2
+ $schema: string;
3
+ title: string;
4
+ type: string;
5
+ properties: {
6
+ Name: {
7
+ type: string;
8
+ minLength: number;
9
+ maxLength: number;
10
+ description: string;
11
+ };
12
+ Roles: {
13
+ type: string;
14
+ items: {
15
+ type: string;
16
+ };
17
+ minItems: number;
18
+ description: string;
19
+ };
20
+ ExpiresAt: {
21
+ type: string[];
22
+ format: string;
23
+ description: string;
24
+ };
25
+ };
26
+ required: string[];
27
+ };
28
+ export declare class CreateTokenDto {
29
+ Name: string;
30
+ Roles: string[];
31
+ ExpiresAt?: string | null;
32
+ constructor(data: any);
33
+ }
34
+ //# sourceMappingURL=create-token-dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-token-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/create-token-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB;IAC/B,OAAO;IACP,KAAK;IACL,IAAI;IACJ,UAAU;QACR,IAAI;YAAI,IAAI;YAAY,SAAS;YAAK,SAAS;YAAO,WAAW;;QACjE,KAAK;YAAI,IAAI;YAAW,KAAK;gBAAI,IAAI;;YAAc,QAAQ;YAAK,WAAW;;QAC3E,SAAS;YAAI,IAAI;YAAsB,MAAM;YAAe,WAAW;;;IAEzE,QAAQ;CACT,CAAC;AAEF,qBACa,cAAc;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,YAAY,IAAI,EAAE,GAAG,EAEpB;CACF"}
@@ -0,0 +1,32 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Schema } from '@spinajs/validation';
11
+ export const CreateTokenDtoSchema = {
12
+ $schema: 'http://json-schema.org/draft-07/schema#',
13
+ title: 'Create access token DTO',
14
+ type: 'object',
15
+ properties: {
16
+ Name: { type: 'string', minLength: 1, maxLength: 128, description: 'Human readable token label' },
17
+ Roles: { type: 'array', items: { type: 'string' }, minItems: 1, description: 'Roles allowed on the token, must be subset of own roles' },
18
+ ExpiresAt: { type: ['string', 'null'], format: 'date-time', description: 'ISO expiration instant; null or omitted = never expires' },
19
+ },
20
+ required: ['Name', 'Roles'],
21
+ };
22
+ let CreateTokenDto = class CreateTokenDto {
23
+ constructor(data) {
24
+ Object.assign(this, data);
25
+ }
26
+ };
27
+ CreateTokenDto = __decorate([
28
+ Schema(CreateTokenDtoSchema),
29
+ __metadata("design:paramtypes", [Object])
30
+ ], CreateTokenDto);
31
+ export { CreateTokenDto };
32
+ //# sourceMappingURL=create-token-dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-token-dto.js","sourceRoot":"","sources":["../../../src/dto/create-token-dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,yBAAyB;IAChC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,4BAA4B,EAAE;QACjG,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,yDAAyD,EAAE;QACxI,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,yDAAyD,EAAE;KACrI;IACD,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;CAC5B,CAAC;AAGK,IAAM,cAAc,GAApB,MAAM,cAAc;IAKzB,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AARY,cAAc;IAD1B,MAAM,CAAC,oBAAoB,CAAC;;GAChB,cAAc,CAQ1B"}
@@ -0,0 +1,4 @@
1
+ import { AccessTokenEvent } from './AccessTokenEvent.js';
2
+ export declare class AccessTokenCreated extends AccessTokenEvent {
3
+ }
4
+ //# sourceMappingURL=AccessTokenCreated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessTokenCreated.d.ts","sourceRoot":"","sources":["../../../src/events/AccessTokenCreated.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qBACa,kBAAmB,SAAQ,gBAAgB;CAAG"}
@@ -0,0 +1,15 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Event } from '@spinajs/queue';
8
+ import { AccessTokenEvent } from './AccessTokenEvent.js';
9
+ let AccessTokenCreated = class AccessTokenCreated extends AccessTokenEvent {
10
+ };
11
+ AccessTokenCreated = __decorate([
12
+ Event()
13
+ ], AccessTokenCreated);
14
+ export { AccessTokenCreated };
15
+ //# sourceMappingURL=AccessTokenCreated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessTokenCreated.js","sourceRoot":"","sources":["../../../src/events/AccessTokenCreated.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGlD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,gBAAgB;CAAG,CAAA;AAA9C,kBAAkB;IAD9B,KAAK,EAAE;GACK,kBAAkB,CAA4B"}
@@ -0,0 +1,4 @@
1
+ import { AccessTokenEvent } from './AccessTokenEvent.js';
2
+ export declare class AccessTokenDeleted extends AccessTokenEvent {
3
+ }
4
+ //# sourceMappingURL=AccessTokenDeleted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessTokenDeleted.d.ts","sourceRoot":"","sources":["../../../src/events/AccessTokenDeleted.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qBACa,kBAAmB,SAAQ,gBAAgB;CAAG"}
@@ -0,0 +1,15 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Event } from '@spinajs/queue';
8
+ import { AccessTokenEvent } from './AccessTokenEvent.js';
9
+ let AccessTokenDeleted = class AccessTokenDeleted extends AccessTokenEvent {
10
+ };
11
+ AccessTokenDeleted = __decorate([
12
+ Event()
13
+ ], AccessTokenDeleted);
14
+ export { AccessTokenDeleted };
15
+ //# sourceMappingURL=AccessTokenDeleted.js.map