fiberx-backend-toolkit 0.0.51 → 0.0.53

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.
@@ -8,4 +8,5 @@ import SafeExecuteUtil from "./safe_execute_util";
8
8
  import InMemoryCache from "./cache_util";
9
9
  import UUIDGeneratorUtil from "./uuid_gen_util";
10
10
  import EncryptorDecryptorUtil from "./encryptor_decryptor_util";
11
- export { LoggerUtil, InputTransformerUtil, InputValidatorUtil, EnvManagerUtil, SqlFormatterUtil, ServerUtil, SafeExecuteUtil, InMemoryCache, UUIDGeneratorUtil, EncryptorDecryptorUtil };
11
+ import TOTPServiceUtil from "./totp_service_util";
12
+ export { LoggerUtil, InputTransformerUtil, InputValidatorUtil, EnvManagerUtil, SqlFormatterUtil, ServerUtil, SafeExecuteUtil, InMemoryCache, UUIDGeneratorUtil, EncryptorDecryptorUtil, TOTPServiceUtil };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EncryptorDecryptorUtil = exports.UUIDGeneratorUtil = exports.InMemoryCache = exports.SafeExecuteUtil = exports.ServerUtil = exports.SqlFormatterUtil = exports.EnvManagerUtil = exports.InputValidatorUtil = exports.InputTransformerUtil = exports.LoggerUtil = void 0;
6
+ exports.TOTPServiceUtil = exports.EncryptorDecryptorUtil = exports.UUIDGeneratorUtil = exports.InMemoryCache = exports.SafeExecuteUtil = exports.ServerUtil = exports.SqlFormatterUtil = exports.EnvManagerUtil = exports.InputValidatorUtil = exports.InputTransformerUtil = exports.LoggerUtil = void 0;
7
7
  const logger_util_1 = __importDefault(require("./logger_util"));
8
8
  exports.LoggerUtil = logger_util_1.default;
9
9
  const input_transformer_util_1 = __importDefault(require("./input_transformer_util"));
@@ -24,3 +24,5 @@ const uuid_gen_util_1 = __importDefault(require("./uuid_gen_util"));
24
24
  exports.UUIDGeneratorUtil = uuid_gen_util_1.default;
25
25
  const encryptor_decryptor_util_1 = __importDefault(require("./encryptor_decryptor_util"));
26
26
  exports.EncryptorDecryptorUtil = encryptor_decryptor_util_1.default;
27
+ const totp_service_util_1 = __importDefault(require("./totp_service_util"));
28
+ exports.TOTPServiceUtil = totp_service_util_1.default;
@@ -1,13 +1,15 @@
1
1
  import { GenerateSecretOptionsType, VerifyResultType, VerifyOptionsType, TOTPServiceOptions, GenerateSecretResult } from "../types/util_type";
2
2
  declare class TOTPServiceUtil {
3
3
  readonly name = "totp_service_util";
4
+ private static instance;
4
5
  private logger;
5
6
  private readonly STEP;
6
7
  private readonly DIGITS;
7
8
  private readonly WINDOW;
8
9
  private readonly ALGORITHM;
9
10
  private readonly SECRET_KEY_REGEX;
10
- constructor(options?: TOTPServiceOptions);
11
+ private constructor();
12
+ static getInstance(options?: TOTPServiceOptions): TOTPServiceUtil;
11
13
  private base32Decode;
12
14
  private base32Encode;
13
15
  private generateForCounter;
@@ -9,6 +9,7 @@ const logger_util_1 = __importDefault(require("./logger_util"));
9
9
  const input_validator_util_1 = __importDefault(require("./input_validator_util"));
10
10
  class TOTPServiceUtil {
11
11
  name = "totp_service_util";
12
+ static instance;
12
13
  logger = new logger_util_1.default(this.name);
13
14
  // ===============================
14
15
  // CONFIG
@@ -24,6 +25,13 @@ class TOTPServiceUtil {
24
25
  this.WINDOW = options.WINDOW ?? constants_1.DEFAULT_TOTP_WINDOW;
25
26
  this.ALGORITHM = options.ALGORITHM?.toLowerCase() ?? "sha1";
26
27
  }
28
+ // ✅ Global access point
29
+ static getInstance(options = {}) {
30
+ if (!TOTPServiceUtil.instance) {
31
+ TOTPServiceUtil.instance = new TOTPServiceUtil(options);
32
+ }
33
+ return TOTPServiceUtil.instance;
34
+ }
27
35
  // ===============================
28
36
  // BASE32 DECODE
29
37
  // ===============================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiberx-backend-toolkit",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "A TypeScript backend toolkit providing shared domain logic, infrastructure helpers, and utilities for FiberX server-side applications and services.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",