@mrxsys/mrx-core 2.11.0-4-and-276-20251029 → 2.11.0
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/dist/{chunk-0d0zd2yg.js → chunk-037vwvd4.js} +2 -2
- package/dist/{chunk-jksb9ers.js → chunk-10w8mg8e.js} +1 -1
- package/dist/{chunk-dre2fgj0.js → chunk-2z8amjqt.js} +1 -1
- package/dist/{chunk-p14h6jfs.js → chunk-4g0x6g4j.js} +2 -2
- package/dist/chunk-4t7sy5qt.js +10 -0
- package/dist/chunk-642xajvx.js +59 -0
- package/dist/chunk-6hs00zfd.js +13 -0
- package/dist/{chunk-afyz8rg5.js → chunk-7j86h1nd.js} +14 -9
- package/dist/chunk-8pw0syzf.js +9 -0
- package/dist/{chunk-eeb7yskp.js → chunk-awphtyzp.js} +4 -4
- package/dist/{chunk-8tffnbpn.js → chunk-ayyrgqyv.js} +1 -1
- package/dist/{chunk-12qzn7jw.js → chunk-dmsev7vs.js} +1 -1
- package/dist/{chunk-gtn1kn0z.js → chunk-hv6g22kf.js} +4 -4
- package/dist/chunk-hwfebx4x.js +11 -0
- package/dist/{chunk-e30paw8a.js → chunk-j7dyc5ks.js} +5 -5
- package/dist/chunk-jz3wd472.js +23 -0
- package/dist/{chunk-fs3wm3p4.js → chunk-r7yr9p57.js} +6 -6
- package/dist/{chunk-afd82epa.js → chunk-sbpj7f3p.js} +13 -13
- package/dist/{chunk-pjv1ekwr.js → chunk-tmvj28bq.js} +1 -1
- package/dist/chunk-y5dtkmnp.js +8 -0
- package/dist/chunk-yrt0ffvf.js +9 -0
- package/dist/{chunk-441xs5k1.js → chunk-yzgdqb02.js} +6 -6
- package/dist/chunk-zn2nm5gg.js +9 -0
- package/dist/{chunk-7t524zqh.js → chunk-zv4ta4fb.js} +3 -3
- package/dist/errors/{base-error.d.ts → app-error.d.ts} +2 -1
- package/dist/errors/http-error.d.ts +2 -2
- package/dist/errors/index.d.ts +2 -1
- package/dist/errors/index.js +6 -4
- package/dist/errors/internal-error.d.ts +4 -0
- package/dist/modules/data/data.d.ts +5 -5
- package/dist/modules/data/enums/data-error-keys.d.ts +1 -1
- package/dist/modules/data/enums/index.js +1 -1
- package/dist/modules/data/index.js +3 -3
- package/dist/modules/database/enums/database-error-keys.d.ts +26 -26
- package/dist/modules/database/enums/index.js +1 -1
- package/dist/modules/database/enums/mssql-error-code.d.ts +23 -23
- package/dist/modules/database/index.js +5 -5
- package/dist/modules/database/mssql.d.ts +9 -9
- package/dist/modules/elysia/cache/index.js +3 -3
- package/dist/modules/elysia/crud/index.js +13 -13
- package/dist/modules/elysia/crud/operations/count.d.ts +20 -4
- package/dist/modules/elysia/crud/operations/delete.d.ts +25 -9
- package/dist/modules/elysia/crud/operations/deleteOne.d.ts +25 -9
- package/dist/modules/elysia/crud/operations/find.d.ts +25 -9
- package/dist/modules/elysia/crud/operations/findOne.d.ts +25 -9
- package/dist/modules/elysia/crud/operations/index.js +10 -10
- package/dist/modules/elysia/crud/operations/insert.d.ts +25 -9
- package/dist/modules/elysia/crud/operations/update.d.ts +25 -19
- package/dist/modules/elysia/crud/operations/updateOne.d.ts +25 -19
- package/dist/modules/elysia/crud/types/response-200-schema.d.ts +2 -2
- package/dist/modules/elysia/crud/utils/create-insert-schema.d.ts +3 -8
- package/dist/modules/elysia/crud/utils/index.js +4 -4
- package/dist/modules/elysia/db-resolver/enums/db-resolver-error-keys.d.ts +1 -1
- package/dist/modules/elysia/db-resolver/enums/index.js +1 -1
- package/dist/modules/elysia/db-resolver/index.js +9 -9
- package/dist/modules/elysia/error/enums/error.keys.d.ts +4 -4
- package/dist/modules/elysia/error/enums/index.js +1 -1
- package/dist/modules/elysia/error/error.d.ts +47 -1
- package/dist/modules/elysia/error/index.d.ts +1 -1
- package/dist/modules/elysia/error/index.js +47 -38
- package/dist/modules/elysia/microservice/enums/index.js +1 -1
- package/dist/modules/elysia/microservice/enums/microservice-success-keys.d.ts +2 -2
- package/dist/modules/elysia/microservice/index.js +1 -1
- package/dist/modules/elysia/rate-limit/enums/index.js +1 -1
- package/dist/modules/elysia/rate-limit/enums/rate-limit-error-keys.d.ts +1 -1
- package/dist/modules/elysia/rate-limit/index.js +5 -5
- package/dist/modules/jwt/enums/index.js +2 -2
- package/dist/modules/jwt/enums/jwt-error-keys.d.ts +3 -3
- package/dist/modules/jwt/enums/parse-human-time-to-seconds-error-keys.d.ts +1 -1
- package/dist/modules/jwt/index.js +10 -12
- package/dist/modules/jwt/utils/index.js +3 -3
- package/dist/modules/jwt/utils/parse-human-time-to-seconds.d.ts +1 -1
- package/dist/modules/kv-store/bun-redis/index.js +7 -7
- package/dist/modules/kv-store/enums/index.js +1 -1
- package/dist/modules/kv-store/enums/kv-store-error-keys.d.ts +3 -3
- package/dist/modules/kv-store/ioredis/index.js +7 -7
- package/dist/modules/kv-store/memory/index.js +3 -3
- package/dist/modules/logger/enums/index.js +1 -1
- package/dist/modules/logger/enums/logger-error-keys.d.ts +7 -7
- package/dist/modules/logger/events/logger-events.d.ts +4 -4
- package/dist/modules/logger/index.js +86 -11
- package/dist/modules/logger/logger.d.ts +1 -1
- package/dist/modules/logger/sinks/console-logger.d.ts +1 -1
- package/dist/modules/logger/sinks/file-logger/enums/file-logger-error-keys.d.ts +1 -1
- package/dist/modules/logger/sinks/index.js +7 -7
- package/dist/modules/logger/worker-logger.d.ts +1 -0
- package/dist/modules/mailer/enums/index.js +1 -1
- package/dist/modules/mailer/enums/mailer-error-keys.d.ts +3 -3
- package/dist/modules/mailer/index.js +6 -6
- package/dist/modules/mailer/smtp.d.ts +4 -4
- package/dist/modules/repository/index.js +4 -4
- package/dist/modules/repository/repository.d.ts +9 -9
- package/dist/modules/singleton-manager/enums/index.js +1 -1
- package/dist/modules/singleton-manager/enums/singleton-manager-error-keys.d.ts +2 -2
- package/dist/modules/singleton-manager/index.js +3 -3
- package/dist/modules/singleton-manager/singleton-manager.d.ts +3 -3
- package/dist/modules/totp/enums/index.js +1 -1
- package/dist/modules/totp/enums/totp-error-keys.d.ts +5 -5
- package/dist/modules/totp/index.js +6 -6
- package/dist/modules/totp/otp-auth-uri.d.ts +1 -1
- package/dist/modules/totp/utils/base32.d.ts +1 -1
- package/dist/modules/totp/utils/generate-secret-bytes.d.ts +1 -1
- package/dist/modules/totp/utils/index.js +5 -5
- package/dist/shared/utils/env.d.ts +1 -1
- package/dist/shared/utils/index.js +3 -3
- package/package.json +16 -17
- package/CHANGELOG.md +0 -407
- package/dist/chunk-4v86f7gp.js +0 -59
- package/dist/chunk-6w9ja96e.js +0 -9
- package/dist/chunk-9cgzhc50.js +0 -15
- package/dist/chunk-9d3zvgp6.js +0 -9
- package/dist/chunk-9r5anep5.js +0 -11
- package/dist/chunk-rz5p4j3p.js +0 -13
- package/dist/chunk-spnh9dzk.js +0 -10
- package/dist/chunk-xhhj1gvj.js +0 -9
- package/dist/chunk-z0ct35ft.js +0 -8
- package/dist/errors/utils/index.d.ts +0 -1
- package/dist/errors/utils/index.js +0 -16
- package/dist/errors/utils/is-nowarajs-error.ts.d.ts +0 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "../../../chunk-
|
|
3
|
+
InternalError
|
|
4
|
+
} from "../../../chunk-jz3wd472.js";
|
|
5
5
|
|
|
6
6
|
// source/modules/logger/sinks/console-logger.ts
|
|
7
7
|
class ConsoleLoggerSink {
|
|
8
|
-
|
|
8
|
+
log(level, timestamp, object) {
|
|
9
9
|
const logEntry = { timestamp, level, content: object };
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const logLevel = level.toLowerCase();
|
|
11
|
+
console[logLevel]?.(JSON.stringify(logEntry));
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
// source/modules/logger/sinks/devnull-logger.ts
|
|
@@ -17,7 +17,7 @@ class DevNullLoggerSink {
|
|
|
17
17
|
}
|
|
18
18
|
// source/modules/logger/sinks/file-logger/enums/file-logger-error-keys.ts
|
|
19
19
|
var FILE_LOGGER_ERROR_KEYS = {
|
|
20
|
-
FAILED_TO_CLOSE_STREAM: "
|
|
20
|
+
FAILED_TO_CLOSE_STREAM: "nowarajs.logger.file_logger.error.failed_to_close_stream"
|
|
21
21
|
};
|
|
22
22
|
// source/modules/logger/sinks/file-logger/file-logger.ts
|
|
23
23
|
import { createWriteStream } from "fs";
|
|
@@ -51,7 +51,7 @@ class FileLoggerSink {
|
|
|
51
51
|
return new Promise((resolve, reject) => {
|
|
52
52
|
this._stream.end((err) => {
|
|
53
53
|
if (err)
|
|
54
|
-
reject(new
|
|
54
|
+
reject(new InternalError(FILE_LOGGER_ERROR_KEYS.FAILED_TO_CLOSE_STREAM, err.message));
|
|
55
55
|
else
|
|
56
56
|
resolve();
|
|
57
57
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const workerFunction: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const MAILER_ERROR_KEYS: {
|
|
2
|
-
readonly SMTP_ALREADY_CONNECTED: "mrx-core.mailer.error.smtp.already_connected";
|
|
3
|
-
readonly SMTP_CONNECTION_ERROR: "mrx-core.mailer.error.smtp.connection_error";
|
|
4
|
-
readonly SMTP_NOT_CONNECTED: "mrx-core.mailer.error.smtp.not_connected";
|
|
2
|
+
readonly SMTP_ALREADY_CONNECTED: "mrx.mrx-core.mailer.error.smtp.already_connected";
|
|
3
|
+
readonly SMTP_CONNECTION_ERROR: "mrx.mrx-core.mailer.error.smtp.connection_error";
|
|
4
|
+
readonly SMTP_NOT_CONNECTED: "mrx.mrx-core.mailer.error.smtp.not_connected";
|
|
5
5
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
MAILER_ERROR_KEYS
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-yrt0ffvf.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "../../chunk-
|
|
6
|
+
InternalError
|
|
7
|
+
} from "../../chunk-jz3wd472.js";
|
|
8
8
|
|
|
9
9
|
// source/modules/mailer/smtp.ts
|
|
10
10
|
import { createTransport } from "nodemailer";
|
|
@@ -20,7 +20,7 @@ class SMTP {
|
|
|
20
20
|
}
|
|
21
21
|
async connect() {
|
|
22
22
|
if (this._transporter)
|
|
23
|
-
throw new
|
|
23
|
+
throw new InternalError(MAILER_ERROR_KEYS.SMTP_ALREADY_CONNECTED);
|
|
24
24
|
this._transporter = createTransport({
|
|
25
25
|
host: this._config.host,
|
|
26
26
|
port: this._config.port,
|
|
@@ -35,7 +35,7 @@ class SMTP {
|
|
|
35
35
|
try {
|
|
36
36
|
await this._transporter.verify();
|
|
37
37
|
} catch (error) {
|
|
38
|
-
throw new
|
|
38
|
+
throw new InternalError(MAILER_ERROR_KEYS.SMTP_CONNECTION_ERROR, error);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
disconnect() {
|
|
@@ -46,7 +46,7 @@ class SMTP {
|
|
|
46
46
|
}
|
|
47
47
|
async sendMail(options) {
|
|
48
48
|
if (!this._transporter)
|
|
49
|
-
throw new
|
|
49
|
+
throw new InternalError(MAILER_ERROR_KEYS.SMTP_NOT_CONNECTED);
|
|
50
50
|
return this._transporter.sendMail(options);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -4,7 +4,7 @@ import type { SMTPOptions } from './types/smtp-options';
|
|
|
4
4
|
* The `SMTP` class manages the connection and operations with an SMTP server.
|
|
5
5
|
*
|
|
6
6
|
* This class provides methods to connect, disconnect, and send emails using
|
|
7
|
-
* the Nodemailer library. It supports connection pooling and error handling ({@link
|
|
7
|
+
* the Nodemailer library. It supports connection pooling and error handling ({@link InternalError}).
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
@@ -39,8 +39,8 @@ export declare class SMTP {
|
|
|
39
39
|
* It enables connection pooling for efficient resource usage and sets the maximum number of
|
|
40
40
|
* concurrent connections as specified in the configuration (default: 5).
|
|
41
41
|
*
|
|
42
|
-
* @throws ({@link
|
|
43
|
-
* @throws ({@link
|
|
42
|
+
* @throws ({@link InternalError}) - If the transporter is already connected.
|
|
43
|
+
* @throws ({@link InternalError}) - If the connection or verification fails.
|
|
44
44
|
*/
|
|
45
45
|
connect(): Promise<void>;
|
|
46
46
|
/**
|
|
@@ -54,7 +54,7 @@ export declare class SMTP {
|
|
|
54
54
|
*
|
|
55
55
|
* @param options - The mail options, such as recipient, subject, and content.
|
|
56
56
|
*
|
|
57
|
-
* @throws ({@link
|
|
57
|
+
* @throws ({@link InternalError}) - If the transporter is not connected.
|
|
58
58
|
*
|
|
59
59
|
* @returns A promise resolving to the result of the send operation.
|
|
60
60
|
*/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
Repository
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-7j86h1nd.js";
|
|
5
5
|
import"../../chunk-grfyngq0.js";
|
|
6
|
-
import"../../chunk-
|
|
7
|
-
import"../../chunk-7t524zqh.js";
|
|
6
|
+
import"../../chunk-zv4ta4fb.js";
|
|
8
7
|
import"../../chunk-sqts8vyk.js";
|
|
9
|
-
import"../../chunk-
|
|
8
|
+
import"../../chunk-jz3wd472.js";
|
|
9
|
+
import"../../chunk-642xajvx.js";
|
|
10
10
|
export {
|
|
11
11
|
Repository
|
|
12
12
|
};
|
|
@@ -17,7 +17,7 @@ import type { QueryOptionsExtendStream } from './types/query-options-extend-stre
|
|
|
17
17
|
* const users = await repo.find({ limit: 10 });
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export declare class Repository<TModel = unknown
|
|
20
|
+
export declare class Repository<TModel = Record<string, unknown>> {
|
|
21
21
|
/**
|
|
22
22
|
* The Knex instance used for database operations.
|
|
23
23
|
*/
|
|
@@ -124,7 +124,7 @@ export declare class Repository<TModel = unknown> {
|
|
|
124
124
|
* });
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
|
-
findStream<KModel extends TModel =
|
|
127
|
+
findStream<KModel extends TModel = TModel>(options?: QueryOptionsExtendStream<KModel>): StreamWithAsyncIterable<Required<KModel>>;
|
|
128
128
|
/**
|
|
129
129
|
* Finds records in the database based on the specified query options and returns the results
|
|
130
130
|
* as an array. This method supports comprehensive filtering, pagination, field selection, and sorting
|
|
@@ -191,7 +191,7 @@ export declare class Repository<TModel = unknown> {
|
|
|
191
191
|
* });
|
|
192
192
|
* ```
|
|
193
193
|
*/
|
|
194
|
-
find<KModel extends TModel =
|
|
194
|
+
find<KModel extends TModel = TModel>(options?: QueryOptionsExtendPagination<KModel>): Promise<Required<KModel>[]>;
|
|
195
195
|
/**
|
|
196
196
|
* Counts the number of records in the database based on the specified query options.
|
|
197
197
|
* This method supports advanced filtering capabilities to count records that match specific criteria.
|
|
@@ -228,7 +228,7 @@ export declare class Repository<TModel = unknown> {
|
|
|
228
228
|
* });
|
|
229
229
|
* ```
|
|
230
230
|
*/
|
|
231
|
-
count<KModel extends TModel =
|
|
231
|
+
count<KModel extends TModel = TModel>(options?: Omit<QueryOptions<KModel>, 'selectedFields' | 'orderBy'>): Promise<number>;
|
|
232
232
|
/**
|
|
233
233
|
* Inserts new records into the database and returns the inserted records.
|
|
234
234
|
* This method supports bulk insertion of multiple records at once.
|
|
@@ -265,7 +265,7 @@ export declare class Repository<TModel = unknown> {
|
|
|
265
265
|
* });
|
|
266
266
|
* ```
|
|
267
267
|
*/
|
|
268
|
-
insert<KModel extends TModel =
|
|
268
|
+
insert<KModel extends TModel = TModel>(data: Partial<NoInfer<KModel>> | Partial<NoInfer<KModel>>[], options?: Omit<QueryOptions<KModel>, 'filters' | 'orderBy'>): Promise<Required<KModel>[]>;
|
|
269
269
|
/**
|
|
270
270
|
* Updates existing records in the database based on the specified query options and returns the updated records.
|
|
271
271
|
* This method supports advanced filtering capabilities to update records that match specific criteria.
|
|
@@ -304,7 +304,7 @@ export declare class Repository<TModel = unknown> {
|
|
|
304
304
|
* });
|
|
305
305
|
* ```
|
|
306
306
|
*/
|
|
307
|
-
update<KModel extends TModel =
|
|
307
|
+
update<KModel extends TModel = TModel>(data: Partial<NoInfer<KModel>>, options: Omit<QueryOptionsExtendPagination<KModel>, 'orderBy' | 'filters'> & Required<Pick<QueryOptions<KModel>, 'filters'>>): Promise<Required<KModel>[]>;
|
|
308
308
|
/**
|
|
309
309
|
* Deletes records from the database based on the specified query options and returns the deleted records.
|
|
310
310
|
* This method supports advanced filtering capabilities to filter the records before deletion.
|
|
@@ -342,7 +342,7 @@ export declare class Repository<TModel = unknown> {
|
|
|
342
342
|
* });
|
|
343
343
|
* ```
|
|
344
344
|
*/
|
|
345
|
-
delete<KModel extends TModel = NoInfer<TModel>>(options: Omit<QueryOptions<KModel>, 'orderBy' | 'filters'> & Required<Pick<QueryOptions<KModel>, 'filters'>>): Promise<KModel[]>;
|
|
345
|
+
delete<KModel extends TModel = NoInfer<TModel>>(options: Omit<QueryOptions<KModel>, 'orderBy' | 'filters'> & Required<Pick<QueryOptions<KModel>, 'filters'>>): Promise<Required<KModel>[]>;
|
|
346
346
|
/**
|
|
347
347
|
* Applies selected fields to a Knex.js query builder. This method supports both single and multiple field selections.
|
|
348
348
|
* It is used to specify which fields should be returned in the query results.
|
|
@@ -352,7 +352,7 @@ export declare class Repository<TModel = unknown> {
|
|
|
352
352
|
* @param query - The Knex.js query builder to apply the selected fields to.
|
|
353
353
|
* @param selectedFields - The fields to select. Can be a single field or an array of fields.
|
|
354
354
|
*/
|
|
355
|
-
protected _applySelectedFields<KModel>(query: Knex.QueryBuilder, selectedFields: QueryOptions<KModel>['selectedFields']
|
|
355
|
+
protected _applySelectedFields<KModel>(query: Knex.QueryBuilder, selectedFields: QueryOptions<KModel>['selectedFields']): void;
|
|
356
356
|
/**
|
|
357
357
|
* Applies filter criteria to a Knex.js query builder. This method supports complex queries
|
|
358
358
|
* using operators like `$eq`, `$neq`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$nin`, `$between`, `$nbetween`,
|
|
@@ -417,5 +417,5 @@ export declare class Repository<TModel = unknown> {
|
|
|
417
417
|
*
|
|
418
418
|
* @returns An array of records returned by the query.
|
|
419
419
|
*/
|
|
420
|
-
protected _executeQuery<KModel>(query: Knex.QueryBuilder, throwIfNoResult?: QueryOptions<KModel>['throwIfNoResult']): Promise<KModel[]>;
|
|
420
|
+
protected _executeQuery<KModel>(query: Knex.QueryBuilder, throwIfNoResult?: QueryOptions<KModel>['throwIfNoResult']): Promise<Required<KModel>[]>;
|
|
421
421
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const SINGLETON_MANAGER_ERROR_KEYS: {
|
|
2
|
-
readonly CLASS_INSTANCE_ALREADY_REGISTERED: "mrx-core.singleton-manager.error.class_instance_already_registered";
|
|
3
|
-
readonly CLASS_INSTANCE_NOT_REGISTERED: "mrx-core.singleton-manager.error.class_instance_not_registered";
|
|
2
|
+
readonly CLASS_INSTANCE_ALREADY_REGISTERED: "mrx.mrx-core.singleton-manager.error.class_instance_already_registered";
|
|
3
|
+
readonly CLASS_INSTANCE_NOT_REGISTERED: "mrx.mrx-core.singleton-manager.error.class_instance_not_registered";
|
|
4
4
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
SingletonManager
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import"../../chunk-
|
|
6
|
-
import"../../chunk-
|
|
4
|
+
} from "../../chunk-r7yr9p57.js";
|
|
5
|
+
import"../../chunk-y5dtkmnp.js";
|
|
6
|
+
import"../../chunk-jz3wd472.js";
|
|
7
7
|
export {
|
|
8
8
|
SingletonManager
|
|
9
9
|
};
|
|
@@ -39,7 +39,7 @@ export declare class SingletonManager {
|
|
|
39
39
|
* @param name - The name of the class.
|
|
40
40
|
* @param instance - The instance of the class to register as singleton.
|
|
41
41
|
*
|
|
42
|
-
* @throws ({@link
|
|
42
|
+
* @throws ({@link InternalError}) If the name is already registered, it throws an error.
|
|
43
43
|
*/
|
|
44
44
|
static register<TClass extends object>(name: string, instance: TClass): void;
|
|
45
45
|
/**
|
|
@@ -47,7 +47,7 @@ export declare class SingletonManager {
|
|
|
47
47
|
*
|
|
48
48
|
* @param name - The name of the class to unregister.
|
|
49
49
|
*
|
|
50
|
-
* @throws ({@link
|
|
50
|
+
* @throws ({@link InternalError}) If the name is not registered, it throws an error.
|
|
51
51
|
*/
|
|
52
52
|
static unregister(name: string): void;
|
|
53
53
|
/**
|
|
@@ -57,7 +57,7 @@ export declare class SingletonManager {
|
|
|
57
57
|
*
|
|
58
58
|
* @param name - The name of the class to get the singleton instance.
|
|
59
59
|
*
|
|
60
|
-
* @throws ({@link
|
|
60
|
+
* @throws ({@link InternalError}) If the class is not registered, it throws an error.
|
|
61
61
|
*
|
|
62
62
|
* @returns The singleton instance of the class.
|
|
63
63
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const TOTP_ERROR_KEYS: {
|
|
2
|
-
readonly INVALID_ALGORITHM: "mrx-core.totp.error.invalid_algorithm";
|
|
3
|
-
readonly INVALID_BASE32_CHARACTER: "mrx-core.totp.error.invalid_base32_character";
|
|
4
|
-
readonly INVALID_OTP_AUTH_URI: "mrx-core.totp.error.invalid_otp_auth_uri";
|
|
5
|
-
readonly INVALID_SECRET_LENGTH: "mrx-core.totp.error.invalid_secret_length";
|
|
6
|
-
readonly MISSING_SECRET: "mrx-core.totp.error.missing_secret";
|
|
2
|
+
readonly INVALID_ALGORITHM: "mrx.mrx-core.totp.error.invalid_algorithm";
|
|
3
|
+
readonly INVALID_BASE32_CHARACTER: "mrx.mrx-core.totp.error.invalid_base32_character";
|
|
4
|
+
readonly INVALID_OTP_AUTH_URI: "mrx.mrx-core.totp.error.invalid_otp_auth_uri";
|
|
5
|
+
readonly INVALID_SECRET_LENGTH: "mrx.mrx-core.totp.error.invalid_secret_length";
|
|
6
|
+
readonly MISSING_SECRET: "mrx.mrx-core.totp.error.missing_secret";
|
|
7
7
|
};
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "../../chunk-m3grz32t.js";
|
|
7
7
|
import {
|
|
8
8
|
TOTP_ERROR_KEYS
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-hwfebx4x.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "../../chunk-
|
|
11
|
+
InternalError
|
|
12
|
+
} from "../../chunk-jz3wd472.js";
|
|
13
13
|
|
|
14
14
|
// source/modules/totp/hotp.ts
|
|
15
15
|
import { webcrypto } from "crypto";
|
|
@@ -47,13 +47,13 @@ var buildOtpAuthUri = ({
|
|
|
47
47
|
var parseOtpAuthUri = (uri) => {
|
|
48
48
|
const url = new URL(uri);
|
|
49
49
|
if (url.protocol !== "otpauth:")
|
|
50
|
-
throw new
|
|
50
|
+
throw new InternalError(TOTP_ERROR_KEYS.INVALID_OTP_AUTH_URI);
|
|
51
51
|
if (url.hostname !== "totp")
|
|
52
|
-
throw new
|
|
52
|
+
throw new InternalError(TOTP_ERROR_KEYS.INVALID_OTP_AUTH_URI);
|
|
53
53
|
const label = decodeURIComponent(url.pathname.slice(1));
|
|
54
54
|
const secretBase32 = url.searchParams.get("secret");
|
|
55
55
|
if (!secretBase32)
|
|
56
|
-
throw new
|
|
56
|
+
throw new InternalError(TOTP_ERROR_KEYS.MISSING_SECRET);
|
|
57
57
|
const issuerParam = url.searchParams.get("issuer");
|
|
58
58
|
const issuer = issuerParam ? decodeURIComponent(issuerParam) : undefined;
|
|
59
59
|
const algorithm = url.searchParams.get("algorithm") || "SHA-1";
|
|
@@ -12,7 +12,7 @@ export declare const buildOtpAuthUri: ({ secretBase32, label, issuer, algorithm,
|
|
|
12
12
|
*
|
|
13
13
|
* @param uri - OTPAuth URI to parse
|
|
14
14
|
*
|
|
15
|
-
* @throws ({@link
|
|
15
|
+
* @throws ({@link InternalError}) - if the URI is invalid or missing required parameters
|
|
16
16
|
*
|
|
17
17
|
* @returns Parsed URI parameters
|
|
18
18
|
*/
|
|
@@ -12,7 +12,7 @@ export declare const base32Encode: (input: string | Uint8Array, withPadding?: bo
|
|
|
12
12
|
*
|
|
13
13
|
* @param base32 - Base32 string to decode
|
|
14
14
|
*
|
|
15
|
-
* @throws ({@link
|
|
15
|
+
* @throws ({@link InternalError}) - if invalid Base32 character is found
|
|
16
16
|
*
|
|
17
17
|
* @returns Decoded bytes
|
|
18
18
|
*/
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "../../../chunk-m3grz32t.js";
|
|
7
7
|
import {
|
|
8
8
|
TOTP_ERROR_KEYS
|
|
9
|
-
} from "../../../chunk-
|
|
9
|
+
} from "../../../chunk-hwfebx4x.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "../../../chunk-
|
|
11
|
+
InternalError
|
|
12
|
+
} from "../../../chunk-jz3wd472.js";
|
|
13
13
|
|
|
14
14
|
// source/modules/totp/utils/base32.ts
|
|
15
15
|
var BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
@@ -43,7 +43,7 @@ var base32Decode = (base32) => {
|
|
|
43
43
|
for (const char of cleanBase32) {
|
|
44
44
|
const charValue = BASE32_ALPHABET.indexOf(char);
|
|
45
45
|
if (charValue === -1)
|
|
46
|
-
throw new
|
|
46
|
+
throw new InternalError(TOTP_ERROR_KEYS.INVALID_BASE32_CHARACTER, `Invalid Base32 character: ${char}`);
|
|
47
47
|
value = value << 5 | charValue;
|
|
48
48
|
bits += 5;
|
|
49
49
|
if (bits >= 8) {
|
|
@@ -57,7 +57,7 @@ var base32Decode = (base32) => {
|
|
|
57
57
|
import { getRandomValues } from "crypto";
|
|
58
58
|
var generateSecretBytes = (length = 20) => {
|
|
59
59
|
if (length <= 0)
|
|
60
|
-
throw new
|
|
60
|
+
throw new InternalError(TOTP_ERROR_KEYS.INVALID_SECRET_LENGTH);
|
|
61
61
|
return getRandomValues(new Uint8Array(length));
|
|
62
62
|
};
|
|
63
63
|
// source/modules/totp/utils/time-remaining.ts
|
|
@@ -5,6 +5,6 @@ import type { TSchema } from '@sinclair/typebox';
|
|
|
5
5
|
* @param schema - The schema to validate the environment variables against.
|
|
6
6
|
* @param env - The environment variables to validate. Defaults to `process.env`.
|
|
7
7
|
*
|
|
8
|
-
* @throws ({@link
|
|
8
|
+
* @throws ({@link InternalError}) - If the environment variables are invalid based on the schema.
|
|
9
9
|
*/
|
|
10
10
|
export declare const validateEnv: (schema: TSchema, env?: Record<string, unknown>) => void;
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
makeStreamAsyncIterable
|
|
11
11
|
} from "../../chunk-grfyngq0.js";
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
} from "../../chunk-
|
|
13
|
+
InternalError
|
|
14
|
+
} from "../../chunk-jz3wd472.js";
|
|
15
15
|
|
|
16
16
|
// source/shared/utils/env.ts
|
|
17
17
|
import { Value } from "@sinclair/typebox/value";
|
|
@@ -19,7 +19,7 @@ var validateEnv = (schema, env = process.env) => {
|
|
|
19
19
|
try {
|
|
20
20
|
Value.Assert(schema, Value.Parse(schema, env));
|
|
21
21
|
} catch (error) {
|
|
22
|
-
throw new
|
|
22
|
+
throw new InternalError(UTILS_ERROR_KEYS.INVALID_ENVIRONMENT, error);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
export {
|
package/package.json
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrxsys/mrx-core",
|
|
3
|
-
"version": "2.11.0
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"author": "Ruby",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@eslint/js": "^9.
|
|
6
|
+
"@eslint/js": "^9.39.1",
|
|
7
7
|
"@sinclair/typebox": "0.34.41",
|
|
8
|
-
"@stylistic/eslint-plugin": "^5.
|
|
9
|
-
"@types/bun": "^1.3.
|
|
10
|
-
"@types/nodemailer": "^7.0.
|
|
11
|
-
"elysia": "1.4.
|
|
12
|
-
"eslint": "^9.
|
|
13
|
-
"globals": "^16.
|
|
8
|
+
"@stylistic/eslint-plugin": "^5.6.1",
|
|
9
|
+
"@types/bun": "^1.3.3",
|
|
10
|
+
"@types/nodemailer": "^7.0.4",
|
|
11
|
+
"elysia": "1.4.16",
|
|
12
|
+
"eslint": "^9.39.1",
|
|
13
|
+
"globals": "^16.5.0",
|
|
14
14
|
"ioredis": "^5.8.2",
|
|
15
|
-
"jose": "^6.1.
|
|
15
|
+
"jose": "^6.1.2",
|
|
16
16
|
"knex": "^3.1.0",
|
|
17
|
-
"mssql": "^12.
|
|
18
|
-
"nodemailer": "^7.0.
|
|
19
|
-
"typescript-eslint": "^8.
|
|
17
|
+
"mssql": "^12.1.1",
|
|
18
|
+
"nodemailer": "^7.0.11",
|
|
19
|
+
"typescript-eslint": "^8.48.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@sinclair/typebox": "0.34.41",
|
|
23
|
-
"elysia": "^1.4.
|
|
23
|
+
"elysia": "^1.4.16",
|
|
24
24
|
"ioredis": "^5.8.2",
|
|
25
|
-
"jose": "^6.1.
|
|
26
|
-
"mssql": "^12.
|
|
25
|
+
"jose": "^6.1.2",
|
|
26
|
+
"mssql": "^12.1.1",
|
|
27
27
|
"knex": "^3.1.0",
|
|
28
|
-
"nodemailer": "^7.0.
|
|
28
|
+
"nodemailer": "^7.0.11",
|
|
29
29
|
"typescript": "^5.9.3"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
32
32
|
"./errors": "./dist/errors/index.js",
|
|
33
33
|
"./errors/enums": "./dist/errors/enums/index.js",
|
|
34
|
-
"./errors/utils": "./dist/errors/utils/index.js",
|
|
35
34
|
"./modules/data": "./dist/modules/data/index.js",
|
|
36
35
|
"./modules/data/enums": "./dist/modules/data/enums/index.js",
|
|
37
36
|
"./modules/data/transformers": "./dist/modules/data/transformers/index.js",
|