@leofcoin/peernet 1.1.73 → 1.1.74
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-dc41c03f.js → browser-rHvRu5xW.js} +1 -1
- package/exports/browser/browser-store.js +2 -27
- package/exports/browser/{client-f193279c.js → client-peGn0FvK.js} +18 -14
- package/exports/browser/identity.d.ts +19 -0
- package/exports/browser/{index-81687e93.js → index-Wv-fIkmw.js} +2 -2
- package/exports/browser/{index-fd97ecae.js → index-jZbVSPhQ.js} +422 -408
- package/exports/browser/{messages-cccb78db.js → messages-y2oPb2AE.js} +2 -2
- package/exports/browser/{peernet-0298b289.js → peernet-w0f2V8kl.js} +624 -610
- package/exports/browser/peernet.js +2 -2
- package/exports/peernet.js +1 -1
- package/exports/types/identity.d.ts +19 -0
- package/package.json +11 -20
- package/src/identity.ts +1 -0
- package/.eslintrc.json +0 -24
- /package/exports/browser/{browser-2c73e2ef.js → browser-AyxSBUXj.js} +0 -0
- /package/exports/browser/{qr-scanner-worker.min-c002e984.js → qr-scanner-worker.min-RaSiJc_R.js} +0 -0
- /package/exports/browser/{value-4e80eeeb.js → value-wzPYMxsX.js} +0 -0
- /package/exports/{messages-42b2109e.js → messages-T3M-Ff1E.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as KeyPath, a as KeyValue } from './value-
|
|
1
|
+
import { K as KeyPath, a as KeyValue } from './value-wzPYMxsX.js';
|
|
2
2
|
|
|
3
3
|
const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
|
|
4
4
|
|
|
@@ -24,9 +24,7 @@ function getCursorAdvanceMethods() {
|
|
|
24
24
|
IDBCursor.prototype.continuePrimaryKey,
|
|
25
25
|
]));
|
|
26
26
|
}
|
|
27
|
-
const cursorRequestMap = new WeakMap();
|
|
28
27
|
const transactionDoneMap = new WeakMap();
|
|
29
|
-
const transactionStoreNamesMap = new WeakMap();
|
|
30
28
|
const transformCache = new WeakMap();
|
|
31
29
|
const reverseTransformCache = new WeakMap();
|
|
32
30
|
function promisifyRequest(request) {
|
|
@@ -46,16 +44,6 @@ function promisifyRequest(request) {
|
|
|
46
44
|
request.addEventListener('success', success);
|
|
47
45
|
request.addEventListener('error', error);
|
|
48
46
|
});
|
|
49
|
-
promise
|
|
50
|
-
.then((value) => {
|
|
51
|
-
// Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
|
|
52
|
-
// (see wrapFunction).
|
|
53
|
-
if (value instanceof IDBCursor) {
|
|
54
|
-
cursorRequestMap.set(value, request);
|
|
55
|
-
}
|
|
56
|
-
// Catching to avoid "Uncaught Promise exceptions"
|
|
57
|
-
})
|
|
58
|
-
.catch(() => { });
|
|
59
47
|
// This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
|
|
60
48
|
// is because we create many promises from a single IDBRequest.
|
|
61
49
|
reverseTransformCache.set(promise, request);
|
|
@@ -92,10 +80,6 @@ let idbProxyTraps = {
|
|
|
92
80
|
// Special handling for transaction.done.
|
|
93
81
|
if (prop === 'done')
|
|
94
82
|
return transactionDoneMap.get(target);
|
|
95
|
-
// Polyfill for objectStoreNames because of Edge.
|
|
96
|
-
if (prop === 'objectStoreNames') {
|
|
97
|
-
return target.objectStoreNames || transactionStoreNamesMap.get(target);
|
|
98
|
-
}
|
|
99
83
|
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
100
84
|
if (prop === 'store') {
|
|
101
85
|
return receiver.objectStoreNames[1]
|
|
@@ -124,15 +108,6 @@ function replaceTraps(callback) {
|
|
|
124
108
|
function wrapFunction(func) {
|
|
125
109
|
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
|
126
110
|
// only create one new func per func.
|
|
127
|
-
// Edge doesn't support objectStoreNames (booo), so we polyfill it here.
|
|
128
|
-
if (func === IDBDatabase.prototype.transaction &&
|
|
129
|
-
!('objectStoreNames' in IDBTransaction.prototype)) {
|
|
130
|
-
return function (storeNames, ...args) {
|
|
131
|
-
const tx = func.call(unwrap(this), storeNames, ...args);
|
|
132
|
-
transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
|
|
133
|
-
return wrap(tx);
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
111
|
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
|
137
112
|
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
|
138
113
|
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
@@ -143,7 +118,7 @@ function wrapFunction(func) {
|
|
|
143
118
|
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
144
119
|
// the original object.
|
|
145
120
|
func.apply(unwrap(this), args);
|
|
146
|
-
return wrap(
|
|
121
|
+
return wrap(this.request);
|
|
147
122
|
};
|
|
148
123
|
}
|
|
149
124
|
return function (...args) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LittlePubSub } from './peernet-
|
|
2
|
-
import './value-
|
|
1
|
+
import { L as LittlePubSub } from './peernet-w0f2V8kl.js';
|
|
2
|
+
import './value-wzPYMxsX.js';
|
|
3
3
|
|
|
4
4
|
class Api {
|
|
5
5
|
_pubsub;
|
|
@@ -206,7 +206,7 @@ class SocketRequestClient {
|
|
|
206
206
|
const init = async () => {
|
|
207
207
|
// @ts-ignore
|
|
208
208
|
if (!globalThis.WebSocket)
|
|
209
|
-
globalThis.WebSocket = (await import('./browser-
|
|
209
|
+
globalThis.WebSocket = (await import('./browser-rHvRu5xW.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
210
210
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
211
211
|
client.onmessage = this.onmessage;
|
|
212
212
|
client.onerror = this.onerror;
|
|
@@ -280,12 +280,15 @@ const iceServers = [
|
|
|
280
280
|
credential: 'openrelayproject'
|
|
281
281
|
}
|
|
282
282
|
];
|
|
283
|
-
const SimplePeer = (await import('./index-
|
|
283
|
+
const SimplePeer = (await import('./index-jZbVSPhQ.js').then(function (n) { return n.i; })).default;
|
|
284
284
|
class Peer extends SimplePeer {
|
|
285
285
|
peerId;
|
|
286
286
|
channelName;
|
|
287
287
|
version;
|
|
288
288
|
bw = { up: 0, down: 0 };
|
|
289
|
+
get connected() {
|
|
290
|
+
return super.connected;
|
|
291
|
+
}
|
|
289
292
|
constructor(options) {
|
|
290
293
|
const { from, to, initiator, trickle, config, version } = options;
|
|
291
294
|
const channelName = initiator ? `${from}:${to}` : `${to}:${from}`;
|
|
@@ -356,6 +359,7 @@ class Peer extends SimplePeer {
|
|
|
356
359
|
}
|
|
357
360
|
}
|
|
358
361
|
|
|
362
|
+
const debug = globalThis.createDebugger('@peernet/swarm/client');
|
|
359
363
|
class Client {
|
|
360
364
|
#peerId;
|
|
361
365
|
#connections = {};
|
|
@@ -404,7 +408,7 @@ class Client {
|
|
|
404
408
|
async _init() {
|
|
405
409
|
// reconnectJob()
|
|
406
410
|
if (!globalThis.RTCPeerConnection)
|
|
407
|
-
globalThis.wrtc = (await import('./browser-
|
|
411
|
+
globalThis.wrtc = (await import('./browser-AyxSBUXj.js').then(function (n) { return n.b; })).default;
|
|
408
412
|
for (const star of this.starsConfig) {
|
|
409
413
|
try {
|
|
410
414
|
const client = new SocketRequestClient(star, this.networkVersion);
|
|
@@ -421,16 +425,16 @@ class Client {
|
|
|
421
425
|
throw new Error(`No star available to connect`);
|
|
422
426
|
}
|
|
423
427
|
}
|
|
424
|
-
if (globalThis.
|
|
425
|
-
globalThis.addEventListener('beforeunload', async () => this.close());
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
+
if (globalThis.process?.versions?.node) {
|
|
428
429
|
process.on('SIGINT', async () => {
|
|
429
430
|
process.stdin.resume();
|
|
430
431
|
await this.close();
|
|
431
432
|
process.exit();
|
|
432
433
|
});
|
|
433
434
|
}
|
|
435
|
+
else {
|
|
436
|
+
globalThis.addEventListener('beforeunload', async () => this.close());
|
|
437
|
+
}
|
|
434
438
|
}
|
|
435
439
|
setupStarListeners(star) {
|
|
436
440
|
star.pubsub.subscribe('peer:joined', (id) => this.#peerJoined(id, star));
|
|
@@ -470,7 +474,7 @@ class Client {
|
|
|
470
474
|
}
|
|
471
475
|
}
|
|
472
476
|
}
|
|
473
|
-
|
|
477
|
+
debug(`star ${id} left`);
|
|
474
478
|
};
|
|
475
479
|
#peerLeft = (peer, star) => {
|
|
476
480
|
const id = peer.peerId || peer;
|
|
@@ -478,7 +482,7 @@ class Client {
|
|
|
478
482
|
this.#connections[id].destroy();
|
|
479
483
|
delete this.#connections[id];
|
|
480
484
|
}
|
|
481
|
-
|
|
485
|
+
debug(`peer ${id} left`);
|
|
482
486
|
};
|
|
483
487
|
#createRTCPeerConnection = (peerId, star, version, initiator = false) => {
|
|
484
488
|
const peer = new Peer({
|
|
@@ -502,7 +506,7 @@ class Client {
|
|
|
502
506
|
}
|
|
503
507
|
// RTCPeerConnection
|
|
504
508
|
this.#createRTCPeerConnection(peerId, star, version, true);
|
|
505
|
-
|
|
509
|
+
debug(`peer ${peerId} joined`);
|
|
506
510
|
};
|
|
507
511
|
#inComingSignal = async ({ from, signal, channelName, version }, star) => {
|
|
508
512
|
if (version !== this.version) {
|
|
@@ -538,10 +542,10 @@ class Client {
|
|
|
538
542
|
peer.destroy();
|
|
539
543
|
delete this.#connections[peer.peerId];
|
|
540
544
|
}
|
|
541
|
-
|
|
545
|
+
debug(`closed ${peer.peerId}'s connection`);
|
|
542
546
|
};
|
|
543
547
|
#peerConnect = (peer) => {
|
|
544
|
-
|
|
548
|
+
debug(`${peer.peerId} connected`);
|
|
545
549
|
globalThis.pubsub.publishVerbose(this.#connectEvent, peer.peerId);
|
|
546
550
|
};
|
|
547
551
|
#noticeMessage = (message, id, from, peer) => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { base58String } from '@vandeurenglenn/base58';
|
|
2
|
+
export default class Identity {
|
|
3
|
+
#private;
|
|
4
|
+
network: any;
|
|
5
|
+
id: string;
|
|
6
|
+
selectedAccount: string;
|
|
7
|
+
constructor(network: string);
|
|
8
|
+
get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
9
|
+
getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
|
|
10
|
+
load(password?: string): Promise<void>;
|
|
11
|
+
selectAccount(account: string): Promise<void> | Promise<IDBValidKey> | Promise<any[]>;
|
|
12
|
+
sign(hash: Uint8Array): any;
|
|
13
|
+
lock(password: string): void;
|
|
14
|
+
unlock(password: string): void;
|
|
15
|
+
export(password: string): Promise<any>;
|
|
16
|
+
import(password: any, encrypted: base58String): Promise<void>;
|
|
17
|
+
exportQR(password: string): Promise<string>;
|
|
18
|
+
importQR(image: File | Blob, password: string): Promise<void>;
|
|
19
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-
|
|
2
|
-
import './value-
|
|
1
|
+
import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-w0f2V8kl.js';
|
|
2
|
+
import './value-wzPYMxsX.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @params {String} network
|