@nxgt/janus 0.24.0 → 0.25.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.
Files changed (41) hide show
  1. package/README.md +24 -10
  2. package/dist/auth/outage.d.ts +2 -2
  3. package/dist/auth/port/assert-stores.d.ts.map +1 -1
  4. package/dist/auth/port/memory/tokens.d.ts.map +1 -1
  5. package/dist/auth/port/types/stores.d.ts +2 -0
  6. package/dist/auth/port/types/stores.d.ts.map +1 -1
  7. package/dist/auth/port/types/tokens.d.ts +12 -0
  8. package/dist/auth/port/types/tokens.d.ts.map +1 -1
  9. package/dist/auth/sessions/collect-expired.d.ts +14 -0
  10. package/dist/auth/sessions/collect-expired.d.ts.map +1 -0
  11. package/dist/auth/sessions/shared-api.d.ts +1 -1
  12. package/dist/auth/sessions/shared-api.d.ts.map +1 -1
  13. package/dist/auth/types/janus.d.ts +4 -3
  14. package/dist/auth/types/janus.d.ts.map +1 -1
  15. package/dist/chunks/{index-6bjfv4xv.js → index-q3w3vr69.js} +13 -3
  16. package/dist/chunks/{index-6bjfv4xv.js.map → index-q3w3vr69.js.map} +3 -3
  17. package/dist/chunks/{index-cntabs9d.js → index-rpp0bw6e.js} +2 -2
  18. package/dist/chunks/{index-kppkcbn5.js → index-spwh8b9z.js} +2 -5
  19. package/dist/chunks/{index-kppkcbn5.js.map → index-spwh8b9z.js.map} +2 -2
  20. package/dist/chunks/{index-4khsm7mw.js → index-y9b327j8.js} +18 -18
  21. package/dist/chunks/{index-4khsm7mw.js.map → index-y9b327j8.js.map} +5 -5
  22. package/dist/conformance/cases/outage.d.ts.map +1 -1
  23. package/dist/conformance/cases/tokens/deletion.d.ts.map +1 -1
  24. package/dist/conformance/describe.d.ts +1 -0
  25. package/dist/conformance/describe.d.ts.map +1 -1
  26. package/dist/conformance/index.js +39 -5
  27. package/dist/conformance/index.js.map +5 -5
  28. package/dist/conformance/types.d.ts +1 -1
  29. package/dist/conformance/types.d.ts.map +1 -1
  30. package/dist/index.js +19 -9
  31. package/dist/index.js.map +7 -6
  32. package/dist/permissions/index.js +3 -3
  33. package/docs/guide/adapters.md +40 -3
  34. package/docs/guide/email-flows.md +2 -2
  35. package/docs/guide/errors.md +1 -1
  36. package/docs/guide/passwords.md +7 -10
  37. package/docs/guide/sessions.md +15 -4
  38. package/docs/roadmap.md +8 -8
  39. package/docs/troubleshooting.md +6 -6
  40. package/package.json +1 -1
  41. /package/dist/chunks/{index-cntabs9d.js.map → index-rpp0bw6e.js.map} +0 -0
package/dist/index.js CHANGED
@@ -7,13 +7,13 @@ import {
7
7
  MAX_PAGE_SIZE2,
8
8
  pageLimit2,
9
9
  invalidCursor2
10
- } from "./chunks/index-4khsm7mw.js";
10
+ } from "./chunks/index-y9b327j8.js";
11
11
  import {
12
12
  mintId2,
13
13
  isId2,
14
14
  mintedAt2,
15
15
  createMemoryStores2
16
- } from "./chunks/index-6bjfv4xv.js";
16
+ } from "./chunks/index-q3w3vr69.js";
17
17
  import {
18
18
  JanusError2,
19
19
  UserInvalidError2,
@@ -39,7 +39,7 @@ import {
39
39
  formatTuple2,
40
40
  parseTuple2,
41
41
  parseSubject2
42
- } from "./chunks/index-kppkcbn5.js";
42
+ } from "./chunks/index-spwh8b9z.js";
43
43
 
44
44
  // src/auth/hashers.ts
45
45
  import { randomBytes, scrypt, timingSafeEqual } from "node:crypto";
@@ -794,6 +794,7 @@ function assertStores(stores, where) {
794
794
  const slots = stores;
795
795
  return {
796
796
  collectExpired: optional(slots, "sessions", "deleteExpiredSessions", where),
797
+ collectExpiredTokens: optional(slots, "tokens", "deleteExpiredTokens", where),
797
798
  findUsers: optional(slots, "users", "findUsers", where)
798
799
  };
799
800
  }
@@ -1023,6 +1024,19 @@ function renewalDue(type, session, now) {
1023
1024
  return type.renewAfterMs !== null && type.lifespanMs - (session.expiresAt.getTime() - now) >= type.renewAfterMs;
1024
1025
  }
1025
1026
 
1027
+ // src/auth/sessions/collect-expired.ts
1028
+ async function collectExpired(context) {
1029
+ const { store, clock, capabilities } = context;
1030
+ const sessions = capabilities.collectExpired ? store.sessions.deleteExpiredSessions : undefined;
1031
+ const tokens = capabilities.collectExpiredTokens ? store.tokens.deleteExpiredTokens : undefined;
1032
+ if (sessions === undefined && tokens === undefined) {
1033
+ throw new UnsupportedError2("collectExpired: store.sessions does not implement deleteExpiredSessions, nor store.tokens deleteExpiredTokens — their stores expire records on their own, or implement the methods", { slot: "sessions", operation: "deleteExpiredSessions" });
1034
+ }
1035
+ const before = clock.now();
1036
+ const collected = sessions === undefined ? 0 : await sessions(before);
1037
+ return collected + (tokens === undefined ? 0 : await tokens(before));
1038
+ }
1039
+
1026
1040
  // src/auth/sessions/cookie.ts
1027
1041
  function cookieOf(context) {
1028
1042
  const { name, domain, path, sameSite, secure } = context.config.cookie;
@@ -1071,11 +1085,7 @@ function sharedApi(context) {
1071
1085
  },
1072
1086
  cookie: cookieOf(context),
1073
1087
  async collectExpired() {
1074
- const collect = store.sessions.deleteExpiredSessions;
1075
- if (!context.capabilities.collectExpired || collect === undefined) {
1076
- throw new UnsupportedError2("collectExpired: store.sessions does not implement deleteExpiredSessions — its store expires sessions on its own, or implement the method", { slot: "sessions", operation: "deleteExpiredSessions" });
1077
- }
1078
- return collect(clock.now());
1088
+ return collectExpired(context);
1079
1089
  },
1080
1090
  types: [...config.types.keys()]
1081
1091
  };
@@ -2864,5 +2874,5 @@ export {
2864
2874
  systemClock
2865
2875
  };
2866
2876
 
2867
- //# debugId=DBC7C1267CB6B80364756E2164756E21
2877
+ //# debugId=D10ED7160A09120864756E2164756E21
2868
2878
  //# sourceMappingURL=index.js.map