@dignetwork/dig-sdk 0.0.1-alpha.3 → 0.0.1-alpha.30
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 +160 -0
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +1 -0
- package/dist/DataIntegrityTree/DataIntegrityTree.js +672 -0
- package/dist/DataIntegrityTree/DataLayerError.d.ts +6 -0
- package/dist/DataIntegrityTree/DataLayerError.d.ts.map +1 -0
- package/dist/DataIntegrityTree/DataLayerError.js +17 -0
- package/dist/DataIntegrityTree/index.d.ts +2 -0
- package/dist/DataIntegrityTree/index.d.ts.map +1 -0
- package/dist/DataIntegrityTree/index.js +17 -0
- package/dist/DigNetwork/ContentServer.d.ts +5 -1
- package/dist/DigNetwork/ContentServer.d.ts.map +1 -1
- package/dist/DigNetwork/ContentServer.js +26 -11
- package/dist/DigNetwork/DigNetwork.d.ts +3 -1
- package/dist/DigNetwork/DigNetwork.d.ts.map +1 -1
- package/dist/DigNetwork/DigNetwork.js +79 -9
- package/dist/DigNetwork/DigPeer.d.ts +5 -1
- package/dist/DigNetwork/DigPeer.d.ts.map +1 -1
- package/dist/DigNetwork/DigPeer.js +51 -16
- package/dist/DigNetwork/PropagationServer.d.ts.map +1 -1
- package/dist/DigNetwork/PropagationServer.js +39 -42
- package/dist/blockchain/DataStore.d.ts +4 -2
- package/dist/blockchain/DataStore.d.ts.map +1 -1
- package/dist/blockchain/DataStore.js +32 -5
- package/dist/blockchain/DataStoreSerializer.d.ts +1 -1
- package/dist/blockchain/DataStoreSerializer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.d.ts +8 -1
- package/dist/blockchain/FullNodePeer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.js +39 -7
- package/dist/blockchain/ServerCoin.d.ts +11 -3
- package/dist/blockchain/ServerCoin.d.ts.map +1 -1
- package/dist/blockchain/ServerCoin.js +30 -17
- package/dist/blockchain/Wallet.d.ts +1 -1
- package/dist/blockchain/Wallet.d.ts.map +1 -1
- package/dist/blockchain/Wallet.js +1 -1
- package/dist/blockchain/coins.d.ts +1 -1
- package/dist/blockchain/coins.d.ts.map +1 -1
- package/dist/blockchain/coins.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +4 -9
- package/dist/utils/directoryUtils.d.ts +1 -7
- package/dist/utils/directoryUtils.d.ts.map +1 -1
- package/dist/utils/directoryUtils.js +30 -11
- package/package.json +3 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class DataLayerError extends Error {
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
// Call the parent constructor with the message
|
|
6
|
+
super(message);
|
|
7
|
+
// Set the name of the error to the class name
|
|
8
|
+
this.name = this.constructor.name;
|
|
9
|
+
// Assign the custom code
|
|
10
|
+
this.code = code;
|
|
11
|
+
// Capture the stack trace (if available in the environment)
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = DataLayerError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DataIntegrityTree/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DataIntegrityTree"), exports);
|
|
@@ -3,6 +3,8 @@ import { Readable } from "stream";
|
|
|
3
3
|
export declare class ContentServer {
|
|
4
4
|
private ipAddress;
|
|
5
5
|
private storeId;
|
|
6
|
+
private static certPath;
|
|
7
|
+
private static keyPath;
|
|
6
8
|
private static readonly port;
|
|
7
9
|
constructor(ipAddress: string, storeId: string);
|
|
8
10
|
getKey(key: string, rootHash: string, challengeHex?: string): Promise<string>;
|
|
@@ -15,7 +17,9 @@ export declare class ContentServer {
|
|
|
15
17
|
success: boolean;
|
|
16
18
|
headers?: http.IncomingHttpHeaders;
|
|
17
19
|
}>;
|
|
18
|
-
headStore(
|
|
20
|
+
headStore(options?: {
|
|
21
|
+
hasRootHash: string;
|
|
22
|
+
}): Promise<{
|
|
19
23
|
success: boolean;
|
|
20
24
|
headers?: http.IncomingHttpHeaders;
|
|
21
25
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/ContentServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContentServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/ContentServer.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAQ;gBAExB,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAYjC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAa7E,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAepC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC;IAM5B,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAM9B,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAM9B,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC;IAM5B,OAAO,CAClB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAA;KAAE,CAAC;IAMvD,SAAS,CAAC,OAAO,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC;QAChE,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;KACpC,CAAC;IAUK,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;YA0ClC,IAAI;YA0EJ,SAAS;YAMT,gBAAgB;YAiChB,KAAK;CA0DpB"}
|
|
@@ -4,17 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ContentServer = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const http_1 = __importDefault(require("http"));
|
|
8
9
|
const url_1 = require("url");
|
|
10
|
+
const ssl_1 = require("../utils/ssl");
|
|
9
11
|
class ContentServer {
|
|
10
12
|
constructor(ipAddress, storeId) {
|
|
11
13
|
this.ipAddress = ipAddress;
|
|
12
14
|
this.storeId = storeId;
|
|
15
|
+
if (!ContentServer.certPath || !ContentServer.keyPath) {
|
|
16
|
+
const { certPath, keyPath } = (0, ssl_1.getOrCreateSSLCerts)();
|
|
17
|
+
ContentServer.certPath = certPath;
|
|
18
|
+
ContentServer.keyPath = keyPath;
|
|
19
|
+
}
|
|
13
20
|
}
|
|
14
21
|
// Method to get the content of a specified key from the peer, with optional challenge query
|
|
15
22
|
async getKey(key, rootHash, challengeHex) {
|
|
16
23
|
// Construct the base URL
|
|
17
|
-
let url = `
|
|
24
|
+
let url = `https://${this.ipAddress}/chia.${this.storeId}.${rootHash}/${key}`;
|
|
18
25
|
// If a challenge is provided, append it as a query parameter
|
|
19
26
|
if (challengeHex) {
|
|
20
27
|
url += `?challenge=${challengeHex}`;
|
|
@@ -35,38 +42,40 @@ class ContentServer {
|
|
|
35
42
|
}
|
|
36
43
|
// Method to get the .well-known information
|
|
37
44
|
async getWellKnown() {
|
|
38
|
-
const url = `
|
|
45
|
+
const url = `https://${this.ipAddress}/.well-known`;
|
|
39
46
|
return this.fetchJson(url);
|
|
40
47
|
}
|
|
41
48
|
// Method to get the list of known stores
|
|
42
49
|
async getKnownStores() {
|
|
43
|
-
const url = `
|
|
50
|
+
const url = `https://${this.ipAddress}/.well-known/stores`;
|
|
44
51
|
return this.fetchJson(url);
|
|
45
52
|
}
|
|
46
53
|
// Method to get the index of all stores
|
|
47
54
|
async getStoresIndex() {
|
|
48
|
-
const url = `
|
|
55
|
+
const url = `https://${this.ipAddress}/`;
|
|
49
56
|
return this.fetchJson(url);
|
|
50
57
|
}
|
|
51
58
|
// Method to get the index of keys in a store
|
|
52
59
|
async getKeysIndex() {
|
|
53
|
-
const url = `
|
|
60
|
+
const url = `https://${this.ipAddress}/${this.storeId}`;
|
|
54
61
|
return this.fetchJson(url);
|
|
55
62
|
}
|
|
56
63
|
// Method to check if a specific key exists (HEAD request)
|
|
57
64
|
async headKey(key) {
|
|
58
|
-
const url = `
|
|
65
|
+
const url = `https://${this.ipAddress}/${this.storeId}/${key}`;
|
|
59
66
|
return this.head(url); // Return the object from head method
|
|
60
67
|
}
|
|
61
68
|
// Method to check if a specific store exists (HEAD request)
|
|
62
|
-
async headStore() {
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
async headStore(options) {
|
|
70
|
+
let url = `https://${this.ipAddress}/${this.storeId}`;
|
|
71
|
+
if (options?.hasRootHash) {
|
|
72
|
+
url += `hasRootHash=${options.hasRootHash}`;
|
|
73
|
+
}
|
|
65
74
|
return this.head(url); // Return the object from head method
|
|
66
75
|
}
|
|
67
76
|
streamKey(key) {
|
|
68
77
|
return new Promise((resolve, reject) => {
|
|
69
|
-
const url = `
|
|
78
|
+
const url = `https://${this.ipAddress}/${this.storeId}/${key}`;
|
|
70
79
|
const urlObj = new url_1.URL(url);
|
|
71
80
|
const requestOptions = {
|
|
72
81
|
hostname: urlObj.hostname,
|
|
@@ -111,6 +120,9 @@ class ContentServer {
|
|
|
111
120
|
(urlObj.protocol === "http:" ? 80 : ContentServer.port),
|
|
112
121
|
path: urlObj.pathname + urlObj.search,
|
|
113
122
|
method: "HEAD",
|
|
123
|
+
key: fs_1.default.readFileSync(ContentServer.keyPath),
|
|
124
|
+
cert: fs_1.default.readFileSync(ContentServer.certPath),
|
|
125
|
+
rejectUnauthorized: false,
|
|
114
126
|
};
|
|
115
127
|
const request = http_1.default.request(requestOptions, (response) => {
|
|
116
128
|
const { statusCode, headers } = response;
|
|
@@ -201,6 +213,9 @@ class ContentServer {
|
|
|
201
213
|
port: urlObj.port || ContentServer.port,
|
|
202
214
|
path: urlObj.pathname + urlObj.search, // Include query params
|
|
203
215
|
method: "GET",
|
|
216
|
+
key: fs_1.default.readFileSync(ContentServer.keyPath),
|
|
217
|
+
cert: fs_1.default.readFileSync(ContentServer.certPath),
|
|
218
|
+
rejectUnauthorized: false,
|
|
204
219
|
};
|
|
205
220
|
const request = http_1.default.request(requestOptions, (response) => {
|
|
206
221
|
let data = "";
|
|
@@ -240,4 +255,4 @@ class ContentServer {
|
|
|
240
255
|
}
|
|
241
256
|
}
|
|
242
257
|
exports.ContentServer = ContentServer;
|
|
243
|
-
ContentServer.port =
|
|
258
|
+
ContentServer.port = 4161;
|
|
@@ -6,10 +6,12 @@ export declare class DigNetwork {
|
|
|
6
6
|
private peerBlacklist;
|
|
7
7
|
constructor(storeId: string);
|
|
8
8
|
private uploadPreflight;
|
|
9
|
+
uploadStoreHead(digPeer: DigPeer): Promise<void>;
|
|
9
10
|
uploadStore(digPeer: DigPeer): Promise<void>;
|
|
10
11
|
static subscribeToStore(storeId: string): Promise<void>;
|
|
12
|
+
static findPeerWithStoreKey(storeId: string, rootHash: string, key?: string): Promise<string | null>;
|
|
11
13
|
static unsubscribeFromStore(storeId: string): void;
|
|
12
|
-
downloadFiles(forceDownload?: boolean, renderProgressBar?: boolean): Promise<void>;
|
|
14
|
+
downloadFiles(forceDownload?: boolean, renderProgressBar?: boolean, skipData?: boolean): Promise<void>;
|
|
13
15
|
private fetchAvailablePeers;
|
|
14
16
|
private downloadHeightFile;
|
|
15
17
|
private downloadManifestFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DigNetwork.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigNetwork.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAA2B;gBAEpC,OAAO,EAAE,MAAM;YAOb,eAAe;
|
|
1
|
+
{"version":3,"file":"DigNetwork.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigNetwork.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAA2B;gBAEpC,OAAO,EAAE,MAAM;YAOb,eAAe;IA8ChB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDhD,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;WA6BrC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAQhD,oBAAoB,CACtC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;WA2CX,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ5C,aAAa,CACxB,aAAa,GAAE,OAAe,EAC9B,iBAAiB,GAAE,OAAc,EACjC,QAAQ,GAAE,OAAe,GACxB,OAAO,CAAC,IAAI,CAAC;YAqFF,mBAAmB;YAWnB,kBAAkB;YASlB,oBAAoB;YASpB,qBAAqB;YAuErB,cAAc;CAoB7B"}
|
|
@@ -63,18 +63,50 @@ class DigNetwork {
|
|
|
63
63
|
}
|
|
64
64
|
return { generationIndex, lastLocalRootHash };
|
|
65
65
|
}
|
|
66
|
+
async uploadStoreHead(digPeer) {
|
|
67
|
+
// First make sure that the remote store is up to date.
|
|
68
|
+
const rootHistory = await this.dataStore.getRootHistory();
|
|
69
|
+
const localManifestHashes = await this.dataStore.getManifestHashes();
|
|
70
|
+
const remoteManifestFile = await digPeer.propagationServer.getStoreData("manifest.dat");
|
|
71
|
+
const remoteManifestHashes = remoteManifestFile.split("\n").filter(Boolean);
|
|
72
|
+
const onChainRootHashes = rootHistory.map((root) => root.root_hash);
|
|
73
|
+
// Check that remote manifest is one behind on-chain root hashes
|
|
74
|
+
if (remoteManifestHashes.length !== onChainRootHashes.length - 1) {
|
|
75
|
+
throw new Error("Remote manifest should be one behind the on-chain root. Cannot push head.");
|
|
76
|
+
}
|
|
77
|
+
// Compare each remote manifest hash with the corresponding on-chain root hash
|
|
78
|
+
for (let i = 0; i < remoteManifestHashes.length; i++) {
|
|
79
|
+
if (remoteManifestHashes[i] !== onChainRootHashes[i]) {
|
|
80
|
+
throw new Error(`Remote manifest does not match on-chain root at index ${i}. Cannot push head.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Get the files for the latest local manifest hash
|
|
84
|
+
const filesToUpload = await this.dataStore.getFileSetForRootHash(localManifestHashes[localManifestHashes.length - 1]);
|
|
85
|
+
if (!filesToUpload.length) {
|
|
86
|
+
console.log("No files to upload.");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Upload files to the remote peer with a progress bar
|
|
90
|
+
await this.runProgressBar(filesToUpload.length, "Store Data", async (progress) => {
|
|
91
|
+
for (const filePath of filesToUpload) {
|
|
92
|
+
const relativePath = path
|
|
93
|
+
.relative(this.storeDir, filePath)
|
|
94
|
+
.replace(/\\/g, "/");
|
|
95
|
+
await digPeer.propagationServer.pushFile(filePath, relativePath);
|
|
96
|
+
progress.increment();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
66
100
|
// Uploads the store to a specific peer
|
|
67
101
|
async uploadStore(digPeer) {
|
|
68
102
|
const { generationIndex } = await this.uploadPreflight(digPeer);
|
|
69
103
|
const filesToUpload = await (0, deltaUtils_1.getDeltaFiles)(this.dataStore.StoreId, generationIndex, path.resolve(config_1.DIG_FOLDER_PATH, "stores"));
|
|
70
|
-
console.log(filesToUpload);
|
|
71
104
|
if (!filesToUpload.length) {
|
|
72
105
|
console.log("No files to upload.");
|
|
73
106
|
return;
|
|
74
107
|
}
|
|
75
108
|
await this.runProgressBar(filesToUpload.length, "Store Data", async (progress) => {
|
|
76
109
|
for (const filePath of filesToUpload) {
|
|
77
|
-
console.log(`Uploading ${filePath}...`);
|
|
78
110
|
const relativePath = path
|
|
79
111
|
.relative(this.storeDir, filePath)
|
|
80
112
|
.replace(/\\/g, "/");
|
|
@@ -90,12 +122,46 @@ class DigNetwork {
|
|
|
90
122
|
const digNetwork = new DigNetwork(storeId);
|
|
91
123
|
await digNetwork.downloadFiles(true);
|
|
92
124
|
}
|
|
125
|
+
static async findPeerWithStoreKey(storeId, rootHash, key) {
|
|
126
|
+
const peerBlackList = [];
|
|
127
|
+
const serverCoin = new blockchain_1.ServerCoin(storeId);
|
|
128
|
+
while (true) {
|
|
129
|
+
try {
|
|
130
|
+
const digPeers = await serverCoin.sampleCurrentEpoch(1, peerBlackList);
|
|
131
|
+
if (digPeers.length === 0)
|
|
132
|
+
break;
|
|
133
|
+
const peerIp = digPeers[0];
|
|
134
|
+
const digPeer = new DigPeer_1.DigPeer(peerIp, storeId);
|
|
135
|
+
const storeResponse = await digPeer.contentServer.headStore({
|
|
136
|
+
hasRootHash: rootHash,
|
|
137
|
+
});
|
|
138
|
+
if (storeResponse.success &&
|
|
139
|
+
storeResponse.headers?.["x-has-rootHash"] === "true") {
|
|
140
|
+
if (!key)
|
|
141
|
+
return peerIp;
|
|
142
|
+
const keyResponse = await digPeer.contentServer.headKey(key);
|
|
143
|
+
if (keyResponse.success &&
|
|
144
|
+
keyResponse.headers?.["x-key-exists"] === "true") {
|
|
145
|
+
return peerIp;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
peerBlackList.push(peerIp);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
console.error("Error while sampling the epoch or contacting peer:", error);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
93
157
|
static unsubscribeFromStore(storeId) {
|
|
94
|
-
fs.rmdirSync(path.join(config_1.DIG_FOLDER_PATH, "stores", storeId), {
|
|
158
|
+
fs.rmdirSync(path.join(config_1.DIG_FOLDER_PATH, "stores", storeId), {
|
|
159
|
+
recursive: true,
|
|
160
|
+
});
|
|
95
161
|
fs.unlinkSync(path.join(config_1.DIG_FOLDER_PATH, "stores", storeId + ".json"));
|
|
96
162
|
}
|
|
97
163
|
// Downloads files from the network based on the manifest
|
|
98
|
-
async downloadFiles(forceDownload = false, renderProgressBar = true) {
|
|
164
|
+
async downloadFiles(forceDownload = false, renderProgressBar = true, skipData = false) {
|
|
99
165
|
try {
|
|
100
166
|
const rootHistory = await this.dataStore.getRootHistory();
|
|
101
167
|
if (!rootHistory.length)
|
|
@@ -124,10 +190,12 @@ class DigNetwork {
|
|
|
124
190
|
const datFileContent = JSON.parse(fs.readFileSync(datFilePath, "utf-8"));
|
|
125
191
|
if (datFileContent.root !== rootHash)
|
|
126
192
|
throw new Error("Root hash mismatch");
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
193
|
+
if (!skipData) {
|
|
194
|
+
for (const file of Object.keys(datFileContent.files)) {
|
|
195
|
+
const filePath = (0, hashUtils_1.getFilePathFromSha256)(datFileContent.files[file].sha256, path.join(this.storeDir, "data"));
|
|
196
|
+
const isInDataDir = filePath.startsWith(path.join(this.storeDir, "data"));
|
|
197
|
+
await this.downloadFileFromPeers((0, hashUtils_1.getFilePathFromSha256)(datFileContent.files[file].sha256, "data"), filePath, forceDownload || !isInDataDir);
|
|
198
|
+
}
|
|
131
199
|
}
|
|
132
200
|
if (localManifestHashes[i] !== rootHash)
|
|
133
201
|
newRootHashes.push(rootHash);
|
|
@@ -216,7 +284,9 @@ class DigNetwork {
|
|
|
216
284
|
noTTYOutput: true,
|
|
217
285
|
}, cli_progress_1.Presets.shades_classic);
|
|
218
286
|
const progress = multiBar.create(total, 0, { name });
|
|
219
|
-
await task(progress).finally(() =>
|
|
287
|
+
await task(progress).finally(() => {
|
|
288
|
+
multiBar.stop();
|
|
289
|
+
});
|
|
220
290
|
}
|
|
221
291
|
}
|
|
222
292
|
exports.DigNetwork = DigNetwork;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ContentServer } from "./ContentServer";
|
|
2
2
|
import { PropagationServer } from "./PropagationServer";
|
|
3
3
|
import { IncentiveServer } from "./IncentiveServer";
|
|
4
|
+
import { Output } from "@dignetwork/datalayer-driver";
|
|
4
5
|
export declare class DigPeer {
|
|
5
6
|
private ipAddress;
|
|
6
7
|
private storeId;
|
|
@@ -14,6 +15,9 @@ export declare class DigPeer {
|
|
|
14
15
|
get IpAddress(): string;
|
|
15
16
|
validateStore(rootHash: string, keys: string[]): Promise<boolean>;
|
|
16
17
|
isSynced(): Promise<boolean>;
|
|
17
|
-
|
|
18
|
+
static sendEqualBulkPayments(walletName: string, addresses: string[], totalAmount: bigint, memos: Buffer[]): Promise<void>;
|
|
19
|
+
static sendBulkPayments(walletName: string, outputs: Output[]): Promise<void>;
|
|
20
|
+
sendPayment(walletName: string, amount: bigint, memos?: Buffer[]): Promise<void>;
|
|
21
|
+
static createPaymentHint(storeId: Buffer): Buffer;
|
|
18
22
|
}
|
|
19
23
|
//# sourceMappingURL=DigPeer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DigPeer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigPeer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"DigPeer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigPeer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAKL,MAAM,EACP,MAAM,8BAA8B,CAAC;AAKtC,qBAAa,OAAO;IAClB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,kBAAkB,CAAoB;IAC9C,OAAO,CAAC,gBAAgB,CAAkB;gBAE9B,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAS9C,IAAW,aAAa,IAAI,aAAa,CAExC;IAGD,IAAW,iBAAiB,IAAI,iBAAiB,CAEhD;IAGD,IAAW,eAAe,IAAI,eAAe,CAE5C;IAED,IAAW,SAAS,IAAI,MAAM,CAE7B;IAEY,aAAa,CACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,OAAO,CAAC;IAgHN,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;WA2B3B,qBAAqB,CACjC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EAAE,EACnB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,IAAI,CAAC;WAuBI,gBAAgB,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC;IAwCH,WAAW,CACtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAM,EAAO,GACnB,OAAO,CAAC,IAAI,CAAC;WAYF,iBAAiB,CAAC,OAAO,EAAE,MAAM;CAoBhD"}
|
|
@@ -9,8 +9,8 @@ const ContentServer_1 = require("./ContentServer");
|
|
|
9
9
|
const PropagationServer_1 = require("./PropagationServer");
|
|
10
10
|
const IncentiveServer_1 = require("./IncentiveServer");
|
|
11
11
|
const blockchain_1 = require("../blockchain");
|
|
12
|
-
const
|
|
13
|
-
const datalayer_driver_1 = require("datalayer-driver");
|
|
12
|
+
const DataIntegrityTree_1 = require("../DataIntegrityTree");
|
|
13
|
+
const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
|
|
14
14
|
const blockchain_2 = require("../blockchain");
|
|
15
15
|
const blockchain_3 = require("../blockchain");
|
|
16
16
|
const coins_1 = require("../blockchain/coins");
|
|
@@ -97,7 +97,7 @@ class DigPeer {
|
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
// Perform tree integrity validation using the datFileContent and the root hash
|
|
100
|
-
const treeCheck =
|
|
100
|
+
const treeCheck = DataIntegrityTree_1.DataIntegrityTree.validateKeyIntegrityWithForeignTree(key, fileData.sha256, datFileContent, rootHash);
|
|
101
101
|
if (!treeCheck) {
|
|
102
102
|
console.error(`Tree validation failed for file ${key}.`);
|
|
103
103
|
filesIntegrityIntact = false;
|
|
@@ -137,22 +137,31 @@ class DigPeer {
|
|
|
137
137
|
return false;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
static sendEqualBulkPayments(walletName, addresses, totalAmount, memos) {
|
|
141
|
+
// Use a Set to ensure unique addresses
|
|
142
|
+
const uniqueAddresses = Array.from(new Set(addresses));
|
|
143
|
+
// Convert unique addresses to puzzle hashes
|
|
144
|
+
const puzzleHashes = uniqueAddresses.map((address) => (0, datalayer_driver_1.addressToPuzzleHash)(address));
|
|
145
|
+
// Calculate amount per puzzle hash
|
|
146
|
+
const amountPerPuzzleHash = totalAmount / BigInt(puzzleHashes.length);
|
|
147
|
+
// Create outputs array
|
|
148
|
+
const outputs = puzzleHashes.map((puzzleHash) => ({
|
|
149
|
+
puzzleHash,
|
|
150
|
+
amount: amountPerPuzzleHash,
|
|
151
|
+
memos,
|
|
152
|
+
}));
|
|
153
|
+
// Call the sendBulkPayments function with the generated outputs
|
|
154
|
+
return DigPeer.sendBulkPayments(walletName, outputs);
|
|
155
|
+
}
|
|
156
|
+
static async sendBulkPayments(walletName, outputs) {
|
|
157
|
+
const feePerCondition = BigInt(1000);
|
|
158
|
+
const totalFee = feePerCondition * BigInt(outputs.length);
|
|
144
159
|
const wallet = await blockchain_3.Wallet.load(walletName);
|
|
145
160
|
const publicSyntheticKey = await wallet.getPublicSyntheticKey();
|
|
146
161
|
const peer = await blockchain_2.FullNodePeer.connect();
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
{
|
|
151
|
-
puzzleHash: paymentAddressPuzzleHash,
|
|
152
|
-
amount: amount,
|
|
153
|
-
},
|
|
154
|
-
];
|
|
155
|
-
const coinSpends = await (0, datalayer_driver_1.sendXch)(publicSyntheticKey, coins, outputs, fee);
|
|
162
|
+
const totalAmount = outputs.reduce((acc, output) => acc + output.amount, BigInt(0));
|
|
163
|
+
const coins = await (0, coins_1.selectUnspentCoins)(peer, totalAmount, totalFee, [], walletName);
|
|
164
|
+
const coinSpends = await (0, datalayer_driver_1.sendXch)(publicSyntheticKey, coins, outputs, totalFee);
|
|
156
165
|
const sig = (0, datalayer_driver_1.signCoinSpends)(coinSpends, [await wallet.getPrivateSyntheticKey()], false);
|
|
157
166
|
const err = await peer.broadcastSpend(coinSpends, [sig]);
|
|
158
167
|
if (err) {
|
|
@@ -160,5 +169,31 @@ class DigPeer {
|
|
|
160
169
|
}
|
|
161
170
|
await blockchain_2.FullNodePeer.waitForConfirmation((0, datalayer_driver_1.getCoinId)(coins[0]));
|
|
162
171
|
}
|
|
172
|
+
async sendPayment(walletName, amount, memos = []) {
|
|
173
|
+
const paymentAddress = await this.contentServer.getPaymentAddress();
|
|
174
|
+
const paymentAddressPuzzleHash = (0, datalayer_driver_1.addressToPuzzleHash)(paymentAddress);
|
|
175
|
+
const output = {
|
|
176
|
+
puzzleHash: paymentAddressPuzzleHash,
|
|
177
|
+
amount,
|
|
178
|
+
memos,
|
|
179
|
+
};
|
|
180
|
+
return DigPeer.sendBulkPayments(walletName, [output]);
|
|
181
|
+
}
|
|
182
|
+
static createPaymentHint(storeId) {
|
|
183
|
+
// Ensure the input is a 32-byte buffer
|
|
184
|
+
if (!Buffer.isBuffer(storeId) || storeId.length !== 32) {
|
|
185
|
+
throw new Error("Invalid input. Must be a 32-byte buffer.");
|
|
186
|
+
}
|
|
187
|
+
// Define the seed
|
|
188
|
+
const seed = "dig";
|
|
189
|
+
// Combine the seed and the original buffer
|
|
190
|
+
const combinedBuffer = Buffer.concat([Buffer.from(seed), storeId]);
|
|
191
|
+
// Apply SHA-256 hash to the combined buffer
|
|
192
|
+
const hash = crypto_1.default.createHash("sha256");
|
|
193
|
+
hash.update(combinedBuffer);
|
|
194
|
+
const transformedBuffer = hash.digest();
|
|
195
|
+
// Return the 32-byte hash as a hex string
|
|
196
|
+
return transformedBuffer;
|
|
197
|
+
}
|
|
163
198
|
}
|
|
164
199
|
exports.DigPeer = DigPeer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropagationServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/PropagationServer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAQ;IACpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAK;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAQ;IAC5C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAS;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,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const credentialsUtils_1 = require("../utils/credentialsUtils");
|
|
12
|
-
const spinnerUtils_1 = require("../utils/spinnerUtils");
|
|
13
12
|
const blockchain_1 = require("../blockchain");
|
|
14
13
|
class PropagationServer {
|
|
15
14
|
constructor(ipAddress, storeId) {
|
|
@@ -122,51 +121,49 @@ class PropagationServer {
|
|
|
122
121
|
// Method to fetch upload details from the server
|
|
123
122
|
async fetchUploadDetails(username, password) {
|
|
124
123
|
const remote = `https://${this.ipAddress}:${PropagationServer.port}/${this.storeId}`;
|
|
125
|
-
return (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
reject(new Error("Missing required headers in the response."));
|
|
157
|
-
}
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
const url = new url_1.URL(remote);
|
|
126
|
+
const options = {
|
|
127
|
+
hostname: url.hostname,
|
|
128
|
+
port: url.port,
|
|
129
|
+
path: url.pathname,
|
|
130
|
+
method: "HEAD",
|
|
131
|
+
headers: {
|
|
132
|
+
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`,
|
|
133
|
+
},
|
|
134
|
+
key: fs_1.default.readFileSync(PropagationServer.keyPath),
|
|
135
|
+
cert: fs_1.default.readFileSync(PropagationServer.certPath),
|
|
136
|
+
rejectUnauthorized: false, // Allow self-signed certificates
|
|
137
|
+
};
|
|
138
|
+
const req = https_1.default.request(options, (res) => {
|
|
139
|
+
if (res.statusCode === 200) {
|
|
140
|
+
// Check if the headers are present and valid
|
|
141
|
+
const nonce = res.headers["x-nonce"];
|
|
142
|
+
const lastUploadedHash = res.headers?.["x-last-uploaded-hash"] ||
|
|
143
|
+
"0000000000000000000000000000000000000000000000000000000000000000";
|
|
144
|
+
const generationIndex = res.headers?.["x-generation-index"] || 0;
|
|
145
|
+
console.log({ nonce, lastUploadedHash, generationIndex });
|
|
146
|
+
if (nonce) {
|
|
147
|
+
resolve({
|
|
148
|
+
nonce: nonce,
|
|
149
|
+
lastUploadedHash: lastUploadedHash,
|
|
150
|
+
generationIndex: Number(generationIndex),
|
|
151
|
+
});
|
|
158
152
|
}
|
|
159
153
|
else {
|
|
160
|
-
reject(new Error(
|
|
154
|
+
reject(new Error("Missing required headers in the response."));
|
|
161
155
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
reject(new Error(`Failed to perform preflight check: ${res.statusCode} ${res.statusMessage}`));
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
req.on("error", (err) => {
|
|
162
|
+
console.error(err.message);
|
|
163
|
+
resolve(false); // Resolve to false if there is an error
|
|
168
164
|
});
|
|
169
|
-
|
|
165
|
+
req.end();
|
|
166
|
+
});
|
|
170
167
|
}
|
|
171
168
|
// Core method to upload a file directly to the server using a stream
|
|
172
169
|
async uploadFileDirect(filePath, uploadUrl, username, password, keyOwnershipSig, publicKey, nonce) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DataStore as DataStoreDriver, DataStoreMetadata } from "datalayer-driver";
|
|
1
|
+
import { DataStore as DataStoreDriver, DataStoreMetadata } from "@dignetwork/datalayer-driver";
|
|
2
2
|
import { RootHistoryItem } from "../types";
|
|
3
|
-
import { DataIntegrityTree, DataIntegrityTreeOptions } from "
|
|
3
|
+
import { DataIntegrityTree, DataIntegrityTreeOptions } from "../DataIntegrityTree";
|
|
4
4
|
import { CreateStoreUserInputs } from "../types";
|
|
5
5
|
export declare class DataStore {
|
|
6
6
|
private storeId;
|
|
@@ -50,5 +50,7 @@ export declare class DataStore {
|
|
|
50
50
|
isSynced(): Promise<boolean>;
|
|
51
51
|
hasMetaWritePermissions(publicSyntheticKey?: Buffer): Promise<boolean>;
|
|
52
52
|
updateMetadata(metadata: DataStoreMetadata): Promise<DataStoreDriver>;
|
|
53
|
+
getFileSetForRootHash(rootHash: string): Promise<string[]>;
|
|
54
|
+
getManifestHashes(): string[];
|
|
53
55
|
}
|
|
54
56
|
//# sourceMappingURL=DataStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataStore.d.ts","sourceRoot":"","sources":["../../src/blockchain/DataStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,SAAS,IAAI,eAAe,EAE5B,iBAAiB,EAIlB,MAAM,
|
|
1
|
+
{"version":3,"file":"DataStore.d.ts","sourceRoot":"","sources":["../../src/blockchain/DataStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,SAAS,IAAI,eAAe,EAE5B,iBAAiB,EAIlB,MAAM,8BAA8B,CAAC;AAYtC,OAAO,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAGpD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAQjD,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAoB;gBAEpB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAiB/D,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,IAAI,IAAI,iBAAiB,CAEnC;IAEM,QAAQ,IAAI,MAAM;IAIlB,QAAQ,IAAI,MAAM;IAIlB,SAAS,IAAI,MAAM;WAMN,cAAc,IAAI,OAAO,CAAC,SAAS,GAAG,S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