miaw-core 0.9.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/CHANGELOG.md +305 -0
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/USAGE.md +1399 -0
- package/babel.config.js +5 -0
- package/dist/client/MiawClient.d.ts +580 -0
- package/dist/client/MiawClient.d.ts.map +1 -0
- package/dist/client/MiawClient.js +2637 -0
- package/dist/client/MiawClient.js.map +1 -0
- package/dist/handlers/AuthHandler.d.ts +21 -0
- package/dist/handlers/AuthHandler.d.ts.map +1 -0
- package/dist/handlers/AuthHandler.js +30 -0
- package/dist/handlers/AuthHandler.js.map +1 -0
- package/dist/handlers/MessageHandler.d.ts +45 -0
- package/dist/handlers/MessageHandler.d.ts.map +1 -0
- package/dist/handlers/MessageHandler.js +185 -0
- package/dist/handlers/MessageHandler.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +632 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +44 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/storage.d.ts +25 -0
- package/dist/utils/storage.d.ts.map +1 -0
- package/dist/utils/storage.js +60 -0
- package/dist/utils/storage.js.map +1 -0
- package/package.json +44 -0
- package/tsconfig.json +24 -0
- package/tsconfig.test.json +13 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles file-based session storage for authentication state
|
|
3
|
+
*/
|
|
4
|
+
export declare class SessionStorage {
|
|
5
|
+
private sessionDir;
|
|
6
|
+
private sessionFile;
|
|
7
|
+
constructor(sessionPath: string, instanceId: string);
|
|
8
|
+
/**
|
|
9
|
+
* Check if session file exists
|
|
10
|
+
*/
|
|
11
|
+
exists(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Load session data from file
|
|
14
|
+
*/
|
|
15
|
+
load(): any;
|
|
16
|
+
/**
|
|
17
|
+
* Save session data to file
|
|
18
|
+
*/
|
|
19
|
+
save(data: any): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get the session file path
|
|
22
|
+
*/
|
|
23
|
+
getFilePath(): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAS;gBAEhB,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAUnD;;OAEG;IACH,MAAM,IAAI,OAAO;IAIjB;;OAEG;IACH,IAAI,IAAI,GAAG;IAcX;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IASrB;;OAEG;IACH,WAAW,IAAI,MAAM;CAGtB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionStorage = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* Handles file-based session storage for authentication state
|
|
8
|
+
*/
|
|
9
|
+
class SessionStorage {
|
|
10
|
+
constructor(sessionPath, instanceId) {
|
|
11
|
+
this.sessionDir = sessionPath;
|
|
12
|
+
this.sessionFile = (0, path_1.join)(sessionPath, `${instanceId}.json`);
|
|
13
|
+
// Ensure session directory exists
|
|
14
|
+
if (!(0, fs_1.existsSync)(this.sessionDir)) {
|
|
15
|
+
(0, fs_1.mkdirSync)(this.sessionDir, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check if session file exists
|
|
20
|
+
*/
|
|
21
|
+
exists() {
|
|
22
|
+
return (0, fs_1.existsSync)(this.sessionFile);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Load session data from file
|
|
26
|
+
*/
|
|
27
|
+
load() {
|
|
28
|
+
try {
|
|
29
|
+
if (!this.exists()) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const data = (0, fs_1.readFileSync)(this.sessionFile, 'utf-8');
|
|
33
|
+
return JSON.parse(data);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Failed to load session:', error);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Save session data to file
|
|
42
|
+
*/
|
|
43
|
+
save(data) {
|
|
44
|
+
try {
|
|
45
|
+
(0, fs_1.writeFileSync)(this.sessionFile, JSON.stringify(data, null, 2), 'utf-8');
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error('Failed to save session:', error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the session file path
|
|
54
|
+
*/
|
|
55
|
+
getFilePath() {
|
|
56
|
+
return this.sessionFile;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.SessionStorage = SessionStorage;
|
|
60
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":";;;AAAA,2BAAwE;AACxE,+BAA4B;AAE5B;;GAEG;AACH,MAAa,cAAc;IAIzB,YAAY,WAAmB,EAAE,UAAkB;QACjD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,GAAG,UAAU,OAAO,CAAC,CAAC;QAE3D,kCAAkC;QAClC,IAAI,CAAC,IAAA,eAAU,EAAC,IA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ileys - Multiple Instance of App WhatsApp",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"prepublishOnly": "npm run build",
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"test:watch": "jest --watch",
|
|
13
|
+
"test:coverage": "jest --coverage"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"whatsapp",
|
|
17
|
+
"baileys",
|
|
18
|
+
"whatsapp-api",
|
|
19
|
+
"whatsapp-bot",
|
|
20
|
+
"multi-instance"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@hapi/boom": "^10.0.1",
|
|
26
|
+
"@whiskeysockets/baileys": "^6.7.21",
|
|
27
|
+
"pino": "^8.19.0",
|
|
28
|
+
"qrcode-terminal": "^0.12.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@babel/preset-env": "^7.28.5",
|
|
32
|
+
"@types/jest": "^29.5.12",
|
|
33
|
+
"@types/node": "^20.11.19",
|
|
34
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
35
|
+
"babel-jest": "^30.2.0",
|
|
36
|
+
"dotenv": "^16.4.5",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"ts-jest": "^29.1.2",
|
|
39
|
+
"typescript": "^5.3.3"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationMap": true,
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"noImplicitReturns": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*"],
|
|
23
|
+
"exclude": ["node_modules", "dist", "examples", "tests", "**/*.test.ts"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"types": ["jest", "node"],
|
|
6
|
+
"noUnusedLocals": false,
|
|
7
|
+
"noUnusedParameters": false,
|
|
8
|
+
"outDir": "./dist-test",
|
|
9
|
+
"rootDir": "./"
|
|
10
|
+
},
|
|
11
|
+
"include": ["tests/**/*", "src/**/*"],
|
|
12
|
+
"exclude": ["node_modules", "dist", "examples"]
|
|
13
|
+
}
|