next-ssr-middleware 0.8.9 → 0.8.10
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.
|
@@ -10,23 +10,23 @@ function oauth2Signer(_a) {
|
|
|
10
10
|
var _this = this;
|
|
11
11
|
var signInURL = _a.signInURL, accessToken = _a.accessToken, userProfile = _a.userProfile, _b = _a.tokenKey, tokenKey = _b === void 0 ? 'token' : _b;
|
|
12
12
|
return function (_a, next_1) { return tslib_1.__awaiter(_this, [_a, next_1], void 0, function (_b, next) {
|
|
13
|
-
var token, pageURL, token_1, user, data, props, _c;
|
|
13
|
+
var token, pageURL, token_1, searchParams, user, data, props, _c;
|
|
14
14
|
var _d = _b.req, url = _d.url, headers = _d.headers, cookies = _d.cookies, query = _b.query, res = _b.res;
|
|
15
15
|
return tslib_1.__generator(this, function (_e) {
|
|
16
16
|
switch (_e.label) {
|
|
17
17
|
case 0:
|
|
18
18
|
token = cookies[tokenKey];
|
|
19
|
-
pageURL = new URL(url || '/', headers['origin'] || Host)
|
|
19
|
+
pageURL = new URL(url || '/', headers['origin'] || Host);
|
|
20
20
|
if (!query.code) return [3 /*break*/, 2];
|
|
21
21
|
return [4 /*yield*/, accessToken(query)];
|
|
22
22
|
case 1:
|
|
23
|
-
token_1 = _e.sent();
|
|
23
|
+
token_1 = _e.sent(), searchParams = pageURL.searchParams;
|
|
24
24
|
res.setHeader('Set-Cookie', "token=".concat(token_1, "; Path=/"));
|
|
25
|
+
searchParams.delete('code');
|
|
26
|
+
if (searchParams.get('state') === '')
|
|
27
|
+
searchParams.delete('state');
|
|
25
28
|
return [2 /*return*/, {
|
|
26
|
-
redirect: {
|
|
27
|
-
destination: pageURL.split('?')[0],
|
|
28
|
-
permanent: false
|
|
29
|
-
},
|
|
29
|
+
redirect: { destination: pageURL + '', permanent: false },
|
|
30
30
|
props: {}
|
|
31
31
|
}];
|
|
32
32
|
case 2:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../source/middleware/remote.ts"],"names":[],"mappings":";;AAyBA,
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../source/middleware/remote.ts"],"names":[],"mappings":";;AAyBA,oCA4CC;AA6BD,oCA8CC;;AAhJD,2CAA2C;AAsB3C,IAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;AACzD,IAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,kBAAW,MAAM,CAAE,CAAC,CAAC,CAAC,uBAAuB,CAAC;AAEpE,SAAgB,YAAY,CAAkD,EAK/D;IALf,iBA4CC;QA3CG,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,WAAW,iBAAA,EACX,gBAAkB,EAAlB,QAAQ,mBAAG,OAAO,KAAA;IAElB,OAAO,wFAAO,EAA8C,EAAE,IAAI;;YAAlD,WAA8B,EAAvB,GAAG,SAAA,EAAE,OAAO,aAAA,EAAE,OAAO,aAAA,EAAI,KAAK,WAAA,EAAE,GAAG,SAAA;;;;oBAChD,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;oBAC1B,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;yBAE3D,KAAK,CAAC,IAAI,EAAV,wBAAU;oBACI,qBAAM,WAAW,CAAC,KAAqB,CAAC,EAAA;;oBAAhD,UAAQ,SAAwC,EAChD,YAAY,GAAK,OAAO,aAAZ;oBAElB,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,gBAAS,OAAK,aAAU,CAAC,CAAC;oBAEtD,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC5B,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE;wBAAE,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAEnE,sBAAO;4BACH,QAAQ,EA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ACxB,IAAI,GAAG,CAAC,0BAA0B,EAAE,WAAW,CAAC,EAChD;4BACI,MAAM,EAAE,MAAM;4BACd,OAAO,EAAE;gCACL,MAAM,EAAE,kBAAkB;gCAC1B,cAAc,EAAE,kBAAkB;6BACrC;4BACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,WAAA,EAAE,aAAa,eAAA,EAAE,IAAI,MAAA,EAAE,CAAC;yBAC3D,CACJ,EAAA;;wBAVK,QAAQ,GAAG,SAUhB;wBAC+B,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAA/C,KAA0B,SAAqB,EAA7C,KAAK,WAAA,EAAE,YAAY,kBAAA;wBAE3B,IAAI,KAAK;4BAAE,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;wBAErC,sBAAO,YAAY,EAAC;;;aACvB;QACD,WAAW,EAAE,UAAM,KAAK;;;;4BACH,qBAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;4BACtD,OAAO,EAAE;gCACL,aAAa,EAAE,iBAAU,KAAK,CAAE;gCAChC,MAAM,EAAE,kBAAkB;6BAC7B;yBACJ,CAAC,EAAA;;wBALI,QAAQ,GAAG,SAKf;wBACF,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG;4BAAE,sBAAO,QAAQ,CAAC,IAAI,EAAE,EAAC;wBAElD,MAAM,IAAI,QAAQ,CAAC,6BAA6B,CAAC,CAAC;;;aACrD;KACJ,CAAC,CAAC;AACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-ssr-middleware",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.10",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"author": "shiy2008@gmail.com",
|
|
6
6
|
"description": "Koa-like middlewares for Next.js Server Side Rendering",
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"jsonwebtoken": "^9.0.2",
|
|
26
26
|
"tslib": "^2.8.1",
|
|
27
|
-
"web-utility": "^4.4.
|
|
27
|
+
"web-utility": "^4.4.3"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"mobx-i18n": ">=0.5 <1",
|
|
31
31
|
"next": ">=9.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/jsonwebtoken": "^9.0.
|
|
35
|
-
"@types/node": "^
|
|
36
|
-
"husky": "^9.1.
|
|
37
|
-
"koajax": "^3.
|
|
38
|
-
"lint-staged": "^15.
|
|
34
|
+
"@types/jsonwebtoken": "^9.0.9",
|
|
35
|
+
"@types/node": "^22.13.10",
|
|
36
|
+
"husky": "^9.1.7",
|
|
37
|
+
"koajax": "^3.1.1",
|
|
38
|
+
"lint-staged": "^15.5.0",
|
|
39
39
|
"mobx-i18n": "^0.6.0",
|
|
40
|
-
"next": "^15.
|
|
40
|
+
"next": "^15.2.2",
|
|
41
41
|
"open-cli": "^8.0.0",
|
|
42
|
-
"prettier": "^3.
|
|
43
|
-
"typedoc": "^0.
|
|
44
|
-
"typescript": "~5.
|
|
42
|
+
"prettier": "^3.5.3",
|
|
43
|
+
"typedoc": "^0.28.0",
|
|
44
|
+
"typescript": "~5.8.2"
|
|
45
45
|
},
|
|
46
46
|
"prettier": {
|
|
47
47
|
"singleQuote": true,
|
|
@@ -4,7 +4,7 @@ import { DataObject, Middleware } from '../compose';
|
|
|
4
4
|
|
|
5
5
|
export type OAuth2Ticket = {
|
|
6
6
|
code: string;
|
|
7
|
-
state
|
|
7
|
+
state: string;
|
|
8
8
|
[key: string]: string;
|
|
9
9
|
};
|
|
10
10
|
|
|
@@ -31,18 +31,19 @@ export function oauth2Signer<I extends DataObject, O extends DataObject = {}>({
|
|
|
31
31
|
}: OAuth2Option): Middleware<I, O> {
|
|
32
32
|
return async ({ req: { url, headers, cookies }, query, res }, next) => {
|
|
33
33
|
const token = cookies[tokenKey];
|
|
34
|
-
const pageURL = new URL(url || '/', headers['origin'] || Host)
|
|
34
|
+
const pageURL = new URL(url || '/', headers['origin'] || Host);
|
|
35
35
|
|
|
36
36
|
if (query.code) {
|
|
37
|
-
const token = await accessToken(query as OAuth2Ticket)
|
|
37
|
+
const token = await accessToken(query as OAuth2Ticket),
|
|
38
|
+
{ searchParams } = pageURL;
|
|
38
39
|
|
|
39
40
|
res.setHeader('Set-Cookie', `token=${token}; Path=/`);
|
|
40
41
|
|
|
42
|
+
searchParams.delete('code');
|
|
43
|
+
if (searchParams.get('state') === '') searchParams.delete('state');
|
|
44
|
+
|
|
41
45
|
return {
|
|
42
|
-
redirect: {
|
|
43
|
-
destination: pageURL.split('?')[0],
|
|
44
|
-
permanent: false
|
|
45
|
-
},
|
|
46
|
+
redirect: { destination: pageURL + '', permanent: false },
|
|
46
47
|
props: {} as O
|
|
47
48
|
};
|
|
48
49
|
}
|