@@ -26,14 +26,13 @@ export class AccountRepository extends Repository {
2626 if ( ! this . client . state . passwordEncryptionPubKey ) {
2727 await this . client . qe . syncLoginExperiments ( ) ;
2828 }
29- const { encrypted, time} = this . encryptPassword ( password ) ;
29+ const { encrypted, time } = this . encryptPassword ( password ) ;
3030 const response = await Bluebird . try ( ( ) =>
3131 this . client . request . send < AccountRepositoryLoginResponseRootObject > ( {
3232 method : 'POST' ,
3333 url : '/api/v1/accounts/login/' ,
3434 form : this . client . request . sign ( {
3535 username,
36- password,
3736 enc_password : `#PWD_INSTAGRAM:4:${ time } :${ encrypted } ` ,
3837 guid : this . client . state . uuid ,
3938 phone_id : this . client . state . phoneId ,
@@ -77,14 +76,17 @@ export class AccountRepository extends Repository {
7776 return `2${ sum } ` ;
7877 }
7978
80- public encryptPassword ( password : string ) : { time : string , encrypted : string } {
79+ public encryptPassword ( password : string ) : { time : string ; encrypted : string } {
8180 const randKey = crypto . randomBytes ( 32 ) ;
8281 const iv = crypto . randomBytes ( 12 ) ;
83- const rsaEncrypted = crypto . publicEncrypt ( {
84- key : Buffer . from ( this . client . state . passwordEncryptionPubKey , 'base64' ) . toString ( ) ,
85- // @ts -ignore
86- padding : crypto . constants . RSA_PKCS1_PADDING ,
87- } , randKey ) ;
82+ const rsaEncrypted = crypto . publicEncrypt (
83+ {
84+ key : Buffer . from ( this . client . state . passwordEncryptionPubKey , 'base64' ) . toString ( ) ,
85+ // @ts -ignore
86+ padding : crypto . constants . RSA_PKCS1_PADDING ,
87+ } ,
88+ randKey ,
89+ ) ;
8890 const cipher = crypto . createCipheriv ( 'aes-256-gcm' , randKey , iv ) ;
8991 const time = Math . floor ( Date . now ( ) / 1000 ) . toString ( ) ;
9092 cipher . setAAD ( Buffer . from ( time ) ) ;
@@ -98,8 +100,10 @@ export class AccountRepository extends Repository {
98100 Buffer . from ( [ 1 , this . client . state . passwordEncryptionKeyId ] ) ,
99101 iv ,
100102 sizeBuffer ,
101- rsaEncrypted , authTag , aesEncrypted ] )
102- . toString ( 'base64' ) ,
103+ rsaEncrypted ,
104+ authTag ,
105+ aesEncrypted ,
106+ ] ) . toString ( 'base64' ) ,
103107 } ;
104108 }
105109
0 commit comments