joye-backend-utility 4.1.21 → 4.1.22-test

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 CHANGED
@@ -2,17 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jwtVerify = exports.createToken = void 0;
4
4
  const jwt = require('jsonwebtoken');
5
- const JWT_SECRET = '3s6v9y$B&E)H+MbQeThWmZq4t7w!z%C*F-JaNcRfUjXn2r5u8x/A?D(G+KbPeSgV';
5
+ const fs_1 = require("fs");
6
+ // const JWT_SECRET = '3s6v9y$B&E)H+MbQeThWmZq4t7w!z%C*F-JaNcRfUjXn2r5u8x/A?D(G+KbPeSgV';
7
+ const JWT_SECRET = '64d5f73bb3f132821122d68330263edd44023810a1f05efb701fc7ec8d0f6382';
8
+ const JWT_PRIVATE_KEY = fs_1.default.readFileSync(`jwt-keys/jwtRS256.key`, 'utf8');
9
+ const JWT_PUBLIC_KEY = fs_1.default.readFileSync(`jwt-keys/jwtRS256.key.pub`, 'utf8');
6
10
  const createToken = async (payload, expiresIn) => {
7
- const token = jwt.sign(payload, process.env.JWT_SECRET || JWT_SECRET, {
11
+ const token = jwt.sign(payload, { key: JWT_PRIVATE_KEY.replace(/\\n/gm, '\n'), passphrase: JWT_SECRET }, {
8
12
  expiresIn,
9
- algorithm: 'HS256',
13
+ algorithm: 'RS256',
10
14
  });
11
15
  return token;
12
16
  };
13
17
  exports.createToken = createToken;
14
18
  const jwtVerify = async (token) => new Promise(resolve => {
15
- jwt.verify(token, process.env.JWT_SECRET || JWT_SECRET, async (err, decoded) => {
19
+ jwt.verify(token, JWT_PUBLIC_KEY.replace(/\\n/gm, '\n'), async (err, decoded) => {
16
20
  if (err) {
17
21
  return resolve(err);
18
22
  }
@@ -138,5 +138,9 @@ const User = new mongoose_1.Schema({
138
138
  type: Number,
139
139
  required: false,
140
140
  },
141
+ lastRecommendationCategory: {
142
+ type: String,
143
+ required: false,
144
+ },
141
145
  });
142
146
  exports.UserSchema = User;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joye-backend-utility",
3
- "version": "4.1.21",
3
+ "version": "4.1.22-test",
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",
@@ -31,6 +31,7 @@
31
31
  "dependencies": {
32
32
  "bcrypt": "^5.0.1",
33
33
  "dotenv": "^16.0.0",
34
+ "fs": "^0.0.1-security",
34
35
  "jsonwebtoken": "^9.0.0",
35
36
  "moment": "^2.29.3",
36
37
  "mongoose": "^5.10.1",