mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-04-29 03:22:13 +00:00
Throwing human-readable error for unsupported node.js versions (#145)
fixes #143
This commit is contained in:
parent
88fcc749a1
commit
41984b8912
29
package-lock.json
generated
29
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@fluencelabs/fluence",
|
"name": "@fluencelabs/fluence",
|
||||||
"version": "0.0.1-fix-sig.0",
|
"version": "0.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@fluencelabs/fluence",
|
"name": "@fluencelabs/fluence",
|
||||||
"version": "0.0.1-fix-sig.0",
|
"version": "0.0.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/libp2p-noise": "^4.1.1",
|
"@chainsafe/libp2p-noise": "^4.1.1",
|
||||||
@ -15,7 +15,6 @@
|
|||||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||||
"@fluencelabs/marine-js": "0.1.0",
|
"@fluencelabs/marine-js": "0.1.0",
|
||||||
"async": "3.2.0",
|
"async": "3.2.0",
|
||||||
"browser-or-node": "^2.0.0",
|
|
||||||
"bs58": "4.0.1",
|
"bs58": "4.0.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"cids": "0.8.1",
|
"cids": "0.8.1",
|
||||||
@ -29,6 +28,7 @@
|
|||||||
"multiaddr": "^10.0.1",
|
"multiaddr": "^10.0.1",
|
||||||
"multiformats": "^9.6.4",
|
"multiformats": "^9.6.4",
|
||||||
"peer-id": "=0.15.4",
|
"peer-id": "=0.15.4",
|
||||||
|
"platform": "^1.3.6",
|
||||||
"rxjs": "^7.3.0",
|
"rxjs": "^7.3.0",
|
||||||
"ts-pattern": "^3.3.3",
|
"ts-pattern": "^3.3.3",
|
||||||
"uuid": "8.3.0"
|
"uuid": "8.3.0"
|
||||||
@ -40,6 +40,7 @@
|
|||||||
"@fluencelabs/aqua": "^0.7.0-285",
|
"@fluencelabs/aqua": "^0.7.0-285",
|
||||||
"@fluencelabs/aqua-lib": "^0.4.3",
|
"@fluencelabs/aqua-lib": "^0.4.3",
|
||||||
"@types/jest": "^26.0.22",
|
"@types/jest": "^26.0.22",
|
||||||
|
"@types/platform": "^1.3.4",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"js-base64": "^3.7.2",
|
"js-base64": "^3.7.2",
|
||||||
"ts-jest": "^26.5.4",
|
"ts-jest": "^26.5.4",
|
||||||
@ -1398,6 +1399,12 @@
|
|||||||
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==",
|
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/platform": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/platform/-/platform-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-U0o4K+GNiK0PNxoDwd8xRnvLVe4kzei6opn3/FCjAriqaP+rfrDdSl1kP/hLL6Y3/Y3hhGnBwD4dCkkAqs1W/Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/prettier": {
|
"node_modules/@types/prettier": {
|
||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.2.tgz",
|
||||||
@ -7594,6 +7601,11 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/platform": {
|
||||||
|
"version": "1.3.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
||||||
|
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
||||||
|
},
|
||||||
"node_modules/posix-character-classes": {
|
"node_modules/posix-character-classes": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
|
||||||
@ -10848,6 +10860,12 @@
|
|||||||
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==",
|
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/platform": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/platform/-/platform-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-U0o4K+GNiK0PNxoDwd8xRnvLVe4kzei6opn3/FCjAriqaP+rfrDdSl1kP/hLL6Y3/Y3hhGnBwD4dCkkAqs1W/Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/prettier": {
|
"@types/prettier": {
|
||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.2.tgz",
|
||||||
@ -15868,6 +15886,11 @@
|
|||||||
"find-up": "^4.0.0"
|
"find-up": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"platform": {
|
||||||
|
"version": "1.3.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
||||||
|
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
||||||
|
},
|
||||||
"posix-character-classes": {
|
"posix-character-classes": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
"@fluencelabs/avm-runner-interface": "^0.2.0",
|
||||||
"@fluencelabs/marine-js": "0.1.0",
|
"@fluencelabs/marine-js": "0.1.0",
|
||||||
"async": "3.2.0",
|
"async": "3.2.0",
|
||||||
"browser-or-node": "^2.0.0",
|
|
||||||
"bs58": "4.0.1",
|
"bs58": "4.0.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"cids": "0.8.1",
|
"cids": "0.8.1",
|
||||||
@ -42,6 +41,7 @@
|
|||||||
"multiaddr": "^10.0.1",
|
"multiaddr": "^10.0.1",
|
||||||
"multiformats": "^9.6.4",
|
"multiformats": "^9.6.4",
|
||||||
"peer-id": "=0.15.4",
|
"peer-id": "=0.15.4",
|
||||||
|
"platform": "^1.3.6",
|
||||||
"rxjs": "^7.3.0",
|
"rxjs": "^7.3.0",
|
||||||
"ts-pattern": "^3.3.3",
|
"ts-pattern": "^3.3.3",
|
||||||
"uuid": "8.3.0"
|
"uuid": "8.3.0"
|
||||||
@ -50,6 +50,7 @@
|
|||||||
"@fluencelabs/aqua": "^0.7.0-285",
|
"@fluencelabs/aqua": "^0.7.0-285",
|
||||||
"@fluencelabs/aqua-lib": "^0.4.3",
|
"@fluencelabs/aqua-lib": "^0.4.3",
|
||||||
"@types/jest": "^26.0.22",
|
"@types/jest": "^26.0.22",
|
||||||
|
"@types/platform": "^1.3.4",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"js-base64": "^3.7.2",
|
"js-base64": "^3.7.2",
|
||||||
"ts-jest": "^26.5.4",
|
"ts-jest": "^26.5.4",
|
||||||
|
@ -20,7 +20,7 @@ import { PeerIdB58 } from './commonTypes';
|
|||||||
import { FluenceConnection } from './FluenceConnection';
|
import { FluenceConnection } from './FluenceConnection';
|
||||||
import { Particle, ParticleExecutionStage, ParticleQueueItem } from './Particle';
|
import { Particle, ParticleExecutionStage, ParticleQueueItem } from './Particle';
|
||||||
import { KeyPair } from './KeyPair';
|
import { KeyPair } from './KeyPair';
|
||||||
import { dataToString, jsonify } from './utils';
|
import { throwIfNotSupported, dataToString, jsonify } from './utils';
|
||||||
import { concatMap, filter, pipe, Subject, tap } from 'rxjs';
|
import { concatMap, filter, pipe, Subject, tap } from 'rxjs';
|
||||||
import log from 'loglevel';
|
import log from 'loglevel';
|
||||||
import { builtInServices } from './builtins/common';
|
import { builtInServices } from './builtins/common';
|
||||||
@ -171,6 +171,8 @@ export class FluencePeer {
|
|||||||
* @param config - object specifying peer configuration
|
* @param config - object specifying peer configuration
|
||||||
*/
|
*/
|
||||||
async start(config?: PeerConfig): Promise<void> {
|
async start(config?: PeerConfig): Promise<void> {
|
||||||
|
throwIfNotSupported();
|
||||||
|
|
||||||
if (config?.KeyPair) {
|
if (config?.KeyPair) {
|
||||||
this._keyPair = config!.KeyPair;
|
this._keyPair = config!.KeyPair;
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@ import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes
|
|||||||
import { FluencePeer } from './FluencePeer';
|
import { FluencePeer } from './FluencePeer';
|
||||||
import { Particle, ParticleExecutionStage } from './Particle';
|
import { Particle, ParticleExecutionStage } from './Particle';
|
||||||
import Buffer from './Buffer';
|
import Buffer from './Buffer';
|
||||||
|
import platform from 'platform';
|
||||||
|
|
||||||
export const MakeServiceCall = (fn: (args: any[]) => CallServiceResultType) => {
|
export const MakeServiceCall = (fn: (args: any[]) => CallServiceResultType) => {
|
||||||
return (req: CallServiceData): CallServiceResult => {
|
return (req: CallServiceData): CallServiceResult => {
|
||||||
@ -144,3 +145,13 @@ export function dataToString(data: Uint8Array) {
|
|||||||
export function jsonify(obj) {
|
export function jsonify(obj) {
|
||||||
return JSON.stringify(obj, null, 4);
|
return JSON.stringify(obj, null, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function throwIfNotSupported() {
|
||||||
|
if (platform.name === 'Node.js') {
|
||||||
|
const version = platform.version.split('.').map(Number);
|
||||||
|
const major = version[0];
|
||||||
|
if (major < 16) {
|
||||||
|
throw new Error('FluenceJS requires node.js version >= "16.x"; Detected ' + platform.description + ' Please update node.js to version 16 or higher.\nYou can use https://nvm.sh utility to update node.js version: "nvm install 17 && nvm use 17 && nvm alias default 17"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user