@imjxsx/wapi 1.1.0-beta → 1.3.0
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 +2 -2
- package/dist/cache/contacts.js +2 -2
- package/dist/cache/contacts.js.map +7 -1
- package/dist/cache/groups.js +2 -2
- package/dist/cache/groups.js.map +7 -1
- package/dist/cache/index.js +2 -3
- package/dist/cache/index.js.map +7 -1
- package/dist/core/auth/index.d.ts.map +1 -0
- package/dist/core/auth/index.js +2 -0
- package/dist/core/auth/index.js.map +7 -0
- package/dist/{auth → core/auth}/local.d.ts +1 -1
- package/dist/core/auth/local.d.ts.map +1 -0
- package/dist/core/auth/local.js +2 -0
- package/dist/core/auth/local.js.map +7 -0
- package/dist/{auth → core/auth}/mongo.d.ts +1 -1
- package/dist/core/auth/mongo.d.ts.map +1 -0
- package/dist/core/auth/mongo.js +2 -0
- package/dist/core/auth/mongo.js.map +7 -0
- package/dist/{auth → core/auth}/redis.d.ts +1 -1
- package/dist/core/auth/redis.d.ts.map +1 -0
- package/dist/core/auth/redis.js +2 -0
- package/dist/core/auth/redis.js.map +7 -0
- package/dist/{bot → core}/bot.d.ts +8 -5
- package/dist/core/bot.d.ts.map +1 -0
- package/dist/core/bot.js +2 -0
- package/dist/core/bot.js.map +7 -0
- package/dist/{context → core/context}/context.d.ts +3 -2
- package/dist/core/context/context.d.ts.map +1 -0
- package/dist/core/context/context.js +2 -0
- package/dist/core/context/context.js.map +7 -0
- package/dist/{context → core/context}/message.d.ts +5 -5
- package/dist/core/context/message.d.ts.map +1 -0
- package/dist/core/context/message.js +2 -0
- package/dist/core/context/message.js.map +7 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/dist/index.js.map +7 -1
- package/dist/types/bot.d.ts +1 -1
- package/dist/types/bot.d.ts.map +1 -1
- package/dist/types/bot.js +1 -2
- package/dist/types/bot.js.map +7 -1
- package/dist/types/context.d.ts +19 -0
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/context.js +1 -2
- package/dist/types/context.js.map +7 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -4
- package/dist/types/index.js.map +7 -1
- package/dist/utils/converters.d.ts +3 -0
- package/dist/utils/converters.d.ts.map +1 -0
- package/dist/utils/converters.js +2 -0
- package/dist/utils/converters.js.map +7 -0
- package/dist/utils/crypto.js +2 -33
- package/dist/utils/crypto.js.map +7 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -7
- package/dist/utils/index.js.map +7 -1
- package/dist/utils/jid.d.ts +1 -2
- package/dist/utils/jid.d.ts.map +1 -1
- package/dist/utils/jid.js +2 -22
- package/dist/utils/jid.js.map +7 -1
- package/dist/utils/message-builder.js +3 -61
- package/dist/utils/message-builder.js.map +7 -1
- package/dist/utils/utils.js +2 -4
- package/dist/utils/utils.js.map +7 -1
- package/dist/utils/validators.d.ts +11 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +2 -0
- package/dist/utils/validators.js.map +7 -0
- package/package.json +12 -12
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -4
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/local.d.ts.map +0 -1
- package/dist/auth/local.js +0 -117
- package/dist/auth/local.js.map +0 -1
- package/dist/auth/mongo.d.ts.map +0 -1
- package/dist/auth/mongo.js +0 -120
- package/dist/auth/mongo.js.map +0 -1
- package/dist/auth/redis.d.ts.map +0 -1
- package/dist/auth/redis.js +0 -116
- package/dist/auth/redis.js.map +0 -1
- package/dist/bot/bot.d.ts.map +0 -1
- package/dist/bot/bot.js +0 -62
- package/dist/bot/bot.js.map +0 -1
- package/dist/bot/disconnect.d.ts +0 -4
- package/dist/bot/disconnect.d.ts.map +0 -1
- package/dist/bot/disconnect.js +0 -12
- package/dist/bot/disconnect.js.map +0 -1
- package/dist/bot/events/connection-update.d.ts +0 -4
- package/dist/bot/events/connection-update.d.ts.map +0 -1
- package/dist/bot/events/connection-update.js +0 -84
- package/dist/bot/events/connection-update.js.map +0 -1
- package/dist/bot/events/contacts-update.d.ts +0 -3
- package/dist/bot/events/contacts-update.d.ts.map +0 -1
- package/dist/bot/events/contacts-update.js +0 -22
- package/dist/bot/events/contacts-update.js.map +0 -1
- package/dist/bot/events/creds-update.d.ts +0 -3
- package/dist/bot/events/creds-update.d.ts.map +0 -1
- package/dist/bot/events/creds-update.js +0 -17
- package/dist/bot/events/creds-update.js.map +0 -1
- package/dist/bot/events/groups-update.d.ts +0 -3
- package/dist/bot/events/groups-update.d.ts.map +0 -1
- package/dist/bot/events/groups-update.js +0 -22
- package/dist/bot/events/groups-update.js.map +0 -1
- package/dist/bot/events/index.d.ts +0 -6
- package/dist/bot/events/index.d.ts.map +0 -1
- package/dist/bot/events/index.js +0 -6
- package/dist/bot/events/index.js.map +0 -1
- package/dist/bot/events/message-upsert.d.ts +0 -3
- package/dist/bot/events/message-upsert.d.ts.map +0 -1
- package/dist/bot/events/message-upsert.js +0 -57
- package/dist/bot/events/message-upsert.js.map +0 -1
- package/dist/bot/index.d.ts +0 -2
- package/dist/bot/index.d.ts.map +0 -1
- package/dist/bot/index.js +0 -2
- package/dist/bot/index.js.map +0 -1
- package/dist/bot/login.d.ts +0 -3
- package/dist/bot/login.d.ts.map +0 -1
- package/dist/bot/login.js +0 -41
- package/dist/bot/login.js.map +0 -1
- package/dist/bot/logout.d.ts +0 -4
- package/dist/bot/logout.d.ts.map +0 -1
- package/dist/bot/logout.js +0 -10
- package/dist/bot/logout.js.map +0 -1
- package/dist/bot/utils.d.ts +0 -10
- package/dist/bot/utils.d.ts.map +0 -1
- package/dist/bot/utils.js +0 -101
- package/dist/bot/utils.js.map +0 -1
- package/dist/context/context.d.ts.map +0 -1
- package/dist/context/context.js +0 -142
- package/dist/context/context.js.map +0 -1
- package/dist/context/index.d.ts +0 -3
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -3
- package/dist/context/index.js.map +0 -1
- package/dist/context/message.d.ts.map +0 -1
- package/dist/context/message.js +0 -170
- package/dist/context/message.js.map +0 -1
- package/dist/types/message.d.ts +0 -15
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/message.js +0 -2
- package/dist/types/message.js.map +0 -1
- package/dist/utils/fs.d.ts +0 -9
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js +0 -72
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/helpers.d.ts +0 -21
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/helpers.js +0 -68
- package/dist/utils/helpers.js.map +0 -1
- /package/dist/{auth → core/auth}/index.d.ts +0 -0
package/dist/types/context.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=context.js.map
|
|
1
|
+
//# sourceMappingURL=context.js.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
|
package/dist/types/index.js
CHANGED
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./bot.js\";\nexport * from \"./context.js\";"],
|
|
5
|
+
"mappings": "AAAA,WAAc,WACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../src/utils/converters.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAK/C;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAK7C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/converters.ts"],
|
|
4
|
+
"sourcesContent": ["import { isString, isError, isObject } from \"./index.js\";\n\nexport function toString(value: unknown): string {\n if (isObject(value)) {\n value = JSON.stringify(value);\n }\n return isString(value) ? value : String(value);\n}\nexport function toError(value: unknown): Error {\n if (isError(value)) {\n return value;\n }\n return new Error(toString(value));\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,EAAU,WAAAC,EAAS,YAAAC,MAAgB,aAErC,SAASC,EAASC,EAAwB,CAC/C,OAAIF,EAASE,CAAK,IAChBA,EAAQ,KAAK,UAAUA,CAAK,GAEvBJ,EAASI,CAAK,EAAIA,EAAQ,OAAOA,CAAK,CAC/C,CACO,SAASC,EAAQD,EAAuB,CAC7C,OAAIH,EAAQG,CAAK,EACRA,EAEF,IAAI,MAAMD,EAASC,CAAK,CAAC,CAClC",
|
|
6
|
+
"names": ["isString", "isError", "isObject", "toString", "value", "toError"]
|
|
7
|
+
}
|
package/dist/utils/crypto.js
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
key;
|
|
4
|
-
constructor(key) {
|
|
5
|
-
this.key = createHash("sha256").update(key).digest();
|
|
6
|
-
}
|
|
7
|
-
encrypt(value) {
|
|
8
|
-
const iv = randomBytes(12);
|
|
9
|
-
const cipher = createCipheriv("aes-256-gcm", this.key, iv);
|
|
10
|
-
const encrypted = Buffer.concat([
|
|
11
|
-
cipher.update(value),
|
|
12
|
-
cipher.final(),
|
|
13
|
-
]);
|
|
14
|
-
const tag = cipher.getAuthTag();
|
|
15
|
-
return Buffer.concat([
|
|
16
|
-
iv,
|
|
17
|
-
tag,
|
|
18
|
-
encrypted,
|
|
19
|
-
]);
|
|
20
|
-
}
|
|
21
|
-
decrypt(value) {
|
|
22
|
-
const iv = value.subarray(0, 12);
|
|
23
|
-
const tag = value.subarray(12, 28);
|
|
24
|
-
const data = value.subarray(28);
|
|
25
|
-
const decipher = createDecipheriv("aes-256-gcm", this.key, iv);
|
|
26
|
-
decipher.setAuthTag(tag);
|
|
27
|
-
return Buffer.concat([
|
|
28
|
-
decipher.update(data),
|
|
29
|
-
decipher.final(),
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=crypto.js.map
|
|
1
|
+
import{createCipheriv as s,createDecipheriv as n,createHash as f,randomBytes as u}from"node:crypto";class p{key;constructor(t){this.key=f("sha256").update(t).digest()}encrypt(t){const c=u(12),e=s("aes-256-gcm",this.key,c),a=Buffer.concat([e.update(t),e.final()]),r=e.getAuthTag();return Buffer.concat([c,r,a])}decrypt(t){const c=t.subarray(0,12),e=t.subarray(12,28),a=t.subarray(28),r=n("aes-256-gcm",this.key,c);return r.setAuthTag(e),Buffer.concat([r.update(a),r.final()])}}export{p as AES256GCM};
|
|
2
|
+
//# sourceMappingURL=crypto.js.map
|
package/dist/utils/crypto.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/crypto.ts"],
|
|
4
|
+
"sourcesContent": ["import { createCipheriv, createDecipheriv, createHash, randomBytes } from \"node:crypto\";\n\nexport class AES256GCM {\n protected key: Buffer;\n constructor(key: string) {\n this.key = createHash(\"sha256\").update(key).digest();\n }\n public encrypt(value: Buffer): Buffer {\n const iv = randomBytes(12);\n const cipher = createCipheriv(\"aes-256-gcm\", this.key, iv);\n const encrypted = Buffer.concat([\n cipher.update(value),\n cipher.final(),\n ]);\n const tag = cipher.getAuthTag();\n return Buffer.concat([\n iv,\n tag,\n encrypted,\n ]);\n }\n public decrypt(value: Buffer): Buffer {\n const iv = value.subarray(0, 12);\n const tag = value.subarray(12, 28);\n const data = value.subarray(28);\n const decipher = createDecipheriv(\"aes-256-gcm\", this.key, iv);\n decipher.setAuthTag(tag);\n return Buffer.concat([\n decipher.update(data),\n decipher.final(),\n ]);\n }\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAS,kBAAAA,EAAgB,oBAAAC,EAAkB,cAAAC,EAAY,eAAAC,MAAmB,cAEnE,MAAMC,CAAU,CACX,IACV,YAAYC,EAAa,CACvB,KAAK,IAAMH,EAAW,QAAQ,EAAE,OAAOG,CAAG,EAAE,OAAO,CACrD,CACO,QAAQC,EAAuB,CACpC,MAAMC,EAAKJ,EAAY,EAAE,EACnBK,EAASR,EAAe,cAAe,KAAK,IAAKO,CAAE,EACnDE,EAAY,OAAO,OAAO,CAC9BD,EAAO,OAAOF,CAAK,EACnBE,EAAO,MAAM,CACf,CAAC,EACKE,EAAMF,EAAO,WAAW,EAC9B,OAAO,OAAO,OAAO,CACnBD,EACAG,EACAD,CACF,CAAC,CACH,CACO,QAAQH,EAAuB,CACpC,MAAMC,EAAKD,EAAM,SAAS,EAAG,EAAE,EACzBI,EAAMJ,EAAM,SAAS,GAAI,EAAE,EAC3BK,EAAOL,EAAM,SAAS,EAAE,EACxBM,EAAWX,EAAiB,cAAe,KAAK,IAAKM,CAAE,EAC7D,OAAAK,EAAS,WAAWF,CAAG,EAChB,OAAO,OAAO,CACnBE,EAAS,OAAOD,CAAI,EACpBC,EAAS,MAAM,CACjB,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["createCipheriv", "createDecipheriv", "createHash", "randomBytes", "AES256GCM", "key", "value", "iv", "cipher", "encrypted", "tag", "data", "decipher"]
|
|
7
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
export * from "./converters.js";
|
|
1
2
|
export * from "./crypto.js";
|
|
2
|
-
export * from "./fs.js";
|
|
3
|
-
export * from "./helpers.js";
|
|
4
3
|
export * from "./jid.js";
|
|
5
4
|
export * from "./message-builder.js";
|
|
6
5
|
export * from "./utils.js";
|
|
6
|
+
export * from "./validators.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAA"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export * from "./helpers.js";
|
|
4
|
-
export * from "./jid.js";
|
|
5
|
-
export * from "./message-builder.js";
|
|
6
|
-
export * from "./utils.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export*from"./converters.js";export*from"./crypto.js";export*from"./jid.js";export*from"./message-builder.js";export*from"./utils.js";export*from"./validators.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./converters.js\";\nexport * from \"./crypto.js\";\nexport * from \"./jid.js\";\nexport * from \"./message-builder.js\";\nexport * from \"./utils.js\";\nexport * from \"./validators.js\""],
|
|
5
|
+
"mappings": "AAAA,WAAc,kBACd,WAAc,cACd,WAAc,WACd,WAAc,uBACd,WAAc,aACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/utils/jid.d.ts
CHANGED
package/dist/utils/jid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jid.d.ts","sourceRoot":"","sources":["../../src/utils/jid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jid.d.ts","sourceRoot":"","sources":["../../src/utils/jid.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAMhD;AACD,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAG9C;AACD,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,GAAG,MAAM,OAAO,CAE7D;AACD,wBAAgB,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,GAAG,MAAM,iBAAiB,CAEpE;AACD,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,GAAG,MAAM,MAAM,CAE1D"}
|
package/dist/utils/jid.js
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const match = toString(jid).match(/^([\w-]+)(?::\d+)?@([\w.-]+)$/) ?? [];
|
|
4
|
-
return {
|
|
5
|
-
jid: match[1] ?? "",
|
|
6
|
-
server: match[2] ?? "",
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
export function normalize(jid) {
|
|
10
|
-
const decoded = decode(toString(jid));
|
|
11
|
-
return `${decoded.jid}@${decoded.server}`;
|
|
12
|
-
}
|
|
13
|
-
export function isGroup(jid) {
|
|
14
|
-
return /@g\.us$/.test(toString(jid));
|
|
15
|
-
}
|
|
16
|
-
export function isPn(jid) {
|
|
17
|
-
return /@s\.whatsapp\.net$/.test(toString(jid));
|
|
18
|
-
}
|
|
19
|
-
export function isLid(jid) {
|
|
20
|
-
return /@lid$/.test(toString(jid));
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=jid.js.map
|
|
1
|
+
import{toString as t}from"./index.js";function e(n){const r=t(n).match(/^([\w-]+)(?::\d+)?@([\w.-]+)$/)??[];return{jid:r[1]??"",server:r[2]??""}}function o(n){const r=e(t(n));return`${r.jid}@${r.server}`}function s(n){return e(n).server==="g.us"}function d(n){return e(n).server==="s.whatsapp.net"}function u(n){return e(n).server==="lid"}export{e as decode,s as isGroup,u as isLid,d as isPn,o as normalize};
|
|
2
|
+
//# sourceMappingURL=jid.js.map
|
package/dist/utils/jid.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/jid.ts"],
|
|
4
|
+
"sourcesContent": ["import { toString } from \"./index.js\";\n\nexport interface IJidDecoded {\n jid: string;\n server: string;\n}\nexport function decode(jid: unknown): IJidDecoded {\n const match = toString(jid).match(/^([\\w-]+)(?::\\d+)?@([\\w.-]+)$/) ?? [];\n return {\n jid: match[1] ?? \"\",\n server: match[2] ?? \"\",\n };\n}\nexport function normalize(jid: unknown): string {\n const decoded = decode(toString(jid));\n return `${decoded.jid}@${decoded.server}`;\n}\nexport function isGroup(jid: unknown): jid is `${string}@g.us` {\n return decode(jid).server === \"g.us\";\n}\nexport function isPn(jid: unknown): jid is `${string}@s.whatsapp.net` {\n return decode(jid).server === \"s.whatsapp.net\";\n}\nexport function isLid(jid: unknown): jid is `${string}@lid` {\n return decode(jid).server === \"lid\";\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,MAAgB,aAMlB,SAASC,EAAOC,EAA2B,CAChD,MAAMC,EAAQH,EAASE,CAAG,EAAE,MAAM,+BAA+B,GAAK,CAAC,EACvE,MAAO,CACL,IAAKC,EAAM,CAAC,GAAK,GACjB,OAAQA,EAAM,CAAC,GAAK,EACtB,CACF,CACO,SAASC,EAAUF,EAAsB,CAC9C,MAAMG,EAAUJ,EAAOD,EAASE,CAAG,CAAC,EACpC,MAAO,GAAGG,EAAQ,GAAG,IAAIA,EAAQ,MAAM,EACzC,CACO,SAASC,EAAQJ,EAAuC,CAC7D,OAAOD,EAAOC,CAAG,EAAE,SAAW,MAChC,CACO,SAASK,EAAKL,EAAiD,CACpE,OAAOD,EAAOC,CAAG,EAAE,SAAW,gBAChC,CACO,SAASM,EAAMN,EAAsC,CAC1D,OAAOD,EAAOC,CAAG,EAAE,SAAW,KAChC",
|
|
6
|
+
"names": ["toString", "decode", "jid", "match", "normalize", "decoded", "isGroup", "isPn", "isLid"]
|
|
7
|
+
}
|
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (text.length >= width) {
|
|
5
|
-
return text;
|
|
6
|
-
}
|
|
7
|
-
return " ".repeat(Math.floor((width - text.length) / 2)) + text;
|
|
8
|
-
}
|
|
9
|
-
addTitle(title, width) {
|
|
10
|
-
if (!title.length) {
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
this.parts.push(this.center(`*『* ${title} *』*`, width ?? 50));
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
addSubTitle(subtitle, width) {
|
|
17
|
-
if (!subtitle.length) {
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
this.parts.push(this.center(`*「* ${subtitle} *」*`, width ?? 25));
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
addDescription(description) {
|
|
24
|
-
if (!description.length) {
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
this.parts.push(`*»* ${description}`);
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
addLine(line) {
|
|
31
|
-
if (!line.length) {
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
this.parts.push(line);
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
addList(items, prefix) {
|
|
38
|
-
for (const item of items) {
|
|
39
|
-
if (!item) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
this.parts.push(`*${prefix ?? "•"}* ${item}`);
|
|
43
|
-
}
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
addBlankLine() {
|
|
47
|
-
this.parts.push("");
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
addFooter(footer, width) {
|
|
51
|
-
if (!footer.length) {
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
this.parts.push(this.center(`_${footer}_`, width ?? 50));
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
build() {
|
|
58
|
-
return this.parts.join("\n");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=message-builder.js.map
|
|
1
|
+
class e{parts=[];center(r,s){return r.length>=s?r:" ".repeat(Math.floor((s-r.length)/2))+r}addTitle(r,s){return r.length?(this.parts.push(this.center(`*\u300E* ${r} *\u300F*`,s??50)),this):this}addSubTitle(r,s){return r.length?(this.parts.push(this.center(`*\u300C* ${r} *\u300D*`,s??25)),this):this}addDescription(r){return r.length?(this.parts.push(`*\xBB* ${r}`),this):this}addLine(r){return r.length?(this.parts.push(r),this):this}addList(r,s){for(const t of r)t&&this.parts.push(`*${s??"\u2022"}* ${t}`);return this}addBlankLine(){return this.parts.push(""),this}addFooter(r,s){return r.length?(this.parts.push(this.center(`_${r}_`,s??50)),this):this}build(){return this.parts.join(`
|
|
2
|
+
`)}}export{e as MessageBuilder};
|
|
3
|
+
//# sourceMappingURL=message-builder.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/message-builder.ts"],
|
|
4
|
+
"sourcesContent": ["export class MessageBuilder {\n private parts: string[] = [];\n private center(text: string, width: number): string {\n if (text.length >= width) {\n return text;\n }\n return \" \".repeat(Math.floor((width - text.length) / 2)) + text;\n }\n public addTitle(title: string, width?: number): MessageBuilder {\n if (!title.length) {\n return this;\n }\n this.parts.push(this.center(`*\u300E* ${title} *\u300F*`, width ?? 50));\n return this;\n }\n public addSubTitle(subtitle: string, width?: number): MessageBuilder {\n if (!subtitle.length) {\n return this;\n }\n this.parts.push(this.center(`*\u300C* ${subtitle} *\u300D*`, width ?? 25));\n return this;\n }\n public addDescription(description: string): MessageBuilder {\n if (!description.length) {\n return this;\n }\n this.parts.push(`*\u00BB* ${description}`);\n return this;\n }\n public addLine(line: string): MessageBuilder {\n if (!line.length) {\n return this;\n }\n this.parts.push(line);\n return this;\n }\n public addList(items: string[], prefix?: string): MessageBuilder {\n for (const item of items) {\n if (!item) {\n continue;\n }\n this.parts.push(`*${prefix ?? \"\u2022\"}* ${item}`);\n }\n return this;\n }\n public addBlankLine(): MessageBuilder {\n this.parts.push(\"\");\n return this;\n }\n public addFooter(footer: string, width?: number): MessageBuilder {\n if (!footer.length) {\n return this;\n }\n this.parts.push(this.center(`_${footer}_`, width ?? 50));\n return this;\n }\n public build(): string {\n return this.parts.join(\"\\n\");\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,CAAe,CAClB,MAAkB,CAAC,EACnB,OAAOC,EAAcC,EAAuB,CAClD,OAAID,EAAK,QAAUC,EACVD,EAEF,IAAI,OAAO,KAAK,OAAOC,EAAQD,EAAK,QAAU,CAAC,CAAC,EAAIA,CAC7D,CACO,SAASE,EAAeD,EAAgC,CAC7D,OAAKC,EAAM,QAGX,KAAK,MAAM,KAAK,KAAK,OAAO,YAAOA,CAAK,YAAQD,GAAS,EAAE,CAAC,EACrD,MAHE,IAIX,CACO,YAAYE,EAAkBF,EAAgC,CACnE,OAAKE,EAAS,QAGd,KAAK,MAAM,KAAK,KAAK,OAAO,YAAOA,CAAQ,YAAQF,GAAS,EAAE,CAAC,EACxD,MAHE,IAIX,CACO,eAAeG,EAAqC,CACzD,OAAKA,EAAY,QAGjB,KAAK,MAAM,KAAK,UAAOA,CAAW,EAAE,EAC7B,MAHE,IAIX,CACO,QAAQC,EAA8B,CAC3C,OAAKA,EAAK,QAGV,KAAK,MAAM,KAAKA,CAAI,EACb,MAHE,IAIX,CACO,QAAQC,EAAiBC,EAAiC,CAC/D,UAAWC,KAAQF,EACZE,GAGL,KAAK,MAAM,KAAK,IAAID,GAAU,QAAG,KAAKC,CAAI,EAAE,EAE9C,OAAO,IACT,CACO,cAA+B,CACpC,YAAK,MAAM,KAAK,EAAE,EACX,IACT,CACO,UAAUC,EAAgBR,EAAgC,CAC/D,OAAKQ,EAAO,QAGZ,KAAK,MAAM,KAAK,KAAK,OAAO,IAAIA,CAAM,IAAKR,GAAS,EAAE,CAAC,EAChD,MAHE,IAIX,CACO,OAAgB,CACrB,OAAO,KAAK,MAAM,KAAK;AAAA,CAAI,CAC7B,CACF",
|
|
6
|
+
"names": ["MessageBuilder", "text", "width", "title", "subtitle", "description", "line", "items", "prefix", "item", "footer"]
|
|
7
|
+
}
|
package/dist/utils/utils.js
CHANGED
package/dist/utils/utils.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/utils.ts"],
|
|
4
|
+
"sourcesContent": ["export async function delay(ms: number): Promise<void> {\n return new Promise((resolve) => (setTimeout(resolve, ms)));\n}"],
|
|
5
|
+
"mappings": "AAAA,eAAsBA,EAAMC,EAA2B,CACrD,OAAO,IAAI,QAASC,GAAa,WAAWA,EAASD,CAAE,CAAE,CAC3D",
|
|
6
|
+
"names": ["delay", "ms", "resolve"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UUID } from "node:crypto";
|
|
2
|
+
export declare function isString(arg: unknown): arg is string;
|
|
3
|
+
export declare function isNumber(arg: unknown): arg is number;
|
|
4
|
+
export declare function isObject(arg: unknown): arg is object;
|
|
5
|
+
export declare function isArray(arg: unknown): arg is unknown[];
|
|
6
|
+
export declare function isBuffer(arg: unknown): arg is Buffer;
|
|
7
|
+
export declare function isUint8Array(arg: unknown): arg is Uint8Array;
|
|
8
|
+
export declare function isError(arg: unknown): arg is Error;
|
|
9
|
+
export declare function isLink(arg: unknown): arg is NonNullable<string>;
|
|
10
|
+
export declare function isUUID(arg: unknown): arg is UUID;
|
|
11
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AACD,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,EAAE,CAEtD;AACD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AACD,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,CAE5D;AACD,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,KAAK,CAElD;AACD,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAQ/D;AACD,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI,CAEhD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{toString as r}from"./index.js";function e(n){return typeof n=="string"}function u(n){return typeof n=="number"&&!isNaN(n)}function f(n){return typeof n=="object"&&n!==null}function s(n){return Array.isArray(n)}function a(n){return Buffer.isBuffer(n)}function c(n){return n instanceof Uint8Array}function p(n){return n instanceof Error}function g(n){try{return new URL(r(n)),!0}catch{return!1}}function k(n){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(r(n))}export{s as isArray,a as isBuffer,p as isError,g as isLink,u as isNumber,f as isObject,e as isString,k as isUUID,c as isUint8Array};
|
|
2
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/validators.ts"],
|
|
4
|
+
"sourcesContent": ["import { UUID } from \"node:crypto\";\nimport { toString } from \"./index.js\";\n\nexport function isString(arg: unknown): arg is string {\n return typeof arg === \"string\";\n}\nexport function isNumber(arg: unknown): arg is number {\n return typeof arg === \"number\" && !isNaN(arg);\n}\nexport function isObject(arg: unknown): arg is object {\n return typeof arg === \"object\" && arg !== null;\n}\nexport function isArray(arg: unknown): arg is unknown[] {\n return Array.isArray(arg);\n}\nexport function isBuffer(arg: unknown): arg is Buffer {\n return Buffer.isBuffer(arg);\n}\nexport function isUint8Array(arg: unknown): arg is Uint8Array {\n return arg instanceof Uint8Array;\n}\nexport function isError(arg: unknown): arg is Error {\n return arg instanceof Error;\n}\nexport function isLink(arg: unknown): arg is NonNullable<string> {\n try {\n new URL(toString(arg));\n return true;\n }\n catch {\n return false;\n }\n}\nexport function isUUID(arg: unknown): arg is UUID {\n return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(toString(arg));\n}"],
|
|
5
|
+
"mappings": "AACA,OAAS,YAAAA,MAAgB,aAElB,SAASC,EAASC,EAA6B,CACpD,OAAO,OAAOA,GAAQ,QACxB,CACO,SAASC,EAASD,EAA6B,CACpD,OAAO,OAAOA,GAAQ,UAAY,CAAC,MAAMA,CAAG,CAC9C,CACO,SAASE,EAASF,EAA6B,CACpD,OAAO,OAAOA,GAAQ,UAAYA,IAAQ,IAC5C,CACO,SAASG,EAAQH,EAAgC,CACtD,OAAO,MAAM,QAAQA,CAAG,CAC1B,CACO,SAASI,EAASJ,EAA6B,CACpD,OAAO,OAAO,SAASA,CAAG,CAC5B,CACO,SAASK,EAAaL,EAAiC,CAC5D,OAAOA,aAAe,UACxB,CACO,SAASM,EAAQN,EAA4B,CAClD,OAAOA,aAAe,KACxB,CACO,SAASO,EAAOP,EAA0C,CAC/D,GAAI,CACF,WAAI,IAAIF,EAASE,CAAG,CAAC,EACd,EACT,MACM,CACJ,MAAO,EACT,CACF,CACO,SAASQ,EAAOR,EAA2B,CAChD,MAAO,gFAAgF,KAAKF,EAASE,CAAG,CAAC,CAC3G",
|
|
6
|
+
"names": ["toString", "isString", "arg", "isNumber", "isObject", "isArray", "isBuffer", "isUint8Array", "isError", "isLink", "isUUID"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imjxsx/wapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Framework for developing bots for the WhatsApp application: fast, secure, and elegant, powered by Baileys and developed 100% in TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,10 +20,7 @@
|
|
|
20
20
|
"bot",
|
|
21
21
|
"whatsapp",
|
|
22
22
|
"baileys",
|
|
23
|
-
"lightweight",
|
|
24
|
-
"typescript",
|
|
25
23
|
"framework",
|
|
26
|
-
"nodejs",
|
|
27
24
|
"wapi"
|
|
28
25
|
],
|
|
29
26
|
"author": "imjxsx",
|
|
@@ -39,24 +36,27 @@
|
|
|
39
36
|
"@hapi/boom": "10.0.1",
|
|
40
37
|
"@imjxsx/logger": "1.1.1",
|
|
41
38
|
"autolinker": "4.1.5",
|
|
42
|
-
"baileys": "7.0.0-rc.
|
|
43
|
-
"cheerio": "1.1.2"
|
|
39
|
+
"baileys": "7.0.0-rc.9",
|
|
40
|
+
"cheerio": "1.1.2",
|
|
41
|
+
"long": "5.3.2"
|
|
44
42
|
},
|
|
45
43
|
"devDependencies": {
|
|
46
44
|
"@types/node": "20.19.5",
|
|
47
45
|
"@types/qrcode": "1.5.6",
|
|
46
|
+
"esbuild": "0.27.0",
|
|
47
|
+
"ioredis": "5.8.2",
|
|
48
|
+
"mongodb": "7.0.0",
|
|
48
49
|
"qrcode": "1.5.4",
|
|
49
50
|
"tsx": "4.20.6",
|
|
50
|
-
"typescript": "5.9.3"
|
|
51
|
-
"ioredis": "5.8.2",
|
|
52
|
-
"long": "5.3.2",
|
|
53
|
-
"mongodb": "7.0.0"
|
|
51
|
+
"typescript": "5.9.3"
|
|
54
52
|
},
|
|
55
53
|
"engines": {
|
|
56
54
|
"node": ">=20.0.0"
|
|
57
55
|
},
|
|
58
56
|
"scripts": {
|
|
59
|
-
"dev": "
|
|
60
|
-
"build": "
|
|
57
|
+
"dev": "node ./example/index",
|
|
58
|
+
"build": "pnpm run build:types && pnpm run build:js",
|
|
59
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
60
|
+
"build:js": "esbuild './src/**/*.ts' --outbase=src --outdir=dist --format=esm --platform=node --target=es2022 --sourcemap --minify --packages=external"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/dist/auth/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/auth/index.js
DELETED
package/dist/auth/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
package/dist/auth/local.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/auth/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,qBAAa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,KAAK,CAAC,CAAsB;IAC7B,IAAI,EAAE,IAAI,CAAC;gBACN,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM;YAQ3B,GAAG;YAoBH,GAAG;YAmBH,MAAM;IAMP,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IA0C7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAIrC"}
|
package/dist/auth/local.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { initAuthCreds, proto } from "baileys";
|
|
4
|
-
import { AES256GCM, FS, isBuffer, isString, isUint8Array, isUUID } from "../utils/index.js";
|
|
5
|
-
export class LocalAuth {
|
|
6
|
-
directory;
|
|
7
|
-
aes;
|
|
8
|
-
cache = new Map();
|
|
9
|
-
creds;
|
|
10
|
-
uuid;
|
|
11
|
-
constructor(uuid, directory) {
|
|
12
|
-
if (!isUUID(uuid)) {
|
|
13
|
-
throw new Error(`'${uuid}' is not a valid UUID.`);
|
|
14
|
-
}
|
|
15
|
-
this.directory = path.isAbsolute(directory) ? path.join(directory, uuid) : path.resolve(directory, uuid);
|
|
16
|
-
this.aes = new AES256GCM(uuid);
|
|
17
|
-
this.uuid = uuid;
|
|
18
|
-
}
|
|
19
|
-
async get(key) {
|
|
20
|
-
const md5 = createHash("md5").update(key).digest("hex");
|
|
21
|
-
const filepath = path.join(this.directory, `${md5}.enc`);
|
|
22
|
-
const encrypted = this.cache.get(md5) ?? await FS.readfile(filepath);
|
|
23
|
-
if (!isBuffer(encrypted)) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
this.cache.set(md5, encrypted);
|
|
27
|
-
const decrypted = this.aes.decrypt(encrypted);
|
|
28
|
-
if (!isBuffer(decrypted)) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const parsed = JSON.parse(decrypted.toString("utf8"), (_, value) => {
|
|
32
|
-
if (value?.type !== "Buffer" && !isString(value?.data)) {
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
return Buffer.from(value.data, "base64");
|
|
36
|
-
});
|
|
37
|
-
return parsed;
|
|
38
|
-
}
|
|
39
|
-
async set(key, value) {
|
|
40
|
-
const md5 = createHash("md5").update(key).digest("hex");
|
|
41
|
-
const filepath = path.join(this.directory, `${md5}.enc`);
|
|
42
|
-
const stringified = JSON.stringify(value, (_, value) => {
|
|
43
|
-
if (!isBuffer(value) && !isUint8Array(value) && value?.type !== "Buffer") {
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
type: "Buffer",
|
|
48
|
-
data: Buffer.from(value.data ?? value).toString("base64"),
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
const encrypted = this.aes.encrypt(Buffer.from(stringified, "utf8"));
|
|
52
|
-
if (!isBuffer(encrypted)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
await FS.writefile(filepath, encrypted);
|
|
56
|
-
this.cache.set(md5, encrypted);
|
|
57
|
-
}
|
|
58
|
-
async delete(key) {
|
|
59
|
-
const md5 = createHash("md5").update(key).digest("hex");
|
|
60
|
-
const filepath = path.join(this.directory, `${md5}.enc`);
|
|
61
|
-
await FS.rm(filepath);
|
|
62
|
-
this.cache.delete(md5);
|
|
63
|
-
}
|
|
64
|
-
async init() {
|
|
65
|
-
if (!(await FS.exists(this.directory))) {
|
|
66
|
-
await FS.mkdir(this.directory);
|
|
67
|
-
}
|
|
68
|
-
this.creds = await this.get("creds") ?? initAuthCreds();
|
|
69
|
-
const keys = {
|
|
70
|
-
get: async (type, ids) => {
|
|
71
|
-
const value = {};
|
|
72
|
-
const tasks = [];
|
|
73
|
-
for (const id of ids) {
|
|
74
|
-
const task = async () => {
|
|
75
|
-
let data = await this.get(`${type}-${id}`);
|
|
76
|
-
if (data !== null && type === "app-state-sync-key") {
|
|
77
|
-
data = proto.Message.AppStateSyncKeyData.fromObject(data);
|
|
78
|
-
}
|
|
79
|
-
value[id] = data;
|
|
80
|
-
};
|
|
81
|
-
tasks.push(task());
|
|
82
|
-
}
|
|
83
|
-
await Promise.all(tasks);
|
|
84
|
-
return value;
|
|
85
|
-
},
|
|
86
|
-
set: async (data) => {
|
|
87
|
-
const tasks = [];
|
|
88
|
-
for (const type of Object.keys(data)) {
|
|
89
|
-
if (!data[type]) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
for (const id of Object.keys(data[type])) {
|
|
93
|
-
const value = data[type][id];
|
|
94
|
-
const task = value ? this.set(`${type}-${id}`, value) : this.delete(`${type}-${id}`);
|
|
95
|
-
tasks.push(task);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
await Promise.all(tasks);
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
creds: this.creds,
|
|
103
|
-
keys,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
async save() {
|
|
107
|
-
if (!this.creds) {
|
|
108
|
-
throw new Error("Credentials not loaded.");
|
|
109
|
-
}
|
|
110
|
-
await this.set("creds", this.creds);
|
|
111
|
-
}
|
|
112
|
-
async remove() {
|
|
113
|
-
await FS.rm(this.directory);
|
|
114
|
-
this.cache.clear();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=local.js.map
|
package/dist/auth/local.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/auth/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAyE,MAAM,SAAS,CAAC;AAEtH,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE5F,MAAM,OAAO,SAAS;IACZ,SAAS,CAAS;IAClB,GAAG,CAAY;IACf,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,KAAK,CAAuB;IAC7B,IAAI,CAAO;IAClB,YAAY,IAAU,EAAE,SAAiB;QACvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,wBAAwB,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACzG,IAAI,CAAC,GAAG,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACO,KAAK,CAAC,GAAG,CAAI,GAAW;QA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