Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix repo to use new aegir #89

Merged
merged 24 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
name: Lint and Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: 14
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --prefer-offline --frozen-lockfile
- run: yarn run check
- run: yarn run build
# LArge bundle because of node-forge and bcrypto
# - uses: ipfs/aegir/actions/bundle-size@master
# name: Check bundle size
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}

test-node:
name: Test Nodejs
needs: check
strategy:
matrix:
node: [12, 14]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --prefer-offline --frozen-lockfile
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
- uses: codecov/codecov-action@v1

test-chrome:
name: Test Chrome
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --prefer-offline --frozen-lockfile
- run: npx aegir test -t browser -t webworker --bail

test-firefox:
name: Test Firefox
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --prefer-offline --frozen-lockfile
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless

test-electron-main:
name: Test Electron Main
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --prefer-offline --frozen-lockfile
- run: npx xvfb-maybe aegir test -t electron-main --bail

test-electron-renderer:
name: Test Electron Renderer
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --prefer-offline --frozen-lockfile
- run: npx xvfb-maybe aegir test -t electron-renderer --bail
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules/
.nyc_output
lib
dist
docs

# Logs
logs
Expand Down
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

33 changes: 21 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,32 @@
"scripts": {
"bench": "node benchmarks/benchmark.js",
"clean": "rm -rf dist",
"copy-dts": "copyfiles -u 1 \"src/**/*.d.ts\" dist/src",
"build": "aegir build --ts",
"check": "aegir dep-check && aegir ts -p check",
"copy-dts": "copyup \"src/**/*.d.ts\" dist/src",
"build": "aegir build",
"postbuild": "yarn run copy-dts",
"lint": "aegir lint --ts",
"lint:fix": "aegir lint --ts --fix",
"test": "aegir test --ts --node true",
"test:node": "aegir test -t node --ts",
"test:browser": "aegir test -t browser --node true --ts",
"lint": "aegir lint",
"lint:fix": "aegir lint --fix",
"pretest": "yarm run check",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"docs": "aegir docs",
"proto:gen": "pbjs -t static-module -o ./src/proto/payload.js ./src/proto/payload.proto && pbts -o ./src/proto/payload.d.ts ./src/proto/payload.js && yarn run lint --fix"
},
"aegir" :{
"node": true,
"tsRepo": true,
"docs": {
"entryPoint": "src/index.ts"
}
},
"devDependencies": {
"@types/bl": "^2.1.0",
"@types/chai": "^4.2.4",
"@types/mocha": "^5.2.7",
"aegir": "28.2.0",
"aegir": "ipfs/aegir#feat/ts-repo-support",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"copyfiles": "^2.4.1",
"eslint-config-ipfs": "^0.1.0",
"karma-mocha-webworker": "^1.3.0",
"microtime": "^3.0.0",
"mocha": "^8.2.1",
Expand All @@ -65,7 +72,9 @@
"eslintConfig": {
"extends": "ipfs",
"rules": {
"@typescript-eslint/no-unused-vars": "error"
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/strict-boolean-expressions": "off"
},
"ignorePatterns": [
"src/proto/payload.js"
Expand Down
12 changes: 6 additions & 6 deletions src/@types/basic.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Buffer} from 'buffer';
import { Buffer } from 'buffer'

export type bytes = Buffer;
export type bytes32 = Buffer;
export type bytes16 = Buffer;
export type bytes = Buffer
export type bytes32 = Buffer
export type bytes16 = Buffer

export type uint32 = number;
export type uint64 = number;
export type uint32 = number
export type uint64 = number
16 changes: 8 additions & 8 deletions src/@types/handshake-interface.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {bytes} from "./basic";
import {NoiseSession} from "./handshake";
import PeerId from "peer-id";
import { bytes } from './basic'
import { NoiseSession } from './handshake'
import PeerId from 'peer-id'

export interface IHandshake {
session: NoiseSession;
remotePeer: PeerId;
remoteEarlyData: Buffer;
encrypt(plaintext: bytes, session: NoiseSession): bytes;
decrypt(ciphertext: bytes, session: NoiseSession): {plaintext: bytes; valid: boolean};
session: NoiseSession
remotePeer: PeerId
remoteEarlyData: Buffer
encrypt: (plaintext: bytes, session: NoiseSession) => bytes
decrypt: (ciphertext: bytes, session: NoiseSession) => {plaintext: bytes, valid: boolean}
}
62 changes: 31 additions & 31 deletions src/@types/handshake.d.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
import {bytes, bytes32, uint32, uint64} from "./basic";
import {KeyPair} from "./libp2p";
import { bytes, bytes32, uint32, uint64 } from './basic'
import { KeyPair } from './libp2p'

export type Hkdf = [bytes, bytes, bytes];
export type Hkdf = [bytes, bytes, bytes]

export type MessageBuffer = {
ne: bytes32;
ns: bytes;
ciphertext: bytes;
export interface MessageBuffer {
ne: bytes32
ns: bytes
ciphertext: bytes
}

export type CipherState = {
k: bytes32;
n: uint32;
export interface CipherState {
k: bytes32
n: uint32
}

export type SymmetricState = {
cs: CipherState;
ck: bytes32; // chaining key
h: bytes32; // handshake hash
export interface SymmetricState {
cs: CipherState
ck: bytes32 // chaining key
h: bytes32 // handshake hash
}

export type HandshakeState = {
ss: SymmetricState;
s: KeyPair;
e?: KeyPair;
rs: bytes32;
re: bytes32;
psk: bytes32;
export interface HandshakeState {
ss: SymmetricState
s: KeyPair
e?: KeyPair
rs: bytes32
re: bytes32
psk: bytes32
}

export type NoiseSession = {
hs: HandshakeState;
h?: bytes32;
cs1?: CipherState;
cs2?: CipherState;
mc: uint64;
i: boolean;
export interface NoiseSession {
hs: HandshakeState
h?: bytes32
cs1?: CipherState
cs2?: CipherState
mc: uint64
i: boolean
}

export interface INoisePayload {
identityKey: bytes;
identitySig: bytes;
data: bytes;
identityKey: bytes
identitySig: bytes
data: bytes
}
Loading