@leofcoin/peernet 1.1.50 → 1.1.52
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-store.js +58 -141
- package/exports/browser/client-3221a5d7.js +17580 -0
- package/exports/browser/dht/dht.d.ts +29 -7
- package/exports/browser/identity.d.ts +15 -0
- package/exports/browser/{index-6311966e.js → index-5f552dff.js} +2 -2
- package/exports/browser/{messages-54aa3cad.js → messages-0591b744.js} +2 -2
- package/exports/browser/{peernet-a4156bfd.js → peernet-bc021698.js} +432 -531
- package/exports/browser/peernet.d.ts +25 -32
- package/exports/browser/peernet.js +2 -2
- package/exports/browser/types.d.ts +16 -0
- package/exports/browser/value-4e80eeeb.js +73 -0
- package/exports/peernet.js +35 -34
- package/exports/store.js +117 -193
- package/exports/types/dht/dht.d.ts +29 -7
- package/exports/types/identity.d.ts +15 -0
- package/exports/types/peernet.d.ts +25 -32
- package/exports/types/types.d.ts +16 -0
- package/package.json +2 -2
- package/src/dht/dht.ts +36 -16
- package/src/peernet.ts +48 -61
- package/src/types.ts +28 -0
- package/exports/browser/client-6072af1a.js +0 -41092
- package/exports/browser/value-157ab062.js +0 -64
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// import base32 from '@vandeurenglenn/base32'
|
|
2
|
-
// import base58 from '@vandeurenglenn/base58'
|
|
3
|
-
|
|
4
|
-
// export const encodings = {
|
|
5
|
-
// base58,
|
|
6
|
-
// base32
|
|
7
|
-
// }
|
|
8
|
-
|
|
9
|
-
const encode = (string, encoding = 'utf-8') => {
|
|
10
|
-
if (typeof string === 'string') {
|
|
11
|
-
let encoded;
|
|
12
|
-
|
|
13
|
-
// if (encodings[encoding]) encoded = encodings[encoding].encode(encoded)
|
|
14
|
-
encoded = new TextEncoder().encode(string);
|
|
15
|
-
return encoded
|
|
16
|
-
}
|
|
17
|
-
throw Error(`expected typeof String instead got ${string}`)
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const decode = (uint8Array, encoding) => {
|
|
21
|
-
if (uint8Array instanceof Uint8Array) {
|
|
22
|
-
let decoded;
|
|
23
|
-
// if (encodings[encoding]) decoded = encodings[encoding].decode(decoded)
|
|
24
|
-
decoded = new TextDecoder().decode(uint8Array);
|
|
25
|
-
|
|
26
|
-
return decoded
|
|
27
|
-
}
|
|
28
|
-
throw Error(`expected typeof uint8Array instead got ${uint8Array}`)
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
class KeyValue {
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {string | Uint8Array} input
|
|
35
|
-
*/
|
|
36
|
-
constructor(input) {
|
|
37
|
-
if (typeof input === 'string') {
|
|
38
|
-
this.uint8Array = encode(input);
|
|
39
|
-
} else if (input instanceof Uint8Array) {
|
|
40
|
-
this.uint8Array = input;
|
|
41
|
-
} else if (input instanceof KeyValue) {
|
|
42
|
-
this.uint8Array = input.uint8Array;
|
|
43
|
-
} else {
|
|
44
|
-
throw new Error('Invalid KeyValue, should be a String, Uint8Array or KeyValue')
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
isKeyValue() {
|
|
49
|
-
return true
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Convert to the string representation
|
|
54
|
-
*
|
|
55
|
-
* @param {import('uint8arrays/to-string').SupportedEncodings} [encoding='utf8'] - The encoding to use.
|
|
56
|
-
* @returns {string}
|
|
57
|
-
*/
|
|
58
|
-
toString(encoding = 'utf8') {
|
|
59
|
-
return decode(this.uint8Array)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { KeyValue as K };
|