@dignetwork/dig-sdk 0.0.1-alpha.99 → 0.1.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/LICENSE +21 -7
- package/README.md +267 -0
- package/dist/adapters.cjs +315 -0
- package/dist/adapters.cjs.map +1 -0
- package/dist/adapters.d.cts +20 -0
- package/dist/adapters.d.ts +20 -0
- package/dist/adapters.js +306 -0
- package/dist/adapters.js.map +1 -0
- package/dist/dev-shim-Bgw8X2E9.d.cts +118 -0
- package/dist/dev-shim-Bgw8X2E9.d.ts +118 -0
- package/dist/dig-client-entry-BIzuZ7Rs.d.cts +263 -0
- package/dist/dig-client-entry-BIzuZ7Rs.d.ts +263 -0
- package/dist/dig-client.cjs +330 -0
- package/dist/dig-client.cjs.map +1 -0
- package/dist/dig-client.d.cts +1 -0
- package/dist/dig-client.d.ts +1 -0
- package/dist/dig-client.js +319 -0
- package/dist/dig-client.js.map +1 -0
- package/dist/index.cjs +754 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +192 -0
- package/dist/index.d.ts +192 -5
- package/dist/index.js +731 -19
- package/dist/index.js.map +1 -0
- package/dist/next.cjs +326 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +23 -0
- package/dist/next.d.ts +23 -0
- package/dist/next.js +319 -0
- package/dist/next.js.map +1 -0
- package/dist/spend.cjs +14 -0
- package/dist/spend.cjs.map +1 -0
- package/dist/spend.d.cts +1 -0
- package/dist/spend.d.ts +1 -0
- package/dist/spend.js +3 -0
- package/dist/spend.js.map +1 -0
- package/dist/vite.cjs +338 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +35 -0
- package/dist/vite.d.ts +35 -0
- package/dist/vite.js +332 -0
- package/dist/vite.js.map +1 -0
- package/package.json +87 -59
- package/vendor/PROVENANCE.md +102 -0
- package/vendor/dig_client.d.ts +150 -0
- package/vendor/dig_client.mjs +805 -0
- package/vendor/dig_client_bg.wasm +0 -0
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts +0 -163
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +0 -1
- package/dist/DataIntegrityTree/DataIntegrityTree.js +0 -707
- package/dist/DataIntegrityTree/DataLayerError.d.ts +0 -6
- package/dist/DataIntegrityTree/DataLayerError.d.ts.map +0 -1
- package/dist/DataIntegrityTree/DataLayerError.js +0 -17
- package/dist/DataIntegrityTree/index.d.ts +0 -2
- package/dist/DataIntegrityTree/index.d.ts.map +0 -1
- package/dist/DataIntegrityTree/index.js +0 -17
- package/dist/DigNetwork/ContentServer.d.ts +0 -31
- package/dist/DigNetwork/ContentServer.d.ts.map +0 -1
- package/dist/DigNetwork/ContentServer.js +0 -176
- package/dist/DigNetwork/DigChallenge.d.ts +0 -82
- package/dist/DigNetwork/DigChallenge.d.ts.map +0 -1
- package/dist/DigNetwork/DigChallenge.js +0 -144
- package/dist/DigNetwork/DigNetwork.d.ts +0 -14
- package/dist/DigNetwork/DigNetwork.d.ts.map +0 -1
- package/dist/DigNetwork/DigNetwork.js +0 -169
- package/dist/DigNetwork/DigPeer.d.ts +0 -24
- package/dist/DigNetwork/DigPeer.d.ts.map +0 -1
- package/dist/DigNetwork/DigPeer.js +0 -118
- package/dist/DigNetwork/IncentiveServer.d.ts +0 -13
- package/dist/DigNetwork/IncentiveServer.d.ts.map +0 -1
- package/dist/DigNetwork/IncentiveServer.js +0 -76
- package/dist/DigNetwork/PropagationServer.d.ts +0 -81
- package/dist/DigNetwork/PropagationServer.d.ts.map +0 -1
- package/dist/DigNetwork/PropagationServer.js +0 -563
- package/dist/DigNetwork/index.d.ts +0 -4
- package/dist/DigNetwork/index.d.ts.map +0 -1
- package/dist/DigNetwork/index.js +0 -19
- package/dist/blockchain/DataStore.d.ts +0 -67
- package/dist/blockchain/DataStore.d.ts.map +0 -1
- package/dist/blockchain/DataStore.js +0 -413
- package/dist/blockchain/DataStoreSerializer.d.ts +0 -52
- package/dist/blockchain/DataStoreSerializer.d.ts.map +0 -1
- package/dist/blockchain/DataStoreSerializer.js +0 -109
- package/dist/blockchain/FullNodePeer.d.ts +0 -31
- package/dist/blockchain/FullNodePeer.d.ts.map +0 -1
- package/dist/blockchain/FullNodePeer.js +0 -295
- package/dist/blockchain/ServerCoin.d.ts +0 -29
- package/dist/blockchain/ServerCoin.d.ts.map +0 -1
- package/dist/blockchain/ServerCoin.js +0 -324
- package/dist/blockchain/Wallet.d.ts +0 -28
- package/dist/blockchain/Wallet.d.ts.map +0 -1
- package/dist/blockchain/Wallet.js +0 -253
- package/dist/blockchain/coins.d.ts +0 -6
- package/dist/blockchain/coins.d.ts.map +0 -1
- package/dist/blockchain/coins.js +0 -102
- package/dist/blockchain/index.d.ts +0 -8
- package/dist/blockchain/index.d.ts.map +0 -1
- package/dist/blockchain/index.js +0 -36
- package/dist/index.d.ts.map +0 -1
- package/dist/prompts.d.ts +0 -21
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -149
- package/dist/types.d.ts +0 -64
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/utils/ContentScanner.d.ts +0 -63
- package/dist/utils/ContentScanner.d.ts.map +0 -1
- package/dist/utils/ContentScanner.js +0 -175
- package/dist/utils/Environment.d.ts +0 -18
- package/dist/utils/Environment.d.ts.map +0 -1
- package/dist/utils/Environment.js +0 -85
- package/dist/utils/FileCache.d.ts +0 -11
- package/dist/utils/FileCache.d.ts.map +0 -1
- package/dist/utils/FileCache.js +0 -58
- package/dist/utils/FileTransfer.d.ts +0 -47
- package/dist/utils/FileTransfer.d.ts.map +0 -1
- package/dist/utils/FileTransfer.js +0 -209
- package/dist/utils/NconfManager.d.ts +0 -11
- package/dist/utils/NconfManager.d.ts.map +0 -1
- package/dist/utils/NconfManager.js +0 -56
- package/dist/utils/StoreArchiveManager.d.ts +0 -45
- package/dist/utils/StoreArchiveManager.d.ts.map +0 -1
- package/dist/utils/StoreArchiveManager.js +0 -153
- package/dist/utils/asyncPool.d.ts +0 -9
- package/dist/utils/asyncPool.d.ts.map +0 -1
- package/dist/utils/asyncPool.js +0 -23
- package/dist/utils/config.d.ts +0 -68
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -223
- package/dist/utils/connectionUtils.d.ts +0 -10
- package/dist/utils/connectionUtils.d.ts.map +0 -1
- package/dist/utils/connectionUtils.js +0 -18
- package/dist/utils/credentialsUtils.d.ts +0 -8
- package/dist/utils/credentialsUtils.d.ts.map +0 -1
- package/dist/utils/credentialsUtils.js +0 -122
- package/dist/utils/directoryUtils.d.ts +0 -9
- package/dist/utils/directoryUtils.d.ts.map +0 -1
- package/dist/utils/directoryUtils.js +0 -110
- package/dist/utils/encryption.d.ts +0 -8
- package/dist/utils/encryption.d.ts.map +0 -1
- package/dist/utils/encryption.js +0 -55
- package/dist/utils/hashUtils.d.ts +0 -8
- package/dist/utils/hashUtils.d.ts.map +0 -1
- package/dist/utils/hashUtils.js +0 -44
- package/dist/utils/index.d.ts +0 -14
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -29
- package/dist/utils/merkle.d.ts +0 -2
- package/dist/utils/merkle.d.ts.map +0 -1
- package/dist/utils/merkle.js +0 -28
- package/dist/utils/network.d.ts +0 -2
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js +0 -54
- package/dist/utils/spinnerUtils.d.ts +0 -2
- package/dist/utils/spinnerUtils.d.ts.map +0 -1
- package/dist/utils/spinnerUtils.js +0 -47
- package/dist/utils/ssl.d.ts +0 -5
- package/dist/utils/ssl.d.ts.map +0 -1
- package/dist/utils/ssl.js +0 -50
- package/dist/utils/validationUtils.d.ts +0 -9
- package/dist/utils/validationUtils.d.ts.map +0 -1
- package/dist/utils/validationUtils.js +0 -55
package/dist/utils/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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("./config"), exports);
|
|
18
|
-
__exportStar(require("./connectionUtils"), exports);
|
|
19
|
-
__exportStar(require("./credentialsUtils"), exports);
|
|
20
|
-
__exportStar(require("./directoryUtils"), exports);
|
|
21
|
-
__exportStar(require("./encryption"), exports);
|
|
22
|
-
__exportStar(require("./FileCache"), exports);
|
|
23
|
-
__exportStar(require("./hashUtils"), exports);
|
|
24
|
-
__exportStar(require("./NconfManager"), exports);
|
|
25
|
-
__exportStar(require("./network"), exports);
|
|
26
|
-
__exportStar(require("./spinnerUtils"), exports);
|
|
27
|
-
__exportStar(require("./ssl"), exports);
|
|
28
|
-
__exportStar(require("./validationUtils"), exports);
|
|
29
|
-
__exportStar(require("./Environment"), exports);
|
package/dist/utils/merkle.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkle.d.ts","sourceRoot":"","sources":["../../src/utils/merkle.ts"],"names":[],"mappings":"AAIA,wBAAsB,oBAAoB,CACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CA6BlB"}
|
package/dist/utils/merkle.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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.merkleIntegrityCheck = merkleIntegrityCheck;
|
|
7
|
-
const DataIntegrityTree_1 = require("../DataIntegrityTree");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
async function merkleIntegrityCheck(treePath, tmpDir, dataPath, roothash) {
|
|
11
|
-
const rootHashContent = fs_1.default.readFileSync(treePath, "utf-8");
|
|
12
|
-
const tree = JSON.parse(rootHashContent);
|
|
13
|
-
// Extract expected sha256 from dataPath
|
|
14
|
-
const expectedSha256 = dataPath.replace("data", "").replace(/\//g, "");
|
|
15
|
-
console.log("expectedSha256", expectedSha256);
|
|
16
|
-
// Find the hexKey in the tree based on matching sha256
|
|
17
|
-
const hexKey = Object.keys(tree.files).find((key) => {
|
|
18
|
-
const fileData = tree.files[key]; // Inline type definition
|
|
19
|
-
return fileData.sha256 === expectedSha256;
|
|
20
|
-
});
|
|
21
|
-
if (!hexKey) {
|
|
22
|
-
throw new Error(`No matching file found with sha256: ${expectedSha256}`);
|
|
23
|
-
}
|
|
24
|
-
// Validate the integrity with the foreign tree
|
|
25
|
-
const integrity = await DataIntegrityTree_1.DataIntegrityTree.validateKeyIntegrityWithForeignTree(hexKey, expectedSha256, tree, roothash, path_1.default.join(tmpDir, "data"));
|
|
26
|
-
console.log("Integrity check result:", integrity);
|
|
27
|
-
return integrity;
|
|
28
|
-
}
|
package/dist/utils/network.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/utils/network.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,MAAM,GAAG,SAAS,CA6CrE,CAAC"}
|
package/dist/utils/network.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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.getPublicIpAddress = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* Stopgap until better solution for finding public IPS found
|
|
9
|
-
*/
|
|
10
|
-
const superagent_1 = __importDefault(require("superagent"));
|
|
11
|
-
const Environment_1 = require("./Environment");
|
|
12
|
-
const MAX_RETRIES = 5;
|
|
13
|
-
const RETRY_DELAY = 2000; // in milliseconds
|
|
14
|
-
// Regular expression for validating both IPv4 and IPv6 addresses
|
|
15
|
-
const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
16
|
-
const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4}|:)|(([0-9a-fA-F]{1,4}:){1,7}|:):(([0-9a-fA-F]{1,4}:){1,6}|:):([0-9a-fA-F]{1,4}|:):([0-9a-fA-F]{1,4}|:)|::)$/;
|
|
17
|
-
// Helper function to validate the IP address
|
|
18
|
-
const isValidIp = (ip) => {
|
|
19
|
-
return ipv4Regex.test(ip) || ipv6Regex.test(ip);
|
|
20
|
-
};
|
|
21
|
-
const getPublicIpAddress = async () => {
|
|
22
|
-
const publicIp = Environment_1.Environment.PUBLIC_IP;
|
|
23
|
-
if (publicIp) {
|
|
24
|
-
console.log("Public IP address from env:", publicIp);
|
|
25
|
-
if (isValidIp(publicIp)) {
|
|
26
|
-
return publicIp;
|
|
27
|
-
}
|
|
28
|
-
console.error("Invalid public IP address in environment variable");
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
let attempt = 0;
|
|
32
|
-
while (attempt < MAX_RETRIES) {
|
|
33
|
-
try {
|
|
34
|
-
const response = await superagent_1.default.get("https://api.datalayer.storage/user/v1/get_user_ip");
|
|
35
|
-
if (response.body && response.body.success) {
|
|
36
|
-
const ipAddress = response.body.ip_address;
|
|
37
|
-
if (isValidIp(ipAddress)) {
|
|
38
|
-
return ipAddress;
|
|
39
|
-
}
|
|
40
|
-
throw new Error("Invalid IP address format received");
|
|
41
|
-
}
|
|
42
|
-
throw new Error("Failed to retrieve public IP address");
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
attempt++;
|
|
46
|
-
console.error(`Error fetching public IP address (Attempt ${attempt}):`, error.message);
|
|
47
|
-
if (attempt >= MAX_RETRIES) {
|
|
48
|
-
throw new Error("Could not retrieve public IP address after several attempts");
|
|
49
|
-
}
|
|
50
|
-
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.getPublicIpAddress = getPublicIpAddress;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinnerUtils.d.ts","sourceRoot":"","sources":["../../src/utils/spinnerUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAU,CAAC,aACzB,MAAM,OAAO,CAAC,CAAC,CAAC,gBACd,MAAM,gBACN,MAAM,cACR,MAAM,KAChB,OAAO,CAAC,CAAC,CA8CX,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.waitForPromise = void 0;
|
|
4
|
-
const nanospinner_1 = require("nanospinner");
|
|
5
|
-
const waitForPromise = async (promiseFn, spinnerText = "Processing...", successText = "OK!", errorText = "Error.") => {
|
|
6
|
-
const spinner = (0, nanospinner_1.createSpinner)(spinnerText).start();
|
|
7
|
-
// Store original console.log and console.error, and collect log messages
|
|
8
|
-
const originalConsoleLog = console.log;
|
|
9
|
-
const originalConsoleError = console.error;
|
|
10
|
-
let logMessages = [];
|
|
11
|
-
let errorMessages = [];
|
|
12
|
-
console.log = (...args) => {
|
|
13
|
-
logMessages.push(args.map(arg => (typeof arg === 'string' ? arg : JSON.stringify(arg))).join(' '));
|
|
14
|
-
};
|
|
15
|
-
console.error = (...args) => {
|
|
16
|
-
errorMessages.push(args.map(arg => (typeof arg === 'string' ? arg : JSON.stringify(arg))).join(' '));
|
|
17
|
-
};
|
|
18
|
-
try {
|
|
19
|
-
const result = await promiseFn();
|
|
20
|
-
if (result) {
|
|
21
|
-
spinner.success({ text: successText });
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
throw new Error(errorText);
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
spinner.error({ text: errorText });
|
|
30
|
-
// Print collected log messages and error messages on error
|
|
31
|
-
if (logMessages.length > 0) {
|
|
32
|
-
originalConsoleLog("\nCollected logs:");
|
|
33
|
-
logMessages.forEach((message) => originalConsoleLog(message));
|
|
34
|
-
}
|
|
35
|
-
if (errorMessages.length > 0) {
|
|
36
|
-
originalConsoleError("\nCollected errors:");
|
|
37
|
-
errorMessages.forEach((message) => originalConsoleError(message));
|
|
38
|
-
}
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
// Restore the original console.log and console.error functions
|
|
43
|
-
console.log = originalConsoleLog;
|
|
44
|
-
console.error = originalConsoleError;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
exports.waitForPromise = waitForPromise;
|
package/dist/utils/ssl.d.ts
DELETED
package/dist/utils/ssl.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssl.d.ts","sourceRoot":"","sources":["../../src/utils/ssl.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB;;;CAqB/B,CAAC"}
|
package/dist/utils/ssl.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getOrCreateSSLCerts = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
|
-
const chia_server_coin_1 = require("chia-server-coin");
|
|
30
|
-
const config_1 = require("./config");
|
|
31
|
-
const getOrCreateSSLCerts = () => {
|
|
32
|
-
const sslDir = path.join(config_1.USER_DIR_PATH, "ssl");
|
|
33
|
-
const certPath = path.join(sslDir, "client.cert");
|
|
34
|
-
const keyPath = path.join(sslDir, "client.key");
|
|
35
|
-
// Ensure the SSL directory exists
|
|
36
|
-
if (!fs.existsSync(sslDir)) {
|
|
37
|
-
fs.mkdirSync(sslDir, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
// Check if the certificate and key exist, if not, generate them
|
|
40
|
-
if (!fs.existsSync(certPath) || !fs.existsSync(keyPath)) {
|
|
41
|
-
new chia_server_coin_1.Tls(certPath, keyPath);
|
|
42
|
-
console.log("Client certificate and key generated successfully.");
|
|
43
|
-
}
|
|
44
|
-
// Return the paths to the cert and key files
|
|
45
|
-
return {
|
|
46
|
-
certPath,
|
|
47
|
-
keyPath,
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
exports.getOrCreateSSLCerts = getOrCreateSSLCerts;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates if the SHA256 hash of the decompressed file matches the provided hash.
|
|
3
|
-
*
|
|
4
|
-
* @param sha256 - The expected SHA256 hash of the decompressed file.
|
|
5
|
-
* @param dataDir - The root folder where the data files are stored.
|
|
6
|
-
* @returns A boolean indicating whether the decompressed file's hash matches the provided hash.
|
|
7
|
-
*/
|
|
8
|
-
export declare const validateFileSha256: (sha256: string, dataDir: string) => boolean;
|
|
9
|
-
//# sourceMappingURL=validationUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validationUtils.d.ts","sourceRoot":"","sources":["../../src/utils/validationUtils.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,WACrB,MAAM,WACL,MAAM,KACd,OAoBF,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.validateFileSha256 = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const zlib = __importStar(require("zlib"));
|
|
29
|
-
const crypto = __importStar(require("crypto"));
|
|
30
|
-
const hashUtils_1 = require("./hashUtils");
|
|
31
|
-
/**
|
|
32
|
-
* Validates if the SHA256 hash of the decompressed file matches the provided hash.
|
|
33
|
-
*
|
|
34
|
-
* @param sha256 - The expected SHA256 hash of the decompressed file.
|
|
35
|
-
* @param dataDir - The root folder where the data files are stored.
|
|
36
|
-
* @returns A boolean indicating whether the decompressed file's hash matches the provided hash.
|
|
37
|
-
*/
|
|
38
|
-
const validateFileSha256 = (sha256, dataDir) => {
|
|
39
|
-
// Derive the file path from the SHA256 hash
|
|
40
|
-
const filePath = (0, hashUtils_1.getFilePathFromSha256)(sha256, dataDir);
|
|
41
|
-
if (!fs.existsSync(filePath)) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
// Read and decompress the file
|
|
45
|
-
const fileBuffer = fs.readFileSync(filePath);
|
|
46
|
-
const decompressedBuffer = zlib.gunzipSync(fileBuffer);
|
|
47
|
-
// Calculate the SHA256 hash of the decompressed content
|
|
48
|
-
const hash = crypto
|
|
49
|
-
.createHash("sha256")
|
|
50
|
-
.update(decompressedBuffer)
|
|
51
|
-
.digest("hex");
|
|
52
|
-
// Compare the calculated hash with the provided hash
|
|
53
|
-
return hash === sha256;
|
|
54
|
-
};
|
|
55
|
-
exports.validateFileSha256 = validateFileSha256;
|