iron-session 6.2.0-beta.0 → 6.2.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/README.md +59 -3
- package/dist/index.js +48 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -12
- package/dist/index.mjs.map +1 -1
- package/edge/dist/index.d.ts +4 -66
- package/edge/dist/index.js +51 -20
- package/edge/dist/index.js.map +1 -1
- package/edge/dist/index.mjs +46 -16
- package/edge/dist/index.mjs.map +1 -1
- package/edge/index.d.ts +4 -66
- package/edge/index.js +51 -20
- package/edge/index.js.map +1 -1
- package/edge/index.mjs +46 -16
- package/edge/index.mjs.map +1 -1
- package/edge/index.ts +3 -1
- package/express/dist/index.js +6 -1
- package/express/dist/index.js.map +1 -1
- package/express/dist/index.mjs +5 -1
- package/express/dist/index.mjs.map +1 -1
- package/express/index.js +6 -1
- package/express/index.js.map +1 -1
- package/express/index.mjs +5 -1
- package/express/index.mjs.map +1 -1
- package/next/dist/index.js +16 -3
- package/next/dist/index.js.map +1 -1
- package/next/dist/index.mjs +15 -3
- package/next/dist/index.mjs.map +1 -1
- package/next/index.js +16 -3
- package/next/index.js.map +1 -1
- package/next/index.mjs +15 -3
- package/next/index.mjs.map +1 -1
- package/package.json +17 -14
package/next/index.mjs
CHANGED
|
@@ -33,7 +33,11 @@ function withIronSessionApiRoute(handler, options) {
|
|
|
33
33
|
sessionOptions = options;
|
|
34
34
|
}
|
|
35
35
|
const session = await getIronSession(req, res, sessionOptions);
|
|
36
|
-
Object.defineProperty(
|
|
36
|
+
Object.defineProperty(
|
|
37
|
+
req,
|
|
38
|
+
"session",
|
|
39
|
+
getPropertyDescriptorForReqSession(session)
|
|
40
|
+
);
|
|
37
41
|
return handler(req, res);
|
|
38
42
|
};
|
|
39
43
|
}
|
|
@@ -45,8 +49,16 @@ function withIronSessionSsr(handler, options) {
|
|
|
45
49
|
} else {
|
|
46
50
|
sessionOptions = options;
|
|
47
51
|
}
|
|
48
|
-
const session = await getIronSession(
|
|
49
|
-
|
|
52
|
+
const session = await getIronSession(
|
|
53
|
+
context.req,
|
|
54
|
+
context.res,
|
|
55
|
+
sessionOptions
|
|
56
|
+
);
|
|
57
|
+
Object.defineProperty(
|
|
58
|
+
context.req,
|
|
59
|
+
"session",
|
|
60
|
+
getPropertyDescriptorForReqSession(session)
|
|
61
|
+
);
|
|
50
62
|
return handler(context);
|
|
51
63
|
};
|
|
52
64
|
}
|
package/next/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../../src/getPropertyDescriptorForReqSession.ts"],"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"],"mappings":";AAQA;;;
|
|
1
|
+
{"version":3,"sources":["../index.ts","../../src/getPropertyDescriptorForReqSession.ts"],"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 com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Q,OAAO;AAAA,EACxB;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iron-session",
|
|
3
|
-
"version": "6.2.0
|
|
3
|
+
"version": "6.2.0",
|
|
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",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"login",
|
|
10
10
|
"auth",
|
|
11
11
|
"Express",
|
|
12
|
-
"NestJS"
|
|
12
|
+
"NestJS",
|
|
13
|
+
"edge",
|
|
14
|
+
"cloudflare workers"
|
|
13
15
|
],
|
|
14
16
|
"bugs": {
|
|
15
17
|
"url": "https://github.com/vvo/iron-session/issues"
|
|
@@ -137,20 +139,20 @@
|
|
|
137
139
|
"iron-webcrypto": "^0.1.0"
|
|
138
140
|
},
|
|
139
141
|
"devDependencies": {
|
|
140
|
-
"@swc/core": "1.2.
|
|
141
|
-
"@swc/jest": "0.2.
|
|
142
|
-
"@tsconfig/node12": "1.0.
|
|
143
|
-
"@types/jest": "28.1.
|
|
144
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
145
|
-
"@typescript-eslint/parser": "5.
|
|
146
|
-
"concurrently": "7.
|
|
147
|
-
"eslint": "8.
|
|
148
|
-
"jest": "28.1.
|
|
149
|
-
"prettier": "2.
|
|
142
|
+
"@swc/core": "1.2.233",
|
|
143
|
+
"@swc/jest": "0.2.22",
|
|
144
|
+
"@tsconfig/node12": "1.0.11",
|
|
145
|
+
"@types/jest": "28.1.6",
|
|
146
|
+
"@typescript-eslint/eslint-plugin": "5.33.0",
|
|
147
|
+
"@typescript-eslint/parser": "5.33.0",
|
|
148
|
+
"concurrently": "7.3.0",
|
|
149
|
+
"eslint": "8.22.0",
|
|
150
|
+
"jest": "28.1.3",
|
|
151
|
+
"prettier": "2.7.1",
|
|
150
152
|
"prettier-plugin-packagejson": "2.2.18",
|
|
151
153
|
"rimraf": "3.0.2",
|
|
152
|
-
"tsup": "6.
|
|
153
|
-
"typescript": "4.7.
|
|
154
|
+
"tsup": "6.2.2",
|
|
155
|
+
"typescript": "4.7.4"
|
|
154
156
|
},
|
|
155
157
|
"peerDependencies": {
|
|
156
158
|
"express": ">=4",
|
|
@@ -164,6 +166,7 @@
|
|
|
164
166
|
"optional": true
|
|
165
167
|
}
|
|
166
168
|
},
|
|
169
|
+
"packageManager": "npm@8.11.0",
|
|
167
170
|
"engines": {
|
|
168
171
|
"node": ">=12"
|
|
169
172
|
},
|