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.
- package/dist/app/context.d.ts +58 -56
- package/dist/app/context.d.ts.map +1 -1
- package/dist/app/context.js +97 -134
- package/dist/app/helper/index.d.ts +2 -6
- package/dist/app/helper/index.d.ts.map +1 -1
- package/dist/app/helper/index.js +5 -19
- package/dist/app/index.d.ts +31 -45
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +68 -94
- package/dist/app/memo/index.d.ts +1 -1
- package/dist/app/memo/index.d.ts.map +1 -1
- package/dist/app/memo/index.js +2 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/jsx/chunk/index.d.ts +9 -0
- package/dist/jsx/chunk/index.d.ts.map +1 -1
- package/dist/jsx/chunk/index.js +11 -0
- package/dist/jsx/index.d.ts +5 -4
- package/dist/jsx/index.d.ts.map +1 -1
- package/dist/jsx/index.js +43 -45
- package/dist/jsx/merge-async-generators.d.ts.map +1 -1
- package/dist/jsx/merge-async-generators.js +9 -3
- package/dist/trie/index.d.ts +5 -0
- package/dist/trie/index.d.ts.map +1 -1
- package/dist/trie/index.js +8 -2
- package/package.json +2 -2
- package/src/app/context.ts +100 -164
- package/src/app/helper/index.ts +6 -24
- package/src/app/index.ts +111 -123
- package/src/app/memo/index.ts +2 -2
- package/src/index.ts +1 -2
- package/src/jsx/chunk/index.ts +12 -0
- package/src/jsx/index.ts +61 -74
- package/src/jsx/merge-async-generators.ts +8 -5
- package/src/trie/index.ts +9 -2
- package/src/util/hash.ts +1 -1
- package/dist/app/mw/csrf.d.ts +0 -23
- package/dist/app/mw/csrf.d.ts.map +0 -1
- package/dist/app/mw/csrf.js +0 -30
- package/src/app/mw/csrf.ts +0 -32
package/dist/app/mw/csrf.js
DELETED
|
@@ -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
|
-
};
|
package/src/app/mw/csrf.ts
DELETED
|
@@ -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
|
-
};
|