@sdflc/backend-helpers 1.0.47 → 1.0.50
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/build/BaseController.js +21 -62
- package/build/BaseCore.d.ts +2 -2
- package/build/BaseCore.js +425 -690
- package/build/BaseGateway.js +350 -554
- package/build/DataCache.js +47 -98
- package/build/Database.js +104 -177
- package/build/DbMigratorAndSeeder.js +131 -238
- package/build/apiContext.js +102 -191
- package/build/checkItHelpers.js +10 -10
- package/build/commonValidators.js +49 -91
- package/build/configBulder.js +8 -19
- package/build/constants.js +3 -3
- package/build/dbHelpers.js +72 -126
- package/build/dbSeeder.js +38 -90
- package/build/dbTableHelpers.js +25 -26
- package/build/interfaces/CoreActionInterface.d.ts +2 -1
- package/build/knexConfigBuilder.js +17 -28
- package/build/passwordHelpers.js +13 -59
- package/build/redisClient.d.ts +1 -0
- package/build/redisClient.js +50 -84
- package/build/resolversHelpers.js +17 -27
- package/build/userToken.js +24 -24
- package/build/utils.js +4 -5
- package/package.json +32 -34
package/build/passwordHelpers.js
CHANGED
|
@@ -8,69 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
15
|
exports.checkPassword = exports.getSaltAndHash = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
salt = _a.sent();
|
|
53
|
-
return [4 /*yield*/, bcrypt_1.default.hash(password, salt)];
|
|
54
|
-
case 2:
|
|
55
|
-
hash = _a.sent();
|
|
56
|
-
return [2 /*return*/, {
|
|
57
|
-
salt: salt,
|
|
58
|
-
hash: hash,
|
|
59
|
-
}];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
};
|
|
16
|
+
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
17
|
+
const getSaltAndHash = (password, saltRounds = 10) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const salt = yield bcrypt_1.default.genSalt(saltRounds);
|
|
19
|
+
const hash = yield bcrypt_1.default.hash(password, salt);
|
|
20
|
+
return {
|
|
21
|
+
salt,
|
|
22
|
+
hash,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
64
25
|
exports.getSaltAndHash = getSaltAndHash;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
case 0: return [4 /*yield*/, bcrypt_1.default.compare(password, hashedPassword)];
|
|
70
|
-
case 1:
|
|
71
|
-
isCorrect = _a.sent();
|
|
72
|
-
return [2 /*return*/, isCorrect];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}); };
|
|
26
|
+
const checkPassword = (password, hashedPassword) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
const isCorrect = yield bcrypt_1.default.compare(password, hashedPassword);
|
|
28
|
+
return isCorrect;
|
|
29
|
+
});
|
|
76
30
|
exports.checkPassword = checkPassword;
|
package/build/redisClient.d.ts
CHANGED
package/build/redisClient.js
CHANGED
|
@@ -1,98 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
6
|
exports.createRedisClient = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var _a = args || {}, redisHost = _a.redisHost, redisPort = _a.redisPort, redisPassword = _a.redisPassword, redisSsl = _a.redisSsl, retryAttempts = _a.retryAttempts, firstTimeout = _a.firstTimeout, pingInterval = _a.pingInterval;
|
|
7
|
+
const redis_1 = __importDefault(require("redis"));
|
|
8
|
+
// const DEFAULT_RETRY_ATTEMPTS = 10;
|
|
9
|
+
// const DEFAULT_FIRST_TIMEOUT = 3000;
|
|
10
|
+
const createRedisClient = (args) => {
|
|
11
|
+
const { redisHost, redisPort, redisPassword, redisSsl,
|
|
12
|
+
//retryAttempts,
|
|
13
|
+
//firstTimeout,
|
|
14
|
+
pingInterval, connectionTimeout, } = args || {};
|
|
52
15
|
if (!redisHost) {
|
|
53
16
|
return null;
|
|
54
17
|
}
|
|
55
|
-
|
|
56
|
-
host: redisHost,
|
|
57
|
-
port: Number(redisPort),
|
|
18
|
+
const newRedisClient = redis_1.default.createClient({
|
|
19
|
+
socket: Object.assign(Object.assign({ host: redisHost, port: Number(redisPort), family: 0, connectTimeout: connectionTimeout != undefined ? connectionTimeout : 5000, noDelay: true, keepAlive: pingInterval != undefined ? pingInterval : 5000 }, (redisSsl && { tls: true })), { rejectUnauthorized: false, reconnectStrategy: (retries) => Math.min(retries * 50, 500) }),
|
|
58
20
|
password: redisPassword || undefined,
|
|
59
|
-
no_ready_check: true,
|
|
60
|
-
retry_strategy: function (options) {
|
|
61
|
-
if (options.error && options.error.code === 'ECONNREFUSED') {
|
|
62
|
-
// End reconnecting on a specific error and flush all commands with
|
|
63
|
-
// a individual error
|
|
64
|
-
return new Error('The server refused the connection');
|
|
65
|
-
}
|
|
66
|
-
if (options.total_retry_time > 1000 * 60 * 60) {
|
|
67
|
-
// End reconnecting after a specific timeout and flush all commands
|
|
68
|
-
// with a individual error
|
|
69
|
-
return new Error('Retry time exhausted');
|
|
70
|
-
}
|
|
71
|
-
var attempts = !retryAttempts || retryAttempts == null || isNaN(retryAttempts)
|
|
72
|
-
? DEFAULT_RETRY_ATTEMPTS
|
|
73
|
-
: Number(retryAttempts);
|
|
74
|
-
if (options.attempt > attempts) {
|
|
75
|
-
// End reconnecting with built in error
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
var timeout = !firstTimeout || firstTimeout == null || isNaN(firstTimeout) ? DEFAULT_FIRST_TIMEOUT : Number(firstTimeout);
|
|
79
|
-
// reconnect after
|
|
80
|
-
return Math.min(options.attempt * 100, timeout);
|
|
81
|
-
},
|
|
82
|
-
tls: redisSsl
|
|
83
|
-
? {
|
|
84
|
-
servername: redisHost,
|
|
85
|
-
}
|
|
86
|
-
: undefined,
|
|
87
21
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
22
|
+
// const newRedisClientOld = redis.createClient({
|
|
23
|
+
// host: redisHost,
|
|
24
|
+
// port: Number(redisPort),
|
|
25
|
+
// password: redisPassword || undefined,
|
|
26
|
+
// no_ready_check: true,
|
|
27
|
+
// retry_strategy: function (options) {
|
|
28
|
+
// if (options.error && options.error.code === 'ECONNREFUSED') {
|
|
29
|
+
// // End reconnecting on a specific error and flush all commands with
|
|
30
|
+
// // a individual error
|
|
31
|
+
// return new Error('The server refused the connection');
|
|
32
|
+
// }
|
|
33
|
+
// if (options.total_retry_time > 1000 * 60 * 60) {
|
|
34
|
+
// // End reconnecting after a specific timeout and flush all commands
|
|
35
|
+
// // with a individual error
|
|
36
|
+
// return new Error('Retry time exhausted');
|
|
37
|
+
// }
|
|
38
|
+
// const attempts =
|
|
39
|
+
// !retryAttempts || retryAttempts == null || isNaN(retryAttempts)
|
|
40
|
+
// ? DEFAULT_RETRY_ATTEMPTS
|
|
41
|
+
// : Number(retryAttempts);
|
|
42
|
+
// if (options.attempt > attempts) {
|
|
43
|
+
// // End reconnecting with built in error
|
|
44
|
+
// return undefined;
|
|
45
|
+
// }
|
|
46
|
+
// const timeout =
|
|
47
|
+
// !firstTimeout || firstTimeout == null || isNaN(firstTimeout) ? DEFAULT_FIRST_TIMEOUT : Number(firstTimeout);
|
|
48
|
+
// // reconnect after
|
|
49
|
+
// return Math.min(options.attempt * 100, timeout);
|
|
50
|
+
// },
|
|
51
|
+
// tls: redisSsl
|
|
52
|
+
// ? {
|
|
53
|
+
// servername: redisHost,
|
|
54
|
+
// }
|
|
55
|
+
// : undefined,
|
|
56
|
+
// });
|
|
57
|
+
// if (pingInterval && !isNaN(pingInterval) && pingInterval > 1000) {
|
|
58
|
+
// setInterval(async () => {
|
|
59
|
+
// newRedisClient.ping();
|
|
60
|
+
// }, pingInterval);
|
|
61
|
+
// }
|
|
96
62
|
return newRedisClient;
|
|
97
63
|
};
|
|
98
64
|
exports.createRedisClient = createRedisClient;
|
|
@@ -1,72 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.buildDefaultResolvers = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
const buildDefaultResolvers = (args) => {
|
|
5
|
+
const { prefix, core, query, mutation, types, disableList, disableGet, disableGetMany, disableCreate, disableCreateMany, disableUpdate, disableUpdateMany, disableSet, disableRemove, disableRemoveMany, } = args || {};
|
|
6
|
+
const Query = Object.assign({}, (query || {}));
|
|
7
|
+
const Mutation = Object.assign({}, (mutation || {}));
|
|
8
|
+
const coreToUse = core || `${prefix}Core`;
|
|
20
9
|
if (disableList !== true) {
|
|
21
|
-
Query[
|
|
10
|
+
Query[`${prefix}List`] = (parent, args, context) => {
|
|
22
11
|
return context.cores[coreToUse].list(args);
|
|
23
12
|
};
|
|
24
13
|
}
|
|
25
14
|
if (disableGet !== true) {
|
|
26
|
-
Query[
|
|
15
|
+
Query[`${prefix}Get`] = (parent, args, context) => {
|
|
27
16
|
return context.cores[coreToUse].get(args);
|
|
28
17
|
};
|
|
29
18
|
}
|
|
30
19
|
if (disableGetMany !== true) {
|
|
31
|
-
Query[
|
|
20
|
+
Query[`${prefix}GetMany`] = (parent, args, context) => {
|
|
32
21
|
return context.cores[coreToUse].getMany(args);
|
|
33
22
|
};
|
|
34
23
|
}
|
|
35
24
|
if (disableCreate !== true) {
|
|
36
|
-
Mutation[
|
|
25
|
+
Mutation[`${prefix}Create`] = (parent, args, context) => {
|
|
37
26
|
return context.cores[coreToUse].create(args);
|
|
38
27
|
};
|
|
39
28
|
}
|
|
40
29
|
if (disableCreateMany !== true) {
|
|
41
|
-
Mutation[
|
|
30
|
+
Mutation[`${prefix}CreateMany`] = (parent, args, context) => {
|
|
42
31
|
return context.cores[coreToUse].createMany(args);
|
|
43
32
|
};
|
|
44
33
|
}
|
|
45
34
|
if (disableUpdate !== true) {
|
|
46
|
-
Mutation[
|
|
35
|
+
Mutation[`${prefix}Update`] = (parent, args, context) => {
|
|
47
36
|
return context.cores[coreToUse].update(args);
|
|
48
37
|
};
|
|
49
38
|
}
|
|
50
39
|
if (disableUpdateMany !== true) {
|
|
51
|
-
Mutation[
|
|
40
|
+
Mutation[`${prefix}UpdateMany`] = (parent, args, context) => {
|
|
52
41
|
return context.cores[coreToUse].updateMany(args);
|
|
53
42
|
};
|
|
54
43
|
}
|
|
55
44
|
if (disableSet !== true) {
|
|
56
|
-
Mutation[
|
|
45
|
+
Mutation[`${prefix}Set`] = (parent, args, context) => {
|
|
57
46
|
return context.cores[coreToUse].set(args);
|
|
58
47
|
};
|
|
59
48
|
}
|
|
60
49
|
if (disableRemove !== true) {
|
|
61
|
-
Mutation[
|
|
50
|
+
Mutation[`${prefix}Remove`] = (parent, args, context) => {
|
|
62
51
|
return context.cores[coreToUse].remove(args);
|
|
63
52
|
};
|
|
64
53
|
}
|
|
65
54
|
if (disableRemoveMany !== true) {
|
|
66
|
-
Mutation[
|
|
55
|
+
Mutation[`${prefix}RemoveMany`] = (parent, args, context) => {
|
|
67
56
|
return context.cores[coreToUse].removeMany(args);
|
|
68
57
|
};
|
|
69
58
|
}
|
|
70
|
-
return
|
|
59
|
+
return Object.assign({ Query,
|
|
60
|
+
Mutation }, (types || {}));
|
|
71
61
|
};
|
|
72
62
|
exports.buildDefaultResolvers = buildDefaultResolvers;
|
package/build/userToken.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
+
const token = jsonwebtoken_1.default.sign(params, secret, {
|
|
15
15
|
algorithm: algorithm || 'HS256',
|
|
16
|
-
audience
|
|
17
|
-
issuer
|
|
18
|
-
jwtid
|
|
19
|
-
subject
|
|
20
|
-
noTimestamp
|
|
21
|
-
header
|
|
22
|
-
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
34
|
+
const obj = jsonwebtoken_1.default.verify(token, secret, {
|
|
35
35
|
algorithms: algorithms || ['HS256'],
|
|
36
|
-
audience
|
|
37
|
-
issuer
|
|
38
|
-
ignoreExpiration
|
|
39
|
-
ignoreNotBefore
|
|
40
|
-
subject
|
|
41
|
-
clockTolerance
|
|
42
|
-
maxAge
|
|
43
|
-
clockTimestamp
|
|
44
|
-
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
|
-
|
|
4
|
+
const setFunction = (func, defaultFunc) => {
|
|
5
5
|
return typeof func === 'function' ? func : defaultFunc;
|
|
6
6
|
};
|
|
7
7
|
exports.setFunction = setFunction;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.
|
|
3
|
+
"version": "1.0.50",
|
|
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,45 @@
|
|
|
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.
|
|
53
|
-
"@sdflc/utils": "^1.0.
|
|
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.
|
|
32
|
+
"dayjs": "^1.11.0",
|
|
59
33
|
"dotenv-safe": "^8.2.0",
|
|
34
|
+
"jest": "^27.5.1",
|
|
60
35
|
"jsonwebtoken": "^8.5.1",
|
|
61
|
-
"knex": "^0.
|
|
62
|
-
"lodash": "^4.17.
|
|
36
|
+
"knex": "^1.0.5",
|
|
37
|
+
"lodash": "^4.17.21",
|
|
63
38
|
"pg": "^8.7.3",
|
|
64
|
-
"redis": "^
|
|
39
|
+
"redis": "^4.0.6",
|
|
65
40
|
"redis-dataloader": "^1.0.2",
|
|
66
|
-
"
|
|
41
|
+
"rimraf": "^3.0.2",
|
|
42
|
+
"uuid": "^8.3.2",
|
|
43
|
+
"typescript": "^4.6.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/bcrypt": "^5.0.0",
|
|
47
|
+
"@types/bluebird": "^3.5.36",
|
|
48
|
+
"@types/dotenv-safe": "^8.1.2",
|
|
49
|
+
"@types/jsonwebtoken": "^8.5.8",
|
|
50
|
+
"@types/lodash": "^4.14.181",
|
|
51
|
+
"@types/node": "^14.18.12",
|
|
52
|
+
"@types/redis": "^4.0.11",
|
|
53
|
+
"@types/uuid": "^8.3.4",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.19.0",
|
|
55
|
+
"@typescript-eslint/parser": "^5.19.0",
|
|
56
|
+
"eslint": "^8.13.0",
|
|
57
|
+
"eslint-config-prettier": "^8.5.0",
|
|
58
|
+
"eslint-plugin-jest": "^24.7.0",
|
|
59
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
60
|
+
"husky": "^7.0.4",
|
|
61
|
+
"prettier": "^2.6.2",
|
|
62
|
+
"run-script-os": "^1.1.6",
|
|
63
|
+
"ts-jest": "^27.1.4",
|
|
64
|
+
"ts-node": "^10.7.0"
|
|
67
65
|
}
|
|
68
66
|
}
|