rotur-sdk 1.0.2 → 1.0.4

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 CHANGED
@@ -31,8 +31,8 @@ const rotur = new Rotur({ token: "your-token-here" });
31
31
  await rotur.login({ system: "my-app", timeout: 60_000 });
32
32
 
33
33
  // Check current auth state
34
- rotur.loggedIn; // boolean
35
- rotur.token; // string | null
34
+ rotur.loggedIn; // boolean
35
+ rotur.token; // string | null
36
36
 
37
37
  // Set/refresh token manually
38
38
  rotur.setToken("new-token");
@@ -117,7 +117,11 @@ await rotur.keys.buy("key-id");
117
117
  ### Items
118
118
 
119
119
  ```ts
120
- const item = await rotur.items.create({ name: "sword", price: 100, selling: true });
120
+ const item = await rotur.items.create({
121
+ name: "sword",
122
+ price: 100,
123
+ selling: true,
124
+ });
121
125
  const item = await rotur.items.get("sword");
122
126
  const items = await rotur.items.list("username");
123
127
  await rotur.items.buy("sword");
@@ -138,9 +142,11 @@ await rotur.gifts.claim("code");
138
142
  const { permissions, groups } = await rotur.tokens.permissions();
139
143
  const { tokens } = await rotur.tokens.list();
140
144
 
141
- const sub = await rotur.tokens.create("bot-token", [
142
- "posts:view", "posts:create", "account:profile"
143
- ], { expiresInHrs: 24, origin: "my-app" });
145
+ const sub = await rotur.tokens.create(
146
+ "bot-token",
147
+ ["posts:view", "posts:create", "account:profile"],
148
+ { expiresInHrs: 24, origin: "my-app" },
149
+ );
144
150
 
145
151
  await rotur.tokens.revoke(sub.id);
146
152
  ```
@@ -178,7 +184,9 @@ const files = await rotur.files.index();
178
184
  const { used, max } = await rotur.files.usage();
179
185
  const file = await rotur.files.getByUUID("uuid");
180
186
  const file = await rotur.files.getByPath("path/to/file");
181
- await rotur.files.upload({ /* file data */ });
187
+ await rotur.files.upload({
188
+ /* file data */
189
+ });
182
190
  ```
183
191
 
184
192
  ### Push Notifications
@@ -187,7 +195,10 @@ await rotur.files.upload({ /* file data */ });
187
195
  const { public_key } = await rotur.push.vapidKeys();
188
196
  await rotur.push.register(endpoint, p256dh, auth, "my-app", "fingerprint");
189
197
  const { endpoints } = await rotur.push.endpoints();
190
- await rotur.push.send("username", "my-app", { title: "Hi!", body: "You have a message" });
198
+ await rotur.push.send("username", "my-app", {
199
+ title: "Hi!",
200
+ body: "You have a message",
201
+ });
191
202
  ```
192
203
 
193
204
  ### Status & Validators
@@ -262,8 +273,8 @@ try {
262
273
  await rotur.me.transfer("user", 1000);
263
274
  } catch (e) {
264
275
  if (e instanceof ApiError) {
265
- console.log(e.status); // HTTP status code
266
- console.log(e.data); // response body
276
+ console.log(e.status); // HTTP status code
277
+ console.log(e.data); // response body
267
278
  console.log(e.message); // human-readable error
268
279
  }
269
280
  }
@@ -288,14 +299,14 @@ npm test # vitest
288
299
 
289
300
  ## Exports
290
301
 
291
- | Export | Description |
292
- |---|---|
293
- | `Rotur` | Main client class |
294
- | `RoturSocket` | WebSocket connection (real-time presence) |
295
- | `ApiError` | HTTP error with `status` and `data` |
296
- | `performAuth`, `AuthError` | Browser auth flow |
297
- | `AuthOptions`, `AuthResult` | Auth option types |
298
- | All types from `types.ts` | `UserProfile`, `NetPost`, `GroupPublic`, `WSMessage`, etc. |
302
+ | Export | Description |
303
+ | --------------------------- | ---------------------------------------------------------- |
304
+ | `Rotur` | Main client class |
305
+ | `RoturSocket` | WebSocket connection (real-time presence) |
306
+ | `ApiError` | HTTP error with `status` and `data` |
307
+ | `performAuth`, `AuthError` | Browser auth flow |
308
+ | `AuthOptions`, `AuthResult` | Auth option types |
309
+ | All types from `types.ts` | `UserProfile`, `NetPost`, `GroupPublic`, `WSMessage`, etc. |
299
310
 
300
311
  ## License
301
312
 
package/dist/index.d.mts CHANGED
@@ -615,6 +615,8 @@ declare class ProfilesNamespace extends Namespace {
615
615
  subscription: string;
616
616
  }>>;
617
617
  getAvatarUrl(username: Username, cache?: string): string;
618
+ getOverlayUrl(username: Username, cache?: string): string;
619
+ getBannerUrl(username: Username, cache?: string): string;
618
620
  }
619
621
  declare class MeNamespace extends Namespace {
620
622
  get(): Promise<Record<string, any>>;
@@ -654,6 +656,9 @@ declare class MeNamespace extends Namespace {
654
656
  requests(): Promise<{
655
657
  requests: Username[];
656
658
  }>;
659
+ outgoing(): Promise<{
660
+ outgoing: Username[];
661
+ }>;
657
662
  transactions(): Promise<any[]>;
658
663
  subscription(): Promise<{
659
664
  active: boolean;
@@ -684,14 +689,43 @@ declare class FriendsNamespace extends Namespace {
684
689
  list(): Promise<{
685
690
  friends: Username[];
686
691
  }>;
687
- request(username: Username): Promise<any>;
688
- accept(username: Username): Promise<any>;
689
- reject(username: Username): Promise<any>;
690
- remove(username: Username): Promise<any>;
692
+ request(username: Username): Promise<{
693
+ ok: boolean;
694
+ message?: string;
695
+ error?: string;
696
+ }>;
697
+ accept(username: Username): Promise<{
698
+ ok: boolean;
699
+ message?: string;
700
+ error?: string;
701
+ }>;
702
+ reject(username: Username): Promise<{
703
+ ok: boolean;
704
+ message?: string;
705
+ error?: string;
706
+ }>;
707
+ remove(username: Username): Promise<{
708
+ ok: boolean;
709
+ message?: string;
710
+ error?: string;
711
+ }>;
712
+ cancel(username: Username): Promise<{
713
+ ok: boolean;
714
+ message?: string;
715
+ error?: string;
716
+ }>;
691
717
  }
692
718
  declare class FollowingNamespace extends Namespace {
693
- follow(username: Username): Promise<any>;
694
- unfollow(username: Username): Promise<any>;
719
+ follow(username: Username): Promise<{
720
+ ok: boolean;
721
+ message?: string;
722
+ error?: string;
723
+ }>;
724
+ unfollow(username: Username): Promise<{
725
+ ok: boolean;
726
+ message?: string;
727
+ error?: string;
728
+ }>;
695
729
  followers(username: Username): Promise<{
696
730
  followers: Username[];
697
731
  }>;
package/dist/index.d.ts CHANGED
@@ -615,6 +615,8 @@ declare class ProfilesNamespace extends Namespace {
615
615
  subscription: string;
616
616
  }>>;
617
617
  getAvatarUrl(username: Username, cache?: string): string;
618
+ getOverlayUrl(username: Username, cache?: string): string;
619
+ getBannerUrl(username: Username, cache?: string): string;
618
620
  }
619
621
  declare class MeNamespace extends Namespace {
620
622
  get(): Promise<Record<string, any>>;
@@ -654,6 +656,9 @@ declare class MeNamespace extends Namespace {
654
656
  requests(): Promise<{
655
657
  requests: Username[];
656
658
  }>;
659
+ outgoing(): Promise<{
660
+ outgoing: Username[];
661
+ }>;
657
662
  transactions(): Promise<any[]>;
658
663
  subscription(): Promise<{
659
664
  active: boolean;
@@ -684,14 +689,43 @@ declare class FriendsNamespace extends Namespace {
684
689
  list(): Promise<{
685
690
  friends: Username[];
686
691
  }>;
687
- request(username: Username): Promise<any>;
688
- accept(username: Username): Promise<any>;
689
- reject(username: Username): Promise<any>;
690
- remove(username: Username): Promise<any>;
692
+ request(username: Username): Promise<{
693
+ ok: boolean;
694
+ message?: string;
695
+ error?: string;
696
+ }>;
697
+ accept(username: Username): Promise<{
698
+ ok: boolean;
699
+ message?: string;
700
+ error?: string;
701
+ }>;
702
+ reject(username: Username): Promise<{
703
+ ok: boolean;
704
+ message?: string;
705
+ error?: string;
706
+ }>;
707
+ remove(username: Username): Promise<{
708
+ ok: boolean;
709
+ message?: string;
710
+ error?: string;
711
+ }>;
712
+ cancel(username: Username): Promise<{
713
+ ok: boolean;
714
+ message?: string;
715
+ error?: string;
716
+ }>;
691
717
  }
692
718
  declare class FollowingNamespace extends Namespace {
693
- follow(username: Username): Promise<any>;
694
- unfollow(username: Username): Promise<any>;
719
+ follow(username: Username): Promise<{
720
+ ok: boolean;
721
+ message?: string;
722
+ error?: string;
723
+ }>;
724
+ unfollow(username: Username): Promise<{
725
+ ok: boolean;
726
+ message?: string;
727
+ error?: string;
728
+ }>;
695
729
  followers(username: Username): Promise<{
696
730
  followers: Username[];
697
731
  }>;
package/dist/index.js CHANGED
@@ -482,6 +482,12 @@ var ProfilesNamespace = class extends Namespace {
482
482
  getAvatarUrl(username, cache = "") {
483
483
  return `https://avatars.rotur.dev/${username}?v=${cache}`;
484
484
  }
485
+ getOverlayUrl(username, cache = "") {
486
+ return `https://avatars.rotur.dev/.overlay/${username}?v=${cache}`;
487
+ }
488
+ getBannerUrl(username, cache = "") {
489
+ return `https://avatars.rotur.dev/.banners/${username}?v=${cache}`;
490
+ }
485
491
  };
486
492
  var MeNamespace = class extends Namespace {
487
493
  async get() {
@@ -551,8 +557,13 @@ var MeNamespace = class extends Namespace {
551
557
  return this.$get("/check_auth");
552
558
  }
553
559
  async requests() {
554
- return this.$get("/me", void 0).then((u) => ({
555
- requests: u["sys.requests"] ?? []
560
+ return this.$get("/requests", void 0).then((u) => ({
561
+ requests: u.requests ?? []
562
+ }));
563
+ }
564
+ async outgoing() {
565
+ return this.$get("/requests_out", void 0).then((u) => ({
566
+ outgoing: u.requests_out ?? []
556
567
  }));
557
568
  }
558
569
  async transactions() {
@@ -607,29 +618,43 @@ var PostsNamespace = class extends Namespace {
607
618
  return this.$get("/limits", void 0, false);
608
619
  }
609
620
  };
621
+ function handleMessageOrError(res) {
622
+ return res.then((r) => {
623
+ if (r.ok) {
624
+ return { ok: true };
625
+ } else if (r.error) {
626
+ return { ok: false, error: r.error };
627
+ } else {
628
+ return { ok: false, message: r.message };
629
+ }
630
+ });
631
+ }
610
632
  var FriendsNamespace = class extends Namespace {
611
633
  async list() {
612
634
  return this.$get("/friends");
613
635
  }
614
636
  async request(username) {
615
- return this.$post(`/friends/request/${username}`);
637
+ return handleMessageOrError(this.$post(`/friends/request/${username}`));
616
638
  }
617
639
  async accept(username) {
618
- return this.$post(`/friends/accept/${username}`);
640
+ return handleMessageOrError(this.$post(`/friends/accept/${username}`));
619
641
  }
620
642
  async reject(username) {
621
- return this.$post(`/friends/reject/${username}`);
643
+ return handleMessageOrError(this.$post(`/friends/reject/${username}`));
622
644
  }
623
645
  async remove(username) {
624
- return this.$post(`/friends/remove/${username}`);
646
+ return handleMessageOrError(this.$post(`/friends/remove/${username}`));
647
+ }
648
+ async cancel(username) {
649
+ return handleMessageOrError(this.$post(`/friends/cancel/${username}`));
625
650
  }
626
651
  };
627
652
  var FollowingNamespace = class extends Namespace {
628
653
  async follow(username) {
629
- return this.$get("/follow", { username });
654
+ return handleMessageOrError(this.$get("/follow", { username }));
630
655
  }
631
656
  async unfollow(username) {
632
- return this.$get("/unfollow", { username });
657
+ return handleMessageOrError(this.$get("/unfollow", { username }));
633
658
  }
634
659
  async followers(username) {
635
660
  return this.$get("/followers", { username }, false);
package/dist/index.mjs CHANGED
@@ -452,6 +452,12 @@ var ProfilesNamespace = class extends Namespace {
452
452
  getAvatarUrl(username, cache = "") {
453
453
  return `https://avatars.rotur.dev/${username}?v=${cache}`;
454
454
  }
455
+ getOverlayUrl(username, cache = "") {
456
+ return `https://avatars.rotur.dev/.overlay/${username}?v=${cache}`;
457
+ }
458
+ getBannerUrl(username, cache = "") {
459
+ return `https://avatars.rotur.dev/.banners/${username}?v=${cache}`;
460
+ }
455
461
  };
456
462
  var MeNamespace = class extends Namespace {
457
463
  async get() {
@@ -521,8 +527,13 @@ var MeNamespace = class extends Namespace {
521
527
  return this.$get("/check_auth");
522
528
  }
523
529
  async requests() {
524
- return this.$get("/me", void 0).then((u) => ({
525
- requests: u["sys.requests"] ?? []
530
+ return this.$get("/requests", void 0).then((u) => ({
531
+ requests: u.requests ?? []
532
+ }));
533
+ }
534
+ async outgoing() {
535
+ return this.$get("/requests_out", void 0).then((u) => ({
536
+ outgoing: u.requests_out ?? []
526
537
  }));
527
538
  }
528
539
  async transactions() {
@@ -577,29 +588,43 @@ var PostsNamespace = class extends Namespace {
577
588
  return this.$get("/limits", void 0, false);
578
589
  }
579
590
  };
591
+ function handleMessageOrError(res) {
592
+ return res.then((r) => {
593
+ if (r.ok) {
594
+ return { ok: true };
595
+ } else if (r.error) {
596
+ return { ok: false, error: r.error };
597
+ } else {
598
+ return { ok: false, message: r.message };
599
+ }
600
+ });
601
+ }
580
602
  var FriendsNamespace = class extends Namespace {
581
603
  async list() {
582
604
  return this.$get("/friends");
583
605
  }
584
606
  async request(username) {
585
- return this.$post(`/friends/request/${username}`);
607
+ return handleMessageOrError(this.$post(`/friends/request/${username}`));
586
608
  }
587
609
  async accept(username) {
588
- return this.$post(`/friends/accept/${username}`);
610
+ return handleMessageOrError(this.$post(`/friends/accept/${username}`));
589
611
  }
590
612
  async reject(username) {
591
- return this.$post(`/friends/reject/${username}`);
613
+ return handleMessageOrError(this.$post(`/friends/reject/${username}`));
592
614
  }
593
615
  async remove(username) {
594
- return this.$post(`/friends/remove/${username}`);
616
+ return handleMessageOrError(this.$post(`/friends/remove/${username}`));
617
+ }
618
+ async cancel(username) {
619
+ return handleMessageOrError(this.$post(`/friends/cancel/${username}`));
595
620
  }
596
621
  };
597
622
  var FollowingNamespace = class extends Namespace {
598
623
  async follow(username) {
599
- return this.$get("/follow", { username });
624
+ return handleMessageOrError(this.$get("/follow", { username }));
600
625
  }
601
626
  async unfollow(username) {
602
- return this.$get("/unfollow", { username });
627
+ return handleMessageOrError(this.$get("/unfollow", { username }));
603
628
  }
604
629
  async followers(username) {
605
630
  return this.$get("/followers", { username }, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotur-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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",