namirasoft-node 1.4.99 → 1.4.101
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/OTPOperation.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class OTPOperation {
|
|
|
8
8
|
static getWaitTime(x_otp_req_tried_count: number): number;
|
|
9
9
|
static onSafeRequest<T>(x_otp: string | null, x_otp_time: Date | string | null, x_otp_req_tried_count: number, handler: (row: {
|
|
10
10
|
x_otp: string;
|
|
11
|
-
x_otp_time: Date
|
|
11
|
+
x_otp_time: Date;
|
|
12
12
|
x_otp_req_tried_count: number;
|
|
13
13
|
x_otp_ver_tried_count: number;
|
|
14
14
|
}) => Promise<T>): Promise<T>;
|
package/dist/OTPOperation.js
CHANGED
|
@@ -55,16 +55,16 @@ class OTPOperation {
|
|
|
55
55
|
static onSafeVerify(x_otp, x_otp_time, x_otp_ver_tried_count, code, handler, errorHandler) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
if (!x_otp || !x_otp_time)
|
|
58
|
-
throw namirasoft_core_1.ErrorOperation.getHTTP(
|
|
58
|
+
throw namirasoft_core_1.ErrorOperation.getHTTP(404, "The OTP not generated yet. Please request first.");
|
|
59
59
|
if (x_otp_time != null)
|
|
60
60
|
x_otp_time = new Date(x_otp_time);
|
|
61
61
|
if (x_otp_time < namirasoft_core_1.TimeOperation.minutesAgo(OTPOperation.OTP_EXPIRE_TIME, new Date()))
|
|
62
|
-
namirasoft_core_1.ErrorOperation.throwHTTP(
|
|
62
|
+
namirasoft_core_1.ErrorOperation.throwHTTP(410, "The OTP code expired. Please request again.");
|
|
63
63
|
if (x_otp_ver_tried_count > OTPOperation.OTP_VER_MAX_TRY_COUNT)
|
|
64
|
-
namirasoft_core_1.ErrorOperation.throwHTTP(
|
|
64
|
+
namirasoft_core_1.ErrorOperation.throwHTTP(429, "The try limit attempt exceeded. Please request again.");
|
|
65
65
|
if (x_otp !== code) {
|
|
66
66
|
yield errorHandler();
|
|
67
|
-
namirasoft_core_1.ErrorOperation.throwHTTP(
|
|
67
|
+
namirasoft_core_1.ErrorOperation.throwHTTP(401, "Wrong code.");
|
|
68
68
|
}
|
|
69
69
|
return yield handler({
|
|
70
70
|
x_otp: null,
|
package/dist/OTPOperation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTPOperation.js","sourceRoot":"","sources":["../src/OTPOperation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAgE;AAEhE,MAAa,YAAY;IASrB,MAAM,CAAC,QAAQ,CAAC,SAAiB,CAAC,EAAE,QAAgB,CAAC;QAEjD,IAAI,CAAC,MAAM;YACP,MAAM,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,KAAK;YACN,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;YAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;QACpD,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE;YAC3B,GAAG,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACf,CAAC;IACD,MAAM,CAAC,WAAW,CAAC,qBAA6B;QAE5C,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,aAAa,GAAG,qBAAqB,GAAG,YAAY,CAAC,qBAAqB,CAAC;QAC/E,IAAI,a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GAAW,CAAC,CAAC;AAC5B,gCAAmB,GAAW,CAAC,CAAC;AAEhC,kCAAqB,GAAW,CAAC,CAAC;AAClC,kCAAqB,GAAW,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
11
|
+
"version": "1.4.101",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"namirasoft-core": "^1.4.74",
|
|
34
34
|
"namirasoft-log": "^1.4.30",
|
|
35
35
|
"namirasoft-schema": "^1.4.25",
|
|
36
|
-
"node-cron": "^4.0.
|
|
36
|
+
"node-cron": "^4.0.7",
|
|
37
37
|
"nodemailer": "^7.0.3",
|
|
38
38
|
"nodemailer-smtp-transport": "^2.7.4",
|
|
39
39
|
"request-ip": "^3.3.0",
|
package/src/OTPOperation.ts
CHANGED
|
@@ -69,21 +69,21 @@ export class OTPOperation
|
|
|
69
69
|
errorHandler: () => Promise<void>): Promise<T>
|
|
70
70
|
{
|
|
71
71
|
if (!x_otp || !x_otp_time)
|
|
72
|
-
throw ErrorOperation.getHTTP(
|
|
72
|
+
throw ErrorOperation.getHTTP(404, "The OTP not generated yet. Please request first.");
|
|
73
73
|
|
|
74
74
|
if (x_otp_time != null)
|
|
75
75
|
x_otp_time = new Date(x_otp_time);
|
|
76
76
|
|
|
77
77
|
if (x_otp_time < TimeOperation.minutesAgo(OTPOperation.OTP_EXPIRE_TIME, new Date()))
|
|
78
|
-
ErrorOperation.throwHTTP(
|
|
78
|
+
ErrorOperation.throwHTTP(410, "The OTP code expired. Please request again.");
|
|
79
79
|
|
|
80
80
|
if (x_otp_ver_tried_count > OTPOperation.OTP_VER_MAX_TRY_COUNT)
|
|
81
|
-
ErrorOperation.throwHTTP(
|
|
81
|
+
ErrorOperation.throwHTTP(429, "The try limit attempt exceeded. Please request again.");
|
|
82
82
|
|
|
83
83
|
if (x_otp !== code)
|
|
84
84
|
{
|
|
85
85
|
await errorHandler();
|
|
86
|
-
ErrorOperation.throwHTTP(
|
|
86
|
+
ErrorOperation.throwHTTP(401, "Wrong code.");
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
return await handler({
|