fiberx-backend-toolkit 0.0.65 → 0.0.67

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.
@@ -18,10 +18,10 @@ const GENERATE_NOTIFICATION_CODE_TYPE = (interface_name, static_obj, db_obj, cod
18
18
  * @generated-notification-code: ${code}
19
19
  */
20
20
  export interface ${interface_name} {
21
- static_data: {
21
+ static_content: {
22
22
  ${objectToType(static_obj, 8)}
23
23
  };
24
- db_data: {
24
+ db_content: {
25
25
  ${objectToType(db_obj, 8)}
26
26
  };
27
27
  }
@@ -373,7 +373,7 @@ class ${class_name}Seeder {
373
373
  const seed_data = this.getSeedData();
374
374
 
375
375
  if (!seed_data || seed_data.length === 0) {
376
- throw new Error("❌ Seeder data for 'roles' is empty. Aborting bulk insert.");
376
+ throw new Error("❌ Seeder data for '${table_name.toLowerCase()}' is empty. Aborting bulk insert.");
377
377
  }
378
378
 
379
379
  await queryInterface.bulkInsert('${table_name.toLowerCase()}', seed_data);
@@ -386,7 +386,7 @@ class ${class_name}Seeder {
386
386
  const seed_data = this.getSeedData();
387
387
 
388
388
  if (!seed_data || seed_data.length === 0) {
389
- throw new Error("❌ Seeder data for 'roles' is empty. Nothing to delete.");
389
+ throw new Error("❌ Seeder data for ${table_name.toLowerCase()}' is empty. Nothing to delete.");
390
390
  }
391
391
 
392
392
  const ids = seed_data.map(row => row.id);
@@ -112,8 +112,8 @@ class EmailEnqueueGenerator {
112
112
  const interface_name = main_1.InputTransformerUtil.toPascalCase(code) + "EmailPayload";
113
113
  const method_name = "send" + main_1.InputTransformerUtil.toPascalCase(code);
114
114
  const placeholders = this.provider.getRequiredPlaceholders(template) ?? {};
115
- const static_obj = main_1.InputTransformerUtil.buildNestedObject(placeholders.static_data ?? []);
116
- const db_obj = main_1.InputTransformerUtil.buildNestedObject(placeholders.db_data ?? []);
115
+ const static_obj = main_1.InputTransformerUtil.buildNestedObject(placeholders.static_content ?? []);
116
+ const db_obj = main_1.InputTransformerUtil.buildNestedObject(placeholders.db_content ?? []);
117
117
  this.logger.info(`🚀 Generating email enqueue code for → ${code}`);
118
118
  const type_success = this.appendType(interface_name, static_obj, db_obj, code);
119
119
  const method_success = this.appendUtilMethod(interface_name, method_name, code);
@@ -32,14 +32,14 @@ class EmailEnqueueProcessor {
32
32
  const check_patch = (obj, path) => {
33
33
  return path.split(".").reduce((o, k) => o?.[k], obj);
34
34
  };
35
- for (const p of required.static_data ?? []) {
36
- if (check_patch(payload["static_data"], p) === undefined) {
37
- missing.push(`static_data.${p}`);
35
+ for (const p of required.static_content ?? []) {
36
+ if (check_patch(payload["static_content"], p) === undefined) {
37
+ missing.push(`static_content.${p}`);
38
38
  }
39
39
  }
40
- for (const p of required.db_data ?? []) {
41
- if (check_patch(payload["db_data"], p) === undefined) {
42
- missing.push(`db_data.${p}`);
40
+ for (const p of required.db_content ?? []) {
41
+ if (check_patch(payload["db_content"], p) === undefined) {
42
+ missing.push(`db_content.${p}`);
43
43
  }
44
44
  }
45
45
  if (missing.length) {
@@ -5,8 +5,8 @@ export interface EmailEnqueueGeneratorOptions {
5
5
  batch_size?: number;
6
6
  }
7
7
  export interface EmailTemplatePlaceholders {
8
- static_data?: string[];
9
- db_data?: string[];
8
+ static_content?: string[];
9
+ db_content?: string[];
10
10
  }
11
11
  export interface EmailEnqueueDataProvider<TTemplate, TNotification> {
12
12
  fetchActiveTemplates(exclude_codes: string[], limit: number): Promise<TTemplate[]>;
@@ -2,7 +2,8 @@ import { GenerateSecretOptionsType, VerifyResultType, VerifyOptionsType, TOTPSer
2
2
  declare class TOTPServiceUtil {
3
3
  readonly name = "totp_service_util";
4
4
  private static instance;
5
- private logger;
5
+ private readonly logger;
6
+ private readonly env_manager;
6
7
  private readonly STEP;
7
8
  private readonly DIGITS;
8
9
  private readonly WINDOW;
@@ -14,6 +15,7 @@ declare class TOTPServiceUtil {
14
15
  private base32Encode;
15
16
  private generateForCounter;
16
17
  generateSecret(options: GenerateSecretOptionsType): GenerateSecretResult;
18
+ generateAppSecret(member_email: string, custom_app_name?: string): GenerateSecretResult;
17
19
  verify(options: VerifyOptionsType & {
18
20
  last_used_counter?: number;
19
21
  }): VerifyResultType;
@@ -7,10 +7,12 @@ const crypto_1 = __importDefault(require("crypto"));
7
7
  const constants_1 = require("../config/constants");
8
8
  const logger_util_1 = __importDefault(require("./logger_util"));
9
9
  const input_validator_util_1 = __importDefault(require("./input_validator_util"));
10
+ const env_manager_util_1 = __importDefault(require("./env_manager_util"));
10
11
  class TOTPServiceUtil {
11
12
  name = "totp_service_util";
12
13
  static instance;
13
14
  logger = new logger_util_1.default(this.name);
15
+ env_manager = env_manager_util_1.default.getInstance();
14
16
  // ===============================
15
17
  // CONFIG
16
18
  // ===============================
@@ -117,6 +119,12 @@ class TOTPServiceUtil {
117
119
  otpauth_url,
118
120
  };
119
121
  }
122
+ generateAppSecret(member_email, custom_app_name = "") {
123
+ const app_name = this.env_manager.getEnvVar("APP_NAME", custom_app_name) ?? custom_app_name;
124
+ const name = input_validator_util_1.default.isProduction() ? `${app_name}:${member_email}` : `Dev ${app_name}:${member_email}`;
125
+ const issuer = (this.env_manager.getEnvVar("APP_ID", custom_app_name) ?? custom_app_name)?.toLowerCase();
126
+ return this.generateSecret({ name, issuer });
127
+ }
120
128
  // ===============================
121
129
  // PUBLIC: VERIFY TOKEN
122
130
  // ===============================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiberx-backend-toolkit",
3
- "version": "0.0.65",
3
+ "version": "0.0.67",
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",