This commit is contained in:
Pavel Murygin 2022-05-13 12:52:56 +03:00
parent 3a88fd9177
commit bf7b523660
5 changed files with 1017 additions and 3757 deletions

4721
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,31 +24,30 @@
"copy-marine": "dist/tools/copyMarine.js"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^4.1.1",
"@chainsafe/libp2p-noise": "6.1.1",
"@fluencelabs/avm": "0.24.2",
"@fluencelabs/marine-js": "0.2.5",
"async": "3.2.0",
"browser-or-node": "^2.0.0",
"bs58": "4.0.1",
"buffer": "^6.0.3",
"cids": "0.8.1",
"it-length-prefixed": "3.0.1",
"it-pipe": "1.1.0",
"libp2p": "=0.33.0",
"libp2p-crypto": "=0.20.0",
"libp2p-mplex": "=0.10.2",
"libp2p-websockets": "^0.16.2",
"cids": "1.1.9",
"it-length-prefixed": "7.0.1",
"it-pipe": "2.0.3",
"libp2p": "0.36.2",
"libp2p-crypto": "0.21.2",
"libp2p-mplex": "0.10.7",
"libp2p-websockets": "0.16.2",
"loglevel": "1.7.0",
"multiaddr": "^10.0.1",
"multiformats": "^9.6.4",
"peer-id": "=0.15.4",
"multiaddr": "10.0.1",
"multiformats": "9.6.5",
"peer-id": "0.16.0",
"platform": "^1.3.6",
"rxjs": "^7.3.0",
"ts-pattern": "^3.3.3",
"uuid": "8.3.0"
},
"devDependencies": {
"@fluencelabs/aqua": "^0.7.0-285",
"@fluencelabs/aqua-lib": "^0.4.3",
"@fluencelabs/fluence-network-environment": "^1.0.13",
"@types/jest": "^26.0.22",

View File

@ -16,19 +16,16 @@
import Websockets from 'libp2p-websockets';
import Mplex from 'libp2p-mplex';
import Lib2p2Peer, { MuxedStream } from 'libp2p';
import Lib2p2Peer from 'libp2p';
import { decode, encode } from 'it-length-prefixed';
import pipe from 'it-pipe';
import { pipe } from 'it-pipe';
import * as log from 'loglevel';
import { Particle } from './Particle';
import { NOISE } from '@chainsafe/libp2p-noise';
import PeerId from 'peer-id';
import { Multiaddr } from 'multiaddr';
import { all as allow_all } from 'libp2p-websockets/src/filters';
import { Connection } from 'libp2p-interfaces/src/topology';
import Buffer from './Buffer';
import ConnectionManager from 'libp2p/src/connection-manager';
import { single } from 'rxjs';
export const PROTOCOL_NAME = '/fluence/particle/2.0.0';
@ -39,7 +36,7 @@ export interface FluenceConnectionOptions {
/**
* Peer id of the Fluence Peer
*/
peerId: PeerId;
peerId: any;
/**
* Multiaddress of the relay to make connection to
@ -69,7 +66,7 @@ export class FluenceConnection {
modules: {
transport: [Websockets],
streamMuxer: [Mplex],
connEncryption: [NOISE],
connEncryption: [NOISE as any],
},
config: {
transport: {
@ -90,6 +87,7 @@ export class FluenceConnection {
pipe(
// force new line
stream.source,
// @ts-ignore
decode(),
async (source: AsyncIterable<string>) => {
try {
@ -177,10 +175,11 @@ export class FluenceConnection {
const { stream } = await this._connection.newStream(PROTOCOL_NAME);
const sink = stream.sink;
stream.pipe(
pipe(
// force new line
[Buffer.from(particle.toString(), 'utf8')],
encode(),
// @ts-ignore
sink,
);
@ -212,7 +211,7 @@ export class FluenceConnection {
}
}
private _outStream: MuxedStream;
// private _outStream: MuxedStream;
private _lib2p2Peer: Lib2p2Peer;
private _connection: Connection;
private _relayAddress: Multiaddr;

View File

@ -14,16 +14,16 @@
* limitations under the License.
*/
import * as PeerId from 'peer-id';
import PeerId from 'peer-id';
import { keys } from 'libp2p-crypto';
export class KeyPair {
/**
* Key pair in libp2p format. Used for backward compatibility with the current FluencePeer implementation
*/
public Libp2pPeerId: PeerId;
public Libp2pPeerId: any;
constructor(libp2pPeerId: PeerId) {
constructor(libp2pPeerId: any) {
this.Libp2pPeerId = libp2pPeerId;
}

View File

@ -1,9 +1,5 @@
{
"compilerOptions": {
"typeRoots": [
"./node_modules/@types",
"./node_modules/libp2p-ts/types",
],
"outDir": "./dist/",
"baseUrl": ".",
"downlevelIteration": true,
@ -13,7 +9,7 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"pretty": true,
"target": "ES5",
"target": "ES6",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
@ -23,6 +19,7 @@
"noImplicitAny": false,
"alwaysStrict": true,
"noImplicitThis": true,
"skipLibCheck": true,
"strictNullChecks": false
},
"exclude": [