floating-live 0.14.5 → 0.14.7
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/plugin/acfun/index.d.ts +3 -6
- package/plugin/acfun/index.js +2 -1
- package/plugin/bilibili/index.d.ts +2 -2
- package/plugin/bilibili/index.js +30 -12
- package/plugin/bilibili/utils.d.ts +1 -1
- package/plugin/bilibili/utils.js +25 -40
- package/src/abstract/Reglist.d.ts +2 -0
- package/src/abstract/Reglist.js +4 -0
- package/src/module/ModAuth.d.ts +3 -1
- package/src/module/ModAuth.js +7 -1
- package/src/module/ModPlugin.d.ts +1 -1
- package/src/types/auth.d.ts +19 -0
- package/src/types/auth.js +2 -0
- package/src/types/index.d.ts +1 -0
- package/src/types/index.js +1 -0
- package/src/types/plugin.d.ts +3 -3
- package/src/types/room.d.ts +15 -16
package/package.json
CHANGED
package/plugin/acfun/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
register: (ctx: FloatingLive) => void;
|
|
5
|
-
};
|
|
6
|
-
export = _default;
|
|
1
|
+
import { FloatingLivePlugin } from "../../src/types";
|
|
2
|
+
declare const acfun: FloatingLivePlugin;
|
|
3
|
+
export = acfun;
|
package/plugin/acfun/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const acfunLive_1 = __importDefault(require("./acfunLive"));
|
|
6
|
-
|
|
6
|
+
const acfun = () => {
|
|
7
7
|
return {
|
|
8
8
|
name: "acfun",
|
|
9
9
|
register: (ctx) => {
|
|
@@ -13,3 +13,4 @@ module.exports = () => {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
module.exports = acfun;
|
package/plugin/bilibili/index.js
CHANGED
|
@@ -3,18 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const room_1 = __importDefault(require("./room"));
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
auth: {
|
|
9
|
-
placeholder: "此处粘贴cookie",
|
|
10
|
-
info: "请在登录后的b站页面中获取cookie并粘贴在输入框内,至少包含SESSDATA字段。",
|
|
11
|
-
},
|
|
12
|
-
qrcode: {
|
|
13
|
-
// generate: () => {},
|
|
14
|
-
},
|
|
15
|
-
// verify: { name: "key", type: "string" },
|
|
16
|
-
};
|
|
17
|
-
module.exports = () => {
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const bilibili = () => {
|
|
18
8
|
return {
|
|
19
9
|
name: "bilibili",
|
|
20
10
|
register: (ctx) => {
|
|
@@ -22,6 +12,34 @@ module.exports = () => {
|
|
|
22
12
|
return new room_1.default(Number(id), open, config);
|
|
23
13
|
});
|
|
24
14
|
ctx.auth.options.register("bilibili", authConfig);
|
|
15
|
+
ctx.command.register("auth.bilibili", async (auth) => {
|
|
16
|
+
const uid = await (0, utils_1.getLoginUid)(auth);
|
|
17
|
+
ctx.auth.account["bilibili"] = uid;
|
|
18
|
+
ctx.auth.set("bilibili", auth);
|
|
19
|
+
ctx.emit("auth:update", "bilibili", uid);
|
|
20
|
+
});
|
|
21
|
+
ctx.command.register("auth.bilibili.qrcode.get", () => {
|
|
22
|
+
return (0, utils_1.generateLoginQRcode)();
|
|
23
|
+
});
|
|
24
|
+
ctx.command.register("auth.bilibili.qrcode.check", async (key) => {
|
|
25
|
+
const [code, auth] = await (0, utils_1.checkLoginQRcode)(key);
|
|
26
|
+
if (auth) {
|
|
27
|
+
const { SESSDATA, DedeUserID } = (0, utils_1.parseCookieString)(auth);
|
|
28
|
+
ctx.auth.account["bilibili"] = DedeUserID;
|
|
29
|
+
ctx.auth.set("bilibili", `SESSDATA=${SESSDATA}`);
|
|
30
|
+
ctx.emit("auth:update", "bilibili", DedeUserID);
|
|
31
|
+
}
|
|
32
|
+
return code;
|
|
33
|
+
});
|
|
25
34
|
},
|
|
26
35
|
};
|
|
27
36
|
};
|
|
37
|
+
const authConfig = {
|
|
38
|
+
auth: {
|
|
39
|
+
type: "cookie",
|
|
40
|
+
},
|
|
41
|
+
qrcode: {
|
|
42
|
+
type: "url",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
module.exports = bilibili;
|
|
@@ -13,4 +13,4 @@ export declare function generateLoginQRcode(): Promise<{
|
|
|
13
13
|
/** 在终端打印登录二维码 */
|
|
14
14
|
export declare function printQRcode(url: string): void;
|
|
15
15
|
/** 检测登录二维码 */
|
|
16
|
-
export declare function checkLoginQRcode(key: string): Promise<
|
|
16
|
+
export declare function checkLoginQRcode(key: string): Promise<(string | number | null)[]>;
|
package/plugin/bilibili/utils.js
CHANGED
|
@@ -92,49 +92,34 @@ function printQRcode(url) {
|
|
|
92
92
|
}
|
|
93
93
|
exports.printQRcode = printQRcode;
|
|
94
94
|
/** 检测登录二维码 */
|
|
95
|
-
function checkLoginQRcode(key) {
|
|
96
|
-
return new Promise((resolve, reject) => {
|
|
97
|
-
let timer = 0;
|
|
98
|
-
const pollFuction = async () => {
|
|
99
|
-
clearTimeout(timer);
|
|
100
|
-
const res = await fetch(`https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=${key}`, {
|
|
101
|
-
headers: {
|
|
102
|
-
"User-Agent": USER_AGENT,
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
const { code, message } = (await res.json()).data;
|
|
106
|
-
if (code == 86101) {
|
|
107
|
-
console.log("未扫码");
|
|
108
|
-
timer = setTimeout(pollFuction, 1000);
|
|
109
|
-
}
|
|
110
|
-
else if (code == 86090) {
|
|
111
|
-
console.log("等待确认");
|
|
112
|
-
timer = setTimeout(pollFuction, 1000);
|
|
113
|
-
}
|
|
114
|
-
else if (code == 0) {
|
|
115
|
-
console.log("登录成功");
|
|
116
|
-
const a = res.headers.get("set-cookie");
|
|
117
|
-
resolve(a);
|
|
118
|
-
}
|
|
119
|
-
else if (code == 86038) {
|
|
120
|
-
console.log("二维码失效");
|
|
121
|
-
resolve("");
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
console.log(`${code} ${message}`);
|
|
125
|
-
resolve("");
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
timer = setTimeout(pollFuction, 1000);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
exports.checkLoginQRcode = checkLoginQRcode;
|
|
132
|
-
/** 轮询登录二维码 */
|
|
133
|
-
async function pollLoginQRCode(key) {
|
|
95
|
+
async function checkLoginQRcode(key) {
|
|
134
96
|
const res = await fetch(`https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=${key}`, {
|
|
135
97
|
headers: {
|
|
136
98
|
"User-Agent": USER_AGENT,
|
|
137
99
|
},
|
|
138
100
|
});
|
|
139
|
-
|
|
101
|
+
const { code, message } = (await res.json()).data;
|
|
102
|
+
if (code == 86101) {
|
|
103
|
+
// 未扫码
|
|
104
|
+
return [1];
|
|
105
|
+
}
|
|
106
|
+
else if (code == 86090) {
|
|
107
|
+
// 等待确认
|
|
108
|
+
return [2];
|
|
109
|
+
}
|
|
110
|
+
else if (code == 0) {
|
|
111
|
+
// 登录成功
|
|
112
|
+
const cookie = res.headers.get("set-cookie");
|
|
113
|
+
return [0, cookie];
|
|
114
|
+
}
|
|
115
|
+
else if (code == 86038) {
|
|
116
|
+
// 二维码失效
|
|
117
|
+
return [-1];
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// 其他错误
|
|
121
|
+
console.log(`${code} ${message}`);
|
|
122
|
+
throw message;
|
|
123
|
+
}
|
|
140
124
|
}
|
|
125
|
+
exports.checkLoginQRcode = checkLoginQRcode;
|
package/src/abstract/Reglist.js
CHANGED
package/src/module/ModAuth.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Reglist } from "../abstract/Reglist";
|
|
2
2
|
import { FloatingLive } from "..";
|
|
3
|
+
import { AuthOptions } from "../types/auth";
|
|
3
4
|
export declare class ModAuth {
|
|
4
|
-
options: Reglist<
|
|
5
|
+
options: Reglist<AuthOptions>;
|
|
6
|
+
account: Record<string, string | number>;
|
|
5
7
|
main: FloatingLive;
|
|
6
8
|
constructor(main: FloatingLive);
|
|
7
9
|
set(name: string, auth: string): void;
|
package/src/module/ModAuth.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.ModAuth = void 0;
|
|
|
4
4
|
const Reglist_1 = require("../abstract/Reglist");
|
|
5
5
|
class ModAuth {
|
|
6
6
|
constructor(main) {
|
|
7
|
+
this.account = {};
|
|
7
8
|
this.options = new Reglist_1.Reglist(main, "auth.options");
|
|
8
9
|
this.main = main;
|
|
9
10
|
this.main.state.register("auth", () => {
|
|
@@ -17,7 +18,12 @@ class ModAuth {
|
|
|
17
18
|
});
|
|
18
19
|
this.main.command.batchRegister({
|
|
19
20
|
auth: (platform, auth) => {
|
|
20
|
-
this.
|
|
21
|
+
if (this.main.command.has(`auth.${platform}`)) {
|
|
22
|
+
this.main.command.execute(`auth.${platform}`, auth);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.set(platform, auth);
|
|
26
|
+
}
|
|
21
27
|
},
|
|
22
28
|
});
|
|
23
29
|
}
|
|
@@ -14,7 +14,7 @@ export declare class ModPlugin<T extends FloatingLive> {
|
|
|
14
14
|
/** 访问插件操作对象 */
|
|
15
15
|
access(name: string): object | undefined;
|
|
16
16
|
/** 注册插件 */
|
|
17
|
-
register(pluginFunc: FloatingLivePlugin<
|
|
17
|
+
register<C extends object, E extends void | object>(pluginFunc: FloatingLivePlugin<C, E>, pluginConfig?: C): {} | undefined;
|
|
18
18
|
/** 移除插件 */
|
|
19
19
|
unregister(name: string): void;
|
|
20
20
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface AuthOptions {
|
|
2
|
+
/** 直接输入凭证 */
|
|
3
|
+
auth: {
|
|
4
|
+
/** 凭证类型 */
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
/** 二维码登录 */
|
|
8
|
+
qrcode?: {
|
|
9
|
+
/** 二维码类型 */
|
|
10
|
+
type: "url" | "base64";
|
|
11
|
+
};
|
|
12
|
+
/** 验证码登录 */
|
|
13
|
+
verify?: {
|
|
14
|
+
/** 验证码发送等待间隔(秒) */
|
|
15
|
+
wait: number;
|
|
16
|
+
/** 第三方验证接口 */
|
|
17
|
+
captcha?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
package/src/types/index.d.ts
CHANGED
package/src/types/index.js
CHANGED
package/src/types/plugin.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FloatingLive } from "..";
|
|
2
2
|
/** 插件模块, 加载时调用 */
|
|
3
|
-
export declare type FloatingLivePlugin<
|
|
3
|
+
export declare type FloatingLivePlugin<C extends object = object, E extends object | void = object | void> = () => {
|
|
4
4
|
/** 插件名称 */
|
|
5
5
|
name: string;
|
|
6
|
-
register: (ctx:
|
|
7
|
-
destroy?: (ctx:
|
|
6
|
+
register: (ctx: FloatingLive, config?: C) => E;
|
|
7
|
+
destroy?: (ctx: FloatingLive) => void;
|
|
8
8
|
};
|
package/src/types/room.d.ts
CHANGED
|
@@ -27,16 +27,16 @@ export interface RoomInfo {
|
|
|
27
27
|
connected: boolean;
|
|
28
28
|
}
|
|
29
29
|
/** 房间展示信息 */
|
|
30
|
-
export
|
|
30
|
+
export interface RoomDetail {
|
|
31
31
|
/** 直播标题 */
|
|
32
32
|
title?: string;
|
|
33
33
|
/** 分区 */
|
|
34
34
|
area?: string[];
|
|
35
35
|
/** 封面 */
|
|
36
36
|
cover?: string;
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
/** 房间统计数据信息 */
|
|
39
|
-
export
|
|
39
|
+
export interface RoomStatsInfo {
|
|
40
40
|
/** 点赞数 */
|
|
41
41
|
like?: number;
|
|
42
42
|
/** 观看数 */
|
|
@@ -45,7 +45,7 @@ export declare type RoomStatsInfo = {
|
|
|
45
45
|
online?: number;
|
|
46
46
|
/** 人气值 */
|
|
47
47
|
popularity?: number;
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
export interface PlatformInfo {
|
|
50
50
|
/** 平台名称 */
|
|
51
51
|
name: string;
|
|
@@ -67,20 +67,19 @@ export interface PlatformInfo {
|
|
|
67
67
|
/** 粉丝vip名称 */
|
|
68
68
|
name: string;
|
|
69
69
|
/** 粉丝vip等级名称 */
|
|
70
|
-
level?: string;
|
|
70
|
+
level?: string[];
|
|
71
71
|
};
|
|
72
72
|
/** 礼物信息 */
|
|
73
73
|
gift: {
|
|
74
|
-
|
|
75
|
-
currency: Array<{
|
|
76
|
-
/** 货币id */
|
|
77
|
-
id: string;
|
|
78
|
-
/** 货币名称 */
|
|
79
|
-
name: string;
|
|
80
|
-
/** 1货币面值等值value (1面值/1数值) */
|
|
81
|
-
face: number;
|
|
82
|
-
/** 1人民币等值value (1.00CNY/1数值) (若为0则为免费货币) */
|
|
83
|
-
cny?: number;
|
|
84
|
-
}>;
|
|
74
|
+
action: string;
|
|
85
75
|
};
|
|
76
|
+
/** 货币信息 */
|
|
77
|
+
currency: Record<string, {
|
|
78
|
+
/** 货币名称 */
|
|
79
|
+
name: string;
|
|
80
|
+
/** 1货币面值等值value (1面值/1数值) */
|
|
81
|
+
face: number;
|
|
82
|
+
/** 1人民币等值value (1.00CNY/1数值) (若为0则为免费货币) */
|
|
83
|
+
cny?: number;
|
|
84
|
+
}>;
|
|
86
85
|
}
|