@gadicc/loom 0.0.0-oidc-bootstrap.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 (342) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +6 -0
  3. package/README.md +448 -0
  4. package/THIRD_PARTY_NOTICES.md +25 -0
  5. package/db/drizzle-config.d.ts +20 -0
  6. package/db/drizzle-config.js +34 -0
  7. package/db/fixtures.d.ts +31 -0
  8. package/db/fixtures.js +52 -0
  9. package/db/neon.d.ts +3 -0
  10. package/db/neon.js +20 -0
  11. package/db/neonFull.d.ts +12 -0
  12. package/db/neonFull.js +33 -0
  13. package/db/package.json +3 -0
  14. package/db/testing.d.ts +26 -0
  15. package/db/testing.js +76 -0
  16. package/db/testing.test.ts +28 -0
  17. package/db/valibot.d.ts +23 -0
  18. package/db/valibot.js +8 -0
  19. package/esm/_dnt.polyfills.d.ts +149 -0
  20. package/esm/_dnt.polyfills.d.ts.map +1 -0
  21. package/esm/_dnt.polyfills.js +163 -0
  22. package/esm/_dnt.shims.d.ts +2 -0
  23. package/esm/_dnt.shims.d.ts.map +1 -0
  24. package/esm/_dnt.shims.js +57 -0
  25. package/esm/bin/loom.d.ts +2 -0
  26. package/esm/bin/loom.d.ts.map +1 -0
  27. package/esm/bin/loom.js +11 -0
  28. package/esm/mod.d.ts +9 -0
  29. package/esm/mod.d.ts.map +1 -0
  30. package/esm/mod.js +8 -0
  31. package/esm/package.json +3 -0
  32. package/esm/src/apiKeys/authorize.d.ts +4 -0
  33. package/esm/src/apiKeys/authorize.d.ts.map +1 -0
  34. package/esm/src/apiKeys/authorize.js +184 -0
  35. package/esm/src/apiKeys/country.d.ts +3 -0
  36. package/esm/src/apiKeys/country.d.ts.map +1 -0
  37. package/esm/src/apiKeys/country.js +7 -0
  38. package/esm/src/apiKeys/credentials.d.ts +4 -0
  39. package/esm/src/apiKeys/credentials.d.ts.map +1 -0
  40. package/esm/src/apiKeys/credentials.js +55 -0
  41. package/esm/src/apiKeys/fingerprint.d.ts +3 -0
  42. package/esm/src/apiKeys/fingerprint.d.ts.map +1 -0
  43. package/esm/src/apiKeys/fingerprint.js +5 -0
  44. package/esm/src/apiKeys/mod.d.ts +9 -0
  45. package/esm/src/apiKeys/mod.d.ts.map +1 -0
  46. package/esm/src/apiKeys/mod.js +8 -0
  47. package/esm/src/apiKeys/policy.d.ts +59 -0
  48. package/esm/src/apiKeys/policy.d.ts.map +1 -0
  49. package/esm/src/apiKeys/policy.js +88 -0
  50. package/esm/src/apiKeys/retention.d.ts +55 -0
  51. package/esm/src/apiKeys/retention.d.ts.map +1 -0
  52. package/esm/src/apiKeys/retention.js +65 -0
  53. package/esm/src/apiKeys/types.d.ts +175 -0
  54. package/esm/src/apiKeys/types.d.ts.map +1 -0
  55. package/esm/src/apiKeys/types.js +1 -0
  56. package/esm/src/cli/externalSkills.d.ts +39 -0
  57. package/esm/src/cli/externalSkills.d.ts.map +1 -0
  58. package/esm/src/cli/externalSkills.js +177 -0
  59. package/esm/src/cli/mod.d.ts +337 -0
  60. package/esm/src/cli/mod.d.ts.map +1 -0
  61. package/esm/src/cli/mod.js +9268 -0
  62. package/esm/src/cli/projectSkills.d.ts +102 -0
  63. package/esm/src/cli/projectSkills.d.ts.map +1 -0
  64. package/esm/src/cli/projectSkills.js +592 -0
  65. package/esm/src/files/client.d.ts +29 -0
  66. package/esm/src/files/client.d.ts.map +1 -0
  67. package/esm/src/files/client.js +41 -0
  68. package/esm/src/files/errors.d.ts +37 -0
  69. package/esm/src/files/errors.d.ts.map +1 -0
  70. package/esm/src/files/errors.js +66 -0
  71. package/esm/src/files/hash.d.ts +15 -0
  72. package/esm/src/files/hash.d.ts.map +1 -0
  73. package/esm/src/files/hash.js +82 -0
  74. package/esm/src/files/memory.d.ts +29 -0
  75. package/esm/src/files/memory.d.ts.map +1 -0
  76. package/esm/src/files/memory.js +109 -0
  77. package/esm/src/files/metadata.d.ts +10 -0
  78. package/esm/src/files/metadata.d.ts.map +1 -0
  79. package/esm/src/files/metadata.js +186 -0
  80. package/esm/src/files/mod.d.ts +10 -0
  81. package/esm/src/files/mod.d.ts.map +1 -0
  82. package/esm/src/files/mod.js +9 -0
  83. package/esm/src/files/s3.d.ts +29 -0
  84. package/esm/src/files/s3.d.ts.map +1 -0
  85. package/esm/src/files/s3.js +107 -0
  86. package/esm/src/files/service.d.ts +27 -0
  87. package/esm/src/files/service.d.ts.map +1 -0
  88. package/esm/src/files/service.js +136 -0
  89. package/esm/src/files/types.d.ts +134 -0
  90. package/esm/src/files/types.d.ts.map +1 -0
  91. package/esm/src/files/types.js +1 -0
  92. package/esm/src/jobs/catalog.d.ts +32 -0
  93. package/esm/src/jobs/catalog.d.ts.map +1 -0
  94. package/esm/src/jobs/catalog.js +208 -0
  95. package/esm/src/jobs/controller.d.ts +28 -0
  96. package/esm/src/jobs/controller.d.ts.map +1 -0
  97. package/esm/src/jobs/controller.js +95 -0
  98. package/esm/src/jobs/direct.d.ts +36 -0
  99. package/esm/src/jobs/direct.d.ts.map +1 -0
  100. package/esm/src/jobs/direct.js +122 -0
  101. package/esm/src/jobs/events.d.ts +15 -0
  102. package/esm/src/jobs/events.d.ts.map +1 -0
  103. package/esm/src/jobs/events.js +30 -0
  104. package/esm/src/jobs/format.d.ts +16 -0
  105. package/esm/src/jobs/format.d.ts.map +1 -0
  106. package/esm/src/jobs/format.js +183 -0
  107. package/esm/src/jobs/http.d.ts +22 -0
  108. package/esm/src/jobs/http.d.ts.map +1 -0
  109. package/esm/src/jobs/http.js +44 -0
  110. package/esm/src/jobs/log.d.ts +2 -0
  111. package/esm/src/jobs/log.d.ts.map +1 -0
  112. package/esm/src/jobs/log.js +10 -0
  113. package/esm/src/jobs/mod.d.ts +10 -0
  114. package/esm/src/jobs/mod.d.ts.map +1 -0
  115. package/esm/src/jobs/mod.js +9 -0
  116. package/esm/src/jobs/run.d.ts +20 -0
  117. package/esm/src/jobs/run.d.ts.map +1 -0
  118. package/esm/src/jobs/run.js +57 -0
  119. package/esm/src/jobs/types.d.ts +31 -0
  120. package/esm/src/jobs/types.d.ts.map +1 -0
  121. package/esm/src/jobs/types.js +1 -0
  122. package/esm/src/mui/apiKeys.d.ts +65 -0
  123. package/esm/src/mui/apiKeys.d.ts.map +1 -0
  124. package/esm/src/mui/apiKeys.js +301 -0
  125. package/esm/src/mui/apiKeysView.d.ts +48 -0
  126. package/esm/src/mui/apiKeysView.d.ts.map +1 -0
  127. package/esm/src/mui/apiKeysView.js +34 -0
  128. package/esm/src/mui/confirm.d.ts +12 -0
  129. package/esm/src/mui/confirm.d.ts.map +1 -0
  130. package/esm/src/mui/confirm.js +78 -0
  131. package/esm/src/mui/mod.d.ts +4 -0
  132. package/esm/src/mui/mod.d.ts.map +1 -0
  133. package/esm/src/mui/mod.js +2 -0
  134. package/esm/src/next/apiKeys/mod.d.ts +64 -0
  135. package/esm/src/next/apiKeys/mod.d.ts.map +1 -0
  136. package/esm/src/next/apiKeys/mod.js +217 -0
  137. package/esm/src/next/auth/config.d.ts +34 -0
  138. package/esm/src/next/auth/config.d.ts.map +1 -0
  139. package/esm/src/next/auth/config.js +103 -0
  140. package/esm/src/next/auth/mod.d.ts +3 -0
  141. package/esm/src/next/auth/mod.d.ts.map +1 -0
  142. package/esm/src/next/auth/mod.js +2 -0
  143. package/esm/src/next/auth/server.d.ts +28 -0
  144. package/esm/src/next/auth/server.d.ts.map +1 -0
  145. package/esm/src/next/auth/server.js +24 -0
  146. package/esm/src/next/files/mod.d.ts +3 -0
  147. package/esm/src/next/files/mod.d.ts.map +1 -0
  148. package/esm/src/next/files/mod.js +2 -0
  149. package/esm/src/next/files/route.d.ts +99 -0
  150. package/esm/src/next/files/route.d.ts.map +1 -0
  151. package/esm/src/next/files/route.js +349 -0
  152. package/esm/src/next/jobs/list.d.ts +25 -0
  153. package/esm/src/next/jobs/list.d.ts.map +1 -0
  154. package/esm/src/next/jobs/list.js +39 -0
  155. package/esm/src/next/jobs/mod.d.ts +6 -0
  156. package/esm/src/next/jobs/mod.d.ts.map +1 -0
  157. package/esm/src/next/jobs/mod.js +5 -0
  158. package/esm/src/next/jobs/paths.d.ts +14 -0
  159. package/esm/src/next/jobs/paths.d.ts.map +1 -0
  160. package/esm/src/next/jobs/paths.js +40 -0
  161. package/esm/src/next/jobs/route.d.ts +48 -0
  162. package/esm/src/next/jobs/route.d.ts.map +1 -0
  163. package/esm/src/next/jobs/route.js +101 -0
  164. package/esm/src/next/jobs/run.d.ts +51 -0
  165. package/esm/src/next/jobs/run.d.ts.map +1 -0
  166. package/esm/src/next/jobs/run.js +563 -0
  167. package/esm/src/next/jobs/stream.d.ts +3 -0
  168. package/esm/src/next/jobs/stream.d.ts.map +1 -0
  169. package/esm/src/next/jobs/stream.js +25 -0
  170. package/esm/src/next/pwa/mod.d.ts +104 -0
  171. package/esm/src/next/pwa/mod.d.ts.map +1 -0
  172. package/esm/src/next/pwa/mod.js +169 -0
  173. package/esm/src/next/pwa/worker.d.ts +27 -0
  174. package/esm/src/next/pwa/worker.d.ts.map +1 -0
  175. package/esm/src/next/pwa/worker.js +27 -0
  176. package/package.json +293 -0
  177. package/script/_dnt.polyfills.d.ts +149 -0
  178. package/script/_dnt.polyfills.d.ts.map +1 -0
  179. package/script/_dnt.polyfills.js +166 -0
  180. package/script/_dnt.shims.d.ts +2 -0
  181. package/script/_dnt.shims.d.ts.map +1 -0
  182. package/script/_dnt.shims.js +60 -0
  183. package/script/bin/loom.d.ts +2 -0
  184. package/script/bin/loom.d.ts.map +1 -0
  185. package/script/bin/loom.js +17 -0
  186. package/script/mod.d.ts +9 -0
  187. package/script/mod.d.ts.map +1 -0
  188. package/script/mod.js +24 -0
  189. package/script/package.json +3 -0
  190. package/script/src/apiKeys/authorize.d.ts +4 -0
  191. package/script/src/apiKeys/authorize.d.ts.map +1 -0
  192. package/script/src/apiKeys/authorize.js +187 -0
  193. package/script/src/apiKeys/country.d.ts +3 -0
  194. package/script/src/apiKeys/country.d.ts.map +1 -0
  195. package/script/src/apiKeys/country.js +10 -0
  196. package/script/src/apiKeys/credentials.d.ts +4 -0
  197. package/script/src/apiKeys/credentials.d.ts.map +1 -0
  198. package/script/src/apiKeys/credentials.js +58 -0
  199. package/script/src/apiKeys/fingerprint.d.ts +3 -0
  200. package/script/src/apiKeys/fingerprint.d.ts.map +1 -0
  201. package/script/src/apiKeys/fingerprint.js +8 -0
  202. package/script/src/apiKeys/mod.d.ts +9 -0
  203. package/script/src/apiKeys/mod.d.ts.map +1 -0
  204. package/script/src/apiKeys/mod.js +24 -0
  205. package/script/src/apiKeys/policy.d.ts +59 -0
  206. package/script/src/apiKeys/policy.d.ts.map +1 -0
  207. package/script/src/apiKeys/policy.js +92 -0
  208. package/script/src/apiKeys/retention.d.ts +55 -0
  209. package/script/src/apiKeys/retention.d.ts.map +1 -0
  210. package/script/src/apiKeys/retention.js +70 -0
  211. package/script/src/apiKeys/types.d.ts +175 -0
  212. package/script/src/apiKeys/types.d.ts.map +1 -0
  213. package/script/src/apiKeys/types.js +2 -0
  214. package/script/src/cli/externalSkills.d.ts +39 -0
  215. package/script/src/cli/externalSkills.d.ts.map +1 -0
  216. package/script/src/cli/externalSkills.js +181 -0
  217. package/script/src/cli/mod.d.ts +337 -0
  218. package/script/src/cli/mod.d.ts.map +1 -0
  219. package/script/src/cli/mod.js +9337 -0
  220. package/script/src/cli/projectSkills.d.ts +102 -0
  221. package/script/src/cli/projectSkills.d.ts.map +1 -0
  222. package/script/src/cli/projectSkills.js +606 -0
  223. package/script/src/files/client.d.ts +29 -0
  224. package/script/src/files/client.d.ts.map +1 -0
  225. package/script/src/files/client.js +45 -0
  226. package/script/src/files/errors.d.ts +37 -0
  227. package/script/src/files/errors.d.ts.map +1 -0
  228. package/script/src/files/errors.js +76 -0
  229. package/script/src/files/hash.d.ts +15 -0
  230. package/script/src/files/hash.d.ts.map +1 -0
  231. package/script/src/files/hash.js +89 -0
  232. package/script/src/files/memory.d.ts +29 -0
  233. package/script/src/files/memory.d.ts.map +1 -0
  234. package/script/src/files/memory.js +113 -0
  235. package/script/src/files/metadata.d.ts +10 -0
  236. package/script/src/files/metadata.d.ts.map +1 -0
  237. package/script/src/files/metadata.js +189 -0
  238. package/script/src/files/mod.d.ts +10 -0
  239. package/script/src/files/mod.d.ts.map +1 -0
  240. package/script/src/files/mod.js +25 -0
  241. package/script/src/files/s3.d.ts +29 -0
  242. package/script/src/files/s3.d.ts.map +1 -0
  243. package/script/src/files/s3.js +110 -0
  244. package/script/src/files/service.d.ts +27 -0
  245. package/script/src/files/service.d.ts.map +1 -0
  246. package/script/src/files/service.js +139 -0
  247. package/script/src/files/types.d.ts +134 -0
  248. package/script/src/files/types.d.ts.map +1 -0
  249. package/script/src/files/types.js +2 -0
  250. package/script/src/jobs/catalog.d.ts +32 -0
  251. package/script/src/jobs/catalog.d.ts.map +1 -0
  252. package/script/src/jobs/catalog.js +223 -0
  253. package/script/src/jobs/controller.d.ts +28 -0
  254. package/script/src/jobs/controller.d.ts.map +1 -0
  255. package/script/src/jobs/controller.js +100 -0
  256. package/script/src/jobs/direct.d.ts +36 -0
  257. package/script/src/jobs/direct.d.ts.map +1 -0
  258. package/script/src/jobs/direct.js +128 -0
  259. package/script/src/jobs/events.d.ts +15 -0
  260. package/script/src/jobs/events.d.ts.map +1 -0
  261. package/script/src/jobs/events.js +37 -0
  262. package/script/src/jobs/format.d.ts +16 -0
  263. package/script/src/jobs/format.d.ts.map +1 -0
  264. package/script/src/jobs/format.js +193 -0
  265. package/script/src/jobs/http.d.ts +22 -0
  266. package/script/src/jobs/http.d.ts.map +1 -0
  267. package/script/src/jobs/http.js +50 -0
  268. package/script/src/jobs/log.d.ts +2 -0
  269. package/script/src/jobs/log.d.ts.map +1 -0
  270. package/script/src/jobs/log.js +13 -0
  271. package/script/src/jobs/mod.d.ts +10 -0
  272. package/script/src/jobs/mod.d.ts.map +1 -0
  273. package/script/src/jobs/mod.js +25 -0
  274. package/script/src/jobs/run.d.ts +20 -0
  275. package/script/src/jobs/run.d.ts.map +1 -0
  276. package/script/src/jobs/run.js +61 -0
  277. package/script/src/jobs/types.d.ts +31 -0
  278. package/script/src/jobs/types.d.ts.map +1 -0
  279. package/script/src/jobs/types.js +2 -0
  280. package/script/src/mui/apiKeys.d.ts +65 -0
  281. package/script/src/mui/apiKeys.d.ts.map +1 -0
  282. package/script/src/mui/apiKeys.js +327 -0
  283. package/script/src/mui/apiKeysView.d.ts +48 -0
  284. package/script/src/mui/apiKeysView.d.ts.map +1 -0
  285. package/script/src/mui/apiKeysView.js +40 -0
  286. package/script/src/mui/confirm.d.ts +12 -0
  287. package/script/src/mui/confirm.d.ts.map +1 -0
  288. package/script/src/mui/confirm.js +85 -0
  289. package/script/src/mui/mod.d.ts +4 -0
  290. package/script/src/mui/mod.d.ts.map +1 -0
  291. package/script/src/mui/mod.js +19 -0
  292. package/script/src/next/apiKeys/mod.d.ts +64 -0
  293. package/script/src/next/apiKeys/mod.d.ts.map +1 -0
  294. package/script/src/next/apiKeys/mod.js +224 -0
  295. package/script/src/next/auth/config.d.ts +34 -0
  296. package/script/src/next/auth/config.d.ts.map +1 -0
  297. package/script/src/next/auth/config.js +142 -0
  298. package/script/src/next/auth/mod.d.ts +3 -0
  299. package/script/src/next/auth/mod.d.ts.map +1 -0
  300. package/script/src/next/auth/mod.js +18 -0
  301. package/script/src/next/auth/server.d.ts +28 -0
  302. package/script/src/next/auth/server.d.ts.map +1 -0
  303. package/script/src/next/auth/server.js +27 -0
  304. package/script/src/next/files/mod.d.ts +3 -0
  305. package/script/src/next/files/mod.d.ts.map +1 -0
  306. package/script/src/next/files/mod.js +18 -0
  307. package/script/src/next/files/route.d.ts +99 -0
  308. package/script/src/next/files/route.d.ts.map +1 -0
  309. package/script/src/next/files/route.js +353 -0
  310. package/script/src/next/jobs/list.d.ts +25 -0
  311. package/script/src/next/jobs/list.d.ts.map +1 -0
  312. package/script/src/next/jobs/list.js +48 -0
  313. package/script/src/next/jobs/mod.d.ts +6 -0
  314. package/script/src/next/jobs/mod.d.ts.map +1 -0
  315. package/script/src/next/jobs/mod.js +21 -0
  316. package/script/src/next/jobs/paths.d.ts +14 -0
  317. package/script/src/next/jobs/paths.d.ts.map +1 -0
  318. package/script/src/next/jobs/paths.js +47 -0
  319. package/script/src/next/jobs/route.d.ts +48 -0
  320. package/script/src/next/jobs/route.d.ts.map +1 -0
  321. package/script/src/next/jobs/route.js +105 -0
  322. package/script/src/next/jobs/run.d.ts +51 -0
  323. package/script/src/next/jobs/run.d.ts.map +1 -0
  324. package/script/src/next/jobs/run.js +570 -0
  325. package/script/src/next/jobs/stream.d.ts +3 -0
  326. package/script/src/next/jobs/stream.d.ts.map +1 -0
  327. package/script/src/next/jobs/stream.js +28 -0
  328. package/script/src/next/pwa/mod.d.ts +104 -0
  329. package/script/src/next/pwa/mod.d.ts.map +1 -0
  330. package/script/src/next/pwa/mod.js +192 -0
  331. package/script/src/next/pwa/worker.d.ts +27 -0
  332. package/script/src/next/pwa/worker.d.ts.map +1 -0
  333. package/script/src/next/pwa/worker.js +33 -0
  334. package/skills/loom/SKILL.md +200 -0
  335. package/skills/loom-api-keys/SKILL.md +123 -0
  336. package/skills/loom-auth/SKILL.md +70 -0
  337. package/skills/loom-db/SKILL.md +94 -0
  338. package/skills/loom-db/references/db-stack.md +39 -0
  339. package/skills/loom-files/SKILL.md +97 -0
  340. package/skills/loom-jobs/SKILL.md +148 -0
  341. package/skills/upgrade-deps/SKILL.md +165 -0
  342. package/skills/upgrade-deps/agents/openai.yaml +4 -0
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
+ * but instead of using npm to install additional dependencies,
4
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
+ *
6
+ * Note that this code might be imported multiple times
7
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
+ * or Node.js might dynamically clear the cache and then force a require).
9
+ * Therefore, it's important to avoid redundant writes to global objects.
10
+ * Additionally, consider that commonjs is used alongside esm,
11
+ * so the two ponyfill functions are stored independently in two separate global objects.
12
+ */
13
+ //@ts-ignore
14
+ import { createRequire } from "node:module";
15
+ //@ts-ignore
16
+ import { fileURLToPath, pathToFileURL } from "node:url";
17
+ //@ts-ignore
18
+ import { dirname } from "node:path";
19
+ const defineGlobalPonyfill = (symbolFor, fn) => {
20
+ if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
21
+ Object.defineProperty(globalThis, Symbol.for(symbolFor), {
22
+ configurable: true,
23
+ get() {
24
+ return fn;
25
+ },
26
+ });
27
+ }
28
+ };
29
+ export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
30
+ (() => {
31
+ const moduleImportMetaWM = new WeakMap();
32
+ return (require, module) => {
33
+ let importMetaCache = moduleImportMetaWM.get(module);
34
+ if (importMetaCache == null) {
35
+ const importMeta = Object.assign(Object.create(null), {
36
+ url: pathToFileURL(module.filename).href,
37
+ main: require.main == module,
38
+ resolve: (specifier, parentURL = importMeta.url) => {
39
+ return pathToFileURL((importMeta.url === parentURL
40
+ ? require
41
+ : createRequire(parentURL))
42
+ .resolve(specifier)).href;
43
+ },
44
+ filename: module.filename,
45
+ dirname: module.path,
46
+ });
47
+ moduleImportMetaWM.set(module, importMeta);
48
+ importMetaCache = importMeta;
49
+ }
50
+ return importMetaCache;
51
+ };
52
+ })());
53
+ defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
54
+ export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
55
+ ((importMeta) => {
56
+ const resolveFunStr = String(importMeta.resolve);
57
+ const shimWs = new WeakSet();
58
+ //@ts-ignore
59
+ const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
60
+ .replace(/\/{3,}/, "///");
61
+ const commonShim = (importMeta) => {
62
+ if (typeof importMeta.main !== "boolean") {
63
+ importMeta.main = importMeta.url === mainUrl;
64
+ }
65
+ if (typeof importMeta.filename !== "string") {
66
+ importMeta.filename = fileURLToPath(importMeta.url);
67
+ importMeta.dirname = dirname(importMeta.filename);
68
+ }
69
+ };
70
+ if (
71
+ // v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
72
+ resolveFunStr === "undefined" ||
73
+ // v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
74
+ resolveFunStr.startsWith("async")
75
+ // enable by --experimental-import-meta-resolve flag
76
+ ) {
77
+ import_meta_ponyfill_esmodule = (importMeta) => {
78
+ if (!shimWs.has(importMeta)) {
79
+ shimWs.add(importMeta);
80
+ const importMetaUrlRequire = {
81
+ url: importMeta.url,
82
+ require: createRequire(importMeta.url),
83
+ };
84
+ importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
85
+ return pathToFileURL((importMetaUrlRequire.url === parentURL
86
+ ? importMetaUrlRequire.require
87
+ : createRequire(parentURL)).resolve(specifier)).href;
88
+ };
89
+ commonShim(importMeta);
90
+ }
91
+ return importMeta;
92
+ };
93
+ }
94
+ else {
95
+ /// native support
96
+ import_meta_ponyfill_esmodule = (importMeta) => {
97
+ if (!shimWs.has(importMeta)) {
98
+ shimWs.add(importMeta);
99
+ commonShim(importMeta);
100
+ }
101
+ return importMeta;
102
+ };
103
+ }
104
+ return import_meta_ponyfill_esmodule(importMeta);
105
+ }));
106
+ defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
107
+ export let import_meta_ponyfill = ((...args) => {
108
+ const _MODULE = (() => {
109
+ if (typeof require === "function" && typeof module === "object") {
110
+ return "commonjs";
111
+ }
112
+ else {
113
+ // eval("typeof import.meta");
114
+ return "esmodule";
115
+ }
116
+ })();
117
+ if (_MODULE === "commonjs") {
118
+ //@ts-ignore
119
+ import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
120
+ }
121
+ else {
122
+ //@ts-ignore
123
+ import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
124
+ }
125
+ //@ts-ignore
126
+ return import_meta_ponyfill(...args);
127
+ });
128
+ function findLastIndex(self, callbackfn, that) {
129
+ const boundFunc = that === undefined ? callbackfn : callbackfn.bind(that);
130
+ let index = self.length - 1;
131
+ while (index >= 0) {
132
+ const result = boundFunc(self[index], index, self);
133
+ if (result) {
134
+ return index;
135
+ }
136
+ index--;
137
+ }
138
+ return -1;
139
+ }
140
+ function findLast(self, callbackfn, that) {
141
+ const index = self.findLastIndex(callbackfn, that);
142
+ return index === -1 ? undefined : self[index];
143
+ }
144
+ if (!Array.prototype.findLastIndex) {
145
+ Array.prototype.findLastIndex = function (callbackfn, that) {
146
+ return findLastIndex(this, callbackfn, that);
147
+ };
148
+ }
149
+ if (!Array.prototype.findLast) {
150
+ Array.prototype.findLast = function (callbackfn, that) {
151
+ return findLast(this, callbackfn, that);
152
+ };
153
+ }
154
+ if (!Uint8Array.prototype.findLastIndex) {
155
+ Uint8Array.prototype.findLastIndex = function (callbackfn, that) {
156
+ return findLastIndex(this, callbackfn, that);
157
+ };
158
+ }
159
+ if (!Uint8Array.prototype.findLast) {
160
+ Uint8Array.prototype.findLast = function (callbackfn, that) {
161
+ return findLast(this, callbackfn, that);
162
+ };
163
+ }
@@ -0,0 +1,2 @@
1
+ export declare const dntGlobalThis: Omit<typeof globalThis, never>;
2
+ //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
@@ -0,0 +1,57 @@
1
+ const dntGlobals = {};
2
+ export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
3
+ function createMergeProxy(baseObj, extObj) {
4
+ return new Proxy(baseObj, {
5
+ get(_target, prop, _receiver) {
6
+ if (prop in extObj) {
7
+ return extObj[prop];
8
+ }
9
+ else {
10
+ return baseObj[prop];
11
+ }
12
+ },
13
+ set(_target, prop, value) {
14
+ if (prop in extObj) {
15
+ delete extObj[prop];
16
+ }
17
+ baseObj[prop] = value;
18
+ return true;
19
+ },
20
+ deleteProperty(_target, prop) {
21
+ let success = false;
22
+ if (prop in extObj) {
23
+ delete extObj[prop];
24
+ success = true;
25
+ }
26
+ if (prop in baseObj) {
27
+ delete baseObj[prop];
28
+ success = true;
29
+ }
30
+ return success;
31
+ },
32
+ ownKeys(_target) {
33
+ const baseKeys = Reflect.ownKeys(baseObj);
34
+ const extKeys = Reflect.ownKeys(extObj);
35
+ const extKeysSet = new Set(extKeys);
36
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
37
+ },
38
+ defineProperty(_target, prop, desc) {
39
+ if (prop in extObj) {
40
+ delete extObj[prop];
41
+ }
42
+ Reflect.defineProperty(baseObj, prop, desc);
43
+ return true;
44
+ },
45
+ getOwnPropertyDescriptor(_target, prop) {
46
+ if (prop in extObj) {
47
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
48
+ }
49
+ else {
50
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
51
+ }
52
+ },
53
+ has(_target, prop) {
54
+ return prop in extObj || prop in baseObj;
55
+ },
56
+ });
57
+ }
@@ -0,0 +1,2 @@
1
+ import "../_dnt.polyfills.js";
2
+ //# sourceMappingURL=loom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loom.d.ts","sourceRoot":"","sources":["../../src/bin/loom.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import "../_dnt.polyfills.js";
2
+ import process from "node:process";
3
+ import { runCli } from "../src/cli/mod.js";
4
+ runCli(process.argv.slice(2))
5
+ .then((code) => {
6
+ process.exitCode = code;
7
+ })
8
+ .catch((error) => {
9
+ console.error(error);
10
+ process.exitCode = 1;
11
+ });
package/esm/mod.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import "./_dnt.polyfills.js";
2
+ export * from "./src/apiKeys/mod.js";
3
+ export * from "./src/files/mod.js";
4
+ export * from "./src/jobs/mod.js";
5
+ export * from "./src/next/auth/mod.js";
6
+ export * from "./src/next/apiKeys/mod.js";
7
+ export * from "./src/next/files/mod.js";
8
+ export * from "./src/next/jobs/mod.js";
9
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC"}
package/esm/mod.js ADDED
@@ -0,0 +1,8 @@
1
+ import "./_dnt.polyfills.js";
2
+ export * from "./src/apiKeys/mod.js";
3
+ export * from "./src/files/mod.js";
4
+ export * from "./src/jobs/mod.js";
5
+ export * from "./src/next/auth/mod.js";
6
+ export * from "./src/next/apiKeys/mod.js";
7
+ export * from "./src/next/files/mod.js";
8
+ export * from "./src/next/jobs/mod.js";
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,4 @@
1
+ import type { ApiKeyAuthorizationResult, AuthorizeApiKeyOptions } from "./types.js";
2
+ /** Authorizes one credential and durably records access before it is granted. */
3
+ export declare function authorizeApiKey(options: AuthorizeApiKeyOptions): Promise<ApiKeyAuthorizationResult>;
4
+ //# sourceMappingURL=authorize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/authorize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,yBAAyB,EAGzB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AA2DpB,iFAAiF;AACjF,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,yBAAyB,CAAC,CAgJpC"}
@@ -0,0 +1,184 @@
1
+ import { extractApiKeyCredential } from "./credentials.js";
2
+ import { normalizeApiKeyCountryCode } from "./country.js";
3
+ import { fingerprintApiKeyCredential } from "./fingerprint.js";
4
+ function statusForExtraction(kind) {
5
+ return kind === "missing" ? 401 : 400;
6
+ }
7
+ function codeForExtraction(kind) {
8
+ if (kind === "ambiguous")
9
+ return "ambiguous_credentials";
10
+ if (kind === "malformed")
11
+ return "credential_malformed";
12
+ return "credential_missing";
13
+ }
14
+ function baseAuditEvent(options) {
15
+ const descriptor = options.descriptor;
16
+ return {
17
+ actionName: descriptor.actionName,
18
+ countryCode: normalizeApiKeyCountryCode(options.request?.countryCode),
19
+ functionName: descriptor.functionName,
20
+ ipAddress: options.request?.ipAddress,
21
+ metadata: descriptor.metadata,
22
+ method: options.request?.method,
23
+ operation: descriptor.operation,
24
+ pageName: descriptor.pageName,
25
+ requestId: options.request?.requestId,
26
+ routeTemplate: options.request?.routeTemplate,
27
+ scopeAction: descriptor.permission.action,
28
+ scopeResource: descriptor.permission.resource,
29
+ userAgent: options.request?.userAgent,
30
+ };
31
+ }
32
+ async function recordDenied(options, event) {
33
+ try {
34
+ return await options.audit.append(event);
35
+ }
36
+ catch {
37
+ // A persistence outage cannot make an already-denied request less denied.
38
+ return undefined;
39
+ }
40
+ }
41
+ function principalAuditFields(principal) {
42
+ return {
43
+ keyId: principal.keyId,
44
+ keyNameSnapshot: principal.keyName,
45
+ keyStartSnapshot: principal.keyStart,
46
+ ownerId: principal.ownerId,
47
+ };
48
+ }
49
+ /** Authorizes one credential and durably records access before it is granted. */
50
+ export async function authorizeApiKey(options) {
51
+ const extracted = extractApiKeyCredential(options.source, options.credentialOptions);
52
+ const auditBase = baseAuditEvent(options);
53
+ if (extracted.kind !== "present") {
54
+ const code = codeForExtraction(extracted.kind);
55
+ const status = statusForExtraction(extracted.kind);
56
+ const recorded = await recordDenied(options, {
57
+ ...auditBase,
58
+ authorizationOutcome: "denied",
59
+ eventType: "authorization",
60
+ httpStatus: status,
61
+ reasonCode: code,
62
+ transport: extracted.kind === "missing"
63
+ ? undefined
64
+ : extracted.kind === "ambiguous"
65
+ ? undefined
66
+ : extracted.transport,
67
+ });
68
+ return {
69
+ authorizationEventId: recorded?.id,
70
+ code,
71
+ ok: false,
72
+ status,
73
+ };
74
+ }
75
+ const credentialFingerprint = await fingerprintApiKeyCredential(extracted.credential);
76
+ let verification;
77
+ try {
78
+ verification = await options.verifier.verify({
79
+ credential: extracted.credential,
80
+ permission: options.descriptor.permission,
81
+ });
82
+ }
83
+ catch {
84
+ const recorded = await recordDenied(options, {
85
+ ...auditBase,
86
+ authorizationOutcome: "error",
87
+ credentialFingerprint,
88
+ eventType: "authorization",
89
+ httpStatus: 500,
90
+ reasonCode: "verification_error",
91
+ transport: extracted.transport,
92
+ });
93
+ return {
94
+ authorizationEventId: recorded?.id,
95
+ code: "verification_error",
96
+ ok: false,
97
+ status: 500,
98
+ };
99
+ }
100
+ if (!verification.ok) {
101
+ const status = verification.status ??
102
+ (verification.code === "rate_limited"
103
+ ? 429
104
+ : verification.code === "insufficient_permission"
105
+ ? 403
106
+ : 401);
107
+ const recorded = await recordDenied(options, {
108
+ ...auditBase,
109
+ authorizationOutcome: "denied",
110
+ credentialFingerprint,
111
+ eventType: "authorization",
112
+ httpStatus: status,
113
+ reasonCode: verification.code,
114
+ transport: extracted.transport,
115
+ });
116
+ return {
117
+ authorizationEventId: recorded?.id,
118
+ code: verification.code,
119
+ ok: false,
120
+ status,
121
+ };
122
+ }
123
+ let policy;
124
+ try {
125
+ policy = await options.policy.authorize(verification.principal, options.descriptor);
126
+ }
127
+ catch {
128
+ const recorded = await recordDenied(options, {
129
+ ...auditBase,
130
+ ...principalAuditFields(verification.principal),
131
+ authorizationOutcome: "error",
132
+ credentialFingerprint,
133
+ eventType: "authorization",
134
+ httpStatus: 500,
135
+ reasonCode: "policy_error",
136
+ transport: extracted.transport,
137
+ });
138
+ return {
139
+ authorizationEventId: recorded?.id,
140
+ code: "policy_error",
141
+ ok: false,
142
+ status: 500,
143
+ };
144
+ }
145
+ if (!policy.ok) {
146
+ const recorded = await recordDenied(options, {
147
+ ...auditBase,
148
+ ...principalAuditFields(verification.principal),
149
+ authorizationOutcome: "denied",
150
+ credentialFingerprint,
151
+ eventType: "authorization",
152
+ httpStatus: policy.status ?? 403,
153
+ reasonCode: policy.code ?? "forbidden",
154
+ transport: extracted.transport,
155
+ });
156
+ return {
157
+ authorizationEventId: recorded?.id,
158
+ code: policy.code ?? "forbidden",
159
+ ok: false,
160
+ status: policy.status ?? 403,
161
+ };
162
+ }
163
+ try {
164
+ const recorded = await options.audit.append({
165
+ ...auditBase,
166
+ ...principalAuditFields(verification.principal),
167
+ authorizationOutcome: "allowed",
168
+ credentialFingerprint,
169
+ eventType: "authorization",
170
+ httpStatus: 200,
171
+ transport: extracted.transport,
172
+ });
173
+ return {
174
+ authorizationEventId: recorded.id,
175
+ credentialFingerprint,
176
+ ok: true,
177
+ principal: verification.principal,
178
+ transport: extracted.transport,
179
+ };
180
+ }
181
+ catch {
182
+ return { code: "audit_unavailable", ok: false, status: 503 };
183
+ }
184
+ }
@@ -0,0 +1,3 @@
1
+ /** Normalizes a two-letter ISO country-code candidate for audit storage. */
2
+ export declare function normalizeApiKeyCountryCode(value?: string | null): string | undefined;
3
+ //# sourceMappingURL=country.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/country.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wBAAgB,0BAA0B,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,sBAK/D"}
@@ -0,0 +1,7 @@
1
+ /** Normalizes a two-letter ISO country-code candidate for audit storage. */
2
+ export function normalizeApiKeyCountryCode(value) {
3
+ const countryCode = value?.trim().toUpperCase();
4
+ return countryCode && /^[A-Z]{2}$/.test(countryCode)
5
+ ? countryCode
6
+ : undefined;
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { ApiKeyCredentialExtractionResult, ApiKeyCredentialOptions, ApiKeyCredentialSource } from "./types.js";
2
+ /** Extracts exactly one API-key credential without selecting a precedence. */
3
+ export declare function extractApiKeyCredential(source: ApiKeyCredentialSource, options?: ApiKeyCredentialOptions): ApiKeyCredentialExtractionResult;
4
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,uBAAuB,EACvB,sBAAsB,EAEvB,MAAM,YAAY,CAAC;AAgCpB,8EAA8E;AAC9E,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,sBAAsB,EAC9B,OAAO,GAAE,uBAA4B,GACpC,gCAAgC,CAwClC"}
@@ -0,0 +1,55 @@
1
+ const DEFAULT_QUERY_NAME = "apiKey";
2
+ const DEFAULT_X_API_KEY_HEADER = "x-api-key";
3
+ function bearerCandidate(headers) {
4
+ const value = headers.get("authorization");
5
+ if (value === null)
6
+ return null;
7
+ const match = /^Bearer ([^\s]+)$/.exec(value);
8
+ return match
9
+ ? { credential: match[1], transport: "authorization-bearer" }
10
+ : { malformed: true, transport: "authorization-bearer" };
11
+ }
12
+ function valueCandidate(value, transport) {
13
+ if (value === null)
14
+ return null;
15
+ if (value.trim() === "" || value !== value.trim()) {
16
+ return { malformed: true, transport };
17
+ }
18
+ return { credential: value, transport };
19
+ }
20
+ /** Extracts exactly one API-key credential without selecting a precedence. */
21
+ export function extractApiKeyCredential(source, options = {}) {
22
+ const candidates = [];
23
+ if (options.allowAuthorizationBearer !== false) {
24
+ const candidate = bearerCandidate(source.headers);
25
+ if (candidate)
26
+ candidates.push(candidate);
27
+ }
28
+ if (options.allowXApiKey !== false) {
29
+ const candidate = valueCandidate(source.headers.get(options.xApiKeyHeaderName ?? DEFAULT_X_API_KEY_HEADER), "x-api-key");
30
+ if (candidate)
31
+ candidates.push(candidate);
32
+ }
33
+ if (options.allowQuery === true) {
34
+ const candidate = valueCandidate(source.searchParams?.get(options.queryName ?? DEFAULT_QUERY_NAME) ?? null, "query");
35
+ if (candidate)
36
+ candidates.push(candidate);
37
+ }
38
+ if (candidates.length === 0)
39
+ return { kind: "missing" };
40
+ if (candidates.length > 1) {
41
+ return {
42
+ kind: "ambiguous",
43
+ transports: candidates.map((candidate) => candidate.transport),
44
+ };
45
+ }
46
+ const candidate = candidates[0];
47
+ if (candidate.malformed || candidate.credential === undefined) {
48
+ return { kind: "malformed", transport: candidate.transport };
49
+ }
50
+ return {
51
+ credential: candidate.credential,
52
+ kind: "present",
53
+ transport: candidate.transport,
54
+ };
55
+ }
@@ -0,0 +1,3 @@
1
+ /** Produces a lowercase SHA-256 fingerprint without retaining the credential. */
2
+ export declare function fingerprintApiKeyCredential(credential: string): Promise<string>;
3
+ //# sourceMappingURL=fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/fingerprint.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,wBAAsB,2BAA2B,CAAC,UAAU,EAAE,MAAM,mBASnE"}
@@ -0,0 +1,5 @@
1
+ /** Produces a lowercase SHA-256 fingerprint without retaining the credential. */
2
+ export async function fingerprintApiKeyCredential(credential) {
3
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(credential));
4
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
5
+ }
@@ -0,0 +1,9 @@
1
+ import "../../_dnt.polyfills.js";
2
+ export * from "./authorize.js";
3
+ export * from "./country.js";
4
+ export * from "./credentials.js";
5
+ export * from "./fingerprint.js";
6
+ export * from "./policy.js";
7
+ export * from "./retention.js";
8
+ export * from "./types.js";
9
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/mod.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ import "../../_dnt.polyfills.js";
2
+ export * from "./authorize.js";
3
+ export * from "./country.js";
4
+ export * from "./credentials.js";
5
+ export * from "./fingerprint.js";
6
+ export * from "./policy.js";
7
+ export * from "./retention.js";
8
+ export * from "./types.js";
@@ -0,0 +1,59 @@
1
+ import type { ApiKeyAuthorizationDescriptor, ApiKeyPermission, ApiKeyPolicy, ApiKeyPolicyResult, ApiKeyPrincipal } from "./types.js";
2
+ /** Minimum shape for one app-owned API-key scope definition. */
3
+ export interface ApiKeyScopeDefinition {
4
+ /** Native resource/action permission stored and verified by the auth provider. */
5
+ permission: ApiKeyPermission;
6
+ }
7
+ export type ApiKeyScopeDefinitions = Readonly<Record<string, ApiKeyScopeDefinition>>;
8
+ type ApiKeyScopeId<TDefinitions extends ApiKeyScopeDefinitions> = Extract<keyof TDefinitions, string>;
9
+ /** A scope definition projected into a list with its record key as `id`. */
10
+ export type ApiKeyScopeListItem<TDefinitions extends ApiKeyScopeDefinitions> = {
11
+ [TId in ApiKeyScopeId<TDefinitions>]: Readonly<{
12
+ id: TId;
13
+ } & TDefinitions[TId]>;
14
+ }[ApiKeyScopeId<TDefinitions>];
15
+ /** Typed projections derived from one app-owned scope definition record. */
16
+ export interface DefinedApiKeyScopes<TDefinitions extends ApiKeyScopeDefinitions> {
17
+ /** Original definitions indexed by stable app-owned scope ID. */
18
+ readonly byId: TDefinitions;
19
+ /** Stable scope IDs in definition order. */
20
+ readonly ids: readonly ApiKeyScopeId<TDefinitions>[];
21
+ /** Definitions in UI-friendly list form with an added `id`. */
22
+ readonly list: readonly ApiKeyScopeListItem<TDefinitions>[];
23
+ /** Native permissions indexed by stable app-owned scope ID. */
24
+ readonly permissions: {
25
+ readonly [TId in ApiKeyScopeId<TDefinitions>]: TDefinitions[TId]["permission"];
26
+ };
27
+ }
28
+ /** Context supplied to an app-owned dynamic policy rule. */
29
+ export interface ApiKeyPolicyRuleContext {
30
+ /** Protected operation and exact permission requested by the route. */
31
+ descriptor: ApiKeyAuthorizationDescriptor;
32
+ /** Explicit key principal returned by the consumer verifier. */
33
+ principal: ApiKeyPrincipal;
34
+ }
35
+ /** A static decision or fresh app-owned eligibility check for one scope. */
36
+ export type ApiKeyPolicyRule = "allow" | "deny" | ((context: ApiKeyPolicyRuleContext) => ApiKeyPolicyResult | Promise<ApiKeyPolicyResult>);
37
+ /** Exhaustive policy rules keyed by the registry's stable scope IDs. */
38
+ export type ApiKeyPolicyRules<TDefinitions extends ApiKeyScopeDefinitions> = {
39
+ readonly [TId in ApiKeyScopeId<TDefinitions>]: ApiKeyPolicyRule;
40
+ };
41
+ /**
42
+ * Defines one app's scopes and derives typed list and permission projections.
43
+ *
44
+ * Scope IDs and native resource/action pairs should remain stable after keys
45
+ * have been issued. Duplicate pairs are rejected because policy dispatch would
46
+ * otherwise be ambiguous.
47
+ */
48
+ export declare function defineApiKeyScopes<const TDefinitions extends ApiKeyScopeDefinitions>(definitions: TDefinitions): DefinedApiKeyScopes<TDefinitions>;
49
+ /**
50
+ * Creates an exact-match, default-deny policy from a typed scope registry.
51
+ *
52
+ * The verifier remains responsible for proving that the key owns the requested
53
+ * native permission. Dynamic rules are for fresh app-owned checks such as
54
+ * current role membership; thrown errors intentionally reach Loom's existing
55
+ * `policy_error` handling.
56
+ */
57
+ export declare function createApiKeyPolicy<const TDefinitions extends ApiKeyScopeDefinitions>(registry: DefinedApiKeyScopes<TDefinitions>, rules: ApiKeyPolicyRules<TDefinitions>): ApiKeyPolicy;
58
+ export {};
59
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CACtC,CAAC;AAEF,KAAK,aAAa,CAAC,YAAY,SAAS,sBAAsB,IAAI,OAAO,CACvE,MAAM,YAAY,EAClB,MAAM,CACP,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,CAC7B,YAAY,SAAS,sBAAsB,IACzC;KACD,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,QAAQ,CAC5C;QAAE,EAAE,EAAE,GAAG,CAAA;KAAE,GAAG,YAAY,CAAC,GAAG,CAAC,CAChC;CACF,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AAE/B,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB,CAClC,YAAY,SAAS,sBAAsB;IAE3C,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,GAAG,EAAE,SAAS,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;IACrD,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,SAAS,mBAAmB,CAAC,YAAY,CAAC,EAAE,CAAC;IAC5D,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE;QACpB,QAAQ,EAAE,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,GAC1C,YAAY,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC;KAClC,CAAC;CACH;AAED,4DAA4D;AAC5D,MAAM,WAAW,uBAAuB;IACtC,uEAAuE;IACvE,UAAU,EAAE,6BAA6B,CAAC;IAC1C,gEAAgE;IAChE,SAAS,EAAE,eAAe,CAAC;CAC5B;AAED,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,MAAM,GACN,CAAC,CACD,OAAO,EAAE,uBAAuB,KAC7B,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAEzD,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,CAC3B,YAAY,SAAS,sBAAsB,IACzC;IACF,QAAQ,EAAE,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,gBAAgB;CAChE,CAAC;AA+CF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,YAAY,SAAS,sBAAsB,EACjD,WAAW,EAAE,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAkB9D;AAsBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,YAAY,SAAS,sBAAsB,EAEjD,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAC3C,KAAK,EAAE,iBAAiB,CAAC,YAAY,CAAC,GACrC,YAAY,CAiBd"}