-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add types, update deps, semantic-release, dependabot
- Loading branch information
Showing
9 changed files
with
341 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'github-actions' | ||
directory: '/' | ||
schedule: | ||
interval: 'daily' | ||
commit-message: | ||
prefix: 'chore' | ||
include: 'scope' | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
schedule: | ||
interval: 'daily' | ||
commit-message: | ||
prefix: 'chore' | ||
include: 'scope' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Test & Maybe Release | ||
on: [push, pull_request] | ||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: [14.x, 16.x] | ||
os: [macos-latest, ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2.3.4 | ||
- name: Use Node.js ${{ matrix.node }} | ||
uses: actions/setup-node@v2.1.5 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- name: Install Dependencies | ||
run: | | ||
npm install --no-progress --no-package-lock | ||
- name: Run tests | ||
run: | | ||
npm test | ||
test-windows: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: [14.x, 16.x] | ||
os: [windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2.3.4 | ||
- name: Use Node.js ${{ matrix.node }} | ||
uses: actions/setup-node@v2.1.5 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- name: Install Dependencies | ||
run: | | ||
npm install --no-progress --no-package-lock | ||
- name: Run tests | ||
run: | | ||
npm run test:node | ||
release: | ||
name: Release | ||
needs: [test, test-windows] | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2.3.4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2.1.5 | ||
with: | ||
node-version: 14 | ||
- name: Install dependencies | ||
run: | | ||
npm install --no-progress --no-package-lock --no-save | ||
- name: Build | ||
run: | | ||
npm run build | ||
- name: Install plugins | ||
run: | | ||
npm install \ | ||
@semantic-release/commit-analyzer \ | ||
conventional-changelog-conventionalcommits \ | ||
@semantic-release/release-notes-generator \ | ||
@semantic-release/npm \ | ||
@semantic-release/github \ | ||
@semantic-release/git \ | ||
@semantic-release/changelog \ | ||
--no-progress --no-package-lock --no-save | ||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
run: npx semantic-release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
.github | ||
dist/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
'use strict' | ||
|
||
import { from } from 'multiformats/hashes/hasher' | ||
import sha3 from 'js-sha3' | ||
const encoder = fn => b => new Uint8Array(fn.array(b)) | ||
|
||
export default [ | ||
{ code: 0x14, name: 'sha3-512', encode: encoder(sha3.sha3_512) }, | ||
{ code: 0x15, name: 'sha3-384', encode: encoder(sha3.sha3_384) }, | ||
{ code: 0x16, name: 'sha3-256', encode: encoder(sha3.sha3_256) }, | ||
{ code: 0x17, name: 'sha3-224', encode: encoder(sha3.sha3_224) }, | ||
{ code: 0x18, name: 'shake-128', encode: encoder(sha3.shake128) }, | ||
{ code: 0x19, name: 'shake-256', encode: encoder(sha3.shake256) }, | ||
{ code: 0x1a, name: 'keccak-224', encode: encoder(sha3.keccak224) }, | ||
{ code: 0x1b, name: 'keccak-256', encode: encoder(sha3.keccak256) }, | ||
{ code: 0x1c, name: 'keccak-384', encode: encoder(sha3.keccak384) }, | ||
{ code: 0x1d, name: 'keccak-512', encode: encoder(sha3.keccak512) } | ||
] | ||
/** | ||
* @param {sha3.Hash} fn | ||
* @returns {(inp:Uint8Array)=>Uint8Array} | ||
*/ | ||
function encoder (fn) { | ||
return (/** @type {Uint8Array} */ b) => new Uint8Array(fn.array(b)) | ||
} | ||
|
||
export const sha3512 = from({ code: 0x14, name: 'sha3-512', encode: encoder(sha3.sha3_512) }) | ||
export const sha3384 = from({ code: 0x15, name: 'sha3-384', encode: encoder(sha3.sha3_384) }) | ||
export const sha3256 = from({ code: 0x16, name: 'sha3-256', encode: encoder(sha3.sha3_256) }) | ||
export const sha3224 = from({ code: 0x17, name: 'sha3-224', encode: encoder(sha3.sha3_224) }) | ||
export const shake128 = from({ code: 0x18, name: 'shake-128', encode: (b) => new Uint8Array(sha3.shake128.array(b, 256)) }) | ||
export const shake256 = from({ code: 0x19, name: 'shake-256', encode: (b) => new Uint8Array(sha3.shake256.array(b, 512)) }) | ||
export const keccak224 = from({ code: 0x1a, name: 'keccak-224', encode: encoder(sha3.keccak224) }) | ||
export const keccak256 = from({ code: 0x1b, name: 'keccak-256', encode: encoder(sha3.keccak256) }) | ||
export const keccak384 = from({ code: 0x1c, name: 'keccak-384', encode: encoder(sha3.keccak384) }) | ||
export const keccak512 = from({ code: 0x1d, name: 'keccak-512', encode: encoder(sha3.keccak512) }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default ` | ||
sha3-512, multihash, 0x14, permanent, | ||
sha3-384, multihash, 0x15, permanent, | ||
sha3-256, multihash, 0x16, permanent, | ||
sha3-224, multihash, 0x17, permanent, | ||
shake-128, multihash, 0x18, draft, | ||
shake-256, multihash, 0x19, draft, | ||
keccak-224, multihash, 0x1a, draft, keccak has variable output length. The number specifies the core length | ||
keccak-256, multihash, 0x1b, draft, | ||
keccak-384, multihash, 0x1c, draft, | ||
keccak-512, multihash, 0x1d, draft, | ||
` |
Oops, something went wrong.