Skip to content

Commit

Permalink
chore: update dev deps, code lint
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jul 21, 2019
1 parent c77c794 commit 418e311
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 35 deletions.
1 change: 1 addition & 0 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class JOSEMultiError extends JOSEError {
}
this.#errors = errors
}

* [Symbol.iterator] () {
for (const error of this.#errors) {
yield error
Expand Down
6 changes: 3 additions & 3 deletions lib/help/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports.KEYLENGTHS = {
'A128CBC-HS256': 256,
'A192CBC-HS384': 384,
'A256CBC-HS512': 512,
'A128GCM': 128,
'A192GCM': 192,
'A256GCM': 256
A128GCM: 128,
A192GCM: 192,
A256GCM: 256
}
4 changes: 2 additions & 2 deletions lib/help/ecdsa_signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports.derToJose = (signature, alg) => {

const sPadding = paramBytes - sLength

let dst = Buffer.allocUnsafe(rPadding + rLength + sPadding + sLength)
const dst = Buffer.allocUnsafe(rPadding + rLength + sPadding + sLength)

for (offset = 0; offset < rPadding; ++offset) {
dst[offset] = 0
Expand Down Expand Up @@ -144,7 +144,7 @@ module.exports.joseToDer = (signature, alg) => {

const shortLength = rsBytes < MAX_OCTET

let dst = Buffer.allocUnsafe((shortLength ? 2 : 3) + rsBytes)
const dst = Buffer.allocUnsafe((shortLength ? 2 : 3) + rsBytes)

let offset = 0
dst[offset++] = ENCODED_TAG_SEQ
Expand Down
12 changes: 6 additions & 6 deletions lib/help/generate_iv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const { randomBytes } = require('crypto')

const IVLENGTHS = {
'A128CBC-HS256': 128 / 8,
'A128GCM': 96 / 8,
'A128GCMKW': 96 / 8,
A128GCM: 96 / 8,
A128GCMKW: 96 / 8,
'A192CBC-HS384': 128 / 8,
'A192GCM': 96 / 8,
'A192GCMKW': 96 / 8,
A192GCM: 96 / 8,
A192GCMKW: 96 / 8,
'A256CBC-HS512': 128 / 8,
'A256GCM': 96 / 8,
'A256GCMKW': 96 / 8
A256GCM: 96 / 8,
A256GCMKW: 96 / 8
}

module.exports = alg => randomBytes(IVLENGTHS[alg])
10 changes: 5 additions & 5 deletions lib/help/rsa_primes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const eGcdX = (a, b) => {
let v = ZERO

while (a !== ZERO) {
let q = b / a
let r = b % a
let m = x - (u * q)
let n = y - (v * q)
const q = b / a
const r = b % a
const m = x - (u * q)
const n = y - (v * q)
b = a
a = r
x = u
Expand All @@ -49,7 +49,7 @@ const gcd = (a, b) => {
b >>= ONE
}
if (a > b) {
let x = a
const x = a
a = b
b = x
}
Expand Down
7 changes: 6 additions & 1 deletion lib/jwe/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ const PROCESS_RECIPIENT = Symbol('PROCESS_RECIPIENT')

class Encrypt {
#aad

#cek

#unprotected

#protected

#cleartext

#recipients

constructor (cleartext, protectedHeader, unprotectedHeader, aad) {
Expand Down Expand Up @@ -86,7 +91,7 @@ class Encrypt {
}
const { key } = recipient

let enc = jweHeader.enc
const enc = jweHeader.enc
let alg = jweHeader.alg

if (alg === 'dir') {
Expand Down
2 changes: 2 additions & 0 deletions lib/jws/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const PROCESS_RECIPIENT = Symbol('PROCESS_RECIPIENT')

class Sign {
#b64

#payload

#recipients

constructor (payload) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
"asn1.js": "^5.1.1"
},
"devDependencies": {
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"ava": "^2.1.0",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"ava": "^2.2.0",
"babel-eslint": "^10.0.2",
"c8": "^5.0.1",
"husky": "^2.4.1",
"standard": "^12.0.1"
"husky": "^3.0.1",
"standard": "^13.1.0"
},
"engines": {
"node": ">=12.0.0"
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports.JWK = {
d: '_i_1Ac5oVmbBxGvEvOEFHMpzMXKZi8voUx8I3Gl6IxY'
},

'secp256k1': {
secp256k1: {
kty: 'EC',
crv: 'secp256k1',
x: 'VRaLqtMjg_JRaDzkbfit7zonkOGDZ42qbZyljhqsg3U',
Expand Down Expand Up @@ -96,27 +96,27 @@ module.exports.PEM = {
private: readFileSync(join(__dirname, 'rsa.key')),
public: readFileSync(join(__dirname, 'rsa.pem'))
},
'Ed25519': {
Ed25519: {
private: readFileSync(join(__dirname, 'Ed25519.key')),
public: readFileSync(join(__dirname, 'Ed25519.pem'))
},
'Ed448': {
Ed448: {
private: readFileSync(join(__dirname, 'Ed448.key')),
public: readFileSync(join(__dirname, 'Ed448.pem'))
},
'X25519': {
X25519: {
private: readFileSync(join(__dirname, 'X25519.key')),
public: readFileSync(join(__dirname, 'X25519.pem'))
},
'X448': {
X448: {
private: readFileSync(join(__dirname, 'X448.key')),
public: readFileSync(join(__dirname, 'X448.pem'))
},
'P-256': {
private: readFileSync(join(__dirname, 'P-256.key')),
public: readFileSync(join(__dirname, 'P-256.pem'))
},
'secp256k1': {
secp256k1: {
private: readFileSync(join(__dirname, 'secp256k1.key')),
public: readFileSync(join(__dirname, 'secp256k1.pem'))
},
Expand Down
6 changes: 3 additions & 3 deletions test/jwe/sanity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ test('JWE no alg/enc specified (multi recipient)', t => {

test('JWE no alg/enc specified (multi recipient) with per-recipient headers', t => {
const encrypt = new JWE.Encrypt('foo')
let k1 = generateSync('RSA', undefined, { kid: 'kid_1' })
const k1 = generateSync('RSA', undefined, { kid: 'kid_1' })
encrypt.recipient(k1, { kid: k1.kid })
let k2 = generateSync('EC', undefined, { kid: 'kid_2' })
const k2 = generateSync('EC', undefined, { kid: 'kid_2' })
encrypt.recipient(k2, { kid: k2.kid })
let k3 = generateSync('oct', 256, { kid: 'kid_3' })
const k3 = generateSync('oct', 256, { kid: 'kid_3' })
encrypt.recipient(k3, { kid: k3.kid })

const jwe = encrypt.encrypt('general')
Expand Down
2 changes: 1 addition & 1 deletion test/jwk/ec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('Unusable with unsupported curves', t => {

Object.entries({
'P-256': ['ES256', 'rDd6H6t9-nJUoz72nTpz8tInvypVWhE2iQoPznj8ZY8'],
'secp256k1': ['ES256K', 'kWx_DzFzKNHUQz1FkNzj8KmSRingv9EQQzdVY3td21w'],
secp256k1: ['ES256K', 'kWx_DzFzKNHUQz1FkNzj8KmSRingv9EQQzdVY3td21w'],
'P-384': ['ES384', '5gebayAhpztJCs4Pxo-z1hhsN0upoyG2NAoKpiiH2b0'],
'P-521': ['ES512', 'BQtkbSY3xgN4M2ZP3IHMLG7-Rp1L29teCMfNqgJHtTY']
}).forEach(([crv, [alg, kid]]) => {
Expand Down
6 changes: 3 additions & 3 deletions test/jws/sanity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ test('JWS no alg specified (multi recipient)', t => {

test('JWS no alg specified (multi recipient) with per-recipient protected headers', t => {
const sign = new JWS.Sign({})
let k1 = generateSync('RSA', undefined, { kid: 'kid_1' })
const k1 = generateSync('RSA', undefined, { kid: 'kid_1' })
sign.recipient(k1, { kid: k1.kid })
let k2 = generateSync('EC', undefined, { kid: 'kid_2' })
const k2 = generateSync('EC', undefined, { kid: 'kid_2' })
sign.recipient(k2, { kid: k2.kid })
let k3 = generateSync('oct', undefined, { kid: 'kid_3' })
const k3 = generateSync('oct', undefined, { kid: 'kid_3' })
sign.recipient(k3, { kid: k3.kid })

const jws = sign.sign('general')
Expand Down

0 comments on commit 418e311

Please sign in to comment.