@platform-x/hep-notification-client 1.2.4 → 1.2.6

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.
@@ -7,8 +7,7 @@ export declare class TwilioService {
7
7
  * @param authToken - Twilio Auth Token
8
8
  * @param senderNumber - Twilio Sender Phone Number
9
9
  */
10
- private constructor();
11
- static TwilioClassObject(): Promise<TwilioService>;
10
+ constructor(accountSid: string, authToken: string, senderNumber: string);
12
11
  /**
13
12
  * Send an SMS using Twilio
14
13
  * @param to - Recipient's phone number
@@ -15,8 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.TwilioService = void 0;
16
16
  const twilio_1 = __importDefault(require("twilio"));
17
17
  const logger_1 = require("../util/logger");
18
- const constants_1 = require("../../platform-x/constants");
19
- const __1 = require("../..");
20
18
  class TwilioService {
21
19
  /**
22
20
  * Constructor to initialize Twilio client and sender number
@@ -24,15 +22,9 @@ class TwilioService {
24
22
  * @param authToken - Twilio Auth Token
25
23
  * @param senderNumber - Twilio Sender Phone Number
26
24
  */
27
- constructor(twilioConfig) {
28
- this.client = (0, twilio_1.default)(twilioConfig === null || twilioConfig === void 0 ? void 0 : twilioConfig[constants_1.DynamicValues === null || constants_1.DynamicValues === void 0 ? void 0 : constants_1.DynamicValues.TWILIO_ACCOUNT_SID], twilioConfig === null || twilioConfig === void 0 ? void 0 : twilioConfig[constants_1.DynamicValues === null || constants_1.DynamicValues === void 0 ? void 0 : constants_1.DynamicValues.TWILIO_AUTH_TOKEN]);
29
- this.senderNumber = twilioConfig === null || twilioConfig === void 0 ? void 0 : twilioConfig[constants_1.DynamicValues === null || constants_1.DynamicValues === void 0 ? void 0 : constants_1.DynamicValues.TWILIO_SENDER_NUMBER];
30
- }
31
- static TwilioClassObject() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const secrets = yield (0, __1.getIAMSecrets)();
34
- return new TwilioService(secrets);
35
- });
25
+ constructor(accountSid, authToken, senderNumber) {
26
+ this.client = (0, twilio_1.default)(accountSid, authToken);
27
+ this.senderNumber = senderNumber;
36
28
  }
37
29
  /**
38
30
  * Send an SMS using Twilio
@@ -1,5 +1,3 @@
1
1
  import { EmailHandler } from "./platform-x/util/emailHandler";
2
2
  import { TwilioService } from "./common/service/twilioService";
3
- export declare const initNotificationSecrets: (secretServiceIns: any) => void;
4
- export declare const getIAMSecrets: () => any;
5
3
  export { EmailHandler, TwilioService };
package/dist/src/index.js CHANGED
@@ -1,20 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TwilioService = exports.EmailHandler = exports.getIAMSecrets = exports.initNotificationSecrets = void 0;
3
+ exports.TwilioService = exports.EmailHandler = void 0;
4
4
  const emailHandler_1 = require("./platform-x/util/emailHandler");
5
5
  Object.defineProperty(exports, "EmailHandler", { enumerable: true, get: function () { return emailHandler_1.EmailHandler; } });
6
6
  const twilioService_1 = require("./common/service/twilioService");
7
7
  Object.defineProperty(exports, "TwilioService", { enumerable: true, get: function () { return twilioService_1.TwilioService; } });
8
- let injectedSecretService;
9
- const initNotificationSecrets = (secretServiceIns) => {
10
- injectedSecretService = secretServiceIns;
11
- };
12
- exports.initNotificationSecrets = initNotificationSecrets;
13
- const getIAMSecrets = () => {
14
- if (!injectedSecretService) {
15
- throw new Error("IAM secrets not initialized");
16
- }
17
- return injectedSecretService.getSecretKeys(); // returns cached data
18
- };
19
- exports.getIAMSecrets = getIAMSecrets;
20
8
  //# sourceMappingURL=index.js.map
@@ -15,8 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const mongoose_1 = __importDefault(require("mongoose"));
16
16
  const logger_1 = require("../../common/util/logger");
17
17
  const index_1 = __importDefault(require("../../config/index"));
18
- const constants_1 = require("../constants");
19
- const __1 = require("../..");
20
18
  let database = mongoose_1.default.connection;
21
19
  // Exit on error
22
20
  mongoose_1.default.connection.on('error', (err) => {
@@ -27,8 +25,7 @@ const connect = () => __awaiter(void 0, void 0, void 0, function* () {
27
25
  if (database.readyState) {
28
26
  return;
29
27
  }
30
- const secrets = yield (0, __1.getIAMSecrets)();
31
- mongoose_1.default.connect(`mongodb://${index_1.default.MONGO.USER}:${secrets === null || secrets === void 0 ? void 0 : secrets[constants_1.DynamicValues === null || constants_1.DynamicValues === void 0 ? void 0 : constants_1.DynamicValues.MONGO_PASS]}@${index_1.default.MONGO.HOST}:${index_1.default.MONGO.PORT}/${index_1.default.MONGO.DB_NAME}?directConnection=true&authMechanism=DEFAULT&authSource=${index_1.default.MONGO.DB_NAME}`);
28
+ mongoose_1.default.connect(`mongodb://${index_1.default.MONGO.USER}:${index_1.default.MONGO.PASS}@${index_1.default.MONGO.HOST}:${index_1.default.MONGO.PORT}/${index_1.default.MONGO.DB_NAME}?directConnection=true&authMechanism=DEFAULT&authSource=${index_1.default.MONGO.DB_NAME}`);
32
29
  database = mongoose_1.default.connection;
33
30
  database.once('open', () => __awaiter(void 0, void 0, void 0, function* () {
34
31
  logger_1.Logger.info(`[Server] connected to MongoDB`, 'connect');
@@ -63,7 +63,6 @@ const dompurify_1 = __importDefault(require("dompurify"));
63
63
  const jsdom_1 = require("jsdom");
64
64
  const logger_1 = require("../../common/util/logger");
65
65
  const path_1 = __importDefault(require("path"));
66
- const __1 = require("../..");
67
66
  const window = new jsdom_1.JSDOM('').window;
68
67
  const DOMPurify = (0, dompurify_1.default)(window);
69
68
  // NOSONAR-NEXT-LINE
@@ -77,8 +76,7 @@ class EmailHandler {
77
76
  sendEmail(emailConfig) {
78
77
  return __awaiter(this, void 0, void 0, function* () {
79
78
  logger_1.Logger.info('EmailHandler: Reached sendEmail method', 'sendEmail');
80
- const secrets = yield (0, __1.getIAMSecrets)();
81
- sgMail.setApiKey(secrets === null || secrets === void 0 ? void 0 : secrets[constants_1.DynamicValues === null || constants_1.DynamicValues === void 0 ? void 0 : constants_1.DynamicValues.SENDGRID_API_KEY]);
79
+ sgMail.setApiKey(config_1.default === null || config_1.default === void 0 ? void 0 : config_1.default.SENDGRID_API_KEY);
82
80
  // Build personalization object
83
81
  const personalization = {
84
82
  to: [{ email: emailConfig.email }],
@@ -229,13 +227,12 @@ class EmailHandler {
229
227
  sendEmailWithPersonalizations(emailConfig, email_from) {
230
228
  return __awaiter(this, void 0, void 0, function* () {
231
229
  logger_1.Logger.info(`EmailHandler: Reached sendEmailWithPersonalizations method with emailConfig: ${JSON.stringify(emailConfig)}`, 'sendEmailWithPersonalizations');
232
- logger_1.Logger.info(`EMAIL_FROM-------> ${email_from}`, 'triggerEmails');
230
+ logger_1.Logger.info(`EMAIL_FROM-------> ${config_1.default === null || config_1.default === void 0 ? void 0 : config_1.default.EMAIL_FROM}`, 'triggerEmails');
233
231
  const Mail = sgHelpers.classes.Mail;
234
232
  // let email_from = isCFF ? config?.CFF_MAIL_FROM : config?.EMAIL_FROM;
235
233
  logger_1.Logger.info('sendEmailWithPersonalizations : Email From:', JSON.stringify(email_from));
236
234
  const Personalization = sgHelpers.classes.Personalization;
237
- const secrets = yield (0, __1.getIAMSecrets)();
238
- sgMail.setApiKey(secrets === null || secrets === void 0 ? void 0 : secrets[constants_1.DynamicValues === null || constants_1.DynamicValues === void 0 ? void 0 : constants_1.DynamicValues.SENDGRID_API_KEY]);
235
+ sgMail.setApiKey(config_1.default === null || config_1.default === void 0 ? void 0 : config_1.default.SENDGRID_API_KEY);
239
236
  const mail = new Mail();
240
237
  mail.setFrom(email_from);
241
238
  mail.setSubject(emailConfig.subject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-x/hep-notification-client",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "@platform-x/hep-notification-client",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
File without changes
File without changes