Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
node-telegram-gateway-api
Advanced tools
A Node.js package to interact with the Telegram Gateway API for sending verification messages and checking verification status.
A Node.js client for interacting with the Telegram Gateway API to manage phone verification messages easily. This library simplifies sending verification messages, checking their status, and revoking them.
Install the package using npm:
npm install telegram-gateway-api-client
First, you need to obtain your API key from the Telegram Gateway API account settings. This key will be used to authorize all requests.
import { TelegramGateway } from "telegram-gateway-api-client";
const apiKey = "YOUR_TELEGRAM_API_KEY";
const client = new TelegramGateway(apiKey);
Use sendVerificationMessage
to send a verification code to a specified phone number:
async function sendVerification() {
try {
const response = await client.sendVerificationMessage("+1234567890", {
sender_username: "YourApp",
code_length: 6,
});
if (response.ok) {
console.log("Message sent successfully:", response.result);
} else {
console.error("Error sending message:", response.error);
}
} catch (error) {
console.error("API request failed:", error);
}
}
Before sending a message, you can verify if it is possible to send a message to the given phone number:
async function checkSendAbility() {
try {
const response = await client.checkSendAbility("+1234567890");
if (response.ok) {
console.log("Able to send verification message:", response.result);
} else {
console.error("Cannot send message:", response.error);
}
} catch (error) {
console.error("API request failed:", error);
}
}
After sending a verification message, you can check its status:
async function checkVerificationStatus() {
try {
const response = await client.checkVerificationStatus(
"request_id_here",
"user_entered_code"
);
if (response.ok) {
console.log("Verification status:", response.result);
} else {
console.error("Error checking status:", response.error);
}
} catch (error) {
console.error("API request failed:", error);
}
}
If needed, you can revoke a verification message that was previously sent:
async function revokeMessage() {
try {
const response = await client.revokeVerificationMessage("request_id_here");
if (response.ok) {
console.log("Message revoked successfully");
} else {
console.error("Error revoking message:", response.error);
}
} catch (error) {
console.error("API request failed:", error);
}
}
For more detailed information about the Telegram Gateway API, visit the official documentation.
Feel free to submit issues or contribute to the project through pull requests. Contributions are welcome! 🙌
This project is licensed under the MIT License.
FAQs
A Node.js package to interact with the Telegram Gateway API for sending verification messages and checking verification status.
The npm package node-telegram-gateway-api receives a total of 1 weekly downloads. As such, node-telegram-gateway-api popularity was classified as not popular.
We found that node-telegram-gateway-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.