Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tdl-tdlib-wasm

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tdl-tdlib-wasm

WebAssembly bindings for TDLib.

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm

An experimental wrapper. Tested with TDLib v1.3.0.

Installation

$ npm i tdl tdl-tdlib-wasm

Usage

import { Client } from 'tdl'
import { TDLib } from 'tdl-tdlib-wasm'

function createClient (options) {
  return new Promise(resolve => {
    Module().then(module => {
      const tdlib = new TDLib(module)
      resolve(new Client(tdlib, options))
    })
  })
}

// for testing
localStorage.debug = 'tdl:client'

async function main () {
  const client = await createClient({
    apiId: 2222, // Your api_id
    apiHash: 'YOUR_API_HASH', // Your api_hash
    useDefaultVerbosityLevel: true
  })

  console.log(client)

  await client.connectAndLogin(() => ({
    getPhoneNumber: retry => Promise.resolve(window.prompt(retry
      ? 'Invalid phone number, please re-enter:'
      : 'Please enter phone number:')),
    getAuthCode: retry => Promise.resolve(window.prompt(retry
      ? 'Wrong auth code, please re-enter:'
      : 'Please enter auth code:')),
    getPassword: (passwordHint, retry) => Promise.resolve(window.prompt(retry
      ? 'Wrong password, please re-enter:'
      : `Please enter password (${passwordHint}):`)),
    getName: () => {
      throw new Error('not supported')
    }
  }))

  const result = await client.invoke({
    _: 'getChats',
    offset_order: '9223372036854775807',
    offset_chat_id: 0,
    limit: 100
  })

  // latest 100 chats will be returned
  console.log('RESULT', result)
}

main()

Keywords

FAQs

Package last updated on 14 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc