acrylblends 0.8.1 → 0.9.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 (235) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +83 -7
  3. package/dist/index.js.map +1 -1
  4. package/lib/audit-BXnYsLge.d.ts +58 -0
  5. package/lib/cell-ChU41DZD.d.ts +32 -0
  6. package/lib/client-modules-CLvWOjbd.js +267 -0
  7. package/lib/connection-ZLEso7XL.d.ts +25 -0
  8. package/lib/conninfo.d.ts +1 -23
  9. package/lib/cordis/db-sqlite.d.ts +56 -0
  10. package/lib/cordis/db-sqlite.js +58 -0
  11. package/lib/cordis/db.d.ts +8 -0
  12. package/lib/cordis/db.js +1 -0
  13. package/lib/cordis/door.d.ts +159 -0
  14. package/lib/cordis/door.js +757 -0
  15. package/lib/cordis/inspect.d.ts +77 -0
  16. package/lib/cordis/inspect.js +149 -0
  17. package/lib/cordis/kv-db.d.ts +16 -0
  18. package/lib/cordis/kv-db.js +18 -0
  19. package/lib/cordis/kv-json.d.ts +16 -0
  20. package/lib/cordis/kv-json.js +44 -0
  21. package/lib/cordis/kv.d.ts +8 -0
  22. package/lib/cordis/kv.js +1 -0
  23. package/lib/cordis/node-server.d.ts +45 -0
  24. package/lib/cordis/node-server.js +93 -0
  25. package/lib/cordis/router-http.d.ts +56 -0
  26. package/lib/cordis/router-http.js +117 -0
  27. package/lib/cordis/router.d.ts +8 -0
  28. package/lib/cordis/router.js +7 -0
  29. package/lib/cordis/state/react.d.ts +6 -0
  30. package/lib/cordis/state/react.js +11 -0
  31. package/lib/cordis/state.d.ts +33 -0
  32. package/lib/cordis/state.js +163 -0
  33. package/lib/core-CaY8XDZ6.js +19 -0
  34. package/lib/database-DBHdwefi.d.ts +44 -0
  35. package/lib/db/conformance.d.ts +11 -0
  36. package/lib/db/conformance.js +267 -0
  37. package/lib/db/sqlite.d.ts +1 -1
  38. package/lib/db/sqlite.js +1 -196
  39. package/lib/db.d.ts +2 -1
  40. package/lib/{src-0hI7M7cN.js → deprecated-BP4fPt38.js} +0 -17
  41. package/lib/door/host.d.ts +24 -0
  42. package/lib/door/host.js +2 -0
  43. package/lib/door/page.d.ts +105 -0
  44. package/lib/door/page.js +1030 -0
  45. package/lib/door/protocol.d.ts +2 -0
  46. package/lib/door/protocol.js +197 -0
  47. package/lib/error-t4N2js2I.d.ts +8 -0
  48. package/lib/etag-DaKMOjty.js +135 -0
  49. package/lib/etag.js +1 -134
  50. package/lib/helpers-CvTauQT5.js +5 -0
  51. package/lib/http-exception-kpGJkmpi.d.ts +57 -0
  52. package/lib/http-exception.d.ts +1 -56
  53. package/lib/{index-BLTYsyc1.d.ts → index-BnGgRKTv.d.ts} +3 -39
  54. package/lib/index-BqVQkTnu.d.ts +98 -0
  55. package/lib/index-Dmst2QCQ.d.ts +44 -0
  56. package/lib/index.d.ts +1 -1
  57. package/lib/index.js +2 -1
  58. package/lib/jwk-LkzeoaU8.js +117 -0
  59. package/lib/jwk.js +1 -116
  60. package/lib/jwt-CskdhEW9.js +115 -0
  61. package/lib/jwt.js +2 -114
  62. package/lib/kv/conformance.d.ts +13 -0
  63. package/lib/kv/conformance.js +301 -0
  64. package/lib/kv/db.d.ts +2 -2
  65. package/lib/kv/json.d.ts +1 -1
  66. package/lib/kv-9f-AlRKN.d.ts +39 -0
  67. package/lib/kv.d.ts +2 -1
  68. package/lib/language-D9a4zqvn.js +198 -0
  69. package/lib/language.js +1 -197
  70. package/lib/middleware-CPQ8himN.js +12 -0
  71. package/lib/node-server/serve-static.d.ts +0 -1
  72. package/lib/node-server/serve-static.js +1 -1
  73. package/lib/node-server.d.ts +1 -7
  74. package/lib/node-server.js +3 -1586
  75. package/lib/open-CMhnJODn.js +197 -0
  76. package/lib/protocol-BizVt4J6.d.ts +144 -0
  77. package/lib/request-id-CKVvHOO1.js +34 -0
  78. package/lib/request-id.js +1 -33
  79. package/lib/secure-headers-mP3j6Hm6.js +163 -0
  80. package/lib/secure-headers.js +1 -162
  81. package/lib/{serve-static-B849HlX2.js → serve-static-3uo_9rjF.js} +1 -4
  82. package/lib/server-DvgMGtzo.js +1323 -0
  83. package/lib/snapshot-text-D3NspDyT.js +338 -0
  84. package/lib/src-CwABFr6r.js +328 -0
  85. package/lib/timeout.d.ts +1 -1
  86. package/lib/timing-Cky7C1Jf.js +183 -0
  87. package/lib/timing.js +1 -182
  88. package/package.json +89 -1
  89. package/plugins/acryl-db/plugin.json +6 -1
  90. package/plugins/acryl-db-sqlite/plugin.json +4 -0
  91. package/plugins/acryl-db-sqlite/src/facade/node.ts +1 -1
  92. package/plugins/acryl-db-sqlite/src/index.ts +2 -2
  93. package/plugins/acryl-db-sqlite/src/open.ts +2 -2
  94. package/plugins/acryl-door/plugin.json +4 -1
  95. package/plugins/acryl-door/src/host/http.ts +2 -2
  96. package/plugins/acryl-door/src/host/mcp-routes.ts +1 -1
  97. package/plugins/acryl-door/src/host/operator-routes.ts +1 -1
  98. package/plugins/acryl-door/src/host/page-routes.ts +3 -3
  99. package/plugins/acryl-door/src/index.ts +2 -2
  100. package/plugins/acryl-inspect/plugin.json +4 -1
  101. package/plugins/acryl-inspect/src/service.ts +2 -2
  102. package/plugins/acryl-kv/plugin.json +6 -1
  103. package/plugins/acryl-kv-db/plugin.json +4 -0
  104. package/plugins/acryl-kv-db/src/index.ts +1 -1
  105. package/plugins/acryl-kv-db/src/open.ts +3 -3
  106. package/plugins/acryl-kv-json/plugin.json +4 -0
  107. package/plugins/acryl-kv-json/src/index.ts +1 -1
  108. package/plugins/acryl-kv-json/src/open.ts +2 -2
  109. package/plugins/acryl-node-server/plugin.json +5 -1
  110. package/plugins/acryl-node-server/src/adapter/conninfo.ts +1 -1
  111. package/plugins/acryl-node-server/src/adapter/early-hints.ts +1 -1
  112. package/plugins/acryl-node-server/src/adapter/serve-static.ts +2 -2
  113. package/plugins/acryl-node-server/src/adapter/websocket.ts +2 -2
  114. package/plugins/acryl-node-server/src/client-modules.ts +2 -2
  115. package/plugins/acryl-node-server/src/index.ts +1 -1
  116. package/plugins/acryl-router/plugin.json +11 -1
  117. package/plugins/acryl-router/src/connection.d.ts +25 -0
  118. package/plugins/acryl-router/src/core/app-base.d.ts +215 -0
  119. package/plugins/acryl-router/src/core/app.d.ts +19 -0
  120. package/plugins/acryl-router/src/core/client/client.d.ts +4 -0
  121. package/plugins/acryl-router/src/core/client/fetch-result-please.d.ts +35 -0
  122. package/plugins/acryl-router/src/core/client/index.d.ts +7 -0
  123. package/plugins/acryl-router/src/core/client/types.d.ts +229 -0
  124. package/plugins/acryl-router/src/core/client/utils.d.ts +18 -0
  125. package/plugins/acryl-router/src/core/compose.d.ts +14 -0
  126. package/plugins/acryl-router/src/core/context.d.ts +443 -0
  127. package/plugins/acryl-router/src/core/helper/accepts/accepts.d.ts +30 -0
  128. package/plugins/acryl-router/src/core/helper/accepts/index.d.ts +5 -0
  129. package/plugins/acryl-router/src/core/helper/conninfo/index.d.ts +5 -0
  130. package/plugins/acryl-router/src/core/helper/conninfo/types.d.ts +36 -0
  131. package/plugins/acryl-router/src/core/helper/cookie/index.d.ts +25 -0
  132. package/plugins/acryl-router/src/core/helper/css/common.d.ts +59 -0
  133. package/plugins/acryl-router/src/core/helper/css/index.d.ts +80 -0
  134. package/plugins/acryl-router/src/core/helper/dev/index.d.ts +20 -0
  135. package/plugins/acryl-router/src/core/helper/factory/index.d.ts +82 -0
  136. package/plugins/acryl-router/src/core/helper/html/index.d.ts +8 -0
  137. package/plugins/acryl-router/src/core/helper/proxy/index.d.ts +73 -0
  138. package/plugins/acryl-router/src/core/helper/route/index.d.ts +75 -0
  139. package/plugins/acryl-router/src/core/helper/ssg/index.d.ts +7 -0
  140. package/plugins/acryl-router/src/core/helper/ssg/middleware.d.ts +44 -0
  141. package/plugins/acryl-router/src/core/helper/ssg/plugins.d.ts +27 -0
  142. package/plugins/acryl-router/src/core/helper/ssg/ssg.d.ts +91 -0
  143. package/plugins/acryl-router/src/core/helper/ssg/utils.d.ts +16 -0
  144. package/plugins/acryl-router/src/core/helper/streaming/index.d.ts +8 -0
  145. package/plugins/acryl-router/src/core/helper/streaming/sse.d.ts +13 -0
  146. package/plugins/acryl-router/src/core/helper/streaming/stream.d.ts +3 -0
  147. package/plugins/acryl-router/src/core/helper/streaming/text.d.ts +3 -0
  148. package/plugins/acryl-router/src/core/helper/streaming/utils.d.ts +1 -0
  149. package/plugins/acryl-router/src/core/helper/testing/index.d.ts +13 -0
  150. package/plugins/acryl-router/src/core/helper/websocket/index.d.ts +70 -0
  151. package/plugins/acryl-router/src/core/http-exception.d.ts +58 -0
  152. package/plugins/acryl-router/src/core/index.d.ts +37 -0
  153. package/plugins/acryl-router/src/core/jsx/base.d.ts +61 -0
  154. package/plugins/acryl-router/src/core/jsx/children.d.ts +9 -0
  155. package/plugins/acryl-router/src/core/jsx/components.d.ts +15 -0
  156. package/plugins/acryl-router/src/core/jsx/constants.d.ts +6 -0
  157. package/plugins/acryl-router/src/core/jsx/context.d.ts +51 -0
  158. package/plugins/acryl-router/src/core/jsx/dom/components.d.ts +10 -0
  159. package/plugins/acryl-router/src/core/jsx/dom/context.d.ts +3 -0
  160. package/plugins/acryl-router/src/core/jsx/dom/css.d.ts +83 -0
  161. package/plugins/acryl-router/src/core/jsx/dom/hooks/index.d.ts +39 -0
  162. package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.d.ts +16 -0
  163. package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.d.ts +8 -0
  164. package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.d.ts +7 -0
  165. package/plugins/acryl-router/src/core/jsx/dom/render.d.ts +73 -0
  166. package/plugins/acryl-router/src/core/jsx/dom/utils.d.ts +1 -0
  167. package/plugins/acryl-router/src/core/jsx/hooks/index.d.ts +47 -0
  168. package/plugins/acryl-router/src/core/jsx/index.d.ts +76 -0
  169. package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.d.ts +6 -0
  170. package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.d.ts +13 -0
  171. package/plugins/acryl-router/src/core/jsx/intrinsic-elements.d.ts +735 -0
  172. package/plugins/acryl-router/src/core/jsx/streaming.d.ts +36 -0
  173. package/plugins/acryl-router/src/core/jsx/types.d.ts +36 -0
  174. package/plugins/acryl-router/src/core/jsx/utils.d.ts +4 -0
  175. package/plugins/acryl-router/src/core/request/constants.d.ts +1 -0
  176. package/plugins/acryl-router/src/core/request.d.ts +306 -0
  177. package/plugins/acryl-router/src/core/router/reg-exp-router/index.d.ts +6 -0
  178. package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.d.ts +7 -0
  179. package/plugins/acryl-router/src/core/router/reg-exp-router/node.d.ts +13 -0
  180. package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.d.ts +17 -0
  181. package/plugins/acryl-router/src/core/router/reg-exp-router/router.d.ts +11 -0
  182. package/plugins/acryl-router/src/core/router/reg-exp-router/trie.d.ts +8 -0
  183. package/plugins/acryl-router/src/core/router/smart-router/index.d.ts +5 -0
  184. package/plugins/acryl-router/src/core/router/smart-router/router.d.ts +11 -0
  185. package/plugins/acryl-router/src/core/router/trie-router/index.d.ts +5 -0
  186. package/plugins/acryl-router/src/core/router/trie-router/node.d.ts +6 -0
  187. package/plugins/acryl-router/src/core/router/trie-router/router.d.ts +7 -0
  188. package/plugins/acryl-router/src/core/router/utils.d.ts +1 -0
  189. package/plugins/acryl-router/src/core/router.d.ts +97 -0
  190. package/plugins/acryl-router/src/core/types.d.ts +573 -0
  191. package/plugins/acryl-router/src/core/utils/accept.d.ts +6 -0
  192. package/plugins/acryl-router/src/core/utils/body.d.ts +79 -0
  193. package/plugins/acryl-router/src/core/utils/buffer.d.ts +17 -0
  194. package/plugins/acryl-router/src/core/utils/color.d.ts +21 -0
  195. package/plugins/acryl-router/src/core/utils/concurrent.d.ts +11 -0
  196. package/plugins/acryl-router/src/core/utils/constants.d.ts +4 -0
  197. package/plugins/acryl-router/src/core/utils/cookie.d.ts +41 -0
  198. package/plugins/acryl-router/src/core/utils/crypto.d.ts +15 -0
  199. package/plugins/acryl-router/src/core/utils/handler.d.ts +6 -0
  200. package/plugins/acryl-router/src/core/utils/headers.d.ts +8 -0
  201. package/plugins/acryl-router/src/core/utils/html.d.ts +44 -0
  202. package/plugins/acryl-router/src/core/utils/http-status.d.ts +32 -0
  203. package/plugins/acryl-router/src/core/utils/mime.d.ts +70 -0
  204. package/plugins/acryl-router/src/core/utils/stream.d.ts +31 -0
  205. package/plugins/acryl-router/src/core/utils/types.d.ts +128 -0
  206. package/plugins/acryl-router/src/core/utils/url.d.ts +44 -0
  207. package/plugins/acryl-router/src/core/validator/index.d.ts +7 -0
  208. package/plugins/acryl-router/src/core/validator/utils.d.ts +29 -0
  209. package/plugins/acryl-router/src/core/validator/validator.d.ts +16 -0
  210. package/plugins/acryl-router/src/helpers/index.d.ts +17 -0
  211. package/plugins/acryl-router/src/helpers/schema-validator.d.ts +54 -0
  212. package/plugins/acryl-router-http/plugin.json +4 -1
  213. package/plugins/acryl-router-http/src/index.ts +1 -1
  214. package/plugins/acryl-state/plugin.json +5 -1
  215. package/plugins/acryl-state/src/service.ts +3 -3
  216. package/plugins/tsconfig.json +32 -20
  217. package/docs/framework/UPSTREAM.md +0 -3
  218. package/docs/framework/upstream.json +0 -9
  219. package/lib/index-D4FAsBZu.d.ts +0 -85
  220. package/plugins/acryl-db/upstream.json +0 -18
  221. package/plugins/acryl-db-sqlite/upstream.json +0 -21
  222. package/plugins/acryl-door/upstream.json +0 -28
  223. package/plugins/acryl-inspect/upstream.json +0 -18
  224. package/plugins/acryl-kv/upstream.json +0 -18
  225. package/plugins/acryl-kv-db/upstream.json +0 -21
  226. package/plugins/acryl-kv-json/upstream.json +0 -22
  227. package/plugins/acryl-node-server/upstream.json +0 -21
  228. package/plugins/acryl-router/upstream.json +0 -20
  229. package/plugins/acryl-router-http/upstream.json +0 -22
  230. package/plugins/acryl-state/NOTICE +0 -30
  231. package/plugins/acryl-state/upstream.json +0 -22
  232. package/plugins/desktop/upstream.json +0 -12
  233. package/plugins/desktop-web/upstream.json +0 -12
  234. package/templates/todo/upstream.json +0 -12
  235. /package/lib/{index-CTy4N7ng.d.ts → deprecated-CTy4N7ng.d.ts} +0 -0
@@ -0,0 +1,98 @@
1
+ import { B as NotFoundHandler, y as ErrorHandler } from "./context-DS3fYyG-.js";
2
+ import { t as ConnectionInfo } from "./connection-ZLEso7XL.js";
3
+ import { Context, Service } from "@deepseek-ai/cordis";
4
+ import z from "@deepseek-ai/schemastery";
5
+
6
+ //#region ../../plugins/acryl-router/src/service.d.ts
7
+ /** How a trailing slash is read: `strict` keeps `/a` and `/a/` distinct, `ignore` treats them as one path. */
8
+ type TrailingSlash = 'strict' | 'ignore';
9
+ /** Validated plugin configuration. */
10
+ interface Config {
11
+ trailingSlash: TrailingSlash;
12
+ disposeGraceMs: number;
13
+ }
14
+ /** Every field has a default, so a caller passes only what it changes: `ctx.plugin(plugin, { ... })` takes the partial shape. */
15
+ declare const Config: z<Partial<Config>, Config>;
16
+ /**
17
+ * The Web adapter's service (`ctx.routerHttp`, provided by `acryl-router-http`). Declared here, beside `router`, so a plugin can ask for its routes to be
18
+ * served over HTTP without depending on the adapter package.
19
+ */
20
+ interface RouterHttpService {
21
+ /** Serve `prefix` and everything below it through the router; returns a remover. The mount also goes away when the calling plugin unloads. */
22
+ mount(prefix: string): () => void;
23
+ }
24
+ declare module '@deepseek-ai/cordis' {
25
+ interface Context {
26
+ router: Router;
27
+ routerHttp: RouterHttpService;
28
+ }
29
+ }
30
+ /** Stable Cordis plugin name, equal to the package name and the Loader row id. */
31
+ declare const name = "acryl-router";
32
+ /**
33
+ * What {@link Router.route} takes: any app with routes, read structurally. An `Acryl` from this package qualifies, and so does one built from
34
+ * another copy of the framework (the published `acrylblends`), whose classes TypeScript would refuse nominally for their private members:
35
+ * mounting copies the app's routes (and keeps its own `onError`), which is all the router reads. Their handlers are then called with this
36
+ * router's `Context`, which has the same shape.
37
+ */
38
+ interface MountableApp {
39
+ readonly routes: readonly MountableRoute[];
40
+ }
41
+ /** One route of a {@link MountableApp}, as the core lists it. A handler of any context type fits (`never` parameters accept every function). */
42
+ interface MountableRoute {
43
+ readonly basePath: string;
44
+ readonly path: string;
45
+ readonly method: string;
46
+ readonly handler: (c: never, next: never) => unknown;
47
+ }
48
+ declare class Router extends Service {
49
+ /** Everything that changes after construction, kept in one object so the service's live state is in one place. */
50
+ private readonly state;
51
+ private readonly flights;
52
+ /** The flight of each request the router dispatched, keyed by the request its handlers see as `c.req.raw`. */
53
+ private readonly flightOf;
54
+ private readonly strict;
55
+ private readonly graceMs;
56
+ private readonly logError;
57
+ constructor(ctx: Context, config?: Partial<Config>);
58
+ /** Registrations currently held (mounts, and the router-wide error and not-found handlers); a leak check for reload tests. */
59
+ get size(): number;
60
+ /**
61
+ * Serve `app` under `path` (`'/'` for its own paths as they are). The mount belongs to the calling plugin and goes away when it unloads;
62
+ * the returned function removes it sooner. Mounts are composed in the order they were made. Like the core's own `app.route`, the routes
63
+ * are copied now: one the app registers after this call is not served (mount again, or finish the app first).
64
+ */
65
+ route(path: string, app: MountableApp): () => void;
66
+ /**
67
+ * The mount's own copy of `app`'s routes as they are now (like the core's `app.route`), each handler wrapped so the router knows which
68
+ * mount's code a request is in. The core's `app.route` runs first so a sub-app's own `onError` still applies to its routes.
69
+ */
70
+ private snapshot;
71
+ /** Abort `flights`, cut their bodies short and wait for them to settle, at most `disposeGraceMs`. */
72
+ private end;
73
+ /** Turn errors no mounted app handled into responses. One handler per router; the calling plugin owns it. */
74
+ onError(handler: ErrorHandler): () => void;
75
+ /** Answer requests no route claimed. One handler per router; the calling plugin owns it. */
76
+ notFound(handler: NotFoundHandler): () => void;
77
+ /**
78
+ * Call the router the way a test calls an app: a path or URL string, a `URL` or a `Request`, with the usual init.
79
+ * A relative path is resolved against `http://localhost`.
80
+ */
81
+ request(input: string | URL | Request, init?: RequestInit, connection?: ConnectionInfo): Promise<Response>;
82
+ /**
83
+ * Run a request in process. Never throws: failures become a 500, a disposed router answers 503. `connection` describes the transport
84
+ * (an HTTP adapter passes the socket's peer address and local port); an in-process caller omits it. Handlers read it with
85
+ * `connectionOf(c)`, abort with `c.req.raw.signal` and keep the request in flight with `c.executionCtx.waitUntil(task)`.
86
+ */
87
+ fetch(request: Request, connection?: ConnectionInfo): Promise<Response>;
88
+ private dispatch;
89
+ private app;
90
+ /**
91
+ * Hand the caller a body the router can end. Reading it passes the handler's chunks through; disposal cancels the handler's stream (which runs
92
+ * the stream helpers' own abort cleanup) and closes the caller's side, so a stream never outlives the plugin that served it.
93
+ */
94
+ private track;
95
+ }
96
+ declare function apply(ctx: Context, config?: Partial<Config>): void;
97
+ //#endregion
98
+ export { TrailingSlash as a, RouterHttpService as i, MountableApp as n, apply as o, Router as r, name as s, Config as t };
@@ -0,0 +1,44 @@
1
+ import { t as Db } from "./database-DBHdwefi.js";
2
+
3
+ //#region ../../plugins/acryl-db/src/facade/migrations.d.ts
4
+ type Migration = {
5
+ readonly version: number;
6
+ readonly statements: readonly string[];
7
+ };
8
+ /**
9
+ * Apply all pending migrations atomically, tracking their version in the named metadata table.
10
+ *
11
+ * The bookkeeping SQL runs unchanged on SQLite and Postgres: no `STRICT` table, `ON CONFLICT DO NOTHING`
12
+ * instead of `INSERT OR IGNORE`, and the version written as a checked integer rather than a binding,
13
+ * since the two dialects spell placeholders differently.
14
+ */
15
+ declare function applyMigrations(database: Db, migrations: readonly Migration[], options: {
16
+ readonly table: string;
17
+ }): Promise<void>;
18
+ //#endregion
19
+ //#region ../../plugins/acryl-db/src/facade/schema.d.ts
20
+ /** Validate a prefix before using it as part of a SQL identifier. */
21
+ declare function validateSchemaPrefix(prefix: string): void;
22
+ //#endregion
23
+ //#region ../../plugins/acryl-db/src/migration-files.d.ts
24
+ /**
25
+ * Read every `NNN-name.sql` file of a folder, in number order.
26
+ * @throws when a `.sql` file is not named `NNN-name.sql`, or the numbers do not run 1, 2, 3, ... without gaps or repeats.
27
+ */
28
+ declare function readMigrationFiles(folder: string | URL): Promise<Migration[]>;
29
+ //#endregion
30
+ //#region ../../plugins/acryl-db/src/index.d.ts
31
+ /**
32
+ * The `db` port: what an app's code sees of its relational database, whichever provider (`acryl-db-sqlite`, `acryl-db-postgres`) serves
33
+ * it. Plain code (an acrylblends app) opens a database with a provider's `openDb`; a Cordis plugin declares `inject: ['db']`, imports
34
+ * `acryl-db/cordis` for the `ctx.db` type, and never imports a driver.
35
+ *
36
+ * Bindings are positional `?` placeholders on every provider; a provider whose database spells them differently translates them.
37
+ * This entry imports nothing from Cordis, at runtime or in its types.
38
+ */
39
+ /** The service name every `db` provider registers. */
40
+ declare const DB_SERVICE = "db";
41
+ /** The table that records an app's migration version. */
42
+ declare const MIGRATIONS_TABLE = "_migrations";
43
+ //#endregion
44
+ export { Migration as a, validateSchemaPrefix as i, MIGRATIONS_TABLE as n, applyMigrations as o, readMigrationFiles as r, DB_SERVICE as t };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { B as NotFoundHandler, L as MiddlewareHandler, O as Handler, Q as ValidationTargets, V as NotFoundResponse, X as ToSchema, Y as Schema, Z as TypedResponse, a as ExecutionContext, j as Input, n as ContextRenderer, r as ContextVariableMap, s as AcrylRequest, t as Context, v as Env, y as ErrorHandler, z as Next } from "./context-DS3fYyG-.js";
2
2
  import { t as Acryl } from "./app-D8riatvv.js";
3
3
  import { c as InferRequestType, i as ClientRequestOptions, l as InferResponseType } from "./types-zNxyEpG2.js";
4
- import { n as AppRequest, t as App } from "./index-CTy4N7ng.js";
4
+ import { n as AppRequest, t as App } from "./deprecated-CTy4N7ng.js";
5
5
  export { Acryl, type AcrylRequest, App, type AppRequest, type ClientRequestOptions, Context, type ContextRenderer, type ContextVariableMap, type Env, type ErrorHandler, type ExecutionContext, type Handler, type InferRequestType, type InferResponseType, type Input, type MiddlewareHandler, type Next, type NotFoundHandler, type NotFoundResponse, type Schema, type ToSchema, type TypedResponse, type ValidationTargets };
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { t as Context } from "./context-DDO0cfuP.js";
2
2
  import { t as Acryl } from "./app-BM0rTCp7.js";
3
- import { t as App } from "./src-0hI7M7cN.js";
3
+ import "./core-CaY8XDZ6.js";
4
+ import { t as App } from "./deprecated-BP4fPt38.js";
4
5
  export { Acryl, App, Context };
@@ -0,0 +1,117 @@
1
+ import { HTTPException } from "./http-exception.js";
2
+ import { getCookie, getSignedCookie } from "./cookie.js";
3
+ import { t as Jwt } from "./jwt-BGJBw5AF.js";
4
+ //#region ../../plugins/acryl-router/src/core/middleware/jwk/jwk.ts
5
+ /**
6
+ * JWK Auth Middleware for Acryl.
7
+ *
8
+ *
9
+ * @param {object} options - The options for the JWK middleware.
10
+ * @param {AcrylJsonWebKey[] | ((ctx: Context) => Promise<AcrylJsonWebKey[]> | AcrylJsonWebKey[])} [options.keys] - The public keys used for JWK verification, or a function that returns them.
11
+ * @param {string | ((ctx: Context) => Promise<string> | string)} [options.jwks_uri] - If set to a URI string or a function that returns a URI string, attempt to fetch JWKs from it. The response must be a JSON object containing a `keys` array, which will be merged with the `keys` option.
12
+ * @param {boolean} [options.allow_anon] - If set to `true`, the middleware allows requests without a token to proceed without authentication.
13
+ * @param {string} [options.cookie] - If set, the middleware attempts to retrieve the token from a cookie with these options (optionally signed) only if no token is found in the header.
14
+ * @param {string} [options.headerName='Authorization'] - The name of the header to look for the JWT token. Default is 'Authorization'.
15
+ * @param {string} [options.realm] - The protection space described by the `realm` parameter of the returned `WWW-Authenticate` challenge header. Defaults to the request URL.
16
+ * @param {AsymmetricAlgorithm[]} options.alg - An array of allowed asymmetric algorithms for JWT verification. Only tokens signed with these algorithms will be accepted.
17
+ * @param {RequestInit} [init] - Optional init options for the `fetch` request when retrieving JWKS from a URI.
18
+ * @param {VerifyOptions} [options.verification] - Additional options for JWK payload verification.
19
+ * @returns {MiddlewareHandler} The middleware handler function.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const app = new Acryl()
24
+ *
25
+ * app.use("/auth/*", jwk({
26
+ * jwks_uri: (c) => `https://${c.env.authServer}/.well-known/jwks.json`,
27
+ * headerName: 'x-custom-auth-header', // Optional, default is 'Authorization'
28
+ * }))
29
+ *
30
+ * app.get('/auth/page', (c) => {
31
+ * return c.text('You are authorized')
32
+ * })
33
+ * ```
34
+ */
35
+ const jwk = (options, init) => {
36
+ const verifyOpts = options.verification || {};
37
+ if (!options || !(options.keys || options.jwks_uri)) throw new Error("JWK auth middleware requires options for either \"keys\" or \"jwks_uri\" or both");
38
+ if (!crypto.subtle || !crypto.subtle.importKey) throw new Error("`crypto.subtle.importKey` is undefined. JWK auth middleware requires it.");
39
+ return async function jwk(ctx, next) {
40
+ const headerName = options.headerName || "Authorization";
41
+ const credentials = ctx.req.raw.headers.get(headerName);
42
+ let token;
43
+ if (credentials) {
44
+ const parts = credentials.split(/\s+/);
45
+ if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
46
+ const errDescription = "invalid credentials structure";
47
+ throw new HTTPException(401, {
48
+ message: errDescription,
49
+ res: unauthorizedResponse({
50
+ ctx,
51
+ error: "invalid_request",
52
+ errDescription,
53
+ realm: options.realm
54
+ })
55
+ });
56
+ } else token = parts[1];
57
+ } else if (options.cookie) if (typeof options.cookie == "string") token = getCookie(ctx, options.cookie);
58
+ else if (options.cookie.secret) if (options.cookie.prefixOptions) token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key, options.cookie.prefixOptions);
59
+ else token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key);
60
+ else if (options.cookie.prefixOptions) token = getCookie(ctx, options.cookie.key, options.cookie.prefixOptions);
61
+ else token = getCookie(ctx, options.cookie.key);
62
+ if (!token) {
63
+ if (options.allow_anon) return next();
64
+ const errDescription = "no authorization included in request";
65
+ throw new HTTPException(401, {
66
+ message: errDescription,
67
+ res: unauthorizedResponse({
68
+ ctx,
69
+ error: "invalid_request",
70
+ errDescription,
71
+ realm: options.realm
72
+ })
73
+ });
74
+ }
75
+ let payload;
76
+ let cause;
77
+ try {
78
+ const keys = typeof options.keys === "function" ? await options.keys(ctx) : options.keys;
79
+ const jwks_uri = typeof options.jwks_uri === "function" ? await options.jwks_uri(ctx) : options.jwks_uri;
80
+ payload = await Jwt.verifyWithJwks(token, {
81
+ keys,
82
+ jwks_uri,
83
+ verification: verifyOpts,
84
+ allowedAlgorithms: options.alg
85
+ }, init);
86
+ } catch (e) {
87
+ cause = e;
88
+ }
89
+ if (!payload) {
90
+ if (cause instanceof Error && cause.constructor === Error) throw cause;
91
+ throw new HTTPException(401, {
92
+ message: "Unauthorized",
93
+ res: unauthorizedResponse({
94
+ ctx,
95
+ error: "invalid_token",
96
+ statusText: "Unauthorized",
97
+ errDescription: "token verification failure",
98
+ realm: options.realm
99
+ }),
100
+ cause
101
+ });
102
+ }
103
+ ctx.set("jwtPayload", payload);
104
+ await next();
105
+ };
106
+ };
107
+ function unauthorizedResponse(opts) {
108
+ const realm = (opts.realm ?? opts.ctx.req.url).replace(/"/g, "\\\"");
109
+ const errDescription = opts.errDescription.replace(/"/g, "\\\"");
110
+ return new Response("Unauthorized", {
111
+ status: 401,
112
+ statusText: opts.statusText,
113
+ headers: { "WWW-Authenticate": `Bearer realm="${realm}",error="${opts.error}",error_description="${errDescription}"` }
114
+ });
115
+ }
116
+ //#endregion
117
+ export { jwk as t };
package/lib/jwk.js CHANGED
@@ -1,117 +1,2 @@
1
- import { HTTPException } from "./http-exception.js";
2
- import { getCookie, getSignedCookie } from "./cookie.js";
3
- import { t as Jwt } from "./jwt-BGJBw5AF.js";
4
- //#region ../../plugins/acryl-router/src/core/middleware/jwk/jwk.ts
5
- /**
6
- * JWK Auth Middleware for Acryl.
7
- *
8
- *
9
- * @param {object} options - The options for the JWK middleware.
10
- * @param {AcrylJsonWebKey[] | ((ctx: Context) => Promise<AcrylJsonWebKey[]> | AcrylJsonWebKey[])} [options.keys] - The public keys used for JWK verification, or a function that returns them.
11
- * @param {string | ((ctx: Context) => Promise<string> | string)} [options.jwks_uri] - If set to a URI string or a function that returns a URI string, attempt to fetch JWKs from it. The response must be a JSON object containing a `keys` array, which will be merged with the `keys` option.
12
- * @param {boolean} [options.allow_anon] - If set to `true`, the middleware allows requests without a token to proceed without authentication.
13
- * @param {string} [options.cookie] - If set, the middleware attempts to retrieve the token from a cookie with these options (optionally signed) only if no token is found in the header.
14
- * @param {string} [options.headerName='Authorization'] - The name of the header to look for the JWT token. Default is 'Authorization'.
15
- * @param {string} [options.realm] - The protection space described by the `realm` parameter of the returned `WWW-Authenticate` challenge header. Defaults to the request URL.
16
- * @param {AsymmetricAlgorithm[]} options.alg - An array of allowed asymmetric algorithms for JWT verification. Only tokens signed with these algorithms will be accepted.
17
- * @param {RequestInit} [init] - Optional init options for the `fetch` request when retrieving JWKS from a URI.
18
- * @param {VerifyOptions} [options.verification] - Additional options for JWK payload verification.
19
- * @returns {MiddlewareHandler} The middleware handler function.
20
- *
21
- * @example
22
- * ```ts
23
- * const app = new Acryl()
24
- *
25
- * app.use("/auth/*", jwk({
26
- * jwks_uri: (c) => `https://${c.env.authServer}/.well-known/jwks.json`,
27
- * headerName: 'x-custom-auth-header', // Optional, default is 'Authorization'
28
- * }))
29
- *
30
- * app.get('/auth/page', (c) => {
31
- * return c.text('You are authorized')
32
- * })
33
- * ```
34
- */
35
- const jwk = (options, init) => {
36
- const verifyOpts = options.verification || {};
37
- if (!options || !(options.keys || options.jwks_uri)) throw new Error("JWK auth middleware requires options for either \"keys\" or \"jwks_uri\" or both");
38
- if (!crypto.subtle || !crypto.subtle.importKey) throw new Error("`crypto.subtle.importKey` is undefined. JWK auth middleware requires it.");
39
- return async function jwk(ctx, next) {
40
- const headerName = options.headerName || "Authorization";
41
- const credentials = ctx.req.raw.headers.get(headerName);
42
- let token;
43
- if (credentials) {
44
- const parts = credentials.split(/\s+/);
45
- if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
46
- const errDescription = "invalid credentials structure";
47
- throw new HTTPException(401, {
48
- message: errDescription,
49
- res: unauthorizedResponse({
50
- ctx,
51
- error: "invalid_request",
52
- errDescription,
53
- realm: options.realm
54
- })
55
- });
56
- } else token = parts[1];
57
- } else if (options.cookie) if (typeof options.cookie == "string") token = getCookie(ctx, options.cookie);
58
- else if (options.cookie.secret) if (options.cookie.prefixOptions) token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key, options.cookie.prefixOptions);
59
- else token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key);
60
- else if (options.cookie.prefixOptions) token = getCookie(ctx, options.cookie.key, options.cookie.prefixOptions);
61
- else token = getCookie(ctx, options.cookie.key);
62
- if (!token) {
63
- if (options.allow_anon) return next();
64
- const errDescription = "no authorization included in request";
65
- throw new HTTPException(401, {
66
- message: errDescription,
67
- res: unauthorizedResponse({
68
- ctx,
69
- error: "invalid_request",
70
- errDescription,
71
- realm: options.realm
72
- })
73
- });
74
- }
75
- let payload;
76
- let cause;
77
- try {
78
- const keys = typeof options.keys === "function" ? await options.keys(ctx) : options.keys;
79
- const jwks_uri = typeof options.jwks_uri === "function" ? await options.jwks_uri(ctx) : options.jwks_uri;
80
- payload = await Jwt.verifyWithJwks(token, {
81
- keys,
82
- jwks_uri,
83
- verification: verifyOpts,
84
- allowedAlgorithms: options.alg
85
- }, init);
86
- } catch (e) {
87
- cause = e;
88
- }
89
- if (!payload) {
90
- if (cause instanceof Error && cause.constructor === Error) throw cause;
91
- throw new HTTPException(401, {
92
- message: "Unauthorized",
93
- res: unauthorizedResponse({
94
- ctx,
95
- error: "invalid_token",
96
- statusText: "Unauthorized",
97
- errDescription: "token verification failure",
98
- realm: options.realm
99
- }),
100
- cause
101
- });
102
- }
103
- ctx.set("jwtPayload", payload);
104
- await next();
105
- };
106
- };
107
- function unauthorizedResponse(opts) {
108
- const realm = (opts.realm ?? opts.ctx.req.url).replace(/"/g, "\\\"");
109
- const errDescription = opts.errDescription.replace(/"/g, "\\\"");
110
- return new Response("Unauthorized", {
111
- status: 401,
112
- statusText: opts.statusText,
113
- headers: { "WWW-Authenticate": `Bearer realm="${realm}",error="${opts.error}",error_description="${errDescription}"` }
114
- });
115
- }
116
- //#endregion
1
+ import { t as jwk } from "./jwk-LkzeoaU8.js";
117
2
  export { jwk };
@@ -0,0 +1,115 @@
1
+ import { HTTPException } from "./http-exception.js";
2
+ import { getCookie, getSignedCookie } from "./cookie.js";
3
+ import { t as Jwt } from "./jwt-BGJBw5AF.js";
4
+ //#region ../../plugins/acryl-router/src/core/middleware/jwt/jwt.ts
5
+ /**
6
+ * JWT Auth Middleware for Acryl.
7
+ *
8
+ *
9
+ * @param {object} options - The options for the JWT middleware.
10
+ * @param {SignatureKey} options.secret - A value of your secret key.
11
+ * @param {string} [options.cookie] - If this value is set, then the value is retrieved from the cookie header using that value as a key, which is then validated as a token.
12
+ * @param {SignatureAlgorithm} options.alg - An algorithm type that is used for verifying (required). Available types are `HS256` | `HS384` | `HS512` | `RS256` | `RS384` | `RS512` | `PS256` | `PS384` | `PS512` | `ES256` | `ES384` | `ES512` | `EdDSA`.
13
+ * @param {string} [options.headerName='Authorization'] - The name of the header to look for the JWT token. Default is 'Authorization'.
14
+ * @param {string} [options.realm] - The protection space described by the `realm` parameter of the returned `WWW-Authenticate` challenge header. Defaults to the request URL.
15
+ * @param {VerifyOptions} [options.verification] - Additional options for JWT payload verification.
16
+ * @returns {MiddlewareHandler} The middleware handler function.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const app = new Acryl()
21
+ *
22
+ * app.use(
23
+ * '/auth/*',
24
+ * jwt({
25
+ * secret: process.env.JWT_SECRET, // never a literal in source
26
+ * alg: 'HS256',
27
+ * headerName: 'x-custom-auth-header', // Optional, default is 'Authorization'
28
+ * })
29
+ * )
30
+ *
31
+ * app.get('/auth/page', (c) => {
32
+ * return c.text('You are authorized')
33
+ * })
34
+ * ```
35
+ */
36
+ const jwt = (options) => {
37
+ const verifyOpts = options.verification || {};
38
+ if (!options || !options.secret) throw new Error("JWT auth middleware requires options for \"secret\"");
39
+ if (!options.alg) throw new Error("JWT auth middleware requires options for \"alg\"");
40
+ if (!crypto.subtle || !crypto.subtle.importKey) throw new Error("`crypto.subtle.importKey` is undefined. JWT auth middleware requires it.");
41
+ return async function jwt(ctx, next) {
42
+ const headerName = options.headerName || "Authorization";
43
+ const credentials = ctx.req.raw.headers.get(headerName);
44
+ let token;
45
+ if (credentials) {
46
+ const parts = credentials.split(/\s+/);
47
+ if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
48
+ const errDescription = "invalid credentials structure";
49
+ throw new HTTPException(401, {
50
+ message: errDescription,
51
+ res: unauthorizedResponse({
52
+ ctx,
53
+ error: "invalid_request",
54
+ errDescription,
55
+ realm: options.realm
56
+ })
57
+ });
58
+ } else token = parts[1];
59
+ } else if (options.cookie) if (typeof options.cookie == "string") token = getCookie(ctx, options.cookie);
60
+ else if (options.cookie.secret) if (options.cookie.prefixOptions) token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key, options.cookie.prefixOptions);
61
+ else token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key);
62
+ else if (options.cookie.prefixOptions) token = getCookie(ctx, options.cookie.key, options.cookie.prefixOptions);
63
+ else token = getCookie(ctx, options.cookie.key);
64
+ if (!token) {
65
+ const errDescription = "no authorization included in request";
66
+ throw new HTTPException(401, {
67
+ message: errDescription,
68
+ res: unauthorizedResponse({
69
+ ctx,
70
+ error: "invalid_request",
71
+ errDescription,
72
+ realm: options.realm
73
+ })
74
+ });
75
+ }
76
+ let payload;
77
+ let cause;
78
+ try {
79
+ payload = await Jwt.verify(token, options.secret, {
80
+ alg: options.alg,
81
+ ...verifyOpts
82
+ });
83
+ } catch (e) {
84
+ cause = e;
85
+ }
86
+ if (!payload) throw new HTTPException(401, {
87
+ message: "Unauthorized",
88
+ res: unauthorizedResponse({
89
+ ctx,
90
+ error: "invalid_token",
91
+ statusText: "Unauthorized",
92
+ errDescription: "token verification failure",
93
+ realm: options.realm
94
+ }),
95
+ cause
96
+ });
97
+ ctx.set("jwtPayload", payload);
98
+ await next();
99
+ };
100
+ };
101
+ function unauthorizedResponse(opts) {
102
+ const realm = (opts.realm ?? opts.ctx.req.url).replace(/"/g, "\\\"");
103
+ const errDescription = opts.errDescription.replace(/"/g, "\\\"");
104
+ return new Response("Unauthorized", {
105
+ status: 401,
106
+ statusText: opts.statusText,
107
+ headers: { "WWW-Authenticate": `Bearer realm="${realm}",error="${opts.error}",error_description="${errDescription}"` }
108
+ });
109
+ }
110
+ const verifyWithJwks = Jwt.verifyWithJwks;
111
+ const verify = Jwt.verify;
112
+ const decode = Jwt.decode;
113
+ const sign = Jwt.sign;
114
+ //#endregion
115
+ export { verifyWithJwks as a, verify as i, jwt as n, sign as r, decode as t };
package/lib/jwt.js CHANGED
@@ -1,115 +1,3 @@
1
- import { HTTPException } from "./http-exception.js";
2
- import { getCookie, getSignedCookie } from "./cookie.js";
3
- import { n as AlgorithmTypes, t as Jwt } from "./jwt-BGJBw5AF.js";
4
- //#region ../../plugins/acryl-router/src/core/middleware/jwt/jwt.ts
5
- /**
6
- * JWT Auth Middleware for Acryl.
7
- *
8
- *
9
- * @param {object} options - The options for the JWT middleware.
10
- * @param {SignatureKey} options.secret - A value of your secret key.
11
- * @param {string} [options.cookie] - If this value is set, then the value is retrieved from the cookie header using that value as a key, which is then validated as a token.
12
- * @param {SignatureAlgorithm} options.alg - An algorithm type that is used for verifying (required). Available types are `HS256` | `HS384` | `HS512` | `RS256` | `RS384` | `RS512` | `PS256` | `PS384` | `PS512` | `ES256` | `ES384` | `ES512` | `EdDSA`.
13
- * @param {string} [options.headerName='Authorization'] - The name of the header to look for the JWT token. Default is 'Authorization'.
14
- * @param {string} [options.realm] - The protection space described by the `realm` parameter of the returned `WWW-Authenticate` challenge header. Defaults to the request URL.
15
- * @param {VerifyOptions} [options.verification] - Additional options for JWT payload verification.
16
- * @returns {MiddlewareHandler} The middleware handler function.
17
- *
18
- * @example
19
- * ```ts
20
- * const app = new Acryl()
21
- *
22
- * app.use(
23
- * '/auth/*',
24
- * jwt({
25
- * secret: process.env.JWT_SECRET, // never a literal in source
26
- * alg: 'HS256',
27
- * headerName: 'x-custom-auth-header', // Optional, default is 'Authorization'
28
- * })
29
- * )
30
- *
31
- * app.get('/auth/page', (c) => {
32
- * return c.text('You are authorized')
33
- * })
34
- * ```
35
- */
36
- const jwt = (options) => {
37
- const verifyOpts = options.verification || {};
38
- if (!options || !options.secret) throw new Error("JWT auth middleware requires options for \"secret\"");
39
- if (!options.alg) throw new Error("JWT auth middleware requires options for \"alg\"");
40
- if (!crypto.subtle || !crypto.subtle.importKey) throw new Error("`crypto.subtle.importKey` is undefined. JWT auth middleware requires it.");
41
- return async function jwt(ctx, next) {
42
- const headerName = options.headerName || "Authorization";
43
- const credentials = ctx.req.raw.headers.get(headerName);
44
- let token;
45
- if (credentials) {
46
- const parts = credentials.split(/\s+/);
47
- if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
48
- const errDescription = "invalid credentials structure";
49
- throw new HTTPException(401, {
50
- message: errDescription,
51
- res: unauthorizedResponse({
52
- ctx,
53
- error: "invalid_request",
54
- errDescription,
55
- realm: options.realm
56
- })
57
- });
58
- } else token = parts[1];
59
- } else if (options.cookie) if (typeof options.cookie == "string") token = getCookie(ctx, options.cookie);
60
- else if (options.cookie.secret) if (options.cookie.prefixOptions) token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key, options.cookie.prefixOptions);
61
- else token = await getSignedCookie(ctx, options.cookie.secret, options.cookie.key);
62
- else if (options.cookie.prefixOptions) token = getCookie(ctx, options.cookie.key, options.cookie.prefixOptions);
63
- else token = getCookie(ctx, options.cookie.key);
64
- if (!token) {
65
- const errDescription = "no authorization included in request";
66
- throw new HTTPException(401, {
67
- message: errDescription,
68
- res: unauthorizedResponse({
69
- ctx,
70
- error: "invalid_request",
71
- errDescription,
72
- realm: options.realm
73
- })
74
- });
75
- }
76
- let payload;
77
- let cause;
78
- try {
79
- payload = await Jwt.verify(token, options.secret, {
80
- alg: options.alg,
81
- ...verifyOpts
82
- });
83
- } catch (e) {
84
- cause = e;
85
- }
86
- if (!payload) throw new HTTPException(401, {
87
- message: "Unauthorized",
88
- res: unauthorizedResponse({
89
- ctx,
90
- error: "invalid_token",
91
- statusText: "Unauthorized",
92
- errDescription: "token verification failure",
93
- realm: options.realm
94
- }),
95
- cause
96
- });
97
- ctx.set("jwtPayload", payload);
98
- await next();
99
- };
100
- };
101
- function unauthorizedResponse(opts) {
102
- const realm = (opts.realm ?? opts.ctx.req.url).replace(/"/g, "\\\"");
103
- const errDescription = opts.errDescription.replace(/"/g, "\\\"");
104
- return new Response("Unauthorized", {
105
- status: 401,
106
- statusText: opts.statusText,
107
- headers: { "WWW-Authenticate": `Bearer realm="${realm}",error="${opts.error}",error_description="${errDescription}"` }
108
- });
109
- }
110
- const verifyWithJwks = Jwt.verifyWithJwks;
111
- const verify = Jwt.verify;
112
- const decode = Jwt.decode;
113
- const sign = Jwt.sign;
114
- //#endregion
1
+ import { n as AlgorithmTypes } from "./jwt-BGJBw5AF.js";
2
+ import { a as verifyWithJwks, i as verify, n as jwt, r as sign, t as decode } from "./jwt-CskdhEW9.js";
115
3
  export { AlgorithmTypes, decode, jwt, sign, verify, verifyWithJwks };
@@ -0,0 +1,13 @@
1
+ import { n as Kv } from "../kv-9f-AlRKN.js";
2
+
3
+ //#region ../../plugins/acryl-kv/src/conformance.d.ts
4
+ /** A fresh, empty store from the provider under test. */
5
+ interface KvUnderTest {
6
+ readonly kv: Kv;
7
+ close(): Promise<void>;
8
+ /** Close this store (if it is still open) and open the same storage again, to prove what was written is durable. */
9
+ reopen(): Promise<KvUnderTest>;
10
+ }
11
+ declare function describeKvConformance(provider: string, open: () => Promise<KvUnderTest>): void;
12
+ //#endregion
13
+ export { KvUnderTest, describeKvConformance };