shogun-relay-sdk 1.0.0
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.d.ts +16 -0
- package/dist/client.js +46 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +28 -0
- package/dist/modules/deals.d.ts +23 -0
- package/dist/modules/deals.js +78 -0
- package/dist/modules/ipfs.d.ts +16 -0
- package/dist/modules/ipfs.js +69 -0
- package/dist/modules/network.d.ts +17 -0
- package/dist/modules/network.js +71 -0
- package/dist/modules/registry.d.ts +18 -0
- package/dist/modules/registry.js +67 -0
- package/dist/modules/system.d.ts +16 -0
- package/dist/modules/system.js +16 -0
- package/dist/modules/uploads.d.ts +8 -0
- package/dist/modules/uploads.js +18 -0
- package/dist/modules/x402.d.ts +15 -0
- package/dist/modules/x402.js +49 -0
- package/package.json +51 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
export interface ApiClientConfig {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
token?: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ApiClient {
|
|
8
|
+
private client;
|
|
9
|
+
private config;
|
|
10
|
+
constructor(config: ApiClientConfig);
|
|
11
|
+
setToken(token: string): void;
|
|
12
|
+
get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
13
|
+
post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
14
|
+
put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
15
|
+
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
16
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApiClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
class ApiClient {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.client = axios_1.default.create({
|
|
12
|
+
baseURL: config.baseURL,
|
|
13
|
+
timeout: config.timeout || 30000,
|
|
14
|
+
headers: {
|
|
15
|
+
'Content-Type': 'application/json',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
// Add auth interceptor
|
|
19
|
+
this.client.interceptors.request.use((req) => {
|
|
20
|
+
if (this.config.token) {
|
|
21
|
+
req.headers['Authorization'] = `Bearer ${this.config.token}`;
|
|
22
|
+
}
|
|
23
|
+
return req;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
setToken(token) {
|
|
27
|
+
this.config.token = token;
|
|
28
|
+
}
|
|
29
|
+
async get(url, config) {
|
|
30
|
+
const response = await this.client.get(url, config);
|
|
31
|
+
return response.data;
|
|
32
|
+
}
|
|
33
|
+
async post(url, data, config) {
|
|
34
|
+
const response = await this.client.post(url, data, config);
|
|
35
|
+
return response.data;
|
|
36
|
+
}
|
|
37
|
+
async put(url, data, config) {
|
|
38
|
+
const response = await this.client.put(url, data, config);
|
|
39
|
+
return response.data;
|
|
40
|
+
}
|
|
41
|
+
async delete(url, config) {
|
|
42
|
+
const response = await this.client.delete(url, config);
|
|
43
|
+
return response.data;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ApiClient = ApiClient;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApiClientConfig } from './client';
|
|
2
|
+
import { SystemModule } from './modules/system';
|
|
3
|
+
import { IpfsModule } from './modules/ipfs';
|
|
4
|
+
import { X402Module } from './modules/x402';
|
|
5
|
+
import { NetworkModule } from './modules/network';
|
|
6
|
+
import { DealsModule } from './modules/deals';
|
|
7
|
+
import { RegistryModule } from './modules/registry';
|
|
8
|
+
import { UploadsModule } from './modules/uploads';
|
|
9
|
+
export declare class ShogunRelaySDK {
|
|
10
|
+
private client;
|
|
11
|
+
system: SystemModule;
|
|
12
|
+
ipfs: IpfsModule;
|
|
13
|
+
x402: X402Module;
|
|
14
|
+
network: NetworkModule;
|
|
15
|
+
deals: DealsModule;
|
|
16
|
+
registry: RegistryModule;
|
|
17
|
+
uploads: UploadsModule;
|
|
18
|
+
constructor(config: ApiClientConfig);
|
|
19
|
+
setToken(token: string): void;
|
|
20
|
+
}
|
|
21
|
+
export default ShogunRelaySDK;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShogunRelaySDK = void 0;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const system_1 = require("./modules/system");
|
|
6
|
+
const ipfs_1 = require("./modules/ipfs");
|
|
7
|
+
const x402_1 = require("./modules/x402");
|
|
8
|
+
const network_1 = require("./modules/network");
|
|
9
|
+
const deals_1 = require("./modules/deals");
|
|
10
|
+
const registry_1 = require("./modules/registry");
|
|
11
|
+
const uploads_1 = require("./modules/uploads");
|
|
12
|
+
class ShogunRelaySDK {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.client = new client_1.ApiClient(config);
|
|
15
|
+
this.system = new system_1.SystemModule(this.client);
|
|
16
|
+
this.ipfs = new ipfs_1.IpfsModule(this.client);
|
|
17
|
+
this.x402 = new x402_1.X402Module(this.client);
|
|
18
|
+
this.network = new network_1.NetworkModule(this.client);
|
|
19
|
+
this.deals = new deals_1.DealsModule(this.client);
|
|
20
|
+
this.registry = new registry_1.RegistryModule(this.client);
|
|
21
|
+
this.uploads = new uploads_1.UploadsModule(this.client);
|
|
22
|
+
}
|
|
23
|
+
setToken(token) {
|
|
24
|
+
this.client.setToken(token);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ShogunRelaySDK = ShogunRelaySDK;
|
|
28
|
+
exports.default = ShogunRelaySDK;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
export declare class DealsModule {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(client: ApiClient);
|
|
5
|
+
getPricing(sizeMB?: number, durationDays?: number, tier?: string): Promise<any>;
|
|
6
|
+
uploadForDeal(fileBuffer: Buffer, filename: string, contentType: string, walletAddress: string): Promise<any>;
|
|
7
|
+
createDeal(dealParams: {
|
|
8
|
+
cid: string;
|
|
9
|
+
clientAddress: string;
|
|
10
|
+
sizeMB: number;
|
|
11
|
+
durationDays: number;
|
|
12
|
+
tier?: string;
|
|
13
|
+
}): Promise<any>;
|
|
14
|
+
activateDeal(dealId: string, payment: any): Promise<any>;
|
|
15
|
+
getDealsByCid(cid: string): Promise<any>;
|
|
16
|
+
getDealsByClient(address: string): Promise<any>;
|
|
17
|
+
getDeal(dealId: string): Promise<any>;
|
|
18
|
+
verifyDeal(dealId: string, clientAddress?: string): Promise<any>;
|
|
19
|
+
renewDeal(dealId: string, additionalDays: number, payment?: any): Promise<any>;
|
|
20
|
+
cancelDeal(dealId: string, clientAddress: string, reason?: string): Promise<any>;
|
|
21
|
+
getDealStats(): Promise<any>;
|
|
22
|
+
getLeaderboard(limit?: number): Promise<any>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DealsModule = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
class DealsModule {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
async getPricing(sizeMB, durationDays, tier) {
|
|
13
|
+
const params = {};
|
|
14
|
+
if (sizeMB)
|
|
15
|
+
params.sizeMB = sizeMB;
|
|
16
|
+
if (durationDays)
|
|
17
|
+
params.durationDays = durationDays;
|
|
18
|
+
if (tier)
|
|
19
|
+
params.tier = tier;
|
|
20
|
+
return this.client.get('/api/v1/deals/pricing', { params });
|
|
21
|
+
}
|
|
22
|
+
async uploadForDeal(fileBuffer, filename, contentType, walletAddress) {
|
|
23
|
+
const form = new form_data_1.default();
|
|
24
|
+
form.append('file', fileBuffer, {
|
|
25
|
+
filename: filename,
|
|
26
|
+
contentType: contentType,
|
|
27
|
+
});
|
|
28
|
+
return this.client.post('/api/v1/deals/upload', form, {
|
|
29
|
+
headers: {
|
|
30
|
+
...form.getHeaders(),
|
|
31
|
+
'x-wallet-address': walletAddress,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async createDeal(dealParams) {
|
|
36
|
+
return this.client.post('/api/v1/deals/create', dealParams);
|
|
37
|
+
}
|
|
38
|
+
async activateDeal(dealId, payment) {
|
|
39
|
+
return this.client.post(`/api/v1/deals/${dealId}/activate`, { payment });
|
|
40
|
+
}
|
|
41
|
+
async getDealsByCid(cid) {
|
|
42
|
+
return this.client.get(`/api/v1/deals/by-cid/${cid}`);
|
|
43
|
+
}
|
|
44
|
+
async getDealsByClient(address) {
|
|
45
|
+
return this.client.get(`/api/v1/deals/by-client/${address}`);
|
|
46
|
+
}
|
|
47
|
+
async getDeal(dealId) {
|
|
48
|
+
return this.client.get(`/api/v1/deals/${dealId}`);
|
|
49
|
+
}
|
|
50
|
+
async verifyDeal(dealId, clientAddress) {
|
|
51
|
+
const params = {};
|
|
52
|
+
if (clientAddress)
|
|
53
|
+
params.clientAddress = clientAddress;
|
|
54
|
+
return this.client.get(`/api/v1/deals/${dealId}/verify`, { params });
|
|
55
|
+
}
|
|
56
|
+
async renewDeal(dealId, additionalDays, payment) {
|
|
57
|
+
return this.client.post(`/api/v1/deals/${dealId}/renew`, {
|
|
58
|
+
additionalDays,
|
|
59
|
+
payment,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async cancelDeal(dealId, clientAddress, reason) {
|
|
63
|
+
return this.client.post(`/api/v1/deals/${dealId}/cancel`, {
|
|
64
|
+
clientAddress,
|
|
65
|
+
reason: reason || 'User requested cancellation',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async getDealStats() {
|
|
69
|
+
return this.client.get('/api/v1/deals/stats');
|
|
70
|
+
}
|
|
71
|
+
async getLeaderboard(limit) {
|
|
72
|
+
const params = {};
|
|
73
|
+
if (limit)
|
|
74
|
+
params.limit = limit;
|
|
75
|
+
return this.client.get('/api/v1/deals/leaderboard', { params });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.DealsModule = DealsModule;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
export declare class IpfsModule {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(client: ApiClient);
|
|
5
|
+
getStatus(): Promise<any>;
|
|
6
|
+
uploadFile(fileBuffer: Buffer, filename: string, contentType: string, userAddress?: string): Promise<any>;
|
|
7
|
+
cat(cid: string): Promise<Buffer>;
|
|
8
|
+
pinAdd(cid: string): Promise<any>;
|
|
9
|
+
pinRm(cid: string): Promise<any>;
|
|
10
|
+
pinLs(): Promise<any>;
|
|
11
|
+
catJson(cid: string): Promise<any>;
|
|
12
|
+
catDecrypt(cid: string, token: string, userAddress?: string): Promise<Buffer>;
|
|
13
|
+
repoGC(): Promise<any>;
|
|
14
|
+
repoStat(): Promise<any>;
|
|
15
|
+
getVersion(): Promise<any>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IpfsModule = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
class IpfsModule {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
async getStatus() {
|
|
13
|
+
return this.client.get('/api/v1/ipfs/status');
|
|
14
|
+
}
|
|
15
|
+
async uploadFile(fileBuffer, filename, contentType, userAddress) {
|
|
16
|
+
const form = new form_data_1.default();
|
|
17
|
+
form.append('file', fileBuffer, {
|
|
18
|
+
filename: filename,
|
|
19
|
+
contentType: contentType,
|
|
20
|
+
});
|
|
21
|
+
const headers = form.getHeaders();
|
|
22
|
+
if (userAddress) {
|
|
23
|
+
headers['x-user-address'] = userAddress;
|
|
24
|
+
}
|
|
25
|
+
return this.client.post('/api/v1/ipfs/upload', form, {
|
|
26
|
+
headers: headers,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async cat(cid) {
|
|
30
|
+
return this.client.get(`/api/v1/ipfs/cat/${cid}`, {
|
|
31
|
+
responseType: 'arraybuffer',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async pinAdd(cid) {
|
|
35
|
+
return this.client.post('/api/v1/ipfs/pin/add', { cid });
|
|
36
|
+
}
|
|
37
|
+
async pinRm(cid) {
|
|
38
|
+
return this.client.post('/api/v1/ipfs/pin/rm', { cid });
|
|
39
|
+
}
|
|
40
|
+
async pinLs() {
|
|
41
|
+
// Note: relay's pin/ls endpoint lists all pins and doesn't support filtering by CID
|
|
42
|
+
return this.client.get('/api/v1/ipfs/pin/ls');
|
|
43
|
+
}
|
|
44
|
+
async catJson(cid) {
|
|
45
|
+
return this.client.get(`/api/v1/ipfs/cat/${cid}/json`);
|
|
46
|
+
}
|
|
47
|
+
async catDecrypt(cid, token, userAddress) {
|
|
48
|
+
const params = { token };
|
|
49
|
+
const headers = {};
|
|
50
|
+
if (userAddress) {
|
|
51
|
+
headers['x-user-address'] = userAddress;
|
|
52
|
+
}
|
|
53
|
+
return this.client.get(`/api/v1/ipfs/cat/${cid}/decrypt`, {
|
|
54
|
+
params,
|
|
55
|
+
headers,
|
|
56
|
+
responseType: 'arraybuffer',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async repoGC() {
|
|
60
|
+
return this.client.post('/api/v1/ipfs/repo/gc');
|
|
61
|
+
}
|
|
62
|
+
async repoStat() {
|
|
63
|
+
return this.client.get('/api/v1/ipfs/repo/stat');
|
|
64
|
+
}
|
|
65
|
+
async getVersion() {
|
|
66
|
+
return this.client.get('/api/v1/ipfs/version');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.IpfsModule = IpfsModule;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
export declare class NetworkModule {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(client: ApiClient);
|
|
5
|
+
getRelays(timeout?: number, maxAge?: number): Promise<any>;
|
|
6
|
+
getRelay(host: string): Promise<any>;
|
|
7
|
+
getStats(): Promise<any>;
|
|
8
|
+
getProof(cid: string, challenge?: string): Promise<any>;
|
|
9
|
+
verifyProof(proof: any): Promise<any>;
|
|
10
|
+
getReputation(host: string): Promise<any>;
|
|
11
|
+
getReputationLeaderboard(minScore?: number, limit?: number): Promise<any>;
|
|
12
|
+
getBestRelays(count?: number, minScore?: number, excludeHost?: string): Promise<any>;
|
|
13
|
+
getOnChainRelays(chainId?: number): Promise<any>;
|
|
14
|
+
getOnChainRelay(address: string, chainId?: number): Promise<any>;
|
|
15
|
+
getOnChainParams(chainId?: number): Promise<any>;
|
|
16
|
+
getPinRequests(maxAge?: number): Promise<any>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NetworkModule = void 0;
|
|
4
|
+
class NetworkModule {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
async getRelays(timeout, maxAge) {
|
|
9
|
+
const params = {};
|
|
10
|
+
if (timeout)
|
|
11
|
+
params.timeout = timeout;
|
|
12
|
+
if (maxAge)
|
|
13
|
+
params.maxAge = maxAge;
|
|
14
|
+
return this.client.get('/api/v1/network/relays', { params });
|
|
15
|
+
}
|
|
16
|
+
async getRelay(host) {
|
|
17
|
+
return this.client.get(`/api/v1/network/relay/${host}`);
|
|
18
|
+
}
|
|
19
|
+
async getStats() {
|
|
20
|
+
return this.client.get('/api/v1/network/stats');
|
|
21
|
+
}
|
|
22
|
+
async getProof(cid, challenge) {
|
|
23
|
+
const params = {};
|
|
24
|
+
if (challenge)
|
|
25
|
+
params.challenge = challenge;
|
|
26
|
+
return this.client.get(`/api/v1/network/proof/${cid}`, { params });
|
|
27
|
+
}
|
|
28
|
+
async verifyProof(proof) {
|
|
29
|
+
return this.client.post('/api/v1/network/verify-proof', { proof });
|
|
30
|
+
}
|
|
31
|
+
async getReputation(host) {
|
|
32
|
+
return this.client.get(`/api/v1/network/reputation/${host}`);
|
|
33
|
+
}
|
|
34
|
+
async getReputationLeaderboard(minScore, limit) {
|
|
35
|
+
const params = {};
|
|
36
|
+
if (minScore)
|
|
37
|
+
params.minScore = minScore;
|
|
38
|
+
if (limit)
|
|
39
|
+
params.limit = limit;
|
|
40
|
+
return this.client.get('/api/v1/network/reputation', { params });
|
|
41
|
+
}
|
|
42
|
+
async getBestRelays(count, minScore, excludeHost) {
|
|
43
|
+
const params = {};
|
|
44
|
+
if (count)
|
|
45
|
+
params.count = count;
|
|
46
|
+
if (minScore)
|
|
47
|
+
params.minScore = minScore;
|
|
48
|
+
if (excludeHost)
|
|
49
|
+
params.exclude = excludeHost;
|
|
50
|
+
return this.client.get('/api/v1/network/best-relays', { params });
|
|
51
|
+
}
|
|
52
|
+
// Note: On-chain endpoints are not available in the relay API
|
|
53
|
+
// Use shogun-contracts-sdk for on-chain interactions instead
|
|
54
|
+
// These methods are kept for backward compatibility but will throw an error
|
|
55
|
+
async getOnChainRelays(chainId) {
|
|
56
|
+
throw new Error('On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.');
|
|
57
|
+
}
|
|
58
|
+
async getOnChainRelay(address, chainId) {
|
|
59
|
+
throw new Error('On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.');
|
|
60
|
+
}
|
|
61
|
+
async getOnChainParams(chainId) {
|
|
62
|
+
throw new Error('On-chain endpoints are not available in relay API. Use shogun-contracts-sdk for on-chain interactions.');
|
|
63
|
+
}
|
|
64
|
+
async getPinRequests(maxAge) {
|
|
65
|
+
const params = {};
|
|
66
|
+
if (maxAge)
|
|
67
|
+
params.maxAge = maxAge;
|
|
68
|
+
return this.client.get('/api/v1/network/pin-requests', { params });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.NetworkModule = NetworkModule;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
export declare class RegistryModule {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(client: ApiClient);
|
|
5
|
+
getStatus(): Promise<any>;
|
|
6
|
+
getBalance(): Promise<any>;
|
|
7
|
+
registerRelay(endpoint: string, gunPubKey: string, stakeAmount: string): Promise<any>;
|
|
8
|
+
updateRelay(newEndpoint?: string, newGunPubKey?: string): Promise<any>;
|
|
9
|
+
increaseStake(amount: string): Promise<any>;
|
|
10
|
+
requestUnstake(): Promise<any>;
|
|
11
|
+
withdrawStake(): Promise<any>;
|
|
12
|
+
getDeals(): Promise<any>;
|
|
13
|
+
griefMissedProof(relayAddress: string, dealId: string, evidence: string): Promise<any>;
|
|
14
|
+
griefDataLoss(relayAddress: string, dealId: string, evidence: string): Promise<any>;
|
|
15
|
+
griefDeal(dealId: string, slashAmount: string, reason: string): Promise<any>;
|
|
16
|
+
getParams(): Promise<any>;
|
|
17
|
+
getConfig(): Promise<any>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegistryModule = void 0;
|
|
4
|
+
class RegistryModule {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
async getStatus() {
|
|
9
|
+
return this.client.get('/api/v1/registry/status');
|
|
10
|
+
}
|
|
11
|
+
async getBalance() {
|
|
12
|
+
return this.client.get('/api/v1/registry/balance');
|
|
13
|
+
}
|
|
14
|
+
async registerRelay(endpoint, gunPubKey, stakeAmount) {
|
|
15
|
+
return this.client.post('/api/v1/registry/register', {
|
|
16
|
+
endpoint,
|
|
17
|
+
gunPubKey,
|
|
18
|
+
stakeAmount,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async updateRelay(newEndpoint, newGunPubKey) {
|
|
22
|
+
return this.client.post('/api/v1/registry/update', {
|
|
23
|
+
newEndpoint,
|
|
24
|
+
newGunPubKey,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async increaseStake(amount) {
|
|
28
|
+
return this.client.post('/api/v1/registry/stake/increase', { amount });
|
|
29
|
+
}
|
|
30
|
+
async requestUnstake() {
|
|
31
|
+
return this.client.post('/api/v1/registry/stake/unstake');
|
|
32
|
+
}
|
|
33
|
+
async withdrawStake() {
|
|
34
|
+
return this.client.post('/api/v1/registry/stake/withdraw');
|
|
35
|
+
}
|
|
36
|
+
async getDeals() {
|
|
37
|
+
return this.client.get('/api/v1/registry/deals');
|
|
38
|
+
}
|
|
39
|
+
async griefMissedProof(relayAddress, dealId, evidence) {
|
|
40
|
+
return this.client.post('/api/v1/registry/grief/missed-proof', {
|
|
41
|
+
relayAddress,
|
|
42
|
+
dealId,
|
|
43
|
+
evidence,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async griefDataLoss(relayAddress, dealId, evidence) {
|
|
47
|
+
return this.client.post('/api/v1/registry/grief/data-loss', {
|
|
48
|
+
relayAddress,
|
|
49
|
+
dealId,
|
|
50
|
+
evidence,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async griefDeal(dealId, slashAmount, reason) {
|
|
54
|
+
return this.client.post('/api/v1/registry/deal/grief', {
|
|
55
|
+
dealId,
|
|
56
|
+
slashAmount,
|
|
57
|
+
reason,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async getParams() {
|
|
61
|
+
return this.client.get('/api/v1/registry/params');
|
|
62
|
+
}
|
|
63
|
+
async getConfig() {
|
|
64
|
+
return this.client.get('/api/v1/registry/config');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.RegistryModule = RegistryModule;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
export interface HealthResponse {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
data: {
|
|
6
|
+
timestamp: string;
|
|
7
|
+
version: string;
|
|
8
|
+
uptime: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare class SystemModule {
|
|
12
|
+
private client;
|
|
13
|
+
constructor(client: ApiClient);
|
|
14
|
+
getHealth(): Promise<HealthResponse>;
|
|
15
|
+
getStats(): Promise<any>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SystemModule = void 0;
|
|
4
|
+
class SystemModule {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
async getHealth() {
|
|
9
|
+
// Use /api/v1/system/health (the correct endpoint in the relay)
|
|
10
|
+
return this.client.get('/api/v1/system/health');
|
|
11
|
+
}
|
|
12
|
+
async getStats() {
|
|
13
|
+
return this.client.get('/api/v1/system/stats');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.SystemModule = SystemModule;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
export declare class UploadsModule {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(client: ApiClient);
|
|
5
|
+
getUserUploads(identifier: string): Promise<any>;
|
|
6
|
+
deleteUpload(identifier: string, hash: string): Promise<any>;
|
|
7
|
+
getSystemHashes(): Promise<any>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UploadsModule = void 0;
|
|
4
|
+
class UploadsModule {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
async getUserUploads(identifier) {
|
|
9
|
+
return this.client.get(`/api/v1/user-uploads/${identifier}`);
|
|
10
|
+
}
|
|
11
|
+
async deleteUpload(identifier, hash) {
|
|
12
|
+
return this.client.delete(`/api/v1/user-uploads/${identifier}/${hash}`);
|
|
13
|
+
}
|
|
14
|
+
async getSystemHashes() {
|
|
15
|
+
return this.client.get('/api/v1/user-uploads/system-hashes');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.UploadsModule = UploadsModule;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
export declare class X402Module {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(client: ApiClient);
|
|
5
|
+
getTiers(): Promise<any>;
|
|
6
|
+
getSubscription(userAddress: string): Promise<any>;
|
|
7
|
+
subscribe(userAddress: string, tier: string, payment?: any): Promise<any>;
|
|
8
|
+
getPaymentRequirements(tier: string): Promise<any>;
|
|
9
|
+
canUpload(userAddress: string, sizeMB: number): Promise<any>;
|
|
10
|
+
getStorageUsage(userAddress: string): Promise<any>;
|
|
11
|
+
canUploadVerified(userAddress: string, sizeMB: number): Promise<any>;
|
|
12
|
+
getRecommendation(fileSizeMB: number, durationDays: number, userAddress?: string): Promise<any>;
|
|
13
|
+
getConfig(): Promise<any>;
|
|
14
|
+
getRelayStorage(): Promise<any>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.X402Module = void 0;
|
|
4
|
+
class X402Module {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
async getTiers() {
|
|
9
|
+
return this.client.get('/api/v1/x402/tiers');
|
|
10
|
+
}
|
|
11
|
+
async getSubscription(userAddress) {
|
|
12
|
+
return this.client.get(`/api/v1/x402/subscription/${userAddress}`);
|
|
13
|
+
}
|
|
14
|
+
async subscribe(userAddress, tier, payment) {
|
|
15
|
+
return this.client.post('/api/v1/x402/subscribe', {
|
|
16
|
+
userAddress,
|
|
17
|
+
tier,
|
|
18
|
+
payment,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async getPaymentRequirements(tier) {
|
|
22
|
+
return this.client.get(`/api/v1/x402/payment-requirements/${tier}`);
|
|
23
|
+
}
|
|
24
|
+
async canUpload(userAddress, sizeMB) {
|
|
25
|
+
return this.client.get(`/api/v1/x402/can-upload/${userAddress}?size=${sizeMB}`);
|
|
26
|
+
}
|
|
27
|
+
async getStorageUsage(userAddress) {
|
|
28
|
+
return this.client.get(`/api/v1/x402/storage/${userAddress}`);
|
|
29
|
+
}
|
|
30
|
+
async canUploadVerified(userAddress, sizeMB) {
|
|
31
|
+
return this.client.get(`/api/v1/x402/can-upload-verified/${userAddress}?size=${sizeMB}`);
|
|
32
|
+
}
|
|
33
|
+
async getRecommendation(fileSizeMB, durationDays, userAddress) {
|
|
34
|
+
const params = {
|
|
35
|
+
fileSizeMB,
|
|
36
|
+
durationDays,
|
|
37
|
+
};
|
|
38
|
+
if (userAddress)
|
|
39
|
+
params.userAddress = userAddress;
|
|
40
|
+
return this.client.get('/api/v1/x402/recommend', { params });
|
|
41
|
+
}
|
|
42
|
+
async getConfig() {
|
|
43
|
+
return this.client.get('/api/v1/x402/config');
|
|
44
|
+
}
|
|
45
|
+
async getRelayStorage() {
|
|
46
|
+
return this.client.get('/api/v1/x402/relay-storage');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.X402Module = X402Module;
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shogun-relay-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDK for interacting with Shogun Relay API - HTTP client for IPFS, deals, registry, and network operations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/**/*.js",
|
|
16
|
+
"dist/**/*.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"shogun",
|
|
25
|
+
"relay",
|
|
26
|
+
"sdk",
|
|
27
|
+
"ipfs",
|
|
28
|
+
"gun",
|
|
29
|
+
"decentralized",
|
|
30
|
+
"storage",
|
|
31
|
+
"api-client"
|
|
32
|
+
],
|
|
33
|
+
"author": "scobru",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/shogun-network/shogun-2.git",
|
|
38
|
+
"directory": "shogun-relay/relay-sdk"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"axios": "^1.6.0",
|
|
42
|
+
"form-data": "^4.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"typescript": "^5.0.0",
|
|
46
|
+
"@types/node": "^20.0.0"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|