kicksdk-js 0.0.0-stage → 0.1.1
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 +36 -2
- package/index.d.ts +34 -0
- package/index.js +220 -0
- package/package.json +20 -4
- package/pkg/kicksdk.d.ts +366 -0
- package/pkg/kicksdk.js +1485 -0
- package/pkg/kicksdk_bg.wasm +0 -0
- package/pkg/kicksdk_bg.wasm.d.ts +67 -0
package/README.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# kicksdk-js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
kicksdk for JavaScript. (On npm the name is `kicksdk-js`: npm treats
|
|
4
|
+
`kicksdk` as too close to the unrelated `kick-sdk`.)
|
|
5
|
+
|
|
6
|
+
Kick (kick.com) without the I/O: requests, response parsers, the realtime chat
|
|
7
|
+
protocol and webhook verification, compiled from the
|
|
8
|
+
[kicksdk](https://github.com/AnisAbdellatif/kicksdk) Rust core to WebAssembly,
|
|
9
|
+
plus `connectChat`, which drives Kick's chat feed with `fetch` and `WebSocket`.
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import * as kick from 'kicksdk-js';
|
|
13
|
+
await kick.init(); // in Node: kick.init(fs.readFileSync(wasmPath))
|
|
14
|
+
|
|
15
|
+
const chat = kick.connectChat({
|
|
16
|
+
chatroomId,
|
|
17
|
+
channelId,
|
|
18
|
+
onEvent: ({ event }) => {
|
|
19
|
+
if (event.type === 'chat_message') console.log(`${event.sender.username}: ${event.content}`);
|
|
20
|
+
},
|
|
21
|
+
onState: ({ connected, subscribed }) => {},
|
|
22
|
+
});
|
|
23
|
+
chat.close();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Where the feed works.** Kick's realtime server only accepts a WebSocket whose
|
|
27
|
+
Origin is `https://kick.com`. Node: works (the driver sets the header). Browser:
|
|
28
|
+
only on kick.com - a page there or an extension's content script. Elsewhere,
|
|
29
|
+
relay through a server.
|
|
30
|
+
|
|
31
|
+
Everything else - `channelRequest` / `parseChannel`, `historyRequest`,
|
|
32
|
+
`livestreamsRequests`, `verifyWebhook`, `parseEvent`, `parseContent`, … -
|
|
33
|
+
returns plain request objects for your `fetch` and parses what comes back.
|
|
34
|
+
Parsers throw an `Error` with a `status` when Kick answered with an error.
|
|
35
|
+
|
|
36
|
+
See the repository's `docs/KICK.md` for everything known about Kick, with
|
|
37
|
+
sources. MIT OR Apache-2.0. Not affiliated with Kick.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export * from './pkg/kicksdk.js';
|
|
2
|
+
|
|
3
|
+
/** The Origin Kick's realtime server accepts. */
|
|
4
|
+
export const REQUIRED_ORIGIN: 'https://kick.com';
|
|
5
|
+
|
|
6
|
+
/** Loads the WebAssembly: a URL, a Response, or the .wasm bytes. */
|
|
7
|
+
export function init(input?: string | URL | Request | Response | BufferSource): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export interface ChatEvent {
|
|
10
|
+
/** The feed it came on, e.g. `chatrooms.668.v2`. */
|
|
11
|
+
channel: string;
|
|
12
|
+
/** Kick's event name, e.g. `App\\Events\\ChatMessageEvent`. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Its data as Kick sent it (usually a JSON string). */
|
|
15
|
+
data: unknown;
|
|
16
|
+
/** The same, typed: `{ type: 'chat_message', … }`. */
|
|
17
|
+
event: { type: string; [key: string]: unknown };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ChatOptions {
|
|
21
|
+
chatroomId: number;
|
|
22
|
+
channelId?: number;
|
|
23
|
+
channels?: string[];
|
|
24
|
+
onEvent(e: ChatEvent): void;
|
|
25
|
+
onState?(s: { connected: boolean; subscribed: string[] }): void;
|
|
26
|
+
onDrop?(reason: string): void;
|
|
27
|
+
fetch?: typeof fetch;
|
|
28
|
+
createSocket?(url: string): WebSocket;
|
|
29
|
+
endpoints?: Partial<{ api: string; id: string; website: string; realtime: string }>;
|
|
30
|
+
now?(): number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Connects to one channel's chat and keeps it up until `close()`. */
|
|
34
|
+
export function connectChat(options: ChatOptions): { close(): void };
|
package/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// kicksdk for JavaScript: the WebAssembly build of the Rust core, plus
|
|
2
|
+
// connectChat(), which drives the realtime protocol with fetch, WebSocket and
|
|
3
|
+
// timers.
|
|
4
|
+
//
|
|
5
|
+
// Call `await init()` once before anything else (in Node, or anywhere the .wasm
|
|
6
|
+
// cannot be fetched beside this file, pass its bytes: `init(bytes)`).
|
|
7
|
+
//
|
|
8
|
+
// Where it works: Kick's realtime server only takes a socket whose Origin is
|
|
9
|
+
// https://kick.com. Node sets that header itself (see `createSocket` below); a
|
|
10
|
+
// browser cannot, so in a browser connectChat only works on kick.com - a page
|
|
11
|
+
// there, or an extension's content script. Elsewhere, relay through a server.
|
|
12
|
+
|
|
13
|
+
import initWasm, {
|
|
14
|
+
initSync,
|
|
15
|
+
Session,
|
|
16
|
+
Backoff,
|
|
17
|
+
chatChannels,
|
|
18
|
+
chatConnectionRequest,
|
|
19
|
+
connectionRequest,
|
|
20
|
+
parseConnection,
|
|
21
|
+
tokenRequest,
|
|
22
|
+
parseToken
|
|
23
|
+
} from './pkg/kicksdk.js';
|
|
24
|
+
|
|
25
|
+
export * from './pkg/kicksdk.js';
|
|
26
|
+
|
|
27
|
+
export const REQUIRED_ORIGIN = 'https://kick.com';
|
|
28
|
+
|
|
29
|
+
let ready = null;
|
|
30
|
+
|
|
31
|
+
/** Loads the WebAssembly. Safe to call more than once. */
|
|
32
|
+
export function init(input) {
|
|
33
|
+
if (!ready) {
|
|
34
|
+
if (input instanceof Uint8Array || input instanceof ArrayBuffer) {
|
|
35
|
+
initSync({ module: input });
|
|
36
|
+
ready = Promise.resolve();
|
|
37
|
+
} else {
|
|
38
|
+
ready = initWasm(input === undefined ? undefined : { module_or_path: input });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return ready;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node);
|
|
45
|
+
|
|
46
|
+
function defaultSocket(url) {
|
|
47
|
+
// Node's WebSocket (undici) takes headers; a browser's ignores the argument
|
|
48
|
+
// and sends its own page's origin.
|
|
49
|
+
return isNode ? new WebSocket(url, { headers: { Origin: REQUIRED_ORIGIN } }) : new WebSocket(url);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function send(fetchImpl, req) {
|
|
53
|
+
// A browser drops the headers it forbids (origin, referer) and sends its own.
|
|
54
|
+
const res = await fetchImpl(req.url, {
|
|
55
|
+
method: req.method,
|
|
56
|
+
headers: Object.fromEntries(req.headers),
|
|
57
|
+
body: req.body ?? undefined,
|
|
58
|
+
credentials: 'omit'
|
|
59
|
+
});
|
|
60
|
+
return { status: res.status, body: await res.text() };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Connects to one channel's chat and keeps the connection up until close().
|
|
65
|
+
*
|
|
66
|
+
* @param {object} o
|
|
67
|
+
* @param {number} o.chatroomId the chatroom (website API `chatroom.id`)
|
|
68
|
+
* @param {number} [o.channelId] the channel; also locates the chat's region
|
|
69
|
+
* @param {string[]} [o.channels] feeds to subscribe to; chatChannels() by default
|
|
70
|
+
* @param {(e: {channel, name, data, event}) => void} o.onEvent
|
|
71
|
+
* @param {(s: {connected: boolean, subscribed: string[]}) => void} [o.onState]
|
|
72
|
+
* @param {(reason: string) => void} [o.onDrop] a connection ended (a new one follows)
|
|
73
|
+
* @param {typeof fetch} [o.fetch]
|
|
74
|
+
* @param {(url: string) => WebSocket} [o.createSocket]
|
|
75
|
+
* @param {object} [o.endpoints] overrides of Kick's URLs
|
|
76
|
+
* @param {() => number} [o.now]
|
|
77
|
+
* @returns {{ close(): void }}
|
|
78
|
+
*/
|
|
79
|
+
export function connectChat(o) {
|
|
80
|
+
const fetchImpl = o.fetch || ((...a) => fetch(...a));
|
|
81
|
+
const createSocket = o.createSocket || defaultSocket;
|
|
82
|
+
const now = o.now || (() => Date.now());
|
|
83
|
+
const channels = o.channels || chatChannels(o.chatroomId, o.channelId);
|
|
84
|
+
const backoff = new Backoff();
|
|
85
|
+
let closed = false;
|
|
86
|
+
let ws = null;
|
|
87
|
+
let session = null;
|
|
88
|
+
let timer = null;
|
|
89
|
+
let retry = null;
|
|
90
|
+
let clientId = null;
|
|
91
|
+
|
|
92
|
+
const state = () => {
|
|
93
|
+
if (o.onState && session) {
|
|
94
|
+
o.onState({ connected: session.isConnected(), subscribed: channels.filter((c) => session.isSubscribed(c)) });
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
function arm() {
|
|
99
|
+
clearTimeout(timer);
|
|
100
|
+
const at = session && session.deadline();
|
|
101
|
+
if (at !== undefined && at !== null) timer = setTimeout(() => apply(session.tick(now())), Math.max(0, at - now()));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function apply(actions) {
|
|
105
|
+
// Anything still in flight once close() has run - a timer, a token
|
|
106
|
+
// arriving - finds nothing left to act on.
|
|
107
|
+
if (closed || !session) return;
|
|
108
|
+
let changed = false;
|
|
109
|
+
for (const a of actions) {
|
|
110
|
+
switch (a.action) {
|
|
111
|
+
case 'send':
|
|
112
|
+
if (ws && ws.readyState === 1) ws.send(a.text);
|
|
113
|
+
break;
|
|
114
|
+
case 'close':
|
|
115
|
+
if (o.onDrop) o.onDrop(a.reason);
|
|
116
|
+
if (ws) ws.close();
|
|
117
|
+
break;
|
|
118
|
+
case 'refresh_token':
|
|
119
|
+
send(fetchImpl, tokenRequest(clientId, o.endpoints))
|
|
120
|
+
.then((r) => parseToken(r.status, r.body))
|
|
121
|
+
.then((token) => {
|
|
122
|
+
if (!closed && session) apply(session.refresh(token, now()));
|
|
123
|
+
})
|
|
124
|
+
.catch(() => {
|
|
125
|
+
// Kick ends the connection when the old token runs out; the
|
|
126
|
+
// reconnect fetches a new one.
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
129
|
+
case 'subscribed':
|
|
130
|
+
if (a.channel === channels[0]) backoff.reset();
|
|
131
|
+
changed = true;
|
|
132
|
+
break;
|
|
133
|
+
case 'connected':
|
|
134
|
+
case 'unsubscribed':
|
|
135
|
+
case 'subscribe_failed':
|
|
136
|
+
changed = true;
|
|
137
|
+
break;
|
|
138
|
+
case 'event':
|
|
139
|
+
o.onEvent({ channel: a.channel, name: a.name, data: a.data, event: a.event });
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (changed) state();
|
|
144
|
+
arm();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function again() {
|
|
148
|
+
if (closed) return;
|
|
149
|
+
clearTimeout(retry);
|
|
150
|
+
retry = setTimeout(connect, backoff.nextDelay());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function connect() {
|
|
154
|
+
if (closed) return;
|
|
155
|
+
// A guest identity: the token is issued to this id, and so is every
|
|
156
|
+
// refreshed one for this connection.
|
|
157
|
+
clientId = crypto.randomUUID();
|
|
158
|
+
let url;
|
|
159
|
+
let token;
|
|
160
|
+
try {
|
|
161
|
+
const where = o.channelId
|
|
162
|
+
? chatConnectionRequest(o.channelId, clientId, o.endpoints)
|
|
163
|
+
: connectionRequest(clientId, o.endpoints);
|
|
164
|
+
const c = await send(fetchImpl, where);
|
|
165
|
+
const found = parseConnection(c.status, c.body).find((x) => x.provider === 'centrifugo');
|
|
166
|
+
if (!found) throw new Error('Kick offered no Centrifugo server');
|
|
167
|
+
url = found.url;
|
|
168
|
+
const t = await send(fetchImpl, tokenRequest(clientId, o.endpoints));
|
|
169
|
+
token = parseToken(t.status, t.body);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
if (o.onDrop) o.onDrop(String((e && e.message) || e));
|
|
172
|
+
again();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (closed) return;
|
|
176
|
+
|
|
177
|
+
if (!session) session = new Session(channels);
|
|
178
|
+
let socket;
|
|
179
|
+
try {
|
|
180
|
+
socket = createSocket(url);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
again();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
ws = socket;
|
|
186
|
+
socket.onopen = () => apply(session.open(token, now()));
|
|
187
|
+
socket.onmessage = (e) => {
|
|
188
|
+
if (ws === socket) apply(session.receive(String(e.data), now()));
|
|
189
|
+
};
|
|
190
|
+
socket.onclose = () => {
|
|
191
|
+
if (ws !== socket) return;
|
|
192
|
+
ws = null;
|
|
193
|
+
clearTimeout(timer);
|
|
194
|
+
apply(session.closed());
|
|
195
|
+
state();
|
|
196
|
+
again();
|
|
197
|
+
};
|
|
198
|
+
socket.onerror = () => {};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
connect();
|
|
202
|
+
return {
|
|
203
|
+
close() {
|
|
204
|
+
closed = true;
|
|
205
|
+
clearTimeout(timer);
|
|
206
|
+
clearTimeout(retry);
|
|
207
|
+
if (ws) {
|
|
208
|
+
const s = ws;
|
|
209
|
+
ws = null;
|
|
210
|
+
s.onclose = null;
|
|
211
|
+
s.close();
|
|
212
|
+
}
|
|
213
|
+
if (session) {
|
|
214
|
+
session.free();
|
|
215
|
+
session = null;
|
|
216
|
+
}
|
|
217
|
+
backoff.free();
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kicksdk-js",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Kick (kick.com) without the I/O: requests, parsers, the realtime chat protocol and webhook verification, from one Rust core",
|
|
5
|
+
"license": "MIT OR Apache-2.0",
|
|
6
|
+
"repository": { "type": "git", "url": "git+https://github.com/AnisAbdellatif/kicksdk.git", "directory": "bindings/js" },
|
|
7
|
+
"keywords": ["kick", "kick.com", "chat", "streaming", "centrifugo", "webassembly"],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": { "types": "./index.d.ts", "default": "./index.js" },
|
|
13
|
+
"./kicksdk_bg.wasm": "./pkg/kicksdk_bg.wasm"
|
|
14
|
+
},
|
|
15
|
+
"files": ["index.js", "index.d.ts", "pkg/", "README.md"],
|
|
16
|
+
"engines": { "node": ">=22" },
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "../../scripts/build-js.sh",
|
|
20
|
+
"test": "node --test test/*.test.js"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/pkg/kicksdk.d.ts
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reconnect delays: 1 s doubling to 30 s.
|
|
6
|
+
*/
|
|
7
|
+
export class Backoff {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* From `initialMs`, doubling to `maxMs`.
|
|
12
|
+
*/
|
|
13
|
+
constructor(initial_ms?: number | null, max_ms?: number | null);
|
|
14
|
+
/**
|
|
15
|
+
* The next wait, ms.
|
|
16
|
+
*/
|
|
17
|
+
nextDelay(): number;
|
|
18
|
+
/**
|
|
19
|
+
* A connection worked.
|
|
20
|
+
*/
|
|
21
|
+
reset(): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One connection's protocol. Each method returns the actions to carry out.
|
|
26
|
+
*/
|
|
27
|
+
export class Session {
|
|
28
|
+
free(): void;
|
|
29
|
+
[Symbol.dispose](): void;
|
|
30
|
+
/**
|
|
31
|
+
* The socket closed.
|
|
32
|
+
*/
|
|
33
|
+
closed(): any;
|
|
34
|
+
/**
|
|
35
|
+
* When to call `tick` next, in ms, or undefined.
|
|
36
|
+
*/
|
|
37
|
+
deadline(): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Whether Kick accepted the connection.
|
|
40
|
+
*/
|
|
41
|
+
isConnected(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether a feed is subscribed.
|
|
44
|
+
*/
|
|
45
|
+
isSubscribed(channel: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* A session for these feeds.
|
|
48
|
+
*/
|
|
49
|
+
constructor(channels: string[]);
|
|
50
|
+
/**
|
|
51
|
+
* The socket opened.
|
|
52
|
+
*/
|
|
53
|
+
open(token: string, now: number): any;
|
|
54
|
+
/**
|
|
55
|
+
* A text frame arrived.
|
|
56
|
+
*/
|
|
57
|
+
receive(text: string, now: number): any;
|
|
58
|
+
/**
|
|
59
|
+
* A new token, after a `refresh_token` action.
|
|
60
|
+
*/
|
|
61
|
+
refresh(token: string, now: number): any;
|
|
62
|
+
/**
|
|
63
|
+
* The clock reached `deadline()`.
|
|
64
|
+
*/
|
|
65
|
+
tick(now: number): any;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* An app token request (client credentials).
|
|
70
|
+
*/
|
|
71
|
+
export function appTokenRequest(client_id: string, client_secret: string, endpoints_: any): any;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Bans a user for good.
|
|
75
|
+
*/
|
|
76
|
+
export function banRequest(session: string, channel_slug: string, username: string, endpoints_: any): any;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A channel by slug (`kick.com/api/v2`): chatroom id, followers, live state.
|
|
80
|
+
*/
|
|
81
|
+
export function channelRequest(slug: string, endpoints_: any): any;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A user as a channel sees them.
|
|
85
|
+
*/
|
|
86
|
+
export function channelUserRequest(channel_slug: string, username: string, endpoints_: any): any;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* `/channels` for up to 50 user ids.
|
|
90
|
+
*/
|
|
91
|
+
export function channelsByIdsRequest(token: string, user_ids: Float64Array, endpoints_: any): any;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* `/channels` for up to 50 slugs (one unknown slug fails them all).
|
|
95
|
+
*/
|
|
96
|
+
export function channelsBySlugsRequest(token: string, slugs: string[], endpoints_: any): any;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The feeds for one chat, the chat feed first.
|
|
100
|
+
*/
|
|
101
|
+
export function chatChannels(chatroom_id: number, channel_id?: number | null): string[];
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Where a channel's chat is served.
|
|
105
|
+
*/
|
|
106
|
+
export function chatConnectionRequest(channel_id: number, client_id: string, endpoints_: any): any;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Where Kick's realtime is served in general.
|
|
110
|
+
*/
|
|
111
|
+
export function connectionRequest(client_id: string, endpoints_: any): any;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Deletes a message.
|
|
115
|
+
*/
|
|
116
|
+
export function deleteMessageRequest(session: string, chatroom_id: number, message_id: string, endpoints_: any): any;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* An emote's image URL.
|
|
120
|
+
*/
|
|
121
|
+
export function emoteUrl(id: string): string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Recent chat and the pin, by channel id.
|
|
125
|
+
*/
|
|
126
|
+
export function historyRequest(channel_id: number, endpoints_: any): any;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* `/livestreams` for any number of user ids: one request per 50.
|
|
130
|
+
*/
|
|
131
|
+
export function livestreamsRequests(token: string, user_ids: Float64Array, endpoints_: any): any;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The signed-in viewer's standing on a channel.
|
|
135
|
+
*/
|
|
136
|
+
export function meRequest(session: string, channel_slug: string, endpoints_: any): any;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Whether an acting call worked; throws with `status` if not.
|
|
140
|
+
*/
|
|
141
|
+
export function parseAction(status: number, body: string): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Reads an app token answer.
|
|
145
|
+
*/
|
|
146
|
+
export function parseAppToken(status: number, body: string): any;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Reads a website channel answer.
|
|
150
|
+
*/
|
|
151
|
+
export function parseChannel(status: number, body: string): any;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Reads a channel user answer.
|
|
155
|
+
*/
|
|
156
|
+
export function parseChannelUser(status: number, body: string): any;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Reads a `/channels` answer.
|
|
160
|
+
*/
|
|
161
|
+
export function parseChannels(status: number, body: string): any;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Reads either connection answer: `[{provider, url}…]`.
|
|
165
|
+
*/
|
|
166
|
+
export function parseConnection(status: number, body: string): any;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* A message's text and emotes.
|
|
170
|
+
*/
|
|
171
|
+
export function parseContent(text: string, combine: boolean): any;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A feed event, typed: `{type: "chat_message", …}`. `data` as Kick sent it.
|
|
175
|
+
*/
|
|
176
|
+
export function parseEvent(name: string, data: any): any;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Reads a history answer: `{messages, pinned}`.
|
|
180
|
+
*/
|
|
181
|
+
export function parseHistory(status: number, body: string): any;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Reads a `/livestreams` answer.
|
|
185
|
+
*/
|
|
186
|
+
export function parseLivestreams(status: number, body: string): any;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Reads a `me` answer.
|
|
190
|
+
*/
|
|
191
|
+
export function parseMe(status: number, body: string): any;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The PEM from a public key answer.
|
|
195
|
+
*/
|
|
196
|
+
export function parsePublicKey(status: number, body: string): string;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Reads a subscriptions answer.
|
|
200
|
+
*/
|
|
201
|
+
export function parseSubscriptions(status: number, body: string): any;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The token from a token answer.
|
|
205
|
+
*/
|
|
206
|
+
export function parseToken(status: number, body: string): string;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Reads a delivery's body by its type header, without checking anything.
|
|
210
|
+
*/
|
|
211
|
+
export function parseWebhook(event_type: string, body: string): any;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Pins a message (the feed's data for it, whole) for `minutes`.
|
|
215
|
+
*/
|
|
216
|
+
export function pinRequest(session: string, channel_slug: string, message: any, minutes: number, endpoints_: any): any;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* The webhook signing key request.
|
|
220
|
+
*/
|
|
221
|
+
export function publicKeyRequest(endpoints_: any): any;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Sends a message, or a reply when `replyTo` is
|
|
225
|
+
* `{message_id, content, sender_id, sender_username}`.
|
|
226
|
+
*/
|
|
227
|
+
export function sendRequest(session: string, chatroom_id: number, text: string, message_ref: string, reply_to: any, endpoints_: any): any;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Subscribes the app to webhook `events` (`[{name, version}]`) for one channel.
|
|
231
|
+
*/
|
|
232
|
+
export function subscribeRequest(token: string, broadcaster_user_id: number, events: any, endpoints_: any): any;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Every webhook subscription the app has.
|
|
236
|
+
*/
|
|
237
|
+
export function subscriptionsRequest(token: string, endpoints_: any): any;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Times a user out.
|
|
241
|
+
*/
|
|
242
|
+
export function timeoutRequest(session: string, channel_slug: string, username: string, minutes: number, endpoints_: any): any;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* A guest token request for `clientId`.
|
|
246
|
+
*/
|
|
247
|
+
export function tokenRequest(client_id: string, endpoints_: any): any;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The top live streams, overall or in a category or language: up to 100.
|
|
251
|
+
* `sort` is `"viewer_count"` (the default) or `"started_at"`.
|
|
252
|
+
*/
|
|
253
|
+
export function topLivestreamsRequest(token: string, category_id: number | null | undefined, language: string | null | undefined, sort: string | null | undefined, limit: number | null | undefined, endpoints_: any): any;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Lifts a ban or timeout.
|
|
257
|
+
*/
|
|
258
|
+
export function unbanRequest(session: string, channel_slug: string, username: string, endpoints_: any): any;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Removes the pin.
|
|
262
|
+
*/
|
|
263
|
+
export function unpinRequest(session: string, channel_slug: string, endpoints_: any): any;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Removes subscriptions, 50 per request.
|
|
267
|
+
*/
|
|
268
|
+
export function unsubscribeRequests(token: string, ids: string[], endpoints_: any): any;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Checks a delivery: `headers` as `[[name, value]…]` or an object, `body` the
|
|
272
|
+
* raw text. Returns the typed event, or throws.
|
|
273
|
+
*/
|
|
274
|
+
export function verifyWebhook(public_key_pem: string, headers: any, body: string): any;
|
|
275
|
+
|
|
276
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
277
|
+
|
|
278
|
+
export interface InitOutput {
|
|
279
|
+
readonly memory: WebAssembly.Memory;
|
|
280
|
+
readonly __wbg_backoff_free: (a: number, b: number) => void;
|
|
281
|
+
readonly __wbg_session_free: (a: number, b: number) => void;
|
|
282
|
+
readonly appTokenRequest: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
283
|
+
readonly backoff_new: (a: number, b: number, c: number, d: number) => number;
|
|
284
|
+
readonly backoff_nextDelay: (a: number) => number;
|
|
285
|
+
readonly backoff_reset: (a: number) => void;
|
|
286
|
+
readonly banRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number, number];
|
|
287
|
+
readonly channelRequest: (a: number, b: number, c: any) => [number, number, number];
|
|
288
|
+
readonly channelUserRequest: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
289
|
+
readonly channelsByIdsRequest: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
290
|
+
readonly channelsBySlugsRequest: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
291
|
+
readonly chatChannels: (a: number, b: number, c: number) => [number, number];
|
|
292
|
+
readonly chatConnectionRequest: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
293
|
+
readonly connectionRequest: (a: number, b: number, c: any) => [number, number, number];
|
|
294
|
+
readonly deleteMessageRequest: (a: number, b: number, c: number, d: number, e: number, f: any) => [number, number, number];
|
|
295
|
+
readonly emoteUrl: (a: number, b: number) => [number, number];
|
|
296
|
+
readonly historyRequest: (a: number, b: any) => [number, number, number];
|
|
297
|
+
readonly livestreamsRequests: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
298
|
+
readonly meRequest: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
299
|
+
readonly parseAction: (a: number, b: number, c: number) => [number, number];
|
|
300
|
+
readonly parseAppToken: (a: number, b: number, c: number) => [number, number, number];
|
|
301
|
+
readonly parseChannel: (a: number, b: number, c: number) => [number, number, number];
|
|
302
|
+
readonly parseChannelUser: (a: number, b: number, c: number) => [number, number, number];
|
|
303
|
+
readonly parseChannels: (a: number, b: number, c: number) => [number, number, number];
|
|
304
|
+
readonly parseConnection: (a: number, b: number, c: number) => [number, number, number];
|
|
305
|
+
readonly parseContent: (a: number, b: number, c: number) => [number, number, number];
|
|
306
|
+
readonly parseEvent: (a: number, b: number, c: any) => [number, number, number];
|
|
307
|
+
readonly parseHistory: (a: number, b: number, c: number) => [number, number, number];
|
|
308
|
+
readonly parseLivestreams: (a: number, b: number, c: number) => [number, number, number];
|
|
309
|
+
readonly parseMe: (a: number, b: number, c: number) => [number, number, number];
|
|
310
|
+
readonly parsePublicKey: (a: number, b: number, c: number) => [number, number, number, number];
|
|
311
|
+
readonly parseSubscriptions: (a: number, b: number, c: number) => [number, number, number];
|
|
312
|
+
readonly parseToken: (a: number, b: number, c: number) => [number, number, number, number];
|
|
313
|
+
readonly parseWebhook: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
314
|
+
readonly pinRequest: (a: number, b: number, c: number, d: number, e: any, f: number, g: any) => [number, number, number];
|
|
315
|
+
readonly publicKeyRequest: (a: any) => [number, number, number];
|
|
316
|
+
readonly sendRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any, i: any) => [number, number, number];
|
|
317
|
+
readonly session_closed: (a: number) => [number, number, number];
|
|
318
|
+
readonly session_deadline: (a: number) => [number, number];
|
|
319
|
+
readonly session_isConnected: (a: number) => number;
|
|
320
|
+
readonly session_isSubscribed: (a: number, b: number, c: number) => number;
|
|
321
|
+
readonly session_new: (a: number, b: number) => number;
|
|
322
|
+
readonly session_open: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
323
|
+
readonly session_receive: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
324
|
+
readonly session_refresh: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
325
|
+
readonly session_tick: (a: number, b: number) => [number, number, number];
|
|
326
|
+
readonly subscribeRequest: (a: number, b: number, c: number, d: any, e: any) => [number, number, number];
|
|
327
|
+
readonly subscriptionsRequest: (a: number, b: number, c: any) => [number, number, number];
|
|
328
|
+
readonly timeoutRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => [number, number, number];
|
|
329
|
+
readonly tokenRequest: (a: number, b: number, c: any) => [number, number, number];
|
|
330
|
+
readonly topLivestreamsRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: any) => [number, number, number];
|
|
331
|
+
readonly unbanRequest: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number, number];
|
|
332
|
+
readonly unpinRequest: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
333
|
+
readonly unsubscribeRequests: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
334
|
+
readonly verifyWebhook: (a: number, b: number, c: any, d: number, e: number) => [number, number, number];
|
|
335
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
336
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
337
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
338
|
+
readonly __externref_table_alloc: () => number;
|
|
339
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
340
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
341
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
342
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
343
|
+
readonly __wbindgen_start: () => void;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
350
|
+
* a precompiled `WebAssembly.Module`.
|
|
351
|
+
*
|
|
352
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
353
|
+
*
|
|
354
|
+
* @returns {InitOutput}
|
|
355
|
+
*/
|
|
356
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
360
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
361
|
+
*
|
|
362
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
363
|
+
*
|
|
364
|
+
* @returns {Promise<InitOutput>}
|
|
365
|
+
*/
|
|
366
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|