1.0.5 • Published 9 months ago

tg-gateway v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Telegram Gateway API JS library

Wrapper library for using Telegram authorization Gateway API (https://core.telegram.org/gateway/api)

Installation

npm install tg-gateway

Usage and examples

import {TgGateway} from "tg-gateway"

Create instance

const gateway = new TgGateway(gateway_api_token)

To access client methods use "client" property

gateway.client

checkSendAbility

await gateway.client.checkSendAbility({
    phone_number: phone,
})

sendVerificationMessage

await gateway.client.sendVerificationMessage({
    phone_number: phone,
    code_length: 4
})

checkVerificationStatus

await gateway.client.checkVerificationStatus({
    request_id: verificationMessageResponse.request_id
})

revokeVerificationMessage

await gateway.client.revokeVerificationMessage({
    request_id: verificationMessageResponse.request_id
})

Integrity check

Library allows to check the integrity of received reports

More info at https://core.telegram.org/gateway/api#report-delivery

To do so, use it like this

gateway.integrity.check(timestamp, signature, body)

true will be returned if integrity check is ok

Testing

Create .tests.json in the root directory, it's content should be:

{
  "token": "your_token",
  "phone": "your_phone"
}

then run

npm run test

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago