@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.
@@ -5,5 +5,5 @@
5
5
  */
6
6
  export declare class pushNotificationManager {
7
7
  private notificationProvider;
8
- pushNotificationProvider(req: any): Promise<any>;
8
+ pushNotificationProvider(notificationReq: any): Promise<any>;
9
9
  }
@@ -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(req) {
22
+ pushNotificationProvider(notificationReq) {
24
23
  return __awaiter(this, void 0, void 0, function* () {
25
24
  try {
26
- let { sitename, provider } = req;
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,7 +0,0 @@
1
- export declare class SecretKeyServices {
2
- private ruleCache;
3
- /**
4
- * Fetches all the secret keys
5
- */
6
- getSecretKeys(): Promise<any>;
7
- }
@@ -1,58 +1,38 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SecretKeyServices = void 0;
16
- const hep_secret_access_1 = require("hep-secret-access");
17
- const constants_1 = require("../../platform-x/constants");
18
- const config_1 = __importDefault(require("../../config"));
19
- class SecretKeyServices {
20
- constructor() {
21
- this.ruleCache = new Map();
22
- }
23
- /**
24
- * Fetches all the secret keys
25
- */
26
- getSecretKeys() {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- try {
29
- // Initialize secret manager object
30
- if (this.ruleCache.has('secret_data')) {
31
- return this.ruleCache.get('secret_data');
32
- }
33
- const secretObject = (0, hep_secret_access_1.secretManager)();
34
- // If secret mode is ENV – read one by one
35
- // for local testing
36
- if ((config_1.default === null || config_1.default === void 0 ? void 0 : config_1.default.SECRET_MODE) === 'env') {
37
- const keyConfig = {};
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;
@@ -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 { validateMongoInitialization } from "./common/util/commonUtil";
6
+ // import { SecretKeyServices } from "./common/util/secretKeyManager";
7
7
  let injectedSecretService;
8
8
  const initPushNotificationSecrets = (secretServiceIns) => {
9
9
  injectedSecretService = secretServiceIns;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-x/hep-push-notification-client",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "@platform-x/hep-push-notification-client",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",