Skip to content

Commit b36f737

Browse files
authored
fix(deps): remove lodash dependencies
1 parent cf33b5f commit b36f737

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@
3838
},
3939
"dependencies": {
4040
"jws": "^4.0.1",
41-
"lodash.includes": "^4.3.0",
42-
"lodash.isboolean": "^3.0.3",
43-
"lodash.isinteger": "^4.0.4",
44-
"lodash.isnumber": "^3.0.3",
45-
"lodash.isplainobject": "^4.0.6",
46-
"lodash.isstring": "^4.0.1",
4741
"lodash.once": "^4.0.0",
4842
"ms": "^2.1.1",
4943
"semver": "^7.5.4"

sign.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ const timespan = require('./lib/timespan');
22
const PS_SUPPORTED = require('./lib/psSupported');
33
const validateAsymmetricKey = require('./lib/validateAsymmetricKey');
44
const jws = require('jws');
5-
const includes = require('lodash.includes');
6-
const isBoolean = require('lodash.isboolean');
7-
const isInteger = require('lodash.isinteger');
8-
const isNumber = require('lodash.isnumber');
9-
const isPlainObject = require('lodash.isplainobject');
10-
const isString = require('lodash.isstring');
5+
116
const once = require('lodash.once');
127
const { KeyObject, createSecretKey, createPrivateKey } = require('crypto')
138

@@ -16,11 +11,22 @@ if (PS_SUPPORTED) {
1611
SUPPORTED_ALGS.splice(3, 0, 'PS256', 'PS384', 'PS512');
1712
}
1813

14+
const isBoolean = (value) => value === true || value === false;
15+
const isNumber = (value) => typeof value === 'number';
16+
const isString = (value) => typeof value === 'string';
17+
18+
function isPlainObject(obj) {
19+
if (!obj) return false;
20+
if (typeof obj !== "object") return false;
21+
const proto = Object.getPrototypeOf(obj);
22+
return (proto === null || proto === Object.prototype);
23+
}
24+
1925
const sign_options_schema = {
20-
expiresIn: { isValid: function(value) { return isInteger(value) || (isString(value) && value); }, message: '"expiresIn" should be a number of seconds or string representing a timespan' },
21-
notBefore: { isValid: function(value) { return isInteger(value) || (isString(value) && value); }, message: '"notBefore" should be a number of seconds or string representing a timespan' },
26+
expiresIn: { isValid: function(value) { return Number.isInteger(value) || (isString(value) && value); }, message: '"expiresIn" should be a number of seconds or string representing a timespan' },
27+
notBefore: { isValid: function(value) { return Number.isInteger(value) || (isString(value) && value); }, message: '"notBefore" should be a number of seconds or string representing a timespan' },
2228
audience: { isValid: function(value) { return isString(value) || Array.isArray(value); }, message: '"audience" must be a string or array' },
23-
algorithm: { isValid: includes.bind(null, SUPPORTED_ALGS), message: '"algorithm" must be a valid string enum value' },
29+
algorithm: { isValid: (val) => SUPPORTED_ALGS.includes(val), message: '"algorithm" must be a valid string enum value' },
2430
header: { isValid: isPlainObject, message: '"header" must be an object' },
2531
encoding: { isValid: isString, message: '"encoding" must be a string' },
2632
issuer: { isValid: isString, message: '"issuer" must be a string' },

0 commit comments

Comments
 (0)