@elizaos/plugin-telegram 2.0.0-alpha.9 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/account-auth-service.d.ts +100 -0
- package/dist/account-auth-service.js +25 -0
- package/dist/account-auth-service.js.map +1 -0
- package/dist/chunk-KFEFF6RI.js +642 -0
- package/dist/chunk-KFEFF6RI.js.map +1 -0
- package/dist/index.d.ts +622 -1
- package/dist/index.js +2686 -339
- package/dist/index.js.map +1 -1
- package/package.json +19 -21
package/README.md
CHANGED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { TelegramClient } from 'telegram';
|
|
2
|
+
import { StringSession } from 'telegram/sessions/index.js';
|
|
3
|
+
|
|
4
|
+
type TelegramAccountAuthStatus = "idle" | "waiting_for_provisioning_code" | "waiting_for_telegram_code" | "waiting_for_password" | "configured" | "connected" | "error";
|
|
5
|
+
interface TelegramAccountAuthAccount {
|
|
6
|
+
id: string;
|
|
7
|
+
username: string | null;
|
|
8
|
+
firstName: string | null;
|
|
9
|
+
lastName: string | null;
|
|
10
|
+
phone: string | null;
|
|
11
|
+
}
|
|
12
|
+
interface TelegramAccountAuthSnapshot {
|
|
13
|
+
status: TelegramAccountAuthStatus;
|
|
14
|
+
phone: string | null;
|
|
15
|
+
error: string | null;
|
|
16
|
+
isCodeViaApp: boolean;
|
|
17
|
+
account: TelegramAccountAuthAccount | null;
|
|
18
|
+
}
|
|
19
|
+
interface TelegramAccountApiCredentials {
|
|
20
|
+
apiId: number;
|
|
21
|
+
apiHash: string;
|
|
22
|
+
}
|
|
23
|
+
interface TelegramAccountConnectorConfig {
|
|
24
|
+
phone: string;
|
|
25
|
+
appId: string;
|
|
26
|
+
appHash: string;
|
|
27
|
+
deviceModel: string;
|
|
28
|
+
systemVersion: string;
|
|
29
|
+
enabled: true;
|
|
30
|
+
}
|
|
31
|
+
interface TelegramAccountAuthSessionLike {
|
|
32
|
+
start(options: {
|
|
33
|
+
phone: string;
|
|
34
|
+
credentials: TelegramAccountApiCredentials | null;
|
|
35
|
+
}): Promise<TelegramAccountAuthSnapshot>;
|
|
36
|
+
submit(input: {
|
|
37
|
+
provisioningCode?: string;
|
|
38
|
+
telegramCode?: string;
|
|
39
|
+
password?: string;
|
|
40
|
+
}): Promise<TelegramAccountAuthSnapshot>;
|
|
41
|
+
stop(): Promise<void>;
|
|
42
|
+
getSnapshot(): TelegramAccountAuthSnapshot;
|
|
43
|
+
getResolvedConnectorConfig(): TelegramAccountConnectorConfig | null;
|
|
44
|
+
}
|
|
45
|
+
type TelegramAccountProvisioningApp = {
|
|
46
|
+
api_id: number;
|
|
47
|
+
api_hash: string;
|
|
48
|
+
};
|
|
49
|
+
type TelegramAccountAuthDeps = {
|
|
50
|
+
createTelegramClient?: (session: StringSession, credentials: TelegramAccountApiCredentials, deviceModel: string, systemVersion: string) => TelegramClient;
|
|
51
|
+
sendProvisioningCode?: (phone: string) => Promise<string>;
|
|
52
|
+
completeProvisioningLogin?: (phone: string, randomHash: string, code: string) => Promise<string>;
|
|
53
|
+
getOrCreateProvisionedApp?: (stelToken: string) => Promise<TelegramAccountProvisioningApp>;
|
|
54
|
+
};
|
|
55
|
+
declare function resolveTelegramAccountSessionFile(): string;
|
|
56
|
+
declare function loadTelegramAccountSessionString(): string;
|
|
57
|
+
declare function saveTelegramAccountSessionString(session: string): void;
|
|
58
|
+
declare function clearTelegramAccountSession(): void;
|
|
59
|
+
declare function telegramAccountSessionExists(): boolean;
|
|
60
|
+
declare function clearTelegramAccountAuthState(): void;
|
|
61
|
+
declare function telegramAccountAuthStateExists(): boolean;
|
|
62
|
+
declare function defaultTelegramAccountDeviceModel(): string;
|
|
63
|
+
declare function defaultTelegramAccountSystemVersion(): string;
|
|
64
|
+
declare class TelegramAccountAuthSession implements TelegramAccountAuthSessionLike {
|
|
65
|
+
private snapshot;
|
|
66
|
+
private client;
|
|
67
|
+
private credentials;
|
|
68
|
+
private connectorConfig;
|
|
69
|
+
private provisioningRandomHash;
|
|
70
|
+
private phoneCodeHash;
|
|
71
|
+
private readonly deviceModel;
|
|
72
|
+
private readonly systemVersion;
|
|
73
|
+
private readonly deps;
|
|
74
|
+
constructor(options?: {
|
|
75
|
+
deviceModel?: string;
|
|
76
|
+
systemVersion?: string;
|
|
77
|
+
}, deps?: TelegramAccountAuthDeps);
|
|
78
|
+
getSnapshot(): TelegramAccountAuthSnapshot;
|
|
79
|
+
getResolvedConnectorConfig(): TelegramAccountConnectorConfig | null;
|
|
80
|
+
start(options: {
|
|
81
|
+
phone: string;
|
|
82
|
+
credentials: TelegramAccountApiCredentials | null;
|
|
83
|
+
}): Promise<TelegramAccountAuthSnapshot>;
|
|
84
|
+
submit(input: {
|
|
85
|
+
provisioningCode?: string;
|
|
86
|
+
telegramCode?: string;
|
|
87
|
+
password?: string;
|
|
88
|
+
}): Promise<TelegramAccountAuthSnapshot>;
|
|
89
|
+
stop(): Promise<void>;
|
|
90
|
+
private beginTelegramLogin;
|
|
91
|
+
private completeTelegramCode;
|
|
92
|
+
private completePassword;
|
|
93
|
+
private finishAuthorized;
|
|
94
|
+
private persistSession;
|
|
95
|
+
private persistAuthState;
|
|
96
|
+
private disconnectClient;
|
|
97
|
+
private ensureClientConnected;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { type TelegramAccountApiCredentials, type TelegramAccountAuthAccount, TelegramAccountAuthSession, type TelegramAccountAuthSessionLike, type TelegramAccountAuthSnapshot, type TelegramAccountAuthStatus, type TelegramAccountConnectorConfig, clearTelegramAccountAuthState, clearTelegramAccountSession, defaultTelegramAccountDeviceModel, defaultTelegramAccountSystemVersion, loadTelegramAccountSessionString, resolveTelegramAccountSessionFile, saveTelegramAccountSessionString, telegramAccountAuthStateExists, telegramAccountSessionExists };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TelegramAccountAuthSession,
|
|
3
|
+
clearTelegramAccountAuthState,
|
|
4
|
+
clearTelegramAccountSession,
|
|
5
|
+
defaultTelegramAccountDeviceModel,
|
|
6
|
+
defaultTelegramAccountSystemVersion,
|
|
7
|
+
loadTelegramAccountSessionString,
|
|
8
|
+
resolveTelegramAccountSessionFile,
|
|
9
|
+
saveTelegramAccountSessionString,
|
|
10
|
+
telegramAccountAuthStateExists,
|
|
11
|
+
telegramAccountSessionExists
|
|
12
|
+
} from "./chunk-KFEFF6RI.js";
|
|
13
|
+
export {
|
|
14
|
+
TelegramAccountAuthSession,
|
|
15
|
+
clearTelegramAccountAuthState,
|
|
16
|
+
clearTelegramAccountSession,
|
|
17
|
+
defaultTelegramAccountDeviceModel,
|
|
18
|
+
defaultTelegramAccountSystemVersion,
|
|
19
|
+
loadTelegramAccountSessionString,
|
|
20
|
+
resolveTelegramAccountSessionFile,
|
|
21
|
+
saveTelegramAccountSessionString,
|
|
22
|
+
telegramAccountAuthStateExists,
|
|
23
|
+
telegramAccountSessionExists
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=account-auth-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|