shogun-relay-sdk 1.2.4 → 1.2.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/modules/ipfs.d.ts +7 -0
- package/dist/modules/ipfs.js +20 -0
- package/package.json +1 -1
package/dist/modules/ipfs.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export declare class IpfsModule {
|
|
|
19
19
|
contentType?: string;
|
|
20
20
|
}>, userAddress?: string): Promise<any>;
|
|
21
21
|
cat(cid: string): Promise<Buffer>;
|
|
22
|
+
/**
|
|
23
|
+
* Cat a file from an IPFS directory using a relative path
|
|
24
|
+
* @param directoryCid The CID of the directory
|
|
25
|
+
* @param filePath The relative path to the file within the directory (e.g., "index.html" or "css/style.css")
|
|
26
|
+
* @returns Promise with file content as Buffer
|
|
27
|
+
*/
|
|
28
|
+
catFromDirectory(directoryCid: string, filePath: string): Promise<Buffer>;
|
|
22
29
|
pinAdd(cid: string): Promise<any>;
|
|
23
30
|
pinRm(cid: string): Promise<any>;
|
|
24
31
|
pinLs(): Promise<any>;
|
package/dist/modules/ipfs.js
CHANGED
|
@@ -59,6 +59,26 @@ class IpfsModule {
|
|
|
59
59
|
responseType: "arraybuffer",
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Cat a file from an IPFS directory using a relative path
|
|
64
|
+
* @param directoryCid The CID of the directory
|
|
65
|
+
* @param filePath The relative path to the file within the directory (e.g., "index.html" or "css/style.css")
|
|
66
|
+
* @returns Promise with file content as Buffer
|
|
67
|
+
*/
|
|
68
|
+
async catFromDirectory(directoryCid, filePath) {
|
|
69
|
+
// IPFS API supports paths like CID/path/to/file
|
|
70
|
+
// We need to encode the CID but keep slashes for path navigation
|
|
71
|
+
// Format: /api/v0/cat?arg=QmDirectory/index.html
|
|
72
|
+
const fullPath = `${directoryCid}/${filePath}`;
|
|
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('/')}`
|
|
76
|
+
: encodeURIComponent(fullPath);
|
|
77
|
+
return this.client.post(`/api/v1/ipfs/api/v0/cat?arg=${encodedPath}`, null, {
|
|
78
|
+
responseType: "arraybuffer",
|
|
79
|
+
// Don't set Content-Length header - browser will block it
|
|
80
|
+
});
|
|
81
|
+
}
|
|
62
82
|
async pinAdd(cid) {
|
|
63
83
|
return this.client.post("/api/v1/ipfs/pin/add", { cid });
|
|
64
84
|
}
|
package/package.json
CHANGED