iron-session 6.2.1 → 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/README.md CHANGED
@@ -24,6 +24,7 @@ _Table of contents:_
24
24
  - [Session wrappers](#session-wrappers)
25
25
  - [Typing session data with TypeScript](#typing-session-data-with-typescript)
26
26
  - [Express](#express)
27
+ - [Koa](#koa)
27
28
  - [Handle password rotation/update the password](#handle-password-rotationupdate-the-password)
28
29
  - [Magic links](#magic-links)
29
30
  - [Impersonation, login as someone else](#impersonation-login-as-someone-else)
@@ -405,6 +406,10 @@ We've taken this technique from [express-session types](https://github.com/Defin
405
406
 
406
407
  See [examples/express](examples/express) for an example of how to use this with Express.
407
408
 
409
+ ### Koa
410
+
411
+ See [examples/koa](examples/koa) for an example of how to use this with Koa.
412
+
408
413
  ### Handle password rotation/update the password
409
414
 
410
415
  When you want to:
@@ -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 };
@@ -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":[]}
@@ -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/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":[]}
@@ -0,0 +1,25 @@
1
+ import { ironSession } from ".";
2
+ import { createMockContext } from "@shopify/jest-koa-mocks";
3
+
4
+ const password = "Gbm49ATjnqnkCCCdhV4uDBhbfnPqsCW0";
5
+ const cookieName = "test";
6
+
7
+ // same structure as other tests otherwise linting will fail because you can have only one per running eslint
8
+ declare module "iron-session" {
9
+ interface IronSessionData {
10
+ user?: { id: number; meta?: string };
11
+ admin?: boolean;
12
+ }
13
+ }
14
+
15
+ test("ironSession: ctx.session exists", async () => {
16
+ const wrappedHandler = ironSession({
17
+ password,
18
+ cookieName,
19
+ });
20
+
21
+ const ctx = createMockContext();
22
+
23
+ await wrappedHandler(ctx, ctx => ctx);
24
+ expect(ctx.session).toMatchInlineSnapshot(`Object {}`);
25
+ });
package/koa/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ import type { IronSessionOptions } from "iron-session";
2
+ import { getIronSession } from "iron-session";
3
+ import * as Koa from "koa";
4
+ import getPropertyDescriptorForReqSession from "../src/getPropertyDescriptorForReqSession";
5
+
6
+ export function ironSession(
7
+ sessionOptions: IronSessionOptions,
8
+ ): (ctx: Koa.Context, next: Koa.Next) => Promise<void> {
9
+ return async function ironSessionMiddleWare(ctx, next) {
10
+ const session = await getIronSession(ctx.req, ctx.res, sessionOptions);
11
+ Object.defineProperty(
12
+ ctx,
13
+ "session",
14
+ getPropertyDescriptorForReqSession(session),
15
+ );
16
+
17
+ await next();
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "..",
5
+ "outDir": "./dist"
6
+ },
7
+ "include": ["./*.ts"]
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iron-session",
3
- "version": "6.2.1",
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",
@@ -10,6 +10,7 @@
10
10
  "auth",
11
11
  "authentication",
12
12
  "Express",
13
+ "Koa",
13
14
  "edge",
14
15
  "cloudflare workers"
15
16
  ],
@@ -35,6 +36,11 @@
35
36
  "require": "./express/dist/index.js",
36
37
  "types": "./express/dist/index.d.ts"
37
38
  },
39
+ "./koa": {
40
+ "import": "./koa/dist/index.mjs",
41
+ "require": "./koa/dist/index.js",
42
+ "types": "./koa/dist/index.d.ts"
43
+ },
38
44
  "./edge": {
39
45
  "import": "./edge/dist/index.mjs",
40
46
  "require": "./edge/dist/index.js",
@@ -48,23 +54,26 @@
48
54
  "dist/",
49
55
  "next/",
50
56
  "express/",
57
+ "koa/",
51
58
  "edge/"
52
59
  ],
53
60
  "scripts": {
54
- "build": "npm run build:clean && npm run build:src && npm run build:next && npm run build:express && npm run build:edge",
55
- "build:clean": "rimraf dist/ next/dist express/dist edge/dist",
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 koa/dist",
56
63
  "build:edge": "tsup edge/index.ts -d edge/dist",
57
64
  "build:express": "tsup express/index.ts -d express/dist",
65
+ "build:koa": "tsup koa/index.ts -d koa/dist",
58
66
  "build:next": "tsup next/index.ts -d next/dist",
59
67
  "build:src": "tsup src/index.ts",
60
- "installExamples": "(cd examples/express && npm ci) && (cd examples/next.js && npm ci) && (cd examples/next.js-typescript && npm ci)",
61
- "lint": "eslint --ext ts,js,jsx,tsx src/ next/ express/ edge/ examples/",
62
- "prepublishOnly": "npm run build && cp next/dist/* next/ && cp express/dist/* express/ && cp edge/dist/* edge/",
63
- "postpublish": "rm next/*.d.ts next/*.js next/*.map next/*.mjs && rm express/*.d.ts express/*.js express/*.map express/*.mjs && rm edge/*.d.ts edge/*.js edge/*.map edge/*.mjs",
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
+ "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 edge/dist/* edge/ && cp koa/dist/* koa/",
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",
64
72
  "test": "jest --coverage --ci && npm run installExamples && npm run lint && tsc --noEmit && npm run build && npm run build:clean",
65
73
  "watch": "npm run build:clean && concurrently \"npm:watch:*\"",
66
74
  "watch:edge": "tsup edge/index.ts -d edge/dist --watch edge/index.ts",
67
75
  "watch:express": "tsup express/index.ts -d express/dist --watch express/index.ts",
76
+ "watch:koa": "tsup koa/index.ts -d koa/dist --watch koa/index.ts",
68
77
  "watch:next": "tsup next/index.ts -d next/dist --watch next/index.ts",
69
78
  "watch:src": "tsup src/index.ts --watch src/index.ts"
70
79
  },
@@ -134,11 +143,13 @@
134
143
  "@peculiar/webcrypto": "^1.4.0",
135
144
  "@types/cookie": "^0.5.1",
136
145
  "@types/express": "^4.17.13",
146
+ "@types/koa": "^2.13.5",
137
147
  "@types/node": "^17.0.41",
138
148
  "cookie": "^0.5.0",
139
149
  "iron-webcrypto": "^0.2.5"
140
150
  },
141
151
  "devDependencies": {
152
+ "@shopify/jest-koa-mocks": "^5.0.1",
142
153
  "@swc/core": "1.2.242",
143
154
  "@swc/jest": "0.2.22",
144
155
  "@tsconfig/node12": "1.0.11",
@@ -156,12 +167,16 @@
156
167
  },
157
168
  "peerDependencies": {
158
169
  "express": ">=4",
170
+ "koa": ">=2",
159
171
  "next": ">=10"
160
172
  },
161
173
  "peerDependenciesMeta": {
162
174
  "express": {
163
175
  "optional": true
164
176
  },
177
+ "koa": {
178
+ "optional": true
179
+ },
165
180
  "next": {
166
181
  "optional": true
167
182
  }