rotur-sdk 1.0.4 → 1.0.6
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 +341 -147
- package/dist/index.d.ts +341 -147
- package/dist/index.js +47 -30
- package/dist/index.mjs +47 -30
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -195,7 +195,9 @@ var RoturSocket = class extends EventTarget {
|
|
|
195
195
|
this.keyCache = { ...msg.user };
|
|
196
196
|
}
|
|
197
197
|
this.startHeartbeat();
|
|
198
|
-
resolve(
|
|
198
|
+
resolve(
|
|
199
|
+
msg
|
|
200
|
+
);
|
|
199
201
|
}
|
|
200
202
|
if (cmd === "join_ok") this.rooms.add(msg.room);
|
|
201
203
|
if (cmd === "leave_ok") this.rooms.delete(msg.room);
|
|
@@ -215,7 +217,9 @@ var RoturSocket = class extends EventTarget {
|
|
|
215
217
|
this.emit("close", {});
|
|
216
218
|
this.scheduleReconnect();
|
|
217
219
|
};
|
|
218
|
-
this.
|
|
220
|
+
this.ws.onopen = () => {
|
|
221
|
+
this.send({ cmd: "auth", key: token });
|
|
222
|
+
};
|
|
219
223
|
});
|
|
220
224
|
}
|
|
221
225
|
startHeartbeat() {
|
|
@@ -261,7 +265,9 @@ var RoturSocket = class extends EventTarget {
|
|
|
261
265
|
return new Promise((resolve) => {
|
|
262
266
|
const h = (msg) => {
|
|
263
267
|
this.off(cmd, h);
|
|
264
|
-
resolve(
|
|
268
|
+
resolve(
|
|
269
|
+
msg
|
|
270
|
+
);
|
|
265
271
|
};
|
|
266
272
|
this.on(cmd, h);
|
|
267
273
|
});
|
|
@@ -526,9 +532,6 @@ var MeNamespace = class extends Namespace {
|
|
|
526
532
|
async badges() {
|
|
527
533
|
return this.$get("/badges");
|
|
528
534
|
}
|
|
529
|
-
async acceptTos() {
|
|
530
|
-
return this.$post("/accept_tos");
|
|
531
|
-
}
|
|
532
535
|
async abilities() {
|
|
533
536
|
return this.$get("/me/able");
|
|
534
537
|
}
|
|
@@ -547,30 +550,36 @@ var MeNamespace = class extends Namespace {
|
|
|
547
550
|
async deleteNote(username) {
|
|
548
551
|
return this.$del(`/me/note/${username}`);
|
|
549
552
|
}
|
|
550
|
-
async resendVerification() {
|
|
551
|
-
return this.$post("/me/resend_verification");
|
|
552
|
-
}
|
|
553
|
-
async verifyEmail(token) {
|
|
554
|
-
return this.$get("/verify_email", { token }, false);
|
|
555
|
-
}
|
|
556
553
|
async checkAuth() {
|
|
557
554
|
return this.$get("/check_auth");
|
|
558
555
|
}
|
|
559
556
|
async requests() {
|
|
560
|
-
return this.$get("/requests", void 0).then((u) =>
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
return this.$get("/requests", void 0).then((u) => {
|
|
558
|
+
const data = u;
|
|
559
|
+
return { requests: data.requests ?? [] };
|
|
560
|
+
});
|
|
563
561
|
}
|
|
564
562
|
async outgoing() {
|
|
565
|
-
return this.$get("/requests_out", void 0).then((u) =>
|
|
566
|
-
|
|
567
|
-
|
|
563
|
+
return this.$get("/requests_out", void 0).then((u) => {
|
|
564
|
+
const data = u;
|
|
565
|
+
return { outgoing: data.requests_out ?? [] };
|
|
566
|
+
});
|
|
568
567
|
}
|
|
569
568
|
async transactions() {
|
|
570
|
-
return this.$get("/me", void 0).then((u) =>
|
|
569
|
+
return this.$get("/me", void 0).then((u) => {
|
|
570
|
+
const data = u;
|
|
571
|
+
return data["sys.transactions"] ?? [];
|
|
572
|
+
});
|
|
571
573
|
}
|
|
572
574
|
async subscription() {
|
|
573
|
-
return this.$get("/me", void 0).then((u) =>
|
|
575
|
+
return this.$get("/me", void 0).then((u) => {
|
|
576
|
+
const data = u;
|
|
577
|
+
return data["sys.subscription"] ?? {
|
|
578
|
+
active: false,
|
|
579
|
+
tier: "Free",
|
|
580
|
+
next_billing: 0
|
|
581
|
+
};
|
|
582
|
+
});
|
|
574
583
|
}
|
|
575
584
|
};
|
|
576
585
|
var PostsNamespace = class extends Namespace {
|
|
@@ -619,13 +628,12 @@ var PostsNamespace = class extends Namespace {
|
|
|
619
628
|
}
|
|
620
629
|
};
|
|
621
630
|
function handleMessageOrError(res) {
|
|
622
|
-
return res.then((
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
return { ok: false, error: r.error };
|
|
631
|
+
return res.then((raw) => {
|
|
632
|
+
const r = raw;
|
|
633
|
+
if (r.error) {
|
|
634
|
+
return { ok: false, error: String(r.error) };
|
|
627
635
|
} else {
|
|
628
|
-
return { ok:
|
|
636
|
+
return { ok: true, message: String(r.message ?? "") };
|
|
629
637
|
}
|
|
630
638
|
});
|
|
631
639
|
}
|
|
@@ -1003,8 +1011,8 @@ var CosmeticsNamespace = class extends Namespace {
|
|
|
1003
1011
|
async unequip(type) {
|
|
1004
1012
|
return this.$post(`/cosmetics/unequip?type=${encodeURIComponent(type)}`);
|
|
1005
1013
|
}
|
|
1006
|
-
async overlays(
|
|
1007
|
-
return this.$get(`/cosmetics/overlays/${
|
|
1014
|
+
async overlays(name) {
|
|
1015
|
+
return this.$get(`/cosmetics/overlays/${name}.gif`, void 0, false);
|
|
1008
1016
|
}
|
|
1009
1017
|
};
|
|
1010
1018
|
var PushNamespace = class extends Namespace {
|
|
@@ -1102,11 +1110,20 @@ var StandingNamespace = class extends Namespace {
|
|
|
1102
1110
|
var DevFundNamespace = class extends Namespace {
|
|
1103
1111
|
/** Transfer credits to escrow for a dev fund petition */
|
|
1104
1112
|
async escrowTransfer(amount, petitionId, note) {
|
|
1105
|
-
return this.$post("/devfund/escrow_transfer", {
|
|
1113
|
+
return this.$post("/devfund/escrow_transfer", {
|
|
1114
|
+
amount,
|
|
1115
|
+
petition_id: petitionId,
|
|
1116
|
+
note
|
|
1117
|
+
});
|
|
1106
1118
|
}
|
|
1107
1119
|
/** Release escrow credits to a developer (admin only) */
|
|
1108
1120
|
async escrowRelease(amount, toUsername, petitionId, note) {
|
|
1109
|
-
return this.$post("/devfund/escrow_release", {
|
|
1121
|
+
return this.$post("/devfund/escrow_release", {
|
|
1122
|
+
amount,
|
|
1123
|
+
to_username: toUsername,
|
|
1124
|
+
petition_id: petitionId,
|
|
1125
|
+
note
|
|
1126
|
+
});
|
|
1110
1127
|
}
|
|
1111
1128
|
};
|
|
1112
1129
|
var CheckNamespace = class extends Namespace {
|
package/dist/index.mjs
CHANGED
|
@@ -165,7 +165,9 @@ var RoturSocket = class extends EventTarget {
|
|
|
165
165
|
this.keyCache = { ...msg.user };
|
|
166
166
|
}
|
|
167
167
|
this.startHeartbeat();
|
|
168
|
-
resolve(
|
|
168
|
+
resolve(
|
|
169
|
+
msg
|
|
170
|
+
);
|
|
169
171
|
}
|
|
170
172
|
if (cmd === "join_ok") this.rooms.add(msg.room);
|
|
171
173
|
if (cmd === "leave_ok") this.rooms.delete(msg.room);
|
|
@@ -185,7 +187,9 @@ var RoturSocket = class extends EventTarget {
|
|
|
185
187
|
this.emit("close", {});
|
|
186
188
|
this.scheduleReconnect();
|
|
187
189
|
};
|
|
188
|
-
this.
|
|
190
|
+
this.ws.onopen = () => {
|
|
191
|
+
this.send({ cmd: "auth", key: token });
|
|
192
|
+
};
|
|
189
193
|
});
|
|
190
194
|
}
|
|
191
195
|
startHeartbeat() {
|
|
@@ -231,7 +235,9 @@ var RoturSocket = class extends EventTarget {
|
|
|
231
235
|
return new Promise((resolve) => {
|
|
232
236
|
const h = (msg) => {
|
|
233
237
|
this.off(cmd, h);
|
|
234
|
-
resolve(
|
|
238
|
+
resolve(
|
|
239
|
+
msg
|
|
240
|
+
);
|
|
235
241
|
};
|
|
236
242
|
this.on(cmd, h);
|
|
237
243
|
});
|
|
@@ -496,9 +502,6 @@ var MeNamespace = class extends Namespace {
|
|
|
496
502
|
async badges() {
|
|
497
503
|
return this.$get("/badges");
|
|
498
504
|
}
|
|
499
|
-
async acceptTos() {
|
|
500
|
-
return this.$post("/accept_tos");
|
|
501
|
-
}
|
|
502
505
|
async abilities() {
|
|
503
506
|
return this.$get("/me/able");
|
|
504
507
|
}
|
|
@@ -517,30 +520,36 @@ var MeNamespace = class extends Namespace {
|
|
|
517
520
|
async deleteNote(username) {
|
|
518
521
|
return this.$del(`/me/note/${username}`);
|
|
519
522
|
}
|
|
520
|
-
async resendVerification() {
|
|
521
|
-
return this.$post("/me/resend_verification");
|
|
522
|
-
}
|
|
523
|
-
async verifyEmail(token) {
|
|
524
|
-
return this.$get("/verify_email", { token }, false);
|
|
525
|
-
}
|
|
526
523
|
async checkAuth() {
|
|
527
524
|
return this.$get("/check_auth");
|
|
528
525
|
}
|
|
529
526
|
async requests() {
|
|
530
|
-
return this.$get("/requests", void 0).then((u) =>
|
|
531
|
-
|
|
532
|
-
|
|
527
|
+
return this.$get("/requests", void 0).then((u) => {
|
|
528
|
+
const data = u;
|
|
529
|
+
return { requests: data.requests ?? [] };
|
|
530
|
+
});
|
|
533
531
|
}
|
|
534
532
|
async outgoing() {
|
|
535
|
-
return this.$get("/requests_out", void 0).then((u) =>
|
|
536
|
-
|
|
537
|
-
|
|
533
|
+
return this.$get("/requests_out", void 0).then((u) => {
|
|
534
|
+
const data = u;
|
|
535
|
+
return { outgoing: data.requests_out ?? [] };
|
|
536
|
+
});
|
|
538
537
|
}
|
|
539
538
|
async transactions() {
|
|
540
|
-
return this.$get("/me", void 0).then((u) =>
|
|
539
|
+
return this.$get("/me", void 0).then((u) => {
|
|
540
|
+
const data = u;
|
|
541
|
+
return data["sys.transactions"] ?? [];
|
|
542
|
+
});
|
|
541
543
|
}
|
|
542
544
|
async subscription() {
|
|
543
|
-
return this.$get("/me", void 0).then((u) =>
|
|
545
|
+
return this.$get("/me", void 0).then((u) => {
|
|
546
|
+
const data = u;
|
|
547
|
+
return data["sys.subscription"] ?? {
|
|
548
|
+
active: false,
|
|
549
|
+
tier: "Free",
|
|
550
|
+
next_billing: 0
|
|
551
|
+
};
|
|
552
|
+
});
|
|
544
553
|
}
|
|
545
554
|
};
|
|
546
555
|
var PostsNamespace = class extends Namespace {
|
|
@@ -589,13 +598,12 @@ var PostsNamespace = class extends Namespace {
|
|
|
589
598
|
}
|
|
590
599
|
};
|
|
591
600
|
function handleMessageOrError(res) {
|
|
592
|
-
return res.then((
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
return { ok: false, error: r.error };
|
|
601
|
+
return res.then((raw) => {
|
|
602
|
+
const r = raw;
|
|
603
|
+
if (r.error) {
|
|
604
|
+
return { ok: false, error: String(r.error) };
|
|
597
605
|
} else {
|
|
598
|
-
return { ok:
|
|
606
|
+
return { ok: true, message: String(r.message ?? "") };
|
|
599
607
|
}
|
|
600
608
|
});
|
|
601
609
|
}
|
|
@@ -973,8 +981,8 @@ var CosmeticsNamespace = class extends Namespace {
|
|
|
973
981
|
async unequip(type) {
|
|
974
982
|
return this.$post(`/cosmetics/unequip?type=${encodeURIComponent(type)}`);
|
|
975
983
|
}
|
|
976
|
-
async overlays(
|
|
977
|
-
return this.$get(`/cosmetics/overlays/${
|
|
984
|
+
async overlays(name) {
|
|
985
|
+
return this.$get(`/cosmetics/overlays/${name}.gif`, void 0, false);
|
|
978
986
|
}
|
|
979
987
|
};
|
|
980
988
|
var PushNamespace = class extends Namespace {
|
|
@@ -1072,11 +1080,20 @@ var StandingNamespace = class extends Namespace {
|
|
|
1072
1080
|
var DevFundNamespace = class extends Namespace {
|
|
1073
1081
|
/** Transfer credits to escrow for a dev fund petition */
|
|
1074
1082
|
async escrowTransfer(amount, petitionId, note) {
|
|
1075
|
-
return this.$post("/devfund/escrow_transfer", {
|
|
1083
|
+
return this.$post("/devfund/escrow_transfer", {
|
|
1084
|
+
amount,
|
|
1085
|
+
petition_id: petitionId,
|
|
1086
|
+
note
|
|
1087
|
+
});
|
|
1076
1088
|
}
|
|
1077
1089
|
/** Release escrow credits to a developer (admin only) */
|
|
1078
1090
|
async escrowRelease(amount, toUsername, petitionId, note) {
|
|
1079
|
-
return this.$post("/devfund/escrow_release", {
|
|
1091
|
+
return this.$post("/devfund/escrow_release", {
|
|
1092
|
+
amount,
|
|
1093
|
+
to_username: toUsername,
|
|
1094
|
+
petition_id: petitionId,
|
|
1095
|
+
note
|
|
1096
|
+
});
|
|
1080
1097
|
}
|
|
1081
1098
|
};
|
|
1082
1099
|
var CheckNamespace = class extends Namespace {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rotur-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "The official SDK for the Rotur platform - auth, profiles, posts, credits, keys, groups, items, gifts, tokens, validators, status, files, cosmetics, push notifications, and more",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"dev": "tsup src/index.ts --watch",
|
|
22
22
|
"test": "vitest",
|
|
23
23
|
"typecheck": "tsc --noEmit",
|
|
24
|
-
"fmt": "prettier --write ."
|
|
24
|
+
"fmt": "prettier --write .",
|
|
25
|
+
"publish": "npm run build && npm publish"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"tsup": "^8.5.1",
|