@sdflc/backend-helpers 1.0.48 → 1.0.51

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.
@@ -4,44 +4,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.verifyUserToken = exports.createUserToken = void 0;
7
- var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
- var api_helpers_1 = require("@sdflc/api-helpers");
9
- var createUserToken = function (params, secret, opt) {
10
- var _a = opt || {}, algorithm = _a.algorithm, audience = _a.audience, issuer = _a.issuer, jwtid = _a.jwtid, subject = _a.subject, noTimestamp = _a.noTimestamp, header = _a.header, keyid = _a.keyid, expiresIn = _a.expiresIn;
7
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
+ const api_helpers_1 = require("@sdflc/api-helpers");
9
+ const createUserToken = (params, secret, opt) => {
10
+ const { algorithm, audience, issuer, jwtid, subject, noTimestamp, header, keyid, expiresIn } = opt || {};
11
11
  if (!params || !secret) {
12
12
  return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED, null, 'Failed to create user JWT');
13
13
  }
14
- var token = jsonwebtoken_1.default.sign(params, secret, {
14
+ const token = jsonwebtoken_1.default.sign(params, secret, {
15
15
  algorithm: algorithm || 'HS256',
16
- audience: audience,
17
- issuer: issuer,
18
- jwtid: jwtid,
19
- subject: subject,
20
- noTimestamp: noTimestamp,
21
- header: header,
22
- keyid: keyid,
16
+ audience,
17
+ issuer,
18
+ jwtid,
19
+ subject,
20
+ noTimestamp,
21
+ header,
22
+ keyid,
23
23
  expiresIn: expiresIn && !isNaN(expiresIn) ? expiresIn : undefined,
24
24
  });
25
25
  return api_helpers_1.OpResult.ok(token);
26
26
  };
27
27
  exports.createUserToken = createUserToken;
28
- var verifyUserToken = function (token, secret, args) {
29
- var _a = args || {}, algorithms = _a.algorithms, audience = _a.audience, issuer = _a.issuer, ignoreExpiration = _a.ignoreExpiration, ignoreNotBefore = _a.ignoreNotBefore, subject = _a.subject, clockTolerance = _a.clockTolerance, maxAge = _a.maxAge, clockTimestamp = _a.clockTimestamp, nonce = _a.nonce;
28
+ const verifyUserToken = (token, secret, args) => {
29
+ const { algorithms, audience, issuer, ignoreExpiration, ignoreNotBefore, subject, clockTolerance, maxAge, clockTimestamp, nonce, } = args || {};
30
30
  if (!args) {
31
31
  return api_helpers_1.OpResult.fail(api_helpers_1.OP_RESULT_CODES.VALIDATION_FAILED, null, 'Cannot verify user token as there are no parameters specified');
32
32
  }
33
33
  try {
34
- var obj = jsonwebtoken_1.default.verify(token, secret, {
34
+ const obj = jsonwebtoken_1.default.verify(token, secret, {
35
35
  algorithms: algorithms || ['HS256'],
36
- audience: audience,
37
- issuer: issuer,
38
- ignoreExpiration: ignoreExpiration,
39
- ignoreNotBefore: ignoreNotBefore,
40
- subject: subject,
41
- clockTolerance: clockTolerance,
42
- maxAge: maxAge,
43
- clockTimestamp: clockTimestamp,
44
- nonce: nonce,
36
+ audience,
37
+ issuer,
38
+ ignoreExpiration,
39
+ ignoreNotBefore,
40
+ subject,
41
+ clockTolerance,
42
+ maxAge,
43
+ clockTimestamp,
44
+ nonce,
45
45
  });
46
46
  return api_helpers_1.OpResult.ok(obj);
47
47
  }
package/build/utils.js CHANGED
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setFunctions = exports.setFunction = void 0;
4
- var setFunction = function (func, defaultFunc) {
4
+ const setFunction = (func, defaultFunc) => {
5
5
  return typeof func === 'function' ? func : defaultFunc;
6
6
  };
7
7
  exports.setFunction = setFunction;
8
- var setFunctions = function (obj, defaultFuncs) {
9
- if (defaultFuncs === void 0) { defaultFuncs = {}; }
10
- var keys = Object.keys(defaultFuncs || {});
11
- return keys.reduce(function (acc, key) {
8
+ const setFunctions = (obj, defaultFuncs = {}) => {
9
+ const keys = Object.keys(defaultFuncs || {});
10
+ return keys.reduce((acc, key) => {
12
11
  if (typeof obj[key] === 'function') {
13
12
  acc[key] = obj[key];
14
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.48",
3
+ "version": "1.0.51",
4
4
  "description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -22,47 +22,46 @@
22
22
  },
23
23
  "author": "Sergey Demidenko",
24
24
  "license": "ISC",
25
- "devDependencies": {
26
- "@types/bcrypt": "^5.0.0",
27
- "@types/bluebird": "^3.5.36",
28
- "@types/dotenv-safe": "^8.1.2",
29
- "@types/jest": "^26.0.24",
30
- "@types/jsonwebtoken": "^8.5.8",
31
- "@types/lodash": "^4.14.179",
32
- "@types/node": "^14.18.12",
33
- "@types/redis": "^2.8.32",
34
- "@types/uuid": "^8.3.4",
35
- "@typescript-eslint/eslint-plugin": "^4.33.0",
36
- "@typescript-eslint/parser": "^4.33.0",
37
- "eslint": "^7.32.0",
38
- "eslint-config-prettier": "^6.15.0",
39
- "eslint-plugin-jest": "^24.7.0",
40
- "eslint-plugin-prettier": "^3.4.1",
41
- "eslint-plugin-react": "^7.29.1",
42
- "husky": "^6.0.0",
43
- "jest": "^26.6.3",
44
- "prettier": "^2.5.1",
45
- "rimraf": "^3.0.2",
46
- "run-script-os": "^1.1.3",
47
- "ts-jest": "^26.4.4",
48
- "ts-node": "^9.0.0",
49
- "typescript": "^4.5.5"
50
- },
51
25
  "dependencies": {
52
- "@sdflc/api-helpers": "^1.1.8",
53
- "@sdflc/utils": "^1.0.19",
26
+ "@sdflc/api-helpers": "^1.1.9",
27
+ "@sdflc/utils": "^1.0.20",
54
28
  "bcrypt": "^5.0.1",
55
29
  "bluebird": "^3.7.2",
56
30
  "checkit": "^0.7.0",
57
31
  "dataloader": "^2.0.0",
58
- "dayjs": "^1.10.7",
32
+ "dayjs": "^1.11.0",
59
33
  "dotenv-safe": "^8.2.0",
34
+ "jest": "^27.5.1",
35
+ "json-stable-stringify": "^1.0.1",
60
36
  "jsonwebtoken": "^8.5.1",
61
- "knex": "^0.95.15",
62
- "lodash": "^4.17.20",
37
+ "knex": "^1.0.5",
38
+ "lodash": "^4.17.21",
63
39
  "pg": "^8.7.3",
64
- "redis": "^3.1.2",
65
- "redis-dataloader": "^1.0.2",
40
+ "redis": "^4.0.6",
41
+ "rimraf": "^3.0.2",
42
+ "typescript": "^4.6.3",
66
43
  "uuid": "^8.3.2"
44
+ },
45
+ "devDependencies": {
46
+ "@types/bcrypt": "^5.0.0",
47
+ "@types/bluebird": "^3.5.36",
48
+ "@types/dotenv-safe": "^8.1.2",
49
+ "@types/json-stable-stringify": "^1.0.34",
50
+ "@types/jsonwebtoken": "^8.5.8",
51
+ "@types/lodash": "^4.14.181",
52
+ "@types/node": "^14.18.12",
53
+ "@types/redis": "^4.0.11",
54
+ "@types/uuid": "^8.3.4",
55
+ "@typescript-eslint/eslint-plugin": "^5.19.0",
56
+ "@typescript-eslint/parser": "^5.19.0",
57
+ "eslint": "^8.13.0",
58
+ "eslint-config-prettier": "^8.5.0",
59
+ "eslint-plugin-jest": "^24.7.0",
60
+ "eslint-plugin-prettier": "^4.0.0",
61
+ "husky": "^7.0.4",
62
+ "prettier": "^2.6.2",
63
+ "run-script-os": "^1.1.6",
64
+ "ts-jest": "^27.1.4",
65
+ "ts-node": "^10.7.0"
67
66
  }
68
67
  }