fiberx-backend-toolkit 1.0.13 → 1.0.15

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 (30) hide show
  1. package/dist/fibase/clients/base_fibase_app_client.d.ts +26 -0
  2. package/dist/fibase/clients/base_fibase_app_client.js +133 -0
  3. package/dist/fibase/clients/generated_fibase_registered_app_client.d.ts +10 -0
  4. package/dist/fibase/clients/generated_fibase_registered_app_client.js +16 -0
  5. package/dist/fibase/clients/v1/fibase_v1_client.d.ts +15 -0
  6. package/dist/fibase/clients/v1/fibase_v1_client.js +23 -0
  7. package/dist/fibase/clients/v1/fibase_v1_identity_client.d.ts +16 -0
  8. package/dist/fibase/clients/v1/fibase_v1_identity_client.js +28 -0
  9. package/dist/fibase/clients/v1/fibase_v1_identity_wallet_client.d.ts +18 -0
  10. package/dist/fibase/clients/v1/fibase_v1_identity_wallet_client.js +37 -0
  11. package/dist/fibase/clients/v1/fibase_v1_payment_config_client.d.ts +16 -0
  12. package/dist/fibase/clients/v1/fibase_v1_payment_config_client.js +31 -0
  13. package/dist/fibase/clients/v1/fibase_v1_transaction_client.d.ts +29 -0
  14. package/dist/fibase/clients/v1/fibase_v1_transaction_client.js +49 -0
  15. package/dist/fibase/clients/v1/main.d.ts +6 -0
  16. package/dist/fibase/clients/v1/main.js +17 -0
  17. package/dist/fibase/fibase_app_client.d.ts +8 -43
  18. package/dist/fibase/fibase_app_client.js +8 -134
  19. package/dist/fibase/main.d.ts +7 -2
  20. package/dist/fibase/main.js +25 -3
  21. package/dist/fibase/registered_app_api_routes.d.ts +87 -0
  22. package/dist/fibase/registered_app_api_routes.js +102 -0
  23. package/dist/types/fibase_registered_app_api_type.d.ts +393 -0
  24. package/dist/types/fibase_registered_app_api_type.js +2 -0
  25. package/dist/types/fibase_type.d.ts +2 -0
  26. package/dist/types/main.d.ts +1 -0
  27. package/dist/types/main.js +1 -0
  28. package/dist/utils/input_validator_util.d.ts +8 -0
  29. package/dist/utils/input_validator_util.js +81 -0
  30. package/package.json +17 -15
@@ -0,0 +1,393 @@
1
+ import type { FibaseHttpResponseInterface, FibaseRequestOptionsInterface } from "./fibase_type";
2
+ /** ISO-8601 date/time string as serialized by the Fibase JSON API. */
3
+ export type FibaseDateTimeString = string;
4
+ export type FibaseIdentityType = "person" | "business" | "system";
5
+ export type FibaseIdentityStatus = "active" | "suspended" | "closed" | "merged";
6
+ export type FibaseIdentityAppAccountStatus = "active" | "inactive" | "banned" | "deleted" | "unknown";
7
+ export interface FibaseApiSuccessEnvelopeInterface<TData, TMessage extends string = string> {
8
+ status: "success";
9
+ msg: TMessage;
10
+ data: TData;
11
+ }
12
+ export interface FibaseApiErrorEnvelopeInterface<TData = unknown> {
13
+ status: "error";
14
+ msg: string;
15
+ data?: TData;
16
+ code?: number;
17
+ }
18
+ export type FibaseApiHttpResponse<TData, TMessage extends string = string> = FibaseHttpResponseInterface<FibaseApiSuccessEnvelopeInterface<TData, TMessage>>;
19
+ export interface FibaseAppIdentityProfileInputInterface {
20
+ first_name: string;
21
+ last_name: string;
22
+ middle_name?: string | null;
23
+ display_name?: string | null;
24
+ dob?: string | null;
25
+ gender?: string | null;
26
+ nationality?: string | null;
27
+ country_of_residence?: string | null;
28
+ profile_photo_link?: string | null;
29
+ primary_email?: string | null;
30
+ primary_phone?: string | null;
31
+ address?: Record<string, unknown> | null;
32
+ metadata?: Record<string, unknown> | null;
33
+ }
34
+ export interface FibaseResolveAppIdentityInputInterface {
35
+ member_public_id: string;
36
+ profile: FibaseAppIdentityProfileInputInterface;
37
+ identity_type?: FibaseIdentityType | null;
38
+ external_member_id?: string | null;
39
+ external_username?: string | null;
40
+ external_status?: FibaseIdentityAppAccountStatus | null;
41
+ registered_at?: string | null;
42
+ metadata?: Record<string, unknown> | null;
43
+ }
44
+ export interface FibaseIdentityProfileInterface {
45
+ public_id: string;
46
+ identity_public_id?: string | null;
47
+ first_name: string | null;
48
+ middle_name: string | null;
49
+ last_name: string | null;
50
+ display_name: string | null;
51
+ dob: string | null;
52
+ gender: string | null;
53
+ nationality: string | null;
54
+ country_of_residence: string | null;
55
+ profile_photo_link: string | null;
56
+ primary_email: string | null;
57
+ primary_phone: string | null;
58
+ address: Record<string, unknown> | null;
59
+ profile_completeness_score: number;
60
+ source_app_account_public_id?: string | null;
61
+ created_at: FibaseDateTimeString;
62
+ updated_at: FibaseDateTimeString | null;
63
+ }
64
+ export interface FibaseIdentityContactInterface {
65
+ public_id: string;
66
+ identity_public_id?: string | null;
67
+ contact_type: string;
68
+ contact_value: string;
69
+ is_primary: boolean;
70
+ is_verified: boolean;
71
+ verified_at: FibaseDateTimeString | null;
72
+ source_app_account_public_id?: string | null;
73
+ created_at: FibaseDateTimeString;
74
+ updated_at: FibaseDateTimeString | null;
75
+ }
76
+ export interface FibaseIdentityInterface {
77
+ public_id: string;
78
+ identity_type: FibaseIdentityType;
79
+ status: FibaseIdentityStatus;
80
+ is_verified: boolean;
81
+ is_deleted: boolean;
82
+ wallet_count?: number;
83
+ merged_into_identity_public_id?: string | null;
84
+ created_at: FibaseDateTimeString;
85
+ updated_at: FibaseDateTimeString | null;
86
+ primary_profile?: FibaseIdentityProfileInterface | null;
87
+ profile?: FibaseIdentityProfileInterface | null;
88
+ contacts?: FibaseIdentityContactInterface[] | null;
89
+ }
90
+ export interface FibaseIdentityAppAccountInterface {
91
+ public_id: string;
92
+ identity_public_id?: string | null;
93
+ external_member_id: string;
94
+ external_public_id: string | null;
95
+ external_username: string | null;
96
+ external_status: FibaseIdentityAppAccountStatus;
97
+ registered_at: FibaseDateTimeString | null;
98
+ last_seen_at: FibaseDateTimeString | null;
99
+ last_synced_at: FibaseDateTimeString | null;
100
+ is_active: boolean;
101
+ is_deleted: boolean;
102
+ created_at: FibaseDateTimeString;
103
+ updated_at: FibaseDateTimeString | null;
104
+ }
105
+ export interface FibaseAppIdentityRecordInterface {
106
+ identity: FibaseIdentityInterface;
107
+ app_account: FibaseIdentityAppAccountInterface;
108
+ created: boolean;
109
+ }
110
+ export type FibaseGetAppIdentityResponse = FibaseApiHttpResponse<FibaseAppIdentityRecordInterface, "fetched_app_identity_record_successfully">;
111
+ export type FibaseResolveAppIdentityResponse = FibaseApiHttpResponse<FibaseAppIdentityRecordInterface, "created_app_identity_record_successfully" | "fetched_app_identity_record_successfully">;
112
+ export interface FibaseCurrencyPreviewInterface {
113
+ code: string;
114
+ logo_url: string | null;
115
+ name: string;
116
+ symbol: string;
117
+ precision: number;
118
+ minor_unit: number | null;
119
+ format: string | null;
120
+ is_active: boolean;
121
+ created_at: FibaseDateTimeString;
122
+ }
123
+ export interface FibaseCurrencyInterface extends FibaseCurrencyPreviewInterface {
124
+ id: number;
125
+ numeric_code: string | null;
126
+ country_code: string | null;
127
+ sort_order: number;
128
+ is_fiat: boolean;
129
+ updated_at: FibaseDateTimeString | null;
130
+ }
131
+ export interface FibaseIdentityPreviewInterface {
132
+ public_id: string;
133
+ identity_type: FibaseIdentityType;
134
+ status: FibaseIdentityStatus;
135
+ is_verified: boolean;
136
+ is_deleted: boolean;
137
+ created_at: FibaseDateTimeString;
138
+ updated_at: FibaseDateTimeString | null;
139
+ }
140
+ export interface FibaseIdentityWalletPreviewInterface {
141
+ public_id: string;
142
+ available_balance: number;
143
+ locked_balance: number;
144
+ status: string;
145
+ is_active: boolean;
146
+ created_at: FibaseDateTimeString;
147
+ identity?: FibaseIdentityPreviewInterface | null;
148
+ currency?: FibaseCurrencyPreviewInterface | null;
149
+ }
150
+ export interface FibaseIdentityWalletInterface extends FibaseIdentityWalletPreviewInterface {
151
+ refunded_balance: number;
152
+ pending_balance: number;
153
+ total_credit: number;
154
+ total_debit: number;
155
+ updated_at: FibaseDateTimeString | null;
156
+ currency?: FibaseCurrencyInterface | null;
157
+ }
158
+ export type FibaseIdentityWalletSortField = "public_id" | "identity_id" | "currency_id" | "available_balance" | "locked_balance" | "refunded_balance" | "pending_balance" | "status" | "is_active" | "is_deleted" | "created_at" | "updated_at";
159
+ export interface FibaseDateRangeQueryInterface {
160
+ start_date: string;
161
+ end_date: string;
162
+ }
163
+ export interface FibaseAppIdentityWalletListQueryInterface {
164
+ page?: number;
165
+ limit?: number;
166
+ sort_by?: FibaseIdentityWalletSortField;
167
+ sort_direction?: "ASC" | "DESC" | "asc" | "desc";
168
+ search?: string | null;
169
+ preview_only?: boolean;
170
+ currency_id?: string | number | null;
171
+ status?: string | null;
172
+ is_active?: boolean | null;
173
+ date_range?: string | FibaseDateRangeQueryInterface | null;
174
+ }
175
+ export interface FibasePaginatedDataInterface<TRecord> {
176
+ total_items: number;
177
+ total_pages: number;
178
+ current_page: number;
179
+ records: TRecord[];
180
+ }
181
+ export interface FibaseGetAppIdentityWalletListInputInterface {
182
+ identity_public_id: string;
183
+ query?: FibaseAppIdentityWalletListQueryInterface;
184
+ }
185
+ export type FibaseGetAppIdentityWalletListResponse = FibaseApiHttpResponse<FibasePaginatedDataInterface<FibaseIdentityWalletInterface | FibaseIdentityWalletPreviewInterface>, "fetched_app_identity_wallet_list_successfully">;
186
+ export interface FibaseGetAppIdentityCurrencyWalletInputInterface {
187
+ identity_public_id: string;
188
+ currency_id: string | number;
189
+ }
190
+ export type FibaseGetAppIdentityCurrencyWalletResponse = FibaseApiHttpResponse<FibaseIdentityWalletInterface, "fetched_app_identity_currency_wallet_successfully">;
191
+ export interface FibaseResolveAppIdentityCurrencyWalletInputInterface extends FibaseGetAppIdentityCurrencyWalletInputInterface {
192
+ }
193
+ export type FibaseResolveAppIdentityCurrencyWalletResponse = FibaseApiHttpResponse<{
194
+ wallet: FibaseIdentityWalletInterface;
195
+ created: boolean;
196
+ }, "created_app_identity_currency_wallet_successfully" | "fetched_app_identity_currency_wallet_successfully">;
197
+ export type FibaseAppCurrencySortField = "is_default" | "created_at" | "updated_at";
198
+ export interface FibaseAppCurrencyListQueryInterface {
199
+ page?: number;
200
+ limit?: number;
201
+ sort_by?: FibaseAppCurrencySortField;
202
+ sort_direction?: "ASC" | "DESC" | "asc" | "desc";
203
+ search?: string | null;
204
+ preview_only?: boolean;
205
+ currency_id?: string | number | null;
206
+ is_fiat?: boolean | null;
207
+ is_default?: boolean | null;
208
+ date_range?: string | FibaseDateRangeQueryInterface | null;
209
+ }
210
+ export interface FibaseGetAppCurrencyListInputInterface {
211
+ query?: FibaseAppCurrencyListQueryInterface;
212
+ }
213
+ export interface FibaseCurrencyListItemInterface extends FibaseCurrencyPreviewInterface {
214
+ numeric_code: string | null;
215
+ country_code: string | null;
216
+ sort_order: number;
217
+ is_fiat: boolean;
218
+ updated_at: FibaseDateTimeString | null;
219
+ }
220
+ export interface FibaseAppCurrencyInterface {
221
+ is_default: boolean;
222
+ created_at: FibaseDateTimeString;
223
+ currency?: FibaseCurrencyListItemInterface | FibaseCurrencyPreviewInterface | null;
224
+ }
225
+ export type FibaseGetAppCurrencyListResponse = FibaseApiHttpResponse<FibasePaginatedDataInterface<FibaseAppCurrencyInterface>, "fetched_app_currency_list_successfully">;
226
+ export type FibasePaymentProviderType = "payment_gateway" | "banking_partner" | "crypto_exchange" | "wallet_provider" | "other";
227
+ export interface FibasePaymentProviderInterface {
228
+ id: number;
229
+ code: string;
230
+ name: string;
231
+ description: string | null;
232
+ provider_type: FibasePaymentProviderType;
233
+ logo_url: string | null;
234
+ website_url: string | null;
235
+ is_active: boolean;
236
+ created_at: FibaseDateTimeString;
237
+ updated_at: FibaseDateTimeString | null;
238
+ }
239
+ export interface FibasePaymentMethodMetadataInterface {
240
+ display_name?: string | null;
241
+ display_description?: string | null;
242
+ display_group?: string | null;
243
+ processing_time_text?: string | null;
244
+ fee_label?: string | null;
245
+ supported_country_codes?: string[];
246
+ supported_currency_codes?: string[];
247
+ requires_redirect?: boolean;
248
+ supports_deposit?: boolean;
249
+ supports_withdrawal?: boolean;
250
+ supports_refund?: boolean;
251
+ min_amount?: number | null;
252
+ max_amount?: number | null;
253
+ [key: string]: string | number | boolean | string[] | null | undefined;
254
+ }
255
+ export interface FibasePaymentMethodInterface {
256
+ id: number;
257
+ code: string;
258
+ name: string;
259
+ description: string | null;
260
+ icon_url: string | null;
261
+ sort_order: number;
262
+ metadata?: FibasePaymentMethodMetadataInterface | null;
263
+ is_active: boolean;
264
+ created_at: FibaseDateTimeString;
265
+ updated_at: FibaseDateTimeString | null;
266
+ }
267
+ export interface FibasePaymentProviderMethodInterface {
268
+ id: number;
269
+ direction: "deposit" | "withdrawal";
270
+ provider_method_code: string | null;
271
+ min_amount: number | null;
272
+ max_amount: number | null;
273
+ is_active: boolean;
274
+ created_at: FibaseDateTimeString;
275
+ updated_at: FibaseDateTimeString | null;
276
+ provider?: FibasePaymentProviderInterface | null;
277
+ payment_method?: FibasePaymentMethodInterface | null;
278
+ }
279
+ export interface FibaseCurrencyPaymentOptionInterface {
280
+ id: number;
281
+ min_amount: number | null;
282
+ max_amount: number | null;
283
+ is_active: boolean;
284
+ created_at: FibaseDateTimeString;
285
+ updated_at: FibaseDateTimeString | null;
286
+ provider_method?: FibasePaymentProviderMethodInterface | null;
287
+ }
288
+ export interface FibaseAppCurrencyPaymentOptionsInterface {
289
+ currency: FibaseCurrencyInterface;
290
+ options: FibaseCurrencyPaymentOptionInterface[];
291
+ }
292
+ export type FibaseGetAppCurrencyPaymentOptionsResponse = FibaseApiHttpResponse<FibaseAppCurrencyPaymentOptionsInterface, "fetched_app_currency_payment_options_successfully">;
293
+ export interface FibaseInitiateAppDepositTransactionInputInterface {
294
+ identity_public_id: string;
295
+ currency_provider_method_id: string | number;
296
+ amount: string;
297
+ app_reference: string;
298
+ idempotency_key: string;
299
+ description?: string | null;
300
+ reason?: string | null;
301
+ redirect_url?: string | null;
302
+ metadata?: Record<string, unknown> | null;
303
+ }
304
+ export type FibasePaymentProviderInteractionStatus = "pending" | "processing" | "successful" | "failed" | "cancelled" | "expired" | "partially_paid" | "overpaid" | "requires_action" | "unknown";
305
+ export interface FibasePaymentProviderAmountInterface {
306
+ amount: number;
307
+ currency_code: string;
308
+ minor_amount?: number | null;
309
+ precision?: number | null;
310
+ }
311
+ export interface FibasePaymentProviderInstructionInterface {
312
+ type: "redirect" | "bank_transfer" | "wallet_transfer" | "provider_action";
313
+ title?: string | null;
314
+ authorization_url?: string | null;
315
+ account_name?: string | null;
316
+ account_number?: string | null;
317
+ bank_name?: string | null;
318
+ bank_code?: string | null;
319
+ wallet_address?: string | null;
320
+ network?: string | null;
321
+ expires_at?: string | null;
322
+ metadata?: Record<string, unknown> | null;
323
+ }
324
+ export interface FibasePaymentProviderInteractionResultInterface {
325
+ status: FibasePaymentProviderInteractionStatus;
326
+ payment_reference?: string | null;
327
+ provider_reference?: string | null;
328
+ amount?: FibasePaymentProviderAmountInterface | null;
329
+ authorization_url?: string | null;
330
+ redirect_url?: string | null;
331
+ account?: Record<string, unknown> | null;
332
+ instructions?: FibasePaymentProviderInstructionInterface[] | null;
333
+ fees?: Array<{
334
+ amount: number;
335
+ currency_code: string;
336
+ label?: string | null;
337
+ }> | null;
338
+ metadata?: Record<string, unknown> | null;
339
+ }
340
+ export interface FibaseRegisteredAppSummaryInterface {
341
+ public_id: string;
342
+ prefix: string;
343
+ name: string;
344
+ description: string | null;
345
+ base_url: string | null;
346
+ logo_url: string | null;
347
+ is_active: boolean;
348
+ created_at: FibaseDateTimeString;
349
+ updated_at: FibaseDateTimeString | null;
350
+ }
351
+ export interface FibasePaymentTransactionInterface {
352
+ public_id: string;
353
+ transaction_type: string;
354
+ direction: string;
355
+ status: string;
356
+ amount: number;
357
+ fee_amount: number;
358
+ net_amount: number;
359
+ app_reference: string | null;
360
+ provider_reference: string | null;
361
+ external_reference: string | null;
362
+ external_destination_type: string | null;
363
+ external_destination_snapshot: Record<string, unknown> | null;
364
+ provider_instruction_snapshot: Record<string, unknown> | null;
365
+ description: string | null;
366
+ reason: string | null;
367
+ initiated_at: FibaseDateTimeString | null;
368
+ authorized_at: FibaseDateTimeString | null;
369
+ settled_at: FibaseDateTimeString | null;
370
+ failed_at: FibaseDateTimeString | null;
371
+ cancelled_at: FibaseDateTimeString | null;
372
+ reversed_at: FibaseDateTimeString | null;
373
+ refunded_at: FibaseDateTimeString | null;
374
+ created_at: FibaseDateTimeString;
375
+ updated_at: FibaseDateTimeString | null;
376
+ parent_transaction_public_id?: string | null;
377
+ app?: FibaseRegisteredAppSummaryInterface | null;
378
+ currency?: FibaseCurrencyInterface | null;
379
+ initiated_by_identity?: FibaseIdentityInterface | null;
380
+ initiated_by_app?: FibaseRegisteredAppSummaryInterface | null;
381
+ destination_identity?: FibaseIdentityInterface | null;
382
+ destination_wallet?: FibaseIdentityWalletInterface | null;
383
+ provider?: FibasePaymentProviderInterface | null;
384
+ payment_method?: FibasePaymentMethodInterface | null;
385
+ }
386
+ export interface FibaseAppTransactionProviderActionInterface {
387
+ transaction: FibasePaymentTransactionInterface;
388
+ provider_result: FibasePaymentProviderInteractionResultInterface | null;
389
+ }
390
+ export type FibaseInitiateAppDepositTransactionResponse = FibaseApiHttpResponse<FibaseAppTransactionProviderActionInterface, "initiated_app_deposit_transaction_successfully" | "app_deposit_transaction_already_initialized">;
391
+ export type FibaseGetAppTransactionResponse = FibaseApiHttpResponse<FibasePaymentTransactionInterface>;
392
+ export type FibaseVerifyAppTransactionResponse = FibaseApiHttpResponse<FibaseAppTransactionProviderActionInterface>;
393
+ export type FibaseRegisteredAppRequestOptionsInterface = Omit<FibaseRequestOptionsInterface, "params">;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -46,6 +46,8 @@ export interface FibaseSignedRequestDataInterface<TBody = unknown> {
46
46
  export interface FibaseRequestOptionsInterface {
47
47
  request_id?: string;
48
48
  headers?: Record<string, string>;
49
+ /** Query parameters sent by Axios. Query values are not included in the Fibase signature body hash. */
50
+ params?: Record<string, unknown>;
49
51
  }
50
52
  export interface FibaseAppEventEnvelopeInterface<TPayload = unknown> {
51
53
  event_type: string;
@@ -11,3 +11,4 @@ export * from "./validator_type";
11
11
  export * from "./storage_type";
12
12
  export * from "./processor_type";
13
13
  export * from "./fibase_type";
14
+ export * from "./fibase_registered_app_api_type";
@@ -27,3 +27,4 @@ __exportStar(require("./validator_type"), exports);
27
27
  __exportStar(require("./storage_type"), exports);
28
28
  __exportStar(require("./processor_type"), exports);
29
29
  __exportStar(require("./fibase_type"), exports);
30
+ __exportStar(require("./fibase_registered_app_api_type"), exports);
@@ -11,6 +11,14 @@ declare class InputValidatorUtil {
11
11
  private static readonly uuid_regex_reg_exp;
12
12
  private static readonly custom_uuid_regex_reg_exp;
13
13
  private static get env_manager();
14
+ static isValidDecimalString(value: string | null | undefined, max_whole_digits?: number, max_fraction_digits?: number, allow_zero?: boolean): boolean;
15
+ static compareDecimalStrings(first_value: string, second_value: string): number;
16
+ static isValidUpperCode(value: string, min_length?: number, max_length?: number): boolean;
17
+ static hasUnsafeControlCharacter(value: string): boolean;
18
+ static stableSerialize(value: unknown): string;
19
+ static hashString(value: string, algorithm?: "sha256" | "sha384" | "sha512"): string;
20
+ static hasSensitiveObjectKey(value: unknown): boolean;
21
+ static getJsonByteLength(value: unknown): number;
14
22
  static isValidateIn: (value: any, allowed: any[]) => boolean;
15
23
  /** ✅ Check member roles */
16
24
  static isAdmin(name: string): boolean;
@@ -25,6 +25,87 @@ class InputValidatorUtil {
25
25
  static get env_manager() {
26
26
  return env_manager_util_1.default.getInstance();
27
27
  }
28
+ // Method to validate a non-negative decimal string with bounded precision.
29
+ static isValidDecimalString(value, max_whole_digits = 18, max_fraction_digits = 18, allow_zero = true) {
30
+ if (value === null ||
31
+ value === undefined ||
32
+ max_whole_digits < 1 ||
33
+ max_fraction_digits < 0) {
34
+ return false;
35
+ }
36
+ const decimal_pattern = new RegExp(`^\\d{1,${max_whole_digits}}${max_fraction_digits > 0 ? `(?:\\.\\d{1,${max_fraction_digits}})?` : ""}$`);
37
+ return (decimal_pattern.test(value) &&
38
+ (allow_zero || this.compareDecimalStrings(value, "0") > 0));
39
+ }
40
+ // Method to compare unsigned decimal strings without floating-point conversion.
41
+ static compareDecimalStrings(first_value, second_value) {
42
+ const normalize_value = (value) => {
43
+ const [whole_value = "0", fraction_value = ""] = value.split(".");
44
+ return [whole_value.replace(/^0+(?=\d)/, "") || "0", fraction_value.replace(/0+$/, "")];
45
+ };
46
+ const [first_whole, first_fraction] = normalize_value(first_value);
47
+ const [second_whole, second_fraction] = normalize_value(second_value);
48
+ if (first_whole.length !== second_whole.length) {
49
+ return first_whole.length > second_whole.length ? 1 : -1;
50
+ }
51
+ if (first_whole !== second_whole) {
52
+ return first_whole > second_whole ? 1 : -1;
53
+ }
54
+ const fraction_length = Math.max(first_fraction.length, second_fraction.length);
55
+ const normalized_first_fraction = first_fraction.padEnd(fraction_length, "0");
56
+ const normalized_second_fraction = second_fraction.padEnd(fraction_length, "0");
57
+ if (normalized_first_fraction === normalized_second_fraction) {
58
+ return 0;
59
+ }
60
+ return normalized_first_fraction > normalized_second_fraction ? 1 : -1;
61
+ }
62
+ // Method to validate an uppercase code containing letters, numbers, underscores, or hyphens.
63
+ static isValidUpperCode(value, min_length = 2, max_length = 80) {
64
+ if (min_length < 1 ||
65
+ max_length < min_length ||
66
+ value.length < min_length ||
67
+ value.length > max_length) {
68
+ return false;
69
+ }
70
+ return /^[A-Z0-9_-]+$/.test(value);
71
+ }
72
+ // Method to detect unsafe control characters while allowing tab and line breaks.
73
+ static hasUnsafeControlCharacter(value) {
74
+ return [...value].some((character) => {
75
+ const character_code = character.charCodeAt(0);
76
+ return character_code < 32 && ![9, 10, 13].includes(character_code);
77
+ });
78
+ }
79
+ // Method to serialize JSON-compatible data using stable object-key ordering.
80
+ static stableSerialize(value) {
81
+ if (Array.isArray(value)) {
82
+ return `[${value.map((item) => this.stableSerialize(item)).join(",")}]`;
83
+ }
84
+ if (value && typeof value === "object") {
85
+ const entries = Object.entries(value).sort(([first_key], [second_key]) => first_key.localeCompare(second_key));
86
+ return `{${entries.map(([key, item]) => `${JSON.stringify(key)}:${this.stableSerialize(item)}`).join(",")}}`;
87
+ }
88
+ return JSON.stringify(value) ?? "null";
89
+ }
90
+ // Method to hash a string with a supported cryptographic digest algorithm.
91
+ static hashString(value, algorithm = "sha256") {
92
+ return crypto_1.default.createHash(algorithm).update(value).digest("hex");
93
+ }
94
+ // Method to detect sensitive property names recursively in object or array data.
95
+ static hasSensitiveObjectKey(value) {
96
+ if (Array.isArray(value)) {
97
+ return value.some((item) => this.hasSensitiveObjectKey(item));
98
+ }
99
+ if (!value || typeof value !== "object") {
100
+ return false;
101
+ }
102
+ const sensitive_key_pattern = /(password|secret|credential|token|api[_-]?key|card|cvv|pin)/i;
103
+ return Object.entries(value).some(([key, item]) => sensitive_key_pattern.test(key) || this.hasSensitiveObjectKey(item));
104
+ }
105
+ // Method to return the UTF-8 byte size of JSON-compatible data.
106
+ static getJsonByteLength(value) {
107
+ return Buffer.byteLength(JSON.stringify(value), "utf8");
108
+ }
28
109
  static isValidateIn = (value, allowed) => allowed.includes(value);
29
110
  /** ✅ Check member roles */
30
111
  static isAdmin(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiberx-backend-toolkit",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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",
@@ -78,7 +78,8 @@
78
78
  "spell:check": "cspell .",
79
79
  "check": "npm run typecheck && npm run lint && npm run format:check && npm run spell:check && npm run build",
80
80
  "prepublishOnly": "npm run build",
81
- "update-dependencies": "node scripts/update-dependencies.js"
81
+ "update-dependencies": "node scripts/update-dependencies.js",
82
+ "generate:fibase-api": "node scripts/generate-fibase-registered-app-routes.js"
82
83
  },
83
84
  "files": [
84
85
  "dist"
@@ -96,16 +97,16 @@
96
97
  "dependencies": {
97
98
  "@google-cloud/storage": "^7.21.0",
98
99
  "@types/nodemailer": "^8.0.1",
99
- "axios": "^1.18.0",
100
+ "axios": "^1.18.1",
100
101
  "bcrypt": "^6.0.0",
101
102
  "dayjs": "^1.11.21",
102
103
  "ejs": "^6.0.1",
103
104
  "express": "^5.2.1",
104
- "js-yaml": "^4.2.0",
105
+ "js-yaml": "^5.2.2",
105
106
  "jsonwebtoken": "^9.0.3",
106
- "nodemailer": "^9.0.0",
107
+ "nodemailer": "^9.0.3",
107
108
  "sequelize": "^6.37.8",
108
- "uuid": "^14.0.0"
109
+ "uuid": "^14.0.1"
109
110
  },
110
111
  "devDependencies": {
111
112
  "@eslint/js": "^10.0.1",
@@ -114,21 +115,22 @@
114
115
  "@types/express": "^5.0.6",
115
116
  "@types/js-yaml": "^4.0.9",
116
117
  "@types/jsonwebtoken": "^9.0.10",
117
- "@types/node": "^25.9.3",
118
+ "@types/node": "^26.1.1",
118
119
  "cspell": "^10.0.1",
119
- "eslint": "^10.5.0",
120
- "globals": "^17.6.0",
121
- "prettier": "^3.8.4",
120
+ "eslint": "^10.8.0",
121
+ "globals": "^17.7.0",
122
+ "prettier": "^3.9.6",
122
123
  "ts-node": "^10.9.2",
123
- "tsc-alias": "^1.8.17",
124
+ "tsc-alias": "^1.9.1",
124
125
  "tsconfig-paths": "^4.2.0",
125
126
  "tsup": "^8.5.1",
126
127
  "typescript": "^6.0.3",
127
- "typescript-eslint": "^8.61.1"
128
+ "typescript-eslint": "^8.65.0"
128
129
  },
129
130
  "overrides": {
130
- "qs": "^6.15.2",
131
- "uuid": "^14.0.0"
131
+ "qs": "^6.15.3",
132
+ "uuid": "^14.0.1",
133
+ "esbuild": "^0.28.1"
132
134
  },
133
135
  "engines": {
134
136
  "node": ">=24 <27"
@@ -136,6 +138,6 @@
136
138
  "allowScripts": {
137
139
  "bcrypt@6.0.0": true,
138
140
  "fsevents@2.3.3": true,
139
- "esbuild@0.15.18": true
141
+ "esbuild@0.28.1": true
140
142
  }
141
143
  }