@konplit-services/common 1.9.0 → 1.9.1
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/build/events/accounts-events/interfaces/index.d.ts +2 -0
- package/build/events/accounts-events/interfaces/index.js +2 -0
- package/build/events/accounts-events/interfaces/twofa-created.interface.d.ts +16 -0
- package/build/events/accounts-events/interfaces/twofa-created.interface.js +2 -0
- package/build/events/accounts-events/interfaces/twofa-updated.interface.d.ts +16 -0
- package/build/events/accounts-events/interfaces/twofa-updated.interface.js +2 -0
- package/build/events/subjects.d.ts +2 -0
- package/build/events/subjects.js +2 -0
- package/build/middlewares/current-user.js +1 -0
- package/build/redis/constants/index.d.ts +2 -0
- package/build/redis/constants/index.js +5 -1
- package/build/services/Jwt.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,3 +4,5 @@ export * from "./permission-created.interface";
|
|
|
4
4
|
export * from "./permission-removed.interface";
|
|
5
5
|
export * from "./user-created.interface";
|
|
6
6
|
export * from "./user-updated.interface";
|
|
7
|
+
export * from "./twofa-created.interface";
|
|
8
|
+
export * from "./twofa-updated.interface";
|
|
@@ -20,3 +20,5 @@ __exportStar(require("./permission-created.interface"), exports);
|
|
|
20
20
|
__exportStar(require("./permission-removed.interface"), exports);
|
|
21
21
|
__exportStar(require("./user-created.interface"), exports);
|
|
22
22
|
__exportStar(require("./user-updated.interface"), exports);
|
|
23
|
+
__exportStar(require("./twofa-created.interface"), exports);
|
|
24
|
+
__exportStar(require("./twofa-updated.interface"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TwoFAType } from "../../../helper";
|
|
2
|
+
import { StreamEvent, StreamName, Subjects } from "../../subjects";
|
|
3
|
+
export interface TWOFACreatedEvent {
|
|
4
|
+
subject: Subjects.TwoFACreated;
|
|
5
|
+
streamName: StreamName.name;
|
|
6
|
+
streamEvents: StreamEvent.Event;
|
|
7
|
+
data: {
|
|
8
|
+
id: string;
|
|
9
|
+
accountId?: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
isTwoFactor?: boolean;
|
|
12
|
+
twoFactorType?: TwoFAType;
|
|
13
|
+
twoFactorSecret?: string;
|
|
14
|
+
version?: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TwoFAType } from "../../../helper";
|
|
2
|
+
import { StreamEvent, StreamName, Subjects } from "../../subjects";
|
|
3
|
+
export interface TWOFAUpdatedEvent {
|
|
4
|
+
subject: Subjects.TwoFAUpdated;
|
|
5
|
+
streamName: StreamName.name;
|
|
6
|
+
streamEvents: StreamEvent.Event;
|
|
7
|
+
data: {
|
|
8
|
+
id: string;
|
|
9
|
+
accountId?: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
isTwoFactor?: boolean;
|
|
12
|
+
twoFactorType?: TwoFAType;
|
|
13
|
+
twoFactorSecret?: string;
|
|
14
|
+
version?: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -7,6 +7,8 @@ export declare enum StreamName {
|
|
|
7
7
|
export declare enum Subjects {
|
|
8
8
|
AccountCreated = "events.account.created",
|
|
9
9
|
AccountUpdated = "events.account.updated",
|
|
10
|
+
TwoFACreated = "events.two.fa.created",
|
|
11
|
+
TwoFAUpdated = "events.two.fa.updated",
|
|
10
12
|
UserCreated = "events.user.created",
|
|
11
13
|
UserUpdated = "events.user.updated",
|
|
12
14
|
MerchantCreated = "events.merchant.created",
|
package/build/events/subjects.js
CHANGED
|
@@ -14,6 +14,8 @@ var Subjects;
|
|
|
14
14
|
// Accounts Subjects
|
|
15
15
|
Subjects["AccountCreated"] = "events.account.created";
|
|
16
16
|
Subjects["AccountUpdated"] = "events.account.updated";
|
|
17
|
+
Subjects["TwoFACreated"] = "events.two.fa.created";
|
|
18
|
+
Subjects["TwoFAUpdated"] = "events.two.fa.updated";
|
|
17
19
|
//users
|
|
18
20
|
Subjects["UserCreated"] = "events.user.created";
|
|
19
21
|
Subjects["UserUpdated"] = "events.user.updated";
|
|
@@ -39,6 +39,7 @@ const currentUser = (req, res, next) => __awaiter(void 0, void 0, void 0, functi
|
|
|
39
39
|
if (payload.type !== Jwt_1.JWTType.ACCESS) {
|
|
40
40
|
throw new notAuthorized_1.NotAuthorizedError(language_1.lang.not_authorized, error_codes_1.error_codes.INVALID_AUTHORIZATION);
|
|
41
41
|
}
|
|
42
|
+
// Check if token found in redis the token is revoked
|
|
42
43
|
const isValidToken = yield base_1.redisWrapper.isTokenRevoked((0, constants_1.checkRevokedToken)(payload.id, token));
|
|
43
44
|
if (isValidToken) {
|
|
44
45
|
throw new notAuthorized_1.NotAuthorizedError(language_1.lang.not_authorized, error_codes_1.error_codes.INVALID_AUTHORIZATION);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const REDIS_REPOSITORY = "RedisRepository";
|
|
2
2
|
export declare const setVerificationCode: (email: string) => string;
|
|
3
3
|
export declare const getVerificationCode: (email: string) => string;
|
|
4
|
+
export declare const setSettlementAuthCode: (email: string) => string;
|
|
5
|
+
export declare const getSettlementAuthCode: (email: string) => string;
|
|
4
6
|
export declare const setTransferCode: (id: string, code: string) => string;
|
|
5
7
|
export declare const getTransferCode: (id: string, code: string) => string;
|
|
6
8
|
export declare const getPermissions: (id: string) => string;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setTransferToken = exports.checkTransferToken = exports.setsetRevokedToken = exports.checkRevokedToken = exports.setPermissions = exports.getPermissions = exports.getTransferCode = exports.setTransferCode = exports.getVerificationCode = exports.setVerificationCode = exports.REDIS_REPOSITORY = void 0;
|
|
3
|
+
exports.setTransferToken = exports.checkTransferToken = exports.setsetRevokedToken = exports.checkRevokedToken = exports.setPermissions = exports.getPermissions = exports.getTransferCode = exports.setTransferCode = exports.getSettlementAuthCode = exports.setSettlementAuthCode = exports.getVerificationCode = exports.setVerificationCode = exports.REDIS_REPOSITORY = void 0;
|
|
4
4
|
exports.REDIS_REPOSITORY = "RedisRepository";
|
|
5
5
|
const setVerificationCode = (email) => `${email}-verification`;
|
|
6
6
|
exports.setVerificationCode = setVerificationCode;
|
|
7
7
|
const getVerificationCode = (email) => `${email}-verification`;
|
|
8
8
|
exports.getVerificationCode = getVerificationCode;
|
|
9
|
+
const setSettlementAuthCode = (email) => `${email}-settlement-auth`;
|
|
10
|
+
exports.setSettlementAuthCode = setSettlementAuthCode;
|
|
11
|
+
const getSettlementAuthCode = (email) => `${email}-settlement-auth`;
|
|
12
|
+
exports.getSettlementAuthCode = getSettlementAuthCode;
|
|
9
13
|
const setTransferCode = (id, code) => `${id}-${code}-transfer`;
|
|
10
14
|
exports.setTransferCode = setTransferCode;
|
|
11
15
|
const getTransferCode = (id, code) => `${id}-${code}-transfer`;
|
package/build/services/Jwt.d.ts
CHANGED