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

tdlib-native

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tdlib-native - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

0

dist/addon.d.ts
export * from "./addon/index";
export { TDLibAddon as default } from "./addon/index";

@@ -0,0 +0,0 @@ import type { TDLib, TDLibClient } from "../shared/client";

export { TDLibAddon } from "./addon";

@@ -0,0 +0,0 @@ /**

25

dist/client.js

@@ -68,6 +68,6 @@ "use strict";

*
* @template {keyof $MethodsDict} T
* @template {keyof $AsyncApi} T
* @param {T} method
* @param {object} parameters
* @return {object} {Promise<ReturnType<$MethodsDict[T]>>}
* @return {object} {Promise<ReturnType<$AsyncApi[T]>>}
* @throws {TDError} - {@link TDError}

@@ -77,9 +77,12 @@ * @memberof Client

async invoke(method, parameters) {
const extra = Math.random();
assignTemporary(parameters, { _: method, "@extra": extra }, (merged) => {
this._adapter.send(this._client, json.serialize(merged));
const promise = new Promise((resolve, reject) => {
const extra = Math.random();
assignTemporary(parameters, { _: method, "@extra": extra }, (merged) => {
this._adapter.send(this._client, json.serialize(merged));
});
const data = new async.AsyncData();
this._requests.set(extra, data);
data.then(resolve, reject);
});
const result = new async.AsyncData();
this._requests.set(extra, result);
return result.catch((error) => {
return await promise.catch((error) => {
throw new TDError(error.message, { code: error.code, method, parameters });

@@ -91,3 +94,3 @@ });

*
* @template {keyof $SyncMethodsDict} T
* @template {keyof $SyncApi} T
* @param {TDLib|Client} executor

@@ -147,6 +150,6 @@ * @param {T} method

*
* @template {keyof $SyncMethodsDict} T
* @template {keyof $SyncApi} T
* @param {T} method
* @param {object} parameters
* @return {object} {Promise<ReturnType<$SyncMethodsDict[T]>>}
* @return {object} {Promise<ReturnType<$SyncApi[T]>>}
* @throws {TDError} - {@link TDError}

@@ -153,0 +156,0 @@ * @memberof Client

@@ -0,0 +0,0 @@ export type Subscription<T> = (value: T) => void;

@@ -0,0 +0,0 @@ export declare const Meta: {

export { Client, TDError } from "./client";
export { Client as default } from "./client";
export * as types from "./types";

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ type Resolve<T> = (value: T | PromiseLike<T>) => void;

@@ -0,0 +0,0 @@ export type TDLibClient = {

export * from "./generated/types";
import * as types from "./generated/types";
export default types;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types$1 = require("./generated/types.js");
exports.default = types$1;
const types = require("./generated/types.js");
exports.$Methods = types.$Methods;
exports.AuthenticationCodeType$Type = types.AuthenticationCodeType$Type;
exports.AuthorizationState$Type = types.AuthorizationState$Type;
exports.AutosaveSettingsScope$Type = types.AutosaveSettingsScope$Type;
exports.BackgroundFill$Type = types.BackgroundFill$Type;
exports.BackgroundType$Type = types.BackgroundType$Type;
exports.Bool$Type = types.Bool$Type;
exports.BotCommandScope$Type = types.BotCommandScope$Type;
exports.CallDiscardReason$Type = types.CallDiscardReason$Type;
exports.CallProblem$Type = types.CallProblem$Type;
exports.CallServerType$Type = types.CallServerType$Type;
exports.CallState$Type = types.CallState$Type;
exports.CallbackQueryPayload$Type = types.CallbackQueryPayload$Type;
exports.CanTransferOwnershipResult$Type = types.CanTransferOwnershipResult$Type;
exports.ChatAction$Type = types.ChatAction$Type;
exports.ChatActionBar$Type = types.ChatActionBar$Type;
exports.ChatAvailableReactions$Type = types.ChatAvailableReactions$Type;
exports.ChatEventAction$Type = types.ChatEventAction$Type;
exports.ChatList$Type = types.ChatList$Type;
exports.ChatMemberStatus$Type = types.ChatMemberStatus$Type;
exports.ChatMembersFilter$Type = types.ChatMembersFilter$Type;
exports.ChatPhotoStickerType$Type = types.ChatPhotoStickerType$Type;
exports.ChatReportReason$Type = types.ChatReportReason$Type;
exports.ChatSource$Type = types.ChatSource$Type;
exports.ChatStatistics$Type = types.ChatStatistics$Type;
exports.ChatType$Type = types.ChatType$Type;
exports.CheckChatUsernameResult$Type = types.CheckChatUsernameResult$Type;
exports.CheckStickerSetNameResult$Type = types.CheckStickerSetNameResult$Type;
exports.ConnectionState$Type = types.ConnectionState$Type;
exports.DeviceToken$Type = types.DeviceToken$Type;
exports.DiceStickers$Type = types.DiceStickers$Type;
exports.EmailAddressAuthentication$Type = types.EmailAddressAuthentication$Type;
exports.EmailAddressResetState$Type = types.EmailAddressResetState$Type;
exports.EmojiCategoryType$Type = types.EmojiCategoryType$Type;
exports.FileType$Type = types.FileType$Type;
exports.FirebaseAuthenticationSettings$Type =
types.FirebaseAuthenticationSettings$Type;
exports.GroupCallVideoQuality$Type = types.GroupCallVideoQuality$Type;
exports.InlineKeyboardButtonType$Type = types.InlineKeyboardButtonType$Type;
exports.InlineQueryResult$Type = types.InlineQueryResult$Type;
exports.InlineQueryResultsButtonType$Type = types.InlineQueryResultsButtonType$Type;
exports.InputBackground$Type = types.InputBackground$Type;
exports.InputChatPhoto$Type = types.InputChatPhoto$Type;
exports.InputCredentials$Type = types.InputCredentials$Type;
exports.InputFile$Type = types.InputFile$Type;
exports.InputInlineQueryResult$Type = types.InputInlineQueryResult$Type;
exports.InputInvoice$Type = types.InputInvoice$Type;
exports.InputMessageContent$Type = types.InputMessageContent$Type;
exports.InputPassportElement$Type = types.InputPassportElement$Type;
exports.InputPassportElementErrorSource$Type =
types.InputPassportElementErrorSource$Type;
exports.InternalLinkType$Type = types.InternalLinkType$Type;
exports.JsonValue$Type = types.JsonValue$Type;
exports.KeyboardButtonType$Type = types.KeyboardButtonType$Type;
exports.LanguagePackStringValue$Type = types.LanguagePackStringValue$Type;
exports.LogStream$Type = types.LogStream$Type;
exports.LoginUrlInfo$Type = types.LoginUrlInfo$Type;
exports.MaskPoint$Type = types.MaskPoint$Type;
exports.MessageContent$Type = types.MessageContent$Type;
exports.MessageExtendedMedia$Type = types.MessageExtendedMedia$Type;
exports.MessageFileType$Type = types.MessageFileType$Type;
exports.MessageForwardOrigin$Type = types.MessageForwardOrigin$Type;
exports.MessageSchedulingState$Type = types.MessageSchedulingState$Type;
exports.MessageSender$Type = types.MessageSender$Type;
exports.MessageSendingState$Type = types.MessageSendingState$Type;
exports.MessageSource$Type = types.MessageSource$Type;
exports.NetworkStatisticsEntry$Type = types.NetworkStatisticsEntry$Type;
exports.NetworkType$Type = types.NetworkType$Type;
exports.NotificationGroupType$Type = types.NotificationGroupType$Type;
exports.NotificationSettingsScope$Type = types.NotificationSettingsScope$Type;
exports.NotificationType$Type = types.NotificationType$Type;
exports.OptionValue$Type = types.OptionValue$Type;
exports.PageBlock$Type = types.PageBlock$Type;
exports.PageBlockHorizontalAlignment$Type = types.PageBlockHorizontalAlignment$Type;
exports.PageBlockVerticalAlignment$Type = types.PageBlockVerticalAlignment$Type;
exports.PassportElement$Type = types.PassportElement$Type;
exports.PassportElementErrorSource$Type = types.PassportElementErrorSource$Type;
exports.PassportElementType$Type = types.PassportElementType$Type;
exports.PaymentProvider$Type = types.PaymentProvider$Type;
exports.PollType$Type = types.PollType$Type;
exports.PremiumFeature$Type = types.PremiumFeature$Type;
exports.PremiumLimitType$Type = types.PremiumLimitType$Type;
exports.PremiumSource$Type = types.PremiumSource$Type;
exports.ProxyType$Type = types.ProxyType$Type;
exports.PublicChatType$Type = types.PublicChatType$Type;
exports.PushMessageContent$Type = types.PushMessageContent$Type;
exports.ReactionType$Type = types.ReactionType$Type;
exports.ReplyMarkup$Type = types.ReplyMarkup$Type;
exports.ResetPasswordResult$Type = types.ResetPasswordResult$Type;
exports.RichText$Type = types.RichText$Type;
exports.SearchMessagesFilter$Type = types.SearchMessagesFilter$Type;
exports.SecretChatState$Type = types.SecretChatState$Type;
exports.SessionType$Type = types.SessionType$Type;
exports.SpeechRecognitionResult$Type = types.SpeechRecognitionResult$Type;
exports.StatisticalGraph$Type = types.StatisticalGraph$Type;
exports.StickerFormat$Type = types.StickerFormat$Type;
exports.StickerFullType$Type = types.StickerFullType$Type;
exports.StickerType$Type = types.StickerType$Type;
exports.StorePaymentPurpose$Type = types.StorePaymentPurpose$Type;
exports.SuggestedAction$Type = types.SuggestedAction$Type;
exports.SupergroupMembersFilter$Type = types.SupergroupMembersFilter$Type;
exports.TMeUrlType$Type = types.TMeUrlType$Type;
exports.TargetChat$Type = types.TargetChat$Type;
exports.TextEntityType$Type = types.TextEntityType$Type;
exports.TextParseMode$Type = types.TextParseMode$Type;
exports.ThumbnailFormat$Type = types.ThumbnailFormat$Type;
exports.TopChatCategory$Type = types.TopChatCategory$Type;
exports.Update$Type = types.Update$Type;
exports.UserPrivacySetting$Type = types.UserPrivacySetting$Type;
exports.UserPrivacySettingRule$Type = types.UserPrivacySettingRule$Type;
exports.UserStatus$Type = types.UserStatus$Type;
exports.UserType$Type = types.UserType$Type;
exports.VectorPathCommand$Type = types.VectorPathCommand$Type;
exports.default = types;

@@ -70,3 +70,3 @@ TDLib / [Modules](modules.md)

await client.api.getOption({ name: "version" });
// => Promise { _: "optionValueString", value: "1.8.12" }
// => Promise { _: "optionValueString", value: "1.8.13" }

@@ -80,4 +80,6 @@ // Subscribe to updates

// client.start();
// Destroy
// client.destroy();
await client.api.close({});
client.destroy();
}

@@ -84,0 +86,0 @@ ```

{
"name": "tdlib-native",
"version": "1.1.2",
"version": "1.2.0",
"description": "🚀 Telegram TDLib native nodejs wrapper",

@@ -91,5 +91,5 @@ "scripts": {

"dotenv": "^16.0.3",
"eslint": "^8.35.0",
"eslint": "^8.36.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^8.7.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",

@@ -100,9 +100,9 @@ "eslint-plugin-prettier": "^4.2.1",

"eslint-plugin-unicorn": "^46.0.0",
"glob": "^9.2.1",
"glob": "^9.3.2",
"husky": "^8.0.3",
"jest": "^29.5.0",
"node-gyp": "^9.3.1",
"prettier": "^2.8.4",
"rimraf": "^4.4.0",
"rollup": "^3.18.0",
"prettier": "^2.8.7",
"rimraf": "^4.4.1",
"rollup": "^3.20.2",
"rollup-plugin-cleanup": "^3.2.1",

@@ -113,6 +113,6 @@ "rollup-plugin-prettier": "^3.0.0",

"ts-node": "^10.9.1",
"typedoc": "^0.23.26",
"typedoc": "^0.23.28",
"typedoc-plugin-markdown": "^3.14.0",
"typedoc-plugin-missing-exports": "^1.0.0",
"typescript": "^4.9.5"
"typescript": "^5.0.2"
},

@@ -119,0 +119,0 @@ "husky": {

@@ -68,3 +68,3 @@ # Quality Package Template

await client.api.getOption({ name: "version" });
// => Promise { _: "optionValueString", value: "1.8.12" }
// => Promise { _: "optionValueString", value: "1.8.13" }

@@ -78,4 +78,6 @@ // Subscribe to updates

// client.start();
// Destroy
// client.destroy();
await client.api.close({});
client.destroy();
}

@@ -82,0 +84,0 @@ ```

@@ -20,2 +20,7 @@ import { TDLibAddon } from "../addon";

afterAll(async () => {
await client.api.close({});
client.destroy();
});
const string = 'Test {"_": "Passed"}';

@@ -112,2 +117,18 @@ const int32 = 2 << 30;

});
test("error", async () => {
const input: error = {
_: "error",
code: 1337,
message: "Test"
};
try {
await client.api.testReturnError({ error: input });
fail("Should throw error");
} catch (error) {
expect(error).toBeInstanceOf(TDError);
expect(error).toMatchObject(input);
}
});
});

@@ -126,2 +147,7 @@

afterAll(async () => {
await client.api.close({});
client.destroy();
});
test("version", () => {

@@ -128,0 +154,0 @@ const version = client.syncApi.getOption({ name: "version" });

@@ -16,5 +16,10 @@ import { TDLibAddon } from "../addon";

afterAll(async () => {
await client.api.close({});
client.destroy();
});
test("Updates", async () => {
const apiHash = process.env.TELEGRAM_API_HASH || "";
const version = await client.invoke("getOption", { name: "version" });
const version = await client.api.getOption({ name: "version" });

@@ -21,0 +26,0 @@ await client.invoke("setTdlibParameters", {

@@ -5,4 +5,5 @@ import type { TDLib, TDLibClient } from "./shared/client";

Update,
$MethodsDict,
$SyncMethodsDict
$AsyncApi,
$SyncApi,
$MethodsDict
} from "./generated/types";

@@ -60,3 +61,3 @@ import * as JSON from "./json";

private readonly _client: TDLibClient;
private readonly _requests: Map<number, AsyncData> = new Map();
private readonly _requests: Map<number, AsyncData<any>> = new Map();
private readonly _updates: EventBus<Update> = new EventBus();

@@ -74,29 +75,14 @@ private _state = ClientState.PAUSED;

readonly api = new Proxy(
Object.freeze({}) as {
readonly [key in keyof $MethodsDict]: (
parameters: OmitType<Parameters<$MethodsDict[key]>[0]>
) => Promise<ReturnType<$MethodsDict[key]>>;
},
{
get: (_target, method) => {
return (parameters: any) =>
this.invoke(method as keyof $MethodsDict, parameters);
}
readonly api = new Proxy(Object.freeze({}) as $AsyncApi, {
get: (_target, method) => {
return (parameters: any) =>
this.invoke(method as keyof $MethodsDict, parameters);
}
);
});
readonly syncApi = new Proxy(
Object.freeze({}) as {
readonly [key in keyof $SyncMethodsDict]: (
parameters: OmitType<Parameters<$SyncMethodsDict[key]>[0]>
) => ReturnType<$SyncMethodsDict[key]>;
},
{
get: (_target, method) => {
return (parameters: any) =>
this.execute(method as keyof $SyncMethodsDict, parameters);
}
readonly syncApi = new Proxy(Object.freeze({}) as $SyncApi, {
get: (_target, method) => {
return (parameters: any) => this.execute(method as keyof $SyncApi, parameters);
}
);
});

@@ -106,23 +92,28 @@ /**

*
* @template {keyof $MethodsDict} T
* @template {keyof $AsyncApi} T
* @param {T} method
* @param {object} parameters
* @return {object} {Promise<ReturnType<$MethodsDict[T]>>}
* @return {object} {Promise<ReturnType<$AsyncApi[T]>>}
* @throws {TDError} - {@link TDError}
* @memberof Client
*/
async invoke<T extends keyof $MethodsDict>(
async invoke<T extends keyof $AsyncApi>(
method: T,
parameters: OmitType<Parameters<$MethodsDict[T]>[0]>
parameters: Parameters<$AsyncApi[T]>[0]
): Promise<ReturnType<$MethodsDict[T]>> {
const extra = Math.random();
const promise = new Promise<ReturnType<$MethodsDict[T]>>((resolve, reject) => {
const extra = Math.random();
assignTemporary(parameters, { _: method, "@extra": extra }, (merged) => {
this._adapter.send(this._client, JSON.serialize(merged));
assignTemporary(parameters, { _: method, "@extra": extra }, (merged) => {
this._adapter.send(this._client, JSON.serialize(merged));
});
const data = new AsyncData();
this._requests.set(extra, data);
data.then(resolve, reject);
});
const result = new AsyncData<ReturnType<$MethodsDict[T]>>();
this._requests.set(extra, result);
return result.catch((error: error) => {
return await promise.catch((error: error) => {
throw new TDError(error.message, { code: error.code, method, parameters });

@@ -135,3 +126,3 @@ });

*
* @template {keyof $SyncMethodsDict} T
* @template {keyof $SyncApi} T
* @param {TDLib|Client} executor

@@ -144,7 +135,7 @@ * @param {T} method

*/
static execute<T extends keyof $SyncMethodsDict>(
static execute<T extends keyof $SyncApi>(
executor: TDLib | Client,
method: T,
parameters: OmitType<Parameters<$MethodsDict[T]>[0]>
): ReturnType<$SyncMethodsDict[T]> {
parameters: Parameters<$SyncApi[T]>[0]
): ReturnType<$SyncApi[T]> {
let adapter: TDLib;

@@ -202,3 +193,3 @@ let client: TDLibClient | undefined;

return data as ReturnType<$SyncMethodsDict[T]>;
return data as ReturnType<$SyncApi[T]>;
}

@@ -209,13 +200,13 @@

*
* @template {keyof $SyncMethodsDict} T
* @template {keyof $SyncApi} T
* @param {T} method
* @param {object} parameters
* @return {object} {Promise<ReturnType<$SyncMethodsDict[T]>>}
* @return {object} {Promise<ReturnType<$SyncApi[T]>>}
* @throws {TDError} - {@link TDError}
* @memberof Client
*/
execute<T extends keyof $SyncMethodsDict>(
execute<T extends keyof $SyncApi>(
method: T,
parameters: OmitType<Parameters<$MethodsDict[T]>[0]>
): ReturnType<$SyncMethodsDict[T]> {
): ReturnType<$SyncApi[T]> {
return Client.execute(this, method, parameters);

@@ -289,3 +280,3 @@ }

*/
start() {
start(): this {
if (this._state === ClientState.PAUSED) {

@@ -306,3 +297,3 @@ this._state = ClientState.RUNNING;

*/
pause() {
pause(): this {
if (this._state === ClientState.RUNNING) {

@@ -309,0 +300,0 @@ this._state = ClientState.PAUSED;

export const Meta = {
version: "1.8.12",
commitHash: "6c53a61162e6ea4a753869ee248b8a9e926ffd5d"
version: "1.8.13",
commitHash: "eb664b4e9f71945ef3faa802af779e1630fedb8f"
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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