zaileys 0.29.13-beta → 0.29.15-beta
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/package.json +1 -1
- package/bun.lock +0 -1027
- package/rollup.config.mjs +0 -46
- package/src/classes/Client.ts +0 -73
- package/src/classes/Event.ts +0 -59
- package/src/classes/Parser.ts +0 -3
- package/src/database/handler.ts +0 -272
- package/src/database/schema.ts +0 -37
- package/src/helpers/adapter.ts +0 -125
- package/src/helpers/error.ts +0 -13
- package/src/index.ts +0 -2
- package/src/types/adapter/general.ts +0 -178
- package/src/types/classes/client.ts +0 -53
- package/src/types/classes/event.ts +0 -29
- package/src/types/libsignal.d.ts +0 -4
- package/test/example.ts +0 -37
- package/tsconfig.json +0 -19
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
type Awaitable<T> = T | Promise<T>;
|
|
2
|
-
|
|
3
|
-
export type AuthAdapterHandlerType = Promise<{
|
|
4
|
-
state: AuthenticationState;
|
|
5
|
-
saveCreds: () => Promise<void>;
|
|
6
|
-
clear: () => Promise<void>;
|
|
7
|
-
removeCreds: () => Promise<void>
|
|
8
|
-
}>;
|
|
9
|
-
|
|
10
|
-
type Contact = {
|
|
11
|
-
id: string;
|
|
12
|
-
lid?: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
notify?: string;
|
|
15
|
-
verifiedName?: string;
|
|
16
|
-
imgUrl?: string | null;
|
|
17
|
-
status?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type Account = {
|
|
21
|
-
details?: Uint8Array | null;
|
|
22
|
-
accountSignatureKey?: Uint8Array | null;
|
|
23
|
-
accountSignature?: Uint8Array | null;
|
|
24
|
-
deviceSignature?: Uint8Array | null;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type SignedKeyPair = {
|
|
28
|
-
keyPair: KeyPair;
|
|
29
|
-
signature: Uint8Array;
|
|
30
|
-
keyId: number;
|
|
31
|
-
timestampS?: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
type ProtocolAddress = {
|
|
35
|
-
name: string;
|
|
36
|
-
deviceId: number;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type SignalIdentity = {
|
|
40
|
-
identifier: ProtocolAddress;
|
|
41
|
-
identifierKey: Uint8Array;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
type LTHashState = {
|
|
45
|
-
version: number;
|
|
46
|
-
hash: Buffer;
|
|
47
|
-
indexValueMap: {
|
|
48
|
-
[indexMacBase64: string]: { valueMac: Uint8Array | Buffer };
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
type SignalCreds = {
|
|
53
|
-
readonly signedIdentityKey: KeyPair;
|
|
54
|
-
readonly signedPreKey: SignedKeyPair;
|
|
55
|
-
readonly registrationId: number;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type AccountSettings = {
|
|
59
|
-
unarchiveChats: boolean;
|
|
60
|
-
defaultDisappearingMode?: Pick<any, "ephemeralExpiration" | "ephemeralSettingTimestamp">;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
type SignalKeyStore = {
|
|
64
|
-
get<T extends keyof SignalDataTypeMap>(
|
|
65
|
-
type: T,
|
|
66
|
-
ids: string[]
|
|
67
|
-
): Awaitable<{
|
|
68
|
-
[id: string]: SignalDataTypeMap[T];
|
|
69
|
-
}>;
|
|
70
|
-
set(data: SignalDataSet): Awaitable<void>;
|
|
71
|
-
clear?(): Awaitable<void>;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
interface RegistrationOptions {
|
|
75
|
-
phoneNumber?: string;
|
|
76
|
-
phoneNumberCountryCode: string;
|
|
77
|
-
phoneNumberNationalNumber: string;
|
|
78
|
-
phoneNumberMobileCountryCode: string;
|
|
79
|
-
phoneNumberMobileNetworkCode: string;
|
|
80
|
-
method?: "sms" | "voice" | "captcha";
|
|
81
|
-
captcha?: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type SslOptions = {
|
|
85
|
-
pfx?: string;
|
|
86
|
-
key?: string | string[] | Buffer | Buffer[];
|
|
87
|
-
passphrase?: string;
|
|
88
|
-
cert?: string | string[] | Buffer | Buffer[];
|
|
89
|
-
ca?: string | string[] | Buffer | Buffer[];
|
|
90
|
-
crl?: string | string[];
|
|
91
|
-
ciphers?: string;
|
|
92
|
-
rejectUnauthorized?: boolean;
|
|
93
|
-
minVersion?: string;
|
|
94
|
-
maxVersion?: string;
|
|
95
|
-
verifyIdentity?: boolean;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export type Fingerprint = {
|
|
99
|
-
rawId: number;
|
|
100
|
-
currentIndex: number;
|
|
101
|
-
deviceIndexes: number[];
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export type AppDataSync = {
|
|
105
|
-
keyData: Uint8Array;
|
|
106
|
-
fingerprint: Fingerprint;
|
|
107
|
-
timestamp: Long | number;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export type SignalDataTypeMap = {
|
|
111
|
-
session: Uint8Array;
|
|
112
|
-
"pre-key": KeyPair;
|
|
113
|
-
"sender-key": Uint8Array;
|
|
114
|
-
"app-state-sync-key": AppDataSync;
|
|
115
|
-
"app-state-sync-version": LTHashState;
|
|
116
|
-
"sender-key-memory": {
|
|
117
|
-
[jid: string]: boolean;
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export type SignalDataSet = {
|
|
122
|
-
[T in keyof SignalDataTypeMap]?: {
|
|
123
|
-
[id: string]: SignalDataTypeMap[T] | null;
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export type KeyPair = {
|
|
128
|
-
public: Uint8Array;
|
|
129
|
-
private: Uint8Array;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export type sqlData = {
|
|
133
|
-
constructor: {
|
|
134
|
-
name: "RowDataPacket";
|
|
135
|
-
};
|
|
136
|
-
value?: object[];
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export type valueReplacer = {
|
|
140
|
-
data: number[];
|
|
141
|
-
type: string;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export type valueReviver = {
|
|
145
|
-
data: string;
|
|
146
|
-
type: string;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export type AuthenticationState = {
|
|
150
|
-
creds: AuthenticationCreds;
|
|
151
|
-
keys: SignalKeyStore;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export type AuthenticationCreds = SignalCreds & {
|
|
155
|
-
readonly noiseKey: KeyPair;
|
|
156
|
-
readonly pairingEphemeralKeyPair: KeyPair;
|
|
157
|
-
advSecretKey: string;
|
|
158
|
-
me?: Contact;
|
|
159
|
-
account?: Account;
|
|
160
|
-
signalIdentities?: SignalIdentity[];
|
|
161
|
-
myAppStateKeyId?: string;
|
|
162
|
-
firstUnuploadedPreKeyId: number;
|
|
163
|
-
nextPreKeyId: number;
|
|
164
|
-
lastAccountSyncTimestamp?: number;
|
|
165
|
-
platform?: string;
|
|
166
|
-
processedHistoryMessages: Pick<any, "key" | "messageTimestamp">[];
|
|
167
|
-
accountSyncCounter: number;
|
|
168
|
-
accountSettings: AccountSettings;
|
|
169
|
-
deviceId: string;
|
|
170
|
-
phoneId: string;
|
|
171
|
-
identityId: Buffer;
|
|
172
|
-
registered: boolean;
|
|
173
|
-
backupToken: Buffer;
|
|
174
|
-
registration: RegistrationOptions;
|
|
175
|
-
pairingCode: string | undefined;
|
|
176
|
-
lastPropHash: string | undefined;
|
|
177
|
-
routingInfo: Buffer | undefined;
|
|
178
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const AdapterDatabaseType = z
|
|
4
|
-
.object({
|
|
5
|
-
type: z.enum(["sqlite", "postgresql", "mysql"]).default("sqlite"),
|
|
6
|
-
connection: z
|
|
7
|
-
.object({
|
|
8
|
-
url: z.string().default("./zaileys.db"),
|
|
9
|
-
})
|
|
10
|
-
.optional()
|
|
11
|
-
.default({}),
|
|
12
|
-
})
|
|
13
|
-
.optional()
|
|
14
|
-
.default({});
|
|
15
|
-
|
|
16
|
-
const ClientClassesBaseType = {
|
|
17
|
-
prefix: z.string().optional(),
|
|
18
|
-
ignoreMe: z.boolean().optional().default(true),
|
|
19
|
-
showLogs: z.boolean().optional().default(true),
|
|
20
|
-
autoMentions: z.boolean().optional().default(true),
|
|
21
|
-
autoOnline: z.boolean().optional().default(true),
|
|
22
|
-
autoRead: z.boolean().optional().default(true),
|
|
23
|
-
autoRejectCall: z.boolean().optional().default(true),
|
|
24
|
-
database: AdapterDatabaseType,
|
|
25
|
-
citation: z
|
|
26
|
-
.record(z.function().returns(z.union([z.number().array(), z.promise(z.number().array())])))
|
|
27
|
-
.optional()
|
|
28
|
-
.transform(async (citation) => {
|
|
29
|
-
const transform: Record<string, any> = {};
|
|
30
|
-
if (citation) {
|
|
31
|
-
for (const key of Object.keys(citation)) {
|
|
32
|
-
const news = `is${key.charAt(0).toUpperCase() + key.slice(1)}`;
|
|
33
|
-
const result = await citation[key]();
|
|
34
|
-
transform[news] = result;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return transform;
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const ClientPairingType = z.object({
|
|
42
|
-
authType: z.literal("pairing"),
|
|
43
|
-
phoneNumber: z.number(),
|
|
44
|
-
...ClientClassesBaseType,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const ClientQRType = z.object({
|
|
48
|
-
authType: z.literal("qr"),
|
|
49
|
-
phoneNumber: z.undefined().optional(),
|
|
50
|
-
...ClientClassesBaseType,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export const ClientClassesType = z.discriminatedUnion("authType", [ClientPairingType, ClientQRType]);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
const EventConnectionType = z.object({
|
|
4
|
-
status: z.enum(["connecting", "open", "close"]),
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
const EventMessagesType = z.object({
|
|
8
|
-
messages: z.object({
|
|
9
|
-
remoteJid: z.string(),
|
|
10
|
-
id: z.string(),
|
|
11
|
-
}),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const EventCallType = z.object({
|
|
15
|
-
call: z.object({
|
|
16
|
-
id: z.string(),
|
|
17
|
-
from: z.string(),
|
|
18
|
-
timestamp: z.number(),
|
|
19
|
-
}),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const EventEnumType = z.enum(["connection", "messages", "call"]);
|
|
23
|
-
export type EventEnumType = z.infer<typeof EventEnumType>;
|
|
24
|
-
|
|
25
|
-
export type EventCallbackType = {
|
|
26
|
-
connection: (data: z.infer<typeof EventConnectionType>) => void;
|
|
27
|
-
messages: (data: z.infer<typeof EventMessagesType>) => void;
|
|
28
|
-
call: (data: z.infer<typeof EventCallType>) => void;
|
|
29
|
-
};
|
package/src/types/libsignal.d.ts
DELETED
package/test/example.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import Client from "../src";
|
|
2
|
-
|
|
3
|
-
// the configuration below is the default
|
|
4
|
-
const wa = new Client({
|
|
5
|
-
prefix: "/", // for command message, example '/'
|
|
6
|
-
phoneNumber: 6287833764462, // fill bot phone number if auth type is 'pairing'
|
|
7
|
-
authType: "pairing", // auth type 'pairing' or 'qr'
|
|
8
|
-
ignoreMe: true, // ignore messages from bot (bot phone number)
|
|
9
|
-
showLogs: true, // show logs of any chats
|
|
10
|
-
autoMentions: true, // bot will be auto mentioned if text contains sender number with '@' prefix
|
|
11
|
-
autoOnline: true, // bot status will be mark online
|
|
12
|
-
autoRead: true, // auto read message from any chats
|
|
13
|
-
autoRejectCall: true, // auto reject call if someone call you
|
|
14
|
-
database: {
|
|
15
|
-
type: "sqlite", // database type "sqlite" | "postgresql" | "mysql"
|
|
16
|
-
connection: {
|
|
17
|
-
url: "./db/zaileys.db", // database url
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
citation: {
|
|
21
|
-
author: async () => {
|
|
22
|
-
// const res = await fetch...
|
|
23
|
-
return await [6285136635787];
|
|
24
|
-
},
|
|
25
|
-
myGroup: () => [6285136635787],
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
wa.on("connection", (ctx) => {
|
|
30
|
-
// console.log("🚀 ~ example.ts:30 ~ wa.on ~ ctx:", ctx);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
wa.on("messages", (ctx) => {
|
|
34
|
-
console.log("🚀 ~ example.ts:31 ~ wa.on ~ ctx:", ctx);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
wa.on("call", () => {});
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "Node",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"allowSyntheticDefaultImports": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"noImplicitAny": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"declarationDir": "dist",
|
|
13
|
-
"outDir": "dist",
|
|
14
|
-
"rootDir": "src",
|
|
15
|
-
"resolveJsonModule": true
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*"],
|
|
18
|
-
"exclude": ["node_modules", "dist"]
|
|
19
|
-
}
|