@smg-automotive/auth 8.4.0-lschuerch-expose-instance.1 → 8.4.1

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.
@@ -1,10 +1,17 @@
1
1
  'use strict';
2
2
 
3
+ var debug = require('debug');
3
4
  var server = require('@auth0/nextjs-auth0/server');
5
+ var redisSessionStore = require('./redisSessionStore.js');
4
6
  var onCallbackFactory = require('./hooks/onCallbackFactory.js');
5
7
  var beforeSessionSavedFactory = require('./hooks/beforeSessionSavedFactory.js');
6
8
  var auth0 = require('../config/auth0.js');
7
9
 
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
+
12
+ var debug__default = /*#__PURE__*/_interopDefaultCompat(debug);
13
+
14
+ const log = debug__default.default('@smg-automotive/auth:setup');
8
15
  const instances = {};
9
16
  const buildInstanceKey = ({ host, protocol }) => {
10
17
  return `${protocol}-${host}`;
@@ -13,25 +20,26 @@ const getAuth0Instance = ({ protocol, host, onError, }) => {
13
20
  const key = buildInstanceKey({ host, protocol });
14
21
  const instance = instances[key];
15
22
  if (instance) {
23
+ log('Auth0 instance found in cache', { key });
16
24
  return instance;
17
25
  }
26
+ log('Creating new Auth0 instance', { key });
18
27
  const auth0Config = auth0.getAuth0Config();
19
28
  const appBaseUrl = `${protocol}://${host}`;
20
- // let sessionStore;
21
- // if (process.env.AUTH0_CUSTOM_REDIS_URL && process.env.AUTH0_SESSION_NAME) {
22
- // // eslint-disable-next-line no-console
23
- // console.info('[Auth-package] Creating Redis Session Sore');
24
- // sessionStore = new RedisSessionStore({
25
- // prefix: `${process.env.AUTH0_SESSION_NAME}:`,
26
- // ttlSeconds: auth0Config.sessionDuration,
27
- // redisUrl: process.env.AUTH0_CUSTOM_REDIS_URL,
28
- // });
29
- // } else {
30
- // // eslint-disable-next-line no-console
31
- // console.info('[Auth-package] Using cookies to store session');
32
- // }
29
+ let sessionStore;
30
+ if (process.env.AUTH0_CUSTOM_REDIS_URL && process.env.AUTH0_SESSION_NAME) {
31
+ log('Creating Redis Session Store');
32
+ sessionStore = new redisSessionStore.RedisSessionStore({
33
+ prefix: `${process.env.AUTH0_SESSION_NAME}:`,
34
+ ttlSeconds: auth0Config.sessionDuration,
35
+ redisUrl: process.env.AUTH0_CUSTOM_REDIS_URL,
36
+ });
37
+ }
38
+ else {
39
+ log('Using cookies to store session');
40
+ }
33
41
  const newInstance = new server.Auth0Client({
34
- // sessionStore,
42
+ sessionStore,
35
43
  appBaseUrl,
36
44
  routes: {
37
45
  login: auth0Config.loginEndpoint,
@@ -1 +1 @@
1
- {"version":3,"file":"getAuth0Instance.js","sources":["../../../../src/server/getAuth0Instance.ts"],"sourcesContent":[null],"names":["getAuth0Config","Auth0Client","beforeSessionSavedFactory","onCallbackFactory"],"mappings":";;;;;;;AAQA,MAAM,SAAS,GAAmB,EAAE;AAOpC,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAA2B,KAAI;AACvE,IAAA,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,IAAI,EAAE;AAC9B,CAAC;AAEM,MAAM,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,OAAO,GAGR,KAAiB;IAChB,MAAM,GAAG,GAAG,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAChD,IAAA,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC;IAC/B,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAO,QAAQ;IACjB;AAEA,IAAA,MAAM,WAAW,GAAGA,oBAAc,EAAE;AACpC,IAAA,MAAM,UAAU,GAAG,CAAA,EAAG,QAAQ,CAAA,GAAA,EAAM,IAAI,EAAE;;;;;;;;;;;;;;AAe1C,IAAA,MAAM,WAAW,GAAG,IAAIC,kBAAW,CAAC;;QAElC,UAAU;AACV,QAAA,MAAM,EAAE;YACN,KAAK,EAAE,WAAW,CAAC,aAAa;YAChC,MAAM,EAAE,WAAW,CAAC,cAAc;YAClC,QAAQ,EAAE,WAAW,CAAC,gBAAgB;AACvC,SAAA;AACD,QAAA,OAAO,EAAE;AACP,YAAA,MAAM,EAAE;gBACN,IAAI,EAAE,WAAW,CAAC,iBAAiB;AACpC,aAAA;AACF,SAAA;AACD,QAAA,uBAAuB,EAAE;YACvB,KAAK,EAAE,WAAW,CAAC,MAAM;YACzB,QAAQ,EAAE,WAAW,CAAC,QAAQ;AAC/B,SAAA;AACD,QAAA,yBAAyB,EAAE,KAAK;AAChC,QAAA,kBAAkB,EAAEC,mDAAyB,CAAC,WAAW,CAAC;QAC1D,UAAU,EAAEC,mCAAiB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACnE,QAAA,cAAc,EAAE,IAAI;AACrB,KAAA,CAAC;AACF,IAAA,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW;AAC5B,IAAA,OAAO,WAAW;AACpB;;;;"}
1
+ {"version":3,"file":"getAuth0Instance.js","sources":["../../../../src/server/getAuth0Instance.ts"],"sourcesContent":[null],"names":["debug","getAuth0Config","RedisSessionStore","Auth0Client","beforeSessionSavedFactory","onCallbackFactory"],"mappings":";;;;;;;;;;;;;AAQA,MAAM,GAAG,GAAGA,sBAAK,CAAC,4BAA4B,CAAC;AAG/C,MAAM,SAAS,GAAmB,EAAE;AAOpC,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAA2B,KAAI;AACvE,IAAA,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,IAAI,EAAE;AAC9B,CAAC;AAEM,MAAM,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,OAAO,GAGR,KAAiB;IAChB,MAAM,GAAG,GAAG,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAChD,IAAA,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC;IA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,kBAAkB,EAAEC,mDAAyB,CAAC,WAAW,CAAC;QAC1D,UAAU,EAAEC,mCAAiB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACnE,QAAA,cAAc,EAAE,IAAI;AACrB,KAAA,CAAC;AACF,IAAA,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW;AAC5B,IAAA,OAAO,WAAW;AACpB;;;;"}
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var redis = require('redis');
4
+
5
+ class RedisSessionStore {
6
+ #client;
7
+ #options;
8
+ constructor(options) {
9
+ this.#options = options;
10
+ this.#client = redis.createClient({ url: options.redisUrl });
11
+ this.#client.connect();
12
+ }
13
+ key(id) {
14
+ return `${this.#options.prefix}${id}`;
15
+ }
16
+ async get(id) {
17
+ const raw = await this.#client.get(this.key(id));
18
+ return raw ? JSON.parse(raw) : null;
19
+ }
20
+ async set(id, session) {
21
+ await this.#client.set(this.key(id), JSON.stringify(session), {
22
+ EX: this.#options.ttlSeconds,
23
+ });
24
+ }
25
+ async delete(id) {
26
+ await this.#client.del(this.key(id));
27
+ }
28
+ }
29
+
30
+ exports.RedisSessionStore = RedisSessionStore;
31
+ //# sourceMappingURL=redisSessionStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redisSessionStore.js","sources":["../../../../src/server/redisSessionStore.ts"],"sourcesContent":[null],"names":["createClient"],"mappings":";;;;MASa,iBAAiB,CAAA;AAC5B,IAAA,OAAO;AACP,IAAA,QAAQ;AAER,IAAA,WAAA,CAAY,OAAiC,EAAA;AAC3C,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,QAAA,IAAI,CAAC,OAAO,GAAGA,kBAAY,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;AACtD,QAAA,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;IACxB;AAEQ,IAAA,GAAG,CAAC,EAAU,EAAA;QACpB,OAAO,CAAA,EAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAG,EAAE,CAAA,CAAE;IACvC;IAEA,MAAM,GAAG,CAAC,EAAU,EAAA;AAClB,QAAA,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAChD,QAAA,OAAO,GAAG,GAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiB,GAAG,IAAI;IACtD;AAEA,IAAA,MAAM,GAAG,CAAC,EAAU,EAAE,OAAoB,EAAA;AACxC,QAAA,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;AAC5D,YAAA,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU;AAC7B,SAAA,CAAC;IACJ;IAEA,MAAM,MAAM,CAAC,EAAU,EAAA;AACrB,QAAA,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACtC;AACD;;;;"}
@@ -1,3 +1,2 @@
1
1
  export * from './server/middleware';
2
2
  export * from './server/helpers';
3
- export { getAuth0Instance } from './server/getAuth0Instance';
@@ -5,7 +5,6 @@ var getAccessToken = require('./server/helpers/getAccessToken.js');
5
5
  var getAuthProps = require('./server/helpers/getAuthProps.js');
6
6
  var getUser = require('./server/helpers/getUser.js');
7
7
  var isLoggedIn = require('./server/helpers/isLoggedIn.js');
8
- var getAuth0Instance = require('./server/getAuth0Instance.js');
9
8
 
10
9
 
11
10
 
@@ -14,5 +13,4 @@ exports.getAccessToken = getAccessToken.getAccessToken;
14
13
  exports.getAuthProps = getAuthProps.getAuthProps;
15
14
  exports.getUser = getUser.getUser;
16
15
  exports.isLoggedIn = isLoggedIn.isLoggedIn;
17
- exports.getAuth0Instance = getAuth0Instance.getAuth0Instance;
18
16
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -1,8 +1,11 @@
1
+ import debug from 'debug';
1
2
  import { Auth0Client } from '@auth0/nextjs-auth0/server';
3
+ import { RedisSessionStore } from './redisSessionStore.js';
2
4
  import { onCallbackFactory } from './hooks/onCallbackFactory.js';
3
5
  import { beforeSessionSavedFactory } from './hooks/beforeSessionSavedFactory.js';
4
6
  import { getAuth0Config } from '../config/auth0.js';
5
7
 
8
+ const log = debug('@smg-automotive/auth:setup');
6
9
  const instances = {};
7
10
  const buildInstanceKey = ({ host, protocol }) => {
8
11
  return `${protocol}-${host}`;
@@ -11,25 +14,26 @@ const getAuth0Instance = ({ protocol, host, onError, }) => {
11
14
  const key = buildInstanceKey({ host, protocol });
12
15
  const instance = instances[key];
13
16
  if (instance) {
17
+ log('Auth0 instance found in cache', { key });
14
18
  return instance;
15
19
  }
20
+ log('Creating new Auth0 instance', { key });
16
21
  const auth0Config = getAuth0Config();
17
22
  const appBaseUrl = `${protocol}://${host}`;
18
- // let sessionStore;
19
- // if (process.env.AUTH0_CUSTOM_REDIS_URL && process.env.AUTH0_SESSION_NAME) {
20
- // // eslint-disable-next-line no-console
21
- // console.info('[Auth-package] Creating Redis Session Sore');
22
- // sessionStore = new RedisSessionStore({
23
- // prefix: `${process.env.AUTH0_SESSION_NAME}:`,
24
- // ttlSeconds: auth0Config.sessionDuration,
25
- // redisUrl: process.env.AUTH0_CUSTOM_REDIS_URL,
26
- // });
27
- // } else {
28
- // // eslint-disable-next-line no-console
29
- // console.info('[Auth-package] Using cookies to store session');
30
- // }
23
+ let sessionStore;
24
+ if (process.env.AUTH0_CUSTOM_REDIS_URL && process.env.AUTH0_SESSION_NAME) {
25
+ log('Creating Redis Session Store');
26
+ sessionStore = new RedisSessionStore({
27
+ prefix: `${process.env.AUTH0_SESSION_NAME}:`,
28
+ ttlSeconds: auth0Config.sessionDuration,
29
+ redisUrl: process.env.AUTH0_CUSTOM_REDIS_URL,
30
+ });
31
+ }
32
+ else {
33
+ log('Using cookies to store session');
34
+ }
31
35
  const newInstance = new Auth0Client({
32
- // sessionStore,
36
+ sessionStore,
33
37
  appBaseUrl,
34
38
  routes: {
35
39
  login: auth0Config.loginEndpoint,
@@ -1 +1 @@
1
- {"version":3,"file":"getAuth0Instance.js","sources":["../../../../src/server/getAuth0Instance.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAQA,MAAM,SAAS,GAAmB,EAAE;AAOpC,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAA2B,KAAI;AACvE,IAAA,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,IAAI,EAAE;AAC9B,CAAC;AAEM,MAAM,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,OAAO,GAGR,KAAiB;IAChB,MAAM,GAAG,GAAG,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAChD,IAAA,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC;IAC/B,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAO,QAAQ;IACjB;AAEA,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE;AACpC,IAAA,MAAM,UAAU,GAAG,CAAA,EAAG,QAAQ,CAAA,GAAA,EAAM,IAAI,EAAE;;;;;;;;;;;;;;AAe1C,IAAA,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC;;QAElC,UAAU;AACV,QAAA,MAAM,EAAE;YACN,KAAK,EAAE,WAAW,CAAC,aAAa;YAChC,MAAM,EAAE,WAAW,CAAC,cAAc;YAClC,QAAQ,EAAE,WAAW,CAAC,gBAAgB;AACvC,SAAA;AACD,QAAA,OAAO,EAAE;AACP,YAAA,MA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AAG,WAAW;AAC5B,IAAA,OAAO,WAAW;AACpB;;;;"}
@@ -0,0 +1,29 @@
1
+ import { createClient } from 'redis';
2
+
3
+ class RedisSessionStore {
4
+ #client;
5
+ #options;
6
+ constructor(options) {
7
+ this.#options = options;
8
+ this.#client = createClient({ url: options.redisUrl });
9
+ this.#client.connect();
10
+ }
11
+ key(id) {
12
+ return `${this.#options.prefix}${id}`;
13
+ }
14
+ async get(id) {
15
+ const raw = await this.#client.get(this.key(id));
16
+ return raw ? JSON.parse(raw) : null;
17
+ }
18
+ async set(id, session) {
19
+ await this.#client.set(this.key(id), JSON.stringify(session), {
20
+ EX: this.#options.ttlSeconds,
21
+ });
22
+ }
23
+ async delete(id) {
24
+ await this.#client.del(this.key(id));
25
+ }
26
+ }
27
+
28
+ export { RedisSessionStore };
29
+ //# sourceMappingURL=redisSessionStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redisSessionStore.js","sources":["../../../../src/server/redisSessionStore.ts"],"sourcesContent":[null],"names":[],"mappings":";;MASa,iBAAiB,CAAA;AAC5B,IAAA,OAAO;AACP,IAAA,QAAQ;AAER,IAAA,WAAA,CAAY,OAAiC,EAAA;AAC3C,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,QAAA,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;AACtD,QAAA,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;IACxB;AAEQ,IAAA,GAAG,CAAC,EAAU,EAAA;QACpB,OAAO,CAAA,EAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAG,EAAE,CAAA,CAAE;IACvC;IAEA,MAAM,GAAG,CAAC,EAAU,EAAA;AAClB,QAAA,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAChD,QAAA,OAAO,GAAG,GAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiB,GAAG,IAAI;IACtD;AAEA,IAAA,MAAM,GAAG,CAAC,EAAU,EAAE,OAAoB,EAAA;AACxC,QAAA,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;AAC5D,YAAA,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU;AAC7B,SAAA,CAAC;IACJ;IAEA,MAAM,MAAM,CAAC,EAAU,EAAA;AACrB,QAAA,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACtC;AACD;;;;"}
@@ -1,3 +1,2 @@
1
1
  export * from './server/middleware';
2
2
  export * from './server/helpers';
3
- export { getAuth0Instance } from './server/getAuth0Instance';
@@ -3,5 +3,4 @@ export { getAccessToken } from './server/helpers/getAccessToken.js';
3
3
  export { getAuthProps } from './server/helpers/getAuthProps.js';
4
4
  export { getUser } from './server/helpers/getUser.js';
5
5
  export { isLoggedIn } from './server/helpers/isLoggedIn.js';
6
- export { getAuth0Instance } from './server/getAuth0Instance.js';
7
6
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
package/dist/server.d.ts CHANGED
@@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from 'next/server';
2
2
  import { Language } from '@smg-automotive/i18n-pkg';
3
3
  import { NextApiRequest, NextApiResponse } from 'next';
4
4
  import { IncomingMessage, ServerResponse } from 'http';
5
- import { Auth0Client } from '@auth0/nextjs-auth0/server';
6
5
  import { a as AuthProviderProps } from './Auth-C40nODjM.js';
7
6
  import { S as SessionUser } from './sessionUser-wavMinWI.js';
8
7
  import 'react';
@@ -33,9 +32,6 @@ type GetAuth0InstanceContext = {
33
32
  protocol: string;
34
33
  host: string;
35
34
  };
36
- declare const getAuth0Instance: ({ protocol, host, onError, }: GetAuth0InstanceContext & {
37
- onError?: (error: Error) => void;
38
- }) => Auth0Client;
39
35
 
40
36
  declare const getAccessToken: ({ protocol, host, context, }: GetAuth0InstanceContext & ServerRequestContext) => Promise<string>;
41
37
 
@@ -51,4 +47,4 @@ declare const getUser: ({ context, host, protocol, }: GetAuth0InstanceContext &
51
47
 
52
48
  declare const isLoggedIn: (context: GetAuth0InstanceContext & ServerRequestContext) => Promise<boolean>;
53
49
 
54
- export { authMiddleware, getAccessToken, getAuth0Instance, getAuthProps, getUser, isLoggedIn };
50
+ export { authMiddleware, getAccessToken, getAuthProps, getUser, isLoggedIn };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smg-automotive/auth",
3
- "version": "8.4.0-lschuerch-expose-instance.1",
3
+ "version": "8.4.1",
4
4
  "description": "SMG Automotive auth package",
5
5
  "exports": {
6
6
  ".": {
@@ -75,8 +75,8 @@
75
75
  "jest-environment-jsdom": "30.2.0",
76
76
  "jest-fetch-mock": "3.0.3",
77
77
  "next": "15.5.7",
78
- "react": "19.2.0",
79
- "react-dom": "19.2.0",
78
+ "react": "19.2.1",
79
+ "react-dom": "19.2.1",
80
80
  "rimraf": "6.1.2",
81
81
  "rollup": "4.53.3",
82
82
  "rollup-plugin-dts": "6.2.3",
@@ -90,7 +90,7 @@
90
90
  "whatwg-fetch": "3.6.20"
91
91
  },
92
92
  "dependencies": {
93
- "@auth0/nextjs-auth0": "4.13.1",
93
+ "@auth0/nextjs-auth0": "4.13.2",
94
94
  "@smg-automotive/api-client-pkg": "4.5.0",
95
95
  "@smg-automotive/i18n-pkg": "2.0.0",
96
96
  "debug": "4.4.3",
@@ -98,9 +98,9 @@
98
98
  "redis": "5.9.0"
99
99
  },
100
100
  "peerDependencies": {
101
- "next": "^15.0.0",
102
- "react": "^19.0.0",
103
- "react-dom": "^19.0.0",
101
+ "next": "^15.5.7 || ^16.0.7",
102
+ "react": "^19.2.1",
103
+ "react-dom": "^19.2.1",
104
104
  "swr": "^2.0.0"
105
105
  }
106
106
  }