@autonomys/auto-drive 1.4.7 → 1.4.9
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/README.md +2 -2
- package/dist/offline/cid.d.ts +2 -1
- package/dist/offline/cid.d.ts.map +1 -1
- package/dist/offline/cid.js +10 -4
- package/package.json +5 -5
- package/src/offline/cid.ts +11 -3
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ To interact with the Auto-Drive API, you'll need to create an API key. Follow th
|
|
|
32
32
|
Here is an example of how to use the `fs.uploadFileFromFilepath` method to upload a file with optional encryption and compression:
|
|
33
33
|
|
|
34
34
|
```typescript
|
|
35
|
-
import { fs,createAutoDriveApi } from '@autonomys/auto-drive'
|
|
35
|
+
import { fs, createAutoDriveApi } from '@autonomys/auto-drive'
|
|
36
36
|
import { NetworkId } from '@autonomys/auto-utils'
|
|
37
37
|
|
|
38
38
|
const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
|
|
@@ -54,7 +54,7 @@ console.log(`The file is uploaded and its cid is ${cid}`)
|
|
|
54
54
|
### How to upload [File](https://developer.mozilla.org/en-US/docs/Web/API/File) interface
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
|
-
import {
|
|
57
|
+
import { createAutoDriveApi } from '@autonomys/auto-drive'
|
|
58
58
|
import { NetworkId } from '@autonomys/auto-utils'
|
|
59
59
|
|
|
60
60
|
const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
|
package/dist/offline/cid.d.ts
CHANGED
|
@@ -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<
|
|
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,
|
|
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"}
|
package/dist/offline/cid.js
CHANGED
|
@@ -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.
|
|
4
|
+
"version": "1.4.9",
|
|
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.
|
|
46
|
-
"@autonomys/auto-dag-data": "^1.4.
|
|
47
|
-
"@autonomys/auto-utils": "^1.4.
|
|
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": "
|
|
55
|
+
"gitHead": "0f722ba0dcbb56511594e88da62bbc8c138ca67e"
|
|
56
56
|
}
|
package/src/offline/cid.ts
CHANGED
|
@@ -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
|
+
}
|