rubjs 2.8.7 → 2.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/package.json +1 -1
- package/rubjs/client.d.ts +7 -3
- package/rubjs/client.js +1 -1
- package/rubjs/clients/index.d.ts +4 -0
- package/rubjs/clients/index.js +12 -0
- package/rubjs/{utils → clients}/loginClient.d.ts +12 -1
- package/rubjs/{utils → clients}/loginClient.js +9 -7
- package/rubjs/index.d.ts +3 -2
- package/rubjs/index.js +5 -4
- package/rubjs/session/index.d.ts +6 -1
- package/rubjs/session/index.js +12 -4
- package/rubjs/utils/index.d.ts +1 -4
- package/rubjs/utils/index.js +1 -7
- /package/rubjs/{utils → clients}/VoiceChatClient.d.ts +0 -0
- /package/rubjs/{utils → clients}/VoiceChatClient.js +0 -0
- /package/rubjs/{utils → clients}/sendLiveClient.d.ts +0 -0
- /package/rubjs/{utils → clients}/sendLiveClient.js +0 -0
package/package.json
CHANGED
package/rubjs/client.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import Methods from "./methods";
|
2
2
|
import Network from "./network";
|
3
3
|
import SessionManager from "./session";
|
4
|
-
import { VoiceChatClient } from "./
|
4
|
+
import { VoiceChatClient } from "./clients";
|
5
5
|
interface Platform {
|
6
6
|
app_name: string;
|
7
7
|
app_version: string;
|
@@ -11,6 +11,10 @@ interface Platform {
|
|
11
11
|
}
|
12
12
|
type TypeUpdate = "show_activities" | "chat_updates" | "message_updates" | "show_notifications";
|
13
13
|
type PlatformType = "Web" | "Android";
|
14
|
+
interface SessionType {
|
15
|
+
iv: string;
|
16
|
+
encryptedData: string;
|
17
|
+
}
|
14
18
|
declare class Client extends Methods {
|
15
19
|
defaultPlatform: Platform;
|
16
20
|
apiVersion: string;
|
@@ -21,7 +25,7 @@ declare class Client extends Methods {
|
|
21
25
|
timeout: number;
|
22
26
|
network: Network;
|
23
27
|
privateKey: string | null;
|
24
|
-
sessionFile: string;
|
28
|
+
sessionFile: string | SessionType;
|
25
29
|
platform: PlatformType;
|
26
30
|
userGuid: string | null;
|
27
31
|
sessionDb: SessionManager;
|
@@ -32,6 +36,6 @@ declare class Client extends Methods {
|
|
32
36
|
updateType: TypeUpdate;
|
33
37
|
}[];
|
34
38
|
voiceChatClient: VoiceChatClient;
|
35
|
-
constructor(sessionFile: string, timeout?: number, platform?: PlatformType);
|
39
|
+
constructor(sessionFile: string | SessionType, timeout?: number, platform?: PlatformType);
|
36
40
|
}
|
37
41
|
export default Client;
|
package/rubjs/client.js
CHANGED
@@ -28,8 +28,8 @@ class Client extends methods_1.default {
|
|
28
28
|
this.timeout = timeout !== null && timeout !== void 0 ? timeout : 0;
|
29
29
|
this.eventHandlers = [];
|
30
30
|
this.platform = platform;
|
31
|
-
this.sessionDb = new session_1.default(sessionFile);
|
32
31
|
this.network = new network_1.default(this);
|
32
|
+
this.sessionDb = new session_1.default(sessionFile);
|
33
33
|
this.auth = null;
|
34
34
|
this.privateKey = null;
|
35
35
|
this.eventHandlers = [];
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.LoginClient = exports.SendLiveClient = exports.VoiceChatClient = void 0;
|
7
|
+
const VoiceChatClient_1 = __importDefault(require("./VoiceChatClient"));
|
8
|
+
exports.VoiceChatClient = VoiceChatClient_1.default;
|
9
|
+
const sendLiveClient_1 = __importDefault(require("./sendLiveClient"));
|
10
|
+
exports.SendLiveClient = sendLiveClient_1.default;
|
11
|
+
const loginClient_1 = __importDefault(require("./loginClient"));
|
12
|
+
exports.LoginClient = loginClient_1.default;
|
@@ -18,9 +18,20 @@ interface AuthFace {
|
|
18
18
|
declare class LoginClient {
|
19
19
|
static systemVersions: Record<string, string>;
|
20
20
|
static sendCode(phone_number: string, pass_key?: string): Promise<AuthResult>;
|
21
|
-
static signIn(phone_code: string,
|
21
|
+
static signIn(phone_code: string, datas: AuthResult, sessionPath?: string): Promise<{
|
22
22
|
isOk: boolean;
|
23
23
|
status: string;
|
24
|
+
sessionData?: undefined;
|
25
|
+
} | {
|
26
|
+
isOk: boolean;
|
27
|
+
status: string;
|
28
|
+
sessionData: {
|
29
|
+
phone: any;
|
30
|
+
auth: string;
|
31
|
+
guid: any;
|
32
|
+
agent: string;
|
33
|
+
private_key: any;
|
34
|
+
};
|
24
35
|
}>;
|
25
36
|
static registerDevice(network: Network, datas: AuthFace): Promise<void>;
|
26
37
|
static getBrowser(userAgent: string, langCode: string, appVersion: string): Promise<{
|
@@ -40,7 +40,7 @@ class LoginClient {
|
|
40
40
|
};
|
41
41
|
});
|
42
42
|
}
|
43
|
-
static signIn(phone_code,
|
43
|
+
static signIn(phone_code, datas, sessionPath) {
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
45
45
|
const network = new loginNetwork_1.default();
|
46
46
|
const [publicKey, privateKey] = crypto_1.default.createKeys();
|
@@ -63,22 +63,24 @@ class LoginClient {
|
|
63
63
|
auth.key = Buffer.from(crypto_1.default.passphrase(sampleAuth), "utf8");
|
64
64
|
auth.auth = sampleAuth;
|
65
65
|
auth.decode_auth = crypto_1.default.decode_auth(sampleAuth);
|
66
|
-
|
67
|
-
|
66
|
+
yield this.registerDevice(network, auth);
|
67
|
+
const sessionData = {
|
68
68
|
phone: response.user.phone,
|
69
69
|
auth: auth.auth,
|
70
70
|
guid: response.user.user_guid,
|
71
71
|
agent: network.userAgent,
|
72
72
|
private_key: privateKey,
|
73
|
-
}
|
74
|
-
|
75
|
-
|
73
|
+
};
|
74
|
+
if (sessionPath) {
|
75
|
+
const session = new session_1.default(sessionPath);
|
76
|
+
session.saveSession(sessionData);
|
77
|
+
}
|
78
|
+
return { isOk: true, status: "Sucessfull", sessionData };
|
76
79
|
});
|
77
80
|
}
|
78
81
|
static registerDevice(network, datas) {
|
79
82
|
return __awaiter(this, void 0, void 0, function* () {
|
80
83
|
const browserData = yield this.getBrowser(network.userAgent, network.defaultPlatform.lang_code, network.defaultPlatform.app_version);
|
81
|
-
const sendData = {};
|
82
84
|
yield network.bulder("registerDevice", browserData, datas);
|
83
85
|
});
|
84
86
|
}
|
package/rubjs/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import Client from "./client";
|
2
2
|
import Crypto from "./crypto";
|
3
3
|
import * as Types from "./types";
|
4
|
-
import { Filters, Utils
|
4
|
+
import { Filters, Utils } from "./utils";
|
5
|
+
import { VoiceChatClient, SendLiveClient, LoginClient } from "./clients";
|
5
6
|
export default Client;
|
6
|
-
export {
|
7
|
+
export { Utils, Types, Crypto, Client, Filters, LoginClient, SendLiveClient, VoiceChatClient };
|
package/rubjs/index.js
CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
37
37
|
};
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
exports.
|
39
|
+
exports.VoiceChatClient = exports.SendLiveClient = exports.LoginClient = exports.Filters = exports.Client = exports.Crypto = exports.Types = exports.Utils = void 0;
|
40
40
|
const client_1 = __importDefault(require("./client"));
|
41
41
|
exports.Client = client_1.default;
|
42
42
|
const crypto_1 = __importDefault(require("./crypto"));
|
@@ -46,7 +46,8 @@ exports.Types = Types;
|
|
46
46
|
const utils_1 = require("./utils");
|
47
47
|
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return utils_1.Filters; } });
|
48
48
|
Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return utils_1.Utils; } });
|
49
|
-
|
50
|
-
Object.defineProperty(exports, "
|
51
|
-
Object.defineProperty(exports, "
|
49
|
+
const clients_1 = require("./clients");
|
50
|
+
Object.defineProperty(exports, "VoiceChatClient", { enumerable: true, get: function () { return clients_1.VoiceChatClient; } });
|
51
|
+
Object.defineProperty(exports, "SendLiveClient", { enumerable: true, get: function () { return clients_1.SendLiveClient; } });
|
52
|
+
Object.defineProperty(exports, "LoginClient", { enumerable: true, get: function () { return clients_1.LoginClient; } });
|
52
53
|
exports.default = client_1.default;
|
package/rubjs/session/index.d.ts
CHANGED
@@ -5,11 +5,16 @@ interface SessionData {
|
|
5
5
|
agent: string;
|
6
6
|
private_key: string;
|
7
7
|
}
|
8
|
+
interface SessionType {
|
9
|
+
iv: string;
|
10
|
+
encryptedData: string;
|
11
|
+
}
|
8
12
|
declare class SessionManager {
|
9
13
|
private secretKey;
|
10
14
|
private filename;
|
11
15
|
private iv;
|
12
|
-
|
16
|
+
private sessionData;
|
17
|
+
constructor(filename: string | SessionType);
|
13
18
|
private encrypt;
|
14
19
|
private decrypt;
|
15
20
|
saveSession(sessionData: SessionData): void;
|
package/rubjs/session/index.js
CHANGED
@@ -9,7 +9,9 @@ class SessionManager {
|
|
9
9
|
constructor(filename) {
|
10
10
|
this.secretKey = "12345678901234567890123456789012";
|
11
11
|
this.iv = crypto_1.default.randomBytes(16);
|
12
|
-
this.filename =
|
12
|
+
this.filename =
|
13
|
+
typeof filename === "string" ? `${filename}.json` : `${Date.now()}.json`;
|
14
|
+
this.sessionData = typeof filename !== "string" && filename;
|
13
15
|
}
|
14
16
|
encrypt(sessionData) {
|
15
17
|
const cipher = crypto_1.default.createCipheriv("aes-256-cbc", Buffer.from(this.secretKey), this.iv);
|
@@ -33,7 +35,7 @@ class SessionManager {
|
|
33
35
|
}
|
34
36
|
getSession() {
|
35
37
|
try {
|
36
|
-
if (!fs_1.default.existsSync(this.filename)) {
|
38
|
+
if (!this.sessionData && !fs_1.default.existsSync(this.filename)) {
|
37
39
|
const defaultSessionData = {
|
38
40
|
phone: "",
|
39
41
|
auth: "",
|
@@ -44,8 +46,14 @@ class SessionManager {
|
|
44
46
|
this.saveSession(defaultSessionData);
|
45
47
|
return defaultSessionData;
|
46
48
|
}
|
47
|
-
|
48
|
-
|
49
|
+
let parsedData;
|
50
|
+
if (this.sessionData) {
|
51
|
+
parsedData = this.sessionData;
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
const rawData = fs_1.default.readFileSync(this.filename, "utf8");
|
55
|
+
parsedData = JSON.parse(rawData);
|
56
|
+
}
|
49
57
|
return this.decrypt(parsedData.encryptedData, Buffer.from(parsedData.iv, "hex"));
|
50
58
|
}
|
51
59
|
catch (error) {
|
package/rubjs/utils/index.d.ts
CHANGED
@@ -1,6 +1,3 @@
|
|
1
1
|
import Filters from "./filters";
|
2
2
|
import Utils from "./utils";
|
3
|
-
|
4
|
-
import SendLiveClient from "./sendLiveClient";
|
5
|
-
import LoginClient from "./loginClient";
|
6
|
-
export { Filters, Utils, VoiceChatClient, SendLiveClient, LoginClient };
|
3
|
+
export { Filters, Utils };
|
package/rubjs/utils/index.js
CHANGED
@@ -3,14 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
6
|
+
exports.Utils = exports.Filters = void 0;
|
7
7
|
const filters_1 = __importDefault(require("./filters"));
|
8
8
|
exports.Filters = filters_1.default;
|
9
9
|
const utils_1 = __importDefault(require("./utils"));
|
10
10
|
exports.Utils = utils_1.default;
|
11
|
-
const VoiceChatClient_1 = __importDefault(require("./VoiceChatClient"));
|
12
|
-
exports.VoiceChatClient = VoiceChatClient_1.default;
|
13
|
-
const sendLiveClient_1 = __importDefault(require("./sendLiveClient"));
|
14
|
-
exports.SendLiveClient = sendLiveClient_1.default;
|
15
|
-
const loginClient_1 = __importDefault(require("./loginClient"));
|
16
|
-
exports.LoginClient = loginClient_1.default;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|