Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
deps(dev): bump aegir from 38.1.8 to 39.0.5 (#320)
Browse files Browse the repository at this point in the history
* deps(dev): bump aegir from 38.1.8 to 39.0.5

Bumps [aegir](https://github.com/ipfs/aegir) from 38.1.8 to 39.0.5.
- [Release notes](https://github.com/ipfs/aegir/releases)
- [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md)
- [Commits](ipfs/aegir@v38.1.8...v39.0.5)

---
updated-dependencies:
- dependency-name: aegir
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: fix linting and deps

* chore: fix build

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: achingbrain <alex@achingbrain.net>
  • Loading branch information
dependabot[bot] and achingbrain authored May 5, 2023
1 parent b8fa2d3 commit f0b4c06
Show file tree
Hide file tree
Showing 31 changed files with 71 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist
node_modules
package-lock.json
yarn.lock
.vscode
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,9 @@
},
"devDependencies": {
"@types/mocha": "^10.0.0",
"aegir": "^38.1.2",
"aegir": "^39.0.5",
"benchmark": "^2.1.4",
"protons": "^7.0.2",
"util": "^0.12.5"
"protons": "^7.0.2"
},
"browser": {
"./dist/src/aes/ciphers.js": "./dist/src/aes/ciphers-browser.js",
Expand Down
2 changes: 1 addition & 1 deletion src/aes/ciphers-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import 'node-forge/lib/aes.js'
// @ts-expect-error types are missing
import forge from 'node-forge/lib/forge.js'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'

export interface Cipher {
update: (data: Uint8Array) => Uint8Array
Expand Down
2 changes: 1 addition & 1 deletion src/aes/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ciphers from './ciphers.js'
import { cipherMode } from './cipher-mode.js'
import * as ciphers from './ciphers.js'

export interface AESCipher {
encrypt: (data: Uint8Array) => Promise<Uint8Array>
Expand Down
2 changes: 1 addition & 1 deletion src/ciphers/aes-gcm.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function create (opts?: CreateOptions): AESCipher {
cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt'])
}
} else {
// Derive a key using PBKDF2.
// Derive a key using PBKDF2.
const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } }
const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey'])
cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['encrypt'])
Expand Down
2 changes: 1 addition & 1 deletion src/ciphers/aes-gcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function create (opts?: CreateOptions): AESCipher {
const key = crypto.pbkdf2Sync(password, salt, iterations, keyLength, digest)

// Decrypt and return result.
return await decryptWithKey(ciphertextAndNonce, key)
return decryptWithKey(ciphertextAndNonce, key)
}

const cipher: AESCipher = {
Expand Down
2 changes: 1 addition & 1 deletion src/hmac/index-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function create (hashType: 'SHA1' | 'SHA256' | 'SHA512', secret: Ui

return {
async digest (data: Uint8Array) { // eslint-disable-line require-await
return await sign(key, data)
return sign(key, data)
},
length: lengths[hashType]
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as hmac from './hmac/index.js'
import * as aes from './aes/index.js'
import * as hmac from './hmac/index.js'
import * as keys from './keys/index.js'
import randomBytes from './random-bytes.js'
import pbkdf2 from './pbkdf2.js'
import randomBytes from './random-bytes.js'

export { aes }
export { hmac }
Expand Down
6 changes: 3 additions & 3 deletions src/keys/ecdh-browser.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CodeError } from '@libp2p/interfaces/errors'
import webcrypto from '../webcrypto.js'
import { base64urlToBuffer } from '../util.js'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { base64urlToBuffer } from '../util.js'
import webcrypto from '../webcrypto.js'
import type { ECDHKey, ECDHKeyPair, JWKEncodedPrivateKey, JWKEncodedPublicKey } from './interface.js'

const bits = {
Expand Down
4 changes: 2 additions & 2 deletions src/keys/ed25519-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export async function generateKeyFromSeed (seed: Uint8Array): Promise<Uint8Array
export async function hashAndSign (privateKey: Uint8Array, msg: Uint8Array): Promise<Uint8Array> {
const privateKeyRaw = privateKey.subarray(0, KEYS_BYTE_LENGTH)

return await ed.sign(msg, privateKeyRaw)
return ed.sign(msg, privateKeyRaw)
}

export async function hashAndVerify (publicKey: Uint8Array, sig: Uint8Array, msg: Uint8Array): Promise<boolean> {
return await ed.verify(sig, msg, publicKey)
return ed.verify(sig, msg, publicKey)
}

function concatKeys (privateKeyRaw: Uint8Array, publicKey: Uint8Array): Uint8Array {
Expand Down
12 changes: 6 additions & 6 deletions src/keys/ed25519-class.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CodeError } from '@libp2p/interfaces/errors'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { sha256 } from 'multiformats/hashes/sha2'
import { base58btc } from 'multiformats/bases/base58'
import { identity } from 'multiformats/hashes/identity'
import { sha256 } from 'multiformats/hashes/sha2'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import * as crypto from './ed25519.js'
import * as pbm from './keys.js'
import { exporter } from './exporter.js'
import * as pbm from './keys.js'
import type { Multibase } from 'multiformats'

export class Ed25519PublicKey {
Expand All @@ -16,7 +16,7 @@ export class Ed25519PublicKey {
}

async verify (data: Uint8Array, sig: Uint8Array): Promise<boolean> { // eslint-disable-line require-await
return await crypto.hashAndVerify(this._key, sig, data)
return crypto.hashAndVerify(this._key, sig, data)
}

marshal (): Uint8Array {
Expand Down Expand Up @@ -53,7 +53,7 @@ export class Ed25519PrivateKey {
}

async sign (message: Uint8Array): Promise<Uint8Array> { // eslint-disable-line require-await
return await crypto.hashAndSign(this._key, message)
return crypto.hashAndSign(this._key, message)
}

get public (): Ed25519PublicKey {
Expand Down Expand Up @@ -100,7 +100,7 @@ export class Ed25519PrivateKey {
*/
async export (password: string, format = 'libp2p-key'): Promise<Multibase<'m'>> {
if (format === 'libp2p-key') {
return await exporter(this.bytes, password)
return exporter(this.bytes, password)
} else {
throw new CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT')
}
Expand Down
2 changes: 1 addition & 1 deletion src/keys/ed25519.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import crypto from 'crypto'
import { promisify } from 'util'
import { toString as uint8arrayToString } from 'uint8arrays/to-string'
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
import { toString as uint8arrayToString } from 'uint8arrays/to-string'
import type { Uint8ArrayKeyPair } from './interface.js'

const keypair = promisify(crypto.generateKeyPair)
Expand Down
2 changes: 1 addition & 1 deletion src/keys/exporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Multibase } from 'multiformats'
import { base64 } from 'multiformats/bases/base64'
import * as ciphers from '../ciphers/aes-gcm.js'
import type { Multibase } from 'multiformats'

/**
* Exports the given PrivateKey as a base64 encoded string.
Expand Down
2 changes: 1 addition & 1 deletion src/keys/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import * as ciphers from '../ciphers/aes-gcm.js'
export async function importer (privateKey: string, password: string): Promise<Uint8Array> {
const encryptedKey = base64.decode(privateKey)
const cipher = ciphers.create()
return await cipher.decrypt(encryptedKey, password)
return cipher.decrypt(encryptedKey, password)
}
16 changes: 8 additions & 8 deletions src/keys/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as keysPBM from './keys.js'
import 'node-forge/lib/asn1.js'
import 'node-forge/lib/pbe.js'
import { CodeError } from '@libp2p/interfaces/errors'
// @ts-expect-error types are missing
import forge from 'node-forge/lib/forge.js'
import { CodeError } from '@libp2p/interfaces/errors'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { keyStretcher } from './key-stretcher.js'
import * as Ed25519 from './ed25519-class.js'
import generateEphemeralKeyPair from './ephemeral-keys.js'
import { importer } from './importer.js'
import { keyStretcher } from './key-stretcher.js'
import * as keysPBM from './keys.js'
import * as RSA from './rsa-class.js'
import * as Ed25519 from './ed25519-class.js'
import * as Secp256k1 from './secp256k1-class.js'
import type { PrivateKey, PublicKey } from '@libp2p/interface-keys'

Expand Down Expand Up @@ -42,7 +42,7 @@ function typeToKey (type: string): typeof RSA | typeof Ed25519 | typeof Secp256k

// Generates a keypair of the given type and bitsize
export async function generateKeyPair (type: KeyTypes, bits?: number): Promise<PrivateKey> { // eslint-disable-line require-await
return await typeToKey(type).generateKeyPair(bits ?? 2048)
return typeToKey(type).generateKeyPair(bits ?? 2048)
}

// Generates a keypair of the given type and bitsize
Expand All @@ -52,7 +52,7 @@ export async function generateKeyPairFromSeed (type: KeyTypes, seed: Uint8Array,
throw new CodeError('Seed key derivation is unimplemented for RSA or secp256k1', 'ERR_UNSUPPORTED_KEY_DERIVATION_TYPE')
}

return await Ed25519.generateKeyPairFromSeed(seed)
return Ed25519.generateKeyPairFromSeed(seed)
}

// Converts a protobuf serialized public key into its
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function unmarshalPrivateKey (buf: Uint8Array): Promise<PrivateKey>

switch (decoded.Type) {
case keysPBM.KeyType.RSA:
return await supportedKeys.rsa.unmarshalRsaPrivateKey(data)
return supportedKeys.rsa.unmarshalRsaPrivateKey(data)
case keysPBM.KeyType.Ed25519:
return supportedKeys.ed25519.unmarshalEd25519PrivateKey(data)
case keysPBM.KeyType.Secp256k1:
Expand Down Expand Up @@ -125,5 +125,5 @@ export async function importKey (encryptedKey: string, password: string): Promis
}
let der = forge.asn1.toDer(forge.pki.privateKeyToAsn1(key))
der = uint8ArrayFromString(der.getBytes(), 'ascii')
return await supportedKeys.rsa.unmarshalRsaPrivateKey(der)
return supportedKeys.rsa.unmarshalRsaPrivateKey(der)
}
16 changes: 8 additions & 8 deletions src/keys/rsa-browser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import webcrypto from '../webcrypto.js'
import randomBytes from '../random-bytes.js'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { CodeError } from '@libp2p/interfaces/errors'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import * as utils from './rsa-utils.js'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import randomBytes from '../random-bytes.js'
import webcrypto from '../webcrypto.js'
import { jwk2pub, jwk2priv } from './jwk2pem.js'
import { CodeError } from '@libp2p/interfaces/errors'
import * as utils from './rsa-utils.js'
import type { JWKKeyPair } from './interface.js'

export { utils }
Expand Down Expand Up @@ -93,7 +93,7 @@ export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint
['verify']
)

return await webcrypto.get().subtle.verify(
return webcrypto.get().subtle.verify(
{ name: 'RSASSA-PKCS1-v1_5' },
publicKey,
sig,
Expand All @@ -106,14 +106,14 @@ async function exportKey (pair: CryptoKeyPair): Promise<[JsonWebKey, JsonWebKey]
throw new CodeError('Private and public key are required', 'ERR_INVALID_PARAMETERS')
}

return await Promise.all([
return Promise.all([
webcrypto.get().subtle.exportKey('jwk', pair.privateKey),
webcrypto.get().subtle.exportKey('jwk', pair.publicKey)
])
}

async function derivePublicFromPrivate (jwKey: JsonWebKey): Promise<CryptoKey> {
return await webcrypto.get().subtle.importKey(
return webcrypto.get().subtle.importKey(
'jwk',
{
kty: jwKey.kty,
Expand Down
18 changes: 9 additions & 9 deletions src/keys/rsa-class.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

import { sha256 } from 'multiformats/hashes/sha2'
import { CodeError } from '@libp2p/interfaces/errors'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import 'node-forge/lib/sha512.js'
import { sha256 } from 'multiformats/hashes/sha2'
// @ts-expect-error types are missing
import forge from 'node-forge/lib/forge.js'
import * as crypto from './rsa.js'
import * as pbm from './keys.js'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import 'node-forge/lib/sha512.js'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { exporter } from './exporter.js'
import * as pbm from './keys.js'
import * as crypto from './rsa.js'
import type { Multibase } from 'multiformats'

export class RsaPublicKey {
Expand All @@ -19,7 +19,7 @@ export class RsaPublicKey {
}

async verify (data: Uint8Array, sig: Uint8Array): Promise<boolean> { // eslint-disable-line require-await
return await crypto.hashAndVerify(this._key, sig, data)
return crypto.hashAndVerify(this._key, sig, data)
}

marshal (): Uint8Array {
Expand Down Expand Up @@ -62,7 +62,7 @@ export class RsaPrivateKey {
}

async sign (message: Uint8Array): Promise<Uint8Array> { // eslint-disable-line require-await
return await crypto.hashAndSign(this._key, message)
return crypto.hashAndSign(this._key, message)
}

get public (): RsaPublicKey {
Expand Down Expand Up @@ -127,7 +127,7 @@ export class RsaPrivateKey {
}
return forge.pki.encryptRsaPrivateKey(privateKey, password, options)
} else if (format === 'libp2p-key') {
return await exporter(this.bytes, password)
return exporter(this.bytes, password)
} else {
throw new CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT')
}
Expand Down
4 changes: 2 additions & 2 deletions src/keys/rsa-utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'node-forge/lib/asn1.js'
import 'node-forge/lib/rsa.js'
import { CodeError } from '@libp2p/interfaces/errors'
// @ts-expect-error types are missing
import forge from 'node-forge/lib/forge.js'
import { bigIntegerToUintBase64url, base64urlToBigInteger } from './../util.js'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { CodeError } from '@libp2p/interfaces/errors'
import { bigIntegerToUintBase64url, base64urlToBigInteger } from './../util.js'

// Convert a PKCS#1 in ASN1 DER format to a JWK key
export function pkcs1ToJwk (bytes: Uint8Array): JsonWebKey {
Expand Down
10 changes: 5 additions & 5 deletions src/keys/secp256k1-class.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { sha256 } from 'multiformats/hashes/sha2'
import { CodeError } from '@libp2p/interfaces/errors'
import { sha256 } from 'multiformats/hashes/sha2'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import * as crypto from './secp256k1.js'
import { exporter } from './exporter.js'
import * as keysProtobuf from './keys.js'
import * as crypto from './secp256k1.js'
import type { Multibase } from 'multiformats'

export class Secp256k1PublicKey {
Expand All @@ -16,7 +16,7 @@ export class Secp256k1PublicKey {
}

async verify (data: Uint8Array, sig: Uint8Array): Promise<boolean> {
return await crypto.hashAndVerify(this._key, sig, data)
return crypto.hashAndVerify(this._key, sig, data)
}

marshal (): Uint8Array {
Expand Down Expand Up @@ -53,7 +53,7 @@ export class Secp256k1PrivateKey {
}

async sign (message: Uint8Array): Promise<Uint8Array> {
return await crypto.hashAndSign(this._key, message)
return crypto.hashAndSign(this._key, message)
}

get public (): Secp256k1PublicKey {
Expand Down Expand Up @@ -98,7 +98,7 @@ export class Secp256k1PrivateKey {
*/
async export (password: string, format = 'libp2p-key'): Promise<Multibase<'m'>> {
if (format === 'libp2p-key') {
return await exporter(this.bytes, password)
return exporter(this.bytes, password)
} else {
throw new CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT')
}
Expand Down
2 changes: 1 addition & 1 deletion src/pbkdf2.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CodeError } from '@libp2p/interfaces/errors'
// @ts-expect-error types are missing
import forgePbkdf2 from 'node-forge/lib/pbkdf2.js'
// @ts-expect-error types are missing
import forgeUtil from 'node-forge/lib/util.js'
import { CodeError } from '@libp2p/interfaces/errors'

/**
* Maps an IPFS hash name to its node-forge equivalent.
Expand Down
2 changes: 1 addition & 1 deletion src/random-bytes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { utils } from '@noble/secp256k1'
import { CodeError } from '@libp2p/interfaces/errors'
import { utils } from '@noble/secp256k1'

export default function randomBytes (length: number): Uint8Array {
if (isNaN(length) || length <= 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'node-forge/lib/util.js'
import 'node-forge/lib/jsbn.js'
// @ts-expect-error types are missing
import forge from 'node-forge/lib/forge.js'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'

export function bigIntegerToUintBase64url (num: { abs: () => any }, len?: number): string {
// Call `.abs()` to convert to unsigned
Expand Down
Loading

0 comments on commit f0b4c06

Please sign in to comment.