@kamod-ch/otok-flash 2.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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/flash.d.ts +13 -0
- package/dist/flash.d.ts.map +1 -0
- package/dist/flash.js +92 -0
- package/dist/flash.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.d.ts +12 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +20 -0
- package/dist/middleware.js.map +1 -0
- package/dist/plugin.d.ts +15 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +37 -0
- package/dist/plugin.js.map +1 -0
- package/dist/sign.d.ts +6 -0
- package/dist/sign.d.ts.map +1 -0
- package/dist/sign.js +35 -0
- package/dist/sign.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kamod
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @kamod-ch/otok-flash
|
|
2
|
+
|
|
3
|
+
Signed one-time flash cookies for [Otok](https://github.com/kamod-ch/otok) PRG flows.
|
|
4
|
+
|
|
5
|
+
Show SSR toasts after `redirect()` without client JavaScript or session storage.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @kamod-ch/otok-flash hono @kamod-ch/otok
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Action → redirect
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { flashRedirect, flashSuccess } from "@kamod-ch/otok-flash";
|
|
17
|
+
import { flashConfig } from "../features/flash.js";
|
|
18
|
+
|
|
19
|
+
export async function action({ hono }: OtokActionContext) {
|
|
20
|
+
await save();
|
|
21
|
+
flashRedirect("/items", flashSuccess("Gespeichert"), hono, flashConfig);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Loader or middleware → display
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { consumeFlash } from "@kamod-ch/otok-flash";
|
|
29
|
+
import { flashConfig } from "../features/flash.js";
|
|
30
|
+
|
|
31
|
+
export async function loader({ hono }) {
|
|
32
|
+
return {
|
|
33
|
+
flash: consumeFlash(hono, flashConfig),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or globally:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { createFlashMiddleware } from "@kamod-ch/otok-flash/middleware";
|
|
42
|
+
|
|
43
|
+
export default createFlashMiddleware({
|
|
44
|
+
secret: process.env.FLASH_SECRET!,
|
|
45
|
+
contextKey: "flash",
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then read `hono.get("flash")` in loaders/components.
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
| Export | Purpose |
|
|
54
|
+
|--------|---------|
|
|
55
|
+
| `setFlash(c, message, config)` | Set signed flash cookie |
|
|
56
|
+
| `consumeFlash(c, config)` | Read + clear cookie |
|
|
57
|
+
| `flashRedirect(location, message, c, config)` | Set flash and `redirect()` |
|
|
58
|
+
| `flashSuccess` / `flashError` / … | Message helpers |
|
|
59
|
+
| `createFlashMiddleware(config)` | Auto-consume on GET requests |
|
|
60
|
+
|
|
61
|
+
Flash cookies are `httpOnly`, signed with HMAC-SHA256, and expire after `maxAgeSeconds` (default 120).
|
|
62
|
+
|
|
63
|
+
## App config helper
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
export const flashConfig = {
|
|
67
|
+
secret: process.env.FLASH_SECRET ?? "dev-only-change-me",
|
|
68
|
+
cookieName: "app_flash",
|
|
69
|
+
secure: () => process.env.NODE_ENV === "production",
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use a strong secret in production.
|
package/dist/flash.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import { DEFAULT_FLASH_COOKIE, type FlashConfig, type FlashMessage, type FlashType } from "./types.js";
|
|
3
|
+
export declare function clearFlash(c: Context, config?: Pick<FlashConfig, "cookieName" | "path">): void;
|
|
4
|
+
export declare function setFlash(c: Context, input: FlashMessage | string, config: FlashConfig): void;
|
|
5
|
+
export declare function consumeFlash(c: Context, config: FlashConfig): FlashMessage | undefined;
|
|
6
|
+
export declare function flashRedirect(location: string, input: FlashMessage | string, c: Context, config: FlashConfig, status?: 302 | 303): never;
|
|
7
|
+
export declare function createFlashType(type: FlashType): (message: string) => FlashMessage;
|
|
8
|
+
export declare const flashSuccess: (message: string) => FlashMessage;
|
|
9
|
+
export declare const flashError: (message: string) => FlashMessage;
|
|
10
|
+
export declare const flashWarning: (message: string) => FlashMessage;
|
|
11
|
+
export declare const flashInfo: (message: string) => FlashMessage;
|
|
12
|
+
export { DEFAULT_FLASH_COOKIE, type FlashConfig, type FlashMessage, type FlashType };
|
|
13
|
+
//# sourceMappingURL=flash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../src/flash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,OAAO,EACL,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,YAAY,EAEjB,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAoCpB,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAE,IAAI,CAAC,WAAW,EAAE,YAAY,GAAG,MAAM,CAAM,GAAG,IAAI,CAOlG;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAW5F;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,CAwBtF;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,YAAY,GAAG,MAAM,EAC5B,CAAC,EAAE,OAAO,EACV,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,GAAG,GAAG,GAAS,GACtB,KAAK,CAGP;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,IACrC,SAAS,MAAM,KAAG,YAAY,CACvC;AAED,eAAO,MAAM,YAAY,YAHN,MAAM,KAAG,YAG0B,CAAC;AACvD,eAAO,MAAM,UAAU,YAJJ,MAAM,KAAG,YAIsB,CAAC;AACnD,eAAO,MAAM,YAAY,YALN,MAAM,KAAG,YAK0B,CAAC;AACvD,eAAO,MAAM,SAAS,YANH,MAAM,KAAG,YAMoB,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,CAAC"}
|
package/dist/flash.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { getCookie, setCookie } from "hono/cookie";
|
|
2
|
+
import { redirect } from "@kamod-ch/otok/server";
|
|
3
|
+
import { seal, unseal } from "./sign.js";
|
|
4
|
+
import { DEFAULT_FLASH_COOKIE, } from "./types.js";
|
|
5
|
+
function resolveSecure(c, secure) {
|
|
6
|
+
if (typeof secure === "function")
|
|
7
|
+
return secure(c);
|
|
8
|
+
if (typeof secure === "boolean")
|
|
9
|
+
return secure;
|
|
10
|
+
return process.env.NODE_ENV === "production";
|
|
11
|
+
}
|
|
12
|
+
function resolveConfig(config) {
|
|
13
|
+
return {
|
|
14
|
+
secret: config.secret,
|
|
15
|
+
cookieName: config.cookieName ?? DEFAULT_FLASH_COOKIE,
|
|
16
|
+
maxAgeSeconds: config.maxAgeSeconds ?? 120,
|
|
17
|
+
sameSite: config.sameSite ?? "Lax",
|
|
18
|
+
path: config.path ?? "/",
|
|
19
|
+
secure: config.secure,
|
|
20
|
+
contextKey: config.contextKey ?? "flash",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function normalizeFlash(input) {
|
|
24
|
+
return typeof input === "string" ? { message: input, type: "info" } : input;
|
|
25
|
+
}
|
|
26
|
+
function writeFlashCookie(c, payload, config) {
|
|
27
|
+
const resolved = resolveConfig(config);
|
|
28
|
+
const token = seal(JSON.stringify(payload), resolved.secret);
|
|
29
|
+
setCookie(c, resolved.cookieName, token, {
|
|
30
|
+
httpOnly: true,
|
|
31
|
+
sameSite: resolved.sameSite,
|
|
32
|
+
path: resolved.path,
|
|
33
|
+
secure: resolveSecure(c, resolved.secure),
|
|
34
|
+
maxAge: resolved.maxAgeSeconds,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function clearFlash(c, config = {}) {
|
|
38
|
+
const cookieName = config.cookieName ?? DEFAULT_FLASH_COOKIE;
|
|
39
|
+
setCookie(c, cookieName, "", {
|
|
40
|
+
httpOnly: true,
|
|
41
|
+
path: config.path ?? "/",
|
|
42
|
+
maxAge: 0,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export function setFlash(c, input, config) {
|
|
46
|
+
const flash = normalizeFlash(input);
|
|
47
|
+
writeFlashCookie(c, {
|
|
48
|
+
message: flash.message,
|
|
49
|
+
type: flash.type ?? "info",
|
|
50
|
+
iat: Date.now(),
|
|
51
|
+
}, config);
|
|
52
|
+
}
|
|
53
|
+
export function consumeFlash(c, config) {
|
|
54
|
+
const resolved = resolveConfig(config);
|
|
55
|
+
const token = getCookie(c, resolved.cookieName);
|
|
56
|
+
clearFlash(c, { cookieName: resolved.cookieName, path: resolved.path });
|
|
57
|
+
if (!token)
|
|
58
|
+
return undefined;
|
|
59
|
+
const raw = unseal(token, resolved.secret);
|
|
60
|
+
if (!raw)
|
|
61
|
+
return undefined;
|
|
62
|
+
let payload;
|
|
63
|
+
try {
|
|
64
|
+
payload = JSON.parse(raw);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
if (!payload.message || typeof payload.message !== "string")
|
|
70
|
+
return undefined;
|
|
71
|
+
if (typeof payload.iat !== "number")
|
|
72
|
+
return undefined;
|
|
73
|
+
if (Date.now() - payload.iat > resolved.maxAgeSeconds * 1000)
|
|
74
|
+
return undefined;
|
|
75
|
+
return {
|
|
76
|
+
message: payload.message,
|
|
77
|
+
type: payload.type,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function flashRedirect(location, input, c, config, status = 303) {
|
|
81
|
+
setFlash(c, input, config);
|
|
82
|
+
redirect(location, status);
|
|
83
|
+
}
|
|
84
|
+
export function createFlashType(type) {
|
|
85
|
+
return (message) => ({ message, type });
|
|
86
|
+
}
|
|
87
|
+
export const flashSuccess = createFlashType("success");
|
|
88
|
+
export const flashError = createFlashType("error");
|
|
89
|
+
export const flashWarning = createFlashType("warning");
|
|
90
|
+
export const flashInfo = createFlashType("info");
|
|
91
|
+
export { DEFAULT_FLASH_COOKIE };
|
|
92
|
+
//# sourceMappingURL=flash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flash.js","sourceRoot":"","sources":["../src/flash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,oBAAoB,GAKrB,MAAM,YAAY,CAAC;AAEpB,SAAS,aAAa,CAAC,CAAU,EAAE,MAA4C;IAC7E,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,OAAO,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAC/C,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAC/C,CAAC;AAED,SAAS,aAAa,CAAC,MAAmB;IACxC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,oBAAoB;QACrD,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,GAAG;QAC1C,QAA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SAAS,CAAC;IAE/E,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,KAA4B,EAC5B,CAAU,EACV,MAAmB,EACnB,SAAoB,GAAG;IAEvB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAe;IAC7C,OAAO,CAAC,OAAe,EAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAuD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { clearFlash, consumeFlash, createFlashType, DEFAULT_FLASH_COOKIE, flashError, flashInfo, flashRedirect, flashSuccess, flashWarning, setFlash, type FlashConfig, type FlashMessage, type FlashType, } from "./flash.js";
|
|
2
|
+
export { createFlashMiddleware, readFlash, type FlashMiddlewareOptions } from "./middleware.js";
|
|
3
|
+
export { seal, unseal } from "./sign.js";
|
|
4
|
+
export { default } from "./plugin.js";
|
|
5
|
+
export type { FlashPluginOptions } from "./plugin.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { clearFlash, consumeFlash, createFlashType, DEFAULT_FLASH_COOKIE, flashError, flashInfo, flashRedirect, flashSuccess, flashWarning, setFlash, } from "./flash.js";
|
|
2
|
+
export { createFlashMiddleware, readFlash } from "./middleware.js";
|
|
3
|
+
export { seal, unseal } from "./sign.js";
|
|
4
|
+
export { default } from "./plugin.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,GAIT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAA+B,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import { type OtokMiddleware } from "@kamod-ch/otok/server";
|
|
3
|
+
import { consumeFlash } from "./flash.js";
|
|
4
|
+
import type { FlashConfig } from "./types.js";
|
|
5
|
+
export interface FlashMiddlewareOptions extends FlashConfig {
|
|
6
|
+
/** When false, leaves flash on the cookie for a later loader. Default: true. */
|
|
7
|
+
consume?: boolean;
|
|
8
|
+
onFlash?: (c: Context, flash: NonNullable<ReturnType<typeof consumeFlash>>) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createFlashMiddleware(options: FlashMiddlewareOptions): OtokMiddleware;
|
|
11
|
+
export declare function readFlash(c: Context, contextKey?: string): ReturnType<typeof consumeFlash> | undefined;
|
|
12
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,KAAK,IAAI,CAAC;CACrF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,cAAc,CAcrF;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,SAAU,GAC5B,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,SAAS,CACxE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineMiddleware } from "@kamod-ch/otok/server";
|
|
2
|
+
import { consumeFlash } from "./flash.js";
|
|
3
|
+
export function createFlashMiddleware(options) {
|
|
4
|
+
const consume = options.consume ?? true;
|
|
5
|
+
const contextKey = options.contextKey ?? "flash";
|
|
6
|
+
return defineMiddleware(async (c, next) => {
|
|
7
|
+
if (consume) {
|
|
8
|
+
const flash = consumeFlash(c, options);
|
|
9
|
+
if (flash) {
|
|
10
|
+
c.set(contextKey, flash);
|
|
11
|
+
options.onFlash?.(c, flash);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
await next();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function readFlash(c, contextKey = "flash") {
|
|
18
|
+
return c.get(contextKey);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS1C,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC;IACxC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC;IAEjD,OAAO,gBAAgB,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACxC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACvC,IAAI,KAAK,EAAE,CAAC;gBACV,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;gBACzB,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,CAAU,EAAE,UAAU,GAAG,OAAO;IACxD,OAAO,CAAC,CAAC,GAAG,CAAC,UAAU,CAAgD,CAAC;AAC1E,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FlashMiddlewareOptions } from "./middleware.js";
|
|
2
|
+
export type FlashPluginOptions = FlashMiddlewareOptions;
|
|
3
|
+
/**
|
|
4
|
+
* Otok flash plugin — mounts signed flash-cookie middleware on the Hono app.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import flash from "@kamod-ch/otok-flash";
|
|
8
|
+
*
|
|
9
|
+
* export default defineConfig({
|
|
10
|
+
* plugins: [flash({ secret: process.env.FLASH_SECRET! })],
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export default function flash(options: FlashPluginOptions): import("@kamod-ch/otok-config").OtokPlugin<unknown>;
|
|
15
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAErF,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAmBxD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAAO,EAAE,kBAAkB,uDAMxD"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { definePlugin } from "@kamod-ch/otok";
|
|
2
|
+
import { createFlashMiddleware } from "./middleware.js";
|
|
3
|
+
const flashPluginFactory = definePlugin({
|
|
4
|
+
name: "@kamod-ch/otok-flash",
|
|
5
|
+
version: "1.0.0",
|
|
6
|
+
schema: {
|
|
7
|
+
parse(input) {
|
|
8
|
+
if (!input || typeof input !== "object") {
|
|
9
|
+
throw new Error("flash() options must be an object");
|
|
10
|
+
}
|
|
11
|
+
const record = input;
|
|
12
|
+
if (typeof record.secret !== "string" || !record.secret) {
|
|
13
|
+
throw new Error("flash() requires secret: string");
|
|
14
|
+
}
|
|
15
|
+
return input;
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Otok flash plugin — mounts signed flash-cookie middleware on the Hono app.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* import flash from "@kamod-ch/otok-flash";
|
|
24
|
+
*
|
|
25
|
+
* export default defineConfig({
|
|
26
|
+
* plugins: [flash({ secret: process.env.FLASH_SECRET! })],
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export default function flash(options) {
|
|
31
|
+
const plugin = flashPluginFactory(options);
|
|
32
|
+
plugin.configureApp = ({ app }) => {
|
|
33
|
+
app.use("*", createFlashMiddleware(options));
|
|
34
|
+
};
|
|
35
|
+
return plugin;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAA+B,MAAM,iBAAiB,CAAC;AAIrF,MAAM,kBAAkB,GAAG,YAAY,CAAqB;IAC1D,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE;QACN,KAAK,CAAC,KAAK;YACT,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,MAAM,GAAG,KAAgC,CAAC;YAChD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACxD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACrD,CAAC;YACD,OAAO,KAA2B,CAAC;QACrC,CAAC;KACF;CACF,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAA2B;IACvD,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;QAChC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/sign.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function encodePayload(payload: string): string;
|
|
2
|
+
export declare function decodePayload(encoded: string): string | null;
|
|
3
|
+
export declare function signPayload(encodedPayload: string, secret: string): string;
|
|
4
|
+
export declare function seal(value: string, secret: string): string;
|
|
5
|
+
export declare function unseal(token: string, secret: string): string | null;
|
|
6
|
+
//# sourceMappingURL=sign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5D;AAED,wBAAgB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAcnE"}
|
package/dist/sign.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
export function encodePayload(payload) {
|
|
3
|
+
return Buffer.from(payload, "utf8").toString("base64url");
|
|
4
|
+
}
|
|
5
|
+
export function decodePayload(encoded) {
|
|
6
|
+
try {
|
|
7
|
+
return Buffer.from(encoded, "base64url").toString("utf8");
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function signPayload(encodedPayload, secret) {
|
|
14
|
+
return createHmac("sha256", secret).update(encodedPayload).digest("base64url");
|
|
15
|
+
}
|
|
16
|
+
export function seal(value, secret) {
|
|
17
|
+
const encoded = encodePayload(value);
|
|
18
|
+
return `${encoded}.${signPayload(encoded, secret)}`;
|
|
19
|
+
}
|
|
20
|
+
export function unseal(token, secret) {
|
|
21
|
+
const separator = token.lastIndexOf(".");
|
|
22
|
+
if (separator <= 0)
|
|
23
|
+
return null;
|
|
24
|
+
const encoded = token.slice(0, separator);
|
|
25
|
+
const signature = token.slice(separator + 1);
|
|
26
|
+
if (!encoded || !signature)
|
|
27
|
+
return null;
|
|
28
|
+
const expected = signPayload(encoded, secret);
|
|
29
|
+
const left = Buffer.from(signature);
|
|
30
|
+
const right = Buffer.from(expected);
|
|
31
|
+
if (left.length !== right.length || !timingSafeEqual(left, right))
|
|
32
|
+
return null;
|
|
33
|
+
return decodePayload(encoded);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=sign.js.map
|
package/dist/sign.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.js","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings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AC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE/E,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
export type FlashType = "info" | "success" | "error" | "warning";
|
|
3
|
+
export type FlashMessage = {
|
|
4
|
+
message: string;
|
|
5
|
+
type?: FlashType;
|
|
6
|
+
};
|
|
7
|
+
export interface FlashConfig {
|
|
8
|
+
secret: string;
|
|
9
|
+
cookieName?: string;
|
|
10
|
+
maxAgeSeconds?: number;
|
|
11
|
+
secure?: boolean | ((c: Context) => boolean);
|
|
12
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
13
|
+
path?: string;
|
|
14
|
+
contextKey?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface FlashPayload extends FlashMessage {
|
|
17
|
+
iat: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_FLASH_COOKIE = "otok_flash";
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,oBAAoB,eAAe,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kamod-ch/otok-flash",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Signed flash cookies for Otok PRG redirects and SSR toasts.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/kamod-ch/otok/tree/main/packages/otok-flash#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/kamod-ch/otok/issues"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/kamod-ch/otok.git",
|
|
13
|
+
"directory": "packages/otok-flash"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./middleware": {
|
|
26
|
+
"types": "./dist/middleware.d.ts",
|
|
27
|
+
"default": "./dist/middleware.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@kamod-ch/otok": ">=0.6.1",
|
|
32
|
+
"hono": ">=4"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^24.12.2",
|
|
36
|
+
"hono": "^4.12.25",
|
|
37
|
+
"preact": "^10.28.2",
|
|
38
|
+
"typescript": "~6.0.2",
|
|
39
|
+
"vitest": "^4.1.2",
|
|
40
|
+
"@kamod-ch/otok": "0.6.1",
|
|
41
|
+
"@kamod-ch/otok-test": "0.5.1"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
|
+
"test": "vitest run"
|
|
53
|
+
}
|
|
54
|
+
}
|