propro-utils 1.3.31 → 1.3.33

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.
@@ -2,8 +2,7 @@ require("dotenv").config();
2
2
  const axios = require("axios");
3
3
  const {getOrSetCache} = require("../utils/redis");
4
4
  const { v4: uuidv4 } = require('uuid');
5
- const { Schema } = require('mongoose');
6
- const { Client } = require('redis');
5
+
7
6
  /**
8
7
  * Retrieves the account profile data from the authentication server and caches it using Redis.
9
8
  * If the profile data is not found in the cache, it fetches it from the authentication server and stores it in the cache.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.3.31",
3
+ "version": "1.3.33",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -61,12 +61,10 @@
61
61
  "axios": "^1.6.1",
62
62
  "dotenv": "^16.4.1",
63
63
  "express-rate-limit": "^7.1.4",
64
- "mongoose": "^8.1.1",
65
64
  "nodemailer": "^6.9.7",
66
65
  "nodemailer-mailgun-transport": "^2.1.5",
67
66
  "querystring": "^0.2.1",
68
67
  "react-email": "^1.9.5",
69
- "redis": "^4.6.12",
70
68
  "uuid": "^9.0.1"
71
69
  }
72
70
  }
package/src/index.js CHANGED
@@ -24,6 +24,7 @@ let _serverAuth, _clientAuth;
24
24
  * }
25
25
  * @param {boolean} [options.useClientAuth=false] - A boolean flag to enable client-side authentication.
26
26
  * @param {Object} [options.clientOptions={}] - Configuration options for client-side authentication.
27
+ * @param {Schema} [userSchema] - The user schema to perform the operations on.
27
28
  *
28
29
  * @returns {Function} An Express middleware function.
29
30
  *
@@ -40,7 +41,7 @@ let _serverAuth, _clientAuth;
40
41
  * useClientAuth: false,
41
42
  * }));
42
43
  */
43
- module.exports = function proproAuthMiddleware(options = {}) {
44
+ module.exports = function proproAuthMiddleware(options = {}, userSchema) {
44
45
  validateEnvironmentVariables([
45
46
  "AUTH_URL",
46
47
  "CLIENT_ID",
@@ -52,7 +53,7 @@ module.exports = function proproAuthMiddleware(options = {}) {
52
53
  try {
53
54
  // Lazy loading and initializing server and client authentication modules with options
54
55
  if (options.useServerAuth) {
55
- _serverAuth = _serverAuth || require("./server")(options.serverOptions);
56
+ _serverAuth = _serverAuth || require("./server")(options.serverOptions, userSchema);
56
57
  _serverAuth(req, res, next);
57
58
  } else if (options.useClientAuth) {
58
59
  _clientAuth = _clientAuth || require("./client")(options.clientOptions);