@infuro/cms-core 1.0.57 → 1.0.59

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.
@@ -1331,7 +1331,7 @@ function renderEmail(templateName, ctx, options) {
1331
1331
  chunkUSNT2KNT_cjs.__name(renderEmail, "renderEmail");
1332
1332
 
1333
1333
  // src/plugins/email/email-service.ts
1334
- var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-JN4AFHZ4.cjs', document.baseURI).href)));
1334
+ var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-HXLC56ZK.cjs', document.baseURI).href)));
1335
1335
  var MailComposer = require2("nodemailer/lib/mail-composer");
1336
1336
  var SES_REGIONS_WITHOUT_SMTP = /* @__PURE__ */ new Set([
1337
1337
  "af-south-1",
@@ -2194,6 +2194,48 @@ async function sendFcmPushNotification(dataSource, entityMap, msg) {
2194
2194
  }
2195
2195
  }
2196
2196
  chunkUSNT2KNT_cjs.__name(sendFcmPushNotification, "sendFcmPushNotification");
2197
+ async function validateFcmCredentials(dataSource, entityMap) {
2198
+ try {
2199
+ const pushSettings = await getSettingsGroup(dataSource, entityMap, "push");
2200
+ let projectId = pushSettings.firebase_project_id?.trim();
2201
+ let clientEmail = pushSettings.firebase_client_email?.trim();
2202
+ let privateKey = pushSettings.firebase_private_key?.trim();
2203
+ if (pushSettings.firebase_service_account_json?.trim()) {
2204
+ try {
2205
+ const parsed = JSON.parse(pushSettings.firebase_service_account_json.trim());
2206
+ if (parsed.project_id) projectId = parsed.project_id;
2207
+ if (parsed.client_email) clientEmail = parsed.client_email;
2208
+ if (parsed.private_key) privateKey = parsed.private_key;
2209
+ } catch {
2210
+ }
2211
+ }
2212
+ if (!projectId || !clientEmail || !privateKey) {
2213
+ return {
2214
+ success: false,
2215
+ error: "Firebase Service Account JSON / credentials are not configured in settings"
2216
+ };
2217
+ }
2218
+ const token = await getGoogleAccessToken(clientEmail, privateKey);
2219
+ if (!token) {
2220
+ return {
2221
+ success: false,
2222
+ error: "Failed to obtain Google OAuth access token"
2223
+ };
2224
+ }
2225
+ return {
2226
+ success: true,
2227
+ projectId,
2228
+ clientEmail
2229
+ };
2230
+ } catch (err) {
2231
+ const msg = err instanceof Error ? err.message : "Credential validation failed";
2232
+ return {
2233
+ success: false,
2234
+ error: msg
2235
+ };
2236
+ }
2237
+ }
2238
+ chunkUSNT2KNT_cjs.__name(validateFcmCredentials, "validateFcmCredentials");
2197
2239
 
2198
2240
  // src/lib/order-notification-dispatcher.ts
2199
2241
  var initialized = false;
@@ -2876,4 +2918,5 @@ exports.resolveChatEmailToolSettings = resolveChatEmailToolSettings;
2876
2918
  exports.sendChatLeadEmail = sendChatLeadEmail;
2877
2919
  exports.sendFcmPushNotification = sendFcmPushNotification;
2878
2920
  exports.serializeEmailRecipients = serializeEmailRecipients;
2921
+ exports.validateFcmCredentials = validateFcmCredentials;
2879
2922
  exports.whatsAppConfigured = whatsAppConfigured;
@@ -2168,6 +2168,48 @@ async function sendFcmPushNotification(dataSource, entityMap, msg) {
2168
2168
  }
2169
2169
  }
2170
2170
  __name(sendFcmPushNotification, "sendFcmPushNotification");
2171
+ async function validateFcmCredentials(dataSource, entityMap) {
2172
+ try {
2173
+ const pushSettings = await getSettingsGroup(dataSource, entityMap, "push");
2174
+ let projectId = pushSettings.firebase_project_id?.trim();
2175
+ let clientEmail = pushSettings.firebase_client_email?.trim();
2176
+ let privateKey = pushSettings.firebase_private_key?.trim();
2177
+ if (pushSettings.firebase_service_account_json?.trim()) {
2178
+ try {
2179
+ const parsed = JSON.parse(pushSettings.firebase_service_account_json.trim());
2180
+ if (parsed.project_id) projectId = parsed.project_id;
2181
+ if (parsed.client_email) clientEmail = parsed.client_email;
2182
+ if (parsed.private_key) privateKey = parsed.private_key;
2183
+ } catch {
2184
+ }
2185
+ }
2186
+ if (!projectId || !clientEmail || !privateKey) {
2187
+ return {
2188
+ success: false,
2189
+ error: "Firebase Service Account JSON / credentials are not configured in settings"
2190
+ };
2191
+ }
2192
+ const token = await getGoogleAccessToken(clientEmail, privateKey);
2193
+ if (!token) {
2194
+ return {
2195
+ success: false,
2196
+ error: "Failed to obtain Google OAuth access token"
2197
+ };
2198
+ }
2199
+ return {
2200
+ success: true,
2201
+ projectId,
2202
+ clientEmail
2203
+ };
2204
+ } catch (err) {
2205
+ const msg = err instanceof Error ? err.message : "Credential validation failed";
2206
+ return {
2207
+ success: false,
2208
+ error: msg
2209
+ };
2210
+ }
2211
+ }
2212
+ __name(validateFcmCredentials, "validateFcmCredentials");
2171
2213
 
2172
2214
  // src/lib/order-notification-dispatcher.ts
2173
2215
  var initialized = false;
@@ -2825,4 +2867,4 @@ async function resendOrderNotification(triggerKey, orderId, deps) {
2825
2867
  }
2826
2868
  __name(resendOrderNotification, "resendOrderNotification");
2827
2869
 
2828
- export { CHAT_EMAIL_LOG, EmailService, WhatsAppService, buildChatbotSystemPromptWithEmailTool, buildEventOrderTemplateVariables, buildTranscriptForLeadEmail, detectChatLeadIntent, emailPlugin, emailTemplates, getSettingsGroup, initWhatsappTriggerDispatcher, isWhatsAppPluginEnabled, joinRecipientsForSend, mergeWhatsAppConfigLayers, parseEmailRecipientsFromConfig, parseIntentRecipientEmails, queueWhatsApp, registerWhatsAppQueueProcessor, renderEmail, renderLayout, resendOrderNotification, resolveChatEmailToolSettings, sendChatLeadEmail, sendFcmPushNotification, serializeEmailRecipients, whatsAppConfigured };
2870
+ export { CHAT_EMAIL_LOG, EmailService, WhatsAppService, buildChatbotSystemPromptWithEmailTool, buildEventOrderTemplateVariables, buildTranscriptForLeadEmail, detectChatLeadIntent, emailPlugin, emailTemplates, getSettingsGroup, initWhatsappTriggerDispatcher, isWhatsAppPluginEnabled, joinRecipientsForSend, mergeWhatsAppConfigLayers, parseEmailRecipientsFromConfig, parseIntentRecipientEmails, queueWhatsApp, registerWhatsAppQueueProcessor, renderEmail, renderLayout, resendOrderNotification, resolveChatEmailToolSettings, sendChatLeadEmail, sendFcmPushNotification, serializeEmailRecipients, validateFcmCredentials, whatsAppConfigured };