@withautonomi/autonomi 0.2.2-rc.3 → 0.4.2

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 DELETED
@@ -1,30 +0,0 @@
1
- # JavaScript Autonomi API Documentation
2
-
3
- Note that this is a first version and will be subject to change.
4
-
5
- The entry point for connecting to the network is {@link Client.connect}.
6
-
7
- This API is a wrapper around the Rust API, found here: https://docs.rs/autonomi/latest/autonomi. The Rust API contains more detailed documentation on concepts and some types.
8
-
9
- ## Addresses
10
-
11
- For addresses (chunk, data, archives, etc) we're using hex-encoded strings containing a 256-bit XOR addresse. For example: `abcdefg012345678900000000000000000000000000000000000000000000000`.
12
-
13
- ## Example
14
-
15
- ```javascript
16
- import init, { Client, Wallet, getEvmNetwork } from 'autonomi';
17
-
18
- let client = await new Client(["/ip4/127.0.0.1/tcp/36075/ws/p2p/12D3KooWALb...BhDAfJY"]);
19
- console.log("connected");
20
-
21
- let wallet = Wallet.new_from_private_key(getEvmNetwork, "your_private_key_here");
22
- console.log("wallet retrieved");
23
-
24
- let data = new Uint8Array([1, 2, 3]);
25
- let result = await client.put(data, wallet);
26
- console.log("Data stored at:", result);
27
-
28
- let fetchedData = await client.get(result);
29
- console.log("Data retrieved:", fetchedData);
30
- ```
package/autonomi.d.ts DELETED
@@ -1,314 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * # Example
5
- *
6
- * ```js
7
- * const secretKey = genSecretKey();
8
- * await client.putUserDataToVault(userData, wallet, secretKey);
9
- * const userDataFetched = await client.getUserDataFromVault(secretKey);
10
- * ```
11
- * @returns {SecretKey}
12
- */
13
- export function genSecretKey(): SecretKey;
14
- /**
15
- * Get the current `EvmNetwork` that was set using environment variables that were used during the build process of this library.
16
- * @returns {any}
17
- */
18
- export function getEvmNetwork(): any;
19
- /**
20
- * Get a funded wallet for testing. This either uses a default private key or the `EVM_PRIVATE_KEY`
21
- * environment variable that was used during the build process of this library.
22
- * @returns {Wallet}
23
- */
24
- export function getFundedWallet(): Wallet;
25
- /**
26
- * Enable tracing logging in the console.
27
- *
28
- * A level could be passed like `trace` or `warn`. Or set for a specific module/crate
29
- * with `sn_networking=trace,autonomi=info`.
30
- *
31
- * # Example
32
- *
33
- * ```js
34
- * logInit("sn_networking=warn,autonomi=trace");
35
- * ```
36
- * @param {string} directive
37
- */
38
- export function logInit(directive: string): void;
39
- /**
40
- * Structure mapping paths to data addresses.
41
- */
42
- export class Archive {
43
- free(): void;
44
- /**
45
- * Create a new archive.
46
- */
47
- constructor();
48
- /**
49
- * Add a new file to the archive.
50
- * @param {string} path
51
- * @param {string} data_addr
52
- */
53
- addNewFile(path: string, data_addr: string): void;
54
- /**
55
- * @param {string} old_path
56
- * @param {string} new_path
57
- */
58
- renameFile(old_path: string, new_path: string): void;
59
- /**
60
- * @returns {any}
61
- */
62
- map(): any;
63
- }
64
- /**
65
- */
66
- export class AttoTokens {
67
- free(): void;
68
- /**
69
- * @returns {string}
70
- */
71
- toString(): string;
72
- }
73
- /**
74
- * The `Client` object allows interaction with the network to store and retrieve data.
75
- *
76
- * To connect to the network, see {@link Client.connect}.
77
- *
78
- * # Example
79
- *
80
- * ```js
81
- * let client = await Client.connect(["/ip4/127.0.0.1/tcp/36075/ws/p2p/12D3KooWALb...BhDAfJY"]);
82
- * const dataAddr = await client.dataPut(new Uint8Array([0, 1, 2, 3]), wallet);
83
- *
84
- * const archive = new Archive();
85
- * archive.addNewFile("foo", dataAddr);
86
- *
87
- * const archiveAddr = await client.archivePut(archive, wallet);
88
- * const archiveFetched = await client.archiveGet(archiveAddr);
89
- * ```
90
- */
91
- export class Client {
92
- free(): void;
93
- /**
94
- * Connect to the network via the given peers.
95
- *
96
- * # Example
97
- *
98
- * ```js
99
- * let client = await Client.connect(["/ip4/127.0.0.1/tcp/36075/ws/p2p/12D3KooWALb...BhDAfJY"]);
100
- * ```
101
- * @param {(string)[]} peers
102
- * @returns {Promise<Client>}
103
- */
104
- static connect(peers: (string)[]): Promise<Client>;
105
- /**
106
- * Upload a chunk to the network.
107
- *
108
- * Returns the hex encoded address of the chunk.
109
- *
110
- * This is not yet implemented.
111
- * @param {Uint8Array} _data
112
- * @param {Wallet} _wallet
113
- * @returns {Promise<string>}
114
- */
115
- chunkPut(_data: Uint8Array, _wallet: Wallet): Promise<string>;
116
- /**
117
- * Fetch the chunk from the network.
118
- * @param {string} addr
119
- * @returns {Promise<Uint8Array>}
120
- */
121
- chunkGet(addr: string): Promise<Uint8Array>;
122
- /**
123
- * Upload data to the network.
124
- *
125
- * Returns the hex encoded address of the data.
126
- * @param {Uint8Array} data
127
- * @param {Wallet} wallet
128
- * @returns {Promise<string>}
129
- */
130
- dataPut(data: Uint8Array, wallet: Wallet): Promise<string>;
131
- /**
132
- * Fetch the data from the network.
133
- * @param {string} addr
134
- * @returns {Promise<Uint8Array>}
135
- */
136
- dataGet(addr: string): Promise<Uint8Array>;
137
- /**
138
- * Get the cost of uploading data to the network.
139
- * @param {Uint8Array} data
140
- * @returns {Promise<AttoTokens>}
141
- */
142
- dataCost(data: Uint8Array): Promise<AttoTokens>;
143
- /**
144
- * Fetch an archive from the network.
145
- * @param {string} addr
146
- * @returns {Promise<Archive>}
147
- */
148
- archiveGet(addr: string): Promise<Archive>;
149
- /**
150
- * Upload an archive to the network.
151
- *
152
- * Returns the hex encoded address of the archive.
153
- * @param {Archive} archive
154
- * @param {Wallet} wallet
155
- * @returns {Promise<string>}
156
- */
157
- archivePut(archive: Archive, wallet: Wallet): Promise<string>;
158
- /**
159
- * Fetch the user data from the vault.
160
- *
161
- * # Example
162
- *
163
- * ```js
164
- * const secretKey = genSecretKey();
165
- * const userData = await client.getUserDataFromVault(secretKey);
166
- * ```
167
- * @param {SecretKey} secret_key
168
- * @returns {Promise<UserData>}
169
- */
170
- getUserDataFromVault(secret_key: SecretKey): Promise<UserData>;
171
- /**
172
- * Put the user data to the vault.
173
- *
174
- * # Example
175
- *
176
- * ```js
177
- * const secretKey = genSecretKey();
178
- * await client.putUserDataToVault(userData, wallet, secretKey);
179
- * ```
180
- * @param {UserData} user_data
181
- * @param {Wallet} wallet
182
- * @param {SecretKey} secret_key
183
- * @returns {Promise<void>}
184
- */
185
- putUserDataToVault(user_data: UserData, wallet: Wallet, secret_key: SecretKey): Promise<void>;
186
- }
187
- /**
188
- */
189
- export class SecretKey {
190
- free(): void;
191
- }
192
- /**
193
- * Structure to keep track of uploaded archives, registers and other data.
194
- */
195
- export class UserData {
196
- free(): void;
197
- /**
198
- * Create a new user data structure.
199
- */
200
- constructor();
201
- /**
202
- * Store an archive address in the user data with an optional name.
203
- *
204
- * # Example
205
- *
206
- * ```js
207
- * userData.addFileArchive(archiveAddr, "foo");
208
- * ```
209
- * @param {string} archive
210
- * @param {string | undefined} [name]
211
- */
212
- addFileArchive(archive: string, name?: string): void;
213
- /**
214
- * @param {string} archive
215
- */
216
- removeFileArchive(archive: string): void;
217
- /**
218
- * @returns {any}
219
- */
220
- fileArchives(): any;
221
- }
222
- /**
223
- */
224
- export class Wallet {
225
- free(): void;
226
- }
227
-
228
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
229
-
230
- export interface InitOutput {
231
- readonly memory: WebAssembly.Memory;
232
- readonly __wbg_client_free: (a: number, b: number) => void;
233
- readonly __wbg_attotokens_free: (a: number, b: number) => void;
234
- readonly attotokens_toString: (a: number, b: number) => void;
235
- readonly client_connect: (a: number, b: number) => number;
236
- readonly client_chunkPut: (a: number, b: number, c: number, d: number) => number;
237
- readonly client_chunkGet: (a: number, b: number, c: number) => number;
238
- readonly client_dataPut: (a: number, b: number, c: number, d: number) => number;
239
- readonly client_dataGet: (a: number, b: number, c: number) => number;
240
- readonly client_dataCost: (a: number, b: number, c: number) => number;
241
- readonly __wbg_archive_free: (a: number, b: number) => void;
242
- readonly archive_new: () => number;
243
- readonly archive_addNewFile: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
244
- readonly archive_renameFile: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
245
- readonly archive_map: (a: number, b: number) => void;
246
- readonly client_archiveGet: (a: number, b: number, c: number) => number;
247
- readonly client_archivePut: (a: number, b: number, c: number) => number;
248
- readonly __wbg_userdata_free: (a: number, b: number) => void;
249
- readonly userdata_new: () => number;
250
- readonly userdata_addFileArchive: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
251
- readonly userdata_removeFileArchive: (a: number, b: number, c: number, d: number) => void;
252
- readonly userdata_fileArchives: (a: number, b: number) => void;
253
- readonly client_getUserDataFromVault: (a: number, b: number) => number;
254
- readonly client_putUserDataToVault: (a: number, b: number, c: number, d: number) => number;
255
- readonly __wbg_secretkey_free: (a: number, b: number) => void;
256
- readonly genSecretKey: () => number;
257
- readonly getEvmNetwork: (a: number) => void;
258
- readonly __wbg_wallet_free: (a: number, b: number) => void;
259
- readonly getFundedWallet: () => number;
260
- readonly logInit: (a: number, b: number) => void;
261
- readonly BrotliDecoderCreateInstance: (a: number, b: number, c: number) => number;
262
- readonly BrotliDecoderSetParameter: (a: number, b: number, c: number) => void;
263
- readonly BrotliDecoderDecompressPrealloc: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
264
- readonly BrotliDecoderDecompressWithReturnInfo: (a: number, b: number, c: number, d: number, e: number) => void;
265
- readonly BrotliDecoderDecompress: (a: number, b: number, c: number, d: number) => number;
266
- readonly BrotliDecoderDecompressStream: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
267
- readonly BrotliDecoderDecompressStreaming: (a: number, b: number, c: number, d: number, e: number) => number;
268
- readonly BrotliDecoderMallocU8: (a: number, b: number) => number;
269
- readonly BrotliDecoderFreeU8: (a: number, b: number, c: number) => void;
270
- readonly BrotliDecoderMallocUsize: (a: number, b: number) => number;
271
- readonly BrotliDecoderFreeUsize: (a: number, b: number, c: number) => void;
272
- readonly BrotliDecoderDestroyInstance: (a: number) => void;
273
- readonly BrotliDecoderHasMoreOutput: (a: number) => number;
274
- readonly BrotliDecoderTakeOutput: (a: number, b: number) => number;
275
- readonly BrotliDecoderIsUsed: (a: number) => number;
276
- readonly BrotliDecoderIsFinished: (a: number) => number;
277
- readonly BrotliDecoderGetErrorCode: (a: number) => number;
278
- readonly BrotliDecoderGetErrorString: (a: number) => number;
279
- readonly BrotliDecoderErrorString: (a: number) => number;
280
- readonly BrotliDecoderVersion: () => number;
281
- readonly ring_core_0_17_8_bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
282
- readonly __wbindgen_malloc: (a: number, b: number) => number;
283
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
284
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
285
- readonly __wbindgen_export_3: WebAssembly.Table;
286
- readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb1127ec8a5f76069: (a: number, b: number) => void;
287
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h7964ee7a46fd96a5: (a: number, b: number, c: number) => void;
288
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6d1a6f0013d59045: (a: number, b: number, c: number) => void;
289
- readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdcedccdc30da04ac: (a: number, b: number) => void;
290
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
291
- readonly __wbindgen_exn_store: (a: number) => void;
292
- readonly wasm_bindgen__convert__closures__invoke2_mut__h2d9c0b8c5965541d: (a: number, b: number, c: number, d: number) => void;
293
- }
294
-
295
- export type SyncInitInput = BufferSource | WebAssembly.Module;
296
- /**
297
- * Instantiates the given `module`, which can either be bytes or
298
- * a precompiled `WebAssembly.Module`.
299
- *
300
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
301
- *
302
- * @returns {InitOutput}
303
- */
304
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
305
-
306
- /**
307
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
308
- * for everything else, calls `WebAssembly.instantiate` directly.
309
- *
310
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
311
- *
312
- * @returns {Promise<InitOutput>}
313
- */
314
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;