@konplit-services/common 1.8.1 → 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/helper/money.js +1 -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/build/swagger/config.d.ts +1 -0
- package/build/swagger/config.js +57 -1
- 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";
|
package/build/helper/money.js
CHANGED
|
@@ -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
package/build/swagger/config.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.configureSwagger = void 0;
|
|
6
|
+
exports.configureSwaggerForTransaction = exports.configureSwagger = void 0;
|
|
7
7
|
const swagger_jsdoc_1 = __importDefault(require("swagger-jsdoc"));
|
|
8
8
|
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
9
9
|
const configureSwagger = (app, paths) => {
|
|
@@ -62,3 +62,59 @@ const configureSwagger = (app, paths) => {
|
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
64
|
exports.configureSwagger = configureSwagger;
|
|
65
|
+
const configureSwaggerForTransaction = (app, paths) => {
|
|
66
|
+
const options = {
|
|
67
|
+
definition: {
|
|
68
|
+
openapi: "3.1.0",
|
|
69
|
+
info: {
|
|
70
|
+
title: "Valuepay Payment System Documentation",
|
|
71
|
+
version: "1.0.0",
|
|
72
|
+
description: "This is a complete API definition for the Valuepay payment system documented with Swagger UI",
|
|
73
|
+
license: {
|
|
74
|
+
name: "IEC Code Components End-user licence agreement",
|
|
75
|
+
url: "https://spdx.org/licenses/IEC-Code-Components-EULA.html",
|
|
76
|
+
},
|
|
77
|
+
contact: {
|
|
78
|
+
name: "Valuepay",
|
|
79
|
+
url: "https://valuepayng.com",
|
|
80
|
+
email: "info@valuepay.ng",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
servers: [
|
|
84
|
+
{
|
|
85
|
+
url: "https://konplit.com",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
url: " https://valuepay.konplit.com",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
components: {
|
|
92
|
+
securitySchemes: {
|
|
93
|
+
bearerAuth: {
|
|
94
|
+
type: "http",
|
|
95
|
+
scheme: "bearer",
|
|
96
|
+
bearerFormat: "JWT",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
security: [
|
|
101
|
+
{
|
|
102
|
+
bearerAuth: [],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
apis: [paths],
|
|
107
|
+
};
|
|
108
|
+
const swaggerSpec = (0, swagger_jsdoc_1.default)(options);
|
|
109
|
+
app.use("/transactions/docs", swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(swaggerSpec, {
|
|
110
|
+
explorer: true,
|
|
111
|
+
// customCssUrl:
|
|
112
|
+
// "https://cdn.jsdelivr.net/npm/swagger-ui-themes@3.0.0/themes/3.x/theme-newspaper.css",
|
|
113
|
+
}));
|
|
114
|
+
// ➕ Serve raw Swagger JSON
|
|
115
|
+
app.get("/transactions/api-json", (_, res) => {
|
|
116
|
+
res.setHeader("Content-Type", "application/json");
|
|
117
|
+
res.send(swaggerSpec);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
exports.configureSwaggerForTransaction = configureSwaggerForTransaction;
|