@dignetwork/dig-sdk 0.0.1-alpha.17 → 0.0.1-alpha.170
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/DataIntegrityTree/DataIntegrityTree.d.ts +10 -1
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +1 -1
- package/dist/DataIntegrityTree/DataIntegrityTree.js +77 -10
- package/dist/DigNetwork/ContentServer.d.ts +24 -5
- package/dist/DigNetwork/ContentServer.d.ts.map +1 -1
- package/dist/DigNetwork/ContentServer.js +239 -27
- package/dist/DigNetwork/DigNetwork.d.ts +15 -9
- package/dist/DigNetwork/DigNetwork.d.ts.map +1 -1
- package/dist/DigNetwork/DigNetwork.js +129 -189
- package/dist/DigNetwork/DigPeer.d.ts +8 -3
- package/dist/DigNetwork/DigPeer.d.ts.map +1 -1
- package/dist/DigNetwork/DigPeer.js +72 -115
- package/dist/DigNetwork/IncentiveServer.d.ts.map +1 -1
- package/dist/DigNetwork/IncentiveServer.js +6 -5
- package/dist/DigNetwork/PropagationServer.d.ts +88 -33
- package/dist/DigNetwork/PropagationServer.d.ts.map +1 -1
- package/dist/DigNetwork/PropagationServer.js +636 -357
- package/dist/blockchain/DataStore.d.ts +25 -7
- package/dist/blockchain/DataStore.d.ts.map +1 -1
- package/dist/blockchain/DataStore.js +115 -159
- package/dist/blockchain/DataStoreSerializer.d.ts +1 -1
- package/dist/blockchain/DataStoreSerializer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.d.ts +95 -10
- package/dist/blockchain/FullNodePeer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.js +324 -115
- package/dist/blockchain/ServerCoin.d.ts +13 -5
- package/dist/blockchain/ServerCoin.d.ts.map +1 -1
- package/dist/blockchain/ServerCoin.js +90 -28
- package/dist/blockchain/StoreMonitorRegistry.d.ts +85 -0
- package/dist/blockchain/StoreMonitorRegistry.d.ts.map +1 -0
- package/dist/blockchain/StoreMonitorRegistry.js +238 -0
- package/dist/blockchain/Wallet.d.ts +2 -2
- package/dist/blockchain/Wallet.d.ts.map +1 -1
- package/dist/blockchain/Wallet.js +50 -18
- package/dist/blockchain/coins.d.ts +1 -2
- package/dist/blockchain/coins.d.ts.map +1 -1
- package/dist/blockchain/coins.js +1 -55
- package/dist/blockchain/index.d.ts +1 -0
- package/dist/blockchain/index.d.ts.map +1 -1
- package/dist/blockchain/index.js +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/ContentScanner.d.ts +63 -0
- package/dist/utils/ContentScanner.d.ts.map +1 -0
- package/dist/utils/ContentScanner.js +175 -0
- package/dist/utils/Environment.d.ts +21 -0
- package/dist/utils/Environment.d.ts.map +1 -0
- package/dist/utils/Environment.js +93 -0
- package/dist/utils/FileCache.d.ts +1 -1
- package/dist/utils/FileCache.d.ts.map +1 -1
- package/dist/utils/FileCache.js +2 -2
- package/dist/utils/FileTransfer.d.ts +47 -0
- package/dist/utils/FileTransfer.d.ts.map +1 -0
- package/dist/utils/FileTransfer.js +209 -0
- package/dist/utils/NconfManager.js +2 -1
- package/dist/utils/PeerRanker.d.ts +55 -0
- package/dist/utils/PeerRanker.d.ts.map +1 -0
- package/dist/utils/PeerRanker.js +186 -0
- package/dist/utils/StoreArchiveManager.d.ts +45 -0
- package/dist/utils/StoreArchiveManager.d.ts.map +1 -0
- package/dist/utils/StoreArchiveManager.js +153 -0
- package/dist/utils/config.d.ts +4 -3
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +13 -8
- package/dist/utils/directoryUtils.d.ts +16 -0
- package/dist/utils/directoryUtils.d.ts.map +1 -1
- package/dist/utils/directoryUtils.js +66 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/merkle.d.ts +2 -0
- package/dist/utils/merkle.d.ts.map +1 -0
- package/dist/utils/merkle.js +28 -0
- package/dist/utils/network.d.ts +2 -1
- package/dist/utils/network.d.ts.map +1 -1
- package/dist/utils/network.js +40 -15
- package/dist/utils/promiseUtils.d.ts +19 -0
- package/dist/utils/promiseUtils.d.ts.map +1 -0
- package/dist/utils/promiseUtils.js +43 -0
- package/dist/utils/ssl.js +2 -2
- package/package.json +18 -5
- package/dist/utils/deltaUtils.d.ts +0 -2
- package/dist/utils/deltaUtils.d.ts.map +0 -1
- package/dist/utils/deltaUtils.js +0 -83
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncentiveServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/IncentiveServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"IncentiveServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/IncentiveServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,eAAe;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,IAAI,CAAgB;gBAEhB,SAAS,EAAE,MAAM;IAKhB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtD,uBAAuB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAO1D,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAOlE,WAAW;CA6C1B"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.IncentiveServer = void 0;
|
|
7
7
|
const https_1 = __importDefault(require("https"));
|
|
8
8
|
const url_1 = require("url");
|
|
9
|
+
const network_1 = require("../utils/network");
|
|
9
10
|
class IncentiveServer {
|
|
10
11
|
constructor(ipAddress) {
|
|
11
12
|
this.port = 4160;
|
|
@@ -13,27 +14,27 @@ class IncentiveServer {
|
|
|
13
14
|
}
|
|
14
15
|
// Method to create a new incentive program
|
|
15
16
|
async createIncentiveProgram(data) {
|
|
16
|
-
const url = `https://${this.ipAddress}:${this.port}/incentive`;
|
|
17
|
+
const url = `https://${(0, network_1.formatHost)(this.ipAddress)}:${this.port}/incentive`;
|
|
17
18
|
await this.makeRequest(url, "POST", data);
|
|
18
19
|
}
|
|
19
20
|
// Method to update an existing incentive program
|
|
20
21
|
async updateIncentiveProgram(data) {
|
|
21
|
-
const url = `https://${this.ipAddress}:${this.port}/incentive`;
|
|
22
|
+
const url = `https://${(0, network_1.formatHost)(this.ipAddress)}:${this.port}/incentive`;
|
|
22
23
|
await this.makeRequest(url, "PUT", data);
|
|
23
24
|
}
|
|
24
25
|
// Method to delete an incentive program by storeId
|
|
25
26
|
async deleteIncentiveProgram(storeId) {
|
|
26
|
-
const url = `https://${this.ipAddress}:${this.port}/incentive`;
|
|
27
|
+
const url = `https://${(0, network_1.formatHost)(this.ipAddress)}:${this.port}/incentive`;
|
|
27
28
|
await this.makeRequest(url, "DELETE", { storeId });
|
|
28
29
|
}
|
|
29
30
|
// Method to get all incentive programs
|
|
30
31
|
async getAllIncentivePrograms() {
|
|
31
|
-
const url = `https://${this.ipAddress}:${this.port}/incentive`;
|
|
32
|
+
const url = `https://${(0, network_1.formatHost)(this.ipAddress)}:${this.port}/incentive`;
|
|
32
33
|
return this.makeRequest(url, "GET");
|
|
33
34
|
}
|
|
34
35
|
// Method to get a specific incentive program by storeId
|
|
35
36
|
async getIncentiveProgram(storeId) {
|
|
36
|
-
const url = `https://${this.ipAddress}:${this.port}/incentive/${storeId}`;
|
|
37
|
+
const url = `https://${(0, network_1.formatHost)(this.ipAddress)}:${this.port}/incentive/${storeId}`;
|
|
37
38
|
return this.makeRequest(url, "GET");
|
|
38
39
|
}
|
|
39
40
|
// Helper method to handle the HTTPS request
|
|
@@ -1,41 +1,96 @@
|
|
|
1
|
-
import
|
|
1
|
+
import https from "https";
|
|
2
|
+
import { PassThrough } from "stream";
|
|
2
3
|
export declare class PropagationServer {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
storeId: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
wallet: any;
|
|
8
|
+
ipAddress: string;
|
|
9
|
+
certPath: string;
|
|
10
|
+
keyPath: string;
|
|
11
|
+
username: string | undefined;
|
|
12
|
+
password: string | undefined;
|
|
7
13
|
private static readonly port;
|
|
8
|
-
private static readonly
|
|
9
|
-
private static readonly initialDelay;
|
|
10
|
-
private static readonly maxDelay;
|
|
11
|
-
private static readonly delayMultiplier;
|
|
14
|
+
private static readonly inactivityTimeout;
|
|
12
15
|
constructor(ipAddress: string, storeId: string);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Initialize the Wallet instance.
|
|
18
|
+
*/
|
|
19
|
+
initializeWallet(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Create an Axios HTTPS Agent with self-signed certificate allowance.
|
|
22
|
+
*/
|
|
23
|
+
createHttpsAgent(): https.Agent;
|
|
24
|
+
/**
|
|
25
|
+
* Ping the current peer about an update to the store, passing rootHash.
|
|
26
|
+
* @param rootHash - The root hash for the store update.
|
|
27
|
+
*/
|
|
28
|
+
getMyPublicIp(rootHash: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Ping the current peer about an update to the store, passing rootHash.
|
|
31
|
+
* If the combination of ipAddress-storeId-rootHash is cached as "successfully synced", skip the request.
|
|
32
|
+
* @param rootHash - The root hash for the store update.
|
|
33
|
+
*/
|
|
34
|
+
pingUpdate(rootHash: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Adds a custom inactivity timeout for large file transfers.
|
|
37
|
+
*/
|
|
38
|
+
addInactivityTimeout(stream: PassThrough, timeoutMs: number): PassThrough;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the store exists and optionally if a specific rootHash exists.
|
|
41
|
+
* Utilizes caching to improve performance.
|
|
42
|
+
*
|
|
43
|
+
* @param rootHash - (Optional) The root hash to check.
|
|
44
|
+
* @returns A promise that resolves to an object containing store existence and root hash existence.
|
|
45
|
+
*/
|
|
46
|
+
checkStoreExists(rootHash?: string): Promise<{
|
|
47
|
+
storeExists: boolean;
|
|
48
|
+
rootHashExists: boolean;
|
|
21
49
|
}>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Start an upload session by sending a POST request with the rootHash.dat file.
|
|
52
|
+
*/
|
|
53
|
+
startUploadSession(rootHash: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Request a nonce for a file by sending a HEAD request to the server.
|
|
56
|
+
*/
|
|
57
|
+
getFileNonce(filename: string): Promise<{
|
|
25
58
|
nonce: string;
|
|
26
|
-
|
|
27
|
-
generationIndex: number;
|
|
28
|
-
username: string;
|
|
29
|
-
password: string;
|
|
59
|
+
fileExists: boolean;
|
|
30
60
|
}>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Upload a file to the server by sending a PUT request.
|
|
63
|
+
* Logs progress using a local cli-progress bar.
|
|
64
|
+
*/
|
|
65
|
+
uploadFile(label: string, dataPath: string, uncompress?: boolean): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Commit the upload session by sending a POST request to the server.
|
|
68
|
+
*/
|
|
69
|
+
commitUploadSession(): Promise<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Static function to handle the entire upload process for multiple files based on rootHash.
|
|
72
|
+
*/
|
|
73
|
+
static uploadStore(storeId: string, rootHash: string, ipAddress: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Fetch a file from the server by sending a GET request and return its content in memory.
|
|
76
|
+
* Logs progress using a local cli-progress bar.
|
|
77
|
+
*/
|
|
78
|
+
fetchFile(dataPath: string): Promise<Buffer>;
|
|
79
|
+
/**
|
|
80
|
+
* Get details of a file, including whether it exists and its size.
|
|
81
|
+
*/
|
|
82
|
+
getFileDetails(dataPath: string, rootHash: string): Promise<{
|
|
83
|
+
exists: boolean;
|
|
84
|
+
size: number;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Download a file from the server by sending a GET request.
|
|
88
|
+
* Logs progress using a local cli-progress bar.
|
|
89
|
+
*/
|
|
90
|
+
downloadFile(label: string, dataPath: string, rootHash: string, baseDir: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Static function to handle downloading multiple files from a DataStore based on file paths.
|
|
93
|
+
*/
|
|
94
|
+
static downloadStore(storeId: string, rootHash: string, ipAddress: string): Promise<void>;
|
|
40
95
|
}
|
|
41
96
|
//# sourceMappingURL=PropagationServer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropagationServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/PropagationServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PropagationServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/PropagationServer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAuBrC,qBAAa,iBAAiB;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,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