joye-backend-utility 4.1.22-test10 → 4.1.22-test11
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 +8 -1
- package/package.json +1 -1
package/dist/jwt.js
CHANGED
|
@@ -9,9 +9,16 @@ const path = require('path');
|
|
|
9
9
|
const folderPath = path.resolve(`${__dirname}`);
|
|
10
10
|
// const JWT_PRIVATE_KEY = fs.readFileSync(`${folderPath}/jwt-keys/jwtRS256.key`, 'utf8');
|
|
11
11
|
// const JWT_PUBLIC_KEY = fs.readFileSync(`${folderPath}/jwt-keys/jwtRS256.key.pub`, 'utf8');
|
|
12
|
-
|
|
12
|
+
let JWT_PRIVATE_KEY = '';
|
|
13
13
|
const JWT_PUBLIC_KEY = '';
|
|
14
14
|
const createToken = async (payload, expiresIn) => {
|
|
15
|
+
try {
|
|
16
|
+
JWT_PRIVATE_KEY = fs.readFileSync(`${folderPath}/jwt-keys/jwtRS256.key`, 'utf8');
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.log('**** Err', err);
|
|
20
|
+
return err;
|
|
21
|
+
}
|
|
15
22
|
const token = jwt.sign(payload, { key: JWT_PRIVATE_KEY.replace(/\\n/gm, '\n'), passphrase: '64d5f73bb3f132821122d68330263edd44023810a1f05efb701fc7ec8d0f6382' }, {
|
|
16
23
|
expiresIn,
|
|
17
24
|
algorithm: 'RS256',
|