Skip to content

Commit 8a5321b

Browse files
authored
feat!: update to [email protected] (#444)
- Incorporates API changes from the upcoming `[email protected]` release. - Removal of libp2p 1.0 interfaces workarounds - Alignment of CI w other libp2p packages - More documentation BREAKING CHANGE: Can only be used with `[email protected]` or later
1 parent a69b43b commit 8a5321b

22 files changed

+433
-445
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ updates:
55
schedule:
66
interval: daily
77
time: "10:00"
8-
open-pull-requests-limit: 10
8+
open-pull-requests-limit: 20
99
commit-message:
10-
prefix: "fix: "
11-
prefix-development: "chore: "
10+
prefix: "deps"
11+
prefix-development: "deps(dev)"
Lines changed: 20 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,28 @@
11
name: test & maybe release
2+
23
on:
34
push:
45
branches:
5-
- master # with #262 - ${{{ github.default_branch }}}
6+
- master
67
pull_request:
7-
branches:
8-
- master # with #262 - ${{{ github.default_branch }}}
9-
10-
jobs:
11-
12-
check:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v4
16-
- uses: actions/setup-node@v4
17-
with:
18-
node-version: lts/*
19-
- uses: ipfs/aegir/actions/cache-node-modules@master
20-
- run: npm run --if-present lint
21-
- run: npm run --if-present dep-check
22-
23-
test-node:
24-
needs: check
25-
runs-on: ${{ matrix.os }}
26-
strategy:
27-
matrix:
28-
os: [windows-latest, ubuntu-latest, macos-latest]
29-
node: [18,20]
30-
fail-fast: true
31-
steps:
32-
- uses: actions/checkout@v4
33-
- uses: actions/setup-node@v4
34-
with:
35-
node-version: ${{ matrix.node }}
36-
- uses: ipfs/aegir/actions/cache-node-modules@master
37-
- run: npm run --if-present test:node
38-
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
39-
with:
40-
directory: ./.nyc_output
41-
flags: node
42-
43-
test-chrome:
44-
needs: check
45-
runs-on: ubuntu-latest
46-
steps:
47-
- uses: actions/checkout@v4
48-
- uses: actions/setup-node@v4
49-
with:
50-
node-version: lts/*
51-
- uses: ipfs/aegir/actions/cache-node-modules@master
52-
- run: npm run --if-present test:chrome
53-
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
54-
with:
55-
directory: ./.nyc_output
56-
flags: chrome
57-
58-
test-chrome-webworker:
59-
needs: check
60-
runs-on: ubuntu-latest
61-
steps:
62-
- uses: actions/checkout@v2
63-
- uses: actions/setup-node@v2
64-
with:
65-
node-version: lts/*
66-
- uses: ipfs/aegir/actions/cache-node-modules@master
67-
- run: npm run --if-present test:chrome-webworker
68-
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
69-
with:
70-
directory: ./.nyc_output
71-
flags: chrome-webworker
8+
workflow_dispatch:
729

73-
test-firefox:
74-
needs: check
75-
runs-on: ubuntu-latest
76-
steps:
77-
- uses: actions/checkout@v4
78-
- uses: actions/setup-node@v4
79-
with:
80-
node-version: lts/*
81-
- uses: ipfs/aegir/actions/cache-node-modules@master
82-
- run: npm run --if-present test:firefox
83-
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
84-
with:
85-
directory: ./.nyc_output
86-
flags: firefox
87-
88-
test-firefox-webworker:
89-
needs: check
90-
runs-on: ubuntu-latest
91-
steps:
92-
- uses: actions/checkout@v4
93-
- uses: actions/setup-node@v4
94-
with:
95-
node-version: lts/*
96-
- uses: ipfs/aegir/actions/cache-node-modules@master
97-
- run: npm run --if-present test:firefox-webworker
98-
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
99-
with:
100-
directory: ./.nyc_output
101-
flags: firefox-webworker
102-
103-
test-electron-main:
104-
needs: check
105-
runs-on: ubuntu-latest
106-
steps:
107-
- uses: actions/checkout@v4
108-
- uses: actions/setup-node@v4
109-
with:
110-
node-version: lts/*
111-
- uses: ipfs/aegir/actions/cache-node-modules@master
112-
- run: npx xvfb-maybe npm run --if-present test:electron-main
113-
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
114-
with:
115-
directory: ./.nyc_output
116-
flags: electron-main
117-
118-
test-electron-renderer:
119-
needs: check
120-
runs-on: ubuntu-latest
121-
steps:
122-
- uses: actions/checkout@v4
123-
- uses: actions/setup-node@v4
124-
with:
125-
node-version: lts/*
126-
- uses: ipfs/aegir/actions/cache-node-modules@master
127-
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
128-
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
129-
with:
130-
directory: ./.nyc_output
131-
flags: electron-renderer
132-
133-
test-interop:
134-
needs: check
135-
runs-on: ubuntu-latest
136-
steps:
137-
- uses: actions/checkout@v4
138-
- uses: actions/setup-node@v4
139-
with:
140-
node-version: lts/*
141-
- uses: ipfs/aegir/actions/cache-node-modules@master
142-
- run: npm run test:interop -- --bail
143-
144-
release:
145-
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer, test-interop]
146-
runs-on: ubuntu-latest
147-
if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
148-
steps:
149-
- uses: google-github-actions/release-please-action@v3
150-
id: release
151-
with:
152-
release-type: node
153-
package-name: release-please-action
154-
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":true}]'
155-
156-
- uses: actions/checkout@v4
157-
if: ${{ steps.release.outputs.release_created }}
158-
with:
159-
fetch-depth: 0
160-
161-
- uses: actions/setup-node@v4
162-
if: ${{ steps.release.outputs.release_created }}
163-
with:
164-
node-version: 18
165-
registry-url: 'https://registry.npmjs.org'
166-
167-
- uses: ipfs/aegir/actions/cache-node-modules@master
168-
if: ${{ steps.release.outputs.release_created }}
169-
170-
- run: npm publish
171-
if: ${{ steps.release.outputs.release_created }}
172-
env:
173-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10+
permissions:
11+
contents: write
12+
id-token: write
13+
packages: write
14+
pull-requests: write
17415

16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
18+
cancel-in-progress: true
17519

20+
jobs:
21+
js-test-and-release:
22+
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
23+
secrets:
24+
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
25+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
26+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
27+
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
28+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/semantic-pr.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Semantic PR
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
uses: pl-strflt/.github/.github/workflows/[email protected]

.github/workflows/stale.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Close and mark stale issue
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
stale:
13+
uses: pl-strflt/.github/.github/workflows/[email protected]

.gitignore

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
bundle
2-
node_modules/
3-
.idea
4-
.env
5-
.nyc_output
6-
lib
1+
node_modules
2+
build
73
dist
8-
docs
9-
10-
# Logs
11-
logs
12-
*.log
13-
npm-debug.log*
14-
yarn-debug.log*
15-
yarn-error.log*
16-
lerna-debug.log*
17-
coverage/*
4+
.docs
5+
.coverage
6+
node_modules
187
package-lock.json
198
yarn.lock
209
.vscode

README.md

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# js-libp2p-noise
1+
# @chainsafe/libp2p-noise
22

33
![npm](https://img.shields.io/npm/v/@chainsafe/libp2p-noise)
44
[![](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-noise/js-test-and-release.yml?branch=master)](https://github.com/ChainSafe/js-libp2p-noise/actions)
@@ -10,22 +10,36 @@
1010
![](https://img.shields.io/badge/Node.js-%3E%3D16.0.0-orange.svg?style=flat-square)
1111
![](https://img.shields.io/badge/browsers-last%202%20versions%2C%20not%20ie%20%3C%3D11-orange)
1212
[![Twitter](https://img.shields.io/twitter/follow/ChainSafeth.svg?label=Twitter)](https://twitter.com/ChainSafeth)
13-
[![Discord](https://img.shields.io/discord/593655374469660673.svg?label=Discord&logo=discord)](https://discord.gg/Q6A3YA2)
13+
[![Discord](https://img.shields.io/discord/593655374469660673.svg?label=Discord\&logo=discord)](https://discord.gg/Q6A3YA2)
1414

1515
> Noise libp2p handshake for js-libp2p
1616
17-
This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
17+
# About
18+
19+
<!--
20+
21+
!IMPORTANT!
22+
23+
Everything in this README between "# About" and "# Install" is automatically
24+
generated and will be overwritten the next time the doc generator is run.
1825
19-
##### Warning: Even though this package works in browser, it will bundle around 600Kb (200Kb gzipped) of code
20-
https://bundlephobia.com/result?p=@chainsafe/libp2p-noise@latest
26+
To make changes to this section, please update the @packageDocumentation section
27+
of src/index.js or src/index.ts
28+
29+
To experiment with formatting, please run "npm run docs" from the root of this
30+
repo and examine the changes made.
31+
32+
-->
33+
34+
This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
2135

2236
## Usage
2337

2438
Install with `yarn add @chainsafe/libp2p-noise` or `npm i @chainsafe/libp2p-noise`.
2539

2640
Example of using default noise configuration and passing it to the libp2p config:
2741

28-
```js
42+
```ts
2943
import {createLibp2p} from "libp2p"
3044
import {noise} from "@chainsafe/libp2p-noise"
3145

@@ -34,32 +48,48 @@ import {noise} from "@chainsafe/libp2p-noise"
3448
const n = noise({ staticNoiseKey });
3549

3650
const libp2p = await createLibp2p({
37-
connectionEncryption: [noise()],
51+
connectionEncrypters: [noise()],
3852
//... other options
3953
})
4054
```
4155

42-
See the [NoiseInit](https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/noise.ts#L29-L38) interface for noise configuration options.
56+
See the [NoiseInit](https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/noise.ts#L22-L30) interface for noise configuration options.
4357

4458
## API
4559

46-
This module exposes an implementation of the [ConnectionEncrypter](https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.connection_encrypter.ConnectionEncrypter.html) interface.
60+
This module exposes an implementation of the [ConnectionEncrypter](https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.ConnectionEncrypter.html) interface.
4761

4862
## Bring your own crypto
4963

50-
You can provide a custom crypto implementation (instead of the default, based on [@noble](https://paulmillr.com/noble/)) by adding a `crypto` field to the init argument passed to the `Noise` factory.
64+
You can provide a custom crypto implementation (instead of the default, based on [@noble](https://paulmillr.com/noble/)) by adding a `crypto` field to the init argument passed to the `Noise` factory.
5165

52-
The implementation must conform to the `ICryptoInterface`, defined in https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts
66+
The implementation must conform to the `ICryptoInterface`, defined in <https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts>
5367

54-
## Contribute
68+
# Install
5569

56-
Feel free to join in. All welcome. Open an issue!
70+
```console
71+
$ npm i @chainsafe/libp2p-noise
72+
```
73+
74+
## Browser `<script>` tag
75+
76+
Loading this module through a script tag will make its exports available as `ChainsafeLibp2pNoise` in the global namespace.
77+
78+
```html
79+
<script src="https://unpkg.com/@chainsafe/libp2p-noise/dist/index.min.js"></script>
80+
```
81+
82+
# API Docs
5783

58-
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)
84+
- <https://ChainSafe.github.io/js-libp2p-noise>
5985

60-
## License
86+
# License
6187

6288
Licensed under either of
6389

64-
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
65-
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)
90+
- Apache 2.0, ([LICENSE-APACHE](https://github.com/ChainSafe/js-libp2p-noise/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
91+
- MIT ([LICENSE-MIT](https://github.com/ChainSafe/js-libp2p-noise/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
92+
93+
# Contribution
94+
95+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)