aboutsummaryrefslogtreecommitdiffstats
path: root/backend/node_modules/jsonwebtoken/lib
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-25 12:09:28 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-07-25 12:09:28 +0530
commitc00ac1ff51c795d4d93c32e0a913e2cebf917d0c (patch)
tree0b5f59a0167b6169426648c383082dbbb3b4f2c7 /backend/node_modules/jsonwebtoken/lib
parentc796d53d2f2391e4f4a075b243cc2c50db38d7da (diff)
downloadadmin-panel-c00ac1ff51c795d4d93c32e0a913e2cebf917d0c.tar.gz
admin-panel-c00ac1ff51c795d4d93c32e0a913e2cebf917d0c.tar.bz2
admin-panel-c00ac1ff51c795d4d93c32e0a913e2cebf917d0c.zip
added backend and login portal
Diffstat (limited to 'backend/node_modules/jsonwebtoken/lib')
-rw-r--r--backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js14
-rw-r--r--backend/node_modules/jsonwebtoken/lib/NotBeforeError.js13
-rw-r--r--backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js13
-rw-r--r--backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js3
-rw-r--r--backend/node_modules/jsonwebtoken/lib/psSupported.js3
-rw-r--r--backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js3
-rw-r--r--backend/node_modules/jsonwebtoken/lib/timespan.js18
-rw-r--r--backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js66
8 files changed, 133 insertions, 0 deletions
diff --git a/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js b/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js
new file mode 100644
index 0000000..e068222
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js
@@ -0,0 +1,14 @@
+var JsonWebTokenError = function (message, error) {
+ Error.call(this, message);
+ if(Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+ this.name = 'JsonWebTokenError';
+ this.message = message;
+ if (error) this.inner = error;
+};
+
+JsonWebTokenError.prototype = Object.create(Error.prototype);
+JsonWebTokenError.prototype.constructor = JsonWebTokenError;
+
+module.exports = JsonWebTokenError;
diff --git a/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js b/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js
new file mode 100644
index 0000000..7b30084
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js
@@ -0,0 +1,13 @@
+var JsonWebTokenError = require('./JsonWebTokenError');
+
+var NotBeforeError = function (message, date) {
+ JsonWebTokenError.call(this, message);
+ this.name = 'NotBeforeError';
+ this.date = date;
+};
+
+NotBeforeError.prototype = Object.create(JsonWebTokenError.prototype);
+
+NotBeforeError.prototype.constructor = NotBeforeError;
+
+module.exports = NotBeforeError; \ No newline at end of file
diff --git a/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js b/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js
new file mode 100644
index 0000000..abb704f
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js
@@ -0,0 +1,13 @@
+var JsonWebTokenError = require('./JsonWebTokenError');
+
+var TokenExpiredError = function (message, expiredAt) {
+ JsonWebTokenError.call(this, message);
+ this.name = 'TokenExpiredError';
+ this.expiredAt = expiredAt;
+};
+
+TokenExpiredError.prototype = Object.create(JsonWebTokenError.prototype);
+
+TokenExpiredError.prototype.constructor = TokenExpiredError;
+
+module.exports = TokenExpiredError; \ No newline at end of file
diff --git a/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js b/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js
new file mode 100644
index 0000000..a6ede56
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js
@@ -0,0 +1,3 @@
+const semver = require('semver');
+
+module.exports = semver.satisfies(process.version, '>=15.7.0');
diff --git a/backend/node_modules/jsonwebtoken/lib/psSupported.js b/backend/node_modules/jsonwebtoken/lib/psSupported.js
new file mode 100644
index 0000000..8c04144
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/psSupported.js
@@ -0,0 +1,3 @@
+var semver = require('semver');
+
+module.exports = semver.satisfies(process.version, '^6.12.0 || >=8.0.0');
diff --git a/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js b/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js
new file mode 100644
index 0000000..7fcf368
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js
@@ -0,0 +1,3 @@
+const semver = require('semver');
+
+module.exports = semver.satisfies(process.version, '>=16.9.0');
diff --git a/backend/node_modules/jsonwebtoken/lib/timespan.js b/backend/node_modules/jsonwebtoken/lib/timespan.js
new file mode 100644
index 0000000..e509869
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/timespan.js
@@ -0,0 +1,18 @@
+var ms = require('ms');
+
+module.exports = function (time, iat) {
+ var timestamp = iat || Math.floor(Date.now() / 1000);
+
+ if (typeof time === 'string') {
+ var milliseconds = ms(time);
+ if (typeof milliseconds === 'undefined') {
+ return;
+ }
+ return Math.floor(timestamp + milliseconds / 1000);
+ } else if (typeof time === 'number') {
+ return timestamp + time;
+ } else {
+ return;
+ }
+
+}; \ No newline at end of file
diff --git a/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js b/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js
new file mode 100644
index 0000000..c10340b
--- /dev/null
+++ b/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js
@@ -0,0 +1,66 @@
+const ASYMMETRIC_KEY_DETAILS_SUPPORTED = require('./asymmetricKeyDetailsSupported');
+const RSA_PSS_KEY_DETAILS_SUPPORTED = require('./rsaPssKeyDetailsSupported');
+
+const allowedAlgorithmsForKeys = {
+ 'ec': ['ES256', 'ES384', 'ES512'],
+ 'rsa': ['RS256', 'PS256', 'RS384', 'PS384', 'RS512', 'PS512'],
+ 'rsa-pss': ['PS256', 'PS384', 'PS512']
+};
+
+const allowedCurves = {
+ ES256: 'prime256v1',
+ ES384: 'secp384r1',
+ ES512: 'secp521r1',
+};
+
+module.exports = function(algorithm, key) {
+ if (!algorithm || !key) return;
+
+ const keyType = key.asymmetricKeyType;
+ if (!keyType) return;
+
+ const allowedAlgorithms = allowedAlgorithmsForKeys[keyType];
+
+ if (!allowedAlgorithms) {
+ throw new Error(`Unknown key type "${keyType}".`);
+ }
+
+ if (!allowedAlgorithms.includes(algorithm)) {
+ throw new Error(`"alg" parameter for "${keyType}" key type must be one of: ${allowedAlgorithms.join(', ')}.`)
+ }
+
+ /*
+ * Ignore the next block from test coverage because it gets executed
+ * conditionally depending on the Node version. Not ignoring it would
+ * prevent us from reaching the target % of coverage for versions of
+ * Node under 15.7.0.
+ */
+ /* istanbul ignore next */
+ if (ASYMMETRIC_KEY_DETAILS_SUPPORTED) {
+ switch (keyType) {
+ case 'ec':
+ const keyCurve = key.asymmetricKeyDetails.namedCurve;
+ const allowedCurve = allowedCurves[algorithm];
+
+ if (keyCurve !== allowedCurve) {
+ throw new Error(`"alg" parameter "${algorithm}" requires curve "${allowedCurve}".`);
+ }
+ break;
+
+ case 'rsa-pss':
+ if (RSA_PSS_KEY_DETAILS_SUPPORTED) {
+ const length = parseInt(algorithm.slice(-3), 10);
+ const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = key.asymmetricKeyDetails;
+
+ if (hashAlgorithm !== `sha${length}` || mgf1HashAlgorithm !== hashAlgorithm) {
+ throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${algorithm}.`);
+ }
+
+ if (saltLength !== undefined && saltLength > length >> 3) {
+ throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${algorithm}.`)
+ }
+ }
+ break;
+ }
+ }
+}