iron-session 6.3.0 → 6.3.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.
package/koa/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { IronSessionOptions } from 'iron-session';
2
+ import * as Koa from 'koa';
3
+
4
+ declare function ironSession(sessionOptions: IronSessionOptions): (ctx: Koa.Context, next: Koa.Next) => Promise<void>;
5
+
6
+ export { ironSession };
package/koa/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // koa/index.ts
21
+ var koa_exports = {};
22
+ __export(koa_exports, {
23
+ ironSession: () => ironSession
24
+ });
25
+ module.exports = __toCommonJS(koa_exports);
26
+ var import_iron_session = require("iron-session");
27
+
28
+ // src/getPropertyDescriptorForReqSession.ts
29
+ function getPropertyDescriptorForReqSession(session) {
30
+ return {
31
+ enumerable: true,
32
+ get() {
33
+ return session;
34
+ },
35
+ set(value) {
36
+ const keys = Object.keys(value);
37
+ const currentKeys = Object.keys(session);
38
+ currentKeys.forEach((key) => {
39
+ if (!keys.includes(key)) {
40
+ delete session[key];
41
+ }
42
+ });
43
+ keys.forEach((key) => {
44
+ session[key] = value[key];
45
+ });
46
+ }
47
+ };
48
+ }
49
+
50
+ // koa/index.ts
51
+ function ironSession(sessionOptions) {
52
+ return async function ironSessionMiddleWare(ctx, next) {
53
+ const session = await (0, import_iron_session.getIronSession)(ctx.req, ctx.res, sessionOptions);
54
+ Object.defineProperty(
55
+ ctx,
56
+ "session",
57
+ getPropertyDescriptorForReqSession(session)
58
+ );
59
+ await next();
60
+ };
61
+ }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ ironSession
65
+ });
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../../src/getPropertyDescriptorForReqSession.ts"],"sourcesContent":["import type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport * as Koa from \"koa\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\n\nexport function ironSession(\n sessionOptions: IronSessionOptions,\n): (ctx: Koa.Context, next: Koa.Next) => Promise<void> {\n return async function ironSessionMiddleWare(ctx, next) {\n const session = await getIronSession(ctx.req, ctx.res, sessionOptions);\n Object.defineProperty(\n ctx,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n\n await next();\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAA+B;;;ACChB,SAAR,mCACL,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA,IACT;AAAA,IACA,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,YAAM,cAAc,OAAO,KAAK,OAAO;AAEvC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,GAAG,GAAG;AAEvB,iBAAO,QAAQ;AAAA,QACjB;AAAA,MACF,CAAC;AAED,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA,MACvB,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;ADtBO,SAAS,YACd,gBACqD;AACrD,SAAO,eAAe,sBAAsB,KAAK,MAAM;AACrD,UAAM,UAAU,UAAM,oCAAe,IAAI,KAAK,IAAI,KAAK,cAAc;AACrE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,mCAAmC,OAAO;AAAA,IAC5C;AAEA,UAAM,KAAK;AAAA,EACb;AACF;","names":[]}
package/koa/index.mjs ADDED
@@ -0,0 +1,41 @@
1
+ // koa/index.ts
2
+ import { getIronSession } from "iron-session";
3
+
4
+ // src/getPropertyDescriptorForReqSession.ts
5
+ function getPropertyDescriptorForReqSession(session) {
6
+ return {
7
+ enumerable: true,
8
+ get() {
9
+ return session;
10
+ },
11
+ set(value) {
12
+ const keys = Object.keys(value);
13
+ const currentKeys = Object.keys(session);
14
+ currentKeys.forEach((key) => {
15
+ if (!keys.includes(key)) {
16
+ delete session[key];
17
+ }
18
+ });
19
+ keys.forEach((key) => {
20
+ session[key] = value[key];
21
+ });
22
+ }
23
+ };
24
+ }
25
+
26
+ // koa/index.ts
27
+ function ironSession(sessionOptions) {
28
+ return async function ironSessionMiddleWare(ctx, next) {
29
+ const session = await getIronSession(ctx.req, ctx.res, sessionOptions);
30
+ Object.defineProperty(
31
+ ctx,
32
+ "session",
33
+ getPropertyDescriptorForReqSession(session)
34
+ );
35
+ await next();
36
+ };
37
+ }
38
+ export {
39
+ ironSession
40
+ };
41
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../../src/getPropertyDescriptorForReqSession.ts"],"sourcesContent":["import type { IronSessionOptions } from \"iron-session\";\nimport { getIronSession } from \"iron-session\";\nimport * as Koa from \"koa\";\nimport getPropertyDescriptorForReqSession from \"../src/getPropertyDescriptorForReqSession\";\n\nexport function ironSession(\n sessionOptions: IronSessionOptions,\n): (ctx: Koa.Context, next: Koa.Next) => Promise<void> {\n return async function ironSessionMiddleWare(ctx, next) {\n const session = await getIronSession(ctx.req, ctx.res, sessionOptions);\n Object.defineProperty(\n ctx,\n \"session\",\n getPropertyDescriptorForReqSession(session),\n );\n\n await next();\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":";AACA,SAAS,sBAAsB;;;ACChB,SAAR,mCACL,SACoB;AACpB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AACJ,aAAO;AAAA,IACT;AAAA,IACA,IAAI,OAAO;AACT,YAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,YAAM,cAAc,OAAO,KAAK,OAAO;AAEvC,kBAAY,QAAQ,CAAC,QAAQ;AAC3B,YAAI,CAAC,KAAK,SAAS,GAAG,GAAG;AAEvB,iBAAO,QAAQ;AAAA,QACjB;AAAA,MACF,CAAC;AAED,WAAK,QAAQ,CAAC,QAAQ;AAEpB,gBAAQ,OAAO,MAAM;AAAA,MACvB,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;ADtBO,SAAS,YACd,gBACqD;AACrD,SAAO,eAAe,sBAAsB,KAAK,MAAM;AACrD,UAAM,UAAU,MAAM,eAAe,IAAI,KAAK,IAAI,KAAK,cAAc;AACrE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,mCAAmC,OAAO;AAAA,IAC5C;AAEA,UAAM,KAAK;AAAA,EACb;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iron-session",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
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",
@@ -59,7 +59,7 @@
59
59
  ],
60
60
  "scripts": {
61
61
  "build": "npm run build:clean && npm run build:src && npm run build:next && npm run build:express && npm run build:koa && npm run build:edge",
62
- "build:clean": "rimraf dist/ next/dist express/dist edge/dist",
62
+ "build:clean": "rimraf dist/ next/dist express/dist edge/dist koa/dist",
63
63
  "build:edge": "tsup edge/index.ts -d edge/dist",
64
64
  "build:express": "tsup express/index.ts -d express/dist",
65
65
  "build:koa": "tsup koa/index.ts -d koa/dist",
@@ -67,7 +67,7 @@
67
67
  "build:src": "tsup src/index.ts",
68
68
  "installExamples": "(cd examples/express && npm ci) && (cd examples/koa && npm ci) && (cd examples/next.js && npm ci) && (cd examples/next.js-typescript && npm ci)",
69
69
  "lint": "eslint --ext ts,js,jsx,tsx src/ next/ express/ koa/ edge/ examples/",
70
- "prepublishOnly": "npm run build && cp next/dist/* next/ && cp express/dist/* express/ && cp express/dist/* express/ && cp edge/dist/* edge/",
70
+ "prepublishOnly": "npm run build && cp next/dist/* next/ && cp express/dist/* express/ && cp edge/dist/* edge/ && cp koa/dist/* koa/",
71
71
  "postpublish": "rm next/*.d.ts next/*.js next/*.map next/*.mjs && rm express/*.d.ts express/*.js express/*.map express/*.mjs && rm koa/*.d.ts koa/*.js koa/*.map koa/*.mjs && rm edge/*.d.ts edge/*.js edge/*.map edge/*.mjs",
72
72
  "test": "jest --coverage --ci && npm run installExamples && npm run lint && tsc --noEmit && npm run build && npm run build:clean",
73
73
  "watch": "npm run build:clean && concurrently \"npm:watch:*\"",