next-ssr-middleware 1.1.4 → 1.1.5
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/dist/index.cjs +3 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -1
- package/package.json +1 -1
- package/source/SSR/middleware/local.ts +5 -1
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,6 @@ _koa_bodyparser = __toESM(_koa_bodyparser);
|
|
|
26
26
|
let _koa_router = require("@koa/router");
|
|
27
27
|
let koa = require("koa");
|
|
28
28
|
koa = __toESM(koa);
|
|
29
|
-
let jsonwebtoken = require("jsonwebtoken");
|
|
30
29
|
let web_utility = require("web-utility");
|
|
31
30
|
//#region source/API.ts
|
|
32
31
|
function withKoa(...parameters) {
|
|
@@ -3036,6 +3035,7 @@ var $cbd22d3323bef9ca$export$45cf759b359d3d24 = class extends $eef213ff4197108b$
|
|
|
3036
3035
|
};
|
|
3037
3036
|
//#endregion
|
|
3038
3037
|
//#region source/SSR/middleware/local.ts
|
|
3038
|
+
const JWT = import("jsonwebtoken").then((module) => module.default || module);
|
|
3039
3039
|
async function errorLogger(context, next) {
|
|
3040
3040
|
try {
|
|
3041
3041
|
return await next();
|
|
@@ -3071,7 +3071,8 @@ function jwtVerifier(tokenKey = "token", secretKey = "JWT_SECRET", options = {})
|
|
|
3071
3071
|
const token = cookies[tokenKey] || "", secret = process.env[secretKey] || "";
|
|
3072
3072
|
let jwtPayload;
|
|
3073
3073
|
try {
|
|
3074
|
-
|
|
3074
|
+
const { verify } = await JWT;
|
|
3075
|
+
jwtPayload = verify(token, secret, options);
|
|
3075
3076
|
} catch (error) {
|
|
3076
3077
|
console.error(url, error);
|
|
3077
3078
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Router, RouterContext, RouterInstance, RouterOptions } from "@koa/router";
|
|
2
2
|
import Koa, { Middleware as Middleware$1 } from "koa";
|
|
3
|
-
import { JwtPayload, VerifyOptions } from "jsonwebtoken";
|
|
4
3
|
import { GetServerSideProps, GetServerSidePropsContext, GetServerSidePropsResult } from "next";
|
|
4
|
+
import { JwtPayload, VerifyOptions } from "jsonwebtoken";
|
|
5
5
|
import { ParsedUrlQuery } from "querystring";
|
|
6
6
|
import { NextRequest } from "next/server";
|
|
7
7
|
import { GetServerSideProps as GetServerSideProps$1 } from "next/types";
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import BodyParser from "@koa/bodyparser";
|
|
2
2
|
import { Router } from "@koa/router";
|
|
3
3
|
import Koa from "koa";
|
|
4
|
-
import { verify } from "jsonwebtoken";
|
|
5
4
|
import { Day, Second, buildURLData, createAsyncIterator, formToJSON, isTypedArray, likeArray, parseJSON, stringifyDOM } from "web-utility";
|
|
6
5
|
//#region source/API.ts
|
|
7
6
|
function withKoa(...parameters) {
|
|
@@ -3011,6 +3010,7 @@ var $cbd22d3323bef9ca$export$45cf759b359d3d24 = class extends $eef213ff4197108b$
|
|
|
3011
3010
|
};
|
|
3012
3011
|
//#endregion
|
|
3013
3012
|
//#region source/SSR/middleware/local.ts
|
|
3013
|
+
const JWT = import("jsonwebtoken").then((module) => module.default || module);
|
|
3014
3014
|
async function errorLogger(context, next) {
|
|
3015
3015
|
try {
|
|
3016
3016
|
return await next();
|
|
@@ -3046,6 +3046,7 @@ function jwtVerifier(tokenKey = "token", secretKey = "JWT_SECRET", options = {})
|
|
|
3046
3046
|
const token = cookies[tokenKey] || "", secret = process.env[secretKey] || "";
|
|
3047
3047
|
let jwtPayload;
|
|
3048
3048
|
try {
|
|
3049
|
+
const { verify } = await JWT;
|
|
3049
3050
|
jwtPayload = verify(token, secret, options);
|
|
3050
3051
|
} catch (error) {
|
|
3051
3052
|
console.error(url, error);
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JwtPayload, VerifyOptions
|
|
1
|
+
import type { JwtPayload, VerifyOptions } from 'jsonwebtoken';
|
|
2
2
|
import { HTTPError } from 'koajax';
|
|
3
3
|
import { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
4
4
|
import { ParsedUrlQuery } from 'querystring';
|
|
@@ -6,6 +6,8 @@ import { Day, Second } from 'web-utility';
|
|
|
6
6
|
|
|
7
7
|
import { DataObject, Middleware } from '../compose';
|
|
8
8
|
|
|
9
|
+
const JWT = import('jsonwebtoken').then(module => module.default || module);
|
|
10
|
+
|
|
9
11
|
export async function errorLogger<
|
|
10
12
|
I extends DataObject,
|
|
11
13
|
O extends DataObject = {}
|
|
@@ -66,6 +68,8 @@ export function jwtVerifier<I extends DataObject, O extends DataObject = {}>(
|
|
|
66
68
|
secret = process.env[secretKey] || '';
|
|
67
69
|
let jwtPayload: (JwtPayload & I) | undefined;
|
|
68
70
|
try {
|
|
71
|
+
const { verify } = await JWT;
|
|
72
|
+
|
|
69
73
|
jwtPayload = verify(token, secret, options) as JwtPayload & I;
|
|
70
74
|
} catch (error) {
|
|
71
75
|
console.error(url, error);
|