@xtandard/permissions 0.1.0 → 0.2.0

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 (164) hide show
  1. package/README.md +5 -3
  2. package/dist/{better-auth-NO40ZqSM.mjs → better-auth-BEmX8qyz.mjs} +28 -8
  3. package/dist/better-auth-BEmX8qyz.mjs.map +1 -0
  4. package/dist/{better-auth-Bp9YVyQa.d.cts → better-auth-DQET1sXa.d.mts} +24 -5
  5. package/dist/{better-auth-DHyW5-yt.cjs → better-auth-MR7dBtpo.cjs} +28 -8
  6. package/dist/better-auth-MR7dBtpo.cjs.map +1 -0
  7. package/dist/{better-auth-NSXgt6ZU.d.mts → better-auth-vgRYgjYK.d.cts} +24 -5
  8. package/dist/cli.cjs +12 -6
  9. package/dist/cli.cjs.map +1 -1
  10. package/dist/cli.mjs +12 -6
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/{contract-BMiOmg2f.d.cts → contract-BAisPHBw.d.cts} +30 -2
  13. package/dist/{contract-Yc5AZuvv.mjs → contract-BganM0fx.mjs} +34 -2
  14. package/dist/contract-BganM0fx.mjs.map +1 -0
  15. package/dist/{contract-CPmJVoRx.cjs → contract-Brnu9XXo.cjs} +45 -1
  16. package/dist/contract-Brnu9XXo.cjs.map +1 -0
  17. package/dist/{contract-Dk6d2ylD.d.cts → contract-CXPMGuHk.d.cts} +18 -2
  18. package/dist/{contract-D32H1t0u.d.mts → contract-D6j-yrBL.d.mts} +30 -2
  19. package/dist/{contract-DUzgB-He.d.mts → contract-DhS23Pcp.d.mts} +18 -2
  20. package/dist/{create-fetch-handler-ojjpk1Iw.mjs → create-fetch-handler-B0twltQL.mjs} +43 -6
  21. package/dist/create-fetch-handler-B0twltQL.mjs.map +1 -0
  22. package/dist/{create-fetch-handler-BHDU4chu.d.mts → create-fetch-handler-B711wb64.d.mts} +4 -4
  23. package/dist/{create-fetch-handler-C-WyaRCR.cjs → create-fetch-handler-BHT4vSZs.cjs} +43 -6
  24. package/dist/create-fetch-handler-BHT4vSZs.cjs.map +1 -0
  25. package/dist/{create-fetch-handler-BtX64_rS.d.cts → create-fetch-handler-DxhvXuBA.d.cts} +4 -4
  26. package/dist/{elysia-shared-BUTFTeal.cjs → elysia-shared-BFcWzfc9.cjs} +3 -3
  27. package/dist/{elysia-shared-BUTFTeal.cjs.map → elysia-shared-BFcWzfc9.cjs.map} +1 -1
  28. package/dist/{elysia-shared-BM6cPoCU.mjs → elysia-shared-BwUYg0Ln.mjs} +3 -3
  29. package/dist/{elysia-shared-BM6cPoCU.mjs.map → elysia-shared-BwUYg0Ln.mjs.map} +1 -1
  30. package/dist/{elysia-shared-DtKViycb.d.cts → elysia-shared-C2LnDOj3.d.cts} +5 -5
  31. package/dist/{elysia-shared-g8zsb_pU.d.mts → elysia-shared-WuDr0jco.d.mts} +5 -5
  32. package/dist/{engine-bMoz3iW-.cjs → engine--C7zo-4M.cjs} +93 -13
  33. package/dist/engine--C7zo-4M.cjs.map +1 -0
  34. package/dist/{engine-CGGVDCqi.d.cts → engine-BTgwbHeO.d.cts} +49 -9
  35. package/dist/{engine-DpFIcbgh.d.mts → engine-C3xHfi3q.d.mts} +49 -9
  36. package/dist/{engine-Bufv0TbD.mjs → engine-CR75K253.mjs} +93 -13
  37. package/dist/engine-CR75K253.mjs.map +1 -0
  38. package/dist/entry-auth-better-auth.cjs +6 -3
  39. package/dist/entry-auth-better-auth.d.cts +4 -4
  40. package/dist/entry-auth-better-auth.d.mts +4 -4
  41. package/dist/entry-auth-better-auth.mjs +4 -4
  42. package/dist/entry-auth-jwt.cjs +6 -2
  43. package/dist/entry-auth-jwt.cjs.map +1 -1
  44. package/dist/entry-auth-jwt.d.cts +9 -3
  45. package/dist/entry-auth-jwt.d.mts +9 -3
  46. package/dist/entry-auth-jwt.mjs +4 -3
  47. package/dist/entry-auth-jwt.mjs.map +1 -1
  48. package/dist/entry-auth-session.cjs +6 -2
  49. package/dist/entry-auth-session.cjs.map +1 -1
  50. package/dist/entry-auth-session.d.cts +8 -3
  51. package/dist/entry-auth-session.d.mts +8 -3
  52. package/dist/entry-auth-session.mjs +4 -3
  53. package/dist/entry-auth-session.mjs.map +1 -1
  54. package/dist/entry-authorization-permissions.cjs +1 -1
  55. package/dist/entry-authorization-permissions.d.cts +1 -1
  56. package/dist/entry-authorization-permissions.d.mts +1 -1
  57. package/dist/entry-authorization-permissions.mjs +1 -1
  58. package/dist/entry-better-auth-client.d.cts +2 -2
  59. package/dist/entry-better-auth-client.d.mts +2 -2
  60. package/dist/entry-better-auth.cjs +1 -1
  61. package/dist/entry-better-auth.d.cts +2 -2
  62. package/dist/entry-better-auth.d.mts +2 -2
  63. package/dist/entry-better-auth.mjs +1 -1
  64. package/dist/entry-bridges-audit.d.cts +1 -1
  65. package/dist/entry-bridges-audit.d.mts +1 -1
  66. package/dist/entry-bridges-webhooks.d.cts +1 -1
  67. package/dist/entry-bridges-webhooks.d.mts +1 -1
  68. package/dist/entry-bun.cjs +2 -2
  69. package/dist/entry-bun.d.cts +4 -4
  70. package/dist/entry-bun.d.mts +4 -4
  71. package/dist/entry-bun.mjs +2 -2
  72. package/dist/entry-elysia.cjs +1 -1
  73. package/dist/entry-elysia.d.cts +4 -4
  74. package/dist/entry-elysia.d.mts +4 -4
  75. package/dist/entry-elysia.mjs +1 -1
  76. package/dist/entry-elysia2.cjs +1 -1
  77. package/dist/entry-elysia2.d.cts +4 -4
  78. package/dist/entry-elysia2.d.mts +4 -4
  79. package/dist/entry-elysia2.mjs +1 -1
  80. package/dist/entry-express.cjs +2 -2
  81. package/dist/entry-express.d.cts +4 -4
  82. package/dist/entry-express.d.mts +4 -4
  83. package/dist/entry-express.mjs +2 -2
  84. package/dist/entry-hono.cjs +2 -2
  85. package/dist/entry-hono.d.cts +4 -4
  86. package/dist/entry-hono.d.mts +4 -4
  87. package/dist/entry-hono.mjs +2 -2
  88. package/dist/entry-hooks-log.d.cts +1 -1
  89. package/dist/entry-hooks-log.d.mts +1 -1
  90. package/dist/entry-next.cjs +2 -2
  91. package/dist/entry-next.d.cts +5 -5
  92. package/dist/entry-next.d.mts +5 -5
  93. package/dist/entry-next.mjs +2 -2
  94. package/dist/entry-react.d.cts +2 -2
  95. package/dist/entry-react.d.mts +2 -2
  96. package/dist/{errors-bL3XQLfE.mjs → errors-CG_OLEEv.mjs} +12 -2
  97. package/dist/errors-CG_OLEEv.mjs.map +1 -0
  98. package/dist/{errors-vVYic8gz.cjs → errors-CjpymzFj.cjs} +17 -1
  99. package/dist/errors-CjpymzFj.cjs.map +1 -0
  100. package/dist/{guard-BOx5cnMP.mjs → guard-Bj8zk23F.mjs} +2 -2
  101. package/dist/{guard-BOx5cnMP.mjs.map → guard-Bj8zk23F.mjs.map} +1 -1
  102. package/dist/{guard-nwdOYe90.cjs → guard-DvaoUgjk.cjs} +2 -2
  103. package/dist/{guard-nwdOYe90.cjs.map → guard-DvaoUgjk.cjs.map} +1 -1
  104. package/dist/{guard-C3o7V14m.d.cts → guard-VEK0W8ug.d.cts} +4 -4
  105. package/dist/{guard-DCbTnqPz.d.mts → guard-k7A71SWC.d.mts} +4 -4
  106. package/dist/index.cjs +9 -6
  107. package/dist/index.d.cts +28 -10
  108. package/dist/index.d.mts +28 -10
  109. package/dist/index.mjs +7 -7
  110. package/dist/{kit-DMVBLBI9.d.mts → kit-51JtMxsn.d.mts} +8 -3
  111. package/dist/{kit-fzXHYb1l.mjs → kit-BM3uosfV.mjs} +23 -8
  112. package/dist/kit-BM3uosfV.mjs.map +1 -0
  113. package/dist/{kit-C7tepDB2.cjs → kit-BrqnCcDw.cjs} +28 -7
  114. package/dist/kit-BrqnCcDw.cjs.map +1 -0
  115. package/dist/{kit-qAROuhOI.d.cts → kit-DLF7DZrp.d.cts} +8 -3
  116. package/dist/{permissions-C9PjftY6.mjs → permissions-CeV6M3v7.mjs} +6 -3
  117. package/dist/permissions-CeV6M3v7.mjs.map +1 -0
  118. package/dist/{permissions-Cxri_P_k.cjs → permissions-DDEkHNvN.cjs} +6 -3
  119. package/dist/permissions-DDEkHNvN.cjs.map +1 -0
  120. package/dist/react-embed.js +1880 -1855
  121. package/dist/relationships-BLYEJ9tc.cjs.map +1 -1
  122. package/dist/relationships-BfLonEMI.mjs.map +1 -1
  123. package/dist/{routes-irNuuZqo.cjs → routes-B2LrYpT0.cjs} +15 -9
  124. package/dist/routes-B2LrYpT0.cjs.map +1 -0
  125. package/dist/{routes-DtRb3EO0.mjs → routes-Cx-kl4PY.mjs} +15 -9
  126. package/dist/routes-Cx-kl4PY.mjs.map +1 -0
  127. package/dist/{server-CJ7AIJpO.d.mts → server-Bn643UOy.d.mts} +4 -4
  128. package/dist/{server-C2F4H6bR.d.cts → server-YdH25OEA.d.cts} +4 -4
  129. package/dist/testing.cjs +1 -1
  130. package/dist/testing.d.cts +2 -2
  131. package/dist/testing.d.mts +2 -2
  132. package/dist/testing.mjs +1 -1
  133. package/dist/types-elysia2/auth-provider/contract.d.ts +28 -0
  134. package/dist/types-elysia2/auth-provider/kit.d.ts +5 -0
  135. package/dist/types-elysia2/engine.d.ts +49 -8
  136. package/dist/types-elysia2/errors.d.ts +8 -0
  137. package/dist/types-elysia2/schema.d.ts +16 -0
  138. package/dist/types-elysia2/server/routes.d.ts +16 -5
  139. package/dist/types-react/engine.d.ts +49 -8
  140. package/dist/types-react/errors.d.ts +8 -0
  141. package/dist/types-react/schema.d.ts +16 -0
  142. package/dist/types-react/ui/App.d.ts +6 -1
  143. package/dist/types-react/ui/components/perm-bits.d.ts +5 -1
  144. package/dist/types-react/ui/types.d.ts +11 -2
  145. package/dist/ui/assets/index-DdvxpphI.js +104 -0
  146. package/dist/ui/index.html +1 -1
  147. package/package.json +1 -1
  148. package/dist/better-auth-DHyW5-yt.cjs.map +0 -1
  149. package/dist/better-auth-NO40ZqSM.mjs.map +0 -1
  150. package/dist/contract-CPmJVoRx.cjs.map +0 -1
  151. package/dist/contract-Yc5AZuvv.mjs.map +0 -1
  152. package/dist/create-fetch-handler-C-WyaRCR.cjs.map +0 -1
  153. package/dist/create-fetch-handler-ojjpk1Iw.mjs.map +0 -1
  154. package/dist/engine-Bufv0TbD.mjs.map +0 -1
  155. package/dist/engine-bMoz3iW-.cjs.map +0 -1
  156. package/dist/errors-bL3XQLfE.mjs.map +0 -1
  157. package/dist/errors-vVYic8gz.cjs.map +0 -1
  158. package/dist/kit-C7tepDB2.cjs.map +0 -1
  159. package/dist/kit-fzXHYb1l.mjs.map +0 -1
  160. package/dist/permissions-C9PjftY6.mjs.map +0 -1
  161. package/dist/permissions-Cxri_P_k.cjs.map +0 -1
  162. package/dist/routes-DtRb3EO0.mjs.map +0 -1
  163. package/dist/routes-irNuuZqo.cjs.map +0 -1
  164. package/dist/ui/assets/index-uXGOtyuj.js +0 -104
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { t as createPermissions } from "./engine-Bufv0TbD.mjs";
3
- import { n as toKitAuth } from "./kit-fzXHYb1l.mjs";
2
+ import { t as createPermissions } from "./engine-CR75K253.mjs";
3
+ import { r as toKitAuth } from "./kit-BM3uosfV.mjs";
4
4
  import { i as isMutatingAction, t as ALL_ACTIONS } from "./contract-DTdTXZtJ.mjs";
5
- import { a as createApiRouter, n as CONFIG_PATHS, t as API_ROUTES } from "./routes-DtRb3EO0.mjs";
5
+ import { a as createApiRouter, n as CONFIG_PATHS, t as API_ROUTES } from "./routes-Cx-kl4PY.mjs";
6
6
  import { createPanelHandler, normalizeBasePath, resolveUiDir } from "@xtandard/kit/server";
7
7
  import { buildOpenApiDocument, errorResponse, ref } from "@xtandard/kit/server/router";
8
8
  //#region src/server/openapi.ts
@@ -49,6 +49,20 @@ const REASONS = [
49
49
  "rule-threw",
50
50
  "unknown-path"
51
51
  ];
52
+ const roleSourceMode = {
53
+ type: "string",
54
+ enum: ["stored", "external"],
55
+ description: "Who owns roles: `stored` (a stored role wins) or `external` (the auth provider; role changes are refused)."
56
+ };
57
+ const roleSource = {
58
+ type: "string",
59
+ enum: [
60
+ "stored",
61
+ "provider",
62
+ "default"
63
+ ],
64
+ description: "What decided the effective role: a stored assignment, the auth provider's role, or the catalog's `defaultRole`."
65
+ };
52
66
  const schemas = {
53
67
  Health: obj({ ok: bool }, ["ok"]),
54
68
  PanelConfig: obj({
@@ -56,10 +70,12 @@ const schemas = {
56
70
  logoUrl: str,
57
71
  basePath: str,
58
72
  readonly: bool,
73
+ roleSource: roleSourceMode,
59
74
  authenticated: bool,
60
75
  principal: { oneOf: [obj({
61
76
  id: str,
62
77
  role: str,
78
+ roleSource,
63
79
  name: str,
64
80
  email: str
65
81
  }, ["id", "role"]), { type: "null" }] },
@@ -75,6 +91,7 @@ const schemas = {
75
91
  "title",
76
92
  "basePath",
77
93
  "readonly",
94
+ "roleSource",
78
95
  "authenticated",
79
96
  "principal",
80
97
  "allowed"
@@ -94,6 +111,7 @@ const schemas = {
94
111
  defaultRole: str,
95
112
  managerRoles: strings,
96
113
  directGrants: bool,
114
+ roleSource: roleSourceMode,
97
115
  paths: {
98
116
  ...strings,
99
117
  description: "Every leaf rule path of every role, sorted."
@@ -109,6 +127,7 @@ const schemas = {
109
127
  "defaultRole",
110
128
  "managerRoles",
111
129
  "directGrants",
130
+ "roleSource",
112
131
  "paths",
113
132
  "relations"
114
133
  ]),
@@ -202,13 +221,20 @@ const schemas = {
202
221
  SubjectRefList: obj({ subjects: strings }, ["subjects"]),
203
222
  SubjectSummary: obj({
204
223
  id: str,
205
- role: nullableStr,
224
+ role: {
225
+ ...nullableStr,
226
+ description: "The stored role assignment, if any."
227
+ },
228
+ effectiveRole: str,
229
+ roleSource,
206
230
  name: str,
207
231
  email: str,
208
232
  grantCount: int
209
233
  }, [
210
234
  "id",
211
235
  "role",
236
+ "effectiveRole",
237
+ "roleSource",
212
238
  "grantCount"
213
239
  ]),
214
240
  SubjectList: obj({ subjects: arrayOf("SubjectSummary") }, ["subjects"]),
@@ -228,6 +254,7 @@ const schemas = {
228
254
  },
229
255
  grants: arrayOf("Grant"),
230
256
  effectiveRole: str,
257
+ roleSource,
231
258
  permissions: {
232
259
  ...strings,
233
260
  description: "Active assignable permissions."
@@ -238,6 +265,7 @@ const schemas = {
238
265
  "role",
239
266
  "grants",
240
267
  "effectiveRole",
268
+ "roleSource",
241
269
  "permissions"
242
270
  ]),
243
271
  SubjectUpdate: obj({
@@ -400,6 +428,10 @@ const schemas = {
400
428
  path: str,
401
429
  subject: nullableStr,
402
430
  role: str,
431
+ roleSource: {
432
+ ...roleSource,
433
+ description: "What decided `role` (absent for a guest)."
434
+ },
403
435
  reason: {
404
436
  type: "string",
405
437
  enum: REASONS
@@ -416,7 +448,8 @@ const schemas = {
416
448
  PermissionsSnapshot: obj({
417
449
  subject: obj({
418
450
  id: nullableStr,
419
- role: str
451
+ role: str,
452
+ roleSource
420
453
  }, ["id", "role"]),
421
454
  permissions: strings
422
455
  }, ["subject", "permissions"])
@@ -509,6 +542,10 @@ function buildOpenApiDocument$1(options = {}) {
509
542
  content: { "application/json": { schema: ref("GrantResult") } }
510
543
  };
511
544
  }
545
+ if (spec.operationId === "updateSubject") {
546
+ const responses = out.responses;
547
+ responses["409"] = errorResponse("Roles are managed by the auth provider (`roleSource: \"external\"`; code `ROLES_EXTERNAL`)");
548
+ }
512
549
  if (spec.operationId === "writeRelationship") {
513
550
  const responses = out.responses;
514
551
  responses["200"] = {
@@ -633,4 +670,4 @@ function createFetchHandler(options) {
633
670
  //#endregion
634
671
  export { create_fetch_handler_exports as n, buildOpenApiDocument$1 as r, createFetchHandler as t };
635
672
 
636
- //# sourceMappingURL=create-fetch-handler-ojjpk1Iw.mjs.map
673
+ //# sourceMappingURL=create-fetch-handler-B0twltQL.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-fetch-handler-B0twltQL.mjs","names":["buildOpenApiDocument","kitBuildOpenApiDocument","buildOpenApiDocument"],"sources":["../src/server/openapi.ts","../src/server/create-fetch-handler.ts"],"sourcesContent":["/**\n * OpenAPI 3.1 description of the panel's HTTP API, served at `GET {basePath}/api/openapi.json`\n * and returned by `createFetchHandler(...).openapi()` (merge it into the host's document).\n *\n * Paths come from the router's own table ({@link API_ROUTES}), so every served route is\n * documented; admin routes carry their action as `x-action`, runtime routes `x-runtime: true`.\n * Component schemas are hand-authored (no generation dependency, the family's precedent).\n *\n * @module\n */\n\nimport {\n buildOpenApiDocument as kitBuildOpenApiDocument,\n errorResponse,\n ref,\n} from \"@xtandard/kit/server/router\";\nimport { ALL_ACTIONS, isMutatingAction } from \"../authorization/contract.ts\";\nimport { API_ROUTES, CONFIG_PATHS, type RouteSpec } from \"./routes.ts\";\n\n/** Options for {@link buildOpenApiDocument}. */\nexport interface OpenApiOptions {\n /** Mount prefix used in the `servers` url (e.g. `\"/permissions\"`). */\n basePath?: string;\n /** Document title. Default `\"@xtandard/permissions\"`. */\n title?: string;\n /** Document version. Default `\"1\"` (the HTTP API version, not the package version). */\n version?: string;\n}\n\ntype Schema = Record<string, unknown>;\n\nconst str: Schema = { type: \"string\" };\nconst int: Schema = { type: \"integer\" };\nconst bool: Schema = { type: \"boolean\" };\nconst time: Schema = { type: \"string\", format: \"date-time\" };\nconst nullableStr: Schema = { type: [\"string\", \"null\"] };\nconst nullableTime: Schema = { type: [\"string\", \"null\"], format: \"date-time\" };\nconst strings: Schema = { type: \"array\", items: str };\nconst arrayOf = (name: string): Schema => ({ type: \"array\", items: ref(name) });\nconst obj = (properties: Schema, required: string[] = [], extra: Schema = {}): Schema => ({\n type: \"object\",\n ...(required.length ? { required } : {}),\n properties,\n ...extra,\n});\n\nconst REASONS = [\"grant\", \"role-rule\", \"denied-by-rule\", \"rule-threw\", \"unknown-path\"];\nconst roleSourceMode: Schema = {\n type: \"string\",\n enum: [\"stored\", \"external\"],\n description:\n \"Who owns roles: `stored` (a stored role wins) or `external` (the auth provider; role changes are refused).\",\n};\nconst roleSource: Schema = {\n type: \"string\",\n enum: [\"stored\", \"provider\", \"default\"],\n description:\n \"What decided the effective role: a stored assignment, the auth provider's role, or the catalog's `defaultRole`.\",\n};\n\nconst schemas: Record<string, Schema> = {\n Health: obj({ ok: bool }, [\"ok\"]),\n PanelConfig: obj(\n {\n title: str,\n logoUrl: str,\n basePath: str,\n readonly: bool,\n roleSource: roleSourceMode,\n authenticated: bool,\n principal: {\n oneOf: [\n obj({ id: str, role: str, roleSource, name: str, email: str }, [\"id\", \"role\"]),\n { type: \"null\" },\n ],\n },\n allowed: {\n type: \"array\",\n items: { type: \"string\", enum: [...ALL_ACTIONS] },\n description: \"The actions the caller may perform (mutating ones left out when readonly).\",\n },\n },\n [\"title\", \"basePath\", \"readonly\", \"roleSource\", \"authenticated\", \"principal\", \"allowed\"],\n ),\n LabeledKey: obj({ key: str, label: str, description: str }, [\"key\", \"label\"]),\n CatalogView: obj(\n {\n roles: { ...arrayOf(\"LabeledKey\"), description: \"Least → most privileged.\" },\n assignable: arrayOf(\"LabeledKey\"),\n guestRole: str,\n defaultRole: str,\n managerRoles: strings,\n directGrants: bool,\n roleSource: roleSourceMode,\n paths: { ...strings, description: \"Every leaf rule path of every role, sorted.\" },\n relations: {\n oneOf: [arrayOf(\"RelationTypeView\"), { type: \"null\" }],\n description: \"The relation schema (ReBAC); `null` when the catalog declares none.\",\n },\n },\n [\n \"roles\",\n \"assignable\",\n \"guestRole\",\n \"defaultRole\",\n \"managerRoles\",\n \"directGrants\",\n \"roleSource\",\n \"paths\",\n \"relations\",\n ],\n ),\n RelationTypeView: obj(\n {\n type: str,\n relations: {\n type: \"array\",\n items: obj(\n {\n name: str,\n subjects: {\n ...strings,\n description:\n 'What may be stored: \"user\", \"group#member\", \"user:*\" (empty: computed only).',\n },\n rule: { ...str, description: \"The rule on one line.\" },\n },\n [\"name\", \"subjects\", \"rule\"],\n ),\n },\n },\n [\"type\", \"relations\"],\n ),\n Relationship: obj(\n {\n object: { ...str, description: '\"doc:1\"' },\n relation: str,\n subject: { ...str, description: '\"user:ana\", \"group:eng#member\" or \"user:*\"' },\n createdBy: nullableStr,\n createdAt: time,\n reason: str,\n },\n [\"object\", \"relation\", \"subject\", \"createdBy\", \"createdAt\"],\n ),\n RelationshipPage: obj({ relationships: arrayOf(\"Relationship\"), nextCursor: nullableStr }, [\n \"relationships\",\n \"nextCursor\",\n ]),\n RelationshipInput: obj(\n { object: str, relation: str, subject: str, reason: { ...str, maxLength: 1000 } },\n [\"object\", \"relation\", \"subject\"],\n ),\n WriteRelationshipResult: obj({ relationship: ref(\"Relationship\"), created: bool }, [\n \"relationship\",\n \"created\",\n ]),\n DeleteRelationshipResult: obj(\n { removed: bool, relationship: { oneOf: [ref(\"Relationship\"), { type: \"null\" }] } },\n [\"removed\", \"relationship\"],\n ),\n RelationCheckInput: obj({ subject: str, relation: str, object: str }, [\n \"subject\",\n \"relation\",\n \"object\",\n ]),\n MeRelationInput: obj({ relation: str, object: str }, [\"relation\", \"object\"]),\n RelationCheckResult: obj(\n {\n allowed: bool,\n path: {\n ...strings,\n description:\n 'When allowed, the hops from the object to the subject, e.g. [\"doc:1#viewer\", \"folder:7#viewer (from doc:1#parent)\", \"group:eng#member\", \"user:ana\"].',\n },\n },\n [\"allowed\", \"path\"],\n ),\n ObjectList: obj({ objects: strings }, [\"objects\"]),\n SubjectRefList: obj({ subjects: strings }, [\"subjects\"]),\n SubjectSummary: obj(\n {\n id: str,\n role: { ...nullableStr, description: \"The stored role assignment, if any.\" },\n effectiveRole: str,\n roleSource,\n name: str,\n email: str,\n grantCount: int,\n },\n [\"id\", \"role\", \"effectiveRole\", \"roleSource\", \"grantCount\"],\n ),\n SubjectList: obj({ subjects: arrayOf(\"SubjectSummary\") }, [\"subjects\"]),\n SubjectRecord: obj({ id: str, role: str, name: str, email: str, updatedAt: time }, [\n \"id\",\n \"updatedAt\",\n ]),\n SubjectDetail: obj(\n {\n id: str,\n record: { oneOf: [ref(\"SubjectRecord\"), { type: \"null\" }] },\n role: { ...nullableStr, description: \"The stored role assignment, if valid.\" },\n grants: arrayOf(\"Grant\"),\n effectiveRole: str,\n roleSource,\n permissions: { ...strings, description: \"Active assignable permissions.\" },\n },\n [\"id\", \"record\", \"role\", \"grants\", \"effectiveRole\", \"roleSource\", \"permissions\"],\n ),\n SubjectUpdate: obj({\n role: { ...nullableStr, description: \"`null` clears the stored role.\" },\n name: { ...nullableStr, description: \"`null` clears it.\" },\n email: { ...nullableStr, description: \"`null` clears it.\" },\n reason: { ...str, maxLength: 1000, description: \"Recorded with a role change.\" },\n }),\n Grant: obj(\n {\n subject: str,\n permission: str,\n grantedBy: nullableStr,\n grantedAt: time,\n reason: str,\n expiresAt: nullableTime,\n },\n [\"subject\", \"permission\", \"grantedBy\", \"grantedAt\"],\n ),\n GrantList: obj({ grants: arrayOf(\"Grant\") }, [\"grants\"]),\n GrantInput: obj(\n {\n subject: str,\n permission: { ...str, description: \"One of the catalog's assignable permissions.\" },\n reason: { ...str, maxLength: 1000 },\n expiresAt: {\n type: [\"string\", \"number\", \"null\"],\n description: \"ISO-8601 or unix ms, in the future; `null` = never.\",\n },\n },\n [\"subject\", \"permission\"],\n ),\n GrantResult: obj({ grant: ref(\"Grant\"), created: bool }, [\"grant\", \"created\"]),\n RevokeInput: obj({ reason: { ...str, maxLength: 1000 } }),\n RevokeResult: obj({ removed: bool, grant: { oneOf: [ref(\"Grant\"), { type: \"null\" }] } }, [\n \"removed\",\n \"grant\",\n ]),\n HistoryEntry: obj(\n {\n id: str,\n type: { type: \"string\", enum: [\"grant\", \"revoke\", \"role\", \"relate\", \"unrelate\"] },\n subject: str,\n object: { ...str, description: \"For relate / unrelate.\" },\n relation: { ...str, description: \"For relate / unrelate.\" },\n permission: str,\n role: nullableStr,\n previousRole: nullableStr,\n expiresAt: nullableTime,\n actor: nullableStr,\n reason: str,\n at: time,\n },\n [\"id\", \"type\", \"subject\", \"actor\", \"at\"],\n ),\n HistoryPage: obj({ entries: arrayOf(\"HistoryEntry\"), nextCursor: nullableStr }, [\n \"entries\",\n \"nextCursor\",\n ]),\n CheckInput: obj(\n {\n subject: { ...nullableStr, description: \"A stored subject.\" },\n role: { ...str, description: \"A role (alone: no subject, no grants).\" },\n path: { ...str, description: 'A permix path, e.g. \"post.publish\".' },\n data: { description: \"The data the rule at `path` reads.\" },\n ctx: { description: \"The rules' app context, for catalogs that declare one.\" },\n },\n [\"path\"],\n ),\n MeCheckInput: obj({ path: str, data: { description: \"The data the rule reads.\" } }, [\"path\"]),\n CheckExplanation: obj(\n {\n type: { type: \"string\", enum: [\"allowed\", \"denied\", \"unknown_path\"] },\n path: str,\n role: str,\n permissions: strings,\n decidedBy: { type: \"string\", enum: [\"constant\", \"predicate\", \"threw\", \"missing\"] },\n error: { ...str, description: \"The message of the error a throwing rule raised.\" },\n },\n [\"type\", \"path\", \"role\", \"permissions\", \"decidedBy\"],\n ),\n CheckResult: obj(\n {\n allowed: bool,\n path: str,\n subject: nullableStr,\n role: str,\n roleSource: { ...roleSource, description: \"What decided `role` (absent for a guest).\" },\n reason: { type: \"string\", enum: REASONS },\n explanation: ref(\"CheckExplanation\"),\n },\n [\"allowed\", \"path\", \"subject\", \"role\", \"reason\", \"explanation\"],\n ),\n PermissionsSnapshot: obj(\n {\n subject: obj({ id: nullableStr, role: str, roleSource }, [\"id\", \"role\"]),\n permissions: strings,\n },\n [\"subject\", \"permissions\"],\n ),\n};\n\n/** Runtime routes: authenticated (not public), no `x-action`, no 403. */\nfunction operation(spec: RouteSpec, op: Schema): Schema {\n if (!spec.runtime) return op;\n const { security: _public, ...rest } = op;\n const responses = rest.responses as Record<string, Schema>;\n return {\n ...rest,\n \"x-runtime\": true,\n responses: { ...responses, \"401\": errorResponse(\"Not authenticated\") },\n };\n}\n\n/** The bootstrap config operation (served at both {@link CONFIG_PATHS}). */\nconst configOperation = (operationId: string): Schema => ({\n operationId,\n tags: [\"panel\"],\n summary: \"SPA bootstrap config: title, readonly, the caller and its allowed actions\",\n security: [],\n responses: {\n \"200\": {\n description: \"Panel config\",\n content: { \"application/json\": { schema: ref(\"PanelConfig\") } },\n },\n },\n});\n\n/**\n * Build the OpenAPI 3.1 document for the panel API.\n *\n * @example\n * ```ts\n * import { buildOpenApiDocument } from \"@xtandard/permissions\";\n * const doc = buildOpenApiDocument({ basePath: \"/permissions\" });\n * ```\n */\nexport function buildOpenApiDocument(options: OpenApiOptions = {}): Record<string, unknown> {\n const doc = kitBuildOpenApiDocument({\n routes: API_ROUTES,\n title: options.title ?? \"@xtandard/permissions\",\n version: options.version ?? \"1\",\n description:\n \"Permissions admin API (catalog, subjects, grants, roles, relationships, history, check playground) and runtime API for the caller (`/api/me`). A denial is not an error: checks answer 200 with `allowed: false`.\",\n ...(options.basePath !== undefined ? { basePath: options.basePath } : {}),\n tags: [\n { name: \"panel\", description: \"Bootstrap, health, this document\" },\n { name: \"catalog\", description: \"Roles, assignable permissions, rule paths\" },\n { name: \"subjects\", description: \"Subjects and their stored roles\" },\n { name: \"grants\", description: \"Grant and revoke assignable permissions\" },\n { name: \"history\", description: \"Grant / revoke / role / relationship history\" },\n { name: \"check\", description: \"Check playground\" },\n { name: \"relationships\", description: \"Relationship tuples (ReBAC): write, check, list\" },\n { name: \"runtime\", description: \"The caller's own snapshot and checks\" },\n ],\n schemas,\n bearerDescription: \"Host-issued bearer credentials (e.g. a JWT with auth/jwt).\",\n isMutatingAction,\n readonlyStatus: 423,\n operation: (spec, op) => {\n const out = operation(spec as RouteSpec, op);\n if (spec.operationId === \"grant\") {\n const responses = out.responses as Record<string, Schema>;\n responses[\"200\"] = {\n description: \"Already granted (unchanged)\",\n content: { \"application/json\": { schema: ref(\"GrantResult\") } },\n };\n }\n if (spec.operationId === \"updateSubject\") {\n const responses = out.responses as Record<string, Schema>;\n responses[\"409\"] = errorResponse(\n 'Roles are managed by the auth provider (`roleSource: \"external\"`; code `ROLES_EXTERNAL`)',\n );\n }\n if (spec.operationId === \"writeRelationship\") {\n const responses = out.responses as Record<string, Schema>;\n responses[\"200\"] = {\n description: \"Already stored (unchanged)\",\n content: { \"application/json\": { schema: ref(\"WriteRelationshipResult\") } },\n };\n }\n return out;\n },\n });\n const paths: Record<string, unknown> = {};\n for (const path of CONFIG_PATHS) {\n paths[path] = { get: configOperation(path === \"/config\" ? \"getConfig\" : \"getApiConfig\") };\n }\n return { ...doc, paths: { ...paths, ...(doc.paths as Record<string, unknown>) } };\n}\n","/**\n * The web-standard fetch handler behind every framework adapter, the CLI's `serve` and the\n * standalone app (ADR 0008): the kit's `createPanelHandler` (healthcheck, static UI, SPA fallback,\n * CORS, OpenAPI) around the permissions API router.\n *\n * Auth plugs in three ways:\n *\n * - `auth` + `authorization`: any kit `AuthProvider` / `AuthorizationProvider` (e.g. `basicAuth` +\n * `rolesAuthorization`, or the pair `toKitAuth(provider, perms)` returns);\n * - `provider`: a `PermissionsAuthProvider` (better-auth, session, JWT), adapted with `toKitAuth`\n * (explicit `auth` / `authorization` still win);\n * - nothing: anonymous, allow-all (embedded / local use only).\n *\n * @module\n */\n\nimport {\n createPanelHandler,\n normalizeBasePath,\n resolveUiDir,\n type PanelHandler,\n} from \"@xtandard/kit/server\";\nimport { toKitAuth, type ToKitAuthOptions } from \"../auth-provider/kit.ts\";\nimport type { PermissionsAuthProvider } from \"../auth-provider/contract.ts\";\nimport type { AuthProvider, Principal } from \"../auth/contract.ts\";\nimport type { AuthorizationProvider } from \"../authorization/contract.ts\";\nimport type { SubjectIdentity } from \"../catalog.ts\";\nimport {\n createPermissions,\n type AnyPermissions,\n type Permissions,\n type PermissionsOptions,\n} from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { PermissionsCorsOptions } from \"./cors.ts\";\nimport { buildOpenApiDocument } from \"./openapi.ts\";\nimport { createApiRouter, type ApiContext } from \"./routes.ts\";\n\n/** Options for the panel handler (shared by every framework adapter). */\nexport interface PermissionsPanelOptions<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> extends Partial<PermissionsOptions<D, R, P, X>> {\n /**\n * The engine to serve. When omitted, one is built from the engine options on this object\n * (`catalog` and `storage` are then required; `hooks`, `cache`, … as for `createPermissions`).\n */\n permissions?: Permissions<D, R, P, X>;\n /** Mount prefix, e.g. `\"/permissions\"`. Default `\"\"` (root). */\n basePath?: string;\n /** Authentication. Default: from `provider`, else anonymous. */\n auth?: AuthProvider;\n /** Authorization of the admin routes. Default: from `provider`, else allow all. */\n authorization?: AuthorizationProvider;\n /**\n * A `PermissionsAuthProvider` (`auth/better-auth`, `auth/session`, `auth/jwt`, or your own),\n * adapted with `toKitAuth(provider, engine, providerOptions)`: managers (the catalog's\n * `managerRoles`, or the provider's `canManage`) may use the panel.\n */\n provider?: PermissionsAuthProvider;\n /** Options for the `toKitAuth` adaptation of `provider`. */\n providerOptions?: ToKitAuthOptions;\n /** Block grants and role changes (423). Also passed to a constructed engine. */\n readonly?: boolean;\n /** UI title. Default `\"@xtandard/permissions\"`. */\n title?: string;\n /** Logo image URL shown in the navbar in place of the title. */\n logoUrl?: string;\n /** Override the directory the bundled UI is served from (default `./ui` beside this module). */\n uiDir?: string;\n /** Answer CORS preflights and decorate every response. */\n cors?: PermissionsCorsOptions;\n /** The rules' `ctx` for the caller's runtime checks (`POST /api/me/check`). */\n checkContext?: (request: Request, subject: SubjectIdentity) => unknown;\n /** The caller's ReBAC subject for `POST /api/me/relation`. Default `user:{principal id}`. */\n relationSubject?: (principal: Principal) => string;\n}\n\n/** Return shape of {@link createFetchHandler}. */\nexport interface CreateFetchHandlerResult<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> {\n /** Web-standard request handler. */\n fetch(request: Request): Promise<Response>;\n /** The engine (given or constructed): use it in-process for checks. */\n engine: Permissions<D, R, P, X>;\n /** The HTTP API as an OpenAPI 3.1 document (also served at `{basePath}/api/openapi.json`). */\n openapi(): Record<string, unknown>;\n /** Stop the panel's background work (the engine is the caller's to `close()`). */\n close(): void;\n}\n\nconst defaultAuth: AuthProvider = { authenticate: async () => ({ id: \"anonymous\" }) };\nconst defaultAuthorization: AuthorizationProvider = { authorize: async () => true };\n\n/** Keys of {@link PermissionsPanelOptions} that are not engine options. */\nconst PANEL_KEYS = new Set([\n \"permissions\",\n \"basePath\",\n \"auth\",\n \"authorization\",\n \"provider\",\n \"providerOptions\",\n \"title\",\n \"logoUrl\",\n \"uiDir\",\n \"cors\",\n \"checkContext\",\n \"relationSubject\",\n]);\n\nfunction buildEngine<D extends Definition, R extends string, P extends string, X>(\n options: PermissionsPanelOptions<D, R, P, X>,\n): Permissions<D, R, P, X> {\n if (options.permissions) return options.permissions;\n if (!options.catalog || !options.storage) {\n throw new TypeError(\n \"createFetchHandler requires either `permissions` (an engine) or `catalog` and `storage` to build one.\",\n );\n }\n const engineOptions: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options)) {\n if (!PANEL_KEYS.has(key) && value !== undefined) engineOptions[key] = value;\n }\n return createPermissions(engineOptions as unknown as PermissionsOptions<D, R, P, X>);\n}\n\n/**\n * Build the panel fetch handler.\n *\n * @example\n * ```ts\n * import { createFetchHandler } from \"@xtandard/permissions\";\n * import { betterAuthProvider } from \"@xtandard/permissions/auth/better-auth\";\n *\n * const { fetch } = createFetchHandler({\n * permissions: perms,\n * provider: betterAuthProvider(auth, { mapRole: { user: \"member\" } }),\n * basePath: \"/permissions\",\n * });\n * Bun.serve({ port: 3000, fetch });\n * ```\n */\nexport function createFetchHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): CreateFetchHandlerResult<D, R, P, X> {\n const basePath = normalizeBasePath(options.basePath);\n const engine = buildEngine(options);\n const readonly = options.readonly ?? engine.readonly;\n const title = options.title ?? \"@xtandard/permissions\";\n const uiDir = options.uiDir ?? resolveUiDir(import.meta.url);\n const openapi = () => buildOpenApiDocument({ basePath, title });\n\n const fromProvider = options.provider\n ? toKitAuth(options.provider, engine, options.providerOptions)\n : undefined;\n\n const apiCtx: ApiContext = {\n engine: engine as unknown as AnyPermissions,\n auth: options.auth ?? fromProvider?.auth ?? defaultAuth,\n authorization: options.authorization ?? fromProvider?.authorization ?? defaultAuthorization,\n title,\n readonly,\n basePath,\n openapi,\n ...(options.logoUrl !== undefined ? { logoUrl: options.logoUrl } : {}),\n ...(options.checkContext ? { checkContext: options.checkContext } : {}),\n ...(options.relationSubject ? { relationSubject: options.relationSubject } : {}),\n };\n const router = createApiRouter(apiCtx);\n\n const panel: PanelHandler = createPanelHandler({\n basePath,\n title,\n ...(options.logoUrl !== undefined ? { logoUrl: options.logoUrl } : {}),\n readonly,\n globalName: \"__PERMISSIONS_CONFIG__\",\n uiDir,\n ...(options.cors ? { cors: options.cors } : {}),\n api: router.handle,\n openapi,\n });\n\n return {\n fetch: panel.fetch,\n engine,\n openapi,\n close() {\n void panel.close();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAM,MAAc,EAAE,MAAM,SAAS;AACrC,MAAM,MAAc,EAAE,MAAM,UAAU;AACtC,MAAM,OAAe,EAAE,MAAM,UAAU;AACvC,MAAM,OAAe;CAAE,MAAM;CAAU,QAAQ;AAAY;AAC3D,MAAM,cAAsB,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;AACvD,MAAM,eAAuB;CAAE,MAAM,CAAC,UAAU,MAAM;CAAG,QAAQ;AAAY;AAC7E,MAAM,UAAkB;CAAE,MAAM;CAAS,OAAO;AAAI;AACpD,MAAM,WAAW,UAA0B;CAAE,MAAM;CAAS,OAAO,IAAI,IAAI;AAAE;AAC7E,MAAM,OAAO,YAAoB,WAAqB,CAAC,GAAG,QAAgB,CAAC,OAAe;CACxF,MAAM;CACN,GAAI,SAAS,SAAS,EAAE,SAAS,IAAI,CAAC;CACtC;CACA,GAAG;AACL;AAEA,MAAM,UAAU;CAAC;CAAS;CAAa;CAAkB;CAAc;AAAc;AACrF,MAAM,iBAAyB;CAC7B,MAAM;CACN,MAAM,CAAC,UAAU,UAAU;CAC3B,aACE;AACJ;AACA,MAAM,aAAqB;CACzB,MAAM;CACN,MAAM;EAAC;EAAU;EAAY;CAAS;CACtC,a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ACN,MAAW,MAAM;EACnB;CACF;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { s as Definition } from "./policy-CGA6QD0a.mjs";
2
2
  import { h as SubjectIdentity } from "./catalog-DJcJ3ycq.mjs";
3
- import { t as PermissionsAuthProvider } from "./contract-D32H1t0u.mjs";
4
- import { r as ToKitAuthOptions } from "./kit-DMVBLBI9.mjs";
3
+ import { t as PermissionsAuthProvider } from "./contract-D6j-yrBL.mjs";
4
+ import { r as ToKitAuthOptions } from "./kit-51JtMxsn.mjs";
5
5
  import { n as AuthorizationProvider } from "./contract-CNgMXr2u.mjs";
6
- import { i as Permissions, o as PermissionsOptions } from "./engine-DpFIcbgh.mjs";
6
+ import { i as Permissions, o as PermissionsOptions } from "./engine-C3xHfi3q.mjs";
7
7
  import { CorsOptions as PermissionsCorsOptions } from "@xtandard/kit/server";
8
8
  import { AuthProvider as AuthProvider$1, Principal as Principal$1 } from "@xtandard/kit/auth";
9
9
 
@@ -74,4 +74,4 @@ interface CreateFetchHandlerResult<D extends Definition = Definition, R extends
74
74
  declare function createFetchHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): CreateFetchHandlerResult<D, R, P, X>;
75
75
  //#endregion
76
76
  export { AuthProvider$1 as a, PermissionsCorsOptions as i, PermissionsPanelOptions as n, Principal$1 as o, createFetchHandler as r, CreateFetchHandlerResult as t };
77
- //# sourceMappingURL=create-fetch-handler-BHDU4chu.d.mts.map
77
+ //# sourceMappingURL=create-fetch-handler-B711wb64.d.mts.map
@@ -1,8 +1,8 @@
1
1
  const require_chunk = require("./chunk-DakpK96I.cjs");
2
- const require_engine = require("./engine-bMoz3iW-.cjs");
3
- const require_kit = require("./kit-C7tepDB2.cjs");
2
+ const require_engine = require("./engine--C7zo-4M.cjs");
3
+ const require_kit = require("./kit-BrqnCcDw.cjs");
4
4
  const require_contract = require("./contract-Bpy8yPrS.cjs");
5
- const require_routes = require("./routes-irNuuZqo.cjs");
5
+ const require_routes = require("./routes-B2LrYpT0.cjs");
6
6
  let _xtandard_kit_server = require("@xtandard/kit/server");
7
7
  let _xtandard_kit_server_router = require("@xtandard/kit/server/router");
8
8
  //#region src/server/openapi.ts
@@ -49,6 +49,20 @@ const REASONS = [
49
49
  "rule-threw",
50
50
  "unknown-path"
51
51
  ];
52
+ const roleSourceMode = {
53
+ type: "string",
54
+ enum: ["stored", "external"],
55
+ description: "Who owns roles: `stored` (a stored role wins) or `external` (the auth provider; role changes are refused)."
56
+ };
57
+ const roleSource = {
58
+ type: "string",
59
+ enum: [
60
+ "stored",
61
+ "provider",
62
+ "default"
63
+ ],
64
+ description: "What decided the effective role: a stored assignment, the auth provider's role, or the catalog's `defaultRole`."
65
+ };
52
66
  const schemas = {
53
67
  Health: obj({ ok: bool }, ["ok"]),
54
68
  PanelConfig: obj({
@@ -56,10 +70,12 @@ const schemas = {
56
70
  logoUrl: str,
57
71
  basePath: str,
58
72
  readonly: bool,
73
+ roleSource: roleSourceMode,
59
74
  authenticated: bool,
60
75
  principal: { oneOf: [obj({
61
76
  id: str,
62
77
  role: str,
78
+ roleSource,
63
79
  name: str,
64
80
  email: str
65
81
  }, ["id", "role"]), { type: "null" }] },
@@ -75,6 +91,7 @@ const schemas = {
75
91
  "title",
76
92
  "basePath",
77
93
  "readonly",
94
+ "roleSource",
78
95
  "authenticated",
79
96
  "principal",
80
97
  "allowed"
@@ -94,6 +111,7 @@ const schemas = {
94
111
  defaultRole: str,
95
112
  managerRoles: strings,
96
113
  directGrants: bool,
114
+ roleSource: roleSourceMode,
97
115
  paths: {
98
116
  ...strings,
99
117
  description: "Every leaf rule path of every role, sorted."
@@ -109,6 +127,7 @@ const schemas = {
109
127
  "defaultRole",
110
128
  "managerRoles",
111
129
  "directGrants",
130
+ "roleSource",
112
131
  "paths",
113
132
  "relations"
114
133
  ]),
@@ -202,13 +221,20 @@ const schemas = {
202
221
  SubjectRefList: obj({ subjects: strings }, ["subjects"]),
203
222
  SubjectSummary: obj({
204
223
  id: str,
205
- role: nullableStr,
224
+ role: {
225
+ ...nullableStr,
226
+ description: "The stored role assignment, if any."
227
+ },
228
+ effectiveRole: str,
229
+ roleSource,
206
230
  name: str,
207
231
  email: str,
208
232
  grantCount: int
209
233
  }, [
210
234
  "id",
211
235
  "role",
236
+ "effectiveRole",
237
+ "roleSource",
212
238
  "grantCount"
213
239
  ]),
214
240
  SubjectList: obj({ subjects: arrayOf("SubjectSummary") }, ["subjects"]),
@@ -228,6 +254,7 @@ const schemas = {
228
254
  },
229
255
  grants: arrayOf("Grant"),
230
256
  effectiveRole: str,
257
+ roleSource,
231
258
  permissions: {
232
259
  ...strings,
233
260
  description: "Active assignable permissions."
@@ -238,6 +265,7 @@ const schemas = {
238
265
  "role",
239
266
  "grants",
240
267
  "effectiveRole",
268
+ "roleSource",
241
269
  "permissions"
242
270
  ]),
243
271
  SubjectUpdate: obj({
@@ -400,6 +428,10 @@ const schemas = {
400
428
  path: str,
401
429
  subject: nullableStr,
402
430
  role: str,
431
+ roleSource: {
432
+ ...roleSource,
433
+ description: "What decided `role` (absent for a guest)."
434
+ },
403
435
  reason: {
404
436
  type: "string",
405
437
  enum: REASONS
@@ -416,7 +448,8 @@ const schemas = {
416
448
  PermissionsSnapshot: obj({
417
449
  subject: obj({
418
450
  id: nullableStr,
419
- role: str
451
+ role: str,
452
+ roleSource
420
453
  }, ["id", "role"]),
421
454
  permissions: strings
422
455
  }, ["subject", "permissions"])
@@ -509,6 +542,10 @@ function buildOpenApiDocument(options = {}) {
509
542
  content: { "application/json": { schema: (0, _xtandard_kit_server_router.ref)("GrantResult") } }
510
543
  };
511
544
  }
545
+ if (spec.operationId === "updateSubject") {
546
+ const responses = out.responses;
547
+ responses["409"] = (0, _xtandard_kit_server_router.errorResponse)("Roles are managed by the auth provider (`roleSource: \"external\"`; code `ROLES_EXTERNAL`)");
548
+ }
512
549
  if (spec.operationId === "writeRelationship") {
513
550
  const responses = out.responses;
514
551
  responses["200"] = {
@@ -650,4 +687,4 @@ Object.defineProperty(exports, "create_fetch_handler_exports", {
650
687
  }
651
688
  });
652
689
 
653
- //# sourceMappingURL=create-fetch-handler-C-WyaRCR.cjs.map
690
+ //# sourceMappingURL=create-fetch-handler-BHT4vSZs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-fetch-handler-BHT4vSZs.cjs","names":["ALL_ACTIONS","API_ROUTES","CONFIG_PATHS","createPermissions","toKitAuth","createApiRouter"],"sources":["../src/server/openapi.ts","../src/server/create-fetch-handler.ts"],"sourcesContent":["/**\n * OpenAPI 3.1 description of the panel's HTTP API, served at `GET {basePath}/api/openapi.json`\n * and returned by `createFetchHandler(...).openapi()` (merge it into the host's document).\n *\n * Paths come from the router's own table ({@link API_ROUTES}), so every served route is\n * documented; admin routes carry their action as `x-action`, runtime routes `x-runtime: true`.\n * Component schemas are hand-authored (no generation dependency, the family's precedent).\n *\n * @module\n */\n\nimport {\n buildOpenApiDocument as kitBuildOpenApiDocument,\n errorResponse,\n ref,\n} from \"@xtandard/kit/server/router\";\nimport { ALL_ACTIONS, isMutatingAction } from \"../authorization/contract.ts\";\nimport { API_ROUTES, CONFIG_PATHS, type RouteSpec } from \"./routes.ts\";\n\n/** Options for {@link buildOpenApiDocument}. */\nexport interface OpenApiOptions {\n /** Mount prefix used in the `servers` url (e.g. `\"/permissions\"`). */\n basePath?: string;\n /** Document title. Default `\"@xtandard/permissions\"`. */\n title?: string;\n /** Document version. Default `\"1\"` (the HTTP API version, not the package version). */\n version?: string;\n}\n\ntype Schema = Record<string, unknown>;\n\nconst str: Schema = { type: \"string\" };\nconst int: Schema = { type: \"integer\" };\nconst bool: Schema = { type: \"boolean\" };\nconst time: Schema = { type: \"string\", format: \"date-time\" };\nconst nullableStr: Schema = { type: [\"string\", \"null\"] };\nconst nullableTime: Schema = { type: [\"string\", \"null\"], format: \"date-time\" };\nconst strings: Schema = { type: \"array\", items: str };\nconst arrayOf = (name: string): Schema => ({ type: \"array\", items: ref(name) });\nconst obj = (properties: Schema, required: string[] = [], extra: Schema = {}): Schema => ({\n type: \"object\",\n ...(required.length ? { required } : {}),\n properties,\n ...extra,\n});\n\nconst REASONS = [\"grant\", \"role-rule\", \"denied-by-rule\", \"rule-threw\", \"unknown-path\"];\nconst roleSourceMode: Schema = {\n type: \"string\",\n enum: [\"stored\", \"external\"],\n description:\n \"Who owns roles: `stored` (a stored role wins) or `external` (the auth provider; role changes are refused).\",\n};\nconst roleSource: Schema = {\n type: \"string\",\n enum: [\"stored\", \"provider\", \"default\"],\n description:\n \"What decided the effective role: a stored assignment, the auth provider's role, or the catalog's `defaultRole`.\",\n};\n\nconst schemas: Record<string, Schema> = {\n Health: obj({ ok: bool }, [\"ok\"]),\n PanelConfig: obj(\n {\n title: str,\n logoUrl: str,\n basePath: str,\n readonly: bool,\n roleSource: roleSourceMode,\n authenticated: bool,\n principal: {\n oneOf: [\n obj({ id: str, role: str, roleSource, name: str, email: str }, [\"id\", \"role\"]),\n { type: \"null\" },\n ],\n },\n allowed: {\n type: \"array\",\n items: { type: \"string\", enum: [...ALL_ACTIONS] },\n description: \"The actions the caller may perform (mutating ones left out when readonly).\",\n },\n },\n [\"title\", \"basePath\", \"readonly\", \"roleSource\", \"authenticated\", \"principal\", \"allowed\"],\n ),\n LabeledKey: obj({ key: str, label: str, description: str }, [\"key\", \"label\"]),\n CatalogView: obj(\n {\n roles: { ...arrayOf(\"LabeledKey\"), description: \"Least → most privileged.\" },\n assignable: arrayOf(\"LabeledKey\"),\n guestRole: str,\n defaultRole: str,\n managerRoles: strings,\n directGrants: bool,\n roleSource: roleSourceMode,\n paths: { ...strings, description: \"Every leaf rule path of every role, sorted.\" },\n relations: {\n oneOf: [arrayOf(\"RelationTypeView\"), { type: \"null\" }],\n description: \"The relation schema (ReBAC); `null` when the catalog declares none.\",\n },\n },\n [\n \"roles\",\n \"assignable\",\n \"guestRole\",\n \"defaultRole\",\n \"managerRoles\",\n \"directGrants\",\n \"roleSource\",\n \"paths\",\n \"relations\",\n ],\n ),\n RelationTypeView: obj(\n {\n type: str,\n relations: {\n type: \"array\",\n items: obj(\n {\n name: str,\n subjects: {\n ...strings,\n description:\n 'What may be stored: \"user\", \"group#member\", \"user:*\" (empty: computed only).',\n },\n rule: { ...str, description: \"The rule on one line.\" },\n },\n [\"name\", \"subjects\", \"rule\"],\n ),\n },\n },\n [\"type\", \"relations\"],\n ),\n Relationship: obj(\n {\n object: { ...str, description: '\"doc:1\"' },\n relation: str,\n subject: { ...str, description: '\"user:ana\", \"group:eng#member\" or \"user:*\"' },\n createdBy: nullableStr,\n createdAt: time,\n reason: str,\n },\n [\"object\", \"relation\", \"subject\", \"createdBy\", \"createdAt\"],\n ),\n RelationshipPage: obj({ relationships: arrayOf(\"Relationship\"), nextCursor: nullableStr }, [\n \"relationships\",\n \"nextCursor\",\n ]),\n RelationshipInput: obj(\n { object: str, relation: str, subject: str, reason: { ...str, maxLength: 1000 } },\n [\"object\", \"relation\", \"subject\"],\n ),\n WriteRelationshipResult: obj({ relationship: ref(\"Relationship\"), created: bool }, [\n \"relationship\",\n \"created\",\n ]),\n DeleteRelationshipResult: obj(\n { removed: bool, relationship: { oneOf: [ref(\"Relationship\"), { type: \"null\" }] } },\n [\"removed\", \"relationship\"],\n ),\n RelationCheckInput: obj({ subject: str, relation: str, object: str }, [\n \"subject\",\n \"relation\",\n \"object\",\n ]),\n MeRelationInput: obj({ relation: str, object: str }, [\"relation\", \"object\"]),\n RelationCheckResult: obj(\n {\n allowed: bool,\n path: {\n ...strings,\n description:\n 'When allowed, the hops from the object to the subject, e.g. [\"doc:1#viewer\", \"folder:7#viewer (from doc:1#parent)\", \"group:eng#member\", \"user:ana\"].',\n },\n },\n [\"allowed\", \"path\"],\n ),\n ObjectList: obj({ objects: strings }, [\"objects\"]),\n SubjectRefList: obj({ subjects: strings }, [\"subjects\"]),\n SubjectSummary: obj(\n {\n id: str,\n role: { ...nullableStr, description: \"The stored role assignment, if any.\" },\n effectiveRole: str,\n roleSource,\n name: str,\n email: str,\n grantCount: int,\n },\n [\"id\", \"role\", \"effectiveRole\", \"roleSource\", \"grantCount\"],\n ),\n SubjectList: obj({ subjects: arrayOf(\"SubjectSummary\") }, [\"subjects\"]),\n SubjectRecord: obj({ id: str, role: str, name: str, email: str, updatedAt: time }, [\n \"id\",\n \"updatedAt\",\n ]),\n SubjectDetail: obj(\n {\n id: str,\n record: { oneOf: [ref(\"SubjectRecord\"), { type: \"null\" }] },\n role: { ...nullableStr, description: \"The stored role assignment, if valid.\" },\n grants: arrayOf(\"Grant\"),\n effectiveRole: str,\n roleSource,\n permissions: { ...strings, description: \"Active assignable permissions.\" },\n },\n [\"id\", \"record\", \"role\", \"grants\", \"effectiveRole\", \"roleSource\", \"permissions\"],\n ),\n SubjectUpdate: obj({\n role: { ...nullableStr, description: \"`null` clears the stored role.\" },\n name: { ...nullableStr, description: \"`null` clears it.\" },\n email: { ...nullableStr, description: \"`null` clears it.\" },\n reason: { ...str, maxLength: 1000, description: \"Recorded with a role change.\" },\n }),\n Grant: obj(\n {\n subject: str,\n permission: str,\n grantedBy: nullableStr,\n grantedAt: time,\n reason: str,\n expiresAt: nullableTime,\n },\n [\"subject\", \"permission\", \"grantedBy\", \"grantedAt\"],\n ),\n GrantList: obj({ grants: arrayOf(\"Grant\") }, [\"grants\"]),\n GrantInput: obj(\n {\n subject: str,\n permission: { ...str, description: \"One of the catalog's assignable permissions.\" },\n reason: { ...str, maxLength: 1000 },\n expiresAt: {\n type: [\"string\", \"number\", \"null\"],\n description: \"ISO-8601 or unix ms, in the future; `null` = never.\",\n },\n },\n [\"subject\", \"permission\"],\n ),\n GrantResult: obj({ grant: ref(\"Grant\"), created: bool }, [\"grant\", \"created\"]),\n RevokeInput: obj({ reason: { ...str, maxLength: 1000 } }),\n RevokeResult: obj({ removed: bool, grant: { oneOf: [ref(\"Grant\"), { type: \"null\" }] } }, [\n \"removed\",\n \"grant\",\n ]),\n HistoryEntry: obj(\n {\n id: str,\n type: { type: \"string\", enum: [\"grant\", \"revoke\", \"role\", \"relate\", \"unrelate\"] },\n subject: str,\n object: { ...str, description: \"For relate / unrelate.\" },\n relation: { ...str, description: \"For relate / unrelate.\" },\n permission: str,\n role: nullableStr,\n previousRole: nullableStr,\n expiresAt: nullableTime,\n actor: nullableStr,\n reason: str,\n at: time,\n },\n [\"id\", \"type\", \"subject\", \"actor\", \"at\"],\n ),\n HistoryPage: obj({ entries: arrayOf(\"HistoryEntry\"), nextCursor: nullableStr }, [\n \"entries\",\n \"nextCursor\",\n ]),\n CheckInput: obj(\n {\n subject: { ...nullableStr, description: \"A stored subject.\" },\n role: { ...str, description: \"A role (alone: no subject, no grants).\" },\n path: { ...str, description: 'A permix path, e.g. \"post.publish\".' },\n data: { description: \"The data the rule at `path` reads.\" },\n ctx: { description: \"The rules' app context, for catalogs that declare one.\" },\n },\n [\"path\"],\n ),\n MeCheckInput: obj({ path: str, data: { description: \"The data the rule reads.\" } }, [\"path\"]),\n CheckExplanation: obj(\n {\n type: { type: \"string\", enum: [\"allowed\", \"denied\", \"unknown_path\"] },\n path: str,\n role: str,\n permissions: strings,\n decidedBy: { type: \"string\", enum: [\"constant\", \"predicate\", \"threw\", \"missing\"] },\n error: { ...str, description: \"The message of the error a throwing rule raised.\" },\n },\n [\"type\", \"path\", \"role\", \"permissions\", \"decidedBy\"],\n ),\n CheckResult: obj(\n {\n allowed: bool,\n path: str,\n subject: nullableStr,\n role: str,\n roleSource: { ...roleSource, description: \"What decided `role` (absent for a guest).\" },\n reason: { type: \"string\", enum: REASONS },\n explanation: ref(\"CheckExplanation\"),\n },\n [\"allowed\", \"path\", \"subject\", \"role\", \"reason\", \"explanation\"],\n ),\n PermissionsSnapshot: obj(\n {\n subject: obj({ id: nullableStr, role: str, roleSource }, [\"id\", \"role\"]),\n permissions: strings,\n },\n [\"subject\", \"permissions\"],\n ),\n};\n\n/** Runtime routes: authenticated (not public), no `x-action`, no 403. */\nfunction operation(spec: RouteSpec, op: Schema): Schema {\n if (!spec.runtime) return op;\n const { security: _public, ...rest } = op;\n const responses = rest.responses as Record<string, Schema>;\n return {\n ...rest,\n \"x-runtime\": true,\n responses: { ...responses, \"401\": errorResponse(\"Not authenticated\") },\n };\n}\n\n/** The bootstrap config operation (served at both {@link CONFIG_PATHS}). */\nconst configOperation = (operationId: string): Schema => ({\n operationId,\n tags: [\"panel\"],\n summary: \"SPA bootstrap config: title, readonly, the caller and its allowed actions\",\n security: [],\n responses: {\n \"200\": {\n description: \"Panel config\",\n content: { \"application/json\": { schema: ref(\"PanelConfig\") } },\n },\n },\n});\n\n/**\n * Build the OpenAPI 3.1 document for the panel API.\n *\n * @example\n * ```ts\n * import { buildOpenApiDocument } from \"@xtandard/permissions\";\n * const doc = buildOpenApiDocument({ basePath: \"/permissions\" });\n * ```\n */\nexport function buildOpenApiDocument(options: OpenApiOptions = {}): Record<string, unknown> {\n const doc = kitBuildOpenApiDocument({\n routes: API_ROUTES,\n title: options.title ?? \"@xtandard/permissions\",\n version: options.version ?? \"1\",\n description:\n \"Permissions admin API (catalog, subjects, grants, roles, relationships, history, check playground) and runtime API for the caller (`/api/me`). A denial is not an error: checks answer 200 with `allowed: false`.\",\n ...(options.basePath !== undefined ? { basePath: options.basePath } : {}),\n tags: [\n { name: \"panel\", description: \"Bootstrap, health, this document\" },\n { name: \"catalog\", description: \"Roles, assignable permissions, rule paths\" },\n { name: \"subjects\", description: \"Subjects and their stored roles\" },\n { name: \"grants\", description: \"Grant and revoke assignable permissions\" },\n { name: \"history\", description: \"Grant / revoke / role / relationship history\" },\n { name: \"check\", description: \"Check playground\" },\n { name: \"relationships\", description: \"Relationship tuples (ReBAC): write, check, list\" },\n { name: \"runtime\", description: \"The caller's own snapshot and checks\" },\n ],\n schemas,\n bearerDescription: \"Host-issued bearer credentials (e.g. a JWT with auth/jwt).\",\n isMutatingAction,\n readonlyStatus: 423,\n operation: (spec, op) => {\n const out = operation(spec as RouteSpec, op);\n if (spec.operationId === \"grant\") {\n const responses = out.responses as Record<string, Schema>;\n responses[\"200\"] = {\n description: \"Already granted (unchanged)\",\n content: { \"application/json\": { schema: ref(\"GrantResult\") } },\n };\n }\n if (spec.operationId === \"updateSubject\") {\n const responses = out.responses as Record<string, Schema>;\n responses[\"409\"] = errorResponse(\n 'Roles are managed by the auth provider (`roleSource: \"external\"`; code `ROLES_EXTERNAL`)',\n );\n }\n if (spec.operationId === \"writeRelationship\") {\n const responses = out.responses as Record<string, Schema>;\n responses[\"200\"] = {\n description: \"Already stored (unchanged)\",\n content: { \"application/json\": { schema: ref(\"WriteRelationshipResult\") } },\n };\n }\n return out;\n },\n });\n const paths: Record<string, unknown> = {};\n for (const path of CONFIG_PATHS) {\n paths[path] = { get: configOperation(path === \"/config\" ? \"getConfig\" : \"getApiConfig\") };\n }\n return { ...doc, paths: { ...paths, ...(doc.paths as Record<string, unknown>) } };\n}\n","/**\n * The web-standard fetch handler behind every framework adapter, the CLI's `serve` and the\n * standalone app (ADR 0008): the kit's `createPanelHandler` (healthcheck, static UI, SPA fallback,\n * CORS, OpenAPI) around the permissions API router.\n *\n * Auth plugs in three ways:\n *\n * - `auth` + `authorization`: any kit `AuthProvider` / `AuthorizationProvider` (e.g. `basicAuth` +\n * `rolesAuthorization`, or the pair `toKitAuth(provider, perms)` returns);\n * - `provider`: a `PermissionsAuthProvider` (better-auth, session, JWT), adapted with `toKitAuth`\n * (explicit `auth` / `authorization` still win);\n * - nothing: anonymous, allow-all (embedded / local use only).\n *\n * @module\n */\n\nimport {\n createPanelHandler,\n normalizeBasePath,\n resolveUiDir,\n type PanelHandler,\n} from \"@xtandard/kit/server\";\nimport { toKitAuth, type ToKitAuthOptions } from \"../auth-provider/kit.ts\";\nimport type { PermissionsAuthProvider } from \"../auth-provider/contract.ts\";\nimport type { AuthProvider, Principal } from \"../auth/contract.ts\";\nimport type { AuthorizationProvider } from \"../authorization/contract.ts\";\nimport type { SubjectIdentity } from \"../catalog.ts\";\nimport {\n createPermissions,\n type AnyPermissions,\n type Permissions,\n type PermissionsOptions,\n} from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { PermissionsCorsOptions } from \"./cors.ts\";\nimport { buildOpenApiDocument } from \"./openapi.ts\";\nimport { createApiRouter, type ApiContext } from \"./routes.ts\";\n\n/** Options for the panel handler (shared by every framework adapter). */\nexport interface PermissionsPanelOptions<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> extends Partial<PermissionsOptions<D, R, P, X>> {\n /**\n * The engine to serve. When omitted, one is built from the engine options on this object\n * (`catalog` and `storage` are then required; `hooks`, `cache`, … as for `createPermissions`).\n */\n permissions?: Permissions<D, R, P, X>;\n /** Mount prefix, e.g. `\"/permissions\"`. Default `\"\"` (root). */\n basePath?: string;\n /** Authentication. Default: from `provider`, else anonymous. */\n auth?: AuthProvider;\n /** Authorization of the admin routes. Default: from `provider`, else allow all. */\n authorization?: AuthorizationProvider;\n /**\n * A `PermissionsAuthProvider` (`auth/better-auth`, `auth/session`, `auth/jwt`, or your own),\n * adapted with `toKitAuth(provider, engine, providerOptions)`: managers (the catalog's\n * `managerRoles`, or the provider's `canManage`) may use the panel.\n */\n provider?: PermissionsAuthProvider;\n /** Options for the `toKitAuth` adaptation of `provider`. */\n providerOptions?: ToKitAuthOptions;\n /** Block grants and role changes (423). Also passed to a constructed engine. */\n readonly?: boolean;\n /** UI title. Default `\"@xtandard/permissions\"`. */\n title?: string;\n /** Logo image URL shown in the navbar in place of the title. */\n logoUrl?: string;\n /** Override the directory the bundled UI is served from (default `./ui` beside this module). */\n uiDir?: string;\n /** Answer CORS preflights and decorate every response. */\n cors?: PermissionsCorsOptions;\n /** The rules' `ctx` for the caller's runtime checks (`POST /api/me/check`). */\n checkContext?: (request: Request, subject: SubjectIdentity) => unknown;\n /** The caller's ReBAC subject for `POST /api/me/relation`. Default `user:{principal id}`. */\n relationSubject?: (principal: Principal) => string;\n}\n\n/** Return shape of {@link createFetchHandler}. */\nexport interface CreateFetchHandlerResult<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> {\n /** Web-standard request handler. */\n fetch(request: Request): Promise<Response>;\n /** The engine (given or constructed): use it in-process for checks. */\n engine: Permissions<D, R, P, X>;\n /** The HTTP API as an OpenAPI 3.1 document (also served at `{basePath}/api/openapi.json`). */\n openapi(): Record<string, unknown>;\n /** Stop the panel's background work (the engine is the caller's to `close()`). */\n close(): void;\n}\n\nconst defaultAuth: AuthProvider = { authenticate: async () => ({ id: \"anonymous\" }) };\nconst defaultAuthorization: AuthorizationProvider = { authorize: async () => true };\n\n/** Keys of {@link PermissionsPanelOptions} that are not engine options. */\nconst PANEL_KEYS = new Set([\n \"permissions\",\n \"basePath\",\n \"auth\",\n \"authorization\",\n \"provider\",\n \"providerOptions\",\n \"title\",\n \"logoUrl\",\n \"uiDir\",\n \"cors\",\n \"checkContext\",\n \"relationSubject\",\n]);\n\nfunction buildEngine<D extends Definition, R extends string, P extends string, X>(\n options: PermissionsPanelOptions<D, R, P, X>,\n): Permissions<D, R, P, X> {\n if (options.permissions) return options.permissions;\n if (!options.catalog || !options.storage) {\n throw new TypeError(\n \"createFetchHandler requires either `permissions` (an engine) or `catalog` and `storage` to build one.\",\n );\n }\n const engineOptions: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options)) {\n if (!PANEL_KEYS.has(key) && value !== undefined) engineOptions[key] = value;\n }\n return createPermissions(engineOptions as unknown as PermissionsOptions<D, R, P, X>);\n}\n\n/**\n * Build the panel fetch handler.\n *\n * @example\n * ```ts\n * import { createFetchHandler } from \"@xtandard/permissions\";\n * import { betterAuthProvider } from \"@xtandard/permissions/auth/better-auth\";\n *\n * const { fetch } = createFetchHandler({\n * permissions: perms,\n * provider: betterAuthProvider(auth, { mapRole: { user: \"member\" } }),\n * basePath: \"/permissions\",\n * });\n * Bun.serve({ port: 3000, fetch });\n * ```\n */\nexport function createFetchHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): CreateFetchHandlerResult<D, R, P, X> {\n const basePath = normalizeBasePath(options.basePath);\n const engine = buildEngine(options);\n const readonly = options.readonly ?? engine.readonly;\n const title = options.title ?? \"@xtandard/permissions\";\n const uiDir = options.uiDir ?? resolveUiDir(import.meta.url);\n const openapi = () => buildOpenApiDocument({ basePath, title });\n\n const fromProvider = options.provider\n ? toKitAuth(options.provider, engine, options.providerOptions)\n : undefined;\n\n const apiCtx: ApiContext = {\n engine: engine as unknown as AnyPermissions,\n auth: options.auth ?? fromProvider?.auth ?? defaultAuth,\n authorization: options.authorization ?? fromProvider?.authorization ?? defaultAuthorization,\n title,\n readonly,\n basePath,\n openapi,\n ...(options.logoUrl !== undefined ? { logoUrl: options.logoUrl } : {}),\n ...(options.checkContext ? { checkContext: options.checkContext } : {}),\n ...(options.relationSubject ? { relationSubject: options.relationSubject } : {}),\n };\n const router = createApiRouter(apiCtx);\n\n const panel: PanelHandler = createPanelHandler({\n basePath,\n title,\n ...(options.logoUrl !== undefined ? { logoUrl: options.logoUrl } : {}),\n readonly,\n globalName: \"__PERMISSIONS_CONFIG__\",\n uiDir,\n ...(options.cors ? { cors: options.cors } : {}),\n api: router.handle,\n openapi,\n });\n\n return {\n fetch: panel.fetch,\n engine,\n openapi,\n close() {\n void panel.close();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAM,MAAc,EAAE,MAAM,SAAS;AACrC,MAAM,MAAc,EAAE,MAAM,UAAU;AACtC,MAAM,OAAe,EAAE,MAAM,UAAU;AACvC,MAAM,OAAe;CAAE,MAAM;CAAU,QAAQ;AAAY;AAC3D,MAAM,cAAsB,EAAE,MAAM,CAAC,UAAU,MAAM,EAAE;AACvD,MAAM,eAAuB;CAAE,MAAM,CAAC,UAAU,MAAM;CAAG,QAAQ;AAAY;AAC7E,MAAM,UAAkB;CAAE,MAAM;CAAS,OAAO;AAAI;AACpD,MAAM,WAAW,UAA0B;CAAE,MAAM;CAAS,QAAA,GAAA,4BA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,MAAM,SAASC,eAAAA,gBAAgB;EAXrB;EACR,MAAM,QAAQ,QAAQ,cAAc,QAAQ;EAC5C,eAAe,QAAQ,iBAAiB,cAAc,iBAAiB;EACvE;EACA;EACA;EACA;EACA,GAAI,QAAQ,YAAY,KAAA,IAAY,EAAE,SAAS,QAAQ,QAAQ,IAAI,CAAC;EACpE,GAAI,QAAQ,eAAe,EAAE,cAAc,QAAQ,aAAa,IAAI,CAAC;EACrE,GAAI,QAAQ,kBAAkB,EAAE,iBAAiB,QAAQ,gBAAgB,IAAI,CAAC;CAE5C,CAAC;CAErC,MAAM,SAAA,GAAA,qBAAA,oBAAyC;EAC7C;EACA;EACA,GAAI,QAAQ,YAAY,KAAA,IAAY,EAAE,SAAS,QAAQ,QAAQ,IAAI,CAAC;EACpE;EACA,YAAY;EACZ;EACA,GAAI,QAAQ,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;EAC7C,KAAK,OAAO;EACZ;CACF,CAAC;CAED,OAAO;EACL,OAAO,MAAM;EACb;EACA;EACA,QAAQ;GACN,MAAW,MAAM;EACnB;CACF;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { s as Definition } from "./policy-DFq_SYR3.cjs";
2
2
  import { h as SubjectIdentity } from "./catalog-DA_d1SdC.cjs";
3
- import { t as PermissionsAuthProvider } from "./contract-BMiOmg2f.cjs";
4
- import { r as ToKitAuthOptions } from "./kit-qAROuhOI.cjs";
3
+ import { t as PermissionsAuthProvider } from "./contract-BAisPHBw.cjs";
4
+ import { r as ToKitAuthOptions } from "./kit-DLF7DZrp.cjs";
5
5
  import { n as AuthorizationProvider } from "./contract-CNgMXr2u.cjs";
6
- import { i as Permissions, o as PermissionsOptions } from "./engine-CGGVDCqi.cjs";
6
+ import { i as Permissions, o as PermissionsOptions } from "./engine-BTgwbHeO.cjs";
7
7
  import { AuthProvider as AuthProvider$1, Principal as Principal$1 } from "@xtandard/kit/auth";
8
8
  import { CorsOptions as PermissionsCorsOptions } from "@xtandard/kit/server";
9
9
 
@@ -74,4 +74,4 @@ interface CreateFetchHandlerResult<D extends Definition = Definition, R extends
74
74
  declare function createFetchHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): CreateFetchHandlerResult<D, R, P, X>;
75
75
  //#endregion
76
76
  export { AuthProvider$1 as a, PermissionsCorsOptions as i, PermissionsPanelOptions as n, Principal$1 as o, createFetchHandler as r, CreateFetchHandlerResult as t };
77
- //# sourceMappingURL=create-fetch-handler-BtX64_rS.d.cts.map
77
+ //# sourceMappingURL=create-fetch-handler-DxhvXuBA.d.cts.map
@@ -1,5 +1,5 @@
1
- const require_create_fetch_handler = require("./create-fetch-handler-C-WyaRCR.cjs");
2
- const require_guard = require("./guard-nwdOYe90.cjs");
1
+ const require_create_fetch_handler = require("./create-fetch-handler-BHT4vSZs.cjs");
2
+ const require_guard = require("./guard-DvaoUgjk.cjs");
3
3
  let _xtandard_kit_adapters_elysia = require("@xtandard/kit/adapters/elysia");
4
4
  //#region src/adapters/elysia-shared.ts
5
5
  /**
@@ -98,4 +98,4 @@ Object.defineProperty(exports, "requireRelation", {
98
98
  }
99
99
  });
100
100
 
101
- //# sourceMappingURL=elysia-shared-BUTFTeal.cjs.map
101
+ //# sourceMappingURL=elysia-shared-BFcWzfc9.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"elysia-shared-BUTFTeal.cjs","names":["createFetchHandler","evaluateGuard","guardEngine","outcomeResponse","evaluateRelationGuard","relationGuardEngine","relationOutcomeResponse"],"sources":["../src/adapters/elysia-shared.ts"],"sourcesContent":["/**\n * Elysia-version-agnostic pieces shared by the 1.x (`./elysia.ts`) and 2.x (`./elysia2.ts`)\n * adapters. Must not import `elysia`: each adapter's types are built against a different major.\n *\n * @module\n */\n\nimport { createPass as kitCreatePass, type PassContext } from \"@xtandard/kit/adapters/elysia\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n outcomeResponse,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** A web-standard fetch handler with `engine` + `openapi()` attached. */\nexport interface ElysiaPermissionsHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> {\n /** Handle a request (what `Elysia.mount(path, handler)` calls). */\n (request: Request): Promise<Response>;\n /** The engine (given or constructed). */\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n /** The HTTP API as an OpenAPI 3.1 document. */\n openapi(): Record<string, unknown>;\n /** Stop the panel's background work. */\n close(): void;\n}\n\n/** Create a panel handler suitable for `Elysia.mount(path, handler)`. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): ElysiaPermissionsHandler<D, R, P, X> {\n const handler = createFetchHandler(options);\n const fn = ((request: Request) => handler.fetch(request)) as ElysiaPermissionsHandler<D, R, P, X>;\n fn.engine = handler.engine;\n fn.openapi = handler.openapi;\n fn.close = handler.close;\n return fn;\n}\n\n/** Options for `permissionsElysia`. */\nexport interface PermissionsElysiaOptions<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> extends PermissionsPanelOptions<D, R, P, X> {\n /** Mount prefix; also the panel basePath. Default `\"/permissions\"`. */\n prefix?: string;\n}\n\n/**\n * The handlers every declared route delegates to. Elysia parses the body of declared routes\n * (draining the stream); `pass` rebuilds the Request from the parsed body before delegating.\n */\nexport function createPass(options: PermissionsElysiaOptions): {\n prefix: string;\n handler: CreateFetchHandlerResult;\n pass: (ctx: PassContext) => Promise<Response>;\n} {\n const prefix = options.prefix ?? \"/permissions\";\n const handler = createFetchHandler({ ...options, basePath: options.basePath ?? prefix });\n const { pass } = kitCreatePass({ prefix, fetch: handler.fetch, name: \"xtandard-permissions\" });\n return { prefix, handler, pass };\n}\n\n/** The minimal Elysia context the guard reads / writes (both majors). */\nexport interface ElysiaGuardContext {\n request: Request;\n /** Set by the guard to the allowing decision. */\n permission?: CheckResult;\n /** Set by `requireRelation` to the allowing relationship decision. */\n relation?: RelationDecision;\n [key: string]: unknown;\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x): `401` / `403` JSON for denials; for an allowed\n * request it sets `ctx.permission` and lets the handler run.\n *\n * ```ts\n * app.post(\"/refund\", ({ permission }) => ({ ok: true }), {\n * beforeHandle: requirePermission(perms, \"billing.refund\", { provider }),\n * });\n * ```\n */\nexport function requirePermission<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateGuard(guardEngine(engine), path, options, ctx, (c) => c.request);\n if (!outcome.allowed) return outcomeResponse(outcome, options, ctx);\n ctx.permission = outcome.result;\n return undefined;\n };\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x) for a relationship (ReBAC): the caller\n * (`user:{id}` unless `subjectRef`) must have `relation` on the object; sets `ctx.relation`.\n *\n * ```ts\n * app.put(\"/docs/:id\", handler, {\n * beforeHandle: requireRelation(perms, \"editor\", (c) => `doc:${c.params.id}`, { provider }),\n * });\n * ```\n */\nexport function requireRelation<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n relation: string,\n object: RelationObjectInput<Ctx>,\n options: RequireRelationOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n ctx,\n (c) => c.request,\n );\n if (!outcome.allowed) return relationOutcomeResponse(outcome, options, ctx);\n ctx.relation = outcome.result;\n return undefined;\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;AAgDA,SAAgB,iBAKd,SAAoF;CACpF,MAAM,UAAUA,6BAAAA,mBAAmB,OAAO;CAC1C,MAAM,OAAO,YAAqB,QAAQ,MAAM,OAAO;CACvD,GAAG,SAAS,QAAQ;CACpB,GAAG,UAAU,QAAQ;CACrB,GAAG,QAAQ,QAAQ;CACnB,OAAO;AACT;;;;;AAiBA,SAAgB,WAAW,SAIzB;CACA,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,UAAUA,6BAAAA,mBAAmB;EAAE,GAAG;EAAS,UAAU,QAAQ,YAAY;CAAO,CAAC;CACvF,MAAM,EAAE,UAAA,GAAA,8BAAA,YAAuB;EAAE;EAAQ,OAAO,QAAQ;EAAO,MAAM;CAAuB,CAAC;CAC7F,OAAO;EAAE;EAAQ;EAAS;CAAK;AACjC;;;;;;;;;;;AAsBA,SAAgB,kBAId,QACA,MACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAMC,cAAAA,cAAcC,cAAAA,YAAY,MAAM,GAAG,MAAM,SAAS,MAAM,MAAM,EAAE,OAAO;EAC7F,IAAI,CAAC,QAAQ,SAAS,OAAOC,cAAAA,gBAAgB,SAAS,SAAS,GAAG;EAClE,IAAI,aAAa,QAAQ;CAE3B;AACF;;;;;;;;;;;AAYA,SAAgB,gBAId,QACA,UACA,QACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAMC,cAAAA,sBACpBC,cAAAA,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,MACC,MAAM,EAAE,OACX;EACA,IAAI,CAAC,QAAQ,SAAS,OAAOC,cAAAA,wBAAwB,SAAS,SAAS,GAAG;EAC1E,IAAI,WAAW,QAAQ;CAEzB;AACF"}
1
+ {"version":3,"file":"elysia-shared-BFcWzfc9.cjs","names":["createFetchHandler","evaluateGuard","guardEngine","outcomeResponse","evaluateRelationGuard","relationGuardEngine","relationOutcomeResponse"],"sources":["../src/adapters/elysia-shared.ts"],"sourcesContent":["/**\n * Elysia-version-agnostic pieces shared by the 1.x (`./elysia.ts`) and 2.x (`./elysia2.ts`)\n * adapters. Must not import `elysia`: each adapter's types are built against a different major.\n *\n * @module\n */\n\nimport { createPass as kitCreatePass, type PassContext } from \"@xtandard/kit/adapters/elysia\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n outcomeResponse,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** A web-standard fetch handler with `engine` + `openapi()` attached. */\nexport interface ElysiaPermissionsHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> {\n /** Handle a request (what `Elysia.mount(path, handler)` calls). */\n (request: Request): Promise<Response>;\n /** The engine (given or constructed). */\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n /** The HTTP API as an OpenAPI 3.1 document. */\n openapi(): Record<string, unknown>;\n /** Stop the panel's background work. */\n close(): void;\n}\n\n/** Create a panel handler suitable for `Elysia.mount(path, handler)`. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): ElysiaPermissionsHandler<D, R, P, X> {\n const handler = createFetchHandler(options);\n const fn = ((request: Request) => handler.fetch(request)) as ElysiaPermissionsHandler<D, R, P, X>;\n fn.engine = handler.engine;\n fn.openapi = handler.openapi;\n fn.close = handler.close;\n return fn;\n}\n\n/** Options for `permissionsElysia`. */\nexport interface PermissionsElysiaOptions<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> extends PermissionsPanelOptions<D, R, P, X> {\n /** Mount prefix; also the panel basePath. Default `\"/permissions\"`. */\n prefix?: string;\n}\n\n/**\n * The handlers every declared route delegates to. Elysia parses the body of declared routes\n * (draining the stream); `pass` rebuilds the Request from the parsed body before delegating.\n */\nexport function createPass(options: PermissionsElysiaOptions): {\n prefix: string;\n handler: CreateFetchHandlerResult;\n pass: (ctx: PassContext) => Promise<Response>;\n} {\n const prefix = options.prefix ?? \"/permissions\";\n const handler = createFetchHandler({ ...options, basePath: options.basePath ?? prefix });\n const { pass } = kitCreatePass({ prefix, fetch: handler.fetch, name: \"xtandard-permissions\" });\n return { prefix, handler, pass };\n}\n\n/** The minimal Elysia context the guard reads / writes (both majors). */\nexport interface ElysiaGuardContext {\n request: Request;\n /** Set by the guard to the allowing decision. */\n permission?: CheckResult;\n /** Set by `requireRelation` to the allowing relationship decision. */\n relation?: RelationDecision;\n [key: string]: unknown;\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x): `401` / `403` JSON for denials; for an allowed\n * request it sets `ctx.permission` and lets the handler run.\n *\n * ```ts\n * app.post(\"/refund\", ({ permission }) => ({ ok: true }), {\n * beforeHandle: requirePermission(perms, \"billing.refund\", { provider }),\n * });\n * ```\n */\nexport function requirePermission<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateGuard(guardEngine(engine), path, options, ctx, (c) => c.request);\n if (!outcome.allowed) return outcomeResponse(outcome, options, ctx);\n ctx.permission = outcome.result;\n return undefined;\n };\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x) for a relationship (ReBAC): the caller\n * (`user:{id}` unless `subjectRef`) must have `relation` on the object; sets `ctx.relation`.\n *\n * ```ts\n * app.put(\"/docs/:id\", handler, {\n * beforeHandle: requireRelation(perms, \"editor\", (c) => `doc:${c.params.id}`, { provider }),\n * });\n * ```\n */\nexport function requireRelation<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n relation: string,\n object: RelationObjectInput<Ctx>,\n options: RequireRelationOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n ctx,\n (c) => c.request,\n );\n if (!outcome.allowed) return relationOutcomeResponse(outcome, options, ctx);\n ctx.relation = outcome.result;\n return undefined;\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;AAgDA,SAAgB,iBAKd,SAAoF;CACpF,MAAM,UAAUA,6BAAAA,mBAAmB,OAAO;CAC1C,MAAM,OAAO,YAAqB,QAAQ,MAAM,OAAO;CACvD,GAAG,SAAS,QAAQ;CACpB,GAAG,UAAU,QAAQ;CACrB,GAAG,QAAQ,QAAQ;CACnB,OAAO;AACT;;;;;AAiBA,SAAgB,WAAW,SAIzB;CACA,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,UAAUA,6BAAAA,mBAAmB;EAAE,GAAG;EAAS,UAAU,QAAQ,YAAY;CAAO,CAAC;CACvF,MAAM,EAAE,UAAA,GAAA,8BAAA,YAAuB;EAAE;EAAQ,OAAO,QAAQ;EAAO,MAAM;CAAuB,CAAC;CAC7F,OAAO;EAAE;EAAQ;EAAS;CAAK;AACjC;;;;;;;;;;;AAsBA,SAAgB,kBAId,QACA,MACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAMC,cAAAA,cAAcC,cAAAA,YAAY,MAAM,GAAG,MAAM,SAAS,MAAM,MAAM,EAAE,OAAO;EAC7F,IAAI,CAAC,QAAQ,SAAS,OAAOC,cAAAA,gBAAgB,SAAS,SAAS,GAAG;EAClE,IAAI,aAAa,QAAQ;CAE3B;AACF;;;;;;;;;;;AAYA,SAAgB,gBAId,QACA,UACA,QACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAMC,cAAAA,sBACpBC,cAAAA,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,MACC,MAAM,EAAE,OACX;EACA,IAAI,CAAC,QAAQ,SAAS,OAAOC,cAAAA,wBAAwB,SAAS,SAAS,GAAG;EAC1E,IAAI,WAAW,QAAQ;CAEzB;AACF"}
@@ -1,5 +1,5 @@
1
- import { t as createFetchHandler } from "./create-fetch-handler-ojjpk1Iw.mjs";
2
- import { c as relationOutcomeResponse, n as evaluateRelationGuard, o as outcomeResponse, r as guardEngine, s as relationGuardEngine, t as evaluateGuard } from "./guard-BOx5cnMP.mjs";
1
+ import { t as createFetchHandler } from "./create-fetch-handler-B0twltQL.mjs";
2
+ import { c as relationOutcomeResponse, n as evaluateRelationGuard, o as outcomeResponse, r as guardEngine, s as relationGuardEngine, t as evaluateGuard } from "./guard-Bj8zk23F.mjs";
3
3
  import { createPass } from "@xtandard/kit/adapters/elysia";
4
4
  //#region src/adapters/elysia-shared.ts
5
5
  /**
@@ -75,4 +75,4 @@ function requireRelation(engine, relation, object, options) {
75
75
  //#endregion
76
76
  export { requireRelation as i, permissionsPanel as n, requirePermission as r, createPass$1 as t };
77
77
 
78
- //# sourceMappingURL=elysia-shared-BM6cPoCU.mjs.map
78
+ //# sourceMappingURL=elysia-shared-BwUYg0Ln.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"elysia-shared-BM6cPoCU.mjs","names":["createPass","kitCreatePass"],"sources":["../src/adapters/elysia-shared.ts"],"sourcesContent":["/**\n * Elysia-version-agnostic pieces shared by the 1.x (`./elysia.ts`) and 2.x (`./elysia2.ts`)\n * adapters. Must not import `elysia`: each adapter's types are built against a different major.\n *\n * @module\n */\n\nimport { createPass as kitCreatePass, type PassContext } from \"@xtandard/kit/adapters/elysia\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n outcomeResponse,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** A web-standard fetch handler with `engine` + `openapi()` attached. */\nexport interface ElysiaPermissionsHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> {\n /** Handle a request (what `Elysia.mount(path, handler)` calls). */\n (request: Request): Promise<Response>;\n /** The engine (given or constructed). */\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n /** The HTTP API as an OpenAPI 3.1 document. */\n openapi(): Record<string, unknown>;\n /** Stop the panel's background work. */\n close(): void;\n}\n\n/** Create a panel handler suitable for `Elysia.mount(path, handler)`. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): ElysiaPermissionsHandler<D, R, P, X> {\n const handler = createFetchHandler(options);\n const fn = ((request: Request) => handler.fetch(request)) as ElysiaPermissionsHandler<D, R, P, X>;\n fn.engine = handler.engine;\n fn.openapi = handler.openapi;\n fn.close = handler.close;\n return fn;\n}\n\n/** Options for `permissionsElysia`. */\nexport interface PermissionsElysiaOptions<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> extends PermissionsPanelOptions<D, R, P, X> {\n /** Mount prefix; also the panel basePath. Default `\"/permissions\"`. */\n prefix?: string;\n}\n\n/**\n * The handlers every declared route delegates to. Elysia parses the body of declared routes\n * (draining the stream); `pass` rebuilds the Request from the parsed body before delegating.\n */\nexport function createPass(options: PermissionsElysiaOptions): {\n prefix: string;\n handler: CreateFetchHandlerResult;\n pass: (ctx: PassContext) => Promise<Response>;\n} {\n const prefix = options.prefix ?? \"/permissions\";\n const handler = createFetchHandler({ ...options, basePath: options.basePath ?? prefix });\n const { pass } = kitCreatePass({ prefix, fetch: handler.fetch, name: \"xtandard-permissions\" });\n return { prefix, handler, pass };\n}\n\n/** The minimal Elysia context the guard reads / writes (both majors). */\nexport interface ElysiaGuardContext {\n request: Request;\n /** Set by the guard to the allowing decision. */\n permission?: CheckResult;\n /** Set by `requireRelation` to the allowing relationship decision. */\n relation?: RelationDecision;\n [key: string]: unknown;\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x): `401` / `403` JSON for denials; for an allowed\n * request it sets `ctx.permission` and lets the handler run.\n *\n * ```ts\n * app.post(\"/refund\", ({ permission }) => ({ ok: true }), {\n * beforeHandle: requirePermission(perms, \"billing.refund\", { provider }),\n * });\n * ```\n */\nexport function requirePermission<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateGuard(guardEngine(engine), path, options, ctx, (c) => c.request);\n if (!outcome.allowed) return outcomeResponse(outcome, options, ctx);\n ctx.permission = outcome.result;\n return undefined;\n };\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x) for a relationship (ReBAC): the caller\n * (`user:{id}` unless `subjectRef`) must have `relation` on the object; sets `ctx.relation`.\n *\n * ```ts\n * app.put(\"/docs/:id\", handler, {\n * beforeHandle: requireRelation(perms, \"editor\", (c) => `doc:${c.params.id}`, { provider }),\n * });\n * ```\n */\nexport function requireRelation<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n relation: string,\n object: RelationObjectInput<Ctx>,\n options: RequireRelationOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n ctx,\n (c) => c.request,\n );\n if (!outcome.allowed) return relationOutcomeResponse(outcome, options, ctx);\n ctx.relation = outcome.result;\n return undefined;\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;AAgDA,SAAgB,iBAKd,SAAoF;CACpF,MAAM,UAAU,mBAAmB,OAAO;CAC1C,MAAM,OAAO,YAAqB,QAAQ,MAAM,OAAO;CACvD,GAAG,SAAS,QAAQ;CACpB,GAAG,UAAU,QAAQ;CACrB,GAAG,QAAQ,QAAQ;CACnB,OAAO;AACT;;;;;AAiBA,SAAgBA,aAAW,SAIzB;CACA,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,UAAU,mBAAmB;EAAE,GAAG;EAAS,UAAU,QAAQ,YAAY;CAAO,CAAC;CACvF,MAAM,EAAE,SAASC,WAAc;EAAE;EAAQ,OAAO,QAAQ;EAAO,MAAM;CAAuB,CAAC;CAC7F,OAAO;EAAE;EAAQ;EAAS;CAAK;AACjC;;;;;;;;;;;AAsBA,SAAgB,kBAId,QACA,MACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAM,cAAc,YAAY,MAAM,GAAG,MAAM,SAAS,MAAM,MAAM,EAAE,OAAO;EAC7F,IAAI,CAAC,QAAQ,SAAS,OAAO,gBAAgB,SAAS,SAAS,GAAG;EAClE,IAAI,aAAa,QAAQ;CAE3B;AACF;;;;;;;;;;;AAYA,SAAgB,gBAId,QACA,UACA,QACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAM,sBACpB,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,MACC,MAAM,EAAE,OACX;EACA,IAAI,CAAC,QAAQ,SAAS,OAAO,wBAAwB,SAAS,SAAS,GAAG;EAC1E,IAAI,WAAW,QAAQ;CAEzB;AACF"}
1
+ {"version":3,"file":"elysia-shared-BwUYg0Ln.mjs","names":["createPass","kitCreatePass"],"sources":["../src/adapters/elysia-shared.ts"],"sourcesContent":["/**\n * Elysia-version-agnostic pieces shared by the 1.x (`./elysia.ts`) and 2.x (`./elysia2.ts`)\n * adapters. Must not import `elysia`: each adapter's types are built against a different major.\n *\n * @module\n */\n\nimport { createPass as kitCreatePass, type PassContext } from \"@xtandard/kit/adapters/elysia\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n outcomeResponse,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** A web-standard fetch handler with `engine` + `openapi()` attached. */\nexport interface ElysiaPermissionsHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> {\n /** Handle a request (what `Elysia.mount(path, handler)` calls). */\n (request: Request): Promise<Response>;\n /** The engine (given or constructed). */\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n /** The HTTP API as an OpenAPI 3.1 document. */\n openapi(): Record<string, unknown>;\n /** Stop the panel's background work. */\n close(): void;\n}\n\n/** Create a panel handler suitable for `Elysia.mount(path, handler)`. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): ElysiaPermissionsHandler<D, R, P, X> {\n const handler = createFetchHandler(options);\n const fn = ((request: Request) => handler.fetch(request)) as ElysiaPermissionsHandler<D, R, P, X>;\n fn.engine = handler.engine;\n fn.openapi = handler.openapi;\n fn.close = handler.close;\n return fn;\n}\n\n/** Options for `permissionsElysia`. */\nexport interface PermissionsElysiaOptions<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> extends PermissionsPanelOptions<D, R, P, X> {\n /** Mount prefix; also the panel basePath. Default `\"/permissions\"`. */\n prefix?: string;\n}\n\n/**\n * The handlers every declared route delegates to. Elysia parses the body of declared routes\n * (draining the stream); `pass` rebuilds the Request from the parsed body before delegating.\n */\nexport function createPass(options: PermissionsElysiaOptions): {\n prefix: string;\n handler: CreateFetchHandlerResult;\n pass: (ctx: PassContext) => Promise<Response>;\n} {\n const prefix = options.prefix ?? \"/permissions\";\n const handler = createFetchHandler({ ...options, basePath: options.basePath ?? prefix });\n const { pass } = kitCreatePass({ prefix, fetch: handler.fetch, name: \"xtandard-permissions\" });\n return { prefix, handler, pass };\n}\n\n/** The minimal Elysia context the guard reads / writes (both majors). */\nexport interface ElysiaGuardContext {\n request: Request;\n /** Set by the guard to the allowing decision. */\n permission?: CheckResult;\n /** Set by `requireRelation` to the allowing relationship decision. */\n relation?: RelationDecision;\n [key: string]: unknown;\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x): `401` / `403` JSON for denials; for an allowed\n * request it sets `ctx.permission` and lets the handler run.\n *\n * ```ts\n * app.post(\"/refund\", ({ permission }) => ({ ok: true }), {\n * beforeHandle: requirePermission(perms, \"billing.refund\", { provider }),\n * });\n * ```\n */\nexport function requirePermission<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateGuard(guardEngine(engine), path, options, ctx, (c) => c.request);\n if (!outcome.allowed) return outcomeResponse(outcome, options, ctx);\n ctx.permission = outcome.result;\n return undefined;\n };\n}\n\n/**\n * An Elysia `beforeHandle` guard (1.x and 2.x) for a relationship (ReBAC): the caller\n * (`user:{id}` unless `subjectRef`) must have `relation` on the object; sets `ctx.relation`.\n *\n * ```ts\n * app.put(\"/docs/:id\", handler, {\n * beforeHandle: requireRelation(perms, \"editor\", (c) => `doc:${c.params.id}`, { provider }),\n * });\n * ```\n */\nexport function requireRelation<\n E extends AnyPermissions,\n Ctx extends ElysiaGuardContext = ElysiaGuardContext,\n>(\n engine: E,\n relation: string,\n object: RelationObjectInput<Ctx>,\n options: RequireRelationOptions<Ctx>,\n): (ctx: Ctx) => Promise<Response | undefined> {\n return async (ctx) => {\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n ctx,\n (c) => c.request,\n );\n if (!outcome.allowed) return relationOutcomeResponse(outcome, options, ctx);\n ctx.relation = outcome.result;\n return undefined;\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;AAgDA,SAAgB,iBAKd,SAAoF;CACpF,MAAM,UAAU,mBAAmB,OAAO;CAC1C,MAAM,OAAO,YAAqB,QAAQ,MAAM,OAAO;CACvD,GAAG,SAAS,QAAQ;CACpB,GAAG,UAAU,QAAQ;CACrB,GAAG,QAAQ,QAAQ;CACnB,OAAO;AACT;;;;;AAiBA,SAAgBA,aAAW,SAIzB;CACA,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,UAAU,mBAAmB;EAAE,GAAG;EAAS,UAAU,QAAQ,YAAY;CAAO,CAAC;CACvF,MAAM,EAAE,SAASC,WAAc;EAAE;EAAQ,OAAO,QAAQ;EAAO,MAAM;CAAuB,CAAC;CAC7F,OAAO;EAAE;EAAQ;EAAS;CAAK;AACjC;;;;;;;;;;;AAsBA,SAAgB,kBAId,QACA,MACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAM,cAAc,YAAY,MAAM,GAAG,MAAM,SAAS,MAAM,MAAM,EAAE,OAAO;EAC7F,IAAI,CAAC,QAAQ,SAAS,OAAO,gBAAgB,SAAS,SAAS,GAAG;EAClE,IAAI,aAAa,QAAQ;CAE3B;AACF;;;;;;;;;;;AAYA,SAAgB,gBAId,QACA,UACA,QACA,SAC6C;CAC7C,OAAO,OAAO,QAAQ;EACpB,MAAM,UAAU,MAAM,sBACpB,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,MACC,MAAM,EAAE,OACX;EACA,IAAI,CAAC,QAAQ,SAAS,OAAO,wBAAwB,SAAS,SAAS,GAAG;EAC1E,IAAI,WAAW,QAAQ;CAEzB;AACF"}
@@ -1,8 +1,8 @@
1
1
  import { s as Definition } from "./policy-DFq_SYR3.cjs";
2
- import { h as CheckResult } from "./contract-Dk6d2ylD.cjs";
3
- import { t as AnyPermissions } from "./engine-CGGVDCqi.cjs";
4
- import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-BtX64_rS.cjs";
5
- import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-C3o7V14m.cjs";
2
+ import { h as CheckResult } from "./contract-CXPMGuHk.cjs";
3
+ import { t as AnyPermissions } from "./engine-BTgwbHeO.cjs";
4
+ import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-DxhvXuBA.cjs";
5
+ import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-VEK0W8ug.cjs";
6
6
  //#region src/adapters/elysia-shared.d.ts
7
7
  /** A web-standard fetch handler with `engine` + `openapi()` attached. */
8
8
  interface ElysiaPermissionsHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> {
@@ -55,4 +55,4 @@ declare function requirePermission<E extends AnyPermissions, Ctx extends ElysiaG
55
55
  declare function requireRelation<E extends AnyPermissions, Ctx extends ElysiaGuardContext = ElysiaGuardContext>(engine: E, relation: string, object: RelationObjectInput<Ctx>, options: RequireRelationOptions<Ctx>): (ctx: Ctx) => Promise<Response | undefined>;
56
56
  //#endregion
57
57
  export { requirePermission as a, permissionsPanel as i, ElysiaPermissionsHandler as n, requireRelation as o, PermissionsElysiaOptions as r, ElysiaGuardContext as t };
58
- //# sourceMappingURL=elysia-shared-DtKViycb.d.cts.map
58
+ //# sourceMappingURL=elysia-shared-C2LnDOj3.d.cts.map
@@ -1,8 +1,8 @@
1
1
  import { s as Definition } from "./policy-CGA6QD0a.mjs";
2
- import { h as CheckResult } from "./contract-DUzgB-He.mjs";
3
- import { t as AnyPermissions } from "./engine-DpFIcbgh.mjs";
4
- import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-BHDU4chu.mjs";
5
- import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-DCbTnqPz.mjs";
2
+ import { h as CheckResult } from "./contract-DhS23Pcp.mjs";
3
+ import { t as AnyPermissions } from "./engine-C3xHfi3q.mjs";
4
+ import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-B711wb64.mjs";
5
+ import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-k7A71SWC.mjs";
6
6
  //#region src/adapters/elysia-shared.d.ts
7
7
  /** A web-standard fetch handler with `engine` + `openapi()` attached. */
8
8
  interface ElysiaPermissionsHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> {
@@ -55,4 +55,4 @@ declare function requirePermission<E extends AnyPermissions, Ctx extends ElysiaG
55
55
  declare function requireRelation<E extends AnyPermissions, Ctx extends ElysiaGuardContext = ElysiaGuardContext>(engine: E, relation: string, object: RelationObjectInput<Ctx>, options: RequireRelationOptions<Ctx>): (ctx: Ctx) => Promise<Response | undefined>;
56
56
  //#endregion
57
57
  export { requirePermission as a, permissionsPanel as i, ElysiaPermissionsHandler as n, requireRelation as o, PermissionsElysiaOptions as r, ElysiaGuardContext as t };
58
- //# sourceMappingURL=elysia-shared-g8zsb_pU.d.mts.map
58
+ //# sourceMappingURL=elysia-shared-WuDr0jco.d.mts.map