iron-session 6.1.0 → 6.1.3
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/README.md +6 -5
- package/next/dist/index.js +10 -4
- package/next/dist/index.js.map +2 -2
- package/next/dist/index.mjs +10 -4
- package/next/dist/index.mjs.map +2 -2
- package/next/index.js +10 -4
- package/next/index.js.map +2 -2
- package/next/index.mjs +10 -4
- package/next/index.mjs.map +2 -2
- package/next/index.test.ts +49 -5
- package/next/index.ts +19 -4
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -32,8 +32,8 @@ _Table of contents:_
|
|
|
32
32
|
- [Firebase usage](#firebase-usage)
|
|
33
33
|
- [API](#api)
|
|
34
34
|
- [ironOptions](#ironoptions)
|
|
35
|
-
- [Next.js: withIronSessionApiRoute(handler, ironOptions)](#nextjs-withironsessionapiroutehandler-ironoptions)
|
|
36
|
-
- [Next.js: withIronSessionSsr(handler, ironOptions)](#nextjs-
|
|
35
|
+
- [Next.js: withIronSessionApiRoute(handler, ironOptions)](#nextjs-withironsessionapiroutehandler-ironoptions--req-nextapirequest-res-nextapiresponse--ironoptions--promiseironoptions)
|
|
36
|
+
- [Next.js: withIronSessionSsr(handler, ironOptions)](#nextjs-withironsessionapiroutehandler-ironoptions--req-nextapirequest-res-nextapiresponse--ironoptions--promiseironoptions)
|
|
37
37
|
- [Express: ironSession(ironOptions)](#express-ironsessionironoptions)
|
|
38
38
|
- [session.save()](#sessionsave)
|
|
39
39
|
- [session.destroy()](#sessiondestroy)
|
|
@@ -302,7 +302,7 @@ async function loginRoute(req, res) {
|
|
|
302
302
|
|
|
303
303
|
import { withSessionSsr } from "lib/withSession";
|
|
304
304
|
|
|
305
|
-
export const getServerSideProps =
|
|
305
|
+
export const getServerSideProps = withSessionSsr(
|
|
306
306
|
async function getServerSideProps({ req }) {
|
|
307
307
|
const user = req.session.user;
|
|
308
308
|
|
|
@@ -586,7 +586,7 @@ Only two options are required: `password` and `cookieName`. Everything else is a
|
|
|
586
586
|
}
|
|
587
587
|
```
|
|
588
588
|
|
|
589
|
-
### Next.js: withIronSessionApiRoute(handler, ironOptions | (req: NextApiRequest, res: NextApiResponse) =>
|
|
589
|
+
### Next.js: withIronSessionApiRoute(handler, ironOptions | (req: NextApiRequest, res: NextApiResponse) => IronOptions | Promise\<IronOptions\>)
|
|
590
590
|
|
|
591
591
|
Wraps a [Next.js API Route](https://nextjs.org/docs/api-routes/dynamic-api-routes) and adds a `session` object to the request.
|
|
592
592
|
|
|
@@ -629,7 +629,7 @@ export default withIronSessionApiRoute(
|
|
|
629
629
|
);
|
|
630
630
|
```
|
|
631
631
|
|
|
632
|
-
### Next.js: withIronSessionSsr(handler, ironOptions | (req: IncomingMessage, res: ServerResponse) =>
|
|
632
|
+
### Next.js: withIronSessionSsr(handler, ironOptions | (req: IncomingMessage, res: ServerResponse) => IronOptions | Promise\<IronOptions\>)
|
|
633
633
|
|
|
634
634
|
Wraps a [Next.js getServerSideProps](https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering) and adds a `session` object to the request of the context.
|
|
635
635
|
|
|
@@ -753,6 +753,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
753
753
|
<table>
|
|
754
754
|
<tr>
|
|
755
755
|
<td align="center"><a href="http://www.afterecon.com/"><img src="https://avatars.githubusercontent.com/u/5559355?v=4?s=100" width="100px;" alt=""/><br /><sub><b>John Vandivier</b></sub></a><br /><a href="https://github.com/vvo/iron-session/commits?author=Vandivier" title="Code">💻</a> <a href="#ideas-Vandivier" title="Ideas, Planning, & Feedback">🤔</a> <a href="#example-Vandivier" title="Examples">💡</a></td>
|
|
756
|
+
<td align="center"><a href="https://searchableguy.com"><img src="https://avatars.githubusercontent.com/u/73341821?v=4?s=100" width="100px;" alt=""/><br /><sub><b>searchableguy</b></sub></a><br /><a href="https://github.com/vvo/iron-session/commits?author=searchableguy" title="Tests">⚠️</a> <a href="https://github.com/vvo/iron-session/commits?author=searchableguy" title="Documentation">📖</a> <a href="https://github.com/vvo/iron-session/commits?author=searchableguy" title="Code">💻</a></td>
|
|
756
757
|
</tr>
|
|
757
758
|
</table>
|
|
758
759
|
|
package/next/dist/index.js
CHANGED
|
@@ -54,20 +54,26 @@ function getPropertyDescriptorForReqSession(session) {
|
|
|
54
54
|
// next/index.ts
|
|
55
55
|
function withIronSessionApiRoute(handler, options) {
|
|
56
56
|
return async function nextApiHandlerWrappedWithIronSession(req, res) {
|
|
57
|
+
let sessionOptions;
|
|
57
58
|
if (options instanceof Function) {
|
|
58
|
-
|
|
59
|
+
sessionOptions = await options(req, res);
|
|
60
|
+
} else {
|
|
61
|
+
sessionOptions = options;
|
|
59
62
|
}
|
|
60
|
-
const session = await (0, import_iron_session.getIronSession)(req, res,
|
|
63
|
+
const session = await (0, import_iron_session.getIronSession)(req, res, sessionOptions);
|
|
61
64
|
Object.defineProperty(req, "session", getPropertyDescriptorForReqSession(session));
|
|
62
65
|
return handler(req, res);
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
function withIronSessionSsr(handler, options) {
|
|
66
69
|
return async function nextGetServerSidePropsHandlerWrappedWithIronSession(context) {
|
|
70
|
+
let sessionOptions;
|
|
67
71
|
if (options instanceof Function) {
|
|
68
|
-
|
|
72
|
+
sessionOptions = await options(context.req, context.res);
|
|
73
|
+
} else {
|
|
74
|
+
sessionOptions = options;
|
|
69
75
|
}
|
|
70
|
-
const session = await (0, import_iron_session.getIronSession)(context.req, context.res,
|
|
76
|
+
const session = await (0, import_iron_session.getIronSession)(context.req, context.res, sessionOptions);
|
|
71
77
|
Object.defineProperty(context.req, "session", getPropertyDescriptorForReqSession(session));
|
|
72
78
|
return handler(context);
|
|
73
79
|
};
|
package/next/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../index.ts", "../../src/getPropertyDescriptorForReqSession.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAQA,0BAA+B;;;ACNhB,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;
|
|
4
|
+
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(req, res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(req, res, sessionOptions);\n\n // we define req.session as being enumerable (so console.log(req) shows it)\n // and we also want to allow people to do:\n // req.session = { admin: true }; or req.session = {...req.session, admin: true};\n // req.session.save();\n Object.defineProperty(\n req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(req, res);\n };\n}\n\n// Argument type based on the SSR context\ntype GetIronSessionSSROptions = (\n request: IncomingMessage,\n response: ServerResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionSsr<\n P extends { [key: string]: unknown } = { [key: string]: unknown },\n>(\n handler: (\n context: GetServerSidePropsContext,\n ) => GetServerSidePropsResult<P> | Promise<GetServerSidePropsResult<P>>,\n options: IronSessionOptions | GetIronSessionSSROptions,\n) {\n return async function nextGetServerSidePropsHandlerWrappedWithIronSession(\n context: GetServerSidePropsContext,\n ) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(context.req, context.res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(\n context.req,\n context.res,\n sessionOptions,\n );\n\n Object.defineProperty(\n context.req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(context);\n };\n}\n", "import type { IronSession } from \".\";\n\nexport default function getPropertyDescriptorForReqSession(\n session: IronSession,\n): PropertyDescriptor {\n return {\n enumerable: true,\n get() {\n return session;\n },\n set(value) {\n const keys = Object.keys(value);\n const currentKeys = Object.keys(session);\n\n currentKeys.forEach((key) => {\n if (!keys.includes(key)) {\n // @ts-ignore See comment in IronSessionData interface\n delete session[key];\n }\n });\n\n keys.forEach((key) => {\n // @ts-ignore See comment in IronSessionData interface\n session[key] = value[key];\n });\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAQA,0BAA+B;;;ACNhB,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;AACnE,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,KAAK;AAAA,WAC/B;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,wCAAe,KAAK,KAAK;AAM/C,WAAO,eACL,KACA,WACA,mCAAmC;AAErC,WAAO,QAAQ,KAAK;AAAA;AAAA;AAUjB,4BAGL,SAGA,SACA;AACA,SAAO,mEACL,SACA;AACA,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,QAAQ,KAAK,QAAQ;AAAA,WAC/C;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,wCACpB,QAAQ,KACR,QAAQ,KACR;AAGF,WAAO,eACL,QAAQ,KACR,WACA,mCAAmC;AAErC,WAAO,QAAQ;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/next/dist/index.mjs
CHANGED
|
@@ -26,20 +26,26 @@ function getPropertyDescriptorForReqSession(session) {
|
|
|
26
26
|
// next/index.ts
|
|
27
27
|
function withIronSessionApiRoute(handler, options) {
|
|
28
28
|
return async function nextApiHandlerWrappedWithIronSession(req, res) {
|
|
29
|
+
let sessionOptions;
|
|
29
30
|
if (options instanceof Function) {
|
|
30
|
-
|
|
31
|
+
sessionOptions = await options(req, res);
|
|
32
|
+
} else {
|
|
33
|
+
sessionOptions = options;
|
|
31
34
|
}
|
|
32
|
-
const session = await getIronSession(req, res,
|
|
35
|
+
const session = await getIronSession(req, res, sessionOptions);
|
|
33
36
|
Object.defineProperty(req, "session", getPropertyDescriptorForReqSession(session));
|
|
34
37
|
return handler(req, res);
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
function withIronSessionSsr(handler, options) {
|
|
38
41
|
return async function nextGetServerSidePropsHandlerWrappedWithIronSession(context) {
|
|
42
|
+
let sessionOptions;
|
|
39
43
|
if (options instanceof Function) {
|
|
40
|
-
|
|
44
|
+
sessionOptions = await options(context.req, context.res);
|
|
45
|
+
} else {
|
|
46
|
+
sessionOptions = options;
|
|
41
47
|
}
|
|
42
|
-
const session = await getIronSession(context.req, context.res,
|
|
48
|
+
const session = await getIronSession(context.req, context.res, sessionOptions);
|
|
43
49
|
Object.defineProperty(context.req, "session", getPropertyDescriptorForReqSession(session));
|
|
44
50
|
return handler(context);
|
|
45
51
|
};
|
package/next/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../index.ts", "../../src/getPropertyDescriptorForReqSession.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n
|
|
5
|
-
"mappings": ";AAQA;;;ACNe,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;
|
|
4
|
+
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(req, res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(req, res, sessionOptions);\n\n // we define req.session as being enumerable (so console.log(req) shows it)\n // and we also want to allow people to do:\n // req.session = { admin: true }; or req.session = {...req.session, admin: true};\n // req.session.save();\n Object.defineProperty(\n req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(req, res);\n };\n}\n\n// Argument type based on the SSR context\ntype GetIronSessionSSROptions = (\n request: IncomingMessage,\n response: ServerResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionSsr<\n P extends { [key: string]: unknown } = { [key: string]: unknown },\n>(\n handler: (\n context: GetServerSidePropsContext,\n ) => GetServerSidePropsResult<P> | Promise<GetServerSidePropsResult<P>>,\n options: IronSessionOptions | GetIronSessionSSROptions,\n) {\n return async function nextGetServerSidePropsHandlerWrappedWithIronSession(\n context: GetServerSidePropsContext,\n ) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(context.req, context.res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(\n context.req,\n context.res,\n sessionOptions,\n );\n\n Object.defineProperty(\n context.req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(context);\n };\n}\n", "import type { IronSession } from \".\";\n\nexport default function getPropertyDescriptorForReqSession(\n session: IronSession,\n): PropertyDescriptor {\n return {\n enumerable: true,\n get() {\n return session;\n },\n set(value) {\n const keys = Object.keys(value);\n const currentKeys = Object.keys(session);\n\n currentKeys.forEach((key) => {\n if (!keys.includes(key)) {\n // @ts-ignore See comment in IronSessionData interface\n delete session[key];\n }\n });\n\n keys.forEach((key) => {\n // @ts-ignore See comment in IronSessionData interface\n session[key] = value[key];\n });\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";AAQA;;;ACNe,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;AACnE,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,KAAK;AAAA,WAC/B;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,eAAe,KAAK,KAAK;AAM/C,WAAO,eACL,KACA,WACA,mCAAmC;AAErC,WAAO,QAAQ,KAAK;AAAA;AAAA;AAUjB,4BAGL,SAGA,SACA;AACA,SAAO,mEACL,SACA;AACA,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,QAAQ,KAAK,QAAQ;AAAA,WAC/C;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,eACpB,QAAQ,KACR,QAAQ,KACR;AAGF,WAAO,eACL,QAAQ,KACR,WACA,mCAAmC;AAErC,WAAO,QAAQ;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/next/index.js
CHANGED
|
@@ -54,20 +54,26 @@ function getPropertyDescriptorForReqSession(session) {
|
|
|
54
54
|
// next/index.ts
|
|
55
55
|
function withIronSessionApiRoute(handler, options) {
|
|
56
56
|
return async function nextApiHandlerWrappedWithIronSession(req, res) {
|
|
57
|
+
let sessionOptions;
|
|
57
58
|
if (options instanceof Function) {
|
|
58
|
-
|
|
59
|
+
sessionOptions = await options(req, res);
|
|
60
|
+
} else {
|
|
61
|
+
sessionOptions = options;
|
|
59
62
|
}
|
|
60
|
-
const session = await (0, import_iron_session.getIronSession)(req, res,
|
|
63
|
+
const session = await (0, import_iron_session.getIronSession)(req, res, sessionOptions);
|
|
61
64
|
Object.defineProperty(req, "session", getPropertyDescriptorForReqSession(session));
|
|
62
65
|
return handler(req, res);
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
function withIronSessionSsr(handler, options) {
|
|
66
69
|
return async function nextGetServerSidePropsHandlerWrappedWithIronSession(context) {
|
|
70
|
+
let sessionOptions;
|
|
67
71
|
if (options instanceof Function) {
|
|
68
|
-
|
|
72
|
+
sessionOptions = await options(context.req, context.res);
|
|
73
|
+
} else {
|
|
74
|
+
sessionOptions = options;
|
|
69
75
|
}
|
|
70
|
-
const session = await (0, import_iron_session.getIronSession)(context.req, context.res,
|
|
76
|
+
const session = await (0, import_iron_session.getIronSession)(context.req, context.res, sessionOptions);
|
|
71
77
|
Object.defineProperty(context.req, "session", getPropertyDescriptorForReqSession(session));
|
|
72
78
|
return handler(context);
|
|
73
79
|
};
|
package/next/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../index.ts", "../../src/getPropertyDescriptorForReqSession.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAQA,0BAA+B;;;ACNhB,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;
|
|
4
|
+
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(req, res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(req, res, sessionOptions);\n\n // we define req.session as being enumerable (so console.log(req) shows it)\n // and we also want to allow people to do:\n // req.session = { admin: true }; or req.session = {...req.session, admin: true};\n // req.session.save();\n Object.defineProperty(\n req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(req, res);\n };\n}\n\n// Argument type based on the SSR context\ntype GetIronSessionSSROptions = (\n request: IncomingMessage,\n response: ServerResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionSsr<\n P extends { [key: string]: unknown } = { [key: string]: unknown },\n>(\n handler: (\n context: GetServerSidePropsContext,\n ) => GetServerSidePropsResult<P> | Promise<GetServerSidePropsResult<P>>,\n options: IronSessionOptions | GetIronSessionSSROptions,\n) {\n return async function nextGetServerSidePropsHandlerWrappedWithIronSession(\n context: GetServerSidePropsContext,\n ) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(context.req, context.res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(\n context.req,\n context.res,\n sessionOptions,\n );\n\n Object.defineProperty(\n context.req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(context);\n };\n}\n", "import type { IronSession } from \".\";\n\nexport default function getPropertyDescriptorForReqSession(\n session: IronSession,\n): PropertyDescriptor {\n return {\n enumerable: true,\n get() {\n return session;\n },\n set(value) {\n const keys = Object.keys(value);\n const currentKeys = Object.keys(session);\n\n currentKeys.forEach((key) => {\n if (!keys.includes(key)) {\n // @ts-ignore See comment in IronSessionData interface\n delete session[key];\n }\n });\n\n keys.forEach((key) => {\n // @ts-ignore See comment in IronSessionData interface\n session[key] = value[key];\n });\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAQA,0BAA+B;;;ACNhB,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;AACnE,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,KAAK;AAAA,WAC/B;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,wCAAe,KAAK,KAAK;AAM/C,WAAO,eACL,KACA,WACA,mCAAmC;AAErC,WAAO,QAAQ,KAAK;AAAA;AAAA;AAUjB,4BAGL,SAGA,SACA;AACA,SAAO,mEACL,SACA;AACA,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,QAAQ,KAAK,QAAQ;AAAA,WAC/C;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,wCACpB,QAAQ,KACR,QAAQ,KACR;AAGF,WAAO,eACL,QAAQ,KACR,WACA,mCAAmC;AAErC,WAAO,QAAQ;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/next/index.mjs
CHANGED
|
@@ -26,20 +26,26 @@ function getPropertyDescriptorForReqSession(session) {
|
|
|
26
26
|
// next/index.ts
|
|
27
27
|
function withIronSessionApiRoute(handler, options) {
|
|
28
28
|
return async function nextApiHandlerWrappedWithIronSession(req, res) {
|
|
29
|
+
let sessionOptions;
|
|
29
30
|
if (options instanceof Function) {
|
|
30
|
-
|
|
31
|
+
sessionOptions = await options(req, res);
|
|
32
|
+
} else {
|
|
33
|
+
sessionOptions = options;
|
|
31
34
|
}
|
|
32
|
-
const session = await getIronSession(req, res,
|
|
35
|
+
const session = await getIronSession(req, res, sessionOptions);
|
|
33
36
|
Object.defineProperty(req, "session", getPropertyDescriptorForReqSession(session));
|
|
34
37
|
return handler(req, res);
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
function withIronSessionSsr(handler, options) {
|
|
38
41
|
return async function nextGetServerSidePropsHandlerWrappedWithIronSession(context) {
|
|
42
|
+
let sessionOptions;
|
|
39
43
|
if (options instanceof Function) {
|
|
40
|
-
|
|
44
|
+
sessionOptions = await options(context.req, context.res);
|
|
45
|
+
} else {
|
|
46
|
+
sessionOptions = options;
|
|
41
47
|
}
|
|
42
|
-
const session = await getIronSession(context.req, context.res,
|
|
48
|
+
const session = await getIronSession(context.req, context.res, sessionOptions);
|
|
43
49
|
Object.defineProperty(context.req, "session", getPropertyDescriptorForReqSession(session));
|
|
44
50
|
return handler(context);
|
|
45
51
|
};
|
package/next/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../index.ts", "../../src/getPropertyDescriptorForReqSession.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n
|
|
5
|
-
"mappings": ";AAQA;;;ACNe,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;
|
|
4
|
+
"sourcesContent": ["import type {\n NextApiHandler,\n GetServerSidePropsContext,\n GetServerSidePropsResult,\n NextApiRequest,\n NextApiResponse,\n} from \"next\";\nimport type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\nimport { IncomingMessage, ServerResponse } from \"http\";\n\n// Argument types based on getIronSession function\ntype GetIronSessionApiOptions = (\n request: NextApiRequest,\n response: NextApiResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionApiRoute(\n handler: NextApiHandler,\n options: IronSessionOptions | GetIronSessionApiOptions,\n): NextApiHandler {\n return async function nextApiHandlerWrappedWithIronSession(req, res) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(req, res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(req, res, sessionOptions);\n\n // we define req.session as being enumerable (so console.log(req) shows it)\n // and we also want to allow people to do:\n // req.session = { admin: true }; or req.session = {...req.session, admin: true};\n // req.session.save();\n Object.defineProperty(\n req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(req, res);\n };\n}\n\n// Argument type based on the SSR context\ntype GetIronSessionSSROptions = (\n request: IncomingMessage,\n response: ServerResponse,\n) => Promise<IronSessionOptions> | IronSessionOptions;\n\nexport function withIronSessionSsr<\n P extends { [key: string]: unknown } = { [key: string]: unknown },\n>(\n handler: (\n context: GetServerSidePropsContext,\n ) => GetServerSidePropsResult<P> | Promise<GetServerSidePropsResult<P>>,\n options: IronSessionOptions | GetIronSessionSSROptions,\n) {\n return async function nextGetServerSidePropsHandlerWrappedWithIronSession(\n context: GetServerSidePropsContext,\n ) {\n let sessionOptions: IronSessionOptions;\n\n // If options is a function, call it and assign the results back.\n if (options instanceof Function) {\n sessionOptions = await options(context.req, context.res);\n } else {\n sessionOptions = options;\n }\n\n const session = await getIronSession(\n context.req,\n context.res,\n sessionOptions,\n );\n\n Object.defineProperty(\n context.req,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n return handler(context);\n };\n}\n", "import type { IronSession } from \".\";\n\nexport default function getPropertyDescriptorForReqSession(\n session: IronSession,\n): PropertyDescriptor {\n return {\n enumerable: true,\n get() {\n return session;\n },\n set(value) {\n const keys = Object.keys(value);\n const currentKeys = Object.keys(session);\n\n currentKeys.forEach((key) => {\n if (!keys.includes(key)) {\n // @ts-ignore See comment in IronSessionData interface\n delete session[key];\n }\n });\n\n keys.forEach((key) => {\n // @ts-ignore See comment in IronSessionData interface\n session[key] = value[key];\n });\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";AAQA;;;ACNe,4CACb,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA;AAAA,IAET,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK;AACzB,YAAM,cAAc,OAAO,KAAK;AAEhC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,MAAM;AAEvB,iBAAO,QAAQ;AAAA;AAAA;AAInB,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;;;ADLtB,iCACL,SACA,SACgB;AAChB,SAAO,oDAAoD,KAAK,KAAK;AACnE,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,KAAK;AAAA,WAC/B;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,eAAe,KAAK,KAAK;AAM/C,WAAO,eACL,KACA,WACA,mCAAmC;AAErC,WAAO,QAAQ,KAAK;AAAA;AAAA;AAUjB,4BAGL,SAGA,SACA;AACA,SAAO,mEACL,SACA;AACA,QAAI;AAGJ,QAAI,mBAAmB,UAAU;AAC/B,uBAAiB,MAAM,QAAQ,QAAQ,KAAK,QAAQ;AAAA,WAC/C;AACL,uBAAiB;AAAA;AAGnB,UAAM,UAAU,MAAM,eACpB,QAAQ,KACR,QAAQ,KACR;AAGF,WAAO,eACL,QAAQ,KACR,WACA,mCAAmC;AAErC,WAAO,QAAQ;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/next/index.test.ts
CHANGED
|
@@ -69,19 +69,22 @@ test("withIconSessionApiRoute: IronSessionOptions passed as a function works cor
|
|
|
69
69
|
const cookie = headerValue[0];
|
|
70
70
|
const cookieParams = cookie.split(";").slice(1).join(";");
|
|
71
71
|
const cookieName = cookie.split("=")[0];
|
|
72
|
-
|
|
72
|
+
// When giving session, iron implementation substracts 60 seconds.
|
|
73
|
+
const maxAgeValue = Number(req.headers["value"]) - 60;
|
|
73
74
|
expect(cookieParams).toMatchInlineSnapshot(
|
|
74
|
-
`" Max-Age
|
|
75
|
+
`" Max-Age=${maxAgeValue}; Path=/; HttpOnly; Secure; SameSite=Lax"`,
|
|
75
76
|
);
|
|
76
77
|
expect(cookieName).toBe("dynamic-cookie-name");
|
|
77
78
|
},
|
|
78
|
-
() => ({
|
|
79
|
+
(request) => ({
|
|
79
80
|
cookieName: "dynamic-cookie-name",
|
|
80
81
|
password,
|
|
81
|
-
ttl:
|
|
82
|
+
ttl: Number(request.headers["value"]),
|
|
82
83
|
}),
|
|
83
84
|
);
|
|
84
85
|
|
|
86
|
+
// Run it twice to make sure different value is assigned on computed session option from request
|
|
87
|
+
await wrappedHandler(getDefaultReq(), getDefaultRes());
|
|
85
88
|
await wrappedHandler(getDefaultReq(), getDefaultRes());
|
|
86
89
|
});
|
|
87
90
|
|
|
@@ -192,9 +195,50 @@ test("withIronSessionSsr: req.session exists", async () => {
|
|
|
192
195
|
} as unknown as GetServerSidePropsContext);
|
|
193
196
|
});
|
|
194
197
|
|
|
198
|
+
test("withIronSessionSsr: IronSessionOptions passed as a function to be computed on each request work correctly", async () => {
|
|
199
|
+
const wrappedHandler = withIronSessionSsr(
|
|
200
|
+
async function handler(context) {
|
|
201
|
+
context.req.session.user = { id: 200 };
|
|
202
|
+
await context.req.session.save();
|
|
203
|
+
const headerValue = (context.res.setHeader as jest.Mock).mock.calls[0][1];
|
|
204
|
+
const cookie = headerValue[0];
|
|
205
|
+
const cookieParams = cookie.split(";").slice(1).join(";");
|
|
206
|
+
const cookieName = cookie.split("=")[0];
|
|
207
|
+
// When giving session, iron implementation substracts 60 seconds.
|
|
208
|
+
const maxAgeValue = Number(context.req.headers["value"]) - 60;
|
|
209
|
+
expect(cookieParams).toMatchInlineSnapshot(
|
|
210
|
+
`" Max-Age=${maxAgeValue}; Path=/; HttpOnly; Secure; SameSite=Lax"`,
|
|
211
|
+
);
|
|
212
|
+
expect(cookieName).toBe("dynamic-cookie-name");
|
|
213
|
+
return {
|
|
214
|
+
props: {},
|
|
215
|
+
};
|
|
216
|
+
},
|
|
217
|
+
(request) => ({
|
|
218
|
+
cookieName: "dynamic-cookie-name",
|
|
219
|
+
password,
|
|
220
|
+
ttl: Number(request.headers["value"]),
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
// Run it twice to make sure different value is assigned on computed session option from request
|
|
225
|
+
await wrappedHandler({
|
|
226
|
+
req: getDefaultReq(),
|
|
227
|
+
res: getDefaultRes(),
|
|
228
|
+
} as unknown as GetServerSidePropsContext);
|
|
229
|
+
|
|
230
|
+
await wrappedHandler({
|
|
231
|
+
req: getDefaultReq(),
|
|
232
|
+
res: getDefaultRes(),
|
|
233
|
+
} as unknown as GetServerSidePropsContext);
|
|
234
|
+
});
|
|
235
|
+
|
|
195
236
|
function getDefaultReq() {
|
|
196
237
|
return {
|
|
197
|
-
headers: {
|
|
238
|
+
headers: {
|
|
239
|
+
// Random number between 100 to 1000
|
|
240
|
+
value: Math.floor(Math.random() * 900) + 100,
|
|
241
|
+
},
|
|
198
242
|
socket: {
|
|
199
243
|
encrypted: true,
|
|
200
244
|
},
|
package/next/index.ts
CHANGED
|
@@ -21,11 +21,16 @@ export function withIronSessionApiRoute(
|
|
|
21
21
|
options: IronSessionOptions | GetIronSessionApiOptions,
|
|
22
22
|
): NextApiHandler {
|
|
23
23
|
return async function nextApiHandlerWrappedWithIronSession(req, res) {
|
|
24
|
+
let sessionOptions: IronSessionOptions;
|
|
25
|
+
|
|
24
26
|
// If options is a function, call it and assign the results back.
|
|
25
27
|
if (options instanceof Function) {
|
|
26
|
-
|
|
28
|
+
sessionOptions = await options(req, res);
|
|
29
|
+
} else {
|
|
30
|
+
sessionOptions = options;
|
|
27
31
|
}
|
|
28
|
-
|
|
32
|
+
|
|
33
|
+
const session = await getIronSession(req, res, sessionOptions);
|
|
29
34
|
|
|
30
35
|
// we define req.session as being enumerable (so console.log(req) shows it)
|
|
31
36
|
// and we also want to allow people to do:
|
|
@@ -57,11 +62,21 @@ export function withIronSessionSsr<
|
|
|
57
62
|
return async function nextGetServerSidePropsHandlerWrappedWithIronSession(
|
|
58
63
|
context: GetServerSidePropsContext,
|
|
59
64
|
) {
|
|
65
|
+
let sessionOptions: IronSessionOptions;
|
|
66
|
+
|
|
60
67
|
// If options is a function, call it and assign the results back.
|
|
61
68
|
if (options instanceof Function) {
|
|
62
|
-
|
|
69
|
+
sessionOptions = await options(context.req, context.res);
|
|
70
|
+
} else {
|
|
71
|
+
sessionOptions = options;
|
|
63
72
|
}
|
|
64
|
-
|
|
73
|
+
|
|
74
|
+
const session = await getIronSession(
|
|
75
|
+
context.req,
|
|
76
|
+
context.res,
|
|
77
|
+
sessionOptions,
|
|
78
|
+
);
|
|
79
|
+
|
|
65
80
|
Object.defineProperty(
|
|
66
81
|
context.req,
|
|
67
82
|
"session",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iron-session",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.3",
|
|
4
4
|
"description": "Node.js stateless session utility using signed and encrypted cookies to store data. Works with Next.js, Express, NestJs, Fastify, and any Node.js HTTP framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Next.js",
|
|
@@ -122,26 +122,26 @@
|
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
124
|
"@hapi/iron": "^6.0.0",
|
|
125
|
-
"@types/cookie": "^0.
|
|
125
|
+
"@types/cookie": "^0.5.1",
|
|
126
126
|
"@types/express": "^4.17.13",
|
|
127
127
|
"@types/node": "^16.11.7",
|
|
128
|
-
"cookie": "^0.
|
|
128
|
+
"cookie": "^0.5.0"
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
|
-
"@swc/core": "^1.2.
|
|
131
|
+
"@swc/core": "^1.2.171",
|
|
132
132
|
"@swc/jest": "^0.2.20",
|
|
133
133
|
"@tsconfig/node12": "1.0.9",
|
|
134
134
|
"@types/jest": "^27.4.1",
|
|
135
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
136
|
-
"@typescript-eslint/parser": "^5.
|
|
137
|
-
"concurrently": "^7.
|
|
138
|
-
"eslint": "^8.
|
|
135
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
136
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
137
|
+
"concurrently": "^7.1.0",
|
|
138
|
+
"eslint": "^8.14.0",
|
|
139
139
|
"jest": "^27.5.1",
|
|
140
|
-
"prettier": "^2.6.
|
|
141
|
-
"prettier-plugin-packagejson": "^2.2.
|
|
140
|
+
"prettier": "^2.6.2",
|
|
141
|
+
"prettier-plugin-packagejson": "^2.2.17",
|
|
142
142
|
"rimraf": "3.0.2",
|
|
143
143
|
"tsup": "5.6.0",
|
|
144
|
-
"typescript": "^4.6.
|
|
144
|
+
"typescript": "^4.6.3"
|
|
145
145
|
},
|
|
146
146
|
"peerDependencies": {
|
|
147
147
|
"express": ">=4",
|