@dignetwork/dig-sdk 0.0.1-alpha.177 → 0.0.1-alpha.178

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.
@@ -89,7 +89,8 @@ export declare class PropagationServer {
89
89
  */
90
90
  downloadFile(label: string, dataPath: string, rootHash: string, baseDir: string): Promise<void>;
91
91
  /**
92
- * Static function to handle downloading multiple files from a DataStore based on file paths.
92
+ * Downloads a store from the specified IP address, saving directly to the main directory,
93
+ * skipping files that already exist.
93
94
  */
94
95
  static downloadStore(storeId: string, rootHash: string, ipAddress: string): Promise<void>;
95
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PropagationServer.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/PropagationServer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,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,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAQ;IACpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;gBAErC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAY9C;;OAEG;IACG,gBAAgB;IAOtB;;OAEG;IACH,gBAAgB;IAQhB;;;OAGG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BpD;;;;OAIG;IACG,UA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AAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IA2BlD;;;OAGG;IACG,UAAU,CACd,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,UAAU,GAAE,OAAe;IAsH7B;;OAEG;IACG,mBAAmB;IAkCzB;;OAEG;WACU,WAAW,CACtB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM;IA0DnB;;;OAGG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmFlD;;OAEG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IA4B7C;;;OAGG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM;IA4GjB;;;OAGG;WACU,aAAa,CACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM;CAuEpB"}
@@ -31,9 +31,7 @@ const axios_1 = __importDefault(require("axios"));
31
31
  const cli_progress_1 = __importDefault(require("cli-progress"));
32
32
  const form_data_1 = __importDefault(require("form-data"));
33
33
  const fs_1 = __importDefault(require("fs"));
34
- const fs_extra_1 = __importDefault(require("fs-extra"));
35
34
  const https_1 = __importDefault(require("https"));
36
- const os_1 = __importDefault(require("os"));
37
35
  const path_1 = __importDefault(require("path"));
38
36
  const progress_stream_1 = __importDefault(require("progress-stream"));
39
37
  const zlib = __importStar(require("zlib"));
@@ -622,13 +620,14 @@ class PropagationServer {
622
620
  }
623
621
  }
624
622
  /**
625
- * Static function to handle downloading multiple files from a DataStore based on file paths.
623
+ * Downloads a store from the specified IP address, saving directly to the main directory,
624
+ * skipping files that already exist.
626
625
  */
627
626
  static async downloadStore(storeId, rootHash, ipAddress) {
628
627
  const propagationServer = new PropagationServer(ipAddress, storeId);
629
628
  // Initialize wallet
630
629
  await propagationServer.initializeWallet();
631
- // Check if the store exists
630
+ // Verify the store and rootHash existence
632
631
  const { storeExists, rootHashExists } = await propagationServer.checkStoreExists(rootHash);
633
632
  if (!storeExists || !rootHashExists) {
634
633
  throw new Error(`Store ${storeId} does not exist.`);
@@ -636,43 +635,37 @@ class PropagationServer {
636
635
  // Fetch the rootHash.dat file
637
636
  const datFileContent = await propagationServer.fetchFile(`${rootHash}.dat`);
638
637
  const root = JSON.parse(datFileContent.toString());
639
- // Prepare download tasks
640
- const downloadTasks = [];
641
- for (const [fileKey, fileData] of Object.entries(root.files)) {
642
- const dataPath = (0, hashUtils_1.getFilePathFromSha256)(root.files[fileKey].sha256, "data");
638
+ // Prepare download tasks, skipping existing files
639
+ const downloadTasks = Object.entries(root.files)
640
+ .map(([fileKey, fileData]) => {
641
+ const dataPath = (0, hashUtils_1.getFilePathFromSha256)(fileData.sha256, "data");
643
642
  const label = Buffer.from(fileKey, "hex").toString("utf-8");
644
- downloadTasks.push({ label, dataPath });
645
- }
646
- // Limit the number of concurrent downloads
647
- const concurrencyLimit = 10; // Adjust this number as needed
648
- // Create a temporary directory
649
- const tempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "downloadStore-"));
643
+ const destinationPath = path_1.default.join(config_1.STORE_PATH, storeId, dataPath);
644
+ return fs_1.default.existsSync(destinationPath)
645
+ ? null
646
+ : { label, dataPath: destinationPath };
647
+ })
648
+ .filter((task) => task !== null);
649
+ // Limit concurrent downloads
650
+ const concurrencyLimit = 10;
650
651
  try {
651
- // Download files to the temporary directory
652
+ // Download missing files directly to the main directory
652
653
  await (0, promiseUtils_1.asyncPool)(concurrencyLimit, downloadTasks, async (task) => {
653
- await propagationServer.downloadFile(task.label, task.dataPath, rootHash, tempDir);
654
+ await propagationServer.downloadFile(task.label, task.dataPath, rootHash, path_1.default.dirname(task.dataPath));
654
655
  });
655
- // Save the rootHash.dat file to the temporary directory
656
- if (!fs_1.default.existsSync(tempDir)) {
657
- fs_1.default.mkdirSync(tempDir, { recursive: true });
656
+ // Save the rootHash.dat file if it doesn’t exist
657
+ const datFilePath = path_1.default.join(config_1.STORE_PATH, storeId, `${rootHash}.dat`);
658
+ if (!fs_1.default.existsSync(datFilePath)) {
659
+ fs_1.default.writeFileSync(datFilePath, datFileContent);
658
660
  }
659
- fs_1.default.writeFileSync(path_1.default.join(tempDir, `${rootHash}.dat`), datFileContent);
660
- // Integrity check for the downloaded files was done during the download
661
- // Here we want to make sure we got all the files or we reject the download session
661
+ // Verify all files are present
662
662
  for (const [fileKey, fileData] of Object.entries(root.files)) {
663
- const dataPath = (0, hashUtils_1.getFilePathFromSha256)(root.files[fileKey].sha256, "data");
664
- if (!fs_1.default.existsSync(path_1.default.join(tempDir, dataPath))) {
665
- if (!fs_1.default.existsSync(path_1.default.join(config_1.STORE_PATH, storeId, dataPath))) {
666
- throw new Error(`Missing file: ${Buffer.from(fileKey, "hex")}, aborting session.`);
667
- }
663
+ // @ts-ignore
664
+ const dataPath = (0, hashUtils_1.getFilePathFromSha256)(fileData.sha256, "data");
665
+ if (!fs_1.default.existsSync(path_1.default.join(config_1.STORE_PATH, storeId, dataPath))) {
666
+ throw new Error(`Missing file: ${Buffer.from(fileKey, "hex")}, aborting session.`);
668
667
  }
669
668
  }
670
- // After all downloads are complete, copy from temp directory to the main directory
671
- const destinationDir = path_1.default.join(config_1.STORE_PATH, storeId);
672
- fs_extra_1.default.copySync(tempDir, destinationDir, {
673
- overwrite: false, // Prevents overwriting existing files
674
- errorOnExist: false, // No error if file already exists
675
- });
676
669
  // Generate the manifest file in the main directory
677
670
  const dataStore = blockchain_1.DataStore.from(storeId);
678
671
  await dataStore.cacheStoreCreationHeight();
@@ -682,10 +675,6 @@ class PropagationServer {
682
675
  catch (error) {
683
676
  console.log((0, colorette_1.red)("✖ Error downloading files:"), error);
684
677
  }
685
- finally {
686
- // Clean up the temporary directory
687
- fs_extra_1.default.removeSync(tempDir);
688
- }
689
678
  }
690
679
  }
691
680
  exports.PropagationServer = PropagationServer;
@@ -1,7 +1,7 @@
1
1
  declare class Udi {
2
2
  readonly chainName: string;
3
- readonly storeId: Buffer;
4
- readonly rootHash: Buffer | null;
3
+ private readonly _storeId;
4
+ private readonly _rootHash;
5
5
  readonly resourceKey: string | null;
6
6
  static readonly nid: string;
7
7
  static readonly namespace: string;
@@ -18,6 +18,8 @@ declare class Udi {
18
18
  toString(): string;
19
19
  clone(): Udi;
20
20
  hashCode(): string;
21
+ get storeId(): string;
22
+ get rootHash(): string | null;
21
23
  }
22
24
  export { Udi };
23
25
  //# sourceMappingURL=Udi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Udi.d.ts","sourceRoot":"","sources":["../../src/utils/Udi.ts"],"names":[],"mappings":"AAWA,cAAM,GAAG;IACL,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAS;IACpC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAoB;gBAGjD,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,GAAE,MAAM,GAAG,MAAM,GAAG,IAAW,EACvC,WAAW,GAAE,MAAM,GAAG,IAAW;IAWrC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAgBtD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIpC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG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,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIvC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,GAAG;IAInD,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,GAAG;IAIhD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IA4BhC,KAAK,CAAC,QAAQ,GAAE,KAAK,GAAG,QAAgB,GAAG,MAAM;IAgBjD,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM;IAMlE,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAS3B,QAAQ,IAAI,MAAM;IAIlB,KAAK,IAAI,GAAG;IAIZ,QAAQ,IAAI,MAAM;IAOlB,IAAI,OAAO,IAAI,MAAM,CAEpB;IAGD,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;CACF;AAED,OAAO,EAAE,GAAG,EAAE,CAAC"}
package/dist/utils/Udi.js CHANGED
@@ -28,11 +28,10 @@ const urns = __importStar(require("urns"));
28
28
  const crypto_1 = require("crypto");
29
29
  const hi_base32_1 = require("hi-base32");
30
30
  //
31
- // This class encapsulates the concept of a Universal Data Identifier (UDI) which is a
31
+ // This class encapsulates the concept of a Universal Data Identifier (UDI), which is a
32
32
  // standardized way to identify resources across the distributed DIG mesh network.
33
- // The UDI is formatted as follows:
34
- // urn:dig:chainName:storeId:rootHash/resourceKey
35
- // The UDI can be used to uniquely identify resources across the DIG network.
33
+ // The UDI format: urn:dig:chainName:storeId:rootHash/resourceKey
34
+ // This allows unique resource identification across the DIG network.
36
35
  //
37
36
  class Udi {
38
37
  constructor(chainName, storeId, rootHash = null, resourceKey = null) {
@@ -40,8 +39,8 @@ class Udi {
40
39
  throw new Error("storeId cannot be empty");
41
40
  }
42
41
  this.chainName = chainName || "chia";
43
- this.storeId = Udi.convertToBuffer(storeId);
44
- this.rootHash = rootHash ? Udi.convertToBuffer(rootHash) : null;
42
+ this._storeId = Udi.convertToBuffer(storeId);
43
+ this._rootHash = rootHash ? Udi.convertToBuffer(rootHash) : null;
45
44
  this.resourceKey = resourceKey;
46
45
  }
47
46
  static convertToBuffer(input) {
@@ -63,10 +62,10 @@ class Udi {
63
62
  return /^[a-z2-7]{52}$/.test(input.toLowerCase());
64
63
  }
65
64
  withRootHash(rootHash) {
66
- return new Udi(this.chainName, this.storeId, rootHash, this.resourceKey);
65
+ return new Udi(this.chainName, this._storeId, rootHash, this.resourceKey);
67
66
  }
68
67
  withResourceKey(resourceKey) {
69
- return new Udi(this.chainName, this.storeId, this.rootHash, resourceKey);
68
+ return new Udi(this.chainName, this._storeId, this._rootHash, resourceKey);
70
69
  }
71
70
  static fromUrn(urn) {
72
71
  const parsedUrn = urns.parseURN(urn);
@@ -91,10 +90,10 @@ class Udi {
91
90
  return new Udi(chainName, storeId, rootHash, resourceKey);
92
91
  }
93
92
  toUrn(encoding = 'hex') {
94
- const storeIdStr = this.bufferToString(this.storeId, encoding);
93
+ const storeIdStr = this.bufferToString(this._storeId, encoding);
95
94
  let urn = `${Udi.namespace}:${this.chainName}:${storeIdStr}`;
96
- if (this.rootHash) {
97
- const rootHashStr = this.bufferToString(this.rootHash, encoding);
95
+ if (this._rootHash) {
96
+ const rootHashStr = this.bufferToString(this._rootHash, encoding);
98
97
  urn += `:${rootHashStr}`;
99
98
  }
100
99
  if (this.resourceKey) {
@@ -108,22 +107,30 @@ class Udi {
108
107
  : (0, hi_base32_1.encode)(buffer).toLowerCase().replace(/=+$/, '');
109
108
  }
110
109
  equals(other) {
111
- return (this.storeId.equals(other.storeId) &&
110
+ return (this._storeId.equals(other._storeId) &&
112
111
  this.chainName === other.chainName &&
113
- (this.rootHash && other.rootHash ? this.rootHash.equals(other.rootHash) : this.rootHash === other.rootHash) &&
112
+ (this._rootHash && other._rootHash ? this._rootHash.equals(other._rootHash) : this._rootHash === other._rootHash) &&
114
113
  this.resourceKey === other.resourceKey);
115
114
  }
116
115
  toString() {
117
116
  return this.toUrn();
118
117
  }
119
118
  clone() {
120
- return new Udi(this.chainName, this.storeId, this.rootHash, this.resourceKey);
119
+ return new Udi(this.chainName, this._storeId, this._rootHash, this.resourceKey);
121
120
  }
122
121
  hashCode() {
123
122
  const hash = (0, crypto_1.createHash)('sha256');
124
123
  hash.update(this.toUrn());
125
124
  return hash.digest('hex');
126
125
  }
126
+ // Getter for storeId as a hex string
127
+ get storeId() {
128
+ return this._storeId.toString('hex');
129
+ }
130
+ // Getter for rootHash as a hex string
131
+ get rootHash() {
132
+ return this._rootHash ? this._rootHash.toString('hex') : null;
133
+ }
127
134
  }
128
135
  exports.Udi = Udi;
129
136
  Udi.nid = "dig";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dignetwork/dig-sdk",
3
- "version": "0.0.1-alpha.177",
3
+ "version": "0.0.1-alpha.178",
4
4
  "description": "",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",