@voltro/plugin-auth 0.83.1 → 0.85.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.
@@ -5,66 +5,10 @@ property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/plugin-auth itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (7 packages).
8
+ Generated from the resolved runtime dependency closure (5 packages).
9
9
 
10
10
  ---
11
11
 
12
- ## @effect/experimental@0.61.1
13
-
14
- License: MIT
15
-
16
- ```
17
- MIT License
18
-
19
- Copyright (c) 2023-present The Contributors
20
-
21
- Permission is hereby granted, free of charge, to any person obtaining a copy
22
- of this software and associated documentation files (the "Software"), to deal
23
- in the Software without restriction, including without limitation the rights
24
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
- copies of the Software, and to permit persons to whom the Software is
26
- furnished to do so, subject to the following conditions:
27
-
28
- The above copyright notice and this permission notice shall be included in all
29
- copies or substantial portions of the Software.
30
-
31
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
- SOFTWARE.
38
- ```
39
-
40
- ## @effect/sql@0.52.1
41
-
42
- License: MIT
43
-
44
- ```
45
- MIT License
46
-
47
- Copyright (c) 2023-present The Contributors
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining a copy
50
- of this software and associated documentation files (the "Software"), to deal
51
- in the Software without restriction, including without limitation the rights
52
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
- copies of the Software, and to permit persons to whom the Software is
54
- furnished to do so, subject to the following conditions:
55
-
56
- The above copyright notice and this permission notice shall be included in all
57
- copies or substantial portions of the Software.
58
-
59
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65
- SOFTWARE.
66
- ```
67
-
68
12
  ## jose@6.2.12
69
13
 
70
14
  License: MIT
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { Effect } from 'effect';
5
5
  import { KeyedSecret } from '@voltro/protocol/session';
6
6
  import { MembershipsSource } from '@voltro/protocol';
7
7
  import { SessionSecrets } from '@voltro/protocol/session';
8
- import { SqlClient } from '@effect/sql/SqlClient';
8
+ import { SqlClient } from 'effect/sql/SqlClient';
9
9
  import { Subject } from '@voltro/protocol';
10
10
  import { SubjectIdentity } from '@voltro/protocol';
11
11
  import { VerifyOptions } from '@voltro/protocol/session';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PasswordEmptyError as e, PasswordHashError as t, hashPassword as n, needsRehash as r, parseScryptParams as i, verifyPassword as a, verifyPasswordWithRehash as o } from "./password.js";
2
2
  import { SESSION_COOKIE_NAME as ee, clearSessionCookie as te, issueSession as s, readSession as c, readSessionFromHeaders as ne, readSessionKeyed as re, resolveSessionSecret as ie, resolveSessionSecrets as ae, sessionSecretsOf as oe } from "./session.js";
3
3
  import { a as l, c as se, i as u, l as d, n as f, o as p, r as m, s as h, t as g } from "./strategy-XaGjSicX.js";
4
- import { $ as _, A as v, B as y, C as b, D as x, E as S, F as C, G as w, H as T, I as E, J as D, K as O, L as k, M as A, N as j, O as M, P as N, Q as P, R as F, S as I, T as L, U as R, V as z, W as B, X as V, Y as H, Z as U, _ as W, _t as G, a as K, at as ce, b as le, c as ue, ct as de, d as fe, dt as pe, et as me, f as he, ft as ge, g as _e, gt as ve, h as ye, ht as be, i as xe, it as Se, j as Ce, k as we, l as Te, lt as Ee, m as De, mt as Oe, n as ke, nt as Ae, o as je, ot as Me, p as Ne, pt as Pe, q as Fe, r as Ie, rt as Le, s as Re, st as ze, t as Be, tt as Ve, u as He, ut as Ue, v as We, vt as Ge, w as Ke, x as qe, y as Je, z as Ye } from "./plugin-CNW-X70p.js";
4
+ import { $ as _, A as v, B as y, C as b, D as x, E as S, F as C, G as w, H as T, I as E, J as D, K as O, L as k, M as A, N as j, O as M, P as N, Q as P, R as F, S as I, T as L, U as R, V as z, W as B, X as V, Y as H, Z as U, _ as W, _t as G, a as K, at as ce, b as le, c as ue, ct as de, d as fe, dt as pe, et as me, f as he, ft as ge, g as _e, gt as ve, h as ye, ht as be, i as xe, it as Se, j as Ce, k as we, l as Te, lt as Ee, m as De, mt as Oe, n as ke, nt as Ae, o as je, ot as Me, p as Ne, pt as Pe, q as Fe, r as Ie, rt as Le, s as Re, st as ze, t as Be, tt as Ve, u as He, ut as Ue, v as We, vt as Ge, w as Ke, x as qe, y as Je, z as Ye } from "./plugin-CbmcyEJs.js";
5
5
  import { EMAIL_VERIFY_TTL_S as Xe, MAGIC_LINK_TTL_S as Ze, MFA_PENDING_TTL_S as Qe, NATIVE_CODE_TTL_S as $e, PASSWORD_RESET_TTL_S as et, hashToken as tt, mintSecret as nt, mintToken as rt } from "./tokens.js";
6
6
  import { CSRF_COOKIE_NAME as it, CSRF_HEADER_NAME as at, isCsrfTokenWellFormed as ot, issueCsrfToken as st, verifyCsrf as q } from "./csrf.js";
7
7
  import { generateChallenge as ct, verifyAssertion as lt, verifyRegistration as ut } from "./webauthn.js";
package/dist/password.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { randomBytes as e, scrypt as t, timingSafeEqual as n } from "node:crypto";
2
2
  import { Data as r, Effect as i } from "effect";
3
3
  //#region src/password.ts
4
- var a = 32768, o = 8, s = 1, c = 32, l = 16, u = (e, t) => 128 * e * t * 2, d = 268435456, f = class extends r.TaggedError("PasswordEmptyError") {}, p = class extends r.TaggedError("PasswordHashError") {}, m = (e, n, r, a) => i.async((o) => {
4
+ var a = 32768, o = 8, s = 1, c = 32, l = 16, u = (e, t) => 128 * e * t * 2, d = 268435456, f = class extends r.TaggedError("PasswordEmptyError") {}, p = class extends r.TaggedError("PasswordHashError") {}, m = (e, n, r, a) => i.callback((o) => {
5
5
  t(e, n, r, {
6
6
  ...a,
7
7
  maxmem: u(a.N, a.r)
@@ -35,7 +35,7 @@ var a = 32768, o = 8, s = 1, c = 32, l = 16, u = (e, t) => 128 * e * t * 2, d =
35
35
  p: o
36
36
  });
37
37
  return l.length === c.length && n(l, c);
38
- }).pipe(i.catchAll(() => i.succeed(!1))), _ = (e) => {
38
+ }).pipe(i.catch(() => i.succeed(!1))), _ = (e) => {
39
39
  let t = e.split("$");
40
40
  if (t.length !== 6) return null;
41
41
  let [n, r, i, a, o, s] = t;
@@ -11,10 +11,13 @@ import { registerRetention as ce, retentionTtlMsFromEnv as le, writeTenantSelect
11
11
  import { IMPERSONATION_METADATA_KEY as k, definePlugin as de, rawImpersonationMark as fe, selectSubjectTenant as pe } from "@voltro/protocol";
12
12
  //#region src/postgresUserStore.ts
13
13
  var me = (e) => {
14
- let t = e?.code;
15
- if (typeof t == "string") return t;
16
- let n = e?.cause?.code;
17
- return typeof n == "string" ? n : void 0;
14
+ let t = e;
15
+ for (let e = 0; typeof t == "object" && t && e < 6; e++) {
16
+ let e = t.code;
17
+ if (typeof e == "string") return e;
18
+ let n = t;
19
+ t = n.reason ?? n.cause;
20
+ }
18
21
  }, he = (e) => {
19
22
  let t = e?.columns ?? {};
20
23
  return {
@@ -89,7 +92,7 @@ var me = (e) => {
89
92
  ...t,
90
93
  email: n,
91
94
  createdAt: a
92
- })), D.catchAll((e) => me(e) === "23505" ? D.fail(new p({ email: n })) : D.die(e)));
95
+ })), D.catch((e) => me(e) === "23505" ? D.fail(new p({ email: n })) : D.die(e)));
93
96
  }), _ = (t) => D.gen(function* () {
94
97
  let n = (yield* e`
95
98
  SELECT ${s().selectList} FROM ${s().usersTable} WHERE ${i("id")} = ${t} LIMIT 1
@@ -149,7 +152,7 @@ var me = (e) => {
149
152
  ...t,
150
153
  joinedAt: n
151
154
  });
152
- }).pipe(D.catchAll(() => D.succeed({
155
+ }).pipe(D.catch(() => D.succeed({
153
156
  ...t,
154
157
  joinedAt: /* @__PURE__ */ new Date()
155
158
  }))), S = (t, n) => D.gen(function* () {
@@ -176,7 +179,7 @@ var me = (e) => {
176
179
  createdAt: n,
177
180
  lastSeenAt: n
178
181
  };
179
- }).pipe(D.catchAll(() => D.succeed({
182
+ }).pipe(D.catch(() => D.succeed({
180
183
  ...t,
181
184
  createdAt: /* @__PURE__ */ new Date(),
182
185
  lastSeenAt: /* @__PURE__ */ new Date()
@@ -216,7 +219,7 @@ var me = (e) => {
216
219
  consumedAt: null,
217
220
  createdAt: n
218
221
  };
219
- }).pipe(D.catchAll(() => D.succeed({
222
+ }).pipe(D.catch(() => D.succeed({
220
223
  ...t,
221
224
  consumedAt: null,
222
225
  createdAt: /* @__PURE__ */ new Date()
@@ -260,7 +263,7 @@ var me = (e) => {
260
263
  revokedByUserId: null,
261
264
  createdAt: n
262
265
  };
263
- }).pipe(D.catchAll((e) => D.die(e))), le = (t) => D.gen(function* () {
266
+ }).pipe(D.catch((e) => D.die(e))), le = (t) => D.gen(function* () {
264
267
  let n = yield* e`
265
268
  SELECT id, "tokenHash", email, "tenantId", role, "invitedByUserId", "expiresAt",
266
269
  "acceptedAt", "acceptedByUserId", "revokedAt", "revokedByUserId", "createdAt"
@@ -279,7 +282,7 @@ var me = (e) => {
279
282
  "acceptedAt", "acceptedByUserId", "revokedAt", "revokedByUserId", "createdAt"
280
283
  `;
281
284
  return i[0] ? { ...i[0] } : null;
282
- }).pipe(D.catchAll((e) => D.die(e))), k = (t, n, r, i) => D.gen(function* () {
285
+ }).pipe(D.catch((e) => D.die(e))), k = (t, n, r, i) => D.gen(function* () {
283
286
  return (yield* e`
284
287
  UPDATE invitations
285
288
  SET "revokedAt" = ${i}, "revokedByUserId" = ${r}
@@ -289,7 +292,7 @@ var me = (e) => {
289
292
  AND "revokedAt" IS NULL
290
293
  RETURNING id
291
294
  `).length > 0;
292
- }).pipe(D.catchAll((e) => D.die(e))), de = (t) => D.gen(function* () {
295
+ }).pipe(D.catch((e) => D.die(e))), de = (t) => D.gen(function* () {
293
296
  return (yield* e`
294
297
  SELECT id, "tokenHash", email, "tenantId", role, "invitedByUserId", "expiresAt",
295
298
  "acceptedAt", "acceptedByUserId", "revokedAt", "revokedByUserId", "createdAt"
@@ -302,7 +305,7 @@ var me = (e) => {
302
305
  WHERE "tenantId" = ${t}
303
306
  AND "acceptedAt" IS NULL AND "revokedAt" IS NULL AND "expiresAt" > ${n}
304
307
  `)[0]?.n ?? 0;
305
- }).pipe(D.catchAll((e) => D.die(e))), pe = (t, n, r, i) => D.gen(function* () {
308
+ }).pipe(D.catch((e) => D.die(e))), pe = (t, n, r, i) => D.gen(function* () {
306
309
  return (yield* e`
307
310
  UPDATE invitations
308
311
  SET "revokedAt" = ${i}, "revokedByUserId" = ${r}
@@ -312,7 +315,7 @@ var me = (e) => {
312
315
  AND "revokedAt" IS NULL
313
316
  RETURNING id
314
317
  `).length;
315
- }).pipe(D.catchAll((e) => D.die(e))), ge = (t) => D.gen(function* () {
318
+ }).pipe(D.catch((e) => D.die(e))), ge = (t) => D.gen(function* () {
316
319
  let n = /* @__PURE__ */ new Date();
317
320
  return yield* e`
318
321
  INSERT INTO "impersonationGrants" (
@@ -329,7 +332,7 @@ var me = (e) => {
329
332
  endedAt: null,
330
333
  endedReason: null
331
334
  };
332
- }).pipe(D.catchAll((e) => D.die(e))), _e = (t) => D.gen(function* () {
335
+ }).pipe(D.catch((e) => D.die(e))), _e = (t) => D.gen(function* () {
333
336
  let n = yield* e`
334
337
  SELECT id, "sessionId", "actorUserId", "actorSessionId", "targetUserId", "tenantId",
335
338
  reason, "startedAt", "expiresAt", "endedAt", "endedReason", "ipAddress", "userAgent"
@@ -343,7 +346,7 @@ var me = (e) => {
343
346
  WHERE "sessionId" = ${t} AND "endedAt" IS NULL
344
347
  RETURNING id
345
348
  `).length > 0;
346
- }).pipe(D.catchAll((e) => D.die(e))), ye = (t) => D.gen(function* () {
349
+ }).pipe(D.catch((e) => D.die(e))), ye = (t) => D.gen(function* () {
347
350
  return (yield* e`
348
351
  SELECT id, "credentialId", "userId", "publicKey", counter, transports, "createdAt", "lastUsedAt"
349
352
  FROM passkeys WHERE "userId" = ${t}
@@ -367,7 +370,7 @@ var me = (e) => {
367
370
  createdAt: n,
368
371
  lastUsedAt: null
369
372
  };
370
- }).pipe(D.catchAll(() => D.succeed({
373
+ }).pipe(D.catch(() => D.succeed({
371
374
  ...t,
372
375
  createdAt: /* @__PURE__ */ new Date(),
373
376
  lastUsedAt: null
@@ -400,7 +403,7 @@ var me = (e) => {
400
403
  SELECT COUNT(*)::int AS n FROM "recoveryCodes"
401
404
  WHERE "userId" = ${t} AND "consumedAt" IS NULL
402
405
  `)[0]?.n ?? 0;
403
- }).pipe(D.orElseSucceed(() => 0)), M = (e, t) => D.catchAll((n) => D.logWarning(`[auth] lockout ${e} failed — brute-force protection is not counting`).pipe(D.annotateLogs("cause", String(n)), D.as(t)));
406
+ }).pipe(D.orElseSucceed(() => 0)), M = (e, t) => D.catch((n) => D.logWarning(`[auth] lockout ${e} failed — brute-force protection is not counting`).pipe(D.annotateLogs("cause", String(n)), D.as(t)));
404
407
  return {
405
408
  findByEmail: f,
406
409
  findById: m,
@@ -748,7 +751,7 @@ var me = (e) => {
748
751
  ok: !0,
749
752
  subject: l
750
753
  }, { setCookie: c });
751
- }).pipe(D.catchAll((e) => D.succeed(B(500, {
754
+ }).pipe(D.catch((e) => D.succeed(B(500, {
752
755
  error: "signup_failed",
753
756
  cause: String(e)
754
757
  })))), Qe = (e) => ({
@@ -763,7 +766,7 @@ var me = (e) => {
763
766
  let n = yield* t.findById(e.userId);
764
767
  if (!n) return B(404, { error: "user_not_found" });
765
768
  let r = ke();
766
- return yield* t.setMfaSecret(n.id, r).pipe(D.catchAll(() => D.succeed(n))), B(200, {
769
+ return yield* t.setMfaSecret(n.id, r).pipe(D.catch(() => D.succeed(n))), B(200, {
767
770
  ok: !0,
768
771
  secret: r,
769
772
  otpauthUrl: Ae({
@@ -778,7 +781,7 @@ var me = (e) => {
778
781
  if (!n.mfaSecret) return B(400, { error: "no_enrollment_in_progress" });
779
782
  if (n.mfaEnrolledAt) return B(409, { error: "already_enrolled" });
780
783
  if (!(yield* N(n.mfaSecret, e.code).pipe(D.map(() => !0), D.catchTag("TotpVerifyError", () => D.succeed(!1))))) return B(401, { error: "invalid_code" });
781
- yield* t.markMfaEnrolled(n.id).pipe(D.catchAll(() => D.succeed(n)));
784
+ yield* t.markMfaEnrolled(n.id).pipe(D.catch(() => D.succeed(n)));
782
785
  let r = Me();
783
786
  return yield* t.replaceRecoveryCodes(n.id, r.map((e) => v(e))).pipe(D.ignore), B(200, {
784
787
  ok: !0,
@@ -796,7 +799,7 @@ var me = (e) => {
796
799
  });
797
800
  }), nt = (e, t) => D.gen(function* () {
798
801
  let n = yield* t.findById(e.userId);
799
- return n ? (yield* t.clearMfa(n.id).pipe(D.catchAll(() => D.succeed(n))), yield* t.replaceRecoveryCodes(n.id, []).pipe(D.ignore), B(200, {
802
+ return n ? (yield* t.clearMfa(n.id).pipe(D.catch(() => D.succeed(n))), yield* t.replaceRecoveryCodes(n.id, []).pipe(D.ignore), B(200, {
800
803
  ok: !0,
801
804
  enrolled: !1
802
805
  })) : B(404, { error: "user_not_found" });
@@ -1296,7 +1299,7 @@ var me = (e) => {
1296
1299
  try: () => Promise.resolve(n),
1297
1300
  catch: (e) => e
1298
1301
  });
1299
- }).pipe(D.catchAllCause(() => D.void)), Gt = (e, t, n) => D.gen(function* () {
1302
+ }).pipe(D.catchCause(() => D.void)), Gt = (e, t, n) => D.gen(function* () {
1300
1303
  let r = n.impersonation, i = (n.now ?? Date.now)(), a = new Date(i), o = e.actorSubject, s = (t, n, i = {}) => Wt(r, {
1301
1304
  kind: "refused",
1302
1305
  at: a,
@@ -1335,7 +1338,7 @@ var me = (e) => {
1335
1338
  actor: o,
1336
1339
  actorUser: c,
1337
1340
  target: l
1338
- }).pipe(D.catchAllCause(() => D.succeed(!1))))) return yield* s(403, "not_permitted", {
1341
+ }).pipe(D.catchCause(() => D.succeed(!1))))) return yield* s(403, "not_permitted", {
1339
1342
  actorUser: c,
1340
1343
  target: l
1341
1344
  });
@@ -1343,7 +1346,7 @@ var me = (e) => {
1343
1346
  actor: g(l),
1344
1347
  actorUser: l,
1345
1348
  target: c
1346
- }).pipe(D.catchAllCause(() => D.succeed(!0)))) return yield* s(403, "target_may_impersonate", {
1349
+ }).pipe(D.catchCause(() => D.succeed(!0)))) return yield* s(403, "target_may_impersonate", {
1347
1350
  actorUser: c,
1348
1351
  target: l,
1349
1352
  message: "This user may themselves impersonate others and cannot be impersonated."
package/dist/plugin.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ConnectionCredential } from '@voltro/protocol';
3
3
  import { DataStore } from '@voltro/database';
4
4
  import { Effect } from 'effect';
5
5
  import { SessionSecrets } from '@voltro/protocol/session';
6
- import { SqlClient } from '@effect/sql/SqlClient';
6
+ import { SqlClient } from 'effect/sql/SqlClient';
7
7
  import { Subject } from '@voltro/protocol';
8
8
  import { VoidIfEmpty } from 'effect/Types';
9
9
  import { VoltroPlugin } from '@voltro/protocol';
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-CNW-X70p.js";
3
+ import { n as e, t } from "./plugin-CbmcyEJs.js";
4
4
  import "./csrf.js";
5
5
  export { t as authRoutesPlugin, e as getAuthSessionStrategy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-auth",
3
- "version": "0.83.1",
3
+ "version": "0.85.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",
@@ -83,12 +83,11 @@
83
83
  "node": ">=24.0.0"
84
84
  },
85
85
  "dependencies": {
86
- "@effect/sql": "^0.52.1",
87
- "@voltro/database": "0.83.1",
88
- "@voltro/protocol": "0.83.1"
86
+ "@voltro/database": "0.85.0",
87
+ "@voltro/protocol": "0.85.0"
89
88
  },
90
89
  "peerDependencies": {
91
- "effect": "^3.22.2",
90
+ "effect": "4.0.1",
92
91
  "react": "^19.0.0"
93
92
  },
94
93
  "peerDependenciesMeta": {