@solidxai/core 0.1.10-beta.15 → 0.1.10-beta.21
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/commands/test-data.command.d.ts +2 -0
- package/dist/commands/test-data.command.d.ts.map +1 -1
- package/dist/commands/test-data.command.js +32 -6
- package/dist/commands/test-data.command.js.map +1 -1
- package/dist/controllers/chatter-message.controller.d.ts +2 -0
- package/dist/controllers/chatter-message.controller.d.ts.map +1 -1
- package/dist/controllers/chatter-message.controller.js +17 -0
- package/dist/controllers/chatter-message.controller.js.map +1 -1
- package/dist/controllers/gupshup-webhook.controller.d.ts +11 -0
- package/dist/controllers/gupshup-webhook.controller.d.ts.map +1 -0
- package/dist/controllers/gupshup-webhook.controller.js +87 -0
- package/dist/controllers/gupshup-webhook.controller.js.map +1 -0
- package/dist/controllers/meta-cloud-whatsapp-webhook.controller.d.ts +16 -0
- package/dist/controllers/meta-cloud-whatsapp-webhook.controller.d.ts.map +1 -0
- package/dist/controllers/meta-cloud-whatsapp-webhook.controller.js +133 -0
- package/dist/controllers/meta-cloud-whatsapp-webhook.controller.js.map +1 -0
- package/dist/dtos/update-chatter-note-message.dto.d.ts +5 -0
- package/dist/dtos/update-chatter-note-message.dto.d.ts.map +1 -0
- package/dist/dtos/update-chatter-note-message.dto.js +34 -0
- package/dist/dtos/update-chatter-note-message.dto.js.map +1 -0
- package/dist/factories/whatsapp.factory.d.ts.map +1 -1
- package/dist/factories/whatsapp.factory.js +13 -11
- package/dist/factories/whatsapp.factory.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +1 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/listeners/user-registration.listener.d.ts +5 -2
- package/dist/listeners/user-registration.listener.d.ts.map +1 -1
- package/dist/listeners/user-registration.listener.js +37 -4
- package/dist/listeners/user-registration.listener.js.map +1 -1
- package/dist/seeders/module-test-data.service.d.ts +2 -0
- package/dist/seeders/module-test-data.service.d.ts.map +1 -1
- package/dist/seeders/module-test-data.service.js +61 -0
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +1 -0
- package/dist/services/authentication.service.d.ts +6 -1
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +144 -14
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/chatter-message.service.d.ts +7 -1
- package/dist/services/chatter-message.service.d.ts.map +1 -1
- package/dist/services/chatter-message.service.js +94 -2
- package/dist/services/chatter-message.service.js.map +1 -1
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.d.ts +1 -0
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.d.ts.map +1 -1
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.js +11 -0
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.js.map +1 -1
- package/dist/services/mediaStorageProviders/file-storage-provider.d.ts +1 -0
- package/dist/services/mediaStorageProviders/file-storage-provider.d.ts.map +1 -1
- package/dist/services/mediaStorageProviders/file-storage-provider.js +6 -0
- package/dist/services/mediaStorageProviders/file-storage-provider.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +174 -0
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +98 -0
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/services/user.service.js +1 -1
- package/dist/services/user.service.js.map +1 -1
- package/dist/services/whatsapp/GupshupOtpWhatsappService.d.ts +11 -0
- package/dist/services/whatsapp/GupshupOtpWhatsappService.d.ts.map +1 -0
- package/dist/services/whatsapp/GupshupOtpWhatsappService.js +127 -0
- package/dist/services/whatsapp/GupshupOtpWhatsappService.js.map +1 -0
- package/dist/services/whatsapp/MetaCloudWhatsappService.d.ts +17 -0
- package/dist/services/whatsapp/MetaCloudWhatsappService.d.ts.map +1 -0
- package/dist/services/whatsapp/MetaCloudWhatsappService.js +209 -0
- package/dist/services/whatsapp/MetaCloudWhatsappService.js.map +1 -0
- package/dist/solid-core.module.d.ts +2 -2
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +14 -6
- package/dist/solid-core.module.js.map +1 -1
- package/dist-tests/api/authenticate.spec.js +119 -0
- package/dist-tests/api/authenticate.spec.js.map +1 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +97 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +1 -0
- package/dist-tests/api/ping.spec.js +21 -0
- package/dist-tests/api/ping.spec.js.map +1 -0
- package/dist-tests/helpers/auth.js +41 -0
- package/dist-tests/helpers/auth.js.map +1 -0
- package/dist-tests/helpers/env.js +11 -0
- package/dist-tests/helpers/env.js.map +1 -0
- package/docs/grouping-enhancements.md +89 -0
- package/docs/java-spring/README.md +3 -0
- package/docs/java-spring/solid-core-module-deep-dive-report.md +1317 -0
- package/docs/seed-changes.md +65 -0
- package/docs/test-data-workflow.md +200 -0
- package/docs/type-declaration-import-issue.md +24 -0
- package/package.json +1 -1
- package/src/commands/test-data.command.ts +29 -6
- package/src/controllers/chatter-message.controller.ts +12 -0
- package/src/controllers/gupshup-webhook.controller.ts +91 -0
- package/src/controllers/meta-cloud-whatsapp-webhook.controller.ts +155 -0
- package/src/dtos/update-chatter-note-message.dto.ts +14 -0
- package/src/factories/whatsapp.factory.ts +33 -32
- package/src/helpers/field-crud-managers/field-quality-check-fixes.md +178 -0
- package/src/index.ts +2 -0
- package/src/interfaces.ts +1 -1
- package/src/listeners/user-registration.listener.ts +49 -6
- package/src/seeders/module-test-data.service.ts +79 -2
- package/src/seeders/seed-data/solid-core-metadata.json +1 -0
- package/src/services/authentication.service.ts +281 -46
- package/src/services/chatter-message.service.ts +112 -2
- package/src/services/mediaStorageProviders/file-s3-storage-provider.ts +12 -0
- package/src/services/mediaStorageProviders/file-storage-provider.ts +8 -1
- package/src/services/settings/default-settings-provider.service.ts +98 -0
- package/src/services/user.service.ts +1 -1
- package/src/services/whatsapp/GupshupOtpWhatsappService.ts +174 -0
- package/src/services/whatsapp/MetaCloudWhatsappService.ts +253 -0
- package/src/solid-core.module.ts +205 -196
- package/src/testing/README.md +15 -0
- package/.claude/settings.local.json +0 -15
- package/CLAUDE.md +0 -18
- package/CURRENT_PROMPT +0 -6
- package/src/services/1.js +0 -6
|
@@ -38,6 +38,7 @@ const setting_service_1 = require("./setting.service");
|
|
|
38
38
|
const user_activity_history_service_1 = require("./user-activity-history.service");
|
|
39
39
|
const user_service_1 = require("./user.service");
|
|
40
40
|
const sms_factory_1 = require("../factories/sms.factory");
|
|
41
|
+
const whatsapp_factory_1 = require("../factories/whatsapp.factory");
|
|
41
42
|
const solid_registry_1 = require("../helpers/solid-registry");
|
|
42
43
|
var LoginProvider;
|
|
43
44
|
(function (LoginProvider) {
|
|
@@ -46,7 +47,7 @@ var LoginProvider;
|
|
|
46
47
|
LoginProvider["OTP"] = "otp";
|
|
47
48
|
})(LoginProvider || (LoginProvider = {}));
|
|
48
49
|
let AuthenticationService = AuthenticationService_1 = class AuthenticationService {
|
|
49
|
-
constructor(userService, userRepository, hashingService, jwtService, refreshTokenIdsStorage, httpService, mailServiceFactory, smsFactory, eventEmitter, settingService, roleMetadataService, userActivityHistoryService, ssoCodeStorage, dataSource, solidRegistry) {
|
|
50
|
+
constructor(userService, userRepository, hashingService, jwtService, refreshTokenIdsStorage, httpService, mailServiceFactory, smsFactory, whatsAppFactory, eventEmitter, settingService, roleMetadataService, userActivityHistoryService, ssoCodeStorage, dataSource, solidRegistry) {
|
|
50
51
|
this.userService = userService;
|
|
51
52
|
this.userRepository = userRepository;
|
|
52
53
|
this.hashingService = hashingService;
|
|
@@ -55,6 +56,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
55
56
|
this.httpService = httpService;
|
|
56
57
|
this.mailServiceFactory = mailServiceFactory;
|
|
57
58
|
this.smsFactory = smsFactory;
|
|
59
|
+
this.whatsAppFactory = whatsAppFactory;
|
|
58
60
|
this.eventEmitter = eventEmitter;
|
|
59
61
|
this.settingService = settingService;
|
|
60
62
|
this.roleMetadataService = roleMetadataService;
|
|
@@ -135,10 +137,14 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
135
137
|
}
|
|
136
138
|
const savedUser = await repo.save(user);
|
|
137
139
|
const userRoles = signUpDto.roles ?? [];
|
|
138
|
-
if ((signUpDto.roles?.length ?? 0) === 0 &&
|
|
140
|
+
if ((signUpDto.roles?.length ?? 0) === 0 &&
|
|
141
|
+
signUpDto.username !== "sa" &&
|
|
142
|
+
defaultRole) {
|
|
139
143
|
userRoles.push(defaultRole);
|
|
140
144
|
}
|
|
141
145
|
await this.handlePostSignup(savedUser, userRoles, pwd, autoGeneratedPwd);
|
|
146
|
+
await this.handlePasswordlessSignupOtp(savedUser, signUpDto, autoGeneratedPwd, repo);
|
|
147
|
+
this.triggerRegistrationEvent(savedUser);
|
|
142
148
|
return savedUser;
|
|
143
149
|
}
|
|
144
150
|
catch (err) {
|
|
@@ -149,6 +155,24 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
149
155
|
throw err;
|
|
150
156
|
}
|
|
151
157
|
}
|
|
158
|
+
async handlePasswordlessSignupOtp(user, signUpDto, autoGeneratedPwd, repo) {
|
|
159
|
+
const isPasswordProvided = !!signUpDto.password;
|
|
160
|
+
const isAutoGeneratedPassword = !!autoGeneratedPwd;
|
|
161
|
+
if (isPasswordProvided || isAutoGeneratedPassword) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (!user.mobile) {
|
|
165
|
+
this.logger.warn(`Skipping passwordless signup OTP WhatsApp notification for user ${user.username}: mobile is missing.`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const isPasswordlessRegistrationEnabled = await this.isPasswordlessRegistrationEnabled();
|
|
169
|
+
if (!isPasswordlessRegistrationEnabled) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
await this.assignRegistrationOtp(constants_1.PasswordlessRegistrationValidateWhatSources.MOBILE, user);
|
|
173
|
+
await repo.save(user);
|
|
174
|
+
await this.notifyUserOnOtpInitiateRegistration(user, constants_1.PasswordlessRegistrationValidateWhatSources.MOBILE);
|
|
175
|
+
}
|
|
152
176
|
async signupForExtensionUser(signUpDto, extensionUserDto, extensionUserRepo) {
|
|
153
177
|
const entity = extensionUserRepo.create(extensionUserDto);
|
|
154
178
|
return this.performSignUp(signUpDto, entity, extensionUserRepo);
|
|
@@ -358,7 +382,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
358
382
|
async notifyUserOnOtpInitiateRegistration(user, registrationValidationSource) {
|
|
359
383
|
const companyLogo = await this.getCompanyLogo();
|
|
360
384
|
if (registrationValidationSource ===
|
|
361
|
-
constants_1.
|
|
385
|
+
constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL) {
|
|
362
386
|
const mailService = this.mailServiceFactory.getMailService();
|
|
363
387
|
mailService.sendEmailUsingTemplate(user.email, "otp-on-register", {
|
|
364
388
|
solidAppName: this.settingService.getConfigValue("appTitle"),
|
|
@@ -370,18 +394,85 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
370
394
|
}, this.settingService.getConfigValue("shouldQueueEmails"), null, null, "user", user.id);
|
|
371
395
|
}
|
|
372
396
|
if (registrationValidationSource ===
|
|
373
|
-
constants_1.
|
|
374
|
-
const
|
|
375
|
-
smsService.sendSMSUsingTemplate(user.mobile, "otp-on-register", {
|
|
397
|
+
constants_1.PasswordlessRegistrationValidateWhatSources.MOBILE) {
|
|
398
|
+
const templateParams = {
|
|
376
399
|
solidAppName: this.settingService.getConfigValue("appTitle"),
|
|
377
400
|
otp: user.mobileVerificationTokenOnRegistration,
|
|
378
401
|
mobileVerificationTokenOnRegistration: user.mobileVerificationTokenOnRegistration,
|
|
379
402
|
firstName: user.username,
|
|
380
403
|
fullName: user.fullName ? user.fullName : user.username,
|
|
381
404
|
companyLogoUrl: companyLogo,
|
|
382
|
-
}
|
|
405
|
+
};
|
|
406
|
+
const whatsappDestination = this.normalizeWhatsAppDestination(user.mobile);
|
|
407
|
+
const gupshupTemplateAppName = process.env.COMMON_GUPSHUP_APP_NAME || "Gupshup";
|
|
408
|
+
const whatsappTemplateId = this.settingService.getConfigValue("otpWhatsappTemplateId") || "common_otp";
|
|
409
|
+
const whatsappIndependentEnabled = this.settingService.getConfigValue("otpWhatsappIndependentEnabled") !== false;
|
|
410
|
+
let smsSent = false;
|
|
411
|
+
let whatsappSent = false;
|
|
412
|
+
let smsErrorMessage;
|
|
413
|
+
let whatsappErrorMessage;
|
|
414
|
+
this.logger.debug(`OTP SMS send attempt: destination=${user.mobile}, whatsappDestination=${whatsappDestination}`);
|
|
415
|
+
try {
|
|
416
|
+
const smsService = this.smsFactory.getSmsService();
|
|
417
|
+
await smsService.sendSMSUsingTemplate(user.mobile, "otp-on-register", templateParams, false);
|
|
418
|
+
smsSent = true;
|
|
419
|
+
}
|
|
420
|
+
catch (smsError) {
|
|
421
|
+
smsErrorMessage = smsError?.message;
|
|
422
|
+
this.logger.warn(`OTP SMS failed: destination=${user.mobile}, message=${smsErrorMessage}`);
|
|
423
|
+
}
|
|
424
|
+
if (whatsappIndependentEnabled) {
|
|
425
|
+
if (!whatsappDestination) {
|
|
426
|
+
whatsappErrorMessage = "Normalized WhatsApp destination is empty";
|
|
427
|
+
this.logger.error(`Independent OTP WhatsApp skipped: destination=${user.mobile}, message=${whatsappErrorMessage}`);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
this.logger.debug(`Independent OTP WhatsApp send attempt: destination=${user.mobile}, whatsappDestination=${whatsappDestination}, templateId=${whatsappTemplateId}`);
|
|
431
|
+
try {
|
|
432
|
+
await this.sendOtpToWhatsappProvider(whatsappDestination, String(whatsappTemplateId), String(gupshupTemplateAppName), String(templateParams.otp || ""));
|
|
433
|
+
whatsappSent = true;
|
|
434
|
+
this.logger.log(`Independent OTP WhatsApp success: destination=${user.mobile}, whatsappDestination=${whatsappDestination}, templateId=${whatsappTemplateId}`);
|
|
435
|
+
}
|
|
436
|
+
catch (waError) {
|
|
437
|
+
whatsappErrorMessage = waError?.message;
|
|
438
|
+
this.logger.error(`Independent OTP WhatsApp failed: destination=${user.mobile}, whatsappDestination=${whatsappDestination}, templateId=${whatsappTemplateId}, message=${whatsappErrorMessage}`);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (!smsSent && !whatsappSent) {
|
|
443
|
+
throw new Error(`OTP delivery failed on both channels. smsError=${smsErrorMessage || "unknown"}, whatsappError=${whatsappErrorMessage || "disabled/unknown"}`);
|
|
444
|
+
}
|
|
383
445
|
}
|
|
384
446
|
}
|
|
447
|
+
normalizeWhatsAppDestination(rawMobile) {
|
|
448
|
+
const raw = (rawMobile || "").trim();
|
|
449
|
+
let sanitized = raw.replace(/[^\d+]/g, "");
|
|
450
|
+
if (sanitized.startsWith("00")) {
|
|
451
|
+
sanitized = `+${sanitized.slice(2)}`;
|
|
452
|
+
}
|
|
453
|
+
const defaultDialCode = String(this.settingService.getConfigValue("otpDefaultCountryDialCode") || "").replace(/\D/g, "");
|
|
454
|
+
if (sanitized.startsWith("+")) {
|
|
455
|
+
const e164Digits = sanitized.slice(1).replace(/\D/g, "");
|
|
456
|
+
if (e164Digits.length >= 8 && e164Digits.length <= 15) {
|
|
457
|
+
return e164Digits;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
const digits = sanitized.replace(/\D/g, "");
|
|
461
|
+
if (digits.length >= 11 && digits.length <= 15) {
|
|
462
|
+
return digits;
|
|
463
|
+
}
|
|
464
|
+
if (digits.length === 10 && defaultDialCode) {
|
|
465
|
+
return `${defaultDialCode}${digits}`;
|
|
466
|
+
}
|
|
467
|
+
return digits;
|
|
468
|
+
}
|
|
469
|
+
async sendOtpToWhatsappProvider(destination, templateId, appName, otp) {
|
|
470
|
+
const whatsappService = this.whatsAppFactory.getWhatsappService();
|
|
471
|
+
await whatsappService.sendWhatsAppMessage(destination, null, {
|
|
472
|
+
type: "text",
|
|
473
|
+
text: `${appName} OTP is ${otp}. It is valid for 10 mins.`,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
385
476
|
async otpConfirmRegistration(confirmSignUpDto) {
|
|
386
477
|
const isPasswordlessRegistrationEnabled = await this.isPasswordlessRegistrationEnabled();
|
|
387
478
|
if (!isPasswordlessRegistrationEnabled) {
|
|
@@ -449,13 +540,13 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
449
540
|
async areAllPasswordlessRegistrationValidationSourcesVerified(user) {
|
|
450
541
|
const registrationValidationSource = this.resolvePasswordlessValidationSource();
|
|
451
542
|
if (registrationValidationSource ===
|
|
452
|
-
constants_1.
|
|
543
|
+
constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL) {
|
|
453
544
|
if (!user.emailVerifiedOnRegistrationAt) {
|
|
454
545
|
return false;
|
|
455
546
|
}
|
|
456
547
|
}
|
|
457
548
|
if (registrationValidationSource ===
|
|
458
|
-
constants_1.
|
|
549
|
+
constants_1.PasswordlessRegistrationValidateWhatSources.MOBILE) {
|
|
459
550
|
if (!user.mobileVerifiedOnRegistrationAt) {
|
|
460
551
|
return false;
|
|
461
552
|
}
|
|
@@ -548,7 +639,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
548
639
|
const dummyOtp = this.getDummyOtpForUser(user);
|
|
549
640
|
if (!dummyOtp) {
|
|
550
641
|
await this.assignLoginOtp(user, type);
|
|
551
|
-
this.notifyUserOnOtpInititateLogin(user, type);
|
|
642
|
+
await this.notifyUserOnOtpInititateLogin(user, type);
|
|
552
643
|
}
|
|
553
644
|
return this.buildLoginOtpResponse(user, type);
|
|
554
645
|
}
|
|
@@ -628,15 +719,53 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
628
719
|
}, this.settingService.getConfigValue("shouldQueueEmails"), null, null, "user", user.id);
|
|
629
720
|
}
|
|
630
721
|
if (loginType === constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
|
|
631
|
-
const
|
|
632
|
-
smsService.sendSMSUsingTemplate(user.mobile, "otp-on-login", {
|
|
722
|
+
const templateParams = {
|
|
633
723
|
solidAppName: this.settingService.getConfigValue("appTitle"),
|
|
634
724
|
otp: user.mobileVerificationTokenOnLogin,
|
|
635
725
|
mobileVerificationTokenOnLogin: user.mobileVerificationTokenOnLogin,
|
|
636
726
|
firstName: user.username,
|
|
637
727
|
fullName: user.fullName ? user.fullName : user.username,
|
|
638
728
|
companyLogoUrl: companyLogo,
|
|
639
|
-
}
|
|
729
|
+
};
|
|
730
|
+
const whatsappDestination = this.normalizeWhatsAppDestination(user.mobile);
|
|
731
|
+
const gupshupTemplateAppName = process.env.COMMON_GUPSHUP_APP_NAME || "Gupshup";
|
|
732
|
+
const whatsappTemplateId = this.settingService.getConfigValue("otpWhatsappTemplateId") || "common_otp";
|
|
733
|
+
const whatsappIndependentEnabled = this.settingService.getConfigValue("otpWhatsappIndependentEnabled") !== false;
|
|
734
|
+
let smsSent = false;
|
|
735
|
+
let whatsappSent = false;
|
|
736
|
+
let smsErrorMessage;
|
|
737
|
+
let whatsappErrorMessage;
|
|
738
|
+
this.logger.debug(`OTP LOGIN SMS send attempt: destination=${user.mobile}, whatsappDestination=${whatsappDestination}`);
|
|
739
|
+
try {
|
|
740
|
+
const smsService = this.smsFactory.getSmsService();
|
|
741
|
+
await smsService.sendSMSUsingTemplate(user.mobile, "otp-on-login", templateParams, false);
|
|
742
|
+
smsSent = true;
|
|
743
|
+
}
|
|
744
|
+
catch (smsError) {
|
|
745
|
+
smsErrorMessage = smsError?.message;
|
|
746
|
+
this.logger.warn(`OTP LOGIN SMS failed: destination=${user.mobile}, message=${smsErrorMessage}`);
|
|
747
|
+
}
|
|
748
|
+
if (whatsappIndependentEnabled) {
|
|
749
|
+
if (!whatsappDestination) {
|
|
750
|
+
whatsappErrorMessage = "Normalized WhatsApp destination is empty";
|
|
751
|
+
this.logger.error(`OTP LOGIN WhatsApp skipped: destination=${user.mobile}, message=${whatsappErrorMessage}`);
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
this.logger.debug(`OTP LOGIN WhatsApp send attempt: destination=${user.mobile}, whatsappDestination=${whatsappDestination}, templateId=${whatsappTemplateId}`);
|
|
755
|
+
try {
|
|
756
|
+
await this.sendOtpToWhatsappProvider(whatsappDestination, String(whatsappTemplateId), String(gupshupTemplateAppName), String(templateParams.otp || ""));
|
|
757
|
+
whatsappSent = true;
|
|
758
|
+
this.logger.log(`OTP LOGIN WhatsApp success: destination=${user.mobile}, whatsappDestination=${whatsappDestination}, templateId=${whatsappTemplateId}`);
|
|
759
|
+
}
|
|
760
|
+
catch (waError) {
|
|
761
|
+
whatsappErrorMessage = waError?.message;
|
|
762
|
+
this.logger.error(`OTP LOGIN WhatsApp failed: destination=${user.mobile}, whatsappDestination=${whatsappDestination}, templateId=${whatsappTemplateId}, message=${whatsappErrorMessage}`);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (!smsSent && !whatsappSent) {
|
|
767
|
+
throw new Error(`OTP LOGIN delivery failed on both channels. smsError=${smsErrorMessage || "unknown"}, whatsappError=${whatsappErrorMessage || "disabled/unknown"}`);
|
|
768
|
+
}
|
|
640
769
|
}
|
|
641
770
|
}
|
|
642
771
|
async otpConfirmLogin(confirmSignInDto) {
|
|
@@ -1267,7 +1396,7 @@ AuthenticationService.SIGNUP_DTO_KEYS = new Set([
|
|
|
1267
1396
|
]);
|
|
1268
1397
|
exports.AuthenticationService = AuthenticationService = AuthenticationService_1 = __decorate([
|
|
1269
1398
|
(0, common_1.Injectable)(),
|
|
1270
|
-
__param(
|
|
1399
|
+
__param(14, (0, typeorm_1.InjectDataSource)()),
|
|
1271
1400
|
__metadata("design:paramtypes", [user_service_1.UserService,
|
|
1272
1401
|
user_repository_1.UserRepository,
|
|
1273
1402
|
hashing_service_1.HashingService,
|
|
@@ -1276,6 +1405,7 @@ exports.AuthenticationService = AuthenticationService = AuthenticationService_1
|
|
|
1276
1405
|
axios_1.HttpService,
|
|
1277
1406
|
mail_factory_1.MailFactory,
|
|
1278
1407
|
sms_factory_1.SmsFactory,
|
|
1408
|
+
whatsapp_factory_1.WhatsAppFactory,
|
|
1279
1409
|
event_emitter_1.EventEmitter2,
|
|
1280
1410
|
setting_service_1.SettingService,
|
|
1281
1411
|
role_metadata_service_1.RoleMetadataService,
|