Skip to content

Commit f0b4c06

Browse files
deps(dev): bump aegir from 38.1.8 to 39.0.5 (libp2p#320)
* 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] <[email protected]> * chore: fix linting and deps * chore: fix build --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: achingbrain <[email protected]>
1 parent b8fa2d3 commit f0b4c06

31 files changed

+71
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dist
66
node_modules
77
package-lock.json
88
yarn.lock
9+
.vscode

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,9 @@
192192
},
193193
"devDependencies": {
194194
"@types/mocha": "^10.0.0",
195-
"aegir": "^38.1.2",
195+
"aegir": "^39.0.5",
196196
"benchmark": "^2.1.4",
197-
"protons": "^7.0.2",
198-
"util": "^0.12.5"
197+
"protons": "^7.0.2"
199198
},
200199
"browser": {
201200
"./dist/src/aes/ciphers.js": "./dist/src/aes/ciphers-browser.js",

src/aes/ciphers-browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import 'node-forge/lib/aes.js'
33
// @ts-expect-error types are missing
44
import forge from 'node-forge/lib/forge.js'
5-
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
65
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
6+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
77

88
export interface Cipher {
99
update: (data: Uint8Array) => Uint8Array

src/aes/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as ciphers from './ciphers.js'
21
import { cipherMode } from './cipher-mode.js'
2+
import * as ciphers from './ciphers.js'
33

44
export interface AESCipher {
55
encrypt: (data: Uint8Array) => Promise<Uint8Array>

src/ciphers/aes-gcm.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function create (opts?: CreateOptions): AESCipher {
5252
cryptoKey = await crypto.subtle.importKey('jwk', derivedEmptyPasswordKey, { name: 'AES-GCM' }, true, ['encrypt'])
5353
}
5454
} else {
55-
// Derive a key using PBKDF2.
55+
// Derive a key using PBKDF2.
5656
const deriveParams = { name: 'PBKDF2', salt, iterations, hash: { name: digest } }
5757
const rawKey = await crypto.subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveKey'])
5858
cryptoKey = await crypto.subtle.deriveKey(deriveParams, rawKey, { name: algorithm, length: keyLength }, true, ['encrypt'])

src/ciphers/aes-gcm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function create (opts?: CreateOptions): AESCipher {
9090
const key = crypto.pbkdf2Sync(password, salt, iterations, keyLength, digest)
9191

9292
// Decrypt and return result.
93-
return await decryptWithKey(ciphertextAndNonce, key)
93+
return decryptWithKey(ciphertextAndNonce, key)
9494
}
9595

9696
const cipher: AESCipher = {

src/hmac/index-browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function create (hashType: 'SHA1' | 'SHA256' | 'SHA512', secret: Ui
2828

2929
return {
3030
async digest (data: Uint8Array) { // eslint-disable-line require-await
31-
return await sign(key, data)
31+
return sign(key, data)
3232
},
3333
length: lengths[hashType]
3434
}

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as hmac from './hmac/index.js'
21
import * as aes from './aes/index.js'
2+
import * as hmac from './hmac/index.js'
33
import * as keys from './keys/index.js'
4-
import randomBytes from './random-bytes.js'
54
import pbkdf2 from './pbkdf2.js'
5+
import randomBytes from './random-bytes.js'
66

77
export { aes }
88
export { hmac }

src/keys/ecdh-browser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { CodeError } from '@libp2p/interfaces/errors'
2-
import webcrypto from '../webcrypto.js'
3-
import { base64urlToBuffer } from '../util.js'
4-
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
52
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
63
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
4+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
5+
import { base64urlToBuffer } from '../util.js'
6+
import webcrypto from '../webcrypto.js'
77
import type { ECDHKey, ECDHKeyPair, JWKEncodedPrivateKey, JWKEncodedPublicKey } from './interface.js'
88

99
const bits = {

src/keys/ed25519-browser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export async function generateKeyFromSeed (seed: Uint8Array): Promise<Uint8Array
4747
export async function hashAndSign (privateKey: Uint8Array, msg: Uint8Array): Promise<Uint8Array> {
4848
const privateKeyRaw = privateKey.subarray(0, KEYS_BYTE_LENGTH)
4949

50-
return await ed.sign(msg, privateKeyRaw)
50+
return ed.sign(msg, privateKeyRaw)
5151
}
5252

5353
export async function hashAndVerify (publicKey: Uint8Array, sig: Uint8Array, msg: Uint8Array): Promise<boolean> {
54-
return await ed.verify(sig, msg, publicKey)
54+
return ed.verify(sig, msg, publicKey)
5555
}
5656

5757
function concatKeys (privateKeyRaw: Uint8Array, publicKey: Uint8Array): Uint8Array {

src/keys/ed25519-class.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { CodeError } from '@libp2p/interfaces/errors'
2-
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
3-
import { sha256 } from 'multiformats/hashes/sha2'
42
import { base58btc } from 'multiformats/bases/base58'
53
import { identity } from 'multiformats/hashes/identity'
4+
import { sha256 } from 'multiformats/hashes/sha2'
5+
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
66
import * as crypto from './ed25519.js'
7-
import * as pbm from './keys.js'
87
import { exporter } from './exporter.js'
8+
import * as pbm from './keys.js'
99
import type { Multibase } from 'multiformats'
1010

1111
export class Ed25519PublicKey {
@@ -16,7 +16,7 @@ export class Ed25519PublicKey {
1616
}
1717

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

2222
marshal (): Uint8Array {
@@ -53,7 +53,7 @@ export class Ed25519PrivateKey {
5353
}
5454

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

5959
get public (): Ed25519PublicKey {
@@ -100,7 +100,7 @@ export class Ed25519PrivateKey {
100100
*/
101101
async export (password: string, format = 'libp2p-key'): Promise<Multibase<'m'>> {
102102
if (format === 'libp2p-key') {
103-
return await exporter(this.bytes, password)
103+
return exporter(this.bytes, password)
104104
} else {
105105
throw new CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT')
106106
}

src/keys/ed25519.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import crypto from 'crypto'
22
import { promisify } from 'util'
3-
import { toString as uint8arrayToString } from 'uint8arrays/to-string'
43
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
4+
import { toString as uint8arrayToString } from 'uint8arrays/to-string'
55
import type { Uint8ArrayKeyPair } from './interface.js'
66

77
const keypair = promisify(crypto.generateKeyPair)

src/keys/exporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Multibase } from 'multiformats'
21
import { base64 } from 'multiformats/bases/base64'
32
import * as ciphers from '../ciphers/aes-gcm.js'
3+
import type { Multibase } from 'multiformats'
44

55
/**
66
* Exports the given PrivateKey as a base64 encoded string.

src/keys/importer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import * as ciphers from '../ciphers/aes-gcm.js'
99
export async function importer (privateKey: string, password: string): Promise<Uint8Array> {
1010
const encryptedKey = base64.decode(privateKey)
1111
const cipher = ciphers.create()
12-
return await cipher.decrypt(encryptedKey, password)
12+
return cipher.decrypt(encryptedKey, password)
1313
}

src/keys/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import * as keysPBM from './keys.js'
21
import 'node-forge/lib/asn1.js'
32
import 'node-forge/lib/pbe.js'
3+
import { CodeError } from '@libp2p/interfaces/errors'
44
// @ts-expect-error types are missing
55
import forge from 'node-forge/lib/forge.js'
6-
import { CodeError } from '@libp2p/interfaces/errors'
76
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
8-
import { keyStretcher } from './key-stretcher.js'
7+
import * as Ed25519 from './ed25519-class.js'
98
import generateEphemeralKeyPair from './ephemeral-keys.js'
109
import { importer } from './importer.js'
10+
import { keyStretcher } from './key-stretcher.js'
11+
import * as keysPBM from './keys.js'
1112
import * as RSA from './rsa-class.js'
12-
import * as Ed25519 from './ed25519-class.js'
1313
import * as Secp256k1 from './secp256k1-class.js'
1414
import type { PrivateKey, PublicKey } from '@libp2p/interface-keys'
1515

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

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

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

55-
return await Ed25519.generateKeyPairFromSeed(seed)
55+
return Ed25519.generateKeyPairFromSeed(seed)
5656
}
5757

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

8989
switch (decoded.Type) {
9090
case keysPBM.KeyType.RSA:
91-
return await supportedKeys.rsa.unmarshalRsaPrivateKey(data)
91+
return supportedKeys.rsa.unmarshalRsaPrivateKey(data)
9292
case keysPBM.KeyType.Ed25519:
9393
return supportedKeys.ed25519.unmarshalEd25519PrivateKey(data)
9494
case keysPBM.KeyType.Secp256k1:
@@ -125,5 +125,5 @@ export async function importKey (encryptedKey: string, password: string): Promis
125125
}
126126
let der = forge.asn1.toDer(forge.pki.privateKeyToAsn1(key))
127127
der = uint8ArrayFromString(der.getBytes(), 'ascii')
128-
return await supportedKeys.rsa.unmarshalRsaPrivateKey(der)
128+
return supportedKeys.rsa.unmarshalRsaPrivateKey(der)
129129
}

src/keys/rsa-browser.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import webcrypto from '../webcrypto.js'
2-
import randomBytes from '../random-bytes.js'
3-
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
1+
import { CodeError } from '@libp2p/interfaces/errors'
42
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
5-
import * as utils from './rsa-utils.js'
3+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
4+
import randomBytes from '../random-bytes.js'
5+
import webcrypto from '../webcrypto.js'
66
import { jwk2pub, jwk2priv } from './jwk2pem.js'
7-
import { CodeError } from '@libp2p/interfaces/errors'
7+
import * as utils from './rsa-utils.js'
88
import type { JWKKeyPair } from './interface.js'
99

1010
export { utils }
@@ -93,7 +93,7 @@ export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint
9393
['verify']
9494
)
9595

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

109-
return await Promise.all([
109+
return Promise.all([
110110
webcrypto.get().subtle.exportKey('jwk', pair.privateKey),
111111
webcrypto.get().subtle.exportKey('jwk', pair.publicKey)
112112
])
113113
}
114114

115115
async function derivePublicFromPrivate (jwKey: JsonWebKey): Promise<CryptoKey> {
116-
return await webcrypto.get().subtle.importKey(
116+
return webcrypto.get().subtle.importKey(
117117
'jwk',
118118
{
119119
kty: jwKey.kty,

src/keys/rsa-class.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
import { sha256 } from 'multiformats/hashes/sha2'
32
import { CodeError } from '@libp2p/interfaces/errors'
4-
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
5-
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
6-
import 'node-forge/lib/sha512.js'
3+
import { sha256 } from 'multiformats/hashes/sha2'
74
// @ts-expect-error types are missing
85
import forge from 'node-forge/lib/forge.js'
9-
import * as crypto from './rsa.js'
10-
import * as pbm from './keys.js'
6+
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
7+
import 'node-forge/lib/sha512.js'
8+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
119
import { exporter } from './exporter.js'
10+
import * as pbm from './keys.js'
11+
import * as crypto from './rsa.js'
1212
import type { Multibase } from 'multiformats'
1313

1414
export class RsaPublicKey {
@@ -19,7 +19,7 @@ export class RsaPublicKey {
1919
}
2020

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

2525
marshal (): Uint8Array {
@@ -62,7 +62,7 @@ export class RsaPrivateKey {
6262
}
6363

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

6868
get public (): RsaPublicKey {
@@ -127,7 +127,7 @@ export class RsaPrivateKey {
127127
}
128128
return forge.pki.encryptRsaPrivateKey(privateKey, password, options)
129129
} else if (format === 'libp2p-key') {
130-
return await exporter(this.bytes, password)
130+
return exporter(this.bytes, password)
131131
} else {
132132
throw new CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT')
133133
}

src/keys/rsa-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'node-forge/lib/asn1.js'
22
import 'node-forge/lib/rsa.js'
3+
import { CodeError } from '@libp2p/interfaces/errors'
34
// @ts-expect-error types are missing
45
import forge from 'node-forge/lib/forge.js'
5-
import { bigIntegerToUintBase64url, base64urlToBigInteger } from './../util.js'
66
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
77
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
8-
import { CodeError } from '@libp2p/interfaces/errors'
8+
import { bigIntegerToUintBase64url, base64urlToBigInteger } from './../util.js'
99

1010
// Convert a PKCS#1 in ASN1 DER format to a JWK key
1111
export function pkcs1ToJwk (bytes: Uint8Array): JsonWebKey {

src/keys/secp256k1-class.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { sha256 } from 'multiformats/hashes/sha2'
21
import { CodeError } from '@libp2p/interfaces/errors'
2+
import { sha256 } from 'multiformats/hashes/sha2'
33
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
44
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
5-
import * as crypto from './secp256k1.js'
65
import { exporter } from './exporter.js'
76
import * as keysProtobuf from './keys.js'
7+
import * as crypto from './secp256k1.js'
88
import type { Multibase } from 'multiformats'
99

1010
export class Secp256k1PublicKey {
@@ -16,7 +16,7 @@ export class Secp256k1PublicKey {
1616
}
1717

1818
async verify (data: Uint8Array, sig: Uint8Array): Promise<boolean> {
19-
return await crypto.hashAndVerify(this._key, sig, data)
19+
return crypto.hashAndVerify(this._key, sig, data)
2020
}
2121

2222
marshal (): Uint8Array {
@@ -53,7 +53,7 @@ export class Secp256k1PrivateKey {
5353
}
5454

5555
async sign (message: Uint8Array): Promise<Uint8Array> {
56-
return await crypto.hashAndSign(this._key, message)
56+
return crypto.hashAndSign(this._key, message)
5757
}
5858

5959
get public (): Secp256k1PublicKey {
@@ -98,7 +98,7 @@ export class Secp256k1PrivateKey {
9898
*/
9999
async export (password: string, format = 'libp2p-key'): Promise<Multibase<'m'>> {
100100
if (format === 'libp2p-key') {
101-
return await exporter(this.bytes, password)
101+
return exporter(this.bytes, password)
102102
} else {
103103
throw new CodeError(`export format '${format}' is not supported`, 'ERR_INVALID_EXPORT_FORMAT')
104104
}

src/pbkdf2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { CodeError } from '@libp2p/interfaces/errors'
12
// @ts-expect-error types are missing
23
import forgePbkdf2 from 'node-forge/lib/pbkdf2.js'
34
// @ts-expect-error types are missing
45
import forgeUtil from 'node-forge/lib/util.js'
5-
import { CodeError } from '@libp2p/interfaces/errors'
66

77
/**
88
* Maps an IPFS hash name to its node-forge equivalent.

src/random-bytes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { utils } from '@noble/secp256k1'
21
import { CodeError } from '@libp2p/interfaces/errors'
2+
import { utils } from '@noble/secp256k1'
33

44
export default function randomBytes (length: number): Uint8Array {
55
if (isNaN(length) || length <= 0) {

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import 'node-forge/lib/util.js'
22
import 'node-forge/lib/jsbn.js'
33
// @ts-expect-error types are missing
44
import forge from 'node-forge/lib/forge.js'
5+
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
56
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
67
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
7-
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
88

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

0 commit comments

Comments
 (0)