docta-package 1.2.9 → 1.2.11

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/build/config.d.ts CHANGED
@@ -10,5 +10,5 @@ interface GeneralConfig {
10
10
  forgotPasswordTokenSecret: string;
11
11
  activationTokenSecret: string;
12
12
  }
13
- export declare const generalConfig: GeneralConfig;
13
+ export declare const getGeneralConfig: () => GeneralConfig;
14
14
  export {};
package/build/config.js CHANGED
@@ -1,15 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generalConfig = void 0;
4
- exports.generalConfig = {
5
- accessTokenSecret: String(process.env.ACCESS_TOKEN_SECRET),
6
- refreshTokenSecret: String(process.env.REFRESH_TOKEN_SECRET),
7
- accessTokenExpiry: Number(process.env.ACCESS_TOKEN_EXPIRY),
8
- refreshTokenExpiry: Number(process.env.REFRESH_TOKEN_EXPIRY),
9
- awsAccessKey: String(process.env.AWS_ACCESS_KEY),
10
- awsSecretKey: String(process.env.AWS_SECRET_KEY),
11
- awsS3Bucket: String(process.env.AWS_S3_BUCKET),
12
- awsS3Region: String(process.env.AWS_S3_REGION),
13
- forgotPasswordTokenSecret: String(process.env.FORGOT_PASSWORD_TOKEN_SECRET),
14
- activationTokenSecret: String(process.env.ACTIVATION_TOKEN_SECRET),
3
+ exports.getGeneralConfig = void 0;
4
+ const getGeneralConfig = () => {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
6
+ return ({
7
+ accessTokenSecret: (_a = process.env.ACCESS_TOKEN_SECRET) !== null && _a !== void 0 ? _a : "",
8
+ refreshTokenSecret: (_b = process.env.REFRESH_TOKEN_SECRET) !== null && _b !== void 0 ? _b : "",
9
+ accessTokenExpiry: Number((_c = process.env.ACCESS_TOKEN_EXPIRY) !== null && _c !== void 0 ? _c : 0),
10
+ refreshTokenExpiry: Number((_d = process.env.REFRESH_TOKEN_EXPIRY) !== null && _d !== void 0 ? _d : 0),
11
+ awsAccessKey: (_e = process.env.AWS_ACCESS_KEY) !== null && _e !== void 0 ? _e : "",
12
+ awsSecretKey: (_f = process.env.AWS_SECRET_KEY) !== null && _f !== void 0 ? _f : "",
13
+ awsS3Bucket: (_g = process.env.AWS_S3_BUCKET) !== null && _g !== void 0 ? _g : "",
14
+ awsS3Region: (_h = process.env.AWS_S3_REGION) !== null && _h !== void 0 ? _h : "",
15
+ forgotPasswordTokenSecret: (_j = process.env.FORGOT_PASSWORD_TOKEN_SECRET) !== null && _j !== void 0 ? _j : "",
16
+ activationTokenSecret: (_k = process.env.ACTIVATION_TOKEN_SECRET) !== null && _k !== void 0 ? _k : "",
17
+ });
15
18
  };
19
+ exports.getGeneralConfig = getGeneralConfig;
@@ -16,10 +16,10 @@ const config_1 = require("../config");
16
16
  class AwsS3Helper {
17
17
  constructor() {
18
18
  this.signedUrlExpiry = 3600; // 1 hour
19
- this.bucketName = config_1.generalConfig.awsS3Bucket;
20
- this.bucketRegion = config_1.generalConfig.awsS3Region;
21
- this.accessKey = config_1.generalConfig.awsAccessKey;
22
- this.secretKey = config_1.generalConfig.awsSecretKey;
19
+ this.bucketName = (0, config_1.getGeneralConfig)().awsS3Bucket;
20
+ this.bucketRegion = (0, config_1.getGeneralConfig)().awsS3Region;
21
+ this.accessKey = (0, config_1.getGeneralConfig)().awsAccessKey;
22
+ this.secretKey = (0, config_1.getGeneralConfig)().awsSecretKey;
23
23
  this.s3 = new client_s3_1.S3Client({
24
24
  credentials: {
25
25
  accessKeyId: this.accessKey,
@@ -8,11 +8,11 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
8
  const config_1 = require("../config");
9
9
  class TokenUtils {
10
10
  static createActivationToken(userId) {
11
- return jsonwebtoken_1.default.sign({ userId }, config_1.generalConfig.accessTokenSecret);
11
+ return jsonwebtoken_1.default.sign({ userId }, (0, config_1.getGeneralConfig)().accessTokenSecret);
12
12
  }
13
13
  static decodeActivationToken(token) {
14
14
  try {
15
- const decoded = jsonwebtoken_1.default.verify(token, config_1.generalConfig.activationTokenSecret);
15
+ const decoded = jsonwebtoken_1.default.verify(token, (0, config_1.getGeneralConfig)().activationTokenSecret);
16
16
  if (typeof decoded === "string") {
17
17
  return null;
18
18
  }
@@ -24,19 +24,19 @@ class TokenUtils {
24
24
  }
25
25
  static createAccessToken(payload) {
26
26
  console.log("General config");
27
- console.log(config_1.generalConfig.accessTokenExpiry);
28
- return jsonwebtoken_1.default.sign(payload, config_1.generalConfig.accessTokenSecret, {
29
- expiresIn: config_1.generalConfig.accessTokenExpiry,
27
+ console.log((0, config_1.getGeneralConfig)());
28
+ return jsonwebtoken_1.default.sign(payload, (0, config_1.getGeneralConfig)().accessTokenSecret, {
29
+ expiresIn: (0, config_1.getGeneralConfig)().accessTokenExpiry,
30
30
  });
31
31
  }
32
32
  static createRefreshToken(payload) {
33
- return jsonwebtoken_1.default.sign(payload, config_1.generalConfig.refreshTokenSecret, {
34
- expiresIn: config_1.generalConfig.refreshTokenExpiry,
33
+ return jsonwebtoken_1.default.sign(payload, (0, config_1.getGeneralConfig)().refreshTokenSecret, {
34
+ expiresIn: (0, config_1.getGeneralConfig)().refreshTokenExpiry,
35
35
  });
36
36
  }
37
37
  static verifyRefreshToken(token) {
38
38
  try {
39
- const decoded = jsonwebtoken_1.default.verify(token, config_1.generalConfig.refreshTokenSecret);
39
+ const decoded = jsonwebtoken_1.default.verify(token, (0, config_1.getGeneralConfig)().refreshTokenSecret);
40
40
  return {
41
41
  id: decoded.id,
42
42
  email: decoded.email,
@@ -49,7 +49,7 @@ class TokenUtils {
49
49
  }
50
50
  static verifyAccessToken(token) {
51
51
  try {
52
- const decoded = jsonwebtoken_1.default.verify(token, config_1.generalConfig.accessTokenSecret);
52
+ const decoded = jsonwebtoken_1.default.verify(token, (0, config_1.getGeneralConfig)().accessTokenSecret);
53
53
  return {
54
54
  id: decoded.id,
55
55
  email: decoded.email,
@@ -61,11 +61,11 @@ class TokenUtils {
61
61
  }
62
62
  }
63
63
  static createForgotPasswordToken(userId) {
64
- return jsonwebtoken_1.default.sign({ userId }, config_1.generalConfig.forgotPasswordTokenSecret);
64
+ return jsonwebtoken_1.default.sign({ userId }, (0, config_1.getGeneralConfig)().forgotPasswordTokenSecret);
65
65
  }
66
66
  static decodeForgotPasswordToken(token) {
67
67
  try {
68
- const decoded = jsonwebtoken_1.default.verify(token, config_1.generalConfig.forgotPasswordTokenSecret);
68
+ const decoded = jsonwebtoken_1.default.verify(token, (0, config_1.getGeneralConfig)().forgotPasswordTokenSecret);
69
69
  if (typeof decoded === "string") {
70
70
  return null;
71
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docta-package",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "This package will contail all the required files to run the docta micro-service app",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",