rotur-sdk 1.0.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/dist/index.d.mts +985 -0
- package/dist/index.d.ts +985 -0
- package/dist/index.js +1067 -0
- package/dist/index.mjs +1036 -0
- package/package.json +31 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1067 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ApiError: () => ApiError,
|
|
24
|
+
AuthError: () => AuthError,
|
|
25
|
+
Rotur: () => Rotur,
|
|
26
|
+
RoturSocket: () => RoturSocket,
|
|
27
|
+
performAuth: () => performAuth
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/http.ts
|
|
32
|
+
var ApiError = class extends Error {
|
|
33
|
+
constructor(status, data) {
|
|
34
|
+
super(
|
|
35
|
+
typeof data === "object" && data !== null && "error" in data ? String(data.error) : `API error ${status}`
|
|
36
|
+
);
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.data = data;
|
|
39
|
+
this.name = "ApiError";
|
|
40
|
+
}
|
|
41
|
+
status;
|
|
42
|
+
data;
|
|
43
|
+
};
|
|
44
|
+
var Http = class {
|
|
45
|
+
baseUrl = "https://api.rotur.dev";
|
|
46
|
+
getToken;
|
|
47
|
+
constructor(getToken) {
|
|
48
|
+
this.getToken = getToken;
|
|
49
|
+
}
|
|
50
|
+
buildUrl(path, params) {
|
|
51
|
+
const url = new URL(path, this.baseUrl);
|
|
52
|
+
if (params) {
|
|
53
|
+
for (const [key, value] of Object.entries(params)) {
|
|
54
|
+
if (value === void 0 || value === null) continue;
|
|
55
|
+
url.searchParams.set(
|
|
56
|
+
key,
|
|
57
|
+
typeof value === "object" ? JSON.stringify(value) : String(value)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return url.toString();
|
|
62
|
+
}
|
|
63
|
+
async get(path, params, auth = true) {
|
|
64
|
+
const token = auth ? this.getToken() : null;
|
|
65
|
+
if (auth && !token)
|
|
66
|
+
throw new ApiError(401, {
|
|
67
|
+
error: "Not authenticated \u2014 call rotur.login() first"
|
|
68
|
+
});
|
|
69
|
+
const allParams = auth && token ? { ...params, auth: token } : params;
|
|
70
|
+
const res = await fetch(this.buildUrl(path, allParams));
|
|
71
|
+
return this.handle(res);
|
|
72
|
+
}
|
|
73
|
+
async post(path, body, auth = true) {
|
|
74
|
+
const token = auth ? this.getToken() : null;
|
|
75
|
+
if (auth && !token)
|
|
76
|
+
throw new ApiError(401, {
|
|
77
|
+
error: "Not authenticated \u2014 call rotur.login() first"
|
|
78
|
+
});
|
|
79
|
+
const opts = {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: { "Content-Type": "application/json" }
|
|
82
|
+
};
|
|
83
|
+
if (body !== void 0) opts.body = JSON.stringify(body);
|
|
84
|
+
const res = await fetch(
|
|
85
|
+
this.buildUrl(path, auth && token ? { auth: token } : void 0),
|
|
86
|
+
opts
|
|
87
|
+
);
|
|
88
|
+
return this.handle(res);
|
|
89
|
+
}
|
|
90
|
+
async patch(path, body) {
|
|
91
|
+
const token = this.getToken();
|
|
92
|
+
if (!token) throw new ApiError(401, { error: "Not authenticated" });
|
|
93
|
+
const opts = {
|
|
94
|
+
method: "PATCH",
|
|
95
|
+
headers: { "Content-Type": "application/json" }
|
|
96
|
+
};
|
|
97
|
+
if (body !== void 0) opts.body = JSON.stringify(body);
|
|
98
|
+
const res = await fetch(this.buildUrl(path, { auth: token }), opts);
|
|
99
|
+
return this.handle(res);
|
|
100
|
+
}
|
|
101
|
+
async del(path, body) {
|
|
102
|
+
const token = this.getToken();
|
|
103
|
+
if (!token) throw new ApiError(401, { error: "Not authenticated" });
|
|
104
|
+
const opts = {
|
|
105
|
+
method: "DELETE",
|
|
106
|
+
headers: { "Content-Type": "application/json" }
|
|
107
|
+
};
|
|
108
|
+
if (body !== void 0) opts.body = JSON.stringify(body);
|
|
109
|
+
const res = await fetch(this.buildUrl(path, { auth: token }), opts);
|
|
110
|
+
return this.handle(res);
|
|
111
|
+
}
|
|
112
|
+
async handle(res) {
|
|
113
|
+
const text = await res.text();
|
|
114
|
+
let data;
|
|
115
|
+
try {
|
|
116
|
+
data = JSON.parse(text);
|
|
117
|
+
} catch {
|
|
118
|
+
if (!res.ok) throw new ApiError(res.status, text);
|
|
119
|
+
return void 0;
|
|
120
|
+
}
|
|
121
|
+
if (!res.ok) throw new ApiError(res.status, data);
|
|
122
|
+
return data;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// src/websocket.ts
|
|
127
|
+
var RoturSocket = class extends EventTarget {
|
|
128
|
+
constructor(url = "wss://api.rotur.dev/status/ws") {
|
|
129
|
+
super();
|
|
130
|
+
this.url = url;
|
|
131
|
+
}
|
|
132
|
+
url;
|
|
133
|
+
ws = null;
|
|
134
|
+
token = null;
|
|
135
|
+
reconnectTimer = null;
|
|
136
|
+
heartbeat = null;
|
|
137
|
+
_connected = false;
|
|
138
|
+
_userId = null;
|
|
139
|
+
_username = null;
|
|
140
|
+
handlers = /* @__PURE__ */ new Map();
|
|
141
|
+
rooms = /* @__PURE__ */ new Set();
|
|
142
|
+
get connected() {
|
|
143
|
+
return this._connected;
|
|
144
|
+
}
|
|
145
|
+
get userId() {
|
|
146
|
+
return this._userId;
|
|
147
|
+
}
|
|
148
|
+
get username() {
|
|
149
|
+
return this._username;
|
|
150
|
+
}
|
|
151
|
+
get joinedRooms() {
|
|
152
|
+
return [...this.rooms];
|
|
153
|
+
}
|
|
154
|
+
connect(token) {
|
|
155
|
+
this.token = token;
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
this.cleanup();
|
|
158
|
+
this.ws = new WebSocket(this.url);
|
|
159
|
+
this.ws.onmessage = (e) => {
|
|
160
|
+
let msg;
|
|
161
|
+
try {
|
|
162
|
+
msg = JSON.parse(e.data);
|
|
163
|
+
} catch {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const cmd = msg.cmd;
|
|
167
|
+
if (cmd === "ready") {
|
|
168
|
+
this._connected = true;
|
|
169
|
+
this._userId = msg.user_id;
|
|
170
|
+
this._username = msg.username;
|
|
171
|
+
this.startHeartbeat();
|
|
172
|
+
resolve(msg);
|
|
173
|
+
}
|
|
174
|
+
if (cmd === "join_ok") this.rooms.add(msg.room);
|
|
175
|
+
if (cmd === "leave_ok") this.rooms.delete(msg.room);
|
|
176
|
+
this.emit(cmd, msg);
|
|
177
|
+
};
|
|
178
|
+
this.ws.onerror = (e) => {
|
|
179
|
+
if (!this._connected) reject(new Error("WebSocket connection failed"));
|
|
180
|
+
this.emit("error", e);
|
|
181
|
+
};
|
|
182
|
+
this.ws.onclose = () => {
|
|
183
|
+
this._connected = false;
|
|
184
|
+
this.emit("close", {});
|
|
185
|
+
this.scheduleReconnect();
|
|
186
|
+
};
|
|
187
|
+
this.send({ cmd: "auth", key: token });
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
startHeartbeat() {
|
|
191
|
+
this.heartbeat = setInterval(() => {
|
|
192
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
193
|
+
this.ws.send(JSON.stringify({ cmd: "ping" }));
|
|
194
|
+
}
|
|
195
|
+
}, 25e3);
|
|
196
|
+
}
|
|
197
|
+
scheduleReconnect() {
|
|
198
|
+
if (!this.token) return;
|
|
199
|
+
this.reconnectTimer = setTimeout(
|
|
200
|
+
() => this.connect(this.token).catch(() => {
|
|
201
|
+
}),
|
|
202
|
+
3e3
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
cleanup() {
|
|
206
|
+
if (this.heartbeat) clearInterval(this.heartbeat);
|
|
207
|
+
if (this.reconnectTimer) clearTimeout(this.reconnectTimer);
|
|
208
|
+
this.heartbeat = null;
|
|
209
|
+
this.reconnectTimer = null;
|
|
210
|
+
}
|
|
211
|
+
emit(cmd, msg) {
|
|
212
|
+
this.handlers.get(cmd)?.forEach((h) => h(msg));
|
|
213
|
+
this.dispatchEvent(new CustomEvent(cmd, { detail: msg }));
|
|
214
|
+
this.dispatchEvent(new CustomEvent("*", { detail: msg }));
|
|
215
|
+
}
|
|
216
|
+
send(packet) {
|
|
217
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
218
|
+
this.ws.send(JSON.stringify(packet));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
on(cmd, handler) {
|
|
222
|
+
if (!this.handlers.has(cmd)) this.handlers.set(cmd, /* @__PURE__ */ new Set());
|
|
223
|
+
this.handlers.get(cmd).add(handler);
|
|
224
|
+
return () => this.handlers.get(cmd)?.delete(handler);
|
|
225
|
+
}
|
|
226
|
+
off(cmd, handler) {
|
|
227
|
+
this.handlers.get(cmd)?.delete(handler);
|
|
228
|
+
}
|
|
229
|
+
once(cmd) {
|
|
230
|
+
return new Promise((resolve) => {
|
|
231
|
+
const h = (msg) => {
|
|
232
|
+
this.off(cmd, h);
|
|
233
|
+
resolve(msg);
|
|
234
|
+
};
|
|
235
|
+
this.on(cmd, h);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
join(rooms) {
|
|
239
|
+
this.send({ cmd: "join", rooms: Array.isArray(rooms) ? rooms : [rooms] });
|
|
240
|
+
}
|
|
241
|
+
leave(rooms) {
|
|
242
|
+
this.send({ cmd: "leave", rooms: Array.isArray(rooms) ? rooms : [rooms] });
|
|
243
|
+
}
|
|
244
|
+
listRooms() {
|
|
245
|
+
this.send({ cmd: "rooms" });
|
|
246
|
+
return this.once("rooms").then((m) => m.rooms);
|
|
247
|
+
}
|
|
248
|
+
roomState(room) {
|
|
249
|
+
this.send({ cmd: "room_state", room });
|
|
250
|
+
}
|
|
251
|
+
setPresence(presence) {
|
|
252
|
+
this.send({ cmd: "set_status", presence });
|
|
253
|
+
}
|
|
254
|
+
setStatus(status) {
|
|
255
|
+
this.send({ cmd: "set_status", status });
|
|
256
|
+
}
|
|
257
|
+
addActivity(activity) {
|
|
258
|
+
this.send({ cmd: "add_activity", ...activity });
|
|
259
|
+
}
|
|
260
|
+
removeActivity(id) {
|
|
261
|
+
this.send({ cmd: "remove_activity", id });
|
|
262
|
+
}
|
|
263
|
+
setMusic(application, media, title) {
|
|
264
|
+
this.send({
|
|
265
|
+
cmd: "add_activity",
|
|
266
|
+
id: application,
|
|
267
|
+
title: title ?? `Listening to ${application}`,
|
|
268
|
+
application: { name: application },
|
|
269
|
+
media
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
setPlaying(application, options) {
|
|
273
|
+
this.send({
|
|
274
|
+
cmd: "add_activity",
|
|
275
|
+
id: application,
|
|
276
|
+
title: options?.title ?? application,
|
|
277
|
+
application: { name: application, url: options?.url },
|
|
278
|
+
status: options?.status,
|
|
279
|
+
image: options?.image
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
clearActivity(id) {
|
|
283
|
+
this.send({ cmd: "remove_activity", id });
|
|
284
|
+
}
|
|
285
|
+
disconnect() {
|
|
286
|
+
this.token = null;
|
|
287
|
+
this.cleanup();
|
|
288
|
+
this.rooms.clear();
|
|
289
|
+
if (this.ws) {
|
|
290
|
+
this.ws.onclose = null;
|
|
291
|
+
this.ws.close();
|
|
292
|
+
this.ws = null;
|
|
293
|
+
}
|
|
294
|
+
this._connected = false;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// src/auth.ts
|
|
299
|
+
var AUTH_URL = "https://rotur.dev/auth";
|
|
300
|
+
var ORIGIN = "https://rotur.dev";
|
|
301
|
+
var AuthError = class extends Error {
|
|
302
|
+
constructor(code, message) {
|
|
303
|
+
super(message);
|
|
304
|
+
this.code = code;
|
|
305
|
+
this.name = "AuthError";
|
|
306
|
+
}
|
|
307
|
+
code;
|
|
308
|
+
};
|
|
309
|
+
function performAuth(options) {
|
|
310
|
+
if (options?.signal?.aborted) {
|
|
311
|
+
throw new AuthError("aborted", "Auth was aborted");
|
|
312
|
+
}
|
|
313
|
+
const timeout = options?.timeout ?? 12e4;
|
|
314
|
+
const authUrl = new URL(AUTH_URL);
|
|
315
|
+
if (options?.system) authUrl.searchParams.set("system", options.system);
|
|
316
|
+
let iframe;
|
|
317
|
+
return new Promise((resolve, reject) => {
|
|
318
|
+
const signal = options?.signal;
|
|
319
|
+
const rejectWithError = (code, msg) => {
|
|
320
|
+
cleanup();
|
|
321
|
+
reject(new AuthError(code, msg));
|
|
322
|
+
};
|
|
323
|
+
const timer = setTimeout(() => {
|
|
324
|
+
rejectWithError("timeout", `Auth timed out after ${timeout}ms`);
|
|
325
|
+
}, timeout);
|
|
326
|
+
const onAbort = () => rejectWithError("aborted", "Auth was aborted");
|
|
327
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
328
|
+
function handler(e) {
|
|
329
|
+
if (e.origin !== ORIGIN) return;
|
|
330
|
+
if (e.data?.type !== "rotur-auth-token") return;
|
|
331
|
+
if (!e.data.token) return;
|
|
332
|
+
cleanup();
|
|
333
|
+
resolve({ token: e.data.token });
|
|
334
|
+
}
|
|
335
|
+
function cleanup() {
|
|
336
|
+
clearTimeout(timer);
|
|
337
|
+
window.removeEventListener("message", handler);
|
|
338
|
+
signal?.removeEventListener("abort", onAbort);
|
|
339
|
+
iframe?.remove();
|
|
340
|
+
}
|
|
341
|
+
window.addEventListener("message", handler);
|
|
342
|
+
const w = window.open(
|
|
343
|
+
authUrl.toString(),
|
|
344
|
+
"rotur-auth",
|
|
345
|
+
"width=480,height=720"
|
|
346
|
+
);
|
|
347
|
+
if (w) return;
|
|
348
|
+
iframe = document.createElement("iframe");
|
|
349
|
+
iframe.style.cssText = "position:fixed;inset:0;width:100%;height:100%;border:none;z-index:9999";
|
|
350
|
+
iframe.src = authUrl.toString();
|
|
351
|
+
document.body.appendChild(iframe);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/client.ts
|
|
356
|
+
var Rotur = class {
|
|
357
|
+
_token = null;
|
|
358
|
+
_http;
|
|
359
|
+
socket;
|
|
360
|
+
me = new MeNamespace(this);
|
|
361
|
+
posts = new PostsNamespace(this);
|
|
362
|
+
friends = new FriendsNamespace(this);
|
|
363
|
+
following = new FollowingNamespace(this);
|
|
364
|
+
notifications = new NotificationsNamespace(this);
|
|
365
|
+
keys = new KeysNamespace(this);
|
|
366
|
+
items = new ItemsNamespace(this);
|
|
367
|
+
gifts = new GiftsNamespace(this);
|
|
368
|
+
tokens = new TokensNamespace(this);
|
|
369
|
+
groups = new GroupsNamespace(this);
|
|
370
|
+
systems = new SystemsNamespace(this);
|
|
371
|
+
stats = new StatsNamespace(this);
|
|
372
|
+
status = new StatusNamespace(this);
|
|
373
|
+
validators = new ValidatorsNamespace(this);
|
|
374
|
+
link = new LinkNamespace(this);
|
|
375
|
+
cosmetics = new CosmeticsNamespace(this);
|
|
376
|
+
push = new PushNamespace(this);
|
|
377
|
+
files = new FilesNamespace(this);
|
|
378
|
+
standing = new StandingNamespace(this);
|
|
379
|
+
profiles = new ProfilesNamespace(this);
|
|
380
|
+
devfund = new DevFundNamespace(this);
|
|
381
|
+
check = new CheckNamespace(this);
|
|
382
|
+
constructor(options) {
|
|
383
|
+
this._token = options?.token ?? null;
|
|
384
|
+
this._http = new Http(() => this._token);
|
|
385
|
+
this.socket = new RoturSocket(options?.wsUrl);
|
|
386
|
+
}
|
|
387
|
+
get token() {
|
|
388
|
+
return this._token;
|
|
389
|
+
}
|
|
390
|
+
get loggedIn() {
|
|
391
|
+
return this._token !== null;
|
|
392
|
+
}
|
|
393
|
+
setToken(token) {
|
|
394
|
+
this._token = token;
|
|
395
|
+
}
|
|
396
|
+
async login(options) {
|
|
397
|
+
const { token } = await performAuth(options);
|
|
398
|
+
this._token = token;
|
|
399
|
+
return this;
|
|
400
|
+
}
|
|
401
|
+
async connectSocket() {
|
|
402
|
+
if (!this._token) throw new ApiError(401, { error: "Login first" });
|
|
403
|
+
return this.socket.connect(this._token);
|
|
404
|
+
}
|
|
405
|
+
logout() {
|
|
406
|
+
this._token = null;
|
|
407
|
+
this.socket.disconnect();
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
var Namespace = class {
|
|
411
|
+
constructor(r) {
|
|
412
|
+
this.r = r;
|
|
413
|
+
}
|
|
414
|
+
r;
|
|
415
|
+
$get(path, params, auth = true) {
|
|
416
|
+
return this.r._http.get(path, params, auth);
|
|
417
|
+
}
|
|
418
|
+
$post(path, body, auth = true) {
|
|
419
|
+
return this.r._http.post(path, body, auth);
|
|
420
|
+
}
|
|
421
|
+
$patch(path, body) {
|
|
422
|
+
return this.r._http.patch(path, body);
|
|
423
|
+
}
|
|
424
|
+
$del(path, body) {
|
|
425
|
+
return this.r._http.del(path, body);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
var ProfilesNamespace = class extends Namespace {
|
|
429
|
+
async get(username, includePosts = true) {
|
|
430
|
+
return this.$get(
|
|
431
|
+
"/profile",
|
|
432
|
+
{ username, include_posts: includePosts ? "1" : "0" },
|
|
433
|
+
false
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
async exists(username) {
|
|
437
|
+
return this.$get("/exists", { username }, false);
|
|
438
|
+
}
|
|
439
|
+
async supporters() {
|
|
440
|
+
return this.$get("/supporters", void 0, false);
|
|
441
|
+
}
|
|
442
|
+
getAvatarUrl(username, cache = "") {
|
|
443
|
+
return `https://avatars.rotur.dev/${username}?v=${cache}`;
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
var MeNamespace = class extends Namespace {
|
|
447
|
+
async get() {
|
|
448
|
+
return this.$get("/me");
|
|
449
|
+
}
|
|
450
|
+
async update(key, value) {
|
|
451
|
+
return this.$post("/me/update", { key, value });
|
|
452
|
+
}
|
|
453
|
+
async deleteKey(key) {
|
|
454
|
+
return this.$del("/me/delete", { key });
|
|
455
|
+
}
|
|
456
|
+
async deleteAccount() {
|
|
457
|
+
return this.$del("/users");
|
|
458
|
+
}
|
|
459
|
+
async refreshToken() {
|
|
460
|
+
return this.$post("/me/refresh_token");
|
|
461
|
+
}
|
|
462
|
+
async transfer(to, amount, note) {
|
|
463
|
+
return this.$post("/me/transfer", { to, amount, note });
|
|
464
|
+
}
|
|
465
|
+
async claimDaily() {
|
|
466
|
+
return this.$get("/claim_daily");
|
|
467
|
+
}
|
|
468
|
+
async claimTime() {
|
|
469
|
+
return this.$get("/claim_time");
|
|
470
|
+
}
|
|
471
|
+
async badges() {
|
|
472
|
+
return this.$get("/badges");
|
|
473
|
+
}
|
|
474
|
+
async acceptTos() {
|
|
475
|
+
return this.$post("/accept_tos");
|
|
476
|
+
}
|
|
477
|
+
async abilities() {
|
|
478
|
+
return this.$get("/me/able");
|
|
479
|
+
}
|
|
480
|
+
async blocked() {
|
|
481
|
+
return this.$get("/me/blocked");
|
|
482
|
+
}
|
|
483
|
+
async block(username) {
|
|
484
|
+
return this.$post(`/me/block/${username}`);
|
|
485
|
+
}
|
|
486
|
+
async unblock(username) {
|
|
487
|
+
return this.$post(`/me/unblock/${username}`);
|
|
488
|
+
}
|
|
489
|
+
async note(username, content) {
|
|
490
|
+
return this.$post(`/me/note/${username}`, { content });
|
|
491
|
+
}
|
|
492
|
+
async deleteNote(username) {
|
|
493
|
+
return this.$del(`/me/note/${username}`);
|
|
494
|
+
}
|
|
495
|
+
async resendVerification() {
|
|
496
|
+
return this.$post("/me/resend_verification");
|
|
497
|
+
}
|
|
498
|
+
async verifyEmail(token) {
|
|
499
|
+
return this.$get("/verify_email", { token }, false);
|
|
500
|
+
}
|
|
501
|
+
async checkAuth() {
|
|
502
|
+
return this.$get("/check_auth");
|
|
503
|
+
}
|
|
504
|
+
async requests() {
|
|
505
|
+
return this.$get("/me", void 0).then((u) => ({
|
|
506
|
+
requests: u["sys.requests"] ?? []
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
async transactions() {
|
|
510
|
+
return this.$get("/me", void 0).then((u) => u["sys.transactions"] ?? []);
|
|
511
|
+
}
|
|
512
|
+
async subscription() {
|
|
513
|
+
return this.$get("/me", void 0).then((u) => u["sys.subscription"] ?? { active: false, tier: "Free", next_billing: 0 });
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
var PostsNamespace = class extends Namespace {
|
|
517
|
+
async create(content, options) {
|
|
518
|
+
const params = { content };
|
|
519
|
+
if (options?.attachment) params.attachment = options.attachment;
|
|
520
|
+
if (options?.profileOnly) params.profile_only = "1";
|
|
521
|
+
if (options?.os) params.os = options.os;
|
|
522
|
+
return this.$get("/post", params);
|
|
523
|
+
}
|
|
524
|
+
async delete(id) {
|
|
525
|
+
return this.$get("/delete", { id });
|
|
526
|
+
}
|
|
527
|
+
async like(id) {
|
|
528
|
+
return this.$get("/rate", { id, rating: 1 });
|
|
529
|
+
}
|
|
530
|
+
async unlike(id) {
|
|
531
|
+
return this.$get("/rate", { id, rating: 0 });
|
|
532
|
+
}
|
|
533
|
+
async reply(id, content) {
|
|
534
|
+
return this.$get("/reply", { id, content });
|
|
535
|
+
}
|
|
536
|
+
async repost(id) {
|
|
537
|
+
return this.$get("/repost", { id });
|
|
538
|
+
}
|
|
539
|
+
async pin(id) {
|
|
540
|
+
return this.$get("/pin_post", { id });
|
|
541
|
+
}
|
|
542
|
+
async unpin(id) {
|
|
543
|
+
return this.$get("/unpin_post", { id });
|
|
544
|
+
}
|
|
545
|
+
async feed(limit = 100, offset = 0) {
|
|
546
|
+
return this.$get("/feed", { limit, offset }, false);
|
|
547
|
+
}
|
|
548
|
+
async followingFeed(limit = 100) {
|
|
549
|
+
return this.$get("/following_feed", { limit });
|
|
550
|
+
}
|
|
551
|
+
async top(limit = 50, timePeriod = 24) {
|
|
552
|
+
return this.$get("/top_posts", { limit, time_period: timePeriod }, false);
|
|
553
|
+
}
|
|
554
|
+
async search(query, limit = 20) {
|
|
555
|
+
return this.$get("/search_posts", { q: query, limit }, false);
|
|
556
|
+
}
|
|
557
|
+
async limits() {
|
|
558
|
+
return this.$get("/limits", void 0, false);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
var FriendsNamespace = class extends Namespace {
|
|
562
|
+
async list() {
|
|
563
|
+
return this.$get("/friends");
|
|
564
|
+
}
|
|
565
|
+
async request(username) {
|
|
566
|
+
return this.$post(`/friends/request/${username}`);
|
|
567
|
+
}
|
|
568
|
+
async accept(username) {
|
|
569
|
+
return this.$post(`/friends/accept/${username}`);
|
|
570
|
+
}
|
|
571
|
+
async reject(username) {
|
|
572
|
+
return this.$post(`/friends/reject/${username}`);
|
|
573
|
+
}
|
|
574
|
+
async remove(username) {
|
|
575
|
+
return this.$post(`/friends/remove/${username}`);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
var FollowingNamespace = class extends Namespace {
|
|
579
|
+
async follow(username) {
|
|
580
|
+
return this.$get("/follow", { username });
|
|
581
|
+
}
|
|
582
|
+
async unfollow(username) {
|
|
583
|
+
return this.$get("/unfollow", { username });
|
|
584
|
+
}
|
|
585
|
+
async followers(username) {
|
|
586
|
+
return this.$get("/followers", { username }, false);
|
|
587
|
+
}
|
|
588
|
+
async following(username) {
|
|
589
|
+
return this.$get("/following", { username }, false);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
var NotificationsNamespace = class extends Namespace {
|
|
593
|
+
async list(afterDays = 1) {
|
|
594
|
+
return this.$get("/notifications", { after: afterDays });
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
var KeysNamespace = class extends Namespace {
|
|
598
|
+
async create(name, options) {
|
|
599
|
+
const params = { name };
|
|
600
|
+
if (options?.description) params.description = options.description;
|
|
601
|
+
if (options?.price !== void 0) params.price = String(options.price);
|
|
602
|
+
if (options?.subscription) params.subscription = "true";
|
|
603
|
+
if (options?.frequency) params.frequency = String(options.frequency);
|
|
604
|
+
if (options?.period) params.period = options.period;
|
|
605
|
+
return this.$get("/keys/create", params);
|
|
606
|
+
}
|
|
607
|
+
async mine() {
|
|
608
|
+
return this.$get("/keys/mine");
|
|
609
|
+
}
|
|
610
|
+
async get(id) {
|
|
611
|
+
return this.$get(`/keys/get/${id}`, void 0, false);
|
|
612
|
+
}
|
|
613
|
+
async check(username, key) {
|
|
614
|
+
return this.$get(`/keys/check/${username}`, { key }, false);
|
|
615
|
+
}
|
|
616
|
+
async rename(id, name) {
|
|
617
|
+
return this.$get(`/keys/name/${id}`, { name });
|
|
618
|
+
}
|
|
619
|
+
async update(id, key, data) {
|
|
620
|
+
return this.$get(`/keys/update/${id}`, { key, data });
|
|
621
|
+
}
|
|
622
|
+
async revoke(id, user) {
|
|
623
|
+
return this.$get(`/keys/revoke/${id}`, { user });
|
|
624
|
+
}
|
|
625
|
+
async delete(id) {
|
|
626
|
+
return this.$get(`/keys/delete/${id}`);
|
|
627
|
+
}
|
|
628
|
+
async addUser(id, user) {
|
|
629
|
+
return this.$get(`/keys/admin_add/${id}`, { user });
|
|
630
|
+
}
|
|
631
|
+
async removeUser(id, user) {
|
|
632
|
+
return this.$get(`/keys/admin_remove/${id}`, { user });
|
|
633
|
+
}
|
|
634
|
+
async buy(id) {
|
|
635
|
+
return this.$get(`/keys/buy/${id}`);
|
|
636
|
+
}
|
|
637
|
+
async cancel(id) {
|
|
638
|
+
return this.$get(`/keys/cancel/${id}`);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
var ItemsNamespace = class extends Namespace {
|
|
642
|
+
async create(item) {
|
|
643
|
+
return this.$get("/items/create", { item: JSON.stringify(item) });
|
|
644
|
+
}
|
|
645
|
+
async get(name) {
|
|
646
|
+
return this.$get(`/items/get/${name}`, void 0, false);
|
|
647
|
+
}
|
|
648
|
+
async list(username) {
|
|
649
|
+
return this.$get(`/items/list/${username}`, void 0, false);
|
|
650
|
+
}
|
|
651
|
+
async selling(limit = 50) {
|
|
652
|
+
return this.$get("/items/selling", { limit }, false);
|
|
653
|
+
}
|
|
654
|
+
async buy(name) {
|
|
655
|
+
return this.$get(`/items/buy/${name}`);
|
|
656
|
+
}
|
|
657
|
+
async transfer(name, username) {
|
|
658
|
+
return this.$get(`/items/transfer/${name}`, { username });
|
|
659
|
+
}
|
|
660
|
+
async sell(name) {
|
|
661
|
+
return this.$get(`/items/sell/${name}`);
|
|
662
|
+
}
|
|
663
|
+
async stopSelling(name) {
|
|
664
|
+
return this.$get(`/items/stop_selling/${name}`);
|
|
665
|
+
}
|
|
666
|
+
async setPrice(name, price) {
|
|
667
|
+
return this.$get(`/items/set_price/${name}`, { price: String(price) });
|
|
668
|
+
}
|
|
669
|
+
async update(name, data) {
|
|
670
|
+
return this.$get(`/items/update/${name}`, { data: JSON.stringify(data) });
|
|
671
|
+
}
|
|
672
|
+
async delete(name) {
|
|
673
|
+
return this.$get(`/items/delete/${name}`);
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
var GiftsNamespace = class extends Namespace {
|
|
677
|
+
async create(amount, options) {
|
|
678
|
+
return this.$post("/gifts/create", {
|
|
679
|
+
amount,
|
|
680
|
+
note: options?.note,
|
|
681
|
+
expires_in_hrs: options?.expiresInHrs
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
async get(code) {
|
|
685
|
+
return this.$get(`/gifts/${code}`, void 0, false);
|
|
686
|
+
}
|
|
687
|
+
async claim(code) {
|
|
688
|
+
return this.$post(`/gifts/claim/${code}`);
|
|
689
|
+
}
|
|
690
|
+
async cancel(id) {
|
|
691
|
+
return this.$post(`/gifts/cancel/${id}`);
|
|
692
|
+
}
|
|
693
|
+
async mine() {
|
|
694
|
+
return this.$get("/gifts/mine");
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
var TokensNamespace = class extends Namespace {
|
|
698
|
+
async permissions() {
|
|
699
|
+
return this.$get("/tokens/permissions", void 0, false);
|
|
700
|
+
}
|
|
701
|
+
async list() {
|
|
702
|
+
return this.$get("/tokens");
|
|
703
|
+
}
|
|
704
|
+
async active() {
|
|
705
|
+
return this.$get("/tokens/active");
|
|
706
|
+
}
|
|
707
|
+
async create(name, permissions, options) {
|
|
708
|
+
return this.$post("/tokens/create", {
|
|
709
|
+
name,
|
|
710
|
+
permissions,
|
|
711
|
+
expires_in_hrs: options?.expiresInHrs,
|
|
712
|
+
origin: options?.origin,
|
|
713
|
+
description: options?.description,
|
|
714
|
+
websites: options?.websites
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
async get(id) {
|
|
718
|
+
return this.$get(`/tokens/${id}`);
|
|
719
|
+
}
|
|
720
|
+
async activity(id) {
|
|
721
|
+
return this.$get(`/tokens/${id}/activity`);
|
|
722
|
+
}
|
|
723
|
+
async update(id, options) {
|
|
724
|
+
return this.$patch(`/tokens/${id}`, options);
|
|
725
|
+
}
|
|
726
|
+
async rename(id, name) {
|
|
727
|
+
return this.$post(`/tokens/${id}/rename`, { name });
|
|
728
|
+
}
|
|
729
|
+
async revoke(id) {
|
|
730
|
+
return this.$post(`/tokens/${id}/revoke`);
|
|
731
|
+
}
|
|
732
|
+
async delete(id) {
|
|
733
|
+
return this.$del(`/tokens/${id}`);
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
var GroupsNamespace = class extends Namespace {
|
|
737
|
+
async mine() {
|
|
738
|
+
return this.$get("/groups/mine");
|
|
739
|
+
}
|
|
740
|
+
async search(query) {
|
|
741
|
+
return this.$get("/groups/search", { query });
|
|
742
|
+
}
|
|
743
|
+
async create(tag, name, options) {
|
|
744
|
+
const params = { tag, name };
|
|
745
|
+
if (options?.description) params.description = options.description;
|
|
746
|
+
if (options?.iconUrl) params.icon_url = options.iconUrl;
|
|
747
|
+
if (options?.bannerUrl) params.banner_url = options.bannerUrl;
|
|
748
|
+
if (options?.public !== void 0) params.public = String(options.public);
|
|
749
|
+
if (options?.joinPolicy) params.join_policy = options.joinPolicy;
|
|
750
|
+
return this.$post("/groups/create", params);
|
|
751
|
+
}
|
|
752
|
+
async get(grouptag) {
|
|
753
|
+
return this.$get(`/groups/${grouptag}`);
|
|
754
|
+
}
|
|
755
|
+
async update(grouptag, updates) {
|
|
756
|
+
return this.$patch(`/groups/${grouptag}`, updates);
|
|
757
|
+
}
|
|
758
|
+
async delete(grouptag) {
|
|
759
|
+
return this.$del(`/groups/${grouptag}`);
|
|
760
|
+
}
|
|
761
|
+
async join(grouptag) {
|
|
762
|
+
return this.$post(`/groups/${grouptag}/join`);
|
|
763
|
+
}
|
|
764
|
+
async leave(grouptag) {
|
|
765
|
+
return this.$post(`/groups/${grouptag}/leave`);
|
|
766
|
+
}
|
|
767
|
+
async represent(grouptag) {
|
|
768
|
+
return this.$post(`/groups/${grouptag}/rep`);
|
|
769
|
+
}
|
|
770
|
+
async disrepresent(grouptag) {
|
|
771
|
+
return this.$post(`/groups/${grouptag}/disrep`);
|
|
772
|
+
}
|
|
773
|
+
async report(grouptag) {
|
|
774
|
+
return this.$post(`/groups/${grouptag}/report`);
|
|
775
|
+
}
|
|
776
|
+
async announcements(grouptag) {
|
|
777
|
+
return this.$get(`/groups/${grouptag}/announcements`, void 0, false);
|
|
778
|
+
}
|
|
779
|
+
async createAnnouncement(grouptag, title, body, options) {
|
|
780
|
+
return this.$post(`/groups/${grouptag}/announcements`, {
|
|
781
|
+
title,
|
|
782
|
+
body,
|
|
783
|
+
ping_members: options?.pingMembers
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
async deleteAnnouncement(grouptag, id) {
|
|
787
|
+
return this.$del(`/groups/${grouptag}/announcements/${id}`);
|
|
788
|
+
}
|
|
789
|
+
async muteAnnouncements(grouptag) {
|
|
790
|
+
return this.$post(`/groups/${grouptag}/announcements/mute`);
|
|
791
|
+
}
|
|
792
|
+
async events(grouptag) {
|
|
793
|
+
return this.$get(`/groups/${grouptag}/events`);
|
|
794
|
+
}
|
|
795
|
+
async createEvent(grouptag, event) {
|
|
796
|
+
return this.$post(`/groups/${grouptag}/events`, event);
|
|
797
|
+
}
|
|
798
|
+
async tips(grouptag) {
|
|
799
|
+
return this.$get(`/groups/${grouptag}/tips`);
|
|
800
|
+
}
|
|
801
|
+
async sendTip(grouptag, amount) {
|
|
802
|
+
return this.$post(`/groups/${grouptag}/tips`, { amount });
|
|
803
|
+
}
|
|
804
|
+
async roles(grouptag) {
|
|
805
|
+
return this.$get(`/groups/${grouptag}/roles`);
|
|
806
|
+
}
|
|
807
|
+
async createRole(grouptag, role) {
|
|
808
|
+
return this.$post(`/groups/${grouptag}/roles`, role);
|
|
809
|
+
}
|
|
810
|
+
async updateRole(grouptag, roleId, updates) {
|
|
811
|
+
return this.$patch(`/groups/${grouptag}/roles/${roleId}`, updates);
|
|
812
|
+
}
|
|
813
|
+
async deleteRole(grouptag, roleId) {
|
|
814
|
+
return this.$del(`/groups/${grouptag}/roles/${roleId}`);
|
|
815
|
+
}
|
|
816
|
+
async userRoles(grouptag, userId) {
|
|
817
|
+
return this.$get(`/groups/${grouptag}/members/${userId}/roles`);
|
|
818
|
+
}
|
|
819
|
+
async userPermissions(grouptag, userId) {
|
|
820
|
+
return this.$get(`/groups/${grouptag}/members/${userId}/permissions`);
|
|
821
|
+
}
|
|
822
|
+
async userBenefits(grouptag, userId) {
|
|
823
|
+
return this.$get(`/groups/${grouptag}/members/${userId}/benefits`);
|
|
824
|
+
}
|
|
825
|
+
async assignRole(grouptag, userId, roleId) {
|
|
826
|
+
return this.$post(`/groups/${grouptag}/members/${userId}/roles/${roleId}`);
|
|
827
|
+
}
|
|
828
|
+
async removeRole(grouptag, userId, roleId) {
|
|
829
|
+
return this.$del(`/groups/${grouptag}/members/${userId}/roles/${roleId}`);
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
var SystemsNamespace = class extends Namespace {
|
|
833
|
+
async list() {
|
|
834
|
+
return this.$get("/systems", void 0, false);
|
|
835
|
+
}
|
|
836
|
+
async users(system) {
|
|
837
|
+
return this.$get("/system/users", { system });
|
|
838
|
+
}
|
|
839
|
+
async update(system, key, value) {
|
|
840
|
+
return this.$post("/update_system", { system, key, value });
|
|
841
|
+
}
|
|
842
|
+
async reload() {
|
|
843
|
+
return this.$get("/reload_systems");
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
var StatsNamespace = class extends Namespace {
|
|
847
|
+
async economy() {
|
|
848
|
+
return this.$get("/stats/economy", void 0, false);
|
|
849
|
+
}
|
|
850
|
+
async users() {
|
|
851
|
+
return this.$get("/stats/users", void 0, false);
|
|
852
|
+
}
|
|
853
|
+
async mostGained(max = 10) {
|
|
854
|
+
return this.$get("/stats/most_gained", { max: String(max) }, false);
|
|
855
|
+
}
|
|
856
|
+
async systems() {
|
|
857
|
+
return this.$get("/stats/systems", void 0, false);
|
|
858
|
+
}
|
|
859
|
+
async followers(max = 10) {
|
|
860
|
+
return this.$get("/stats/followers", { max: String(max) }, false);
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
var StatusNamespace = class extends Namespace {
|
|
864
|
+
async get(username) {
|
|
865
|
+
return this.$get("/status/get", { name: username }, false);
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
var ValidatorsNamespace = class extends Namespace {
|
|
869
|
+
async generate(key) {
|
|
870
|
+
return this.$get("/generate_validator", { key });
|
|
871
|
+
}
|
|
872
|
+
async validate(validator, key) {
|
|
873
|
+
return this.$get("/validate", { v: validator, key }, false);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
var LinkNamespace = class extends Namespace {
|
|
877
|
+
async getCode() {
|
|
878
|
+
return this.$get("/link/code", void 0, false);
|
|
879
|
+
}
|
|
880
|
+
async status(code) {
|
|
881
|
+
return this.$get("/link/status", { code }, false);
|
|
882
|
+
}
|
|
883
|
+
async linkedUser(code) {
|
|
884
|
+
return this.$get("/link/user", { code }, false);
|
|
885
|
+
}
|
|
886
|
+
async linkCode(code) {
|
|
887
|
+
return this.$post("/link/code", { code });
|
|
888
|
+
}
|
|
889
|
+
async pollUntilLinked(code, intervalMs = 1500, timeoutMs = 12e4) {
|
|
890
|
+
const start = Date.now();
|
|
891
|
+
while (Date.now() - start < timeoutMs) {
|
|
892
|
+
const res = await this.$get(
|
|
893
|
+
"/link/user",
|
|
894
|
+
{ code },
|
|
895
|
+
false
|
|
896
|
+
);
|
|
897
|
+
if (res.linked && res.token) {
|
|
898
|
+
this.r.setToken(res.token);
|
|
899
|
+
return res.token;
|
|
900
|
+
}
|
|
901
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
902
|
+
}
|
|
903
|
+
throw new Error("Link polling timed out");
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
var CosmeticsNamespace = class extends Namespace {
|
|
907
|
+
async shop(options) {
|
|
908
|
+
const params = {};
|
|
909
|
+
if (options?.type) params.type = options.type;
|
|
910
|
+
if (options?.featured) params.featured = "true";
|
|
911
|
+
if (options?.search) params.search = options.search;
|
|
912
|
+
if (options?.sort) params.sort = options.sort;
|
|
913
|
+
if (options?.limit !== void 0) params.limit = String(options.limit);
|
|
914
|
+
if (options?.offset !== void 0) params.offset = String(options.offset);
|
|
915
|
+
return this.$get("/cosmetics/shop", params, false);
|
|
916
|
+
}
|
|
917
|
+
async get(id) {
|
|
918
|
+
return this.$get(`/cosmetics/items/${id}`, void 0, false);
|
|
919
|
+
}
|
|
920
|
+
async mine() {
|
|
921
|
+
return this.$get("/cosmetics/mine");
|
|
922
|
+
}
|
|
923
|
+
async purchase(id) {
|
|
924
|
+
return this.$post(`/cosmetics/purchase/${id}`);
|
|
925
|
+
}
|
|
926
|
+
async equip(id) {
|
|
927
|
+
return this.$post(`/cosmetics/equip/${id}`);
|
|
928
|
+
}
|
|
929
|
+
async unequip(type) {
|
|
930
|
+
return this.$post(`/cosmetics/unequip?type=${encodeURIComponent(type)}`);
|
|
931
|
+
}
|
|
932
|
+
async overlays(filepath) {
|
|
933
|
+
return this.$get(`/cosmetics/overlays/${filepath}`, void 0, false);
|
|
934
|
+
}
|
|
935
|
+
/** Admin: List all cosmetics in catalog */
|
|
936
|
+
async adminList(options) {
|
|
937
|
+
return this.$get("/cosmetics/admin/list", options, true);
|
|
938
|
+
}
|
|
939
|
+
/** Admin: Create a cosmetic */
|
|
940
|
+
async adminCreate(data) {
|
|
941
|
+
return this.$post("/cosmetics/admin/create", data);
|
|
942
|
+
}
|
|
943
|
+
/** Admin: Update a cosmetic */
|
|
944
|
+
async adminUpdate(id, data) {
|
|
945
|
+
return this.$patch(`/cosmetics/admin/update/${id}`, data);
|
|
946
|
+
}
|
|
947
|
+
/** Admin: Delete a cosmetic */
|
|
948
|
+
async adminDelete(id) {
|
|
949
|
+
return this.$del(`/cosmetics/admin/delete/${id}`);
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
var PushNamespace = class extends Namespace {
|
|
953
|
+
async vapidKeys() {
|
|
954
|
+
return this.$get("/notify/vapid", void 0, false);
|
|
955
|
+
}
|
|
956
|
+
async register(endpoint, p256dh, auth, source, fingerprint) {
|
|
957
|
+
return this.$post("/notify/register", {
|
|
958
|
+
endpoint,
|
|
959
|
+
p256dh,
|
|
960
|
+
auth,
|
|
961
|
+
source,
|
|
962
|
+
fingerprint
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
async check(source, fingerprint) {
|
|
966
|
+
return this.$get("/notify/check", { source, fingerprint });
|
|
967
|
+
}
|
|
968
|
+
async endpoints() {
|
|
969
|
+
return this.$get("/notify/endpoints");
|
|
970
|
+
}
|
|
971
|
+
async deleteDevice(deviceId) {
|
|
972
|
+
return this.$del(`/notify/device/${deviceId}`);
|
|
973
|
+
}
|
|
974
|
+
async allowedSenders() {
|
|
975
|
+
return this.$get("/notify/allowed");
|
|
976
|
+
}
|
|
977
|
+
async allowSender(username, source) {
|
|
978
|
+
return this.$post(`/notify/allowed/${username}`, { source });
|
|
979
|
+
}
|
|
980
|
+
async removeSender(username, source) {
|
|
981
|
+
return this.$del(`/notify/allowed/${username}`, { source });
|
|
982
|
+
}
|
|
983
|
+
async log() {
|
|
984
|
+
return this.$get("/notify/log");
|
|
985
|
+
}
|
|
986
|
+
async send(username, source, options) {
|
|
987
|
+
return this.$post(`/notify/${username}`, {
|
|
988
|
+
source,
|
|
989
|
+
title: options?.title,
|
|
990
|
+
body: options?.body,
|
|
991
|
+
data: options?.data
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
async sendMany(users, source, options) {
|
|
995
|
+
return this.$post("/notify/", {
|
|
996
|
+
source,
|
|
997
|
+
title: options?.title,
|
|
998
|
+
body: options?.body,
|
|
999
|
+
data: options?.data,
|
|
1000
|
+
users
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
async notifiableUsers(source) {
|
|
1004
|
+
return this.$get(`/notify/${source}/users`);
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
var FilesNamespace = class extends Namespace {
|
|
1008
|
+
async index() {
|
|
1009
|
+
return this.$get("/files/index");
|
|
1010
|
+
}
|
|
1011
|
+
async all() {
|
|
1012
|
+
return this.$get("/files/entries");
|
|
1013
|
+
}
|
|
1014
|
+
async getByUUID(uuid) {
|
|
1015
|
+
return this.$get("/files", { uuid });
|
|
1016
|
+
}
|
|
1017
|
+
async getByPath(path) {
|
|
1018
|
+
return this.$get(`/files/by-path/${path}`);
|
|
1019
|
+
}
|
|
1020
|
+
async usage() {
|
|
1021
|
+
return this.$get("/files/usage");
|
|
1022
|
+
}
|
|
1023
|
+
async stats(uuids) {
|
|
1024
|
+
return this.$post("/files/stats", { uuids });
|
|
1025
|
+
}
|
|
1026
|
+
async byUUIDs(uuids) {
|
|
1027
|
+
return this.$post("/files/by-uuid", { uuids });
|
|
1028
|
+
}
|
|
1029
|
+
async pathIndex() {
|
|
1030
|
+
return this.$get("/files/path-index");
|
|
1031
|
+
}
|
|
1032
|
+
async upload(files) {
|
|
1033
|
+
return this.$post("/files", files);
|
|
1034
|
+
}
|
|
1035
|
+
async deleteAll() {
|
|
1036
|
+
return this.$del("/files");
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
var StandingNamespace = class extends Namespace {
|
|
1040
|
+
async get(username) {
|
|
1041
|
+
return this.$get("/get_standing", { username }, false);
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
var DevFundNamespace = class extends Namespace {
|
|
1045
|
+
/** Transfer credits to escrow for a dev fund petition */
|
|
1046
|
+
async escrowTransfer(amount, petitionId, note) {
|
|
1047
|
+
return this.$post("/devfund/escrow_transfer", { amount, petition_id: petitionId, note });
|
|
1048
|
+
}
|
|
1049
|
+
/** Release escrow credits to a developer (admin only) */
|
|
1050
|
+
async escrowRelease(amount, toUsername, petitionId, note) {
|
|
1051
|
+
return this.$post("/devfund/escrow_release", { amount, to_username: toUsername, petition_id: petitionId, note });
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
var CheckNamespace = class extends Namespace {
|
|
1055
|
+
/** Check if a list of usernames are banned */
|
|
1056
|
+
async banned(usernames) {
|
|
1057
|
+
return this.$post("/check/banned", usernames.join(","));
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1061
|
+
0 && (module.exports = {
|
|
1062
|
+
ApiError,
|
|
1063
|
+
AuthError,
|
|
1064
|
+
Rotur,
|
|
1065
|
+
RoturSocket,
|
|
1066
|
+
performAuth
|
|
1067
|
+
});
|