joye-backend-utility 4.1.22-test12 → 4.1.22-test13
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/jwt.js +4 -14
- package/package.json +6 -3
package/dist/jwt.js
CHANGED
|
@@ -4,22 +4,12 @@ exports.jwtVerify = exports.createToken = void 0;
|
|
|
4
4
|
const jwt = require('jsonwebtoken');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
-
|
|
8
|
-
// const JWT_SECRET = '3s6v9y$B&E)H+MbQeThWmZq4t7w!z%C*F-JaNcRfUjXn2r5u8x/A?D(G+KbPeSgV';
|
|
7
|
+
const JWT_SECRET = '64d5f73bb3f132821122d68330263edd44023810a1f05efb701fc7ec8d0f6382';
|
|
9
8
|
const folderPath = path.resolve(`${__dirname}`);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let JWT_PRIVATE_KEY = '';
|
|
13
|
-
const JWT_PUBLIC_KEY = '';
|
|
9
|
+
const JWT_PRIVATE_KEY = fs.readFileSync(`${folderPath}/jwtKeys/jwtRS256.key`, 'utf8');
|
|
10
|
+
const JWT_PUBLIC_KEY = fs.readFileSync(`${folderPath}/jwtKeys/jwtRS256.key.pub`, 'utf8');
|
|
14
11
|
const createToken = async (payload, expiresIn) => {
|
|
15
|
-
|
|
16
|
-
JWT_PRIVATE_KEY = fs.readFileSync(`${folderPath}/jwtKeys/jwtRS256.key`, 'utf8');
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
console.log('**** Err', err);
|
|
20
|
-
return err;
|
|
21
|
-
}
|
|
22
|
-
const token = jwt.sign(payload, { key: JWT_PRIVATE_KEY.replace(/\\n/gm, '\n'), passphrase: '64d5f73bb3f132821122d68330263edd44023810a1f05efb701fc7ec8d0f6382' }, {
|
|
12
|
+
const token = jwt.sign(payload, { key: JWT_PRIVATE_KEY.replace(/\\n/gm, '\n'), passphrase: JWT_SECRET }, {
|
|
23
13
|
expiresIn,
|
|
24
14
|
algorithm: 'RS256',
|
|
25
15
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joye-backend-utility",
|
|
3
|
-
"version": "4.1.22-
|
|
3
|
+
"version": "4.1.22-test13",
|
|
4
4
|
"description": "Joye backend utility for db functions and common functions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
"node": "17.1.0"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "tsc",
|
|
14
|
+
"build": "tsc && yarn copy-files",
|
|
15
15
|
"test": "echo \"Error: no test specified\"",
|
|
16
16
|
"postinstall": "npm run build",
|
|
17
17
|
"lint": "eslint --ignore-path .gitignore --ext .ts .",
|
|
18
18
|
"lint:fix": "npm run lint -- --fix",
|
|
19
|
-
"prepare": "husky install && yarn build"
|
|
19
|
+
"prepare": "husky install && yarn build",
|
|
20
|
+
"copy-files": "copyfiles -u 1 lib/jwtKeys/**/* dist/"
|
|
20
21
|
},
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|
|
@@ -43,12 +44,14 @@
|
|
|
43
44
|
"@types/node": "^17.0.25",
|
|
44
45
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
45
46
|
"@typescript-eslint/parser": "^4.28.2",
|
|
47
|
+
"copyfiles": "^2.4.1",
|
|
46
48
|
"eslint": "^7.30.0",
|
|
47
49
|
"eslint-config-prettier": "^8.3.0",
|
|
48
50
|
"eslint-plugin-prettier": "^3.4.0",
|
|
49
51
|
"husky": "^7.0.0",
|
|
50
52
|
"lint-staged": "^11.0.0",
|
|
51
53
|
"prettier": "^2.3.2",
|
|
54
|
+
"rimraf": "^5.0.1",
|
|
52
55
|
"ts-node": "^10.4.0",
|
|
53
56
|
"tsc-alias": "^1.4.1",
|
|
54
57
|
"tsconfig-paths": "^3.10.1",
|