akeyless-server-commons 1.0.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/README.md +3 -0
- package/dist/cjs/helpers/email_helpers.d.ts +2 -0
- package/dist/cjs/helpers/email_helpers.js +87 -0
- package/dist/cjs/helpers/email_helpers.js.map +1 -0
- package/dist/cjs/helpers/firebase_helpers.d.ts +24 -0
- package/dist/cjs/helpers/firebase_helpers.js +404 -0
- package/dist/cjs/helpers/firebase_helpers.js.map +1 -0
- package/dist/cjs/helpers/global_helpers.d.ts +10 -0
- package/dist/cjs/helpers/global_helpers.js +107 -0
- package/dist/cjs/helpers/global_helpers.js.map +1 -0
- package/dist/cjs/helpers/index.d.ts +8 -0
- package/dist/cjs/helpers/index.js +25 -0
- package/dist/cjs/helpers/index.js.map +1 -0
- package/dist/cjs/helpers/login_helpers.d.ts +8 -0
- package/dist/cjs/helpers/login_helpers.js +36 -0
- package/dist/cjs/helpers/login_helpers.js.map +1 -0
- package/dist/cjs/helpers/notification_helpers.d.ts +11 -0
- package/dist/cjs/helpers/notification_helpers.js +248 -0
- package/dist/cjs/helpers/notification_helpers.js.map +1 -0
- package/dist/cjs/helpers/phone_number_helpers.d.ts +13 -0
- package/dist/cjs/helpers/phone_number_helpers.js +103 -0
- package/dist/cjs/helpers/phone_number_helpers.js.map +1 -0
- package/dist/cjs/helpers/start.d.ts +5 -0
- package/dist/cjs/helpers/start.js +61 -0
- package/dist/cjs/helpers/start.js.map +1 -0
- package/dist/cjs/helpers/time_helpers.d.ts +17 -0
- package/dist/cjs/helpers/time_helpers.js +35 -0
- package/dist/cjs/helpers/time_helpers.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/managers/cache_manager.d.ts +11 -0
- package/dist/cjs/managers/cache_manager.js +32 -0
- package/dist/cjs/managers/cache_manager.js.map +1 -0
- package/dist/cjs/managers/index.d.ts +3 -0
- package/dist/cjs/managers/index.js +20 -0
- package/dist/cjs/managers/index.js.map +1 -0
- package/dist/cjs/managers/logger_manager.d.ts +12 -0
- package/dist/cjs/managers/logger_manager.js +57 -0
- package/dist/cjs/managers/logger_manager.js.map +1 -0
- package/dist/cjs/managers/translation_manager.d.ts +14 -0
- package/dist/cjs/managers/translation_manager.js +43 -0
- package/dist/cjs/managers/translation_manager.js.map +1 -0
- package/dist/cjs/middlewares/auth_mw.d.ts +5 -0
- package/dist/cjs/middlewares/auth_mw.js +80 -0
- package/dist/cjs/middlewares/auth_mw.js.map +1 -0
- package/dist/cjs/middlewares/error_handling.d.ts +11 -0
- package/dist/cjs/middlewares/error_handling.js +24 -0
- package/dist/cjs/middlewares/error_handling.js.map +1 -0
- package/dist/cjs/middlewares/global_mw.d.ts +2 -0
- package/dist/cjs/middlewares/global_mw.js +55 -0
- package/dist/cjs/middlewares/global_mw.js.map +1 -0
- package/dist/cjs/middlewares/index.d.ts +3 -0
- package/dist/cjs/middlewares/index.js +20 -0
- package/dist/cjs/middlewares/index.js.map +1 -0
- package/dist/cjs/test.d.ts +1 -0
- package/dist/cjs/test.js +18 -0
- package/dist/cjs/test.js.map +1 -0
- package/dist/cjs/types/enums/global.d.ts +16 -0
- package/dist/cjs/types/enums/global.js +22 -0
- package/dist/cjs/types/enums/global.js.map +1 -0
- package/dist/cjs/types/enums/index.d.ts +1 -0
- package/dist/cjs/types/enums/index.js +18 -0
- package/dist/cjs/types/enums/index.js.map +1 -0
- package/dist/cjs/types/index.d.ts +3 -0
- package/dist/cjs/types/index.js +20 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/interfaces/email.d.ts +24 -0
- package/dist/cjs/types/interfaces/email.js +3 -0
- package/dist/cjs/types/interfaces/email.js.map +1 -0
- package/dist/cjs/types/interfaces/global.d.ts +12 -0
- package/dist/cjs/types/interfaces/global.js +3 -0
- package/dist/cjs/types/interfaces/global.js.map +1 -0
- package/dist/cjs/types/interfaces/index.d.ts +2 -0
- package/dist/cjs/types/interfaces/index.js +19 -0
- package/dist/cjs/types/interfaces/index.js.map +1 -0
- package/dist/cjs/types/types/firebase_types.d.ts +30 -0
- package/dist/cjs/types/types/firebase_types.js +3 -0
- package/dist/cjs/types/types/firebase_types.js.map +1 -0
- package/dist/cjs/types/types/global.d.ts +15 -0
- package/dist/cjs/types/types/global.js +3 -0
- package/dist/cjs/types/types/global.js.map +1 -0
- package/dist/cjs/types/types/index.d.ts +2 -0
- package/dist/cjs/types/types/index.js +19 -0
- package/dist/cjs/types/types/index.js.map +1 -0
- package/dist/esm/helpers/email_helpers.d.ts +2 -0
- package/dist/esm/helpers/email_helpers.js +80 -0
- package/dist/esm/helpers/email_helpers.js.map +1 -0
- package/dist/esm/helpers/firebase_helpers.d.ts +24 -0
- package/dist/esm/helpers/firebase_helpers.js +381 -0
- package/dist/esm/helpers/firebase_helpers.js.map +1 -0
- package/dist/esm/helpers/global_helpers.d.ts +10 -0
- package/dist/esm/helpers/global_helpers.js +96 -0
- package/dist/esm/helpers/global_helpers.js.map +1 -0
- package/dist/esm/helpers/index.d.ts +8 -0
- package/dist/esm/helpers/index.js +9 -0
- package/dist/esm/helpers/index.js.map +1 -0
- package/dist/esm/helpers/login_helpers.d.ts +8 -0
- package/dist/esm/helpers/login_helpers.js +31 -0
- package/dist/esm/helpers/login_helpers.js.map +1 -0
- package/dist/esm/helpers/notification_helpers.d.ts +11 -0
- package/dist/esm/helpers/notification_helpers.js +239 -0
- package/dist/esm/helpers/notification_helpers.js.map +1 -0
- package/dist/esm/helpers/phone_number_helpers.d.ts +13 -0
- package/dist/esm/helpers/phone_number_helpers.js +89 -0
- package/dist/esm/helpers/phone_number_helpers.js.map +1 -0
- package/dist/esm/helpers/start.d.ts +5 -0
- package/dist/esm/helpers/start.js +52 -0
- package/dist/esm/helpers/start.js.map +1 -0
- package/dist/esm/helpers/time_helpers.d.ts +17 -0
- package/dist/esm/helpers/time_helpers.js +27 -0
- package/dist/esm/helpers/time_helpers.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/managers/cache_manager.d.ts +11 -0
- package/dist/esm/managers/cache_manager.js +28 -0
- package/dist/esm/managers/cache_manager.js.map +1 -0
- package/dist/esm/managers/index.d.ts +3 -0
- package/dist/esm/managers/index.js +4 -0
- package/dist/esm/managers/index.js.map +1 -0
- package/dist/esm/managers/logger_manager.d.ts +12 -0
- package/dist/esm/managers/logger_manager.js +51 -0
- package/dist/esm/managers/logger_manager.js.map +1 -0
- package/dist/esm/managers/translation_manager.d.ts +14 -0
- package/dist/esm/managers/translation_manager.js +39 -0
- package/dist/esm/managers/translation_manager.js.map +1 -0
- package/dist/esm/middlewares/auth_mw.d.ts +5 -0
- package/dist/esm/middlewares/auth_mw.js +73 -0
- package/dist/esm/middlewares/auth_mw.js.map +1 -0
- package/dist/esm/middlewares/error_handling.d.ts +11 -0
- package/dist/esm/middlewares/error_handling.js +20 -0
- package/dist/esm/middlewares/error_handling.js.map +1 -0
- package/dist/esm/middlewares/global_mw.d.ts +2 -0
- package/dist/esm/middlewares/global_mw.js +51 -0
- package/dist/esm/middlewares/global_mw.js.map +1 -0
- package/dist/esm/middlewares/index.d.ts +3 -0
- package/dist/esm/middlewares/index.js +4 -0
- package/dist/esm/middlewares/index.js.map +1 -0
- package/dist/esm/test.d.ts +1 -0
- package/dist/esm/test.js +16 -0
- package/dist/esm/test.js.map +1 -0
- package/dist/esm/types/enums/global.d.ts +16 -0
- package/dist/esm/types/enums/global.js +19 -0
- package/dist/esm/types/enums/global.js.map +1 -0
- package/dist/esm/types/enums/index.d.ts +1 -0
- package/dist/esm/types/enums/index.js +2 -0
- package/dist/esm/types/enums/index.js.map +1 -0
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/esm/types/index.js +4 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/interfaces/email.d.ts +24 -0
- package/dist/esm/types/interfaces/email.js +2 -0
- package/dist/esm/types/interfaces/email.js.map +1 -0
- package/dist/esm/types/interfaces/global.d.ts +12 -0
- package/dist/esm/types/interfaces/global.js +2 -0
- package/dist/esm/types/interfaces/global.js.map +1 -0
- package/dist/esm/types/interfaces/index.d.ts +2 -0
- package/dist/esm/types/interfaces/index.js +3 -0
- package/dist/esm/types/interfaces/index.js.map +1 -0
- package/dist/esm/types/types/firebase_types.d.ts +30 -0
- package/dist/esm/types/types/firebase_types.js +2 -0
- package/dist/esm/types/types/firebase_types.js.map +1 -0
- package/dist/esm/types/types/global.d.ts +15 -0
- package/dist/esm/types/types/global.js +2 -0
- package/dist/esm/types/types/global.js.map +1 -0
- package/dist/esm/types/types/index.d.ts +2 -0
- package/dist/esm/types/types/index.js +3 -0
- package/dist/esm/types/types/index.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TObject } from "akeyless-types-commons";
|
|
2
|
+
import { EntityOptions, LangOptions } from "../types";
|
|
3
|
+
export declare class TranslationManager {
|
|
4
|
+
private static instance;
|
|
5
|
+
private data;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): TranslationManager;
|
|
8
|
+
setTranslationData(data: TObject<any>): void;
|
|
9
|
+
getTranslationData(): TObject<any>;
|
|
10
|
+
get_translation(scope: string, lang: string, entity: string, key: string): string;
|
|
11
|
+
get_sms(lang: LangOptions, entity: EntityOptions, key: string): string;
|
|
12
|
+
get_email(lang: LangOptions, entity: EntityOptions, key: string): string;
|
|
13
|
+
}
|
|
14
|
+
export declare const translation_manager: TranslationManager;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class TranslationManager {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.data = {};
|
|
4
|
+
}
|
|
5
|
+
static getInstance() {
|
|
6
|
+
if (!TranslationManager.instance) {
|
|
7
|
+
TranslationManager.instance = new TranslationManager();
|
|
8
|
+
}
|
|
9
|
+
return TranslationManager.instance;
|
|
10
|
+
}
|
|
11
|
+
setTranslationData(data) {
|
|
12
|
+
this.data = data;
|
|
13
|
+
}
|
|
14
|
+
getTranslationData() {
|
|
15
|
+
return this.data;
|
|
16
|
+
}
|
|
17
|
+
get_translation(scope, lang, entity, key) {
|
|
18
|
+
key = entity + (entity === "" ? "" : "__") + key;
|
|
19
|
+
return this.data[scope][lang][key] || key;
|
|
20
|
+
}
|
|
21
|
+
get_sms(lang, entity, key) {
|
|
22
|
+
try {
|
|
23
|
+
return this.data["sms"][lang][entity + "__" + key];
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return "N/A";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
get_email(lang, entity, key) {
|
|
30
|
+
try {
|
|
31
|
+
return this.data["email"][lang][entity + "__" + key];
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return "N/A";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export const translation_manager = TranslationManager.getInstance();
|
|
39
|
+
//# sourceMappingURL=translation_manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation_manager.js","sourceRoot":"","sources":["../../../src/managers/translation_manager.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,kBAAkB;IAG3B;QADQ,SAAI,GAAiB,EAAE,CAAC;IACT,CAAC;IACjB,MAAM,CAAC,WAAW;QACrB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC;YAC/B,kBAAkB,CAAC,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAC3D,CAAC;QACD,OAAO,kBAAkB,CAAC,QAAQ,CAAC;IACvC,CAAC;IACM,kBAAkB,CAAC,IAAkB;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACM,kBAAkB;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACM,eAAe,CAAC,KAAa,EAAE,IAAY,EAAE,MAAc,EAAE,GAAW;QAC3E,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QACjD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IAC9C,CAAC;IACM,OAAO,CAAC,IAAiB,EAAE,MAAqB,EAAE,GAAW;QAChE,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACM,SAAS,CAAC,IAAiB,EAAE,MAAqB,EAAE,GAAW;QAClE,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { verify_token, json_failed, get_users_by_phone, query_document, convert_to_short_phone_number, query_document_optional } from "../helpers";
|
|
11
|
+
import { logger } from "../managers";
|
|
12
|
+
export const verify_user_auth = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const authorization = req.headers.authorization;
|
|
15
|
+
yield verify_token(authorization);
|
|
16
|
+
next();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
logger.error("error from verify user auth", error);
|
|
20
|
+
res.status(403).send(json_failed(error));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export const get_users_login = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const authorization = req.headers.authorization;
|
|
26
|
+
const user_data = yield verify_token(authorization);
|
|
27
|
+
const { phone_number } = user_data;
|
|
28
|
+
if (!phone_number) {
|
|
29
|
+
return next();
|
|
30
|
+
}
|
|
31
|
+
const users = yield get_users_by_phone(phone_number);
|
|
32
|
+
req.body = Object.assign(Object.assign({}, req.body), users);
|
|
33
|
+
next();
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
logger.error("error from verify user auth", error);
|
|
37
|
+
res.status(403).send(json_failed(error));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
export const nx_user_login = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
try {
|
|
42
|
+
const authorization = req.headers.authorization;
|
|
43
|
+
const user_data = yield verify_token(authorization);
|
|
44
|
+
const { phone_number } = user_data;
|
|
45
|
+
if (!phone_number) {
|
|
46
|
+
throw "Invalid authorization token";
|
|
47
|
+
}
|
|
48
|
+
const nx_user = yield query_document("nx-users", "phone_number", "in", [convert_to_short_phone_number(phone_number), phone_number]);
|
|
49
|
+
req.body.nx_user = nx_user;
|
|
50
|
+
next();
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
res.status(403).send(json_failed(error));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
export const client_login = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
const token = req.headers.authorization;
|
|
59
|
+
if (!token) {
|
|
60
|
+
throw new Error("Authorization token not found.");
|
|
61
|
+
}
|
|
62
|
+
const client_data = (yield query_document_optional("nx-clients", "api_token", "==", token));
|
|
63
|
+
if (!client_data) {
|
|
64
|
+
throw new Error(`No client found with token: ${token} .`);
|
|
65
|
+
}
|
|
66
|
+
req.body.client = client_data;
|
|
67
|
+
next();
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
res.status(403).send(json_failed(error.message || error));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=auth_mw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth_mw.js","sourceRoot":"","sources":["../../../src/middlewares/auth_mw.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
import { Service } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Utility to handle async errors
|
|
5
|
+
*/
|
|
6
|
+
declare const async_error_handler: (service: Service) => (req: Request, res: Response, next: NextFunction) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Global error-handling middleware.
|
|
9
|
+
*/
|
|
10
|
+
declare const error_handler: (err: Error, req: Request, res: Response, next: NextFunction) => void;
|
|
11
|
+
export { error_handler, async_error_handler };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to handle async errors
|
|
3
|
+
*/
|
|
4
|
+
const async_error_handler = (service) => {
|
|
5
|
+
return (req, res, next) => {
|
|
6
|
+
Promise.resolve(service(req, res)).catch(next);
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Global error-handling middleware.
|
|
11
|
+
*/
|
|
12
|
+
const error_handler = (err, req, res, next) => {
|
|
13
|
+
console.error("Global Error Handler:", err.stack);
|
|
14
|
+
res.status(500).json({
|
|
15
|
+
status: "error",
|
|
16
|
+
message: err.message || "Internal Server Error",
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export { error_handler, async_error_handler };
|
|
20
|
+
//# sourceMappingURL=error_handling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error_handling.js","sourceRoot":"","sources":["../../../src/middlewares/error_handling.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC7C,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QACvD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC,CAAC;AACN,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,aAAa,GAAG,CAAC,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IAClF,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAElD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACjB,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,uBAAuB;KAClD,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { json_failed } from "../helpers";
|
|
2
|
+
const validateParameter = (data, parameter) => {
|
|
3
|
+
if (data[parameter.key] === undefined) {
|
|
4
|
+
throw `missing mandatory parameter: ${parameter.key}`;
|
|
5
|
+
}
|
|
6
|
+
if (parameter.type === "array" && !Array.isArray(data[parameter.key])) {
|
|
7
|
+
throw `parameter ${parameter.key} must be of type: Array`;
|
|
8
|
+
}
|
|
9
|
+
if (typeof data[parameter.key] !== parameter.type && parameter.type !== "array") {
|
|
10
|
+
throw `parameter ${parameter.key} must be of type: ${parameter.type}`;
|
|
11
|
+
}
|
|
12
|
+
if ((Array.isArray(data[parameter.key]) && parameter.length && data[parameter.key].length < parameter.length) ||
|
|
13
|
+
(parameter.type === "string" && parameter.length && data[parameter.key].length < parameter.length)) {
|
|
14
|
+
throw `parameter ${parameter.key} must have minimum length: ${parameter.length}`;
|
|
15
|
+
}
|
|
16
|
+
if (parameter.type === "object" && parameter.required_keys) {
|
|
17
|
+
const missingKeys = parameter.required_keys.filter((key) => data[parameter.key][key] === undefined);
|
|
18
|
+
if (missingKeys.length > 0) {
|
|
19
|
+
throw `parameter ${parameter.key} is missing required keys: ${missingKeys.join(", ")}`;
|
|
20
|
+
}
|
|
21
|
+
parameter.required_keys.forEach((key) => {
|
|
22
|
+
const value = data[parameter.key][key];
|
|
23
|
+
if ((typeof value === "string" || Array.isArray(value)) && value.length === 0) {
|
|
24
|
+
throw `parameter ${key} in ${parameter.key} must have some length `;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export const mandatory = ({ body, headers }) => {
|
|
30
|
+
return (req, res, next) => {
|
|
31
|
+
try {
|
|
32
|
+
const body_data = req.body;
|
|
33
|
+
const headers_data = req.headers;
|
|
34
|
+
if (body) {
|
|
35
|
+
body.forEach((parameter) => {
|
|
36
|
+
validateParameter(body_data, parameter);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (headers) {
|
|
40
|
+
headers.forEach((parameter) => {
|
|
41
|
+
validateParameter(headers_data, parameter);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
next();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return res.status(500).send(json_failed(error));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=global_mw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global_mw.js","sourceRoot":"","sources":["../../../src/middlewares/global_mw.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/test.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { get_nx_service_urls } from "./helpers";
|
|
2
|
+
const paul = "+972546361975";
|
|
3
|
+
const paulTestPhone = "0547380791";
|
|
4
|
+
const avraham = "+972546559314";
|
|
5
|
+
const avrahamLocal = "0546559314";
|
|
6
|
+
const from2 = "+12185857393";
|
|
7
|
+
const ami_friend = "+18182775344";
|
|
8
|
+
const iccid = "8999925200420110809";
|
|
9
|
+
const iccid2 = "8999925200420110808";
|
|
10
|
+
const ruptelaMsg = "imei";
|
|
11
|
+
// send_sms(avrahamLocal, "test 7", "testing");
|
|
12
|
+
// send_sms(avraham, "test 8", "testing");
|
|
13
|
+
// send_sms(iccid2, ruptelaMsg, "testing") ;
|
|
14
|
+
const nx_service_urls = get_nx_service_urls();
|
|
15
|
+
console.log(nx_service_urls);
|
|
16
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,WAAW,CAAC;AAC1D,MAAM,IAAI,GAAG,eAAe,CAAC;AAC7B,MAAM,aAAa,GAAG,YAAY,CAAC;AACnC,MAAM,OAAO,GAAG,eAAe,CAAC;AAChC,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,KAAK,GAAG,cAAc,CAAC;AAC7B,MAAM,UAAU,GAAG,cAAc,CAAC;AAClC,MAAM,KAAK,GAAG,qBAAqB,CAAC;AACpC,MAAM,MAAM,GAAG,qBAAqB,CAAC;AACrC,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,+CAA+C;AAC/C,0CAA0C;AAC1C,4CAA4C;AAE5C,MAAM,eAAe,GAAG,mBAAmB,EAAE,CAAC;AAC9C,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum SimProvider {
|
|
2
|
+
partner = "partner",
|
|
3
|
+
pelephone = "pelephone",
|
|
4
|
+
celcom = "celcom",
|
|
5
|
+
monogoto = "monogoto",
|
|
6
|
+
unknown = "unknown"
|
|
7
|
+
}
|
|
8
|
+
export declare enum NxServiceName {
|
|
9
|
+
bi = "bi",
|
|
10
|
+
call_center = "call_center",
|
|
11
|
+
dashboard = "dashboard",
|
|
12
|
+
devices = "devices",
|
|
13
|
+
installer = "installer",
|
|
14
|
+
ox_server = "ox_server",
|
|
15
|
+
toolbox = "toolbox"
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var SimProvider;
|
|
2
|
+
(function (SimProvider) {
|
|
3
|
+
SimProvider["partner"] = "partner";
|
|
4
|
+
SimProvider["pelephone"] = "pelephone";
|
|
5
|
+
SimProvider["celcom"] = "celcom";
|
|
6
|
+
SimProvider["monogoto"] = "monogoto";
|
|
7
|
+
SimProvider["unknown"] = "unknown";
|
|
8
|
+
})(SimProvider || (SimProvider = {}));
|
|
9
|
+
export var NxServiceName;
|
|
10
|
+
(function (NxServiceName) {
|
|
11
|
+
NxServiceName["bi"] = "bi";
|
|
12
|
+
NxServiceName["call_center"] = "call_center";
|
|
13
|
+
NxServiceName["dashboard"] = "dashboard";
|
|
14
|
+
NxServiceName["devices"] = "devices";
|
|
15
|
+
NxServiceName["installer"] = "installer";
|
|
16
|
+
NxServiceName["ox_server"] = "ox_server";
|
|
17
|
+
NxServiceName["toolbox"] = "toolbox";
|
|
18
|
+
})(NxServiceName || (NxServiceName = {}));
|
|
19
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../../../src/types/enums/global.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACnB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,gCAAiB,CAAA;IACjB,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;AACvB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAED,MAAM,CAAN,IAAY,aAQX;AARD,WAAY,aAAa;IACrB,0BAAS,CAAA;IACT,4CAA2B,CAAA;IAC3B,wCAAuB,CAAA;IACvB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,wCAAuB,CAAA;IACvB,oCAAmB,CAAA;AACvB,CAAC,EARW,aAAa,KAAb,aAAa,QAQxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./global";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/enums/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface EmailData {
|
|
2
|
+
subject: string;
|
|
3
|
+
entity_for_audit: string;
|
|
4
|
+
to?: string | string[];
|
|
5
|
+
from?: string | {
|
|
6
|
+
email: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
};
|
|
9
|
+
group_name?: string;
|
|
10
|
+
cc?: string | string[];
|
|
11
|
+
body_plain_text?: string;
|
|
12
|
+
body_html?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface EmailSettings {
|
|
15
|
+
default_from: {
|
|
16
|
+
email: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
};
|
|
19
|
+
groups: Record<string, {
|
|
20
|
+
cc?: string[];
|
|
21
|
+
to: string[];
|
|
22
|
+
}>;
|
|
23
|
+
sendgrid_api_key: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../src/types/interfaces/email.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface MandatoryObject {
|
|
2
|
+
key: string;
|
|
3
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
4
|
+
length?: number;
|
|
5
|
+
required_keys?: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface MandatoryParams {
|
|
8
|
+
body?: MandatoryObject[];
|
|
9
|
+
headers?: MandatoryObject[];
|
|
10
|
+
}
|
|
11
|
+
export type LangOptions = "he" | "en" | "ru" | (string & {});
|
|
12
|
+
export type EntityOptions = "nx_devices" | (string & {});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../../../src/types/interfaces/global.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TObject } from "akeyless-types-commons";
|
|
2
|
+
export type QueryDocuments = (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any) => Promise<TObject<any>[]>;
|
|
3
|
+
export type WhereCondition = {
|
|
4
|
+
field_name: string;
|
|
5
|
+
operator: FirebaseFirestore.WhereFilterOp;
|
|
6
|
+
value: any;
|
|
7
|
+
};
|
|
8
|
+
export type QueryDocumentsByConditions = (collection_path: string, where_conditions: WhereCondition[]) => Promise<TObject<any>[]>;
|
|
9
|
+
export type QueryDocumentByConditions = (collection_path: string, where_conditions: WhereCondition[], log?: boolean) => Promise<TObject<any>>;
|
|
10
|
+
export type QueryDocument = (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any, ignore_log?: boolean) => Promise<TObject<any>>;
|
|
11
|
+
export type QueryDocumentOptional = (collection_path: string, field_name: string, operator: FirebaseFirestore.WhereFilterOp, value: any) => Promise<TObject<any> | null>;
|
|
12
|
+
export type OnSnapshotCallback = (documents: any[], config: OnSnapshotConfig) => void;
|
|
13
|
+
export interface OnSnapshotParsers {
|
|
14
|
+
on_first_time?: OnSnapshotCallback;
|
|
15
|
+
on_add?: OnSnapshotCallback;
|
|
16
|
+
on_modify?: OnSnapshotCallback;
|
|
17
|
+
on_remove?: OnSnapshotCallback;
|
|
18
|
+
}
|
|
19
|
+
export interface OnSnapshotConfig extends OnSnapshotParsers {
|
|
20
|
+
collection_name: string;
|
|
21
|
+
extra_parsers?: OnSnapshotParsers[];
|
|
22
|
+
}
|
|
23
|
+
export type Snapshot = (config: OnSnapshotConfig) => Promise<void>;
|
|
24
|
+
export type SnapshotBulk = (snapshots: ReturnType<Snapshot>[], label?: string) => Promise<void>;
|
|
25
|
+
export type SnapshotBulkByNamesParamObject = {
|
|
26
|
+
collection_name: string;
|
|
27
|
+
extra_parsers: OnSnapshotParsers[];
|
|
28
|
+
};
|
|
29
|
+
export type SnapshotBulkByNamesParam = string | SnapshotBulkByNamesParamObject;
|
|
30
|
+
export type SnapshotBulkByNames = (params: SnapshotBulkByNamesParam[]) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase_types.js","sourceRoot":"","sources":["../../../../src/types/types/firebase_types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Request, Response, Express, NextFunction } from "express";
|
|
2
|
+
import { Installer, TObject } from "akeyless-types-commons";
|
|
3
|
+
export type JsonOK<T> = (data?: T) => {
|
|
4
|
+
success: true;
|
|
5
|
+
data: T | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type JsonFailed = (error?: any, msg?: string) => {
|
|
8
|
+
success: false;
|
|
9
|
+
error: any;
|
|
10
|
+
};
|
|
11
|
+
export type MainRouter = (app: Express) => void;
|
|
12
|
+
export type MW = (req: Request, res: Response, next: NextFunction) => void;
|
|
13
|
+
export type Service = (req: Request, res: Response) => void;
|
|
14
|
+
export type Route = (req: Request, res: Response, next?: NextFunction) => Response;
|
|
15
|
+
export type AddAuditRecord = (action: string, entity: string, details: TObject<any>, user?: Installer) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../../../src/types/types/global.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "akeyless-server-commons",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
6
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
7
|
+
"build": "npm run build:cjs && npm run build:esm",
|
|
8
|
+
"uc": "npm i akeyless-types-commons",
|
|
9
|
+
"deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",
|
|
10
|
+
"start": "npm run build && node ./dist/cjs/",
|
|
11
|
+
"test": "npm run build && node --input-type=commonjs ./dist/cjs/test.js",
|
|
12
|
+
"git": "powershell -ExecutionPolicy Bypass -File ./ps/create_branch.ps1",
|
|
13
|
+
"git2": "powershell -ExecutionPolicy Bypass -File ./ps/move_to_main.ps1"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
"./managers": {
|
|
20
|
+
"import": "./dist/esm/managers/index.js",
|
|
21
|
+
"require": "./dist/cjs/managers/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./middlewares": {
|
|
24
|
+
"import": "./dist/esm/middlewares/index.js",
|
|
25
|
+
"require": "./dist/cjs/middlewares/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./helpers": {
|
|
28
|
+
"import": "./dist/esm/helpers/index.js",
|
|
29
|
+
"require": "./dist/cjs/helpers/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./types": {
|
|
32
|
+
"import": "./dist/esm/types/index.js",
|
|
33
|
+
"require": "./dist/cjs/types/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"typesVersions": {
|
|
37
|
+
"*": {
|
|
38
|
+
"managers": [
|
|
39
|
+
"./dist/esm/managers/index.d.ts"
|
|
40
|
+
],
|
|
41
|
+
"middlewares": [
|
|
42
|
+
"./dist/esm/middlewares/index.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"helpers": [
|
|
45
|
+
"./dist/esm/helpers/index.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"types": [
|
|
48
|
+
"./dist/esm/types/index.d.ts"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/akeylesspro/akeyless-server-commons.git"
|
|
55
|
+
},
|
|
56
|
+
"optionalDependencies": {
|
|
57
|
+
"axios": "^1.7.7",
|
|
58
|
+
"cors": "^2.8.5",
|
|
59
|
+
"dotenv": "^16.4.5",
|
|
60
|
+
"express": "^4.19.2",
|
|
61
|
+
"firebase-admin": "^12.4.0",
|
|
62
|
+
"lodash": "^4.17.21",
|
|
63
|
+
"moment": "^2.30.1",
|
|
64
|
+
"moment-timezone": "^0.5.45"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/cors": "^2.8.17",
|
|
68
|
+
"@types/lodash": "^4.17.7",
|
|
69
|
+
"@types/moment": "^2.11.29",
|
|
70
|
+
"@types/node": "^22.5.2",
|
|
71
|
+
"@types/twilio": "^3.19.2",
|
|
72
|
+
"@types/uuid": "^10.0.0",
|
|
73
|
+
"typescript": "^5.5.4"
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@sendgrid/mail": "^8.1.3",
|
|
77
|
+
"akeyless-types-commons": "^1.0.2",
|
|
78
|
+
"form-data": "^4.0.1",
|
|
79
|
+
"tsup": "^8.3.5",
|
|
80
|
+
"twilio": "^5.4.0",
|
|
81
|
+
"uuid": "^11.0.3"
|
|
82
|
+
}
|
|
83
|
+
}
|