@mtproto/core
Advanced tools
Comparing version 3.0.0-beta.6 to 3.0.0-beta.7
{ | ||
"name": "@mtproto/core", | ||
"version": "3.0.0-beta.6", | ||
"version": "3.0.0-beta.7", | ||
"description": "Telegram API (MTProto) client library for browser and nodejs", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -112,22 +112,4 @@ # @mtproto/core | ||
Example: | ||
```js | ||
mtproto | ||
.call('auth.sendCode', { | ||
phone_number: '+9996621111', | ||
settings: { | ||
_: 'codeSettings', | ||
}, | ||
}) | ||
.catch(error => { | ||
if (error.error_message.includes('_MIGRATE_')) { | ||
const [item, dcId] = error.error_message.split('_MIGRATE_'); | ||
See the example in the [authentication](docs/authentication.md). | ||
mtproto.setDefaultDc(+dcId); | ||
// Repeat call this | ||
} | ||
}); | ||
``` | ||
### `getSRPParams({ g, p, salt1, salt2, gB, password }) => { A, M1 }` | ||
@@ -134,0 +116,0 @@ |
@@ -15,2 +15,4 @@ const { Socket } = require('net'); | ||
this.stream = new Uint8Array(); | ||
this.connect(); | ||
@@ -34,5 +36,23 @@ } | ||
const payload = this.getIntermediatePayload(deobfuscatedBytes); | ||
this.stream = new Uint8Array([...this.stream, ...deobfuscatedBytes]); | ||
this.emit('message', payload.buffer); | ||
const dataView = new DataView(this.stream.buffer); | ||
const payloadLength = dataView.getUint32(0, true); | ||
if (payloadLength === this.stream.length - 4) { | ||
const payload = this.stream.slice(4); | ||
if (payloadLength === 4) { | ||
const code = dataView.getInt32(4, true) * -1; | ||
this.emit('error', { | ||
type: 'transport', | ||
code, | ||
}); | ||
} else { | ||
this.emit('message', payload.buffer); | ||
} | ||
this.stream = new Uint8Array(); | ||
} | ||
} | ||
@@ -39,0 +59,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
582542
24117
128