@autonomys/auto-drive 1.2.2 → 1.2.4

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 CHANGED
@@ -20,14 +20,22 @@ yarn add @autonomys/auto-drive
20
20
 
21
21
  ### How to use it?
22
22
 
23
+ To interact with the Auto-Drive API, you'll need to create an API key. Follow these steps:
24
+
25
+ - Go to [Auto-Drive](https://ai3.storage) and login with your preffered SSO.
26
+ - Once you're logged in, click on the profile section in the left sidebar menu.
27
+ - In the profile section, click on 'Create API Key'
28
+ - Read the modal message and click on generate
29
+
23
30
  ### How to upload a file from filepath? (Not available in browser)
24
31
 
25
32
  Here is an example of how to use the `uploadFileFromFilepath` method to upload a file with optional encryption and compression:
26
33
 
27
34
  ```typescript
28
35
  import { uploadFileFromFilepath,createAutoDriveApi } from '@autonomys/auto-drive'
36
+ import { NetworkId } from '@autonomys/auto-utils'
29
37
 
30
- const api = createAutoDriveApi({ apiKey: 'your-api-key' }) // Initialize your API instance with API key
38
+ const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
31
39
  const filePath = 'path/to/your/file.txt' // Specify the path to your file
32
40
  const options = {
33
41
  password: 'your-encryption-password', // Optional: specify a password for encryption
@@ -47,8 +55,9 @@ console.log(`The file is uploaded and its cid is ${cid}`)
47
55
 
48
56
  ```typescript
49
57
  import { uploadFileFromInput, createAutoDriveApi } from '@autonomys/auto-drive'
58
+ import { NetworkId } from '@autonomys/auto-utils'
50
59
 
51
- const api = createAutoDriveApi({ apiKey: 'your-api-key' }) // Initialize your API instance with API key
60
+ const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
52
61
 
53
62
  // e.g Get File from object from HTML event
54
63
  const file: File = e.target.value // Substitute with your file
@@ -81,8 +90,9 @@ You could upload any file that could be represented in that way. For example, up
81
90
 
82
91
  ```typescript
83
92
  import { createAutoDriveApi, uploadFile } from '@autonomys/auto-drive'
93
+ import { NetworkId } from '@autonomys/auto-utils'
84
94
 
85
- const api = createAutoDriveApi({ apiKey: 'your-api-key' }) // Initialize your API instance with API key
95
+ const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
86
96
  const buffer = Buffer.from(...);
87
97
  const genericFile = {
88
98
  read: async function *() {
@@ -112,8 +122,9 @@ console.log(`The file is uploaded and its cid is ${cid}`)
112
122
 
113
123
  ```ts
114
124
  import { createAutoDriveApi, uploadFolderFromFolderPath } from '@autonomys/auto-drive'
125
+ import { NetworkId } from '@autonomys/auto-utils'
115
126
 
116
- const api = createAutoDriveApi({ apiKey: 'your-api-key' }) // Initialize your API instance with API key
127
+ const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
117
128
  const folderPath = 'path/to/your/folder' // Specify the path to your folder
118
129
 
119
130
  const options = {
@@ -138,8 +149,9 @@ Here is an example of how to use the `downloadFile` method to download a file fr
138
149
 
139
150
  ```typescript
140
151
  import { createAutoDriveApi, downloadFile } from '@autonomys/auto-drive'
152
+ import { NetworkId } from '@autonomys/auto-utils'
141
153
 
142
- const api = createAutoDriveApi({ apiKey: 'your-api-key' }) // Initialize your API instance with API key
154
+ const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
143
155
 
144
156
  try {
145
157
  const cid = '..'
@@ -160,8 +172,9 @@ Here is an example of how to use the `getRoots` method to retrieve the root dire
160
172
 
161
173
  ```typescript
162
174
  import { createAutoDriveApi, apiCalls, Scope } from '@autonomys/auto-drive'
175
+ import { NetworkId } from '@autonomys/auto-utils'
163
176
 
164
- const api = createAutoDriveApi({ apiKey: 'your-api-key' }) // Initialize your API instance with API key
177
+ const api = createAutoDriveApi({ apiKey: 'your-api-key', network: NetworkId.TAURUS }) // Initialize your API instance with API key
165
178
 
166
179
  try {
167
180
  const myFiles = await apiCalls.getRoots(api, {
@@ -1,3 +1,4 @@
1
+ import { AutoDriveNetwork } from './networks';
1
2
  export interface AutoDriveApi {
2
3
  sendRequest: (relativeUrl: string, request: Partial<Request>, body?: BodyInit) => Promise<Response>;
3
4
  }
@@ -7,9 +8,17 @@ export declare enum OAuthProvider {
7
8
  }
8
9
  export type ApiKeyAuthProvider = 'apikey';
9
10
  export type AuthProvider = ApiKeyAuthProvider | 'oauth';
10
- export declare const createAutoDriveApi: ({ provider, apiKey, url, }: {
11
+ type ConnectionOptions = {
11
12
  provider?: AuthProvider;
12
- apiKey: string;
13
- url?: string;
14
- }) => AutoDriveApi;
13
+ apiKey?: string;
14
+ url?: null;
15
+ network: AutoDriveNetwork;
16
+ } | {
17
+ provider?: AuthProvider;
18
+ apiKey?: string;
19
+ url: string;
20
+ network?: null;
21
+ };
22
+ export declare const createAutoDriveApi: ({ provider, apiKey, url, network, }: ConnectionOptions) => AutoDriveApi;
23
+ export {};
15
24
  //# sourceMappingURL=connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/api/connection.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,CACX,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EACzB,IAAI,CAAC,EAAE,QAAQ,KACZ,OAAO,CAAC,QAAQ,CAAC,CAAA;CACvB;AAED,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AACzC,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,OAAO,CAAA;AAEvD,eAAO,MAAM,kBAAkB,+BAI5B;IACD,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,KAAG,YAiBH,CAAA"}
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/api/connection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAA2B,MAAM,YAAY,CAAA;AAEtE,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,CACX,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EACzB,IAAI,CAAC,EAAE,QAAQ,KACZ,OAAO,CAAC,QAAQ,CAAC,CAAA;CACvB;AAED,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AACzC,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,OAAO,CAAA;AAEvD,KAAK,iBAAiB,GAClB;IACE,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,gBAAgB,CAAA;CAC1B,GACD;IACE,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,IAAI,CAAA;CACf,CAAA;AAEL,eAAO,MAAM,kBAAkB,wCAK5B,iBAAiB,KAAG,YAmBtB,CAAA"}
@@ -10,18 +10,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createAutoDriveApi = exports.OAuthProvider = void 0;
13
+ const networks_1 = require("./networks");
13
14
  var OAuthProvider;
14
15
  (function (OAuthProvider) {
15
16
  OAuthProvider["GOOGLE"] = "google";
16
17
  OAuthProvider["DISCORD"] = "discord";
17
18
  })(OAuthProvider || (exports.OAuthProvider = OAuthProvider = {}));
18
- const createAutoDriveApi = ({ provider = 'apikey', apiKey, url = 'https://demo.auto-drive.autonomys.xyz/api', }) => {
19
+ const createAutoDriveApi = ({ provider = 'apikey', apiKey, url = null, network, }) => {
20
+ const baseUrl = !network ? url : (0, networks_1.getNetworkUrl)(network);
19
21
  return {
20
22
  sendRequest: (relativeUrl, request, body) => __awaiter(void 0, void 0, void 0, function* () {
21
23
  var _a;
22
24
  const headers = new Headers(Object.assign(Object.assign({}, Object.fromEntries(((_a = request.headers) === null || _a === void 0 ? void 0 : _a.entries()) || [])), { 'x-auth-provider': provider, Authorization: `Bearer ${apiKey}` }));
23
25
  const fullRequest = Object.assign(Object.assign({}, request), { headers: new Headers(headers), body });
24
- return fetch(`${url}${relativeUrl}`, fullRequest);
26
+ return fetch(`${baseUrl}${relativeUrl}`, fullRequest);
25
27
  }),
26
28
  };
27
29
  };
@@ -1,5 +1,7 @@
1
+ export type AutoDriveNetwork = keyof typeof networks;
1
2
  export declare const networks: {
2
3
  taurus: string;
4
+ mainnet: string;
3
5
  };
4
- export declare const getNetworkUrl: (networkId: keyof typeof networks) => string;
6
+ export declare const getNetworkUrl: (networkId: AutoDriveNetwork) => string;
5
7
  //# sourceMappingURL=networks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../src/api/networks.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;CAEyB,CAAA;AAE9C,eAAO,MAAM,aAAa,cAAe,MAAM,OAAO,QAAQ,WAM7D,CAAA"}
1
+ {"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../src/api/networks.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,QAAQ,CAAA;AAEpD,eAAO,MAAM,QAAQ;;;CAGyB,CAAA;AAE9C,eAAO,MAAM,aAAa,cAAe,gBAAgB,WAMxD,CAAA"}
@@ -4,6 +4,7 @@ exports.getNetworkUrl = exports.networks = void 0;
4
4
  const auto_utils_1 = require("@autonomys/auto-utils");
5
5
  exports.networks = {
6
6
  [auto_utils_1.NetworkId.TAURUS]: 'https://demo.auto-drive.autonomys.xyz/api',
7
+ [auto_utils_1.NetworkId.MAINNET]: 'https://mainnet.auto-drive.autonomys.xyz/api',
7
8
  };
8
9
  const getNetworkUrl = (networkId) => {
9
10
  if (!exports.networks[networkId]) {
@@ -0,0 +1,3 @@
1
+ export * from './api/index.js';
2
+ export * from './utils/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './api/index.js';
2
+ export * from './utils/index.js';
@@ -0,0 +1,2 @@
1
+ export declare const getFiles: (folderPath: string) => Promise<string[]>;
2
+ //# sourceMappingURL=folder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../../src/utils/folder.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,eAAsB,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,CAWnE,CAAA"}
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import fs from 'fs/promises';
11
+ import path from 'path';
12
+ export const getFiles = (folderPath) => __awaiter(void 0, void 0, void 0, function* () {
13
+ const stat = yield fs.stat(folderPath);
14
+ if (stat.isDirectory()) {
15
+ const files = yield fs.readdir(folderPath);
16
+ const promises = files.map((file) => getFiles(path.join(folderPath, file)));
17
+ const allFiles = yield Promise.all(promises);
18
+ return allFiles.flat();
19
+ }
20
+ else {
21
+ return [folderPath];
22
+ }
23
+ });
@@ -1,2 +1,7 @@
1
- export {};
1
+ import * as rxjs from 'rxjs';
2
+ export declare class PromisedObservable<T> extends rxjs.Observable<T> {
3
+ constructor(subscribe?: (this: rxjs.Observable<T>, subscriber: rxjs.Subscriber<T>) => void);
4
+ get promise(): Promise<T>;
5
+ }
6
+ export declare const firstValueFrom: typeof rxjs.firstValueFrom, lastValueFrom: typeof rxjs.lastValueFrom;
2
7
  //# sourceMappingURL=observable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../src/utils/observable.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../src/utils/observable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAQ5B,qBAAa,kBAAkB,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC/C,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;IAI1F,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAExB;CACF;AAED,eAAO,MAAQ,cAAc,8BAAE,aAAa,2BAAS,CAAA"}
@@ -1,2 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ import * as rxjs from 'rxjs';
2
+ const asyncCallback = (callback) => {
3
+ return (t) => {
4
+ callback(t);
5
+ };
6
+ };
7
+ export class PromisedObservable extends rxjs.Observable {
8
+ constructor(subscribe) {
9
+ super(subscribe && asyncCallback(subscribe));
10
+ }
11
+ get promise() {
12
+ return lastValueFrom(this);
13
+ }
14
+ }
15
+ export const { firstValueFrom, lastValueFrom } = rxjs;
@@ -0,0 +1,3 @@
1
+ import { WriteStream } from 'fs';
2
+ export declare const createWriteStreamAdapter: (nodeWriteStream: WriteStream) => WritableStream<Uint8Array>;
3
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AAEhC,eAAO,MAAM,wBAAwB,oBAClB,WAAW,KAC3B,cAAc,CAAC,UAAU,CAoB3B,CAAA"}
@@ -0,0 +1,22 @@
1
+ export const createWriteStreamAdapter = (nodeWriteStream) => {
2
+ return new WritableStream({
3
+ write(chunk) {
4
+ return new Promise((resolve, reject) => {
5
+ nodeWriteStream.write(chunk, (err) => {
6
+ if (err) {
7
+ reject(err);
8
+ }
9
+ else {
10
+ resolve();
11
+ }
12
+ });
13
+ });
14
+ },
15
+ close() {
16
+ nodeWriteStream.end();
17
+ },
18
+ abort(err) {
19
+ nodeWriteStream.destroy(err);
20
+ },
21
+ });
22
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@autonomys/auto-drive",
3
3
  "packageManager": "yarn@4.2.2",
4
- "version": "1.2.2",
4
+ "version": "1.2.4",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -42,12 +42,12 @@
42
42
  "typescript": "^5.6.3"
43
43
  },
44
44
  "dependencies": {
45
- "@autonomys/auto-dag-data": "^1.2.2",
45
+ "@autonomys/auto-dag-data": "^1.2.4",
46
46
  "jszip": "^3.10.1",
47
47
  "mime-types": "^2.1.35",
48
48
  "process": "^0.11.10",
49
49
  "stream": "^0.0.3",
50
50
  "zod": "^3.23.8"
51
51
  },
52
- "gitHead": "6e9151e187b7e7186700c3b663df33b7064fe9a4"
52
+ "gitHead": "1c98f6917d695bec8fee770c875d339707662709"
53
53
  }
@@ -1,3 +1,6 @@
1
+ import { NetworkId } from '@autonomys/auto-utils'
2
+ import { AutoDriveNetwork, getNetworkUrl, networks } from './networks'
3
+
1
4
  export interface AutoDriveApi {
2
5
  sendRequest: (
3
6
  relativeUrl: string,
@@ -14,15 +17,28 @@ export enum OAuthProvider {
14
17
  export type ApiKeyAuthProvider = 'apikey'
15
18
  export type AuthProvider = ApiKeyAuthProvider | 'oauth'
16
19
 
20
+ type ConnectionOptions =
21
+ | {
22
+ provider?: AuthProvider
23
+ apiKey?: string
24
+ url?: null
25
+ network: AutoDriveNetwork
26
+ }
27
+ | {
28
+ provider?: AuthProvider
29
+ apiKey?: string
30
+ url: string
31
+ network?: null
32
+ }
33
+
17
34
  export const createAutoDriveApi = ({
18
35
  provider = 'apikey',
19
36
  apiKey,
20
- url = 'https://demo.auto-drive.autonomys.xyz/api',
21
- }: {
22
- provider?: AuthProvider
23
- apiKey: string
24
- url?: string
25
- }): AutoDriveApi => {
37
+ url = null,
38
+ network,
39
+ }: ConnectionOptions): AutoDriveApi => {
40
+ const baseUrl = !network ? url : getNetworkUrl(network)
41
+
26
42
  return {
27
43
  sendRequest: async (relativeUrl: string, request: Partial<Request>, body?: BodyInit) => {
28
44
  const headers = new Headers({
@@ -36,7 +52,7 @@ export const createAutoDriveApi = ({
36
52
  body,
37
53
  }
38
54
 
39
- return fetch(`${url}${relativeUrl}`, fullRequest)
55
+ return fetch(`${baseUrl}${relativeUrl}`, fullRequest)
40
56
  },
41
57
  }
42
58
  }
@@ -0,0 +1,16 @@
1
+ import { NetworkId } from '@autonomys/auto-utils'
2
+
3
+ export type AutoDriveNetwork = keyof typeof networks
4
+
5
+ export const networks = {
6
+ [NetworkId.TAURUS]: 'https://demo.auto-drive.autonomys.xyz/api',
7
+ [NetworkId.MAINNET]: 'https://mainnet.auto-drive.autonomys.xyz/api',
8
+ } satisfies Partial<Record<NetworkId, string>>
9
+
10
+ export const getNetworkUrl = (networkId: AutoDriveNetwork) => {
11
+ if (!networks[networkId]) {
12
+ throw new Error(`Network ${networkId} not found`)
13
+ }
14
+
15
+ return networks[networkId]
16
+ }
package/.env DELETED
@@ -1,6 +0,0 @@
1
- OBJECT_MAPPING_ARCHIVER_URL=ws://127.0.0.1:1234
2
- RPC_ENDPOINT=ws://127.0.0.1:1234
3
- PRIVATE_KEYS_PATH=//Alice
4
- CORS_ALLOW_ORIGINS=*
5
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
6
- MAX_CACHE_SIZE=1073741824
@@ -1,17 +0,0 @@
1
- import type { CID } from 'multiformats/cid';
2
- interface AutoCIDTransformers {
3
- stringToCid: (cid: string) => CID;
4
- blake3HashFromCid: (cid: CID) => Uint8Array;
5
- }
6
- export declare class AutoCID {
7
- private readonly cid;
8
- private readonly tools;
9
- constructor(cid: string, tools: AutoCIDTransformers);
10
- static create(cid: string): Promise<AutoCID>;
11
- get asString(): string;
12
- get asCID(): CID;
13
- get asBlake3Hash(): Buffer;
14
- }
15
- export declare const getToolsFromAutoDagData: Promise<AutoCIDTransformers>;
16
- export {};
17
- //# sourceMappingURL=autohash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autohash.d.ts","sourceRoot":"","sources":["../../src/utils/autohash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,UAAU,mBAAmB;IAC3B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAA;IACjC,iBAAiB,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,UAAU,CAAA;CAC5C;AAED,qBAAa,OAAO;IAEhB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,mBAAmB;WAGhC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,KAAK,IAAI,GAAG,CAEf;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;CACF;AAED,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAAC,mBAAmB,CAO/D,CAAA"}
@@ -1,73 +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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.getToolsFromAutoDagData = exports.AutoCID = void 0;
46
- class AutoCID {
47
- constructor(cid, tools) {
48
- this.cid = cid;
49
- this.tools = tools;
50
- }
51
- static create(cid) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const tools = yield exports.getToolsFromAutoDagData;
54
- return new AutoCID(cid, tools);
55
- });
56
- }
57
- get asString() {
58
- return this.cid;
59
- }
60
- get asCID() {
61
- return this.tools.stringToCid(this.cid);
62
- }
63
- get asBlake3Hash() {
64
- return Buffer.from(this.tools.blake3HashFromCid(this.asCID));
65
- }
66
- }
67
- exports.AutoCID = AutoCID;
68
- exports.getToolsFromAutoDagData = Promise.resolve().then(() => __importStar(require('@autonomys/auto-dag-data'))).then(({ stringToCid, blake3HashFromCid }) => {
69
- return {
70
- stringToCid,
71
- blake3HashFromCid,
72
- };
73
- });