ovr 4.5.1 → 5.0.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 (41) hide show
  1. package/dist/app/context.d.ts +58 -56
  2. package/dist/app/context.d.ts.map +1 -1
  3. package/dist/app/context.js +97 -134
  4. package/dist/app/helper/index.d.ts +2 -6
  5. package/dist/app/helper/index.d.ts.map +1 -1
  6. package/dist/app/helper/index.js +5 -19
  7. package/dist/app/index.d.ts +31 -45
  8. package/dist/app/index.d.ts.map +1 -1
  9. package/dist/app/index.js +68 -94
  10. package/dist/app/memo/index.d.ts +1 -1
  11. package/dist/app/memo/index.d.ts.map +1 -1
  12. package/dist/app/memo/index.js +2 -2
  13. package/dist/index.d.ts +1 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +0 -1
  16. package/dist/jsx/chunk/index.d.ts +9 -0
  17. package/dist/jsx/chunk/index.d.ts.map +1 -1
  18. package/dist/jsx/chunk/index.js +11 -0
  19. package/dist/jsx/index.d.ts +5 -4
  20. package/dist/jsx/index.d.ts.map +1 -1
  21. package/dist/jsx/index.js +43 -45
  22. package/dist/jsx/merge-async-generators.d.ts.map +1 -1
  23. package/dist/jsx/merge-async-generators.js +9 -3
  24. package/dist/trie/index.d.ts +5 -0
  25. package/dist/trie/index.d.ts.map +1 -1
  26. package/dist/trie/index.js +8 -2
  27. package/package.json +2 -2
  28. package/src/app/context.ts +100 -164
  29. package/src/app/helper/index.ts +6 -24
  30. package/src/app/index.ts +111 -123
  31. package/src/app/memo/index.ts +2 -2
  32. package/src/index.ts +1 -2
  33. package/src/jsx/chunk/index.ts +12 -0
  34. package/src/jsx/index.ts +61 -74
  35. package/src/jsx/merge-async-generators.ts +8 -5
  36. package/src/trie/index.ts +9 -2
  37. package/src/util/hash.ts +1 -1
  38. package/dist/app/mw/csrf.d.ts +0 -23
  39. package/dist/app/mw/csrf.d.ts.map +0 -1
  40. package/dist/app/mw/csrf.js +0 -30
  41. package/src/app/mw/csrf.ts +0 -32
@@ -1,30 +0,0 @@
1
- /**
2
- * Basic
3
- * [cross-site request forgery (CSRF)](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/CSRF)
4
- * protection that checks the request's `method` and `Origin` header.
5
- * For more robust protection you'll need a stateful server or a database to store
6
- * [CSRF tokens](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/CSRF#csrf_tokens).
7
- *
8
- * @param options
9
- * @returns CSRF middleware
10
- *
11
- * @example
12
- *
13
- * ```ts
14
- * import { csrf } from "ovr";
15
- *
16
- * app.use(csrf({ origin: "https://example.com" }));
17
- * ```
18
- */
19
- export const csrf = (options) => {
20
- if (typeof options.origin === "string")
21
- options.origin = [options.origin];
22
- return (c, next) => {
23
- if (["GET", "HEAD"].includes(c.req.method))
24
- return next();
25
- const origin = c.req.headers.get("Origin");
26
- if (origin && options.origin.includes(origin))
27
- return next();
28
- return c.text("Forbidden", 403);
29
- };
30
- };
@@ -1,32 +0,0 @@
1
- import type { Middleware } from "../index.js";
2
-
3
- /**
4
- * Basic
5
- * [cross-site request forgery (CSRF)](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/CSRF)
6
- * protection that checks the request's `method` and `Origin` header.
7
- * For more robust protection you'll need a stateful server or a database to store
8
- * [CSRF tokens](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/CSRF#csrf_tokens).
9
- *
10
- * @param options
11
- * @returns CSRF middleware
12
- *
13
- * @example
14
- *
15
- * ```ts
16
- * import { csrf } from "ovr";
17
- *
18
- * app.use(csrf({ origin: "https://example.com" }));
19
- * ```
20
- */
21
- export const csrf = (options: { origin: string | string[] }): Middleware => {
22
- if (typeof options.origin === "string") options.origin = [options.origin];
23
-
24
- return (c, next) => {
25
- if (["GET", "HEAD"].includes(c.req.method)) return next();
26
-
27
- const origin = c.req.headers.get("Origin");
28
- if (origin && options.origin.includes(origin)) return next();
29
-
30
- return c.text("Forbidden", 403);
31
- };
32
- };