@platform-x/hep-push-notification-client 1.0.3 → 1.0.5
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/src/PushNotificationManager.d.ts +1 -1
- package/dist/src/PushNotificationManager.js +4 -10
- package/dist/src/common/util/commonUtil.d.ts +0 -6
- package/dist/src/common/util/commonUtil.js +1 -26
- package/dist/src/common/util/secretKeyManager.d.ts +0 -7
- package/dist/src/common/util/secretKeyManager.js +36 -56
- package/dist/src/config/index.d.ts +0 -7
- package/dist/src/config/index.js +0 -7
- package/dist/src/index.js +1 -2
- package/package.json +1 -1
|
@@ -8,30 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.pushNotificationManager = void 0;
|
|
16
13
|
const logger_1 = require("./common/util/logger");
|
|
17
14
|
const constants_1 = require("./platform-x/constants");
|
|
18
15
|
const fcmservices_1 = require("./platform-x/services/fcmservices");
|
|
19
|
-
const site_domain_dao_1 = __importDefault(require("./platform-x/database/dao/site_domain.dao"));
|
|
20
16
|
/**
|
|
21
17
|
* Push Notification Manager - supports multiple providers
|
|
22
18
|
* Currently implemented: FCM
|
|
23
19
|
* Future providers: SAP_EMARSYS
|
|
24
20
|
*/
|
|
25
21
|
class pushNotificationManager {
|
|
26
|
-
pushNotificationProvider(
|
|
22
|
+
pushNotificationProvider(notificationReq) {
|
|
27
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
var _a, _b, _c;
|
|
29
24
|
try {
|
|
25
|
+
let { sitename, provider } = notificationReq;
|
|
30
26
|
logger_1.Logger.info('pushNotificationManager: Reached pushNotificationProvider', 'pushNotificationProvider');
|
|
31
|
-
let pushConfig = yield new site_domain_dao_1.default().details({ sitename });
|
|
32
|
-
let pushNotifyProvider = (_c = (_b = (_a = pushConfig === null || pushConfig === void 0 ? void 0 : pushConfig.providers) === null || _a === void 0 ? void 0 : _a.notification) === null || _b === void 0 ? void 0 : _b.active) !== null && _c !== void 0 ? _c : constants_1.PROVIDERS.FCM;
|
|
33
27
|
logger_1.Logger.info(`pushNotificationManager: Initializing the provider for client ${sitename}`, '');
|
|
34
|
-
switch (
|
|
28
|
+
switch (provider) {
|
|
35
29
|
case constants_1.PROVIDERS.FCM:
|
|
36
30
|
this.notificationProvider = yield fcmservices_1.FcmClient.fcmClientObject(sitename);
|
|
37
31
|
logger_1.Logger.info('pushNotificationManager: Initialized with FCM provider', 'constructor');
|
|
@@ -41,7 +35,7 @@ class pushNotificationManager {
|
|
|
41
35
|
logger_1.Logger.info('pushNotificationManager: Initialized with SAP_EMARSYS provider', 'constructor');
|
|
42
36
|
break;
|
|
43
37
|
default:
|
|
44
|
-
throw new Error(`Unsupported provider: ${
|
|
38
|
+
throw new Error(`Unsupported provider: ${provider}. Supported providers: ${Object.values(constants_1.PROVIDERS).join(', ')}`);
|
|
45
39
|
}
|
|
46
40
|
return this.notificationProvider;
|
|
47
41
|
}
|
|
@@ -4,9 +4,3 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const base64ToString: (toDecode: string) => string;
|
|
6
6
|
export declare function getDynamicSecretdata(sitename: any, providerName: any, secretKey: any): Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Validate that MongoDB connection is properly initialized for server startup
|
|
9
|
-
* If no external MongoDB connection is found, it will initialize its own connection
|
|
10
|
-
* Call this during your server startup to ensure proper MongoDB configuration
|
|
11
|
-
*/
|
|
12
|
-
export declare const validateMongoInitialization: () => Promise<boolean>;
|
|
@@ -8,16 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
12
|
+
exports.base64ToString = void 0;
|
|
16
13
|
exports.getDynamicSecretdata = getDynamicSecretdata;
|
|
17
14
|
const __1 = require("../..");
|
|
18
15
|
const constants_1 = require("../../platform-x/constants");
|
|
19
16
|
const logger_1 = require("./logger");
|
|
20
|
-
const connection_1 = __importDefault(require("../../platform-x/database/connection"));
|
|
21
17
|
/**
|
|
22
18
|
* base64ToString - to convert base64 into string
|
|
23
19
|
* @param {string} toDecode- string base64 request
|
|
@@ -44,25 +40,4 @@ function getDynamicSecretdata(sitename, providerName, secretKey) {
|
|
|
44
40
|
return finalValue;
|
|
45
41
|
});
|
|
46
42
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Validate that MongoDB connection is properly initialized for server startup
|
|
49
|
-
* If no external MongoDB connection is found, it will initialize its own connection
|
|
50
|
-
* Call this during your server startup to ensure proper MongoDB configuration
|
|
51
|
-
*/
|
|
52
|
-
const validateMongoInitialization = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
// Check if MongoDB connection exists and is connected
|
|
54
|
-
if (!connection_1.default.database || connection_1.default.database.readyState !== 1) {
|
|
55
|
-
// If no external connection, try to initialize own connection
|
|
56
|
-
if (!connection_1.default.isUsingExternalConnection()) {
|
|
57
|
-
logger_1.Logger.info('Push Notification Package: No external MongoDB connection found, initializing own connection', 'validatePackageInitialization');
|
|
58
|
-
yield connection_1.default.connect();
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
throw new Error('Push Notification Package: MongoDB connection not initialized. Please call initPushNotificationWithExternalMongo() or initPushNotificationWithOwnMongo() before starting the server.');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
logger_1.Logger.info('Push Notification Package: MongoDB validation passed - package is properly initialized', 'validatePackageInitialization');
|
|
65
|
-
return true;
|
|
66
|
-
});
|
|
67
|
-
exports.validateMongoInitialization = validateMongoInitialization;
|
|
68
43
|
//# sourceMappingURL=commonUtil.js.map
|
|
@@ -1,58 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
for (const key of Object.values(constants_1.DynamicValues)) {
|
|
39
|
-
// Fetch individual value (existing read() method)
|
|
40
|
-
const value = yield secretObject.read(key);
|
|
41
|
-
keyConfig[key] = value;
|
|
42
|
-
}
|
|
43
|
-
this.ruleCache.set('secret_data', keyConfig);
|
|
44
|
-
return keyConfig;
|
|
45
|
-
}
|
|
46
|
-
// else – fetch all secrets from GSM
|
|
47
|
-
const data = yield secretObject.readAllSecrets();
|
|
48
|
-
this.ruleCache.set('secret_data', data);
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.SecretKeyServices = SecretKeyServices;
|
|
2
|
+
// import { secretManager } from 'hep-secret-access';
|
|
3
|
+
// import { DynamicValues } from '../../platform-x/constants';
|
|
4
|
+
// import config from '../../config';
|
|
5
|
+
// export class SecretKeyServices {
|
|
6
|
+
// private ruleCache = new Map<string, any | null>();
|
|
7
|
+
// /**
|
|
8
|
+
// * Fetches all the secret keys
|
|
9
|
+
// */
|
|
10
|
+
// public async getSecretKeys() {
|
|
11
|
+
// try {
|
|
12
|
+
// // Initialize secret manager object
|
|
13
|
+
// if (this.ruleCache.has('secret_data')) {
|
|
14
|
+
// return this.ruleCache.get('secret_data')!;
|
|
15
|
+
// }
|
|
16
|
+
// const secretObject = secretManager();
|
|
17
|
+
// // If secret mode is ENV – read one by one
|
|
18
|
+
// // for local testing
|
|
19
|
+
// if (config?.SECRET_MODE === 'env') {
|
|
20
|
+
// const keyConfig: Record<any, any> = {};
|
|
21
|
+
// for (const key of Object.values(DynamicValues)) {
|
|
22
|
+
// // Fetch individual value (existing read() method)
|
|
23
|
+
// const value = await secretObject.read(key);
|
|
24
|
+
// keyConfig[key] = value;
|
|
25
|
+
// }
|
|
26
|
+
// this.ruleCache.set('secret_data', keyConfig);
|
|
27
|
+
// return keyConfig;
|
|
28
|
+
// }
|
|
29
|
+
// // else – fetch all secrets from GSM
|
|
30
|
+
// const data = await secretObject.readAllSecrets();
|
|
31
|
+
// this.ruleCache.set('secret_data', data);
|
|
32
|
+
// return data;
|
|
33
|
+
// } catch (err) {
|
|
34
|
+
// return {};
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
// }
|
|
58
38
|
//# sourceMappingURL=secretKeyManager.js.map
|
|
@@ -2,13 +2,6 @@ declare const _default: {
|
|
|
2
2
|
LOG_LEVELS: string[];
|
|
3
3
|
APP_NAME: string;
|
|
4
4
|
NODE_ENV: string | undefined;
|
|
5
|
-
MONGO: {
|
|
6
|
-
HOST: string | undefined;
|
|
7
|
-
PORT: string | undefined;
|
|
8
|
-
DB_NAME: string | undefined;
|
|
9
|
-
USER: string | undefined;
|
|
10
|
-
PASS: string | undefined;
|
|
11
|
-
};
|
|
12
5
|
FCM: {
|
|
13
6
|
PROJECT: string | undefined;
|
|
14
7
|
TYPE: string | undefined;
|
package/dist/src/config/index.js
CHANGED
|
@@ -12,13 +12,6 @@ exports.default = {
|
|
|
12
12
|
LOG_LEVELS: ((_a = process.env.LOG_LEVELS) === null || _a === void 0 ? void 0 : _a.split(',')) || [],
|
|
13
13
|
APP_NAME: process.env.npm_package_name || constants_1.DEFAULT_APP_NAME,
|
|
14
14
|
NODE_ENV: process.env.NODE_ENV,
|
|
15
|
-
MONGO: {
|
|
16
|
-
HOST: process.env.MONGO_HOST,
|
|
17
|
-
PORT: process.env.MONGO_PORT,
|
|
18
|
-
DB_NAME: process.env.MONGO_DB,
|
|
19
|
-
USER: process.env.MONGO_USER,
|
|
20
|
-
PASS: process.env.MONGO_PASS,
|
|
21
|
-
},
|
|
22
15
|
FCM: {
|
|
23
16
|
PROJECT: process.env.FCM_PROJECT,
|
|
24
17
|
TYPE: process.env.FCM_TYPE,
|
package/dist/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.pushNotificationManager = exports.getPushNotificationSecrets = exports.initPushNotificationSecrets = void 0;
|
|
4
4
|
const PushNotificationManager_1 = require("./PushNotificationManager");
|
|
5
5
|
Object.defineProperty(exports, "pushNotificationManager", { enumerable: true, get: function () { return PushNotificationManager_1.pushNotificationManager; } });
|
|
6
|
-
|
|
6
|
+
// import { SecretKeyServices } from "./common/util/secretKeyManager";
|
|
7
7
|
let injectedSecretService;
|
|
8
8
|
const initPushNotificationSecrets = (secretServiceIns) => {
|
|
9
9
|
injectedSecretService = secretServiceIns;
|
|
@@ -17,7 +17,6 @@ const getPushNotificationSecrets = () => {
|
|
|
17
17
|
// return new SecretKeyServices().getSecretKeys(); // for localpackage test
|
|
18
18
|
};
|
|
19
19
|
exports.getPushNotificationSecrets = getPushNotificationSecrets;
|
|
20
|
-
(0, commonUtil_1.validateMongoInitialization)(); // Ensure MongoDB is initialized when the package is loaded
|
|
21
20
|
// for testing
|
|
22
21
|
// export const testval = async () => {
|
|
23
22
|
// let id: any = new pushNotificationManager();
|