@platform-x/hep-push-notification-client 1.0.4 → 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 +2 -5
- package/dist/src/common/util/commonUtil.d.ts +0 -5
- package/dist/src/common/util/commonUtil.js +0 -20
- 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 -1
- package/package.json +1 -1
|
@@ -13,20 +13,17 @@ exports.pushNotificationManager = void 0;
|
|
|
13
13
|
const logger_1 = require("./common/util/logger");
|
|
14
14
|
const constants_1 = require("./platform-x/constants");
|
|
15
15
|
const fcmservices_1 = require("./platform-x/services/fcmservices");
|
|
16
|
-
// import SiteDomainDao from './platform-x/database/dao/site_domain.dao';
|
|
17
16
|
/**
|
|
18
17
|
* Push Notification Manager - supports multiple providers
|
|
19
18
|
* Currently implemented: FCM
|
|
20
19
|
* Future providers: SAP_EMARSYS
|
|
21
20
|
*/
|
|
22
21
|
class pushNotificationManager {
|
|
23
|
-
pushNotificationProvider(
|
|
22
|
+
pushNotificationProvider(notificationReq) {
|
|
24
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
24
|
try {
|
|
26
|
-
let { sitename, provider } =
|
|
25
|
+
let { sitename, provider } = notificationReq;
|
|
27
26
|
logger_1.Logger.info('pushNotificationManager: Reached pushNotificationProvider', 'pushNotificationProvider');
|
|
28
|
-
// let pushConfig: any = await new SiteDomainDao().details({sitename});
|
|
29
|
-
// let pushNotifyProvider: any = pushConfig?.providers?.notification?.active ?? PROVIDERS.FCM;
|
|
30
27
|
logger_1.Logger.info(`pushNotificationManager: Initializing the provider for client ${sitename}`, '');
|
|
31
28
|
switch (provider) {
|
|
32
29
|
case constants_1.PROVIDERS.FCM:
|
|
@@ -4,8 +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
|
-
*/
|
|
@@ -14,7 +14,6 @@ exports.getDynamicSecretdata = getDynamicSecretdata;
|
|
|
14
14
|
const __1 = require("../..");
|
|
15
15
|
const constants_1 = require("../../platform-x/constants");
|
|
16
16
|
const logger_1 = require("./logger");
|
|
17
|
-
// import MongoDbConnection from "../../platform-x/database/connection";
|
|
18
17
|
/**
|
|
19
18
|
* base64ToString - to convert base64 into string
|
|
20
19
|
* @param {string} toDecode- string base64 request
|
|
@@ -41,23 +40,4 @@ function getDynamicSecretdata(sitename, providerName, secretKey) {
|
|
|
41
40
|
return finalValue;
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Validate that MongoDB connection is properly initialized for server startup
|
|
46
|
-
* If no external MongoDB connection is found, it will initialize its own connection
|
|
47
|
-
* Call this during your server startup to ensure proper MongoDB configuration
|
|
48
|
-
*/
|
|
49
|
-
// export const validateMongoInitialization = async () => {
|
|
50
|
-
// // Check if MongoDB connection exists and is connected
|
|
51
|
-
// if (!MongoDbConnection.database || MongoDbConnection.database.readyState !== 1) {
|
|
52
|
-
// // If no external connection, try to initialize own connection
|
|
53
|
-
// if (!MongoDbConnection.isUsingExternalConnection()) {
|
|
54
|
-
// Logger.info('Push Notification Package: No external MongoDB connection found, initializing own connection', 'validatePackageInitialization');
|
|
55
|
-
// await MongoDbConnection.connect();
|
|
56
|
-
// } else {
|
|
57
|
-
// throw new Error('Push Notification Package: MongoDB connection not initialized. Please call initPushNotificationWithExternalMongo() or initPushNotificationWithOwnMongo() before starting the server.');
|
|
58
|
-
// }
|
|
59
|
-
// }
|
|
60
|
-
// Logger.info('Push Notification Package: MongoDB validation passed - package is properly initialized', 'validatePackageInitialization');
|
|
61
|
-
// return true;
|
|
62
|
-
// };
|
|
63
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
|
-
// import {
|
|
6
|
+
// import { SecretKeyServices } from "./common/util/secretKeyManager";
|
|
7
7
|
let injectedSecretService;
|
|
8
8
|
const initPushNotificationSecrets = (secretServiceIns) => {
|
|
9
9
|
injectedSecretService = secretServiceIns;
|