Send verification SMS on the service line so carriers deliver the code.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
88f6a430d9
commit
0f80de1f05
@@ -35,5 +35,7 @@ MEDIA_MAX_FILE_SIZE_MB=10
|
||||
MESHKEE_SMS_URL=https://api.meshkee.com/api/v1/public/sms/send
|
||||
MESHKEE_SMS_API_KEY=
|
||||
MESHKEE_SMS_DOMAIN=manacollections.ir
|
||||
# Service line. Omit and the gateway uses the advertising shortcode, which does not deliver OTP.
|
||||
MESHKEE_SMS_SOURCE=5000110005
|
||||
# Comma-separated admin mobiles for alerts
|
||||
SMS_NOTIFY_MOBILES=
|
||||
|
||||
+5
-1
@@ -24,6 +24,10 @@ async function main() {
|
||||
'https://api.meshkee.com/api/v1/public/sms/send';
|
||||
const apiKey = process.env.MESHKEE_SMS_API_KEY;
|
||||
const domain = process.env.MESHKEE_SMS_DOMAIN ?? 'manacollections.ir';
|
||||
const source =
|
||||
process.argv.includes('--source')
|
||||
? arg('source')
|
||||
: (process.env.MESHKEE_SMS_SOURCE ?? '5000110005');
|
||||
|
||||
if (!apiKey) throw new Error('MESHKEE_SMS_API_KEY is not set in .env');
|
||||
if (!/^09\d{9}$/.test(to)) throw new Error('to must match 09xxxxxxxxx');
|
||||
@@ -35,7 +39,7 @@ async function main() {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Api-Key': apiKey,
|
||||
},
|
||||
body: JSON.stringify({ domain, to, message }),
|
||||
body: JSON.stringify({ domain, to, message, source }),
|
||||
});
|
||||
|
||||
const body = await response.json().catch(() => null);
|
||||
|
||||
@@ -379,6 +379,7 @@ export class AuthService {
|
||||
await this.sms.send({
|
||||
to: input.cellNumber,
|
||||
message: input.message(code),
|
||||
source: this.sms.otpSource(),
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -20,6 +20,14 @@ export class SmsService {
|
||||
this.domain = this.config.getOrThrow<string>('MESHKEE_SMS_DOMAIN');
|
||||
}
|
||||
|
||||
/**
|
||||
* Service shortcode (خط خدماتی). The partner gateway otherwise sends from
|
||||
* the advertising line, which operators drop for verification texts.
|
||||
*/
|
||||
otpSource(): string {
|
||||
return this.config.get<string>('MESHKEE_SMS_SOURCE')?.trim() || '5000110005';
|
||||
}
|
||||
|
||||
notifyMobiles(): string[] {
|
||||
const raw = this.config.get<string>('SMS_NOTIFY_MOBILES', '');
|
||||
return raw
|
||||
@@ -69,6 +77,7 @@ export class SmsService {
|
||||
domain: this.domain,
|
||||
to,
|
||||
message,
|
||||
...(input.source ? { source: input.source } : {}),
|
||||
}),
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export type SendSmsInput = {
|
||||
to: string;
|
||||
message: string;
|
||||
/** Gama shortcode. OTP must use the service line; the partner default is advertising. */
|
||||
source?: string;
|
||||
};
|
||||
|
||||
export type SendSmsResult = {
|
||||
|
||||
Reference in New Issue
Block a user