@devmoods/express-extras 0.28.5 → 0.28.7
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/auth.js +6 -2
- package/dist/middleware.js +1 -0
- package/package.json +2 -2
package/dist/auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as crypto from 'node:crypto';
|
|
2
|
-
import
|
|
2
|
+
import bcrypt from 'bcrypt';
|
|
3
3
|
import { Router, } from 'express';
|
|
4
|
-
import
|
|
4
|
+
import jwt from 'jsonwebtoken';
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
6
|
import { setContext, useContext } from './context.js';
|
|
7
7
|
import { BadRequest, NotFound, Unauthorized } from './errors.js';
|
|
@@ -25,6 +25,7 @@ const emailSchema = { type: 'string', minLength: 4 };
|
|
|
25
25
|
* Returns a signed JWT token.
|
|
26
26
|
*/
|
|
27
27
|
export function createAuthToken(payload, secret = AUTH_SECRET) {
|
|
28
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
28
29
|
return jwt.sign(payload, secret, { expiresIn: TOKEN_EXPIRES_IN });
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
@@ -32,6 +33,7 @@ export function createAuthToken(payload, secret = AUTH_SECRET) {
|
|
|
32
33
|
*/
|
|
33
34
|
export function decodeAuthToken(token, secret = AUTH_SECRET) {
|
|
34
35
|
try {
|
|
36
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
35
37
|
const decoded = jwt.verify(token.trim(), secret);
|
|
36
38
|
/* c8 ignore next 3 */
|
|
37
39
|
if (typeof decoded === 'string') {
|
|
@@ -328,6 +330,7 @@ export async function checkIfPasswordsMatch(realPassword, attemptedPassword) {
|
|
|
328
330
|
if (!realPassword) {
|
|
329
331
|
throw new Error('User has no defined password');
|
|
330
332
|
}
|
|
333
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
331
334
|
const validPassword = await bcrypt.compare(attemptedPassword, realPassword);
|
|
332
335
|
if (!validPassword) {
|
|
333
336
|
throw new Error(`Passwords do not match`);
|
|
@@ -338,5 +341,6 @@ export async function checkIfPasswordsMatch(realPassword, attemptedPassword) {
|
|
|
338
341
|
* Returns a hash of a password suitable for storage.
|
|
339
342
|
*/
|
|
340
343
|
export function hashPassword(password) {
|
|
344
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
341
345
|
return bcrypt.hash(password, 10);
|
|
342
346
|
}
|
package/dist/middleware.js
CHANGED
|
@@ -41,6 +41,7 @@ export function before({ cookies = false, helmet: useHelmet = true, json: useJso
|
|
|
41
41
|
'script-src': [
|
|
42
42
|
"'self'",
|
|
43
43
|
...(allowUnsafeInlineScripts ? ["'unsafe-inline'"] : []),
|
|
44
|
+
'*.cdn-apple.com',
|
|
44
45
|
],
|
|
45
46
|
'script-src-attr': ["'none'"],
|
|
46
47
|
'style-src': ["'self'", 'https:', "'unsafe-inline'"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devmoods/express-extras",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.7",
|
|
4
4
|
"description": "Kubernetes-ready utilities for rapid Node.js application development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@devmoods/fetch": "^4.0.1",
|
|
49
|
-
"@sentry/node": "^7.
|
|
49
|
+
"@sentry/node": "^7.80.0",
|
|
50
50
|
"@types/bcrypt": "^5.0.2",
|
|
51
51
|
"@types/body-parser": "^1.19.5",
|
|
52
52
|
"@types/cookie-parser": "^1.4.6",
|