@autonomys/auto-drive 1.4.7 → 1.4.8

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.
@@ -5,6 +5,7 @@ import { GenericFile } from '../api/models/file';
5
5
  * @param name - The name of the file (ignored if file is a GenericFile)
6
6
  * @returns The CID of the file
7
7
  */
8
- export declare const precomputeCid: (file: File | GenericFile | Buffer, name?: string) => Promise<import("multiformats", { with: { "resolution-mode": "import" } }).CID<unknown, number, number, import("multiformats", { with: { "resolution-mode": "import" } }).Version>>;
8
+ export declare const precomputeCid: (file: File | GenericFile | Buffer, name?: string) => Promise<string>;
9
9
  export declare const blake3Hash: (cid: string) => Promise<Buffer<ArrayBuffer>>;
10
+ export declare const cidStringFromBlake3Hash: (hash: Buffer) => Promise<string>;
10
11
  //# sourceMappingURL=cid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../src/offline/cid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAuChD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAU,MAAM,IAAI,GAAG,WAAW,GAAG,MAAM,EAAE,OAAO,MAAM,uLAQnF,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,KAAK,MAAM,iCAI3C,CAAA"}
1
+ {"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../src/offline/cid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAuChD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAU,MAAM,IAAI,GAAG,WAAW,GAAG,MAAM,EAAE,OAAO,MAAM,oBAUnF,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,KAAK,MAAM,iCAI3C,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAU,MAAM,MAAM,oBAIzD,CAAA"}
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.blake3Hash = exports.precomputeCid = void 0;
12
+ exports.cidStringFromBlake3Hash = exports.blake3Hash = exports.precomputeCid = void 0;
13
13
  const asynchronous_1 = require("@autonomys/asynchronous");
14
14
  const precomputeCidFromGenericFile = (file) => __awaiter(void 0, void 0, void 0, function* () {
15
15
  const { processFileToIPLDFormat } = yield import('@autonomys/auto-dag-data');
@@ -42,14 +42,15 @@ const isBuffer = (file) => {
42
42
  * @returns The CID of the file
43
43
  */
44
44
  const precomputeCid = (file, name) => __awaiter(void 0, void 0, void 0, function* () {
45
+ const { cidToString } = yield import('@autonomys/auto-dag-data');
45
46
  if (isGenericFile(file)) {
46
- return precomputeCidFromGenericFile(file);
47
+ return cidToString(yield precomputeCidFromGenericFile(file));
47
48
  }
48
49
  else if (isBuffer(file)) {
49
- return precomputeCidFromBuffer(file, name);
50
+ return cidToString(yield precomputeCidFromBuffer(file, name));
50
51
  }
51
52
  else {
52
- return precomputeCidFromFile(file, name);
53
+ return cidToString(yield precomputeCidFromFile(file, name));
53
54
  }
54
55
  });
55
56
  exports.precomputeCid = precomputeCid;
@@ -58,3 +59,8 @@ const blake3Hash = (cid) => __awaiter(void 0, void 0, void 0, function* () {
58
59
  return Buffer.from(blake3HashFromCid(stringToCid(cid)));
59
60
  });
60
61
  exports.blake3Hash = blake3Hash;
62
+ const cidStringFromBlake3Hash = (hash) => __awaiter(void 0, void 0, void 0, function* () {
63
+ const { cidToString, cidFromBlakeHash } = yield import('@autonomys/auto-dag-data');
64
+ return cidToString(cidFromBlakeHash(hash));
65
+ });
66
+ exports.cidStringFromBlake3Hash = cidStringFromBlake3Hash;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@autonomys/auto-drive",
3
3
  "packageManager": "yarn@4.7.0",
4
- "version": "1.4.7",
4
+ "version": "1.4.8",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -42,9 +42,9 @@
42
42
  "typescript": "^5.6.3"
43
43
  },
44
44
  "dependencies": {
45
- "@autonomys/asynchronous": "^1.4.7",
46
- "@autonomys/auto-dag-data": "^1.4.7",
47
- "@autonomys/auto-utils": "^1.4.7",
45
+ "@autonomys/asynchronous": "^1.4.8",
46
+ "@autonomys/auto-dag-data": "^1.4.8",
47
+ "@autonomys/auto-utils": "^1.4.8",
48
48
  "blockstore-core": "^5.0.2",
49
49
  "jszip": "^3.10.1",
50
50
  "mime-types": "^2.1.35",
@@ -52,5 +52,5 @@
52
52
  "stream": "^0.0.3",
53
53
  "zod": "^3.24.2"
54
54
  },
55
- "gitHead": "79014d250300c8150ed1ef65299c704bfd1054c1"
55
+ "gitHead": "31a60064b1616e8a87749e473e53b5708bfeadee"
56
56
  }
@@ -45,12 +45,14 @@ const isBuffer = (file: File | GenericFile | Buffer): file is Buffer => {
45
45
  * @returns The CID of the file
46
46
  */
47
47
  export const precomputeCid = async (file: File | GenericFile | Buffer, name?: string) => {
48
+ const { cidToString } = await import('@autonomys/auto-dag-data')
49
+
48
50
  if (isGenericFile(file)) {
49
- return precomputeCidFromGenericFile(file)
51
+ return cidToString(await precomputeCidFromGenericFile(file))
50
52
  } else if (isBuffer(file)) {
51
- return precomputeCidFromBuffer(file, name)
53
+ return cidToString(await precomputeCidFromBuffer(file, name))
52
54
  } else {
53
- return precomputeCidFromFile(file, name)
55
+ return cidToString(await precomputeCidFromFile(file, name))
54
56
  }
55
57
  }
56
58
 
@@ -59,3 +61,9 @@ export const blake3Hash = async (cid: string) => {
59
61
 
60
62
  return Buffer.from(blake3HashFromCid(stringToCid(cid)))
61
63
  }
64
+
65
+ export const cidStringFromBlake3Hash = async (hash: Buffer) => {
66
+ const { cidToString, cidFromBlakeHash } = await import('@autonomys/auto-dag-data')
67
+
68
+ return cidToString(cidFromBlakeHash(hash))
69
+ }