@adonis-agora/flags 0.0.0-beta-20261112141227

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 (322) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +16 -0
  4. package/dist/assets/spa/assets/index-DdmFo7xr.js +12 -0
  5. package/dist/assets/spa/assets/index-DdmFo7xr.js.map +1 -0
  6. package/dist/assets/spa/assets/index-DhkcP3Cw.css +2 -0
  7. package/dist/assets/spa/index.html +26 -0
  8. package/dist/commands/flags_list.d.ts +9 -0
  9. package/dist/commands/flags_list.d.ts.map +1 -0
  10. package/dist/commands/flags_list.js +51 -0
  11. package/dist/commands/flags_list.js.map +1 -0
  12. package/dist/commands/flags_ops.d.ts +60 -0
  13. package/dist/commands/flags_ops.d.ts.map +1 -0
  14. package/dist/commands/flags_ops.js +253 -0
  15. package/dist/commands/flags_ops.js.map +1 -0
  16. package/dist/commands/flags_refs.d.ts +15 -0
  17. package/dist/commands/flags_refs.d.ts.map +1 -0
  18. package/dist/commands/flags_refs.js +90 -0
  19. package/dist/commands/flags_refs.js.map +1 -0
  20. package/dist/commands/flags_set.d.ts +19 -0
  21. package/dist/commands/flags_set.d.ts.map +1 -0
  22. package/dist/commands/flags_set.js +97 -0
  23. package/dist/commands/flags_set.js.map +1 -0
  24. package/dist/commands/flags_types.d.ts +18 -0
  25. package/dist/commands/flags_types.d.ts.map +1 -0
  26. package/dist/commands/flags_types.js +94 -0
  27. package/dist/commands/flags_types.js.map +1 -0
  28. package/dist/commands/flags_work.d.ts +16 -0
  29. package/dist/commands/flags_work.d.ts.map +1 -0
  30. package/dist/commands/flags_work.js +71 -0
  31. package/dist/commands/flags_work.js.map +1 -0
  32. package/dist/commands/main.d.ts +15 -0
  33. package/dist/commands/main.d.ts.map +1 -0
  34. package/dist/commands/main.js +30 -0
  35. package/dist/commands/main.js.map +1 -0
  36. package/dist/commands/shared.d.ts +21 -0
  37. package/dist/commands/shared.d.ts.map +1 -0
  38. package/dist/commands/shared.js +70 -0
  39. package/dist/commands/shared.js.map +1 -0
  40. package/dist/configure.d.ts +11 -0
  41. package/dist/configure.d.ts.map +1 -0
  42. package/dist/configure.js +32 -0
  43. package/dist/configure.js.map +1 -0
  44. package/dist/providers/dashboard_provider.d.ts +65 -0
  45. package/dist/providers/dashboard_provider.d.ts.map +1 -0
  46. package/dist/providers/dashboard_provider.js +340 -0
  47. package/dist/providers/dashboard_provider.js.map +1 -0
  48. package/dist/providers/flags_provider.d.ts +30 -0
  49. package/dist/providers/flags_provider.d.ts.map +1 -0
  50. package/dist/providers/flags_provider.js +184 -0
  51. package/dist/providers/flags_provider.js.map +1 -0
  52. package/dist/services/main.d.ts +17 -0
  53. package/dist/services/main.d.ts.map +1 -0
  54. package/dist/services/main.js +20 -0
  55. package/dist/services/main.js.map +1 -0
  56. package/dist/src/admin.d.ts +189 -0
  57. package/dist/src/admin.d.ts.map +1 -0
  58. package/dist/src/admin.js +539 -0
  59. package/dist/src/admin.js.map +1 -0
  60. package/dist/src/analytics/backend.d.ts +18 -0
  61. package/dist/src/analytics/backend.d.ts.map +1 -0
  62. package/dist/src/analytics/backend.js +25 -0
  63. package/dist/src/analytics/backend.js.map +1 -0
  64. package/dist/src/analytics/clickhouse_backend.d.ts +16 -0
  65. package/dist/src/analytics/clickhouse_backend.d.ts.map +1 -0
  66. package/dist/src/analytics/clickhouse_backend.js +48 -0
  67. package/dist/src/analytics/clickhouse_backend.js.map +1 -0
  68. package/dist/src/analytics/duckdb.d.ts +39 -0
  69. package/dist/src/analytics/duckdb.d.ts.map +1 -0
  70. package/dist/src/analytics/duckdb.js +117 -0
  71. package/dist/src/analytics/duckdb.js.map +1 -0
  72. package/dist/src/analytics/lucid_backend.d.ts +16 -0
  73. package/dist/src/analytics/lucid_backend.d.ts.map +1 -0
  74. package/dist/src/analytics/lucid_backend.js +45 -0
  75. package/dist/src/analytics/lucid_backend.js.map +1 -0
  76. package/dist/src/analytics/metrics.d.ts +50 -0
  77. package/dist/src/analytics/metrics.d.ts.map +1 -0
  78. package/dist/src/analytics/metrics.js +42 -0
  79. package/dist/src/analytics/metrics.js.map +1 -0
  80. package/dist/src/analytics/results.d.ts +80 -0
  81. package/dist/src/analytics/results.d.ts.map +1 -0
  82. package/dist/src/analytics/results.js +143 -0
  83. package/dist/src/analytics/results.js.map +1 -0
  84. package/dist/src/dashboard/access_denied_page.d.ts +100 -0
  85. package/dist/src/dashboard/access_denied_page.d.ts.map +1 -0
  86. package/dist/src/dashboard/access_denied_page.js +262 -0
  87. package/dist/src/dashboard/access_denied_page.js.map +1 -0
  88. package/dist/src/dashboard/actor.d.ts +12 -0
  89. package/dist/src/dashboard/actor.d.ts.map +1 -0
  90. package/dist/src/dashboard/actor.js +33 -0
  91. package/dist/src/dashboard/actor.js.map +1 -0
  92. package/dist/src/dashboard/authorize_decision.d.ts +48 -0
  93. package/dist/src/dashboard/authorize_decision.d.ts.map +1 -0
  94. package/dist/src/dashboard/authorize_decision.js +44 -0
  95. package/dist/src/dashboard/authorize_decision.js.map +1 -0
  96. package/dist/src/dashboard/console_authorize.d.ts +77 -0
  97. package/dist/src/dashboard/console_authorize.d.ts.map +1 -0
  98. package/dist/src/dashboard/console_authorize.js +104 -0
  99. package/dist/src/dashboard/console_authorize.js.map +1 -0
  100. package/dist/src/dashboard/define_config.d.ts +71 -0
  101. package/dist/src/dashboard/define_config.d.ts.map +1 -0
  102. package/dist/src/dashboard/define_config.js +18 -0
  103. package/dist/src/dashboard/define_config.js.map +1 -0
  104. package/dist/src/dashboard/handlers.d.ts +172 -0
  105. package/dist/src/dashboard/handlers.d.ts.map +1 -0
  106. package/dist/src/dashboard/handlers.js +949 -0
  107. package/dist/src/dashboard/handlers.js.map +1 -0
  108. package/dist/src/dashboard/index.d.ts +15 -0
  109. package/dist/src/dashboard/index.d.ts.map +1 -0
  110. package/dist/src/dashboard/index.js +10 -0
  111. package/dist/src/dashboard/index.js.map +1 -0
  112. package/dist/src/dashboard/shape.d.ts +12 -0
  113. package/dist/src/dashboard/shape.d.ts.map +1 -0
  114. package/dist/src/dashboard/shape.js +232 -0
  115. package/dist/src/dashboard/shape.js.map +1 -0
  116. package/dist/src/dashboard/spa.d.ts +34 -0
  117. package/dist/src/dashboard/spa.d.ts.map +1 -0
  118. package/dist/src/dashboard/spa.js +50 -0
  119. package/dist/src/dashboard/spa.js.map +1 -0
  120. package/dist/src/declare.d.ts +85 -0
  121. package/dist/src/declare.d.ts.map +1 -0
  122. package/dist/src/declare.js +62 -0
  123. package/dist/src/declare.js.map +1 -0
  124. package/dist/src/define_config.d.ts +256 -0
  125. package/dist/src/define_config.d.ts.map +1 -0
  126. package/dist/src/define_config.js +90 -0
  127. package/dist/src/define_config.js.map +1 -0
  128. package/dist/src/durable.d.ts +29 -0
  129. package/dist/src/durable.d.ts.map +1 -0
  130. package/dist/src/durable.js +55 -0
  131. package/dist/src/durable.js.map +1 -0
  132. package/dist/src/enrichers.d.ts +51 -0
  133. package/dist/src/enrichers.d.ts.map +1 -0
  134. package/dist/src/enrichers.js +105 -0
  135. package/dist/src/enrichers.js.map +1 -0
  136. package/dist/src/events/buffer.d.ts +38 -0
  137. package/dist/src/events/buffer.d.ts.map +1 -0
  138. package/dist/src/events/buffer.js +86 -0
  139. package/dist/src/events/buffer.js.map +1 -0
  140. package/dist/src/events/event.d.ts +42 -0
  141. package/dist/src/events/event.d.ts.map +1 -0
  142. package/dist/src/events/event.js +82 -0
  143. package/dist/src/events/event.js.map +1 -0
  144. package/dist/src/http/browser.d.ts +33 -0
  145. package/dist/src/http/browser.d.ts.map +1 -0
  146. package/dist/src/http/browser.js +81 -0
  147. package/dist/src/http/browser.js.map +1 -0
  148. package/dist/src/http/browser_api.d.ts +48 -0
  149. package/dist/src/http/browser_api.d.ts.map +1 -0
  150. package/dist/src/http/browser_api.js +273 -0
  151. package/dist/src/http/browser_api.js.map +1 -0
  152. package/dist/src/http/browser_tokens.d.ts +27 -0
  153. package/dist/src/http/browser_tokens.d.ts.map +1 -0
  154. package/dist/src/http/browser_tokens.js +48 -0
  155. package/dist/src/http/browser_tokens.js.map +1 -0
  156. package/dist/src/http/control_plane.d.ts +58 -0
  157. package/dist/src/http/control_plane.d.ts.map +1 -0
  158. package/dist/src/http/control_plane.js +318 -0
  159. package/dist/src/http/control_plane.js.map +1 -0
  160. package/dist/src/http/csrf.d.ts +22 -0
  161. package/dist/src/http/csrf.d.ts.map +1 -0
  162. package/dist/src/http/csrf.js +24 -0
  163. package/dist/src/http/csrf.js.map +1 -0
  164. package/dist/src/http/edge_tag.d.ts +55 -0
  165. package/dist/src/http/edge_tag.d.ts.map +1 -0
  166. package/dist/src/http/edge_tag.js +45 -0
  167. package/dist/src/http/edge_tag.js.map +1 -0
  168. package/dist/src/http/flag_middleware.d.ts +27 -0
  169. package/dist/src/http/flag_middleware.d.ts.map +1 -0
  170. package/dist/src/http/flag_middleware.js +30 -0
  171. package/dist/src/http/flag_middleware.js.map +1 -0
  172. package/dist/src/http/flags_middleware.d.ts +20 -0
  173. package/dist/src/http/flags_middleware.d.ts.map +1 -0
  174. package/dist/src/http/flags_middleware.js +20 -0
  175. package/dist/src/http/flags_middleware.js.map +1 -0
  176. package/dist/src/http/subject_resolver.d.ts +45 -0
  177. package/dist/src/http/subject_resolver.d.ts.map +1 -0
  178. package/dist/src/http/subject_resolver.js +93 -0
  179. package/dist/src/http/subject_resolver.js.map +1 -0
  180. package/dist/src/identity.d.ts +82 -0
  181. package/dist/src/identity.d.ts.map +1 -0
  182. package/dist/src/identity.js +100 -0
  183. package/dist/src/identity.js.map +1 -0
  184. package/dist/src/index.d.ts +41 -0
  185. package/dist/src/index.d.ts.map +1 -0
  186. package/dist/src/index.js +34 -0
  187. package/dist/src/index.js.map +1 -0
  188. package/dist/src/manager.d.ts +154 -0
  189. package/dist/src/manager.d.ts.map +1 -0
  190. package/dist/src/manager.js +333 -0
  191. package/dist/src/manager.js.map +1 -0
  192. package/dist/src/openfeature/provider.d.ts +36 -0
  193. package/dist/src/openfeature/provider.d.ts.map +1 -0
  194. package/dist/src/openfeature/provider.js +82 -0
  195. package/dist/src/openfeature/provider.js.map +1 -0
  196. package/dist/src/relay/relay.d.ts +36 -0
  197. package/dist/src/relay/relay.d.ts.map +1 -0
  198. package/dist/src/relay/relay.js +73 -0
  199. package/dist/src/relay/relay.js.map +1 -0
  200. package/dist/src/relay/results_cache.d.ts +20 -0
  201. package/dist/src/relay/results_cache.d.ts.map +1 -0
  202. package/dist/src/relay/results_cache.js +31 -0
  203. package/dist/src/relay/results_cache.js.map +1 -0
  204. package/dist/src/relay/worker.d.ts +66 -0
  205. package/dist/src/relay/worker.d.ts.map +1 -0
  206. package/dist/src/relay/worker.js +177 -0
  207. package/dist/src/relay/worker.js.map +1 -0
  208. package/dist/src/ruleset_source.d.ts +73 -0
  209. package/dist/src/ruleset_source.d.ts.map +1 -0
  210. package/dist/src/ruleset_source.js +128 -0
  211. package/dist/src/ruleset_source.js.map +1 -0
  212. package/dist/src/runtime.d.ts +70 -0
  213. package/dist/src/runtime.d.ts.map +1 -0
  214. package/dist/src/runtime.js +301 -0
  215. package/dist/src/runtime.js.map +1 -0
  216. package/dist/src/schema.d.ts +39 -0
  217. package/dist/src/schema.d.ts.map +1 -0
  218. package/dist/src/schema.js +311 -0
  219. package/dist/src/schema.js.map +1 -0
  220. package/dist/src/services/accessor.d.ts +5 -0
  221. package/dist/src/services/accessor.d.ts.map +1 -0
  222. package/dist/src/services/accessor.js +20 -0
  223. package/dist/src/services/accessor.js.map +1 -0
  224. package/dist/src/sinks/clickhouse.d.ts +41 -0
  225. package/dist/src/sinks/clickhouse.d.ts.map +1 -0
  226. package/dist/src/sinks/clickhouse.js +117 -0
  227. package/dist/src/sinks/clickhouse.js.map +1 -0
  228. package/dist/src/sinks/lucid_sink.d.ts +25 -0
  229. package/dist/src/sinks/lucid_sink.d.ts.map +1 -0
  230. package/dist/src/sinks/lucid_sink.js +87 -0
  231. package/dist/src/sinks/lucid_sink.js.map +1 -0
  232. package/dist/src/sinks/parquet_sink.d.ts +41 -0
  233. package/dist/src/sinks/parquet_sink.d.ts.map +1 -0
  234. package/dist/src/sinks/parquet_sink.js +140 -0
  235. package/dist/src/sinks/parquet_sink.js.map +1 -0
  236. package/dist/src/sinks/posthog_sink.d.ts +29 -0
  237. package/dist/src/sinks/posthog_sink.d.ts.map +1 -0
  238. package/dist/src/sinks/posthog_sink.js +65 -0
  239. package/dist/src/sinks/posthog_sink.js.map +1 -0
  240. package/dist/src/sinks/sink.d.ts +36 -0
  241. package/dist/src/sinks/sink.d.ts.map +1 -0
  242. package/dist/src/sinks/sink.js +36 -0
  243. package/dist/src/sinks/sink.js.map +1 -0
  244. package/dist/src/sql.d.ts +33 -0
  245. package/dist/src/sql.d.ts.map +1 -0
  246. package/dist/src/sql.js +66 -0
  247. package/dist/src/sql.js.map +1 -0
  248. package/dist/src/stores/lucid_store.d.ts +55 -0
  249. package/dist/src/stores/lucid_store.d.ts.map +1 -0
  250. package/dist/src/stores/lucid_store.js +412 -0
  251. package/dist/src/stores/lucid_store.js.map +1 -0
  252. package/dist/src/stores/memory_store.d.ts +38 -0
  253. package/dist/src/stores/memory_store.d.ts.map +1 -0
  254. package/dist/src/stores/memory_store.js +166 -0
  255. package/dist/src/stores/memory_store.js.map +1 -0
  256. package/dist/src/stores/store.d.ts +166 -0
  257. package/dist/src/stores/store.d.ts.map +1 -0
  258. package/dist/src/stores/store.js +67 -0
  259. package/dist/src/stores/store.js.map +1 -0
  260. package/dist/src/subject.d.ts +25 -0
  261. package/dist/src/subject.d.ts.map +1 -0
  262. package/dist/src/subject.js +30 -0
  263. package/dist/src/subject.js.map +1 -0
  264. package/dist/src/testing/index.d.ts +31 -0
  265. package/dist/src/testing/index.d.ts.map +1 -0
  266. package/dist/src/testing/index.js +60 -0
  267. package/dist/src/testing/index.js.map +1 -0
  268. package/dist/src/topology/browser_token.d.ts +48 -0
  269. package/dist/src/topology/browser_token.d.ts.map +1 -0
  270. package/dist/src/topology/browser_token.js +128 -0
  271. package/dist/src/topology/browser_token.js.map +1 -0
  272. package/dist/src/topology/remote_source.d.ts +39 -0
  273. package/dist/src/topology/remote_source.d.ts.map +1 -0
  274. package/dist/src/topology/remote_source.js +184 -0
  275. package/dist/src/topology/remote_source.js.map +1 -0
  276. package/dist/src/topology/token.d.ts +36 -0
  277. package/dist/src/topology/token.d.ts.map +1 -0
  278. package/dist/src/topology/token.js +68 -0
  279. package/dist/src/topology/token.js.map +1 -0
  280. package/dist/src/topology/verify.d.ts +88 -0
  281. package/dist/src/topology/verify.d.ts.map +1 -0
  282. package/dist/src/topology/verify.js +128 -0
  283. package/dist/src/topology/verify.js.map +1 -0
  284. package/dist/src/transports/db_transport.d.ts +55 -0
  285. package/dist/src/transports/db_transport.d.ts.map +1 -0
  286. package/dist/src/transports/db_transport.js +202 -0
  287. package/dist/src/transports/db_transport.js.map +1 -0
  288. package/dist/src/transports/http_transport.d.ts +30 -0
  289. package/dist/src/transports/http_transport.d.ts.map +1 -0
  290. package/dist/src/transports/http_transport.js +51 -0
  291. package/dist/src/transports/http_transport.js.map +1 -0
  292. package/dist/src/transports/memory_transport.d.ts +29 -0
  293. package/dist/src/transports/memory_transport.d.ts.map +1 -0
  294. package/dist/src/transports/memory_transport.js +91 -0
  295. package/dist/src/transports/memory_transport.js.map +1 -0
  296. package/dist/src/transports/redis_transport.d.ts +50 -0
  297. package/dist/src/transports/redis_transport.d.ts.map +1 -0
  298. package/dist/src/transports/redis_transport.js +107 -0
  299. package/dist/src/transports/redis_transport.js.map +1 -0
  300. package/dist/src/transports/transport.d.ts +62 -0
  301. package/dist/src/transports/transport.d.ts.map +1 -0
  302. package/dist/src/transports/transport.js +2 -0
  303. package/dist/src/transports/transport.js.map +1 -0
  304. package/dist/src/types.d.ts +30 -0
  305. package/dist/src/types.d.ts.map +1 -0
  306. package/dist/src/types.js +2 -0
  307. package/dist/src/types.js.map +1 -0
  308. package/dist/src/usage.d.ts +18 -0
  309. package/dist/src/usage.d.ts.map +1 -0
  310. package/dist/src/usage.js +52 -0
  311. package/dist/src/usage.js.map +1 -0
  312. package/dist/stubs/config/flags.stub +50 -0
  313. package/dist/stubs/config/flags_dashboard.stub +35 -0
  314. package/dist/stubs/database/migrations/create_flags_tables.stub +27 -0
  315. package/dist/stubs/main.d.ts +3 -0
  316. package/dist/stubs/main.d.ts.map +1 -0
  317. package/dist/stubs/main.js +9 -0
  318. package/dist/stubs/main.js.map +1 -0
  319. package/package.json +181 -0
  320. package/skills/flags-basics/SKILL.md +142 -0
  321. package/skills/flags-deployment/SKILL.md +125 -0
  322. package/skills/flags-experiments/SKILL.md +99 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results.js","sourceRoot":"","sources":["../../../src/analytics/results.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAET,cAAc,EAEd,cAAc,EACd,OAAO,EACP,SAAS,GACV,MAAM,0BAA0B,CAAC;AAIlC,gFAAgF;AAChF,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AA+D7C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAoB;IAClD,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CACvF,CAAC,KAAK,EAAsD,EAAE,CAAC,OAAO,IAAI,KAAK,CAChF,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,CAAE,CAAC,KAAK;QAChC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,O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I,CAAC;gBACtB,OAAO;gBACP,GAAG,UAAU;gBACb,UAAU,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE;gBACxF,OAAO;aACR,CAAC,CAAC;YACH,uFAAuF;YACvF,IAAI,SAAS,IAAI,GAAG,CAAC,WAAW,IAAI,CAAC,QAAQ;gBAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;QACrE,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,GAAG;QACpB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW;QACX,OAAO;QACP,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,SAAS;QACT,OAAO;QACP,GAAG;QACH,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The built-in "access denied" page a BROWSER sees when the dashboard guard refuses a page
3
+ * navigation — the SPA shell or its assets. Before this page
4
+ * existed the guard answered every denial with the JSON it answers the API with
5
+ * (`{ "error": "forbidden" }`), which is the right thing for the SPA's `fetch` calls and the wrong
6
+ * thing for a human staring at a browser tab.
7
+ *
8
+ * Deliberately a small, dependency-free, hand-authored HTML page — NOT part
9
+ * of the bundled SPA, so a denial never needs the SPA to load first. It carries NO `<script>` at all,
10
+ * so a host running a nonce'd `script-src` CSP (the `@adonisjs/shield` default) cannot break it; the
11
+ * one inline `<style>` takes the request's CSP nonce when the provider hands one over.
12
+ *
13
+ * Every string the host can supply ({@link AccessDeniedPageOptions}) is HTML-escaped on the way in.
14
+ * They are developer-controlled config values, not user input — but escaping them costs nothing and
15
+ * removes the one class of bug a "just interpolate it" template would invite.
16
+ *
17
+ * The visual language (Aviary neutrals, the console's own accent, mono eyebrow over a sans body)
18
+ * mirrors the flags SPA so the refusal reads as part of the same product, not a server default.
19
+ *
20
+ * Ported from `@adonis-agora/payments` (as durable, media, agent and telescope were) with only
21
+ * {@link CONSOLE} changed, so the Agora consoles share ONE
22
+ * refusal story rather than each inventing its own.
23
+ */
24
+ /** Why the guard refused. Drives the default title/message and which buttons make sense. */
25
+ export type AccessDeniedReason =
26
+ /** Nobody is signed in (a `401`): offer the login page when one exists. */
27
+ 'unauthenticated'
28
+ /** Somebody is signed in but `authorize` said no (a `403`). */
29
+ | 'forbidden';
30
+ /** What the provider knows about the refusal — handed to a custom renderer and to the default page. */
31
+ export interface AccessDeniedInfo {
32
+ /** The HTTP status the page is served with. */
33
+ status: 401 | 403;
34
+ reason: AccessDeniedReason;
35
+ /** The console's mount path (`/flags`; `''` when mounted at the root). */
36
+ basePath: string;
37
+ /** The app's login page, when the console knows one (`accessDenied.loginHref`). */
38
+ loginHref?: string;
39
+ /** A developer-facing detail (e.g. a thrown hook's message). Providers set it OUTSIDE production only. */
40
+ detail?: string;
41
+ /** The request's CSP nonce, applied to the inline `<style>` so a nonce'd `style-src` keeps the page styled. */
42
+ nonce?: string;
43
+ }
44
+ /**
45
+ * Knobs for the built-in page — the `accessDenied` config option in its OBJECT form. Every field is
46
+ * optional; omit the option entirely for the defaults.
47
+ */
48
+ export interface AccessDeniedPageOptions {
49
+ /** Console name in the eyebrow and `<title>`. Default: the console's own name (`Flags`). */
50
+ brand?: string;
51
+ /** Heading. Default depends on {@link AccessDeniedInfo.reason}. */
52
+ title?: string;
53
+ /** The sentence under the heading. Default depends on the reason. */
54
+ message?: string;
55
+ /** Where "Back to app" points. Default `/`; `false` hides the button. */
56
+ homeHref?: string | false;
57
+ /** Label of the "Back to app" button. */
58
+ homeLabel?: string;
59
+ /** Where "Sign in" points (your app's login page). Default: none; `false` hides it. */
60
+ loginHref?: string | false;
61
+ /** Label of the "Sign in" button. */
62
+ loginLabel?: string;
63
+ /** Accent colour (any CSS colour). Default: the console's own accent. */
64
+ accent?: string;
65
+ }
66
+ /**
67
+ * The `accessDenied` config option in its FUNCTION form: render the page yourself. Return an HTML
68
+ * string and the provider serves it (with the refusal's status, `text/html`, `no-store`). Return
69
+ * nothing after answering the request yourself — a redirect to your own login page, most commonly —
70
+ * and the provider stands down. Return nothing WITHOUT answering and the default page is served, so
71
+ * the hook is safe to use for side effects (logging) alone.
72
+ *
73
+ * `Ctx` is the host framework's HTTP context — the provider passes AdonisJS's `HttpContext` through
74
+ * untouched; it is generic here so this module stays framework-light and unit-testable.
75
+ */
76
+ export type AccessDeniedRenderer<Ctx = unknown> = (info: AccessDeniedInfo, ctx: Ctx) => string | undefined | null | void | Promise<string | undefined | null | void>;
77
+ /** The `accessDenied` config option: tweak the built-in page, or replace it. */
78
+ export type AccessDeniedOption<Ctx = unknown> = AccessDeniedPageOptions | AccessDeniedRenderer<Ctx>;
79
+ /** This console's identity — the ONLY thing that differs between the Agora ports of this file. */
80
+ export declare const CONSOLE: {
81
+ readonly brand: 'Flags';
82
+ readonly accent: '#818cf8';
83
+ readonly packageName: '@adonis-agora/flags';
84
+ };
85
+ /** Escape the five characters that matter inside HTML text and double-quoted attributes. */
86
+ export declare function escapeHtml(value: string): string;
87
+ /**
88
+ * Render the built-in page. Pure: same `info` + `options` in, same HTML out — so it is trivially
89
+ * snapshot/regex testable and safe to call from anywhere (the provider, a test, a host that wants
90
+ * to embed the default page inside its own layout).
91
+ */
92
+ export declare function renderAccessDeniedPage(info: AccessDeniedInfo, options?: AccessDeniedPageOptions): string;
93
+ /**
94
+ * Resolve WHAT to serve for a refusal, honouring the host's `accessDenied` option in either form.
95
+ * Returns the HTML to send, or `null` when a custom renderer already answered the request itself
96
+ * (`answered()` reports whether it did — the provider wires that to "a `location` header or a body
97
+ * is already set"). Framework-light: knows nothing about the HTTP context beyond passing it through.
98
+ */
99
+ export declare function resolveAccessDeniedPage<Ctx>(info: AccessDeniedInfo, option: AccessDeniedOption<Ctx> | null | undefined, ctx: Ctx, answered: () => boolean): Promise<string | null>;
100
+ //# sourceMappingURL=access_denied_page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access_denied_page.d.ts","sourceRoot":"","sources":["../../../src/dashboard/access_denied_page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,4FAA4F;AAC5F,MAAM,MAAM,kBAAkB;AAC5B,2EAA2E;AACzE,iBAAiB;AACnB,+DAA+D;GAC7D,WAAW,CAAC;AAEhB,uGAAuG;AACvG,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0GAA0G;IAC1G,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+GAA+G;IAC/G,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC1B,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,GAAG,GAAG,OAAO,IAAI,CAChD,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,GAAG,KAEL,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAElF,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,CAAC,GAAG,GAAG,OAAO,IAAI,uBAAuB,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAEpG,kGAAkG;AAClG,eAAO,MAAM,OAAO;aAClB,KAAK,EAAE,OAAO;aACd,MAAM,EAAE,SAAS;aACjB,WAAW,EAAE,qBAAqB;CAC1B,CAAC;AAcX,4FAA4F;AAC5F,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOhD;AAyBD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,gBAAgB,EACtB,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAqLR;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAC/C,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,EAClD,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,OAAO,GACtB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB"}
@@ -0,0 +1,262 @@
1
+ /**
2
+ * The built-in "access denied" page a BROWSER sees when the dashboard guard refuses a page
3
+ * navigation — the SPA shell or its assets. Before this page
4
+ * existed the guard answered every denial with the JSON it answers the API with
5
+ * (`{ "error": "forbidden" }`), which is the right thing for the SPA's `fetch` calls and the wrong
6
+ * thing for a human staring at a browser tab.
7
+ *
8
+ * Deliberately a small, dependency-free, hand-authored HTML page — NOT part
9
+ * of the bundled SPA, so a denial never needs the SPA to load first. It carries NO `<script>` at all,
10
+ * so a host running a nonce'd `script-src` CSP (the `@adonisjs/shield` default) cannot break it; the
11
+ * one inline `<style>` takes the request's CSP nonce when the provider hands one over.
12
+ *
13
+ * Every string the host can supply ({@link AccessDeniedPageOptions}) is HTML-escaped on the way in.
14
+ * They are developer-controlled config values, not user input — but escaping them costs nothing and
15
+ * removes the one class of bug a "just interpolate it" template would invite.
16
+ *
17
+ * The visual language (Aviary neutrals, the console's own accent, mono eyebrow over a sans body)
18
+ * mirrors the flags SPA so the refusal reads as part of the same product, not a server default.
19
+ *
20
+ * Ported from `@adonis-agora/payments` (as durable, media, agent and telescope were) with only
21
+ * {@link CONSOLE} changed, so the Agora consoles share ONE
22
+ * refusal story rather than each inventing its own.
23
+ */
24
+ /** This console's identity — the ONLY thing that differs between the Agora ports of this file. */
25
+ export const CONSOLE = {
26
+ brand: 'Flags',
27
+ accent: '#818cf8',
28
+ packageName: '@adonis-agora/flags',
29
+ };
30
+ const DEFAULT_COPY = {
31
+ unauthenticated: {
32
+ title: 'Sign in required',
33
+ message: 'You need to be signed in to open this console.',
34
+ },
35
+ forbidden: {
36
+ title: 'Access denied',
37
+ message: 'Your account is not allowed to open this console. If that looks wrong, ask an administrator to grant you access.',
38
+ },
39
+ };
40
+ /** Escape the five characters that matter inside HTML text and double-quoted attributes. */
41
+ export function escapeHtml(value) {
42
+ return value
43
+ .replaceAll('&', '&amp;')
44
+ .replaceAll('<', '&lt;')
45
+ .replaceAll('>', '&gt;')
46
+ .replaceAll('"', '&quot;')
47
+ .replaceAll("'", '&#39;');
48
+ }
49
+ /**
50
+ * Accept only a same-origin, root-relative path for a button `href` — the same open-redirect rule
51
+ * `sanitizeReturnTo` applies to `returnTo`. A host-supplied absolute URL is still a developer's
52
+ * choice, so it is allowed; what is refused is anything that could smuggle a `javascript:` scheme.
53
+ */
54
+ function safeHref(candidate) {
55
+ const trimmed = candidate.trim();
56
+ if (trimmed === '')
57
+ return null;
58
+ if (/^(https?:)?\/\//i.test(trimmed))
59
+ return trimmed;
60
+ if (trimmed.startsWith('/'))
61
+ return trimmed;
62
+ return null;
63
+ }
64
+ /** Only a plausible CSS colour token reaches the stylesheet; anything else falls back to the accent. */
65
+ function safeColor(candidate) {
66
+ return /^[#a-zA-Z0-9(),.%\s-]+$/.test(candidate) ? candidate : CONSOLE.accent;
67
+ }
68
+ const LOCK_ICON = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>';
69
+ const KEY_ICON = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="7.5" cy="15.5" r="4.5"/><path d="m21 2-9.6 9.6"/><path d="m15.5 7.5 3 3L22 7l-3-3"/></svg>';
70
+ /**
71
+ * Render the built-in page. Pure: same `info` + `options` in, same HTML out — so it is trivially
72
+ * snapshot/regex testable and safe to call from anywhere (the provider, a test, a host that wants
73
+ * to embed the default page inside its own layout).
74
+ */
75
+ export function renderAccessDeniedPage(info, options = {}) {
76
+ const copy = DEFAULT_COPY[info.reason];
77
+ const brand = escapeHtml(options.brand ?? CONSOLE.brand);
78
+ const title = escapeHtml(options.title ?? copy.title);
79
+ const message = escapeHtml(options.message ?? copy.message);
80
+ const accent = safeColor(options.accent ?? CONSOLE.accent);
81
+ const nonceAttr = info.nonce !== undefined ? ` nonce="${escapeHtml(info.nonce)}"` : '';
82
+ const loginHref = options.loginHref === false
83
+ ? null
84
+ : (safeHref(options.loginHref ?? info.loginHref ?? '') ?? null);
85
+ const homeHref = options.homeHref === false ? null : safeHref(options.homeHref ?? '/');
86
+ const buttons = [];
87
+ if (loginHref !== null && info.reason !== 'forbidden') {
88
+ buttons.push(`<a class="btn primary" href="${escapeHtml(loginHref)}">${KEY_ICON}${escapeHtml(options.loginLabel ?? 'Sign in')}</a>`);
89
+ }
90
+ if (homeHref !== null) {
91
+ buttons.push(`<a class="btn${buttons.length === 0 ? ' primary' : ''}" href="${escapeHtml(homeHref)}">${escapeHtml(options.homeLabel ?? 'Back to app')}</a>`);
92
+ }
93
+ if (loginHref !== null && info.reason === 'forbidden') {
94
+ // A forbidden user might simply be the wrong user: offer a way to switch accounts, second.
95
+ buttons.push(`<a class="btn" href="${escapeHtml(loginHref)}">${escapeHtml(options.loginLabel ?? 'Sign in as someone else')}</a>`);
96
+ }
97
+ const detail = info.detail !== undefined && info.detail !== ''
98
+ ? `\n <p class="detail">${escapeHtml(info.detail)}</p>`
99
+ : '';
100
+ const actions = buttons.length > 0 ? `\n <div class="actions">${buttons.join('')}</div>` : '';
101
+ return `<!doctype html>
102
+ <html lang="en">
103
+ <head>
104
+ <meta charset="utf-8" />
105
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
106
+ <meta name="robots" content="noindex, nofollow" />
107
+ <title>${title} — ${brand}</title>
108
+ <style${nonceAttr}>
109
+ :root {
110
+ color-scheme: dark;
111
+ --bg: #09090b;
112
+ --panel: #0c0c0f;
113
+ --panel-2: #101017;
114
+ --line: #1c1c22;
115
+ --text: #e7e7ea;
116
+ --muted: #76767f;
117
+ --bad: #f87171;
118
+ --accent: ${accent};
119
+ }
120
+ * { box-sizing: border-box; }
121
+ body {
122
+ margin: 0;
123
+ min-height: 100vh;
124
+ display: flex;
125
+ align-items: center;
126
+ justify-content: center;
127
+ padding: 24px;
128
+ background:
129
+ radial-gradient(900px 480px at 50% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
130
+ var(--bg);
131
+ color: var(--text);
132
+ font: 15px/1.6 "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
133
+ -webkit-font-smoothing: antialiased;
134
+ }
135
+ .card {
136
+ position: relative;
137
+ overflow: hidden;
138
+ width: 100%;
139
+ max-width: 440px;
140
+ padding: 36px 32px 28px;
141
+ background: var(--panel);
142
+ border: 1px solid var(--line);
143
+ border-radius: 12px;
144
+ box-shadow: 0 30px 60px -24px rgb(0 0 0 / 0.7);
145
+ }
146
+ .card::before {
147
+ content: "";
148
+ position: absolute;
149
+ inset: 0 0 auto 0;
150
+ height: 2px;
151
+ background: linear-gradient(90deg, var(--accent), transparent 80%);
152
+ }
153
+ .eyebrow {
154
+ display: flex;
155
+ align-items: center;
156
+ gap: 10px;
157
+ margin: 0 0 22px;
158
+ font: 11px/1 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
159
+ letter-spacing: 0.12em;
160
+ text-transform: uppercase;
161
+ color: var(--muted);
162
+ }
163
+ .eyebrow .brand { color: var(--accent); }
164
+ .eyebrow .status {
165
+ margin-left: auto;
166
+ padding: 4px 7px;
167
+ border: 1px solid var(--line);
168
+ border-radius: 4px;
169
+ color: var(--bad);
170
+ letter-spacing: 0.08em;
171
+ }
172
+ .icon {
173
+ display: grid;
174
+ place-items: center;
175
+ width: 40px;
176
+ height: 40px;
177
+ margin-bottom: 18px;
178
+ border-radius: 10px;
179
+ background: color-mix(in srgb, var(--accent) 12%, transparent);
180
+ color: var(--accent);
181
+ }
182
+ h1 {
183
+ margin: 0 0 8px;
184
+ font-size: 22px;
185
+ font-weight: 600;
186
+ letter-spacing: -0.01em;
187
+ }
188
+ p { margin: 0; color: var(--muted); }
189
+ .detail {
190
+ margin-top: 14px;
191
+ padding: 10px 12px;
192
+ border: 1px solid var(--line);
193
+ border-radius: 6px;
194
+ background: var(--panel-2);
195
+ font: 12px/1.5 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
196
+ color: var(--text);
197
+ overflow-wrap: anywhere;
198
+ }
199
+ .actions {
200
+ display: flex;
201
+ flex-wrap: wrap;
202
+ gap: 10px;
203
+ margin-top: 26px;
204
+ }
205
+ .btn {
206
+ display: inline-flex;
207
+ align-items: center;
208
+ gap: 8px;
209
+ padding: 9px 14px;
210
+ border: 1px solid var(--line);
211
+ border-radius: 6px;
212
+ background: var(--panel-2);
213
+ color: var(--text);
214
+ font-size: 13px;
215
+ font-weight: 500;
216
+ text-decoration: none;
217
+ }
218
+ .btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
219
+ .btn.primary {
220
+ background: color-mix(in srgb, var(--accent) 14%, transparent);
221
+ border-color: color-mix(in srgb, var(--accent) 45%, transparent);
222
+ color: var(--accent);
223
+ }
224
+ .btn.primary:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
225
+ .foot {
226
+ margin-top: 26px;
227
+ font: 11px/1 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
228
+ letter-spacing: 0.04em;
229
+ color: var(--muted);
230
+ opacity: 0.7;
231
+ }
232
+ </style>
233
+ </head>
234
+ <body>
235
+ <main class="card">
236
+ <p class="eyebrow"><span class="brand">${brand}</span><span>console</span><span class="status">${info.status}</span></p>
237
+ <div class="icon" aria-hidden="true">${info.reason === 'forbidden' ? LOCK_ICON : KEY_ICON}</div>
238
+ <h1>${title}</h1>
239
+ <p>${message}</p>${detail}${actions}
240
+ <p class="foot">${escapeHtml(CONSOLE.packageName)}</p>
241
+ </main>
242
+ </body>
243
+ </html>`;
244
+ }
245
+ /**
246
+ * Resolve WHAT to serve for a refusal, honouring the host's `accessDenied` option in either form.
247
+ * Returns the HTML to send, or `null` when a custom renderer already answered the request itself
248
+ * (`answered()` reports whether it did — the provider wires that to "a `location` header or a body
249
+ * is already set"). Framework-light: knows nothing about the HTTP context beyond passing it through.
250
+ */
251
+ export async function resolveAccessDeniedPage(info, option, ctx, answered) {
252
+ if (typeof option === 'function') {
253
+ const rendered = await option(info, ctx);
254
+ if (typeof rendered === 'string')
255
+ return rendered;
256
+ if (answered())
257
+ return null;
258
+ return renderAccessDeniedPage(info);
259
+ }
260
+ return renderAccessDeniedPage(info, option ?? {});
261
+ }
262
+ //# sourceMappingURL=access_denied_page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access_denied_page.js","sourceRoot":"","sources":["../../../src/dashboard/access_denied_page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAkEH,kGAAkG;AAClG,MAAM,CAAC,MAAM,OAAO,GAAG;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O;sBACjB,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC;;;QAG7C,CAAC;AACT,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,IAAsB,EACtB,MAAkD,EAClD,GAAQ,EACR,QAAuB;IAEvB,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACzC,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAClD,IAAI,QAAQ,EAAE;YAAE,OAAO,IAAI,CAAC;QAC5B,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,sBAAsB,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Actor } from '../stores/store.js';
2
+ /** Who a change is attributed to when nobody can be identified. */
3
+ export declare const FALLBACK_ACTOR: Actor;
4
+ /**
5
+ * The default `actor`: the signed-in user (`ctx.auth.user`, read structurally — this package does
6
+ * not depend on `@adonisjs/auth`). `id` is the user's `id`; `name` its `email` or `name`.
7
+ * `'dashboard'` when nobody is signed in.
8
+ */
9
+ export declare function defaultActor(ctx: unknown): Actor;
10
+ /** Normalize what a configured `actor` resolver returned. */
11
+ export declare function toActor(value: unknown): Actor;
12
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../../src/dashboard/actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,mEAAmE;AACnE,eAAO,MAAM,cAAc,EAAE,KAA4C,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAYhD;AAED,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAS7C"}
@@ -0,0 +1,33 @@
1
+ /** Who a change is attributed to when nobody can be identified. */
2
+ export const FALLBACK_ACTOR = { id: 'dashboard', anonymous: true };
3
+ /**
4
+ * The default `actor`: the signed-in user (`ctx.auth.user`, read structurally — this package does
5
+ * not depend on `@adonisjs/auth`). `id` is the user's `id`; `name` its `email` or `name`.
6
+ * `'dashboard'` when nobody is signed in.
7
+ */
8
+ export function defaultActor(ctx) {
9
+ const user = ctx?.auth?.user;
10
+ if (!user)
11
+ return FALLBACK_ACTOR;
12
+ const id = user.id;
13
+ const name = [user.email, user.name].find((value) => typeof value === 'string' && value !== '');
14
+ if (typeof id === 'string' && id !== '')
15
+ return name ? { id, name } : { id };
16
+ if (typeof id === 'number' || typeof id === 'bigint') {
17
+ return name ? { id: String(id), name } : { id: String(id) };
18
+ }
19
+ return name ? { id: name, name } : FALLBACK_ACTOR;
20
+ }
21
+ /** Normalize what a configured `actor` resolver returned. */
22
+ export function toActor(value) {
23
+ if (typeof value === 'string' && value !== '')
24
+ return { id: value };
25
+ if (typeof value === 'object' && value !== null) {
26
+ const { id, name } = value;
27
+ if (typeof id === 'string' && id !== '') {
28
+ return typeof name === 'string' && name !== '' ? { id, name } : { id };
29
+ }
30
+ }
31
+ return FALLBACK_ACTOR;
32
+ }
33
+ //# sourceMappingURL=actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.js","sourceRoot":"","sources":["../../../src/dashboard/actor.ts"],"names":[],"mappings":"AAEA,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAU,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAE1E;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,MAAM,IAAI,GAAI,GAAmE,EAAE,IAAI,EAAE,IAAI,CAAC;IAC9F,IAAI,CAAC,IAAI;QAAE,OAAO,cAAc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CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The dashboard-gate contract: what an `authorize` hook may answer, and how that answer becomes an
3
+ * HTTP status. Framework-light (no AdonisJS types), so it is unit-testable on its own.
4
+ *
5
+ * Every `@adonis-agora` console (payments, durable, telescope, media, agent, flags) carries an IDENTICAL
6
+ * copy of these types — copied, not shared through a package — so a hook such as
7
+ * `@adonis-agora/authz`'s `authorizeByRoles` can be dropped into any of them and mean the same thing.
8
+ *
9
+ * The one rule that matters most: a decision OBJECT is truthy, so `if (!(await authorize(ctx)))`
10
+ * would wave `{ allowed: false }` through. Always go through {@link resolveAuthorizeResult}.
11
+ */
12
+ /**
13
+ * A structured answer from an `authorize` hook. `reason` lets a console tell "nobody is signed in"
14
+ * (`401`) apart from "signed in, but not allowed" (`403`). Omitted on a denial → `403`.
15
+ */
16
+ export interface AuthorizeDecision {
17
+ allowed: boolean;
18
+ reason?: 'unauthenticated' | 'forbidden';
19
+ }
20
+ /** What an `authorize` hook returns: a bare boolean, or an {@link AuthorizeDecision}. */
21
+ export type AuthorizeResult = boolean | AuthorizeDecision;
22
+ /** An {@link AuthorizeResult} normalized to the HTTP answer it maps to. */
23
+ export type ResolvedAuthorizeResult = {
24
+ allowed: true;
25
+ } | {
26
+ allowed: false;
27
+ status: 401;
28
+ reason: 'unauthenticated';
29
+ } | {
30
+ allowed: false;
31
+ status: 403;
32
+ reason: 'forbidden';
33
+ };
34
+ /**
35
+ * Normalize whatever an `authorize` hook returned. Fails CLOSED: only `true` or an object whose
36
+ * `allowed` is exactly `true` passes; anything else (`false`, `{ allowed: false }`, `undefined`, a
37
+ * malformed value) is a denial — `401` when the hook said `reason: 'unauthenticated'`, `403`
38
+ * otherwise.
39
+ */
40
+ export declare function resolveAuthorizeResult(result: unknown): ResolvedAuthorizeResult;
41
+ /**
42
+ * Run an `authorize` hook and normalize its answer. A hook that THROWS is a `403` denial, never a
43
+ * `500` and never a pass; the error is handed back so the caller can log it.
44
+ */
45
+ export declare function runAuthorize<Ctx>(hook: (ctx: Ctx) => AuthorizeResult | Promise<AuthorizeResult>, ctx: Ctx): Promise<ResolvedAuthorizeResult & {
46
+ hookError?: unknown;
47
+ }>;
48
+ //# sourceMappingURL=authorize_decision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize_decision.d.ts","sourceRoot":"","sources":["../../../src/dashboard/authorize_decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAAC;CAC1C;AAED,yFAAyF;AACzF,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,iBAAiB,CAAC;AAE1D,2EAA2E;AAC3E,MAAM,MAAM,uBAAuB,GAC/B;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAC1D;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC;AAIzD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,uBAAuB,CAS/E;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,GAAG,EACpC,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,EAC9D,GAAG,EAAE,GAAG,GACP,OAAO,CAAC,uBAAuB,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAM5D"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The dashboard-gate contract: what an `authorize` hook may answer, and how that answer becomes an
3
+ * HTTP status. Framework-light (no AdonisJS types), so it is unit-testable on its own.
4
+ *
5
+ * Every `@adonis-agora` console (payments, durable, telescope, media, agent, flags) carries an IDENTICAL
6
+ * copy of these types — copied, not shared through a package — so a hook such as
7
+ * `@adonis-agora/authz`'s `authorizeByRoles` can be dropped into any of them and mean the same thing.
8
+ *
9
+ * The one rule that matters most: a decision OBJECT is truthy, so `if (!(await authorize(ctx)))`
10
+ * would wave `{ allowed: false }` through. Always go through {@link resolveAuthorizeResult}.
11
+ */
12
+ const FORBIDDEN = { allowed: false, status: 403, reason: 'forbidden' };
13
+ /**
14
+ * Normalize whatever an `authorize` hook returned. Fails CLOSED: only `true` or an object whose
15
+ * `allowed` is exactly `true` passes; anything else (`false`, `{ allowed: false }`, `undefined`, a
16
+ * malformed value) is a denial — `401` when the hook said `reason: 'unauthenticated'`, `403`
17
+ * otherwise.
18
+ */
19
+ export function resolveAuthorizeResult(result) {
20
+ if (result === true)
21
+ return { allowed: true };
22
+ if (typeof result !== 'object' || result === null)
23
+ return FORBIDDEN;
24
+ const decision = result;
25
+ if (decision.allowed === true)
26
+ return { allowed: true };
27
+ if (decision.reason === 'unauthenticated') {
28
+ return { allowed: false, status: 401, reason: 'unauthenticated' };
29
+ }
30
+ return FORBIDDEN;
31
+ }
32
+ /**
33
+ * Run an `authorize` hook and normalize its answer. A hook that THROWS is a `403` denial, never a
34
+ * `500` and never a pass; the error is handed back so the caller can log it.
35
+ */
36
+ export async function runAuthorize(hook, ctx) {
37
+ try {
38
+ return resolveAuthorizeResult(await hook(ctx));
39
+ }
40
+ catch (error) {
41
+ return { ...FORBIDDEN, hookError: error };
42
+ }
43
+ }
44
+ //# sourceMappingURL=authorize_decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize_decision.js","sourceRoot":"","sources":["../../../src/dashboard/authorize_decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoBH,MAAM,SAAS,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAW,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAe;IACpD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC9C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACpE,MAAM,QAAQ,GAAG,MAAoC,CAAC;IACtD,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACxD,IAAI,QAAQ,CAAC,MAAM,KAAK,iBAAiB,EAAE,CAAC;QAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IACpE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAA8D,EAC9D,GAAQ;IAER,IAAI,CAAC;QACH,OAAO,sBAAsB,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,GAAG,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;AACH,CAAC"}
@@ -0,0 +1,77 @@
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ /**
3
+ * The console access contract every `@adonis-agora` console (durable, telescope, media, payments, flags,
4
+ * agent, the authkit admin) takes for its `authorize` option. These types are copied, not shared
5
+ * through a package, and kept identical across the libs: TypeScript is structural, so one
6
+ * authorizer class satisfies every console.
7
+ */
8
+ /** What an authorizer may answer. */
9
+ export type ConsoleAuthorizeResult = boolean | {
10
+ allowed: true;
11
+ } | {
12
+ allowed: false;
13
+ reason?: 'unauthenticated' | 'forbidden';
14
+ } | {
15
+ redirectTo: string;
16
+ };
17
+ /** A class form, for an authorizer in its own file (`@inject()` works). */
18
+ export interface ConsoleAuthorizer {
19
+ authorize(ctx: HttpContext): ConsoleAuthorizeResult | Promise<ConsoleAuthorizeResult>;
20
+ }
21
+ export type ConsoleAuthorizerClass = new (...args: any[]) => ConsoleAuthorizer;
22
+ /** The `authorize` option: an inline function, the authorizer class, or a lazy import of it. */
23
+ export type ConsoleAuthorize = ((ctx: HttpContext) => ConsoleAuthorizeResult | Promise<ConsoleAuthorizeResult>) | ConsoleAuthorizerClass | (() => Promise<{
24
+ default: ConsoleAuthorizerClass;
25
+ }>);
26
+ /** A {@link ConsoleAuthorizeResult} normalized to the answer the console writes. */
27
+ export type ConsoleAuthorizeDecision = {
28
+ allowed: true;
29
+ } | {
30
+ allowed: false;
31
+ status: 401;
32
+ reason: 'unauthenticated';
33
+ } | {
34
+ allowed: false;
35
+ status: 403;
36
+ reason: 'forbidden';
37
+ error?: unknown;
38
+ } | {
39
+ allowed: false;
40
+ status: 302;
41
+ redirectTo: string;
42
+ };
43
+ /**
44
+ * Normalize an authorizer's answer. Fails closed: only `true` or `{ allowed: true }` passes;
45
+ * `{ redirectTo }` with a non-empty string is a redirect; anything else is a denial (`401` for
46
+ * `reason: 'unauthenticated'`, `403` otherwise).
47
+ */
48
+ export declare function normalizeConsoleAuthorizeResult(result: unknown): ConsoleAuthorizeDecision;
49
+ /**
50
+ * Turn an `authorize` option into one guard function.
51
+ *
52
+ * - A class is built through the request's container (`ctx.containerResolver.make`), so
53
+ * `@inject()` works, and its `authorize(ctx)` is called.
54
+ * - A function is called with `ctx`. When it resolves to a module whose `default` is an
55
+ * authorizer class, it was a lazy import: the class is remembered (the import runs once per
56
+ * returned guard) and used as above.
57
+ * - A thrown error is a `403` denial, carried on `error` so the caller can log it.
58
+ */
59
+ export declare function resolveConsoleAuthorize(authorize: ConsoleAuthorize): (ctx: HttpContext) => Promise<ConsoleAuthorizeDecision>;
60
+ /** Options for {@link authorizeByToken}. */
61
+ export interface AuthorizeByTokenOptions {
62
+ /** The shared secret callers send as `Authorization: Bearer <token>`. */
63
+ token: string | undefined;
64
+ }
65
+ /**
66
+ * An `authorize` check for machine access: allows a request whose `Authorization` header is
67
+ * `Bearer <token>` (compared in constant time), and answers
68
+ * `{ allowed: false, reason: 'unauthenticated' }` (`401`) otherwise. Only the header is read.
69
+ *
70
+ * ```ts
71
+ * authorize: authorizeByToken({ token: env.get('CONSOLE_TOKEN') }),
72
+ * ```
73
+ *
74
+ * Throws at config time when `token` is empty or undefined.
75
+ */
76
+ export declare function authorizeByToken(options: AuthorizeByTokenOptions): ConsoleAuthorize;
77
+ //# sourceMappingURL=console_authorize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console_authorize.d.ts","sourceRoot":"","sources":["../../../src/dashboard/console_authorize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AAEH,qCAAqC;AACrC,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAAA;CAAE,GAC5D;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3B,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACvF;AAGD,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,iBAAiB,CAAC;AAE/E,gGAAgG;AAChG,MAAM,MAAM,gBAAgB,GACxB,CAAC,CAA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