fix(core): string session

closes #17
This commit is contained in:
alina 🌸 2024-02-22 16:30:17 +03:00
parent 10ccfae496
commit 8f0e072f4a
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
2 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,16 @@
import { describe, expect, it } from 'vitest'
import { StubTelegramClient } from '@mtcute/test'
describe('BaseTelegramClient', () => {
describe('string sessions', () => {
it('should export session', async () => {
const client = new StubTelegramClient()
const session = await client.exportSession()
expect(session).toMatchInlineSnapshot(
'"AwQAAAAXAQIADjE0OS4xNTQuMTY3LjUwALsBAAAXAQICDzE0OS4xNTQuMTY3LjIyMrsBAAD-AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"',
)
})
})
})

View file

@ -230,7 +230,7 @@ export class BaseTelegramClient implements ITelegramClient {
if (!authKey) throw new Error('Auth key is not ready yet') if (!authKey) throw new Error('Auth key is not ready yet')
return writeStringSession({ return writeStringSession({
version: 2, version: 3,
self: await this.storage.self.fetch(), self: await this.storage.self.fetch(),
testMode: Boolean(this.params.testMode), testMode: Boolean(this.params.testMode),
primaryDcs, primaryDcs,