@dignetwork/dig-sdk 0.0.1-alpha.7 → 0.0.1-alpha.71

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.
Files changed (56) hide show
  1. package/dist/DataIntegrityTree/DataIntegrityTree.d.ts +5 -2
  2. package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +1 -1
  3. package/dist/DataIntegrityTree/DataIntegrityTree.js +94 -34
  4. package/dist/DigNetwork/ContentServer.d.ts +9 -4
  5. package/dist/DigNetwork/ContentServer.d.ts.map +1 -1
  6. package/dist/DigNetwork/ContentServer.js +55 -19
  7. package/dist/DigNetwork/DigNetwork.d.ts +3 -8
  8. package/dist/DigNetwork/DigNetwork.d.ts.map +1 -1
  9. package/dist/DigNetwork/DigNetwork.js +115 -171
  10. package/dist/DigNetwork/DigPeer.d.ts +9 -3
  11. package/dist/DigNetwork/DigPeer.d.ts.map +1 -1
  12. package/dist/DigNetwork/DigPeer.js +68 -114
  13. package/dist/DigNetwork/PropagationServer.d.ts +91 -33
  14. package/dist/DigNetwork/PropagationServer.d.ts.map +1 -1
  15. package/dist/DigNetwork/PropagationServer.js +412 -372
  16. package/dist/blockchain/DataStore.d.ts +13 -6
  17. package/dist/blockchain/DataStore.d.ts.map +1 -1
  18. package/dist/blockchain/DataStore.js +64 -91
  19. package/dist/blockchain/DataStoreSerializer.d.ts +1 -1
  20. package/dist/blockchain/DataStoreSerializer.d.ts.map +1 -1
  21. package/dist/blockchain/FullNodePeer.d.ts +9 -1
  22. package/dist/blockchain/FullNodePeer.d.ts.map +1 -1
  23. package/dist/blockchain/FullNodePeer.js +38 -10
  24. package/dist/blockchain/ServerCoin.d.ts +11 -3
  25. package/dist/blockchain/ServerCoin.d.ts.map +1 -1
  26. package/dist/blockchain/ServerCoin.js +45 -17
  27. package/dist/blockchain/Wallet.d.ts +2 -2
  28. package/dist/blockchain/Wallet.d.ts.map +1 -1
  29. package/dist/blockchain/Wallet.js +2 -2
  30. package/dist/blockchain/coins.d.ts +1 -1
  31. package/dist/blockchain/coins.d.ts.map +1 -1
  32. package/dist/blockchain/coins.js +1 -1
  33. package/dist/types.d.ts +1 -0
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/utils/ContentScanner.d.ts +63 -0
  36. package/dist/utils/ContentScanner.d.ts.map +1 -0
  37. package/dist/utils/ContentScanner.js +175 -0
  38. package/dist/utils/FileTransfer.d.ts +47 -0
  39. package/dist/utils/FileTransfer.d.ts.map +1 -0
  40. package/dist/utils/FileTransfer.js +209 -0
  41. package/dist/utils/StoreArchiveManager.d.ts +45 -0
  42. package/dist/utils/StoreArchiveManager.d.ts.map +1 -0
  43. package/dist/utils/StoreArchiveManager.js +153 -0
  44. package/dist/utils/config.d.ts +0 -1
  45. package/dist/utils/config.d.ts.map +1 -1
  46. package/dist/utils/config.js +2 -3
  47. package/dist/utils/directoryUtils.d.ts +0 -6
  48. package/dist/utils/directoryUtils.d.ts.map +1 -1
  49. package/dist/utils/directoryUtils.js +30 -11
  50. package/dist/utils/index.d.ts +0 -1
  51. package/dist/utils/index.d.ts.map +1 -1
  52. package/dist/utils/index.js +0 -1
  53. package/package.json +12 -3
  54. package/dist/utils/deltaUtils.d.ts +0 -2
  55. package/dist/utils/deltaUtils.d.ts.map +0 -1
  56. package/dist/utils/deltaUtils.js +0 -83
@@ -1,41 +1,99 @@
1
- import { Readable } from "stream";
1
+ import https from "https";
2
2
  export declare class PropagationServer {
3
- private ipAddress;
4
- private storeId;
5
- private static certPath;
6
- private static keyPath;
3
+ storeId: string;
4
+ sessionId: string;
5
+ publicKey: string;
6
+ wallet: any;
7
+ ipAddress: string;
8
+ certPath: string;
9
+ keyPath: string;
10
+ username: string | undefined;
11
+ password: string | undefined;
7
12
  private static readonly port;
8
- private static readonly maxRetries;
9
- private static readonly initialDelay;
10
- private static readonly maxDelay;
11
- private static readonly delayMultiplier;
13
+ private static multiBar;
12
14
  constructor(ipAddress: string, storeId: string);
13
- pushFile(filePath: string, relativePath: string): Promise<void>;
14
- subscribeToStore(): Promise<void>;
15
- unsubscribeFromStore(): Promise<void>;
16
- getStoreStatus(): Promise<any>;
17
- streamStoreData(dataPath: string): Promise<Readable>;
18
- getStoreData(dataPath: string): Promise<string>;
19
- getStatus(): Promise<{
20
- synced: boolean;
15
+ /**
16
+ * Initialize the Wallet instance.
17
+ */
18
+ initializeWallet(): Promise<void>;
19
+ /**
20
+ * Create an Axios HTTPS Agent with self-signed certificate allowance.
21
+ */
22
+ createHttpsAgent(): https.Agent;
23
+ /**
24
+ * Check if the store and optional root hash exist by making a HEAD request.
25
+ *
26
+ * @param {string} [rootHash] - Optional root hash to check for existence.
27
+ * @returns {Promise<{ storeExists: boolean, rootHashExists: boolean }>} - An object indicating if the store and root hash exist.
28
+ */
29
+ checkStoreExists(rootHash?: string): Promise<{
30
+ storeExists: boolean;
31
+ rootHashExists: boolean;
21
32
  }>;
22
- headStore(): Promise<boolean>;
23
- isStoreSynced(): Promise<boolean>;
24
- getUploadDetails(): Promise<{
33
+ /**
34
+ * Start an upload session by sending a POST request with the rootHash.dat file.
35
+ *
36
+ * @param {string} rootHash - The root hash used to name the .dat file.
37
+ * @param {string} datFilePath - The full path to the rootHash.dat file.
38
+ */
39
+ startUploadSession(rootHash: string): Promise<void>;
40
+ /**
41
+ * Request a nonce for a file by sending a HEAD request to the server.
42
+ * Checks if the file already exists based on the 'x-file-exists' header.
43
+ */
44
+ getFileNonce(filename: string): Promise<{
25
45
  nonce: string;
26
- lastUploadedHash: string;
27
- generationIndex: number;
28
- username: string;
29
- password: string;
46
+ fileExists: boolean;
30
47
  }>;
31
- private postRequest;
32
- private fetchUploadDetails;
33
- private uploadFileDirect;
34
- private retryOperation;
35
- private fetch;
36
- private head;
37
- private fetchJson;
38
- private createReadStreamWithRetries;
39
- private createReadStream;
48
+ /**
49
+ * Upload a file to the server by sending a PUT request.
50
+ * Logs progress using cli-progress for each file.
51
+ */
52
+ uploadFile(label: string, dataPath: string): Promise<any>;
53
+ /**
54
+ * Commit the upload session by sending a POST request to the server.
55
+ * This finalizes the upload and moves files from the temporary session directory to the permanent location.
56
+ */
57
+ commitUploadSession(): Promise<any>;
58
+ /**
59
+ * Static function to handle the entire upload process for multiple files based on rootHash.
60
+ * @param {string} storeId - The ID of the DataStore.
61
+ * @param {string} rootHash - The root hash used to derive the file set.
62
+ * @param {string} publicKey - The public key of the user.
63
+ * @param {string} ipAddress - The IP address of the server.
64
+ */
65
+ static uploadStore(storeId: string, rootHash: string, ipAddress: string): Promise<void>;
66
+ /**
67
+ * Fetch a file from the server by sending a GET request and return its content in memory.
68
+ * Logs progress using cli-progress.
69
+ * @param {string} dataPath - The data path of the file to download.
70
+ * @returns {Promise<Buffer>} - The file content in memory as a Buffer.
71
+ */
72
+ fetchFile(dataPath: string): Promise<Buffer>;
73
+ /**
74
+ * Get details of a file, including whether it exists and its size.
75
+ * Makes a HEAD request to the server and checks the response headers.
76
+ *
77
+ * @param {string} dataPath - The path of the file within the DataStore.
78
+ * @param {string} rootHash - The root hash associated with the DataStore.
79
+ * @returns {Promise<{ exists: boolean; size: number }>} - An object containing file existence and size information.
80
+ */
81
+ getFileDetails(dataPath: string, rootHash: string): Promise<{
82
+ exists: boolean;
83
+ size: number;
84
+ }>;
85
+ /**
86
+ * Download a file from the server by sending a GET request.
87
+ * Logs progress using cli-progress.
88
+ * @param {string} dataPath - The data path of the file to download.
89
+ */
90
+ downloadFile(dataPath: string): Promise<void>;
91
+ /**
92
+ * Static function to handle downloading multiple files from a DataStore based on file paths.
93
+ * @param {string} storeId - The ID of the DataStore.
94
+ * @param {string[]} dataPaths - The list of data paths to download.
95
+ * @param {string} ipAddress - The IP address of the server.
96
+ */
97
+ static downloadStore(storeId: string, rootHash: string, ipAddress: string): Promise<void>;
40
98
  }
41
99
  //# sourceMappingURL=PropagationServer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropagationServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/PropagationServer.ts"],"names":[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