mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: registration + add captcha support (#227)
* fix: registration + update mobile version * feat: add captcha support for registration * fix: jid protocol address missing device * fix: linting errors
This commit is contained in:
@@ -86,7 +86,11 @@ export interface RegistrationOptions {
|
||||
/**
|
||||
* How to send the one time code
|
||||
*/
|
||||
method?: 'sms' | 'voice'
|
||||
method?: 'sms' | 'voice' | 'captcha'
|
||||
/**
|
||||
* The captcha code if it was requested
|
||||
*/
|
||||
captcha?: string
|
||||
}
|
||||
|
||||
export type RegistrationParams = RegistrationData & RegistrationOptions
|
||||
@@ -136,6 +140,7 @@ export function registrationParams(params: RegistrationParams) {
|
||||
id: convertBufferToUrlHex(params.identityId),
|
||||
backup_token: convertBufferToUrlHex(params.backupToken),
|
||||
token: md5(Buffer.concat([MOBILE_TOKEN, Buffer.from(params.phoneNumberNationalNumber)])).toString('hex'),
|
||||
fraud_checkpoint_code: params.captcha,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,13 +201,11 @@ export async function mobileRegisterFetch(path: string, opts: AxiosRequestConfig
|
||||
const parameter = [] as string[]
|
||||
|
||||
for(const param in opts.params) {
|
||||
parameter.push(param + '=' + urlencode(opts.params[param]))
|
||||
if(opts.params[param] !== null && opts.params[param] !== undefined) {
|
||||
parameter.push(param + '=' + urlencode(opts.params[param]))
|
||||
}
|
||||
}
|
||||
|
||||
console.log('parameter', opts.params, parameter)
|
||||
|
||||
// const params = urlencode(mobileRegisterEncrypt(parameter.join('&')))
|
||||
// url += `?ENC=${params}`
|
||||
url += `?${parameter.join('&')}`
|
||||
delete opts.params
|
||||
}
|
||||
@@ -230,16 +233,18 @@ export async function mobileRegisterFetch(path: string, opts: AxiosRequestConfig
|
||||
|
||||
|
||||
export interface ExistsResponse {
|
||||
status: 'fail'
|
||||
status: 'fail' | 'sent'
|
||||
voice_length?: number
|
||||
voice_wait?: number
|
||||
sms_length?: number
|
||||
sms_wait?: number
|
||||
reason?: 'incorrect' | 'missing_param'
|
||||
reason?: 'incorrect' | 'missing_param' | 'code_checkpoint'
|
||||
login?: string
|
||||
flash_type?: number
|
||||
ab_hash?: string
|
||||
ab_key?: string
|
||||
exp_cfg?: string
|
||||
lid?: string
|
||||
image_blob?: string
|
||||
audio_blob?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user