rotur-sdk 1.0.5 → 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.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(msg);
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.send({ cmd: "auth", key: token });
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(msg);
268
+ resolve(
269
+ msg
270
+ );
265
271
  };
266
272
  this.on(cmd, h);
267
273
  });
@@ -548,28 +554,32 @@ var MeNamespace = class extends Namespace {
548
554
  return this.$get("/check_auth");
549
555
  }
550
556
  async requests() {
551
- return this.$get("/requests", void 0).then((u) => ({
552
- requests: u.requests ?? []
553
- }));
557
+ return this.$get("/requests", void 0).then((u) => {
558
+ const data = u;
559
+ return { requests: data.requests ?? [] };
560
+ });
554
561
  }
555
562
  async outgoing() {
556
- return this.$get("/requests_out", void 0).then((u) => ({
557
- outgoing: u.requests_out ?? []
558
- }));
563
+ return this.$get("/requests_out", void 0).then((u) => {
564
+ const data = u;
565
+ return { outgoing: data.requests_out ?? [] };
566
+ });
559
567
  }
560
568
  async transactions() {
561
- return this.$get("/me", void 0).then(
562
- (u) => u["sys.transactions"] ?? []
563
- );
569
+ return this.$get("/me", void 0).then((u) => {
570
+ const data = u;
571
+ return data["sys.transactions"] ?? [];
572
+ });
564
573
  }
565
574
  async subscription() {
566
- return this.$get("/me", void 0).then(
567
- (u) => u["sys.subscription"] ?? {
575
+ return this.$get("/me", void 0).then((u) => {
576
+ const data = u;
577
+ return data["sys.subscription"] ?? {
568
578
  active: false,
569
579
  tier: "Free",
570
580
  next_billing: 0
571
- }
572
- );
581
+ };
582
+ });
573
583
  }
574
584
  };
575
585
  var PostsNamespace = class extends Namespace {
@@ -618,13 +628,12 @@ var PostsNamespace = class extends Namespace {
618
628
  }
619
629
  };
620
630
  function handleMessageOrError(res) {
621
- return res.then((r) => {
622
- if (r.ok) {
623
- return { ok: true };
624
- } else if (r.error) {
625
- 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) };
626
635
  } else {
627
- return { ok: false, message: r.message };
636
+ return { ok: true, message: String(r.message ?? "") };
628
637
  }
629
638
  });
630
639
  }
@@ -1003,11 +1012,7 @@ var CosmeticsNamespace = class extends Namespace {
1003
1012
  return this.$post(`/cosmetics/unequip?type=${encodeURIComponent(type)}`);
1004
1013
  }
1005
1014
  async overlays(name) {
1006
- return this.$get(
1007
- `/cosmetics/overlays/${name}.gif`,
1008
- void 0,
1009
- false
1010
- );
1015
+ return this.$get(`/cosmetics/overlays/${name}.gif`, void 0, false);
1011
1016
  }
1012
1017
  };
1013
1018
  var PushNamespace = 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(msg);
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.send({ cmd: "auth", key: token });
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(msg);
238
+ resolve(
239
+ msg
240
+ );
235
241
  };
236
242
  this.on(cmd, h);
237
243
  });
@@ -518,28 +524,32 @@ var MeNamespace = class extends Namespace {
518
524
  return this.$get("/check_auth");
519
525
  }
520
526
  async requests() {
521
- return this.$get("/requests", void 0).then((u) => ({
522
- requests: u.requests ?? []
523
- }));
527
+ return this.$get("/requests", void 0).then((u) => {
528
+ const data = u;
529
+ return { requests: data.requests ?? [] };
530
+ });
524
531
  }
525
532
  async outgoing() {
526
- return this.$get("/requests_out", void 0).then((u) => ({
527
- outgoing: u.requests_out ?? []
528
- }));
533
+ return this.$get("/requests_out", void 0).then((u) => {
534
+ const data = u;
535
+ return { outgoing: data.requests_out ?? [] };
536
+ });
529
537
  }
530
538
  async transactions() {
531
- return this.$get("/me", void 0).then(
532
- (u) => u["sys.transactions"] ?? []
533
- );
539
+ return this.$get("/me", void 0).then((u) => {
540
+ const data = u;
541
+ return data["sys.transactions"] ?? [];
542
+ });
534
543
  }
535
544
  async subscription() {
536
- return this.$get("/me", void 0).then(
537
- (u) => u["sys.subscription"] ?? {
545
+ return this.$get("/me", void 0).then((u) => {
546
+ const data = u;
547
+ return data["sys.subscription"] ?? {
538
548
  active: false,
539
549
  tier: "Free",
540
550
  next_billing: 0
541
- }
542
- );
551
+ };
552
+ });
543
553
  }
544
554
  };
545
555
  var PostsNamespace = class extends Namespace {
@@ -588,13 +598,12 @@ var PostsNamespace = class extends Namespace {
588
598
  }
589
599
  };
590
600
  function handleMessageOrError(res) {
591
- return res.then((r) => {
592
- if (r.ok) {
593
- return { ok: true };
594
- } else if (r.error) {
595
- 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) };
596
605
  } else {
597
- return { ok: false, message: r.message };
606
+ return { ok: true, message: String(r.message ?? "") };
598
607
  }
599
608
  });
600
609
  }
@@ -973,11 +982,7 @@ var CosmeticsNamespace = class extends Namespace {
973
982
  return this.$post(`/cosmetics/unequip?type=${encodeURIComponent(type)}`);
974
983
  }
975
984
  async overlays(name) {
976
- return this.$get(
977
- `/cosmetics/overlays/${name}.gif`,
978
- void 0,
979
- false
980
- );
985
+ return this.$get(`/cosmetics/overlays/${name}.gif`, void 0, false);
981
986
  }
982
987
  };
983
988
  var PushNamespace = class extends Namespace {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotur-sdk",
3
- "version": "1.0.5",
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",