@leofcoin/peernet 1.2.27 → 1.2.28
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-D-r0O9Qn.js → browser-CWeoyGUw.js} +1 -1
- package/exports/browser/{browser-_hiyXwPp.js → browser-DvU1xNFS.js} +1 -1
- package/exports/browser/{client-BVhUamQG.js → client-B-jyclOB.js} +4 -4
- package/exports/browser/{identity-ChyyZSve.js → identity-CYVPDmkf.js} +7 -2
- package/exports/browser/identity.js +1 -1
- package/exports/browser/{index-BD0Anx7_.js → index-Bxr5Iztg.js} +1 -1
- package/exports/browser/{messages-UKnuelZ7.js → messages-FMRAS8QX.js} +2 -2
- package/exports/browser/{peernet-r_9IyzTe.js → peernet-CRbrmeU3.js} +3 -3
- package/exports/browser/peernet.js +2 -2
- package/exports/identity.js +6 -1
- package/package.json +1 -1
- package/src/identity.ts +6 -1
- package/test/fresh-empty-store.js +15 -0
- package/test/peernet.test.js +19 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-
|
|
2
|
-
import './identity-
|
|
1
|
+
import { L as LittlePubSub, d as deflate_1, i as inflate_1, c as createDebugger } from './peernet-CRbrmeU3.js';
|
|
2
|
+
import './identity-CYVPDmkf.js';
|
|
3
3
|
import 'crypto';
|
|
4
4
|
import './value-C3vAp-wb.js';
|
|
5
5
|
|
|
@@ -232,7 +232,7 @@ class SocketRequestClient {
|
|
|
232
232
|
const init = async () => {
|
|
233
233
|
// @ts-ignore
|
|
234
234
|
if (!globalThis.WebSocket && !this.#experimentalWebsocket)
|
|
235
|
-
globalThis.WebSocket = (await import('./browser-
|
|
235
|
+
globalThis.WebSocket = (await import('./browser-DvU1xNFS.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
236
236
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
237
237
|
if (this.#experimentalWebsocket) {
|
|
238
238
|
client.addEventListener('error', this.onerror);
|
|
@@ -1324,7 +1324,7 @@ class Client {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
}
|
|
1326
1326
|
async #loadNodeWebrtcImplementation() {
|
|
1327
|
-
const koushWrtcModule = await import('./browser-
|
|
1327
|
+
const koushWrtcModule = await import('./browser-CWeoyGUw.js').then(function (n) { return n.b; });
|
|
1328
1328
|
const koushWrtc = koushWrtcModule.default;
|
|
1329
1329
|
if (!isWrtcImplementation(koushWrtc)) {
|
|
1330
1330
|
throw new Error('@koush/wrtc does not match required wrtc contract');
|
|
@@ -8323,7 +8323,12 @@ class Identity {
|
|
|
8323
8323
|
const importee = await import('./prompts/password.js');
|
|
8324
8324
|
password = await importee.default();
|
|
8325
8325
|
}
|
|
8326
|
-
|
|
8326
|
+
// LevelDB opens lazily. Touch both stores before freshIdentity clears them;
|
|
8327
|
+
// clearing a brand-new, unopened store throws LEVEL_DATABASE_NOT_OPEN.
|
|
8328
|
+
const [accountExists] = await Promise.all([
|
|
8329
|
+
globalThis.accountStore.has('public'),
|
|
8330
|
+
globalThis.walletStore.has('identity')
|
|
8331
|
+
]);
|
|
8327
8332
|
if (accountExists && !fresh) {
|
|
8328
8333
|
const pub = await globalThis.accountStore.get('public');
|
|
8329
8334
|
this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
|
|
@@ -8331,7 +8336,7 @@ class Identity {
|
|
|
8331
8336
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
8332
8337
|
}
|
|
8333
8338
|
else {
|
|
8334
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
8339
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-Bxr5Iztg.js');
|
|
8335
8340
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
8336
8341
|
if (fresh) {
|
|
8337
8342
|
await globalThis.accountStore.clear();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { I as default, r as resolveAccountWallets } from './identity-
|
|
1
|
+
export { I as default, r as resolveAccountWallets } from './identity-CYVPDmkf.js';
|
|
2
2
|
import 'crypto';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as index$2, b as base, a as base58$1, c as index$3, d as index$4, e as index$5, f as createSHA512, g as createSHA384, h as createSHA256, j as createSHA224, k as createSHA1, I as Identity } from './identity-
|
|
1
|
+
import { i as index$2, b as base, a as base58$1, c as index$3, d as index$4, e as index$5, f as createSHA512, g as createSHA384, h as createSHA256, j as createSHA224, k as createSHA1, I as Identity } from './identity-CYVPDmkf.js';
|
|
2
2
|
import { K as KeyPath, a as KeyValue } from './value-C3vAp-wb.js';
|
|
3
3
|
|
|
4
4
|
const getTargets = () => Array.from([]);
|
|
@@ -8615,7 +8615,7 @@ class Peernet {
|
|
|
8615
8615
|
await getAddress();
|
|
8616
8616
|
this.storePrefix = options.storePrefix;
|
|
8617
8617
|
this.root = options.root;
|
|
8618
|
-
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-
|
|
8618
|
+
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-FMRAS8QX.js');
|
|
8619
8619
|
/**
|
|
8620
8620
|
* proto Object containing protos
|
|
8621
8621
|
* @type {Object}
|
|
@@ -8662,7 +8662,7 @@ class Peernet {
|
|
|
8662
8662
|
if (this.#starting || this.#started)
|
|
8663
8663
|
return;
|
|
8664
8664
|
this.#starting = true;
|
|
8665
|
-
const importee = await import('./client-
|
|
8665
|
+
const importee = await import('./client-B-jyclOB.js');
|
|
8666
8666
|
/**
|
|
8667
8667
|
* @access public
|
|
8668
8668
|
* @type {PeernetClient}
|
package/exports/identity.js
CHANGED
|
@@ -68,7 +68,12 @@ class Identity {
|
|
|
68
68
|
const importee = await import('./prompts/password.js');
|
|
69
69
|
password = await importee.default();
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
// LevelDB opens lazily. Touch both stores before freshIdentity clears them;
|
|
72
|
+
// clearing a brand-new, unopened store throws LEVEL_DATABASE_NOT_OPEN.
|
|
73
|
+
const [accountExists] = await Promise.all([
|
|
74
|
+
globalThis.accountStore.has('public'),
|
|
75
|
+
globalThis.walletStore.has('identity')
|
|
76
|
+
]);
|
|
72
77
|
if (accountExists && !fresh) {
|
|
73
78
|
const pub = await globalThis.accountStore.get('public');
|
|
74
79
|
this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
|
package/package.json
CHANGED
package/src/identity.ts
CHANGED
|
@@ -87,7 +87,12 @@ export default class Identity {
|
|
|
87
87
|
password = await importee.default()
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
// LevelDB opens lazily. Touch both stores before freshIdentity clears them;
|
|
91
|
+
// clearing a brand-new, unopened store throws LEVEL_DATABASE_NOT_OPEN.
|
|
92
|
+
const [accountExists] = await Promise.all([
|
|
93
|
+
globalThis.accountStore.has('public'),
|
|
94
|
+
globalThis.walletStore.has('identity')
|
|
95
|
+
])
|
|
91
96
|
if (accountExists && !fresh) {
|
|
92
97
|
const pub = await globalThis.accountStore.get('public')
|
|
93
98
|
this.id = JSON.parse(new TextDecoder().decode(pub)).walletId
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Peernet from '../exports/peernet.js'
|
|
2
|
+
|
|
3
|
+
const peernet = await new Peernet(
|
|
4
|
+
{
|
|
5
|
+
network: 'leofcoin:peach',
|
|
6
|
+
stars: [],
|
|
7
|
+
root: process.argv[2],
|
|
8
|
+
autoStart: false,
|
|
9
|
+
freshIdentity: true
|
|
10
|
+
},
|
|
11
|
+
'fresh-empty-store-test'
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
if (!peernet.id || !peernet.selectedAccount) throw new Error('fresh identity was not initialized')
|
|
15
|
+
console.log('FRESH_IDENTITY_READY')
|
package/test/peernet.test.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import test from 'node:test'
|
|
2
2
|
import assert from 'node:assert/strict'
|
|
3
3
|
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { execFile } from 'node:child_process'
|
|
5
|
+
import { mkdtemp, rm } from 'node:fs/promises'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
import { promisify } from 'node:util'
|
|
4
9
|
|
|
5
10
|
import Peernet from '../exports/peernet.js'
|
|
6
11
|
import Identity, { resolveAccountWallets } from '../exports/identity.js'
|
|
@@ -18,6 +23,20 @@ const options = {
|
|
|
18
23
|
|
|
19
24
|
const password = 'password'
|
|
20
25
|
const peernet = await new Peernet(options, password)
|
|
26
|
+
const execFileAsync = promisify(execFile)
|
|
27
|
+
|
|
28
|
+
test('freshIdentity initializes against a completely empty store root', async () => {
|
|
29
|
+
const root = await mkdtemp(join(tmpdir(), 'peernet-fresh-identity-'))
|
|
30
|
+
try {
|
|
31
|
+
const { stdout } = await execFileAsync(process.execPath, ['test/fresh-empty-store.js', root], {
|
|
32
|
+
cwd: new URL('..', import.meta.url),
|
|
33
|
+
timeout: 20_000
|
|
34
|
+
})
|
|
35
|
+
assert.match(stdout, /FRESH_IDENTITY_READY/)
|
|
36
|
+
} finally {
|
|
37
|
+
await rm(root, { recursive: true, force: true })
|
|
38
|
+
}
|
|
39
|
+
})
|
|
21
40
|
|
|
22
41
|
test('node bundle uses a portable password prompt import', async () => {
|
|
23
42
|
const identityBundle = await readFile(new URL('../exports/identity.js', import.meta.url), 'utf8')
|