@leofcoin/peernet 1.1.75 → 1.1.77
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/exports/browser/{browser-Tj0_3j2t.js → browser-Ei0BXMlu.js} +1 -1
- package/exports/browser/browser-store.js +40 -308
- package/exports/browser/{client-OL7g9E_m.js → client-A009z8av.js} +3 -3
- package/exports/browser/identity.d.ts +1 -1
- package/exports/browser/{index-JbTsvSFB.js → index-G74WLzL7.js} +1 -1
- package/exports/browser/{index-Bvry90bx.js → index-YQrIDBUQ.js} +408 -422
- package/exports/browser/{messages-tiGOv4p0.js → messages-lWRTai7t.js} +1 -1
- package/exports/browser/{peernet-50qCgIc4.js → peernet-dyeDQR4X.js} +628 -625
- package/exports/browser/peernet.d.ts +7 -7
- package/exports/browser/peernet.js +1 -1
- package/exports/store.js +22 -10
- package/exports/types/identity.d.ts +1 -1
- package/exports/types/peernet.d.ts +7 -7
- package/package.json +1 -1
|
@@ -71,7 +71,7 @@ export default class Peernet {
|
|
|
71
71
|
get selectedAccount(): string;
|
|
72
72
|
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
73
73
|
get defaultStores(): string[];
|
|
74
|
-
selectAccount(account: string): Promise<void> | Promise<
|
|
74
|
+
selectAccount(account: string): Promise<void> | Promise<any[]>;
|
|
75
75
|
addProto(name: any, proto: any): void;
|
|
76
76
|
addCodec(codec: any): void;
|
|
77
77
|
addStore(name: any, prefix: any, root: any, isPrivate?: boolean): Promise<void>;
|
|
@@ -131,12 +131,12 @@ export default class Peernet {
|
|
|
131
131
|
providersFor(hash: string, store?: undefined): Promise<import("./dht/dht.js").DHTProviderMapValue>;
|
|
132
132
|
get block(): {
|
|
133
133
|
get: (hash: string) => Promise<any>;
|
|
134
|
-
put: (hash: string, data: Uint8Array) => Promise<void | any[]
|
|
134
|
+
put: (hash: string, data: Uint8Array) => Promise<void | any[]>;
|
|
135
135
|
has: (hash: string) => Promise<boolean | any[]>;
|
|
136
136
|
};
|
|
137
137
|
get transaction(): {
|
|
138
138
|
get: (hash: string) => Promise<any>;
|
|
139
|
-
put: (hash: string, data: Uint8Array) => Promise<void | any[]
|
|
139
|
+
put: (hash: string, data: Uint8Array) => Promise<void | any[]>;
|
|
140
140
|
has: (hash: string) => Promise<boolean | any[]>;
|
|
141
141
|
};
|
|
142
142
|
requestData(hash: any, store: any): any;
|
|
@@ -153,7 +153,7 @@ export default class Peernet {
|
|
|
153
153
|
* @param {String} hash
|
|
154
154
|
* @param {Buffer} message
|
|
155
155
|
*/
|
|
156
|
-
put: (hash: any, message: any) => Promise<void | any[]
|
|
156
|
+
put: (hash: any, message: any) => Promise<void | any[]>;
|
|
157
157
|
/**
|
|
158
158
|
* @param {String} hash
|
|
159
159
|
* @return {Boolean}
|
|
@@ -173,7 +173,7 @@ export default class Peernet {
|
|
|
173
173
|
* @param {String} hash
|
|
174
174
|
* @param {Buffer} data
|
|
175
175
|
*/
|
|
176
|
-
put: (hash: any, data: any) => Promise<void | any[]
|
|
176
|
+
put: (hash: any, data: any) => Promise<void | any[]>;
|
|
177
177
|
/**
|
|
178
178
|
* @param {String} hash
|
|
179
179
|
* @return {Boolean}
|
|
@@ -193,7 +193,7 @@ export default class Peernet {
|
|
|
193
193
|
* @param {String} hash
|
|
194
194
|
* @param {Buffer} data
|
|
195
195
|
*/
|
|
196
|
-
put: (hash: any, data: any) => Promise<void | any[]
|
|
196
|
+
put: (hash: any, data: any) => Promise<void | any[]>;
|
|
197
197
|
/**
|
|
198
198
|
* @param {String} hash
|
|
199
199
|
* @return {Boolean}
|
|
@@ -223,7 +223,7 @@ export default class Peernet {
|
|
|
223
223
|
* @param {Buffer} data
|
|
224
224
|
* @param {String} storeName - storeName to access
|
|
225
225
|
*/
|
|
226
|
-
put(hash: string, data: Uint8Array, storeName?: string | LeofcoinStorageClass): Promise<void | any[]
|
|
226
|
+
put(hash: string, data: Uint8Array, storeName?: string | LeofcoinStorageClass): Promise<void | any[]>;
|
|
227
227
|
/**
|
|
228
228
|
* @param {String} hash
|
|
229
229
|
* @return {Boolean}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-dyeDQR4X.js';
|
|
2
2
|
import './value-wzPYMxsX.js';
|
package/exports/store.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { homedir } from 'os';
|
|
3
|
-
import { readdir, mkdir } from 'fs/promises';
|
|
4
2
|
import { ClassicLevel } from 'classic-level';
|
|
5
3
|
|
|
6
4
|
const encode = (string) => {
|
|
@@ -75,17 +73,22 @@ class KeyValue {
|
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
|
|
76
|
+
globalThis.process?.versions?.node ? false : true;
|
|
78
77
|
const init = async (root, home = true) => {
|
|
79
78
|
let _root = root;
|
|
80
|
-
|
|
79
|
+
const join = (await import('path')).join;
|
|
80
|
+
if (home) {
|
|
81
|
+
const homedir = (await import('os')).homedir;
|
|
81
82
|
_root = join(homedir(), root);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
}
|
|
84
|
+
const readdir = (await import('fs/promises')).readdir;
|
|
85
|
+
try {
|
|
86
|
+
await readdir(_root);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
const mkdir = (await import('fs/promises')).mkdir;
|
|
90
|
+
await mkdir(_root, { recursive: true });
|
|
91
|
+
}
|
|
89
92
|
return _root;
|
|
90
93
|
};
|
|
91
94
|
|
|
@@ -115,6 +118,15 @@ class Store {
|
|
|
115
118
|
? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength / Uint8Array.BYTES_PER_ELEMENT)
|
|
116
119
|
: buffer;
|
|
117
120
|
}
|
|
121
|
+
async has(key) {
|
|
122
|
+
try {
|
|
123
|
+
await this.get(key);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
118
130
|
async get(key) {
|
|
119
131
|
return this.toUint8Array(await this.db.get(this.toKeyPath(key)));
|
|
120
132
|
}
|
|
@@ -8,7 +8,7 @@ export default class Identity {
|
|
|
8
8
|
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
9
9
|
getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
10
10
|
load(password?: string): Promise<void>;
|
|
11
|
-
selectAccount(account: string): Promise<void> | Promise<
|
|
11
|
+
selectAccount(account: string): Promise<void> | Promise<any[]>;
|
|
12
12
|
sign(hash: Uint8Array): any;
|
|
13
13
|
lock(password: string): void;
|
|
14
14
|
unlock(password: string): void;
|
|
@@ -71,7 +71,7 @@ export default class Peernet {
|
|
|
71
71
|
get selectedAccount(): string;
|
|
72
72
|
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
73
73
|
get defaultStores(): string[];
|
|
74
|
-
selectAccount(account: string): Promise<void> | Promise<
|
|
74
|
+
selectAccount(account: string): Promise<void> | Promise<any[]>;
|
|
75
75
|
addProto(name: any, proto: any): void;
|
|
76
76
|
addCodec(codec: any): void;
|
|
77
77
|
addStore(name: any, prefix: any, root: any, isPrivate?: boolean): Promise<void>;
|
|
@@ -131,12 +131,12 @@ export default class Peernet {
|
|
|
131
131
|
providersFor(hash: string, store?: undefined): Promise<import("./dht/dht.js").DHTProviderMapValue>;
|
|
132
132
|
get block(): {
|
|
133
133
|
get: (hash: string) => Promise<any>;
|
|
134
|
-
put: (hash: string, data: Uint8Array) => Promise<void | any[]
|
|
134
|
+
put: (hash: string, data: Uint8Array) => Promise<void | any[]>;
|
|
135
135
|
has: (hash: string) => Promise<boolean | any[]>;
|
|
136
136
|
};
|
|
137
137
|
get transaction(): {
|
|
138
138
|
get: (hash: string) => Promise<any>;
|
|
139
|
-
put: (hash: string, data: Uint8Array) => Promise<void | any[]
|
|
139
|
+
put: (hash: string, data: Uint8Array) => Promise<void | any[]>;
|
|
140
140
|
has: (hash: string) => Promise<boolean | any[]>;
|
|
141
141
|
};
|
|
142
142
|
requestData(hash: any, store: any): any;
|
|
@@ -153,7 +153,7 @@ export default class Peernet {
|
|
|
153
153
|
* @param {String} hash
|
|
154
154
|
* @param {Buffer} message
|
|
155
155
|
*/
|
|
156
|
-
put: (hash: any, message: any) => Promise<void | any[]
|
|
156
|
+
put: (hash: any, message: any) => Promise<void | any[]>;
|
|
157
157
|
/**
|
|
158
158
|
* @param {String} hash
|
|
159
159
|
* @return {Boolean}
|
|
@@ -173,7 +173,7 @@ export default class Peernet {
|
|
|
173
173
|
* @param {String} hash
|
|
174
174
|
* @param {Buffer} data
|
|
175
175
|
*/
|
|
176
|
-
put: (hash: any, data: any) => Promise<void | any[]
|
|
176
|
+
put: (hash: any, data: any) => Promise<void | any[]>;
|
|
177
177
|
/**
|
|
178
178
|
* @param {String} hash
|
|
179
179
|
* @return {Boolean}
|
|
@@ -193,7 +193,7 @@ export default class Peernet {
|
|
|
193
193
|
* @param {String} hash
|
|
194
194
|
* @param {Buffer} data
|
|
195
195
|
*/
|
|
196
|
-
put: (hash: any, data: any) => Promise<void | any[]
|
|
196
|
+
put: (hash: any, data: any) => Promise<void | any[]>;
|
|
197
197
|
/**
|
|
198
198
|
* @param {String} hash
|
|
199
199
|
* @return {Boolean}
|
|
@@ -223,7 +223,7 @@ export default class Peernet {
|
|
|
223
223
|
* @param {Buffer} data
|
|
224
224
|
* @param {String} storeName - storeName to access
|
|
225
225
|
*/
|
|
226
|
-
put(hash: string, data: Uint8Array, storeName?: string | LeofcoinStorageClass): Promise<void | any[]
|
|
226
|
+
put(hash: string, data: Uint8Array, storeName?: string | LeofcoinStorageClass): Promise<void | any[]>;
|
|
227
227
|
/**
|
|
228
228
|
* @param {String} hash
|
|
229
229
|
* @return {Boolean}
|