@voltro/plugin-auth 0.37.0 → 0.39.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/plugin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./password.js";
2
2
  import "./session.js";
3
- import { n as e, t } from "./plugin-BZm5Semm.js";
3
+ import { n as e, t } from "./plugin-CPcpSSf9.js";
4
4
  import "./csrf.js";
5
5
  export { t as authRoutesPlugin, e as getAuthSessionStrategy };
package/dist/session.js CHANGED
@@ -1,6 +1,6 @@
1
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 = i, f = a, p = (e) => typeof e == "string" ? e : e.current, m = (t) => {
3
+ var l = "voltro:session", u = 604800, d = i, f = a, p = (e) => typeof e == "string" ? e : e.current, m = (t) => {
4
4
  if (typeof t != "string") return t;
5
5
  let n = r(), i = {
6
6
  kid: n && s(n.current.secret, t) ? n.current.kid : e,
@@ -143,7 +143,7 @@ var s = 3e4, c = 1e4, l = (e, t = {}) => {
143
143
  }),
144
144
  latestToken: (e, t) => n.sync(() => {
145
145
  let n = null;
146
- for (let r of o) r.userId !== e || r.purpose !== t || (n === null || r.createdAt.getTime() > n.createdAt.getTime()) && (n = r);
146
+ for (let r of o) r.userId === e && r.purpose === t && (n === null || r.createdAt.getTime() > n.createdAt.getTime()) && (n = r);
147
147
  return n;
148
148
  }),
149
149
  insertInvitation: (e) => n.sync(() => {
@@ -294,26 +294,26 @@ var s = 3e4, c = 1e4, l = (e, t = {}) => {
294
294
  resolve: (c) => {
295
295
  let l = r(c.headers.cookie, o);
296
296
  if (!l) return { kind: "skip" };
297
- let u = a(l, e(t.secret ?? i()));
298
- if (!u) return {
297
+ let u = e(t.secret ?? i()), d = a(l, u);
298
+ if (!d) return {
299
299
  kind: "failed",
300
300
  reason: "voltro session cookie failed verification"
301
301
  };
302
- let d = b(u.subject, "voltro-password");
302
+ let f = b(d.subject, "voltro-password");
303
303
  if (!s) return {
304
304
  kind: "matched",
305
- subject: d
305
+ subject: f
306
306
  };
307
- let f = h(d);
308
- return f ? n.runPromise(s.isLive(f)).then((e) => e ? {
307
+ let p = h(f);
308
+ return p ? n.runPromise(s.isLive(p)).then((e) => e ? {
309
309
  kind: "matched",
310
- subject: d
310
+ subject: f
311
311
  } : {
312
312
  kind: "failed",
313
313
  reason: "voltro session revoked"
314
314
  }) : {
315
315
  kind: "matched",
316
- subject: d
316
+ subject: f
317
317
  };
318
318
  }
319
319
  };
package/dist/strategy.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./session.js";
2
- import { t as e } from "./strategy-Bty6_XUj.js";
2
+ import { t as e } from "./strategy-MP_KxNuA.js";
3
3
  export { e as voltroPasswordStrategy };
package/dist/tokens.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createHash as e, randomBytes as t } from "node:crypto";
2
2
  //#region src/tokens.ts
3
- var n = 900, r = 3600, i = 1440 * 60, a = 300, o = {
3
+ var n = 900, r = 3600, i = 86400, a = 300, o = {
4
4
  "magic-link": 900,
5
5
  "password-reset": r,
6
6
  "mfa-pending": 300,
package/dist/web.js CHANGED
@@ -52,7 +52,7 @@ var i = e(null), a = ({ subject: e, children: t }) => /* @__PURE__ */ r(i.Provid
52
52
  userVerification: "preferred",
53
53
  residentKey: "preferred"
54
54
  },
55
- timeout: 300 * 1e3
55
+ timeout: 3e5
56
56
  } });
57
57
  if (!c) throw Error("credential creation was cancelled");
58
58
  let p = c.response, m = typeof p.getAuthenticatorData == "function" ? p.getAuthenticatorData() : /* @__PURE__ */ new ArrayBuffer(0), h = await f(`${n}/passkey/register/verify`, {
@@ -73,7 +73,7 @@ var i = e(null), a = ({ subject: e, children: t }) => /* @__PURE__ */ r(i.Provid
73
73
  id: u(e.id)
74
74
  })),
75
75
  userVerification: "preferred",
76
- timeout: 300 * 1e3
76
+ timeout: 3e5
77
77
  } });
78
78
  if (!s) throw Error("assertion was cancelled");
79
79
  let c = s.response, p = await f(`${n}/passkey/assert/verify`, {
package/dist/webauthn.js CHANGED
@@ -287,7 +287,7 @@ var o = (e) => {
287
287
  error: "unsupported-key"
288
288
  };
289
289
  let a = Buffer.concat([n, c(o(e.clientDataJSON))]), s = o(e.signature);
290
- return T(i.key, i.alg, a, s) ? !(r.signCount === 0 && e.storedCounter === 0) && r.signCount <= e.storedCounter ? {
290
+ return T(i.key, i.alg, a, s) ? (r.signCount !== 0 || e.storedCounter !== 0) && r.signCount <= e.storedCounter ? {
291
291
  ok: !1,
292
292
  error: "counter-replay"
293
293
  } : {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-auth",
3
- "version": "0.37.0",
3
+ "version": "0.39.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",
@@ -79,8 +79,8 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@effect/sql": "^0.52.0",
82
- "@voltro/database": "0.37.0",
83
- "@voltro/protocol": "0.37.0"
82
+ "@voltro/database": "0.39.0",
83
+ "@voltro/protocol": "0.39.0"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "effect": "^3.22.0",