mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-04-30 20:12:14 +00:00
Swapped secio with noise (#32)
Update libp2p-related packages and switch from secio to noise
This commit is contained in:
parent
6013f623d4
commit
f732a30eb8
3321
package-lock.json
generated
3321
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -23,12 +23,14 @@
|
|||||||
"cids": "0.8.1",
|
"cids": "0.8.1",
|
||||||
"it-length-prefixed": "3.0.1",
|
"it-length-prefixed": "3.0.1",
|
||||||
"it-pipe": "1.1.0",
|
"it-pipe": "1.1.0",
|
||||||
"libp2p": "0.28.3",
|
"libp2p": "0.30.10",
|
||||||
"libp2p-mplex": "0.9.5",
|
"libp2p-crypto": "^0.19.0",
|
||||||
"libp2p-secio": "0.12.5",
|
"libp2p-mplex": "0.10.2",
|
||||||
"libp2p-websockets": "0.13.6",
|
"libp2p-noise": "2.0.5",
|
||||||
|
"libp2p-websockets": "0.15.3",
|
||||||
"loglevel": "1.7.0",
|
"loglevel": "1.7.0",
|
||||||
"peer-id": "0.13.12",
|
"multiaddr": "^8.1.2",
|
||||||
|
"peer-id": "0.14.3",
|
||||||
"uuid": "8.3.0"
|
"uuid": "8.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -44,7 +46,6 @@
|
|||||||
"babel-plugin-replace-ts-export-assignment": "0.0.2",
|
"babel-plugin-replace-ts-export-assignment": "0.0.2",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"libp2p-ts": "https://github.com/ChainSafe/libp2p-ts.git#fca072c9764436ef71f974a211bb1befae432575",
|
|
||||||
"text-encoding": "^0.7.0",
|
"text-encoding": "^0.7.0",
|
||||||
"ts-jest": "^26.5.0",
|
"ts-jest": "^26.5.0",
|
||||||
"ts-loader": "7.0.5",
|
"ts-loader": "7.0.5",
|
||||||
|
@ -73,8 +73,10 @@ describe('Builtins usage suite', () => {
|
|||||||
let bpId = 'some';
|
let bpId = 'some';
|
||||||
|
|
||||||
let bpIdReturned = await addBlueprint(client, 'test_broken_blueprint', ['test_broken_module'], bpId);
|
let bpIdReturned = await addBlueprint(client, 'test_broken_blueprint', ['test_broken_module'], bpId);
|
||||||
|
let allBps = await getBlueprints(client);
|
||||||
|
const allBpIds = allBps.map(x => x.id);
|
||||||
|
|
||||||
expect(bpIdReturned).toEqual(bpId);
|
expect(allBpIds).toContain(bpIdReturned);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create broken blueprint', async function () {
|
it('create broken blueprint', async function () {
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
import Websockets from 'libp2p-websockets';
|
import Websockets from 'libp2p-websockets';
|
||||||
import Mplex from 'libp2p-mplex';
|
import Mplex from 'libp2p-mplex';
|
||||||
import SECIO from 'libp2p-secio';
|
|
||||||
import Peer from 'libp2p';
|
import Peer from 'libp2p';
|
||||||
import { decode, encode } from 'it-length-prefixed';
|
import { decode, encode } from 'it-length-prefixed';
|
||||||
import pipe from 'it-pipe';
|
import pipe from 'it-pipe';
|
||||||
import Multiaddr from 'multiaddr';
|
|
||||||
import PeerId from 'peer-id';
|
|
||||||
import * as log from 'loglevel';
|
import * as log from 'loglevel';
|
||||||
import { parseParticle, Particle, toPayload } from './particle';
|
import { parseParticle, Particle, toPayload } from './particle';
|
||||||
|
import { NOISE } from 'libp2p-noise';
|
||||||
|
import PeerId from 'peer-id';
|
||||||
|
import Multiaddr from 'multiaddr'
|
||||||
|
|
||||||
export const PROTOCOL_NAME = '/fluence/faas/1.0.0';
|
export const PROTOCOL_NAME = '/fluence/faas/1.0.0';
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ enum Status {
|
|||||||
|
|
||||||
export class FluenceConnection {
|
export class FluenceConnection {
|
||||||
private readonly selfPeerId: PeerId;
|
private readonly selfPeerId: PeerId;
|
||||||
private node: LibP2p;
|
private node: Peer;
|
||||||
private readonly address: Multiaddr;
|
private readonly address: Multiaddr;
|
||||||
readonly nodePeerId: PeerId;
|
readonly nodePeerId: PeerId;
|
||||||
private readonly selfPeerIdStr: string;
|
private readonly selfPeerIdStr: string;
|
||||||
@ -62,8 +62,7 @@ export class FluenceConnection {
|
|||||||
modules: {
|
modules: {
|
||||||
transport: [Websockets],
|
transport: [Websockets],
|
||||||
streamMuxer: [Mplex],
|
streamMuxer: [Mplex],
|
||||||
connEncryption: [SECIO],
|
connEncryption: [NOISE],
|
||||||
peerDiscovery: [],
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -127,7 +126,7 @@ export class FluenceConnection {
|
|||||||
|
|
||||||
// create outgoing substream
|
// create outgoing substream
|
||||||
const conn = (await this.node.dialProtocol(this.address, PROTOCOL_NAME)) as {
|
const conn = (await this.node.dialProtocol(this.address, PROTOCOL_NAME)) as {
|
||||||
stream: Stream;
|
stream;
|
||||||
protocol: string;
|
protocol: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -257,9 +257,9 @@ export const createService = async (
|
|||||||
* @param {[string]} nodeId - Optional node peer id to get available blueprints from
|
* @param {[string]} nodeId - Optional node peer id to get available blueprints from
|
||||||
* @param {[string]} nodeId - Optional node peer id to deploy service to
|
* @param {[string]} nodeId - Optional node peer id to deploy service to
|
||||||
* @param {[number]} ttl - Optional ttl for the particle which does the job
|
* @param {[number]} ttl - Optional ttl for the particle which does the job
|
||||||
* @returns { Array<string> } - List of available blueprints
|
* @returns { Array<object> } - List of available blueprints
|
||||||
*/
|
*/
|
||||||
export const getBlueprints = async (client: FluenceClient, nodeId?: string, ttl?: number): Promise<string[]> => {
|
export const getBlueprints = async (client: FluenceClient, nodeId?: string, ttl?: number): Promise<[{dependencies, id: string, name: string}]> => {
|
||||||
let returnValue = 'blueprints';
|
let returnValue = 'blueprints';
|
||||||
let call = (nodeId: string) => `(call "${nodeId}" ("dist" "list_blueprints") [] ${returnValue})`;
|
let call = (nodeId: string) => `(call "${nodeId}" ("dist" "list_blueprints") [] ${returnValue})`;
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ export const getBlueprints = async (client: FluenceClient, nodeId?: string, ttl?
|
|||||||
call,
|
call,
|
||||||
returnValue,
|
returnValue,
|
||||||
new Map(),
|
new Map(),
|
||||||
(args: any[]) => args[0] as string[],
|
(args: any[]) => args[0],
|
||||||
nodeId,
|
nodeId,
|
||||||
ttl,
|
ttl,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user