@leofcoin/peernet 1.1.58 → 1.1.60
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/.prettierrc +7 -0
- package/.travis.yml +4 -4
- package/exports/browser/browser-store.js +1 -1
- package/exports/browser/{index-8868bdd8.js → index-5cd0a662.js} +1 -1
- package/exports/browser/{messages-eb6e5c71.js → messages-638774c5.js} +15 -25
- package/exports/browser/{peernet-87ea02a4.js → peernet-61545c25.js} +7165 -292
- package/exports/browser/peernet.d.ts +13 -16
- package/exports/browser/peernet.js +1 -1
- package/exports/browser/types.d.ts +5 -5
- package/exports/{messages-b9a32987.js → messages-42b2109e.js} +14 -24
- package/exports/peernet.js +110 -132
- package/exports/src/prompts/password.js +1 -1
- package/exports/store.js +3 -1
- package/exports/types/peernet.d.ts +13 -16
- package/exports/types/types.d.ts +5 -5
- package/package.json +1 -1
- package/src/dht/dht.ts +39 -33
- package/src/discovery/peer-discovery.js +8 -8
- package/src/handlers/data.js +3 -3
- package/src/handlers/message.js +1 -1
- package/src/identity.ts +12 -11
- package/src/messages/chat.js +1 -2
- package/src/messages/data-response.js +1 -2
- package/src/messages/data.js +1 -2
- package/src/messages/dht-response.js +1 -2
- package/src/messages/dht.js +1 -2
- package/src/messages/file-link.js +1 -2
- package/src/messages/file.js +1 -2
- package/src/messages/peer-response.js +1 -2
- package/src/messages/peer.js +1 -1
- package/src/messages/peernet.js +1 -2
- package/src/messages/ps.js +1 -1
- package/src/messages/request.js +1 -2
- package/src/messages/response.js +1 -2
- package/src/peernet.ts +333 -394
- package/src/prompts/password/browser.js +1 -1
- package/src/prompts/password/node.js +2 -2
- package/src/proto/chat-message.proto.js +1 -1
- package/src/proto/data-response.proto.js +1 -1
- package/src/types.ts +7 -9
- package/src/utils/utils.js +7 -8
- package/exports/browser/identity.d.ts +0 -18
- package/exports/types/identity.d.ts +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
export default async () => prompt('enter password')
|
|
1
|
+
export default async () => prompt('enter password')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import inquirer from 'inquirer'
|
|
2
2
|
|
|
3
3
|
export default async () => {
|
|
4
|
-
const answers = await inquirer.prompt({type: 'password', name: 'password', message: 'Enter password'})
|
|
4
|
+
const answers = await inquirer.prompt({ type: 'password', name: 'password', message: 'Enter password' })
|
|
5
5
|
return answers.password
|
|
6
|
-
}
|
|
6
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -6,14 +6,12 @@ import DHT from './dht/dht.js'
|
|
|
6
6
|
import { BufferToUint8Array, protoFor, target } from './utils/utils.js'
|
|
7
7
|
import MessageHandler from './handlers/message.js'
|
|
8
8
|
import dataHandler from './handlers/data.js'
|
|
9
|
-
import { encapsulatedError, dhtError,
|
|
10
|
-
nothingFoundError } from './errors/errors.js'
|
|
9
|
+
import { encapsulatedError, dhtError, nothingFoundError } from './errors/errors.js'
|
|
11
10
|
|
|
12
|
-
import {
|
|
11
|
+
import { Storage as LeofcoinStorageClass } from '@leofcoin/storage'
|
|
13
12
|
import { utils as codecUtils } from '@leofcoin/codecs'
|
|
14
13
|
import Identity from './identity.js'
|
|
15
14
|
|
|
16
|
-
|
|
17
15
|
declare global {
|
|
18
16
|
var debug: (message) => string
|
|
19
17
|
var globalSub: PubSub
|
|
@@ -21,8 +19,8 @@ declare global {
|
|
|
21
19
|
var peernet: Peernet
|
|
22
20
|
var LeofcoinStorage: typeof LeofcoinStorageClass
|
|
23
21
|
var LeofcoinStorageClient
|
|
24
|
-
var messageStore:
|
|
25
|
-
var dataStore:
|
|
26
|
-
var transactionStore:
|
|
27
|
-
var blockStore:
|
|
28
|
-
}
|
|
22
|
+
var messageStore: LeofcoinStorageClass
|
|
23
|
+
var dataStore: LeofcoinStorageClass
|
|
24
|
+
var transactionStore: LeofcoinStorageClass
|
|
25
|
+
var blockStore: LeofcoinStorageClass
|
|
26
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Codec } from '@leofcoin/codec-format-interface'
|
|
2
2
|
|
|
3
|
-
export const BufferToUint8Array = data => {
|
|
3
|
+
export const BufferToUint8Array = (data) => {
|
|
4
4
|
if (data.type === 'Buffer') {
|
|
5
5
|
data = new Uint8Array(data.data)
|
|
6
6
|
}
|
|
@@ -9,24 +9,23 @@ export const BufferToUint8Array = data => {
|
|
|
9
9
|
|
|
10
10
|
export const expected = (expected, actual) => {
|
|
11
11
|
const rule = (entry) => {
|
|
12
|
-
return !entry ? `: undefined - ${entry} `
|
|
12
|
+
return !entry ? `: undefined - ${entry} ` : `: ${typeof entry} - `
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const entries = Object.entries(actual)
|
|
16
|
-
.map((entry) => entry.join(rule(entry[1])));
|
|
15
|
+
const entries = Object.entries(actual).map((entry) => entry.join(rule(entry[1])))
|
|
17
16
|
|
|
18
17
|
return `\nExpected:
|
|
19
18
|
${expected.join('\n\t')}
|
|
20
19
|
|
|
21
20
|
actual:
|
|
22
|
-
${entries.join('\n\t')}
|
|
21
|
+
${entries.join('\n\t')}`
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export const protoFor = (message) => {
|
|
26
25
|
const codec = new Codec(message)
|
|
27
26
|
if (!codec.name) throw new Error('proto not found')
|
|
28
27
|
const Proto = globalThis.peernet.protos[codec.name]
|
|
29
|
-
if (!Proto) throw
|
|
28
|
+
if (!Proto) throw new Error(`No proto defined for ${codec.name}`)
|
|
30
29
|
return new Proto(message)
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -45,7 +44,7 @@ export const hasDaemon = async () => {
|
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
export const https = () => {
|
|
48
|
-
if (!globalThis.location) return false
|
|
47
|
+
if (!globalThis.location) return false
|
|
49
48
|
return Boolean(globalThis.location.protocol === 'https:')
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -74,5 +73,5 @@ export const target = async () => {
|
|
|
74
73
|
let daemon = false
|
|
75
74
|
if (!https()) daemon = await hasDaemon()
|
|
76
75
|
|
|
77
|
-
return {daemon, environment: environment()}
|
|
76
|
+
return { daemon, environment: environment() }
|
|
78
77
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default class Identity {
|
|
2
|
-
#private;
|
|
3
|
-
network: any;
|
|
4
|
-
id: string;
|
|
5
|
-
selectedAccount: string;
|
|
6
|
-
constructor(network: string);
|
|
7
|
-
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
8
|
-
getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
9
|
-
load(password?: string): Promise<void>;
|
|
10
|
-
selectAccount(account: string): Promise<void> | Promise<IDBValidKey> | Promise<any[]>;
|
|
11
|
-
sign(hash: Uint8Array): any;
|
|
12
|
-
lock(password: string): void;
|
|
13
|
-
unlock(password: string): void;
|
|
14
|
-
export(password: string): Promise<any>;
|
|
15
|
-
import(password: any, encrypted: base58String): Promise<void>;
|
|
16
|
-
exportQR(password: string): Promise<string>;
|
|
17
|
-
importQR(image: File | Blob, password: string): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default class Identity {
|
|
2
|
-
#private;
|
|
3
|
-
network: any;
|
|
4
|
-
id: string;
|
|
5
|
-
selectedAccount: string;
|
|
6
|
-
constructor(network: string);
|
|
7
|
-
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
8
|
-
getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
9
|
-
load(password?: string): Promise<void>;
|
|
10
|
-
selectAccount(account: string): Promise<void> | Promise<IDBValidKey> | Promise<any[]>;
|
|
11
|
-
sign(hash: Uint8Array): any;
|
|
12
|
-
lock(password: string): void;
|
|
13
|
-
unlock(password: string): void;
|
|
14
|
-
export(password: string): Promise<any>;
|
|
15
|
-
import(password: any, encrypted: base58String): Promise<void>;
|
|
16
|
-
exportQR(password: string): Promise<string>;
|
|
17
|
-
importQR(image: File | Blob, password: string): Promise<void>;
|
|
18
|
-
}
|