Migrate to monorepo and pnpm (#163)

DXJ-85
This commit is contained in:
Pavel 2022-08-24 18:03:06 +03:00 committed by GitHub
parent bcfd5ff634
commit 16fdbce17d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 5341 additions and 19263 deletions

View File

@ -1,23 +0,0 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module', // Allows for the use of imports
},
env: {
browser: true,
es2021: true,
},
extends: [
'airbnb-base',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
// Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:prettier/recommended',
],
plugins: ['@typescript-eslint', 'prettier'],
rules: {},
settings: {
'import/extensions': ['.js', '.ts'],
},
};

View File

@ -1,11 +1,10 @@
name: "publish-branch"
name: "Publish development branch packages"
on:
workflow_dispatch:
push:
jobs:
npm-publish:
name: "Publish"
publish-branch:
runs-on: ubuntu-latest
permissions:
@ -14,6 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: "Setup node with self-hosted npm registry"
uses: actions/setup-node@v2
@ -21,8 +24,10 @@ jobs:
node-version: "16"
registry-url: "https://npm.fluence.dev"
- run: npm ci
- run: npm run build
- name: "Build packages"
run: |
pnpm i
pnpm -r build
- name: "Import secrets"
uses: hashicorp/vault-action@v2.4.2
@ -53,8 +58,12 @@ jobs:
RUN: ${{ github.run_number }}
ATTEMPT: ${{ github.run_attempt }}
run: |
npm version prerelease --no-git-tag-version \
--preid ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }}
for package in packages/*; do
cd $package
pnpm version prepatch --no-git-tag-version \
--preid ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }}
cd -
done
- name: "Publish to self-hosted npm repo"
run: npm publish --tag snapshot --registry https://npm.fluence.dev
run: pnpm --no-git-checks --registry https://npm.fluence.dev -r publish --tag snapshot -filter '@fluencelabs/*'

View File

@ -1,4 +1,4 @@
name: "release"
name: "Make github release"
on:
push:
@ -6,8 +6,7 @@ on:
- "v*"
jobs:
npm-publish:
name: "Publish"
release-github:
runs-on: ubuntu-latest
defaults:
run:
@ -20,23 +19,6 @@ jobs:
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
### Set version
- name: Set version to ${{ env.RELEASE_VERSION }}
run: npm version --new-version --allow-same-version ${{ env.RELEASE_VERSION }} --no-git-tag-version
### Publish to NPM registry
- uses: actions/setup-node@v1
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- run: npm i
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
### Create a release
- name: Build Changelog
id: changelog
@ -56,4 +38,4 @@ jobs:
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

50
.github/workflows/release_packages.yml vendored Normal file
View File

@ -0,0 +1,50 @@
name: "Release packages"
on:
workflow_dispatch:
jobs:
release-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: "Setup node"
uses: actions/setup-node@v2
with:
node-version: "16"
- name: "Build packages"
run: |
pnpm i
pnpm -r build
- name: "Publish to npmjs.com"
run: |
result=$(pnpm --no-git-checks -r publish -filter '@fluencelabs/*')
if [[ $result == "There are no new packages that should be published" ]]
then
echo ERROR: no packages have been published. Did you forget to bump version?
exit 1
fi
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "Get the version of fluence-js package"
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: packages/fluence-js
- name: "Create tag for release"
uses: rickstaa/action-create-tag@v1
with:
tag: "v${{ steps.package-version.outputs.current-version }}"
message: ""
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -18,24 +18,27 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: pnpm/action-setup@v2.2.2
with:
path: ~/.npm
key: ${{ runner.os }}-v1-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-v1-node-${{ matrix.node-version }}
version: 7
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Run container with Fluence node
run: |
docker pull fluencelabs/fluence
docker run -d --rm -e RUST_LOG="info" -p 1210:1210 -p 4310:4310 fluencelabs/fluence -t 1210 -w 4310 -k gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj --local --aqua-pool-size 2
- run: npm install
- run: npm run test:all
- name: Install deps
run: pnpm i
- name: Run tests
run: |
pnpm -r build
pnpm -r test
env:
CI: true

View File

@ -1,18 +0,0 @@
name: "tag"
on:
workflow_dispatch:
jobs:
tag:
name: "Tag"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.5
with:
github_token: ${{ secrets.PERSONAL_TOKEN }}

14
.gitignore vendored
View File

@ -1,18 +1,6 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
bundle/
.idea
# Dependency directories
node_modules/
jspm_packages/
/dist/
.idea

1
.npmrc Normal file
View File

@ -0,0 +1 @@
auto-install-peers=true

View File

@ -14,12 +14,29 @@ While the project is still in the early stages of development, you are welcome t
### Setting up dev environment
Install node packages
Fluence JS uses pnpm to manage monorepo packages. See [pnpm.io](https://pnpm.io/installation) for installation instructions.
Install dependencies
```bash
npm install
pnpm install
```
Build all packages
```
pnpm -r build
```
### Repository structure
| Folder | Package | Description |
| --------------------------- | ----------------------- | --------------------------------------------- |
| packages/fluence-js | @fluencelabs/fluence-js | TypeScript implementation of the Fluence Peer |
| packages/fluence-interfaces | @fluencelabs/interfaces | Common interfaces used in Fluence Peer |
| packages/fluence-connection | @fluencelabs/connection | Connectivity layer used in Fluence Peer |
| packages/fluence-keypair | @fluencelabs/keypair | Key Pair implementation |
### Running tests
Tests are split into unit and integration categories. By default integration tests require a locally running Fluence node with 4310 port open for ws connections. The dependency can be started with docker
@ -28,28 +45,22 @@ Tests are split into unit and integration categories. By default integration tes
docker run --rm -e RUST_LOG="info" -p 1210:1210 -p 4310:4310 fluencelabs/fluence -t 1210 -w 4310 -k gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj
```
To run all tests in interactive mode
To run all tests
```bash
npm run test
pnpm -r test
```
To run only unit tests
```bash
npm run test:unit
pnpm -r test:unit
```
To run only integration tests
```bash
npm run test:unit
```
To run all tests
```bash
npm run test:all
pnpm -r test:integration
```
## License

19118
package-lock.json generated

File diff suppressed because it is too large Load Diff

21
packages/@test_smoke/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
bundle/
dist
esm
types
# Dependency directories
node_modules/
jspm_packages/
.idea

View File

@ -0,0 +1,26 @@
{
"name": "@test/smoke",
"version": "0.1.0",
"description": "Smoke test",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"engines": {
"node": ">=10",
"pnpm": ">=3"
},
"scripts": {
"build": "tsc",
"test": "ts-node src/index.ts"
},
"repository": "https://github.com/fluencelabs/fluence-js",
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/fluence": "workspace:*",
"ts-node": "^10.9.1"
},
"devDependencies": {
"@types/node": "^18.7.13",
"typescript": "^4.6.4"
}
}

View File

@ -0,0 +1,22 @@
import { FluencePeer } from "@fluencelabs/fluence";
const peer = new FluencePeer();
const main = async () => {
await peer.start({});
const peerId = peer.getStatus().peerId;
if (!peerId) {
throw new Error("Peer id is null");
}
console.log("peer id is: ", peerId);
await peer.stop();
};
main()
.then(() => console.log("done"))
.catch((err) => console.error(err))
.finally(() => {
if (peer) {
peer.stop();
}
});

View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"outDir": "./dist/",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"declaration": true,
"skipDefaultLibCheck": true
},
"exclude": ["node_modules", "dist"],
"include": ["src/**/*"]
}

21
packages/fluence-connection/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
bundle/
dist
esm
types
# Dependency directories
node_modules/
jspm_packages/
.idea

View File

@ -0,0 +1,13 @@
## Contribute Code
You are welcome to contribute to Fluence.
Things you need to know:
1. You need to **agree to the Contributors License Agreement**. This is a common practice in all major Open Source projects. At the current moment we are unable to accept contributions made on behalf of a company. Only individual contributions will be accepted.
2. **Not all proposed contributions can be accepted**. Some features may e.g. just fit a third-party add-on better. The contribution must fit the overall direction of Fluence and really improve it. The more effort you invest, the better you should clarify in advance whether the contribution fits: the best way would be to just open an issue to discuss the contribution you plan to make.
### Contributor License Agreement
When you contribute, you have to be aware that your contribution is covered by **Apache License 2.0**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**.
In particular you need to agree to the [Contributor License Agreement](https://gist.github.com/fluencelabs-org/3f4cbb3cc14c1c0fb9ad99d8f7316ed7). If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.

View File

@ -0,0 +1,11 @@
# FluenceJS connection
This package is a part of FluenceJS, the official implementation of the Fluence Peer in typescript. See the [FluenceJS repo](https://github.com/fluencelabs/fluence-js) for more info
## Contributing
While the project is still in the early stages of development, you are welcome to track progress and contribute. As the project is undergoing rapid changes, interested contributors should contact the team before embarking on larger pieces of work. All contributors should consult with and agree to our [basic contributing rules](CONTRIBUTING.md).
## License
[Apache 2.0](LICENSE)

View File

@ -0,0 +1,33 @@
{
"name": "@fluencelabs/connection",
"version": "0.1.0",
"description": "Fluence connection",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"engines": {
"node": ">=10",
"pnpm": ">=3"
},
"scripts": {
"build": "tsc"
},
"repository": "https://github.com/fluencelabs/fluence-js",
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/interfaces": "workspace:0.1.0",
"peer-id": "0.16.0",
"it-length-prefixed": "5.0.3",
"it-pipe": "1.1.0",
"@chainsafe/libp2p-noise": "^4.1.1",
"libp2p": "0.36.2",
"libp2p-interfaces": "^4.0.6",
"libp2p-mplex": "0.10.7",
"libp2p-websockets": "0.16.2",
"loglevel": "1.8.0",
"multiaddr": "10.0.1"
},
"devDependencies": {
"typescript": "^4.6.4"
}
}

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FluenceConnection, ParticleHandler, PeerIdB58 } from '@fluencelabs/interfaces';
// @ts-ignore
import Websockets from 'libp2p-websockets';
// @ts-ignore
@ -28,8 +29,6 @@ import { Multiaddr } from 'multiaddr';
// @ts-ignore
import { all as allow_all } from 'libp2p-websockets/src/filters';
import { Connection } from 'libp2p-interfaces/src/topology';
import Buffer from './Buffer';
import { PeerIdB58 } from './commonTypes';
export const PROTOCOL_NAME = '/fluence/particle/2.0.0';
@ -53,18 +52,6 @@ export interface FluenceConnectionOptions {
dialTimeoutMs?: number;
}
export type ParticleHandler = (particle: string) => void;
/**
* Base class for connectivity layer to Fluence Network
*/
export abstract class FluenceConnection {
abstract readonly relayPeerId: PeerIdB58 | null;
abstract connect(onIncomingParticle: ParticleHandler): Promise<void>;
abstract disconnect(): Promise<void>;
abstract sendParticle(nextPeerIds: PeerIdB58[], particle: string): Promise<void>;
}
/**
* Implementation for JS peers which connects to Fluence through relay node
*/

View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"outDir": "./dist/",
"lib": ["ES2015"],
"target": "ES5",
"module": "commonjs",
"skipLibCheck": true,
"sourceMap": true,
"declaration": true,
"esModuleInterop": true,
},
"exclude": ["node_modules", "dist"],
"include": ["src/**/*"]
}

21
packages/fluence-interfaces/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
bundle/
dist
esm
types
# Dependency directories
node_modules/
jspm_packages/
.idea

View File

@ -0,0 +1,12 @@
.idea
.gitignore
node_modules
types
src/
tsconfig.json
webpack.config.js
bundle
pkg

View File

@ -0,0 +1,8 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
printWidth: 120,
tabWidth: 4,
useTabs: false
};

View File

@ -0,0 +1,13 @@
## Contribute Code
You are welcome to contribute to Fluence.
Things you need to know:
1. You need to **agree to the Contributors License Agreement**. This is a common practice in all major Open Source projects. At the current moment we are unable to accept contributions made on behalf of a company. Only individual contributions will be accepted.
2. **Not all proposed contributions can be accepted**. Some features may e.g. just fit a third-party add-on better. The contribution must fit the overall direction of Fluence and really improve it. The more effort you invest, the better you should clarify in advance whether the contribution fits: the best way would be to just open an issue to discuss the contribution you plan to make.
### Contributor License Agreement
When you contribute, you have to be aware that your contribution is covered by **Apache License 2.0**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**.
In particular you need to agree to the [Contributor License Agreement](https://gist.github.com/fluencelabs-org/3f4cbb3cc14c1c0fb9ad99d8f7316ed7). If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.

View File

@ -0,0 +1,11 @@
# FluenceJS interfaces
This package is a part of FluenceJS, the official implementation of the Fluence Peer in typescript. See the [FluenceJS repo](https://github.com/fluencelabs/fluence-js) for more info
## Contributing
While the project is still in the early stages of development, you are welcome to track progress and contribute. As the project is undergoing rapid changes, interested contributors should contact the team before embarking on larger pieces of work. All contributors should consult with and agree to our [basic contributing rules](CONTRIBUTING.md).
## License
[Apache 2.0](LICENSE)

View File

@ -0,0 +1,21 @@
{
"name": "@fluencelabs/interfaces",
"version": "0.1.0",
"description": "Fluence interfaces",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"engines": {
"node": ">=10",
"pnpm": ">=3"
},
"scripts": {
"build": "tsc"
},
"repository": "https://github.com/fluencelabs/fluence-js",
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {},
"devDependencies": {
"typescript": "^4.6.4"
}
}

View File

@ -0,0 +1,29 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type PeerIdB58 = string;
export type ParticleHandler = (particle: string) => void;
/**
* Base class for connectivity layer to Fluence Network
*/
export abstract class FluenceConnection {
abstract readonly relayPeerId: PeerIdB58 | null;
abstract connect(onIncomingParticle: ParticleHandler): Promise<void>;
abstract disconnect(): Promise<void>;
abstract sendParticle(nextPeerIds: PeerIdB58[], particle: string): Promise<void>;
}

View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"outDir": "./dist/",
"lib": ["ES2015"],
"target": "ES5",
"module": "commonjs",
"skipLibCheck": true,
"sourceMap": true,
"declaration": true,
"esModuleInterop": true,
},
"exclude": ["node_modules", "dist"],
"include": ["src/**/*"]
}

21
packages/fluence-js/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
bundle/
dist
esm
types
# Dependency directories
node_modules/
jspm_packages/
.idea

View File

@ -0,0 +1,12 @@
.idea
.gitignore
node_modules
types
src/
tsconfig.json
webpack.config.js
bundle
pkg

View File

@ -0,0 +1 @@
/dist/

View File

@ -0,0 +1,8 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
printWidth: 120,
tabWidth: 4,
useTabs: false
};

View File

@ -0,0 +1,13 @@
## Contribute Code
You are welcome to contribute to Fluence.
Things you need to know:
1. You need to **agree to the Contributors License Agreement**. This is a common practice in all major Open Source projects. At the current moment we are unable to accept contributions made on behalf of a company. Only individual contributions will be accepted.
2. **Not all proposed contributions can be accepted**. Some features may e.g. just fit a third-party add-on better. The contribution must fit the overall direction of Fluence and really improve it. The more effort you invest, the better you should clarify in advance whether the contribution fits: the best way would be to just open an issue to discuss the contribution you plan to make.
### Contributor License Agreement
When you contribute, you have to be aware that your contribution is covered by **Apache License 2.0**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**.
In particular you need to agree to the [Contributor License Agreement](https://gist.github.com/fluencelabs-org/3f4cbb3cc14c1c0fb9ad99d8f7316ed7). If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.

View File

@ -0,0 +1,17 @@
# Fluence JS
[![npm](https://img.shields.io/npm/v/@fluencelabs/fluence)](https://www.npmjs.com/package/@fluencelabs/fluence)
Official TypeScript implementation of the Fluence Peer.
## Getting started
To start developing applications with Fluence JS refer to the official [documentation](https://doc.fluence.dev/docs/js-sdk)
## Contributing
While the project is still in the early stages of development, you are welcome to track progress and contribute. As the project is undergoing rapid changes, interested contributors should contact the team before embarking on larger pieces of work. All contributors should consult with and agree to our [basic contributing rules](CONTRIBUTING.md).
## License
[Apache 2.0](LICENSE)

View File

@ -1,15 +1,18 @@
{
"name": "@fluencelabs/fluence",
"version": "0.0.0",
"version": "0.23.5",
"description": "TypeScript implementation of Fluence Peer",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"engines": {
"node": ">=10",
"pnpm": ">=3"
},
"scripts": {
"compile-aqua": "npm run compile-aqua:src && npm run compile-aqua:test",
"compile-aqua:src": "aqua -i ./aqua/src/ -o ./src/internal/_aqua",
"compile-aqua:test": "aqua -i ./aqua/tests/ -o ./src/__test__/_aqua",
"test": "jest --watch",
"test:all": "jest",
"test": "jest",
"test:unit": "jest --testPathPattern=src/__test__/unit",
"test:integration": "jest --testPathPattern=src/__test__/integration",
"build": "tsc",
@ -22,28 +25,23 @@
"copy-marine": "dist/tools/copyMarine.js"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^4.1.1",
"@fluencelabs/avm": "0.25.0",
"@fluencelabs/marine-js": "0.3.5",
"@fluencelabs/connection": "workspace:0.1.0",
"@fluencelabs/keypair": "workspace:0.1.0",
"@fluencelabs/interfaces": "workspace:0.1.0",
"async": "3.2.3",
"multiformats": "9.6.5",
"base64-js": "^1.5.1",
"browser-or-node": "^2.0.0",
"bs58": "5.0.0",
"buffer": "^6.0.3",
"cids": "1.1.9",
"it-length-prefixed": "5.0.3",
"it-pipe": "1.1.0",
"libp2p": "0.36.2",
"libp2p-crypto": "0.21.2",
"libp2p-mplex": "0.10.7",
"libp2p-websockets": "0.16.2",
"loglevel": "1.8.0",
"multiaddr": "10.0.1",
"multiformats": "9.6.5",
"peer-id": "0.16.0",
"platform": "^1.3.6",
"rxjs": "^7.5.5",
"ts-pattern": "3.3.3",
"js-base64": "^3.7.2",
"uuid": "8.3.2"
},
"devDependencies": {
@ -54,7 +52,10 @@
"@types/jest": "^27.5.1",
"@types/platform": "^1.3.4",
"@types/uuid": "^8.3.4",
"js-base64": "^3.7.2",
"multiaddr": "10.0.1",
"jest": "^28.1.0",
"jest-each": "^28.1.3",
"ts-jest": "^28.0.2",
"typedoc": "^0.22.15",
"typescript": "^4.6.4"

View File

@ -1,6 +1,6 @@
import * as bs58 from 'bs58';
import * as base64 from 'base64-js';
import { KeyPair } from '../../internal/KeyPair';
import { KeyPair } from '@fluencelabs/keypair';
describe('KeyPair tests', () => {
it('generate keypair from seed', async function () {

View File

@ -1,7 +1,7 @@
import { CallParams, CallServiceData } from '../../internal/commonTypes';
import each from 'jest-each';
import { builtInServices } from '../../internal/builtins/common';
import { KeyPair } from '../../internal/KeyPair';
import { KeyPair } from '@fluencelabs/keypair';
import { Sig, defaultSigGuard, allowServiceFn } from '../../internal/builtins/Sig';
import { toUint8Array } from 'js-base64';

View File

@ -1,5 +1,6 @@
import { KeyPair } from '@fluencelabs/keypair';
import { EphemeralNetwork, defaultConfig } from '../../internal/ephemeral';
import { FluencePeer, KeyPair } from '../../index';
import { FluencePeer } from '../../index';
import { ResultCodes } from '../../internal/commonTypes';
let en: EphemeralNetwork;

View File

@ -15,11 +15,11 @@
*/
import log, { LogLevelDesc } from 'loglevel';
export { KeyPair } from '@fluencelabs/keypair';
import { FluencePeer, PeerConfig } from './internal/FluencePeer';
export { PeerStatus } from './internal/FluencePeer';
export { KeyPair } from './internal/KeyPair';
export { FluencePeer, PeerConfig } from './internal/FluencePeer';
export { MarineLoglevel as AvmLoglevel } from './internal/utils';
export { PeerIdB58, CallParams } from './internal/commonTypes';

View File

@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { RelayConnection } from '@fluencelabs/connection';
import { FluenceConnection } from '@fluencelabs/interfaces';
import { KeyPair } from '@fluencelabs/keypair';
import { FluenceAppService, loadDefaults, loadWasmFromFileSystem, loadWasmFromServer } from '@fluencelabs/marine-js';
import type { MultiaddrInput } from 'multiaddr';
import { CallServiceData, CallServiceResult, GenericCallServiceHandler, ResultCodes } from './commonTypes';
import { PeerIdB58 } from './commonTypes';
import { RelayConnection, FluenceConnection } from './FluenceConnection';
import { Particle, ParticleExecutionStage, ParticleQueueItem } from './Particle';
import { KeyPair } from './KeyPair';
import { throwIfNotSupported, dataToString, jsonify, MarineLoglevel, marineLogLevelToEnvs } from './utils';
import { concatMap, filter, pipe, Subject, tap } from 'rxjs';
import log from 'loglevel';
@ -27,7 +28,7 @@ import { builtInServices } from './builtins/common';
import { defaultSigGuard, Sig } from './builtins/Sig';
import { registerSig } from './_aqua/services';
import Buffer from './Buffer';
import { FluenceAppService, loadDefaults, loadWasmFromFileSystem, loadWasmFromServer } from '@fluencelabs/marine-js';
import { AVM, AvmRunner } from './avm';
import { isBrowser, isNode } from 'browser-or-node';
import { InterpreterResult, LogLevel } from '@fluencelabs/avm';

View File

@ -14,13 +14,13 @@
* limitations under the License.
*/
import { CallResultsArray, LogLevel } from '@fluencelabs/avm';
import { v4 as uuidv4 } from 'uuid';
import { fromByteArray, toByteArray } from 'base64-js';
import log from 'loglevel';
import { ParticleContext } from './commonTypes';
import { dataToString, jsonify } from './utils';
import Buffer from './Buffer';
import { CallResultsArray, LogLevel } from '@fluencelabs/avm';
export class Particle {
// TODO: make it not optional (should be added to the constructor)

View File

@ -1,6 +1,6 @@
import { SecurityTetraplet } from '@fluencelabs/avm';
import { CallParams, PeerIdB58 } from '../commonTypes';
import { KeyPair } from '../KeyPair';
import { KeyPair } from '@fluencelabs/keypair';
import { SigDef } from '../_aqua/services';
/**

View File

@ -1,7 +1,8 @@
import { FluenceConnection, ParticleHandler } from '@fluencelabs/interfaces';
import { keyPairFromBase64Sk } from '@fluencelabs/keypair';
import { PeerIdB58 } from './commonTypes';
import { FluenceConnection, ParticleHandler } from './FluenceConnection';
import { FluencePeer } from '../index';
import { keyPairFromBase64Sk } from './KeyPair';
import log from 'loglevel';
interface EphemeralConfig {

View File

@ -16,10 +16,10 @@
import log from 'loglevel';
import platform from 'platform';
import { LogLevel } from '@fluencelabs/avm';
import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes } from './commonTypes';
import { FluencePeer } from './FluencePeer';
import { LogLevel } from '@fluencelabs/avm';
import { ParticleExecutionStage } from './Particle';
import Buffer from './Buffer';

View File

@ -1,6 +1,5 @@
{
"compilerOptions": {
"typeRoots": ["./node_modules/@types", "./node_modules/libp2p-ts/types"],
"outDir": "./dist/",
"baseUrl": ".",
"downlevelIteration": true,

21
packages/fluence-keypair/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
bundle/
dist
esm
types
# Dependency directories
node_modules/
jspm_packages/
.idea

View File

@ -0,0 +1,12 @@
.idea
.gitignore
node_modules
types
src/
tsconfig.json
webpack.config.js
bundle
pkg

View File

@ -0,0 +1,8 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
printWidth: 120,
tabWidth: 4,
useTabs: false
};

View File

@ -0,0 +1,13 @@
## Contribute Code
You are welcome to contribute to Fluence.
Things you need to know:
1. You need to **agree to the Contributors License Agreement**. This is a common practice in all major Open Source projects. At the current moment we are unable to accept contributions made on behalf of a company. Only individual contributions will be accepted.
2. **Not all proposed contributions can be accepted**. Some features may e.g. just fit a third-party add-on better. The contribution must fit the overall direction of Fluence and really improve it. The more effort you invest, the better you should clarify in advance whether the contribution fits: the best way would be to just open an issue to discuss the contribution you plan to make.
### Contributor License Agreement
When you contribute, you have to be aware that your contribution is covered by **Apache License 2.0**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**.
In particular you need to agree to the [Contributor License Agreement](https://gist.github.com/fluencelabs-org/3f4cbb3cc14c1c0fb9ad99d8f7316ed7). If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.

View File

@ -0,0 +1,11 @@
# FluenceJS Keypair
This package is a part of FluenceJS, the official implementation of the Fluence Peer in typescript. See the [FluenceJS repo](https://github.com/fluencelabs/fluence-js) for more info
## Contributing
While the project is still in the early stages of development, you are welcome to track progress and contribute. As the project is undergoing rapid changes, interested contributors should contact the team before embarking on larger pieces of work. All contributors should consult with and agree to our [basic contributing rules](CONTRIBUTING.md).
## License
[Apache 2.0](LICENSE)

View File

@ -0,0 +1,25 @@
{
"name": "@fluencelabs/keypair",
"version": "0.1.0",
"description": "Keypair implementation for Fluence JS Peer",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"engines": {
"node": ">=10",
"pnpm": ">=3"
},
"scripts": {
"build": "tsc"
},
"repository": "https://github.com/fluencelabs/fluence-js",
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"peer-id": "0.16.0",
"libp2p-crypto": "0.21.2",
"js-base64": "^3.7.2"
},
"devDependencies": {
"typescript": "^4.6.4"
}
}

View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"outDir": "./dist/",
"lib": ["ES2015"],
"target": "ES5",
"sourceMap": true,
"declaration": true,
"module": "commonjs",
},
"exclude": ["node_modules", "dist"],
"include": ["src/**/*"]
}

4724
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

3
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,3 @@
packages:
- 'packages/*'

View File

@ -3,5 +3,5 @@
"theme": "default",
"out": "docs",
"excludePrivate": true,
"entryPoints": ["src/index.ts"]
"entryPoints": ["packages/fluence-js/src/index.ts"]
}