@bikdotai/bik-shared-backend 20.3.1 ā 20.3.2-beta.1
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/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.d.ts +1 -0
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.js +4 -0
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.d.ts +1 -0
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.js +4 -0
- package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.d.ts +1 -0
- package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.js +4 -0
- package/lib/alertsV2/alertInstances.repo.js +26 -2
- package/lib/alertsV2/alertsV2.helper.d.ts +3 -4
- package/lib/alertsV2/alertsV2.helper.js +49 -3
- package/lib/alertsV2/alertsV2.service.js +14 -5
- package/lib/auth/authMiddlewares.js +68 -3
- package/lib/auth/firebase-auth.service.js +3 -3
- package/lib/auth/implementations/bik-admin-auth-service.d.ts +1 -1
- package/lib/auth/implementations/bik-admin-auth-service.js +2 -1
- package/lib/auth/index.d.ts +3 -0
- package/lib/auth/index.js +3 -0
- package/lib/auth/secret-manager/configManager.firestore.d.ts +22 -0
- package/lib/auth/secret-manager/configManager.firestore.js +166 -0
- package/lib/auth/secret-manager/configManager.helper.d.ts +13 -0
- package/lib/auth/secret-manager/configManager.helper.js +32 -0
- package/lib/auth/secret-manager/configManager.model.d.ts +38 -0
- package/lib/auth/secret-manager/configManager.model.js +2 -0
- package/lib/auth/secret-manager/configManager.service.d.ts +17 -0
- package/lib/auth/secret-manager/configManager.service.js +138 -0
- package/lib/auth/secret-manager/env-variables/variables.list.d.ts +3 -0
- package/lib/auth/secret-manager/env-variables/variables.list.js +3 -0
- package/lib/chat-handover-protocol/chat-handover-protocol.js +26 -41
- package/lib/core/local_runner.js +28 -11
- package/lib/core/setup.d.ts +3 -0
- package/lib/core/setup.js +24 -2
- package/lib/database/database.model.d.ts +95 -0
- package/lib/database/database.model.js +5 -0
- package/lib/database/database.service.d.ts +90 -0
- package/lib/database/database.service.js +382 -0
- package/lib/database/index.d.ts +7 -0
- package/lib/database/index.js +23 -0
- package/lib/elastic/counter/ingestion.js +1 -0
- package/lib/elastic/queries/campaign/getBroadcastDetailedStats.d.ts +117 -0
- package/lib/elastic/queries/campaign/getBroadcastDetailedStats.js +94 -1
- package/lib/elastic/queries/campaign/getUniqueCustomerCnt.d.ts +1 -0
- package/lib/elastic/queries/campaign/getUniqueCustomerCnt.js +1 -0
- package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.d.ts +117 -0
- package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.js +98 -0
- package/lib/elastic/queries/chatbot/getAiOperations.d.ts +5 -5
- package/lib/elastic/queries/chatbot/getAiOperations.js +3 -3
- package/lib/elastic/queries/chatbot/index.d.ts +1 -0
- package/lib/elastic/queries/chatbot/index.js +1 -0
- package/lib/elastic/queries/crm/getActivityTimelineByAgent.js +1 -1
- package/lib/elastic/queries/crm/getBreachedSLACount.d.ts +1 -0
- package/lib/elastic/queries/crm/getBreachedSLACount.js +8 -5
- package/lib/elastic/queries/crm/getFirstResponseTime.d.ts +1 -0
- package/lib/elastic/queries/crm/getFirstResponseTime.js +8 -5
- package/lib/elastic/queries/integrations/getOrdersShadowServices.d.ts +76 -0
- package/lib/elastic/queries/integrations/getOrdersShadowServices.js +61 -0
- package/lib/elastic/queries/integrations/index.d.ts +1 -0
- package/lib/elastic/queries/integrations/index.js +1 -0
- package/lib/elastic/queries/openAi/addToCartSession.d.ts +1 -0
- package/lib/elastic/queries/openAi/addToCartSession.js +11 -3
- package/lib/elastic/queries/openAi/checkoutCompletedSession.d.ts +1 -0
- package/lib/elastic/queries/openAi/checkoutCompletedSession.js +11 -3
- package/lib/elastic/reports/crm/index.d.ts +1 -0
- package/lib/elastic/reports/crm/index.js +1 -0
- package/lib/elastic/reports/reports.service.js +17 -8
- package/lib/events/events.d.ts +8 -0
- package/lib/events/events.js +25 -1
- package/lib/events/schema/events.helper.d.ts +1 -0
- package/lib/events/schema/events.helper.js +12 -6
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/merchant-events/elastic.search.d.ts +5 -0
- package/lib/merchant-events/elastic.search.js +23 -2
- package/lib/merchant-events/merchant.service.d.ts +1 -1
- package/lib/merchant-events/merchant.service.js +12 -11
- package/lib/recordAnalytics/recordAnalytics.service.js +5 -4
- package/lib/redis/redisPubSubService.d.ts +4 -6
- package/lib/redis/redisPubSubService.js +211 -123
- package/lib/redis/redisService.js +14 -8
- package/lib/swagger/SwaggerSchemaHelper.js +21 -17
- package/lib/user-properties/userProperties.service.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const email = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Campaign Moved to Draft</title><style>body { margin: 0; padding: 0; background-color: #f5f5f5; font-family: Arial, Helvetica, sans-serif;}table { border-collapse: collapse;}.container { width: 100%; max-width: 520px; margin: 0 auto; background-color: #ffffff;}.content { padding: 24px; color: #000000; font-size: 14px; line-height: 1.6;}h1 { font-size: 22px; text-align: center; margin: 20px 0;}.button { display: inline-block; background-color: #4a136a; color: #ffffff !important; text-decoration: none; padding: 12px 24px; border-radius: 4px; font-size: 14px; font-weight: bold;}.footer { font-size: 12px; color: #777777; text-align: center; padding: 20px;}.divider { border-top: 1px solid #dddddd; margin: 30px 0 20px;}@media only screen and (max-width: 520px) { .content { padding: 18px; }}</style></head><body><table width=\"100%\"><tr><td align=\"center\"><table class=\"container\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" style=\"padding: 24px 0;\"><img src=\"https://d15k2d11r6t6rl.cloudfront.net/public/users/Integrators/7d081d61-4dc8-48b8-a19d-9d907d27d124/XJdIdqNvP6gN7jZQIETZMADLDue2/b222a835-aaf6-4085-ac3d-a1992aa21e61.png\" width=\"100\" alt=\"BIK Logo\" style=\"display:block;\"></td></tr><tr><td class=\"content\"><h1>Campaign Moved to Draft \u2013 Segment Sync Delay</h1><p>Hi {{Store Name}} team,</p><p>Your broadcast \"<strong>{{Broadcast Name}}</strong>\" has been moved to Draft because the associated segment sync is taking longer than 3 hours to complete.</p> <div style=\"text-align:center; margin:30px 0;\"><!--[if mso]><v:roundrect xmlns:v=\"urn:schemas-microsoft-com:vml\" href=\"https://dashboard.bik.ai/campaigns/overview\"style=\"height:40px;v-text-anchor:middle;width:260px;\" arcsize=\"50%\" stroke=\"f\" fillcolor=\"#4a136a\"><w:anchorlock/><center style=\"color:#ffffff;font-family:Arial;font-size:14px;font-weight:bold;\">View Campaign Details</center></v:roundrect><![endif]--><!--[if !mso]><!-- --><a href=\"https://dashboard.bik.ai/campaigns/overview\"class=\"button\"target=\"_blank\">View Campaign Details</a><!--<![endif]--></div> <p>To ensure accurate audience targeting, we have not sent the campaign.</p><p>We recommend rescheduling the campaign once the segment sync is complete.</p><p>If the delay continues or you need assistance, please contact BIK Support.</p><p>Best,<br>Team BIK</p></td></tr> </table></body></html>";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.email = void 0;
|
|
4
|
+
exports.email = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Campaign Moved to Draft</title><style>body { margin: 0; padding: 0; background-color: #f5f5f5; font-family: Arial, Helvetica, sans-serif;}table { border-collapse: collapse;}.container { width: 100%; max-width: 520px; margin: 0 auto; background-color: #ffffff;}.content { padding: 24px; color: #000000; font-size: 14px; line-height: 1.6;}h1 { font-size: 22px; text-align: center; margin: 20px 0;}.button { display: inline-block; background-color: #4a136a; color: #ffffff !important; text-decoration: none; padding: 12px 24px; border-radius: 4px; font-size: 14px; font-weight: bold;}.footer { font-size: 12px; color: #777777; text-align: center; padding: 20px;}.divider { border-top: 1px solid #dddddd; margin: 30px 0 20px;}@media only screen and (max-width: 520px) { .content { padding: 18px; }}</style></head><body><table width="100%"><tr><td align="center"><table class="container" role="presentation" cellpadding="0" cellspacing="0"><tr><td align="center" style="padding: 24px 0;"><img src="https://d15k2d11r6t6rl.cloudfront.net/public/users/Integrators/7d081d61-4dc8-48b8-a19d-9d907d27d124/XJdIdqNvP6gN7jZQIETZMADLDue2/b222a835-aaf6-4085-ac3d-a1992aa21e61.png" width="100" alt="BIK Logo" style="display:block;"></td></tr><tr><td class="content"><h1>Campaign Moved to Draft ā Segment Sync Delay</h1><p>Hi {{Store Name}} team,</p><p>Your broadcast "<strong>{{Broadcast Name}}</strong>" has been moved to Draft because the associated segment sync is taking longer than 3 hours to complete.</p> <div style="text-align:center; margin:30px 0;"><!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" href="https://dashboard.bik.ai/campaigns/overview"style="height:40px;v-text-anchor:middle;width:260px;" arcsize="50%" stroke="f" fillcolor="#4a136a"><w:anchorlock/><center style="color:#ffffff;font-family:Arial;font-size:14px;font-weight:bold;">View Campaign Details</center></v:roundrect><![endif]--><!--[if !mso]><!-- --><a href="https://dashboard.bik.ai/campaigns/overview"class="button"target="_blank">View Campaign Details</a><!--<![endif]--></div> <p>To ensure accurate audience targeting, we have not sent the campaign.</p><p>We recommend rescheduling the campaign once the segment sync is complete.</p><p>If the delay continues or you need assistance, please contact BIK Support.</p><p>Best,<br>Team BIK</p></td></tr> </table></body></html>`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const email = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Campaign Moved to Draft</title><style>body { margin: 0; padding: 0; background-color: #f5f5f5; font-family: Arial, Helvetica, sans-serif;}table { border-collapse: collapse;}.container { width: 100%; max-width: 520px; margin: 0 auto; background-color: #ffffff;}.content { padding: 24px; color: #000000; font-size: 14px; line-height: 1.6;}h1 { font-size: 22px; text-align: center; margin: 20px 0;}.button { display: inline-block; background-color: #4a136a; color: #ffffff !important; text-decoration: none; padding: 12px 24px; border-radius: 4px; font-size: 14px; font-weight: bold;}@media only screen and (max-width: 520px) { .content { padding: 18px; }}</style></head><body><table width=\"100%\"><tr><td align=\"center\"><table class=\"container\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" style=\"padding: 24px 0;\"><img src=\"https://d15k2d11r6t6rl.cloudfront.net/public/users/Integrators/7d081d61-4dc8-48b8-a19d-9d907d27d124/XJdIdqNvP6gN7jZQIETZMADLDue2/b222a835-aaf6-4085-ac3d-a1992aa21e61.png\" width=\"100\" alt=\"BIK Logo\" style=\"display:block;\"></td></tr><tr><td class=\"content\"><h1>Campaign Moved to Draft \u2013 Segment Sync Failed</h1><p>Hi {{Store Name}} team,</p><p>Your campaign \"<strong>{{Campaign Name}}</strong>\" has been moved to Draft because the associated segment sync failed.</p><div style=\"text-align:center; margin:30px 0;\"><!--[if mso]><v:roundrect xmlns:v=\"urn:schemas-microsoft-com:vml\" href=\"https://dashboard.bik.ai/campaigns/overview\"style=\"height:40px;v-text-anchor:middle;width:260px;\" arcsize=\"50%\" stroke=\"f\" fillcolor=\"#4a136a\"><w:anchorlock/><center style=\"color:#ffffff;font-family:Arial;font-size:14px;font-weight:bold;\">View Campaign Details</center></v:roundrect><![endif]--><!--[if !mso]><!-- --><a href=\"https://dashboard.bik.ai/campaigns/overview\"class=\"button\"target=\"_blank\">View Campaign Details</a><!--<![endif]--></div><p>To prevent sending to an incomplete or incorrect audience, we have paused the campaign.</p><p>Please review the segment, retry the sync, and reschedule the campaign once the sync completes successfully.</p><p>Best,<br>Team BIK</p></td></tr></table></td></tr></table></body></html>";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.email = void 0;
|
|
4
|
+
exports.email = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Campaign Moved to Draft</title><style>body { margin: 0; padding: 0; background-color: #f5f5f5; font-family: Arial, Helvetica, sans-serif;}table { border-collapse: collapse;}.container { width: 100%; max-width: 520px; margin: 0 auto; background-color: #ffffff;}.content { padding: 24px; color: #000000; font-size: 14px; line-height: 1.6;}h1 { font-size: 22px; text-align: center; margin: 20px 0;}.button { display: inline-block; background-color: #4a136a; color: #ffffff !important; text-decoration: none; padding: 12px 24px; border-radius: 4px; font-size: 14px; font-weight: bold;}@media only screen and (max-width: 520px) { .content { padding: 18px; }}</style></head><body><table width="100%"><tr><td align="center"><table class="container" role="presentation" cellpadding="0" cellspacing="0"><tr><td align="center" style="padding: 24px 0;"><img src="https://d15k2d11r6t6rl.cloudfront.net/public/users/Integrators/7d081d61-4dc8-48b8-a19d-9d907d27d124/XJdIdqNvP6gN7jZQIETZMADLDue2/b222a835-aaf6-4085-ac3d-a1992aa21e61.png" width="100" alt="BIK Logo" style="display:block;"></td></tr><tr><td class="content"><h1>Campaign Moved to Draft ā Segment Sync Failed</h1><p>Hi {{Store Name}} team,</p><p>Your campaign "<strong>{{Campaign Name}}</strong>" has been moved to Draft because the associated segment sync failed.</p><div style="text-align:center; margin:30px 0;"><!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" href="https://dashboard.bik.ai/campaigns/overview"style="height:40px;v-text-anchor:middle;width:260px;" arcsize="50%" stroke="f" fillcolor="#4a136a"><w:anchorlock/><center style="color:#ffffff;font-family:Arial;font-size:14px;font-weight:bold;">View Campaign Details</center></v:roundrect><![endif]--><!--[if !mso]><!-- --><a href="https://dashboard.bik.ai/campaigns/overview"class="button"target="_blank">View Campaign Details</a><!--<![endif]--></div><p>To prevent sending to an incomplete or incorrect audience, we have paused the campaign.</p><p>Please review the segment, retry the sync, and reschedule the campaign once the sync completes successfully.</p><p>Best,<br>Team BIK</p></td></tr></table></td></tr></table></body></html>`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const email = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Campaign Scheduled Time Exceeded</title><style>body { margin: 0; padding: 0; background-color: #f5f5f5; font-family: Arial, Helvetica, sans-serif;}table { border-collapse: collapse;}.container { width: 100%; max-width: 520px; margin: 0 auto; background-color: #ffffff;}.content { padding: 24px; color: #000000; font-size: 14px; line-height: 1.6;}h1 { font-size: 22px; text-align: center; margin: 20px 0;}.button { display: inline-block; background-color: #4a136a; color: #ffffff !important; text-decoration: none; padding: 12px 24px; border-radius: 4px; font-size: 14px; font-weight: bold;}@media only screen and (max-width: 520px) { .content { padding: 18px; }}</style></head><body><table width=\"100%\"><tr><td align=\"center\"><table class=\"container\" role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" style=\"padding: 24px 0;\"><img src=\"https://d15k2d11r6t6rl.cloudfront.net/public/users/Integrators/7d081d61-4dc8-48b8-a19d-9d907d27d124/XJdIdqNvP6gN7jZQIETZMADLDue2/b222a835-aaf6-4085-ac3d-a1992aa21e61.png\" width=\"100\" alt=\"BIK Logo\" style=\"display:block;\"></td></tr><tr><td class=\"content\"><h1>Campaign Scheduled Time Exceeded Due to Sync Delay</h1><p>Hi {{Store Name}} team,</p><p>Your broadcast \"<strong>{{Broadcast Name}}</strong>\" is currently scheduled, and the associated segment sync is still in progress.</p><p>To ensure accurate audience targeting, the campaign will only be executed once the segment sync is successfully completed.</p><p><strong>Please note:</strong> If the sync takes longer than 3 hours and does not complete before the scheduled send time, the campaign will not be executed and will automatically move to Draft.</p><p>We recommend monitoring the segment sync status and rescheduling the campaign if needed.</p><div style=\"text-align:center; margin:30px 0;\"><!--[if mso]><v:roundrect xmlns:v=\"urn:schemas-microsoft-com:vml\" href=\"https://dashboard.bik.ai/campaigns/overview\"style=\"height:40px;v-text-anchor:middle;width:260px;\" arcsize=\"50%\" stroke=\"f\" fillcolor=\"#4a136a\"><w:anchorlock/><center style=\"color:#ffffff;font-family:Arial;font-size:14px;font-weight:bold;\">View Campaign Details</center></v:roundrect><![endif]--><!--[if !mso]><!-- --><a href=\"https://dashboard.bik.ai/campaigns/overview\"class=\"button\"target=\"_blank\">View Campaign Details</a><!--<![endif]--></div><p>If you need any assistance, please contact BIK Support.</p><p>Best,<br>Team BIK</p></td></tr></table></td></tr></table></body></html>";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.email = void 0;
|
|
4
|
+
exports.email = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Campaign Scheduled Time Exceeded</title><style>body { margin: 0; padding: 0; background-color: #f5f5f5; font-family: Arial, Helvetica, sans-serif;}table { border-collapse: collapse;}.container { width: 100%; max-width: 520px; margin: 0 auto; background-color: #ffffff;}.content { padding: 24px; color: #000000; font-size: 14px; line-height: 1.6;}h1 { font-size: 22px; text-align: center; margin: 20px 0;}.button { display: inline-block; background-color: #4a136a; color: #ffffff !important; text-decoration: none; padding: 12px 24px; border-radius: 4px; font-size: 14px; font-weight: bold;}@media only screen and (max-width: 520px) { .content { padding: 18px; }}</style></head><body><table width="100%"><tr><td align="center"><table class="container" role="presentation" cellpadding="0" cellspacing="0"><tr><td align="center" style="padding: 24px 0;"><img src="https://d15k2d11r6t6rl.cloudfront.net/public/users/Integrators/7d081d61-4dc8-48b8-a19d-9d907d27d124/XJdIdqNvP6gN7jZQIETZMADLDue2/b222a835-aaf6-4085-ac3d-a1992aa21e61.png" width="100" alt="BIK Logo" style="display:block;"></td></tr><tr><td class="content"><h1>Campaign Scheduled Time Exceeded Due to Sync Delay</h1><p>Hi {{Store Name}} team,</p><p>Your broadcast "<strong>{{Broadcast Name}}</strong>" is currently scheduled, and the associated segment sync is still in progress.</p><p>To ensure accurate audience targeting, the campaign will only be executed once the segment sync is successfully completed.</p><p><strong>Please note:</strong> If the sync takes longer than 3 hours and does not complete before the scheduled send time, the campaign will not be executed and will automatically move to Draft.</p><p>We recommend monitoring the segment sync status and rescheduling the campaign if needed.</p><div style="text-align:center; margin:30px 0;"><!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" href="https://dashboard.bik.ai/campaigns/overview"style="height:40px;v-text-anchor:middle;width:260px;" arcsize="50%" stroke="f" fillcolor="#4a136a"><w:anchorlock/><center style="color:#ffffff;font-family:Arial;font-size:14px;font-weight:bold;">View Campaign Details</center></v:roundrect><![endif]--><!--[if !mso]><!-- --><a href="https://dashboard.bik.ai/campaigns/overview"class="button"target="_blank">View Campaign Details</a><!--<![endif]--></div><p>If you need any assistance, please contact BIK Support.</p><p>Best,<br>Team BIK</p></td></tr></table></td></tr></table></body></html>`;
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,6 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
33
|
};
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
35
|
exports.AlertInstancesRepo = void 0;
|
|
36
|
+
const admin = __importStar(require("firebase-admin"));
|
|
13
37
|
const auth_1 = require("../auth");
|
|
14
38
|
const bik_models_1 = require("@bikdotai/bik-models");
|
|
15
39
|
class AlertInstancesRepo {
|
|
@@ -30,7 +54,7 @@ class AlertInstancesRepo {
|
|
|
30
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
55
|
try {
|
|
32
56
|
const docRef = id ? this.dbRef().doc(id) : this.dbRef().doc();
|
|
33
|
-
const alertInstanceData = Object.assign(Object.assign({}, instance), { id: docRef.id, createdAt:
|
|
57
|
+
const alertInstanceData = Object.assign(Object.assign({}, instance), { id: docRef.id, createdAt: admin.firestore.Timestamp.now().toDate().toISOString() });
|
|
34
58
|
yield docRef.set(alertInstanceData);
|
|
35
59
|
return {
|
|
36
60
|
id: docRef.id,
|
|
@@ -47,7 +71,7 @@ class AlertInstancesRepo {
|
|
|
47
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
72
|
try {
|
|
49
73
|
const batch = this.db.batch();
|
|
50
|
-
const createdAt =
|
|
74
|
+
const createdAt = admin.firestore.Timestamp.now().toDate().toISOString();
|
|
51
75
|
instances.forEach((instance) => {
|
|
52
76
|
const docRef = this.dbRef().doc();
|
|
53
77
|
const alertInstanceData = Object.assign(Object.assign({}, instance), { id: docRef.id, createdAt });
|
|
@@ -4,13 +4,12 @@ export declare class AlertsV2Helper {
|
|
|
4
4
|
private static validateTemplate;
|
|
5
5
|
private static validateEmailConfig;
|
|
6
6
|
static getRecipients(body: AlertsV2.GetRecipientsRequest): ResolvedFunctionResponse<AlertsV2.GetUsersByRolesResponse>;
|
|
7
|
-
static
|
|
8
|
-
|
|
9
|
-
storeId: string;
|
|
10
|
-
}): ResolvedFunctionResponse<AlertsV2.GetUserByAgentIdResponse>;
|
|
7
|
+
static getPhoneNumberFromAgentEmail(body: AlertsV2.getPhoneNumberFromAgentEmailRequest): ResolvedFunctionResponse<AlertsV2.getPhoneNumberFromAgentEmailResponse>;
|
|
8
|
+
static getUserByAgentId(body: AlertsV2.GetUserByAgentIdRequest): ResolvedFunctionResponse<AlertsV2.GetUserByAgentIdResponse>;
|
|
11
9
|
static validateCreateAlertConfig(body: AlertsV2.CreateAlertConfigRequest): ResolvedFunctionResponse<void>;
|
|
12
10
|
static validateSendAlert(body: AlertsV2.SendAlertRequest, hasCurrentUser: boolean): FunctionResponse<void>;
|
|
13
11
|
static validateSendWhatsappAlert(body: AlertsV2.SendWhatsappAlertRequest): FunctionResponse<void>;
|
|
14
12
|
static validateAndReplaceVariables(request: AlertsV2.ValidateAndReplaceVariablesRequest): FunctionResponse<AlertsV2.ValidatedComponentPayload>;
|
|
15
13
|
static extractContactInfo(recipients: AlertsV2.UserContactInfo[]): AlertsV2.ExtractedContactInfo;
|
|
14
|
+
static extractSingleContactInfo(recipients: AlertsV2.UserContactInfo): AlertsV2.ExtractedContactInfo;
|
|
16
15
|
}
|
|
@@ -83,11 +83,11 @@ class AlertsV2Helper {
|
|
|
83
83
|
return apis_1.FunctionResponseHelper.success(responseData);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
static
|
|
86
|
+
static getPhoneNumberFromAgentEmail(body) {
|
|
87
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
88
|
const getUsersByAgentIdRequestBody = {
|
|
89
89
|
storeId: body.storeId,
|
|
90
|
-
email: body.
|
|
90
|
+
email: body.email
|
|
91
91
|
};
|
|
92
92
|
const updateDetailsRequest = {
|
|
93
93
|
apiPath: `${(0, elastic_1.getApiUrl)(constants_1.POD_NAME.CRM)}/userApiFunctions-getUsers`,
|
|
@@ -106,7 +106,7 @@ class AlertsV2Helper {
|
|
|
106
106
|
// Handle users as an array
|
|
107
107
|
if (!parsedData.users || !Array.isArray(parsedData.users) || parsedData.users.length === 0) {
|
|
108
108
|
console.warn('No user found with the provided agent ID');
|
|
109
|
-
return apis_1.FunctionResponseHelper.failed(api_response_1.ErrorCodes.RESOURCE_NOT_FOUND, `User not found for
|
|
109
|
+
return apis_1.FunctionResponseHelper.failed(api_response_1.ErrorCodes.RESOURCE_NOT_FOUND, `User not found for email: ${body.email}`);
|
|
110
110
|
}
|
|
111
111
|
// Map array of users to extract email and phoneNumber
|
|
112
112
|
const users = parsedData.users.map((user) => ({
|
|
@@ -119,6 +119,38 @@ class AlertsV2Helper {
|
|
|
119
119
|
return apis_1.FunctionResponseHelper.success(responseData);
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
+
static getUserByAgentId(body) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const getUsersByAgentIdRequestBody = {
|
|
125
|
+
storeId: body.storeId,
|
|
126
|
+
agentId: body.agentId
|
|
127
|
+
};
|
|
128
|
+
const updateDetailsRequest = {
|
|
129
|
+
apiPath: `${(0, elastic_1.getApiUrl)(constants_1.POD_NAME.CRM)}/userApiFunctions-getUserByAgentId`,
|
|
130
|
+
apiMethod: executor_1.HTTPMethods.POST,
|
|
131
|
+
requestHeader: {},
|
|
132
|
+
requestBody: JSON.stringify(getUsersByAgentIdRequestBody),
|
|
133
|
+
isInternal: true,
|
|
134
|
+
};
|
|
135
|
+
const response = yield executor_1.RequestExecutor.executeHttpAPIRequest(updateDetailsRequest);
|
|
136
|
+
if (response.status !== 200) {
|
|
137
|
+
const errorText = yield response.text();
|
|
138
|
+
console.log('Error response: ', errorText);
|
|
139
|
+
return apis_1.FunctionResponseHelper.failed(api_response_1.ErrorCodes.INTERNAL_SERVER_ERROR, `Failed to get recipients: ${errorText}`);
|
|
140
|
+
}
|
|
141
|
+
const parsedData = yield response.json();
|
|
142
|
+
const data = parsedData.data;
|
|
143
|
+
// Handle users as an array
|
|
144
|
+
if (!data.users) {
|
|
145
|
+
console.warn('No user found with the provided agent ID');
|
|
146
|
+
return apis_1.FunctionResponseHelper.failed(api_response_1.ErrorCodes.RESOURCE_NOT_FOUND, `User not found for agentId: ${body.agentId}`);
|
|
147
|
+
}
|
|
148
|
+
const responseData = {
|
|
149
|
+
users: data.users
|
|
150
|
+
};
|
|
151
|
+
return apis_1.FunctionResponseHelper.success(responseData);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
122
154
|
static validateCreateAlertConfig(body) {
|
|
123
155
|
var _a, _b, _c;
|
|
124
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -261,5 +293,19 @@ class AlertsV2Helper {
|
|
|
261
293
|
emails,
|
|
262
294
|
};
|
|
263
295
|
}
|
|
296
|
+
static extractSingleContactInfo(recipients) {
|
|
297
|
+
const phoneNumbers = [];
|
|
298
|
+
const emails = [];
|
|
299
|
+
if (recipients.phoneNumber && recipients.phoneNumber.trim() !== '') {
|
|
300
|
+
phoneNumbers.push(recipients.phoneNumber);
|
|
301
|
+
}
|
|
302
|
+
if (recipients.email && recipients.email.trim() !== '') {
|
|
303
|
+
emails.push(recipients.email);
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
phoneNumbers,
|
|
307
|
+
emails,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
264
310
|
}
|
|
265
311
|
exports.AlertsV2Helper = AlertsV2Helper;
|
|
@@ -308,8 +308,11 @@ class AlertsV2Service {
|
|
|
308
308
|
if (!validationResult.success) {
|
|
309
309
|
return validationResult;
|
|
310
310
|
}
|
|
311
|
-
//
|
|
311
|
+
// Fetch recipient contacts using appropriate strategy
|
|
312
312
|
const { phoneNumbers, emails } = yield this.fetchRecipientContacts(body);
|
|
313
|
+
if (phoneNumbers.length === 0 && emails.length === 0) {
|
|
314
|
+
return apis_1.FunctionResponseHelper.failed(api_response_1.ErrorCodes.RESOURCE_NOT_FOUND, 'No valid recipients found for alert');
|
|
315
|
+
}
|
|
313
316
|
const channels = body.types;
|
|
314
317
|
// Track per-recipient results separately for each channel
|
|
315
318
|
const recipientChannelSuccess = new Map();
|
|
@@ -354,7 +357,7 @@ class AlertsV2Service {
|
|
|
354
357
|
const variableConfig = yield this.alertConfigsRepo.getVariableConfigByAlertConfigId(body.alertConfigId);
|
|
355
358
|
const emailRequest = {
|
|
356
359
|
emailConfig,
|
|
357
|
-
variables: body.variables ||
|
|
360
|
+
variables: body.variables || {},
|
|
358
361
|
variableConfig,
|
|
359
362
|
emails: emails,
|
|
360
363
|
storeId: body.storeId,
|
|
@@ -391,6 +394,7 @@ class AlertsV2Service {
|
|
|
391
394
|
try {
|
|
392
395
|
const pushNotificationConfig = yield this.alertConfigsRepo.getPushNotificationConfigByAlertConfigId(body.alertConfigId);
|
|
393
396
|
const variableConfig = yield this.alertConfigsRepo.getVariableConfigByAlertConfigId(body.alertConfigId);
|
|
397
|
+
console.log('Push notification config:', pushNotificationConfig);
|
|
394
398
|
const pushNotificationRequest = {
|
|
395
399
|
storeId: body.storeId,
|
|
396
400
|
pushNotificationConfig,
|
|
@@ -440,7 +444,7 @@ class AlertsV2Service {
|
|
|
440
444
|
configId: body.alertConfigId,
|
|
441
445
|
configName: alertConfig.name,
|
|
442
446
|
persistHistory: alertConfig.persistHistory,
|
|
443
|
-
agentId:
|
|
447
|
+
agentId: emails,
|
|
444
448
|
channel: channels,
|
|
445
449
|
};
|
|
446
450
|
const { successfulRecipients, failedRecipients, feConfigs, errors } = yield this.sendFrontendNotification(frontendNotificationRequest);
|
|
@@ -662,7 +666,9 @@ class AlertsV2Service {
|
|
|
662
666
|
return {
|
|
663
667
|
successfulRecipients: new Map(),
|
|
664
668
|
failedRecipients: new Map(),
|
|
665
|
-
errors: [
|
|
669
|
+
errors: [
|
|
670
|
+
'Missing email content configuration: provide emailType, templateId, emailBody.html, or emailBody.text',
|
|
671
|
+
],
|
|
666
672
|
};
|
|
667
673
|
}
|
|
668
674
|
const emailFrom = ((_j = body.emailConfig.emailBody) === null || _j === void 0 ? void 0 : _j.from) ||
|
|
@@ -701,6 +707,7 @@ class AlertsV2Service {
|
|
|
701
707
|
emailBody,
|
|
702
708
|
sendViaMailgun: true,
|
|
703
709
|
};
|
|
710
|
+
console.log('Sending email with request:', { emailRequest, emailEndpoint });
|
|
704
711
|
const sendEmailRequest = {
|
|
705
712
|
apiPath: emailEndpoint,
|
|
706
713
|
apiMethod: executor_1.HTTPMethods.POST,
|
|
@@ -763,7 +770,9 @@ class AlertsV2Service {
|
|
|
763
770
|
successfulRecipients.set(email, messageId);
|
|
764
771
|
}
|
|
765
772
|
else {
|
|
766
|
-
const errorText =
|
|
773
|
+
const errorText = responseData
|
|
774
|
+
? JSON.stringify(responseData)
|
|
775
|
+
: `HTTP ${sendResponse.status}`;
|
|
767
776
|
console.error(`Failed to send email alert to ${email}:`, errorText);
|
|
768
777
|
errors.push(`${email}: ${errorText}`);
|
|
769
778
|
failedRecipients.set(email, errorText);
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,6 +31,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
11
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
38
|
exports.AuthMiddlewareService = void 0;
|
|
13
39
|
const logger_1 = require("../logger");
|
|
@@ -17,6 +43,8 @@ const firebase_auth_service_1 = require("./firebase-auth.service");
|
|
|
17
43
|
const all_services_1 = require("./implementations/all-services");
|
|
18
44
|
const swagger_1 = require("../swagger");
|
|
19
45
|
const core_1 = require("../core");
|
|
46
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
47
|
+
const util = __importStar(require("util"));
|
|
20
48
|
class AuthMiddlewareService {
|
|
21
49
|
constructor(isProd, throwError, whitelistedApis, publicApis, firebaseApp, apiSchema, debugEnabled = false) {
|
|
22
50
|
this.isProd = isProd;
|
|
@@ -27,8 +55,8 @@ class AuthMiddlewareService {
|
|
|
27
55
|
this.apiSchema = apiSchema;
|
|
28
56
|
this.debugEnabled = debugEnabled;
|
|
29
57
|
this.authMiddleware = (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
var _a;
|
|
31
|
-
const requestUrl = (request.routeOptions.url || request.url).substring(1);
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const requestUrl = (((_a = request.routeOptions) === null || _a === void 0 ? void 0 : _a.url) || request.url).substring(1);
|
|
32
60
|
if (requestUrl.startsWith('not-a-documentation')) {
|
|
33
61
|
yield swagger_1.SwaggerSetupHelper.authenticateSwagger(request, response);
|
|
34
62
|
return;
|
|
@@ -44,6 +72,43 @@ class AuthMiddlewareService {
|
|
|
44
72
|
const requestBody = request.body || {};
|
|
45
73
|
const referrer = request.headers['bik-referer'] || '';
|
|
46
74
|
const authorization = request.headers['authorization'];
|
|
75
|
+
if (authorization) {
|
|
76
|
+
try {
|
|
77
|
+
// Remove 'Bearer ' prefix if present (case-insensitive)
|
|
78
|
+
const rawAuth = Array.isArray(authorization) ? authorization[0] : authorization;
|
|
79
|
+
const token = rawAuth.toString().replace(/^\s*Bearer\s+/i, '').trim();
|
|
80
|
+
// print full raw token without truncation
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
82
|
+
let headers = request.headers || {};
|
|
83
|
+
// normalize header values to strings/arrays of strings so nothing gets truncated/inspected oddly
|
|
84
|
+
const normalizedHeaders = Object.fromEntries(Object.entries(headers).map(([k, v]) => [
|
|
85
|
+
k,
|
|
86
|
+
Array.isArray(v) ? v.map((x) => (x === undefined || x === null ? '' : String(x))) : (v === undefined || v === null ? '' : String(v))
|
|
87
|
+
]));
|
|
88
|
+
// inspect options to avoid truncation
|
|
89
|
+
const inspectOptions = { depth: null, maxArrayLength: null, maxStringLength: null, breakLength: Infinity };
|
|
90
|
+
// print token again with full options (ensure no truncation)
|
|
91
|
+
console.log('FULL TOKEN (no truncate):', util.inspect(token, inspectOptions));
|
|
92
|
+
// also print a flattened, human-readable single-line representation
|
|
93
|
+
const flatHeaders = Object.entries(normalizedHeaders || {})
|
|
94
|
+
.map(([k, v]) => `${k}: ${Array.isArray(v) ? v.join(',') : v}`)
|
|
95
|
+
.join(' | ');
|
|
96
|
+
console.log('HEADERS FLAT:', flatHeaders);
|
|
97
|
+
// Decode WITHOUT verification (for debugging only)
|
|
98
|
+
// use require here to avoid changing top-level imports
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
100
|
+
const decodedPayload = jsonwebtoken_1.default.decode(token);
|
|
101
|
+
console.log('\n' +
|
|
102
|
+
'='.repeat(50) +
|
|
103
|
+
'\nš TOKEN INFORMATION:\n' +
|
|
104
|
+
util.inspect(decodedPayload, inspectOptions) +
|
|
105
|
+
'\n' +
|
|
106
|
+
'='.repeat(50));
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
console.warn('ā ļø Failed to decode token:', err);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
47
112
|
// For public APIs the body.captchaToken variable should be present and valid.
|
|
48
113
|
const availableServices = all_services_1.ALL_SERVICES;
|
|
49
114
|
const requestHeaders = request.headers;
|
|
@@ -78,7 +143,7 @@ class AuthMiddlewareService {
|
|
|
78
143
|
return this.throwErrorIfRequired(requestUrl, 'email-not-allowed', referrer, requestBody, requestHeaders, userSnapshot, false, 'The email you are using is not allowed to access this API. Please contact support.');
|
|
79
144
|
}
|
|
80
145
|
if (authVerificationResponse.verified) {
|
|
81
|
-
logger_1.LogExecutionContextHelper.setAuthProperties((
|
|
146
|
+
logger_1.LogExecutionContextHelper.setAuthProperties((_b = authVerificationResponse.email) !== null && _b !== void 0 ? _b : authVerificationResponse.userId, authType);
|
|
82
147
|
return true;
|
|
83
148
|
}
|
|
84
149
|
if (canUse === auth_interface_1.AuthEnforcementType.ENFORCED) {
|
|
@@ -81,7 +81,7 @@ class FirebaseAuthService {
|
|
|
81
81
|
return {
|
|
82
82
|
verified: isVerified,
|
|
83
83
|
userId: isVerified ? user.uid : undefined,
|
|
84
|
-
email: isVerified ? completeUser.email : undefined
|
|
84
|
+
email: isVerified ? completeUser.email : undefined,
|
|
85
85
|
};
|
|
86
86
|
});
|
|
87
87
|
}
|
|
@@ -90,7 +90,7 @@ class FirebaseAuthService {
|
|
|
90
90
|
if (this.TEST_STORE_IDS.includes(storeId)) {
|
|
91
91
|
return {
|
|
92
92
|
verified: true,
|
|
93
|
-
userId: storeId
|
|
93
|
+
userId: storeId,
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
const user = yield this.firebaseApp.auth().getUser(storeId);
|
|
@@ -103,7 +103,7 @@ class FirebaseAuthService {
|
|
|
103
103
|
const domain = email.split('@')[1];
|
|
104
104
|
return {
|
|
105
105
|
verified: domain === 'bikayi.com' || domain === 'bik.ai',
|
|
106
|
-
email: domain === 'bikayi.com' || domain === 'bik.ai' ? email : undefined
|
|
106
|
+
email: domain === 'bikayi.com' || domain === 'bik.ai' ? email : undefined,
|
|
107
107
|
};
|
|
108
108
|
});
|
|
109
109
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthEnforcementType, AuthMiddlewareParams, AuthService, AuthVerificationResponse, RequestHeaders } from './auth.interface';
|
|
2
2
|
import { AuthTypes } from '../../apis';
|
|
3
|
-
import { auth } from
|
|
3
|
+
import { auth } from 'firebase-admin';
|
|
4
4
|
import DecodedIdToken = auth.DecodedIdToken;
|
|
5
5
|
export declare class BikAdminAuthService implements AuthService {
|
|
6
6
|
getAuthType(): AuthTypes;
|
|
@@ -32,7 +32,8 @@ class BikAdminAuthService {
|
|
|
32
32
|
// Happens only for prod as custom claims logic doesn't work on staging.
|
|
33
33
|
// This is to check if spoofed login from dashboard has same store id in body and token.
|
|
34
34
|
let isStoreIdVerified = false;
|
|
35
|
-
if (core_1.isProd &&
|
|
35
|
+
if (core_1.isProd &&
|
|
36
|
+
['merchant-admin-react', 'manifest-frontend-merchant'].includes(requestHeaders.callerservicename)) {
|
|
36
37
|
isStoreIdVerified = yield firebaseAuthService.isLikelyBikAdmin(userSnapshot, storeId);
|
|
37
38
|
}
|
|
38
39
|
else {
|
package/lib/auth/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export * from './authMiddlewares';
|
|
|
2
2
|
export * from './secret-manager/secretManager.service';
|
|
3
3
|
export * from './secret-manager/secretManager.model';
|
|
4
4
|
export * from './secret-manager/secretManager.helper';
|
|
5
|
+
export * from './secret-manager/configManager.model';
|
|
6
|
+
export * from './secret-manager/configManager.service';
|
|
7
|
+
export * from './secret-manager/configManager.helper';
|
|
5
8
|
export * from './config';
|
|
6
9
|
export * from './secret-manager/env-variables/variables.list';
|
|
7
10
|
export * from './secret-manager/env-variables/env-variables.helper';
|
package/lib/auth/index.js
CHANGED
|
@@ -18,6 +18,9 @@ __exportStar(require("./authMiddlewares"), exports);
|
|
|
18
18
|
__exportStar(require("./secret-manager/secretManager.service"), exports);
|
|
19
19
|
__exportStar(require("./secret-manager/secretManager.model"), exports);
|
|
20
20
|
__exportStar(require("./secret-manager/secretManager.helper"), exports);
|
|
21
|
+
__exportStar(require("./secret-manager/configManager.model"), exports);
|
|
22
|
+
__exportStar(require("./secret-manager/configManager.service"), exports);
|
|
23
|
+
__exportStar(require("./secret-manager/configManager.helper"), exports);
|
|
21
24
|
__exportStar(require("./config"), exports);
|
|
22
25
|
__exportStar(require("./secret-manager/env-variables/variables.list"), exports);
|
|
23
26
|
__exportStar(require("./secret-manager/env-variables/env-variables.helper"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PodNameOrGlobal, SecretSchema } from './secretManager.model';
|
|
2
|
+
import { ConfigDocument, ConfigSection } from './configManager.model';
|
|
3
|
+
export declare class FirestoreConfigManager {
|
|
4
|
+
private static instance;
|
|
5
|
+
private db;
|
|
6
|
+
private secretsCollection;
|
|
7
|
+
private readonly envDocPrefix;
|
|
8
|
+
private readonly globalSecretsDocId;
|
|
9
|
+
private constructor();
|
|
10
|
+
static getInstance(): FirestoreConfigManager;
|
|
11
|
+
private getDocId;
|
|
12
|
+
private isDocFromSection;
|
|
13
|
+
private getPodNameFromDocId;
|
|
14
|
+
private toEmptySchema;
|
|
15
|
+
getConfig(section: ConfigSection, podName: PodNameOrGlobal): Promise<ConfigDocument>;
|
|
16
|
+
storeConfig(section: ConfigSection, podName: PodNameOrGlobal, schema: SecretSchema, updatedBy?: string): Promise<void>;
|
|
17
|
+
getAll(section: ConfigSection): Promise<Record<string, SecretSchema>>;
|
|
18
|
+
getAllConfigs(): Promise<{
|
|
19
|
+
envVariables: Record<string, SecretSchema>;
|
|
20
|
+
secrets: Record<string, SecretSchema>;
|
|
21
|
+
}>;
|
|
22
|
+
}
|