shogun-relay-sdk 1.2.9 → 1.2.11

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/client.js CHANGED
@@ -20,6 +20,10 @@ class ApiClient {
20
20
  if (this.config.token) {
21
21
  req.headers["Authorization"] = `Bearer ${this.config.token}`;
22
22
  }
23
+ // If data is FormData, remove Content-Type header to let browser set it with boundary
24
+ if (req.data instanceof FormData) {
25
+ delete req.headers["Content-Type"];
26
+ }
23
27
  return req;
24
28
  });
25
29
  }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,9 @@ import { DealsModule } from "./modules/deals";
7
7
  import { RegistryModule } from "./modules/registry";
8
8
  import { UploadsModule } from "./modules/uploads";
9
9
  import { BridgeModule } from "./modules/bridge";
10
+ import { AnnasArchiveModule } from "./modules/annas-archive";
10
11
  export * from "./types";
12
+ export * from "./modules/annas-archive";
11
13
  export declare class ShogunRelaySDK {
12
14
  private client;
13
15
  system: SystemModule;
@@ -18,6 +20,7 @@ export declare class ShogunRelaySDK {
18
20
  registry: RegistryModule;
19
21
  uploads: UploadsModule;
20
22
  bridge: BridgeModule;
23
+ annasArchive: AnnasArchiveModule;
21
24
  constructor(config: ApiClientConfig);
22
25
  setToken(token: string): void;
23
26
  }
package/dist/index.js CHANGED
@@ -24,8 +24,10 @@ const deals_1 = require("./modules/deals");
24
24
  const registry_1 = require("./modules/registry");
25
25
  const uploads_1 = require("./modules/uploads");
26
26
  const bridge_1 = require("./modules/bridge");
27
+ const annas_archive_1 = require("./modules/annas-archive");
27
28
  // Export types
28
29
  __exportStar(require("./types"), exports);
30
+ __exportStar(require("./modules/annas-archive"), exports);
29
31
  class ShogunRelaySDK {
30
32
  constructor(config) {
31
33
  this.client = new client_1.ApiClient(config);
@@ -37,6 +39,7 @@ class ShogunRelaySDK {
37
39
  this.registry = new registry_1.RegistryModule(this.client);
38
40
  this.uploads = new uploads_1.UploadsModule(this.client);
39
41
  this.bridge = new bridge_1.BridgeModule(this.client);
42
+ this.annasArchive = new annas_archive_1.AnnasArchiveModule(this.client);
40
43
  }
41
44
  setToken(token) {
42
45
  this.client.setToken(token);
@@ -0,0 +1,35 @@
1
+ import { ApiClient } from "../client";
2
+ export interface AnnasArchiveStatus {
3
+ enabled: boolean;
4
+ activeTorrents: number;
5
+ downloadSpeed: number;
6
+ uploadSpeed: number;
7
+ ratio: number;
8
+ torrents: {
9
+ infoHash: string;
10
+ name: string;
11
+ progress: number;
12
+ downloadSpeed: number;
13
+ uploadSpeed: number;
14
+ peers: number;
15
+ }[];
16
+ }
17
+ export declare class AnnasArchiveModule {
18
+ private client;
19
+ constructor(client: ApiClient);
20
+ /**
21
+ * Get Anna's Archive integration status
22
+ */
23
+ getStatus(): Promise<{
24
+ success: boolean;
25
+ data: AnnasArchiveStatus;
26
+ }>;
27
+ /**
28
+ * Add a manual torrent
29
+ * @param magnet Magnet link or URL
30
+ */
31
+ addTorrent(magnet: string): Promise<{
32
+ success: boolean;
33
+ message: string;
34
+ }>;
35
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnnasArchiveModule = void 0;
4
+ class AnnasArchiveModule {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get Anna's Archive integration status
10
+ */
11
+ async getStatus() {
12
+ return this.client.get("/api/v1/annas-archive/status");
13
+ }
14
+ /**
15
+ * Add a manual torrent
16
+ * @param magnet Magnet link or URL
17
+ */
18
+ async addTorrent(magnet) {
19
+ return this.client.post("/api/v1/annas-archive/add", { magnet });
20
+ }
21
+ }
22
+ exports.AnnasArchiveModule = AnnasArchiveModule;
@@ -71,8 +71,11 @@ class IpfsModule {
71
71
  // Format: /api/v0/cat?arg=QmDirectory/index.html
72
72
  const fullPath = `${directoryCid}/${filePath}`;
73
73
  // Encode only the CID part, keep slashes for navigation
74
- const encodedPath = fullPath.includes('/')
75
- ? `${encodeURIComponent(directoryCid)}/${filePath.split('/').map(p => encodeURIComponent(p)).join('/')}`
74
+ const encodedPath = fullPath.includes("/")
75
+ ? `${encodeURIComponent(directoryCid)}/${filePath
76
+ .split("/")
77
+ .map((p) => encodeURIComponent(p))
78
+ .join("/")}`
76
79
  : encodeURIComponent(fullPath);
77
80
  // Use GET instead of POST, or send empty string instead of null to avoid JSON parser error
78
81
  // IPFS API v0 cat accepts POST with empty body, but Express JSON parser fails on null
@@ -131,8 +134,17 @@ class IpfsModule {
131
134
  if (userAddress) {
132
135
  headers["x-user-address"] = userAddress;
133
136
  }
137
+ // Explicitly don't set Content-Type - let browser set it with boundary for FormData
134
138
  return this.client.post("/api/v1/ipfs/upload", formData, {
135
139
  headers: headers,
140
+ // Ensure axios doesn't serialize FormData as JSON
141
+ transformRequest: [(data) => {
142
+ // If it's FormData, return as-is (axios will handle it)
143
+ if (data instanceof form_data_1.default) {
144
+ return data;
145
+ }
146
+ return data;
147
+ }],
136
148
  });
137
149
  }
138
150
  /**
@@ -158,8 +170,17 @@ class IpfsModule {
158
170
  if (userAddress) {
159
171
  headers["x-user-address"] = userAddress;
160
172
  }
173
+ // Explicitly don't set Content-Type - let browser set it with boundary for FormData
161
174
  return this.client.post("/api/v1/ipfs/upload-directory", formData, {
162
175
  headers: headers,
176
+ // Ensure axios doesn't serialize FormData as JSON
177
+ transformRequest: [(data) => {
178
+ // If it's FormData, return as-is (axios will handle it)
179
+ if (data instanceof form_data_1.default) {
180
+ return data;
181
+ }
182
+ return data;
183
+ }],
163
184
  });
164
185
  }
165
186
  /**
@@ -180,8 +201,11 @@ class IpfsModule {
180
201
  */
181
202
  async catFromDirectoryBlob(directoryCid, filePath) {
182
203
  const fullPath = `${directoryCid}/${filePath}`;
183
- const encodedPath = fullPath.includes('/')
184
- ? `${encodeURIComponent(directoryCid)}/${filePath.split('/').map(p => encodeURIComponent(p)).join('/')}`
204
+ const encodedPath = fullPath.includes("/")
205
+ ? `${encodeURIComponent(directoryCid)}/${filePath
206
+ .split("/")
207
+ .map((p) => encodeURIComponent(p))
208
+ .join("/")}`
185
209
  : encodeURIComponent(fullPath);
186
210
  return this.client.post(`/api/v1/ipfs/api/v0/cat?arg=${encodedPath}`, "", {
187
211
  responseType: "blob",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shogun-relay-sdk",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "SDK for interacting with Shogun Relay API - HTTP client for IPFS, deals, registry, and network operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",