@voltro/plugin-auth 0.5.0 → 0.6.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/CHANGELOG.md +48 -1
- package/dist/index.d.ts +14 -4
- package/dist/index.js +14 -14
- package/dist/plugin-DOBoUVJ-.js +801 -0
- package/dist/plugin.d.ts +14 -2
- package/dist/plugin.js +1 -1
- package/dist/session.d.ts +0 -2
- package/dist/session.js +15 -15
- package/package.json +3 -3
- package/dist/plugin-CRt-kdEA.js +0 -801
package/dist/plugin.d.ts
CHANGED
|
@@ -7,9 +7,21 @@ import { VoltroPlugin } from '@voltro/protocol';
|
|
|
7
7
|
import { YieldableError } from 'effect/Cause';
|
|
8
8
|
|
|
9
9
|
declare interface AuthConfig {
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The session-signing key. OMIT IT and the value is read from
|
|
12
|
+
* `VOLTRO_SESSION_SECRET` when a request is actually handled.
|
|
13
|
+
*
|
|
14
|
+
* Omitting is the better default: `app.config.ts` is evaluated before the
|
|
15
|
+
* environment gate runs (and before `voltro dev` mints a project-local
|
|
16
|
+
* secret), so reading `process.env` here to pass a value is precisely what
|
|
17
|
+
* pushes apps into shipping a hardcoded fallback. Deferring the read means
|
|
18
|
+
* there is nothing to fall back TO.
|
|
19
|
+
*
|
|
20
|
+
* Pass one explicitly only when the key does not come from the environment.
|
|
21
|
+
*/
|
|
22
|
+
readonly secret?: string;
|
|
11
23
|
/** Explicit keyed secret set for zero-downtime rotation. When absent,
|
|
12
|
-
* the set is derived from `secret` (
|
|
24
|
+
* the set is derived from `secret` (or `VOLTRO_SESSION_SECRET`) plus the
|
|
13
25
|
* `VOLTRO_SESSION_SECRET_PREVIOUS` / `VOLTRO_SESSION_KID*` env vars —
|
|
14
26
|
* so env-var rotation works without setting this. Cookies are always
|
|
15
27
|
* SIGNED with the current key; verification also accepts `previous`. */
|
package/dist/plugin.js
CHANGED
package/dist/session.d.ts
CHANGED
package/dist/session.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { DEFAULT_SESSION_KID as e,
|
|
1
|
+
import { DEFAULT_SESSION_KID as e, buildSetCookie as t, readCookie as n, resolveOptionalSessionSecrets as r, resolveSessionSecret as i, resolveSessionSecrets as a, signSession as o, timingSafeStringEqual as s, verifySessionKeyed as c } from "@voltro/protocol/session";
|
|
2
2
|
//#region src/session.ts
|
|
3
|
-
var l = "voltro:session", u = 3600 * 24 * 7, d =
|
|
3
|
+
var l = "voltro:session", u = 3600 * 24 * 7, d = i, f = a, p = (e) => typeof e == "string" ? e : e.current, m = (t) => {
|
|
4
4
|
if (typeof t != "string") return t;
|
|
5
|
-
let n =
|
|
6
|
-
kid: s(n.current.secret, t) ? n.current.kid : e,
|
|
5
|
+
let n = r(), i = {
|
|
6
|
+
kid: n && s(n.current.secret, t) ? n.current.kid : e,
|
|
7
7
|
secret: t
|
|
8
8
|
};
|
|
9
|
-
return n
|
|
10
|
-
current:
|
|
9
|
+
return n?.previous ? {
|
|
10
|
+
current: i,
|
|
11
11
|
previous: n.previous
|
|
12
|
-
} : { current:
|
|
13
|
-
},
|
|
14
|
-
let i = r.ttlSeconds ?? u, a = o(e,
|
|
12
|
+
} : { current: i };
|
|
13
|
+
}, h = (e, n, r = {}) => {
|
|
14
|
+
let i = r.ttlSeconds ?? u, a = o(e, p(n), { ttlSeconds: i });
|
|
15
15
|
return {
|
|
16
16
|
value: a,
|
|
17
|
-
setCookie:
|
|
17
|
+
setCookie: t(l, a, {
|
|
18
18
|
maxAgeSeconds: i,
|
|
19
19
|
httpOnly: !0,
|
|
20
20
|
sameSite: "lax",
|
|
@@ -23,10 +23,10 @@ var l = "voltro:session", u = 3600 * 24 * 7, d = t, f = i, p = a, m = (e) => typ
|
|
|
23
23
|
path: "/"
|
|
24
24
|
})
|
|
25
25
|
};
|
|
26
|
-
},
|
|
27
|
-
let i =
|
|
28
|
-
return i ? c(i,
|
|
29
|
-
},
|
|
26
|
+
}, g = (e, t) => _(e, t)?.subject ?? null, _ = (e, t, r = {}) => {
|
|
27
|
+
let i = n(e, l);
|
|
28
|
+
return i ? c(i, m(t), r) : null;
|
|
29
|
+
}, v = (e = {}) => t(l, "", {
|
|
30
30
|
maxAgeSeconds: 0,
|
|
31
31
|
httpOnly: !0,
|
|
32
32
|
sameSite: "lax",
|
|
@@ -35,4 +35,4 @@ var l = "voltro:session", u = 3600 * 24 * 7, d = t, f = i, p = a, m = (e) => typ
|
|
|
35
35
|
path: "/"
|
|
36
36
|
});
|
|
37
37
|
//#endregion
|
|
38
|
-
export { l as SESSION_COOKIE_NAME,
|
|
38
|
+
export { l as SESSION_COOKIE_NAME, v as clearSessionCookie, h as issueSession, g as readSession, _ as readSessionKeyed, d as resolveSessionSecret, f as resolveSessionSecrets, m as sessionSecretsOf };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Authentication primitives: password hashing, session creation, schema mixin + tables. Pairs with the `auth` app template for the UI; both independently usable. Server-side only (uses node:crypto).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@effect/sql": "^0.51.1",
|
|
81
|
-
"@voltro/database": "0.
|
|
82
|
-
"@voltro/protocol": "0.
|
|
81
|
+
"@voltro/database": "0.6.0",
|
|
82
|
+
"@voltro/protocol": "0.6.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"effect": "^3.21.4",
|