@devmoods/express-extras 0.28.5 → 0.28.6

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.
Files changed (2) hide show
  1. package/dist/auth.js +6 -2
  2. package/package.json +1 -1
package/dist/auth.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as crypto from 'node:crypto';
2
- import * as bcrypt from 'bcrypt';
2
+ import bcrypt from 'bcrypt';
3
3
  import { Router, } from 'express';
4
- import * as jwt from 'jsonwebtoken';
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devmoods/express-extras",
3
- "version": "0.28.5",
3
+ "version": "0.28.6",
4
4
  "description": "Kubernetes-ready utilities for rapid Node.js application development",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",