@abtnode/util 1.16.47-beta-20250714-035905-f63c5239 → 1.16.47-beta-20250715-034905-11207b15
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/lib/get-token-from-req.js +7 -7
- package/package.json +11 -11
|
@@ -5,10 +5,10 @@ const decodeCookie = require('cookie-parser').signedCookie;
|
|
|
5
5
|
const getCookie = (serializedCookies, key) => parseCookie(serializedCookies)[key] || false;
|
|
6
6
|
|
|
7
7
|
function getTokenFromReq(req, opts) {
|
|
8
|
-
const queryKey = opts?.queryKey
|
|
9
|
-
const bodyKey = opts?.bodyKey
|
|
10
|
-
const headerName = opts?.headerName
|
|
11
|
-
const headerKey = opts?.headerKey
|
|
8
|
+
const queryKey = opts?.queryKey ?? 'access_token';
|
|
9
|
+
const bodyKey = opts?.bodyKey ?? 'access_token';
|
|
10
|
+
const headerName = opts?.headerName ?? 'authorization';
|
|
11
|
+
const headerKey = opts?.headerKey ?? 'Bearer';
|
|
12
12
|
const cookie = opts?.cookie ?? {
|
|
13
13
|
key: 'access_token',
|
|
14
14
|
};
|
|
@@ -19,11 +19,11 @@ function getTokenFromReq(req, opts) {
|
|
|
19
19
|
let cookieToken;
|
|
20
20
|
let headerToken;
|
|
21
21
|
|
|
22
|
-
if (req.query?.[queryKey]) {
|
|
22
|
+
if (queryKey && req.query?.[queryKey]) {
|
|
23
23
|
queryToken = req.query[queryKey];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
if (req.body?.[bodyKey]) {
|
|
26
|
+
if (bodyKey && req.body?.[bodyKey]) {
|
|
27
27
|
bodyToken = req.body[bodyKey];
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -35,7 +35,7 @@ function getTokenFromReq(req, opts) {
|
|
|
35
35
|
} else if (req.cookies) {
|
|
36
36
|
cookieToken = req.cookies[cookie.key];
|
|
37
37
|
}
|
|
38
|
-
if (req.headers?.[headerName]) {
|
|
38
|
+
if (headerName && req.headers?.[headerName]) {
|
|
39
39
|
const parts = req.headers[headerName].split(' ');
|
|
40
40
|
if (parts.length === 2 && toLower(parts[0]) === toLower(headerKey)) {
|
|
41
41
|
[, headerToken] = parts;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.47-beta-
|
|
6
|
+
"version": "1.16.47-beta-20250715-034905-11207b15",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.47-beta-
|
|
22
|
-
"@abtnode/db-cache": "1.16.47-beta-
|
|
23
|
-
"@arcblock/did": "1.20.
|
|
21
|
+
"@abtnode/constant": "1.16.47-beta-20250715-034905-11207b15",
|
|
22
|
+
"@abtnode/db-cache": "1.16.47-beta-20250715-034905-11207b15",
|
|
23
|
+
"@arcblock/did": "1.20.16",
|
|
24
24
|
"@arcblock/pm2": "^5.4.0",
|
|
25
|
-
"@blocklet/constant": "1.16.47-beta-
|
|
25
|
+
"@blocklet/constant": "1.16.47-beta-20250715-034905-11207b15",
|
|
26
26
|
"@blocklet/error": "^0.2.5",
|
|
27
|
-
"@blocklet/meta": "1.16.47-beta-
|
|
27
|
+
"@blocklet/meta": "1.16.47-beta-20250715-034905-11207b15",
|
|
28
28
|
"@blocklet/xss": "^0.2.2",
|
|
29
|
-
"@ocap/client": "1.20.
|
|
30
|
-
"@ocap/mcrypto": "1.20.
|
|
31
|
-
"@ocap/util": "1.20.
|
|
32
|
-
"@ocap/wallet": "1.20.
|
|
29
|
+
"@ocap/client": "1.20.16",
|
|
30
|
+
"@ocap/mcrypto": "1.20.16",
|
|
31
|
+
"@ocap/util": "1.20.16",
|
|
32
|
+
"@ocap/wallet": "1.20.16",
|
|
33
33
|
"archiver": "^7.0.1",
|
|
34
34
|
"axios": "^1.7.9",
|
|
35
35
|
"axios-mock-adapter": "^2.1.0",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"fs-extra": "^11.2.0",
|
|
90
90
|
"jest": "^29.7.0"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "f08ee3ac63c808c93967db43445042b3050a015e"
|
|
93
93
|
}
|