From 46eb7edb8027e40189723dec04e1e28d93a26804 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 1 Mar 2019 19:42:10 +0200 Subject: [PATCH] refactor: mention thumbprint rather then kid in ref oct key thumbprint --- lib/jwk/key/ec.js | 2 ++ lib/jwk/key/oct.js | 4 +++- lib/jwk/key/okp.js | 2 ++ lib/jwk/key/rsa.js | 2 ++ test/jwk/oct.test.js | 2 +- 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/jwk/key/ec.js b/lib/jwk/key/ec.js index dfaf498156..7ba0a5446f 100644 --- a/lib/jwk/key/ec.js +++ b/lib/jwk/key/ec.js @@ -50,6 +50,8 @@ class ECKey extends Key { return EC_PRIVATE } + // https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys no need for any special + // JSON.stringify handling in V8 [THUMBPRINT_MATERIAL] () { return { crv: this.crv, kty: 'EC', x: this.x, y: this.y } } diff --git a/lib/jwk/key/oct.js b/lib/jwk/key/oct.js index 0e5d21e163..b2aeb8269f 100644 --- a/lib/jwk/key/oct.js +++ b/lib/jwk/key/oct.js @@ -60,9 +60,11 @@ class OctKey extends Key { return OCT_PRIVATE } + // https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys no need for any special + // JSON.stringify handling in V8 [THUMBPRINT_MATERIAL] () { if (!this[KEYOBJECT]) { - throw new TypeError('reference "oct" keys without "k" cannot have their "kid" calculated') + throw new TypeError('reference "oct" keys without "k" cannot have their thumbprint calculated') } return { k: this.k, kty: 'oct' } } diff --git a/lib/jwk/key/okp.js b/lib/jwk/key/okp.js index 54498f1afd..6f2810c0e9 100644 --- a/lib/jwk/key/okp.js +++ b/lib/jwk/key/okp.js @@ -38,6 +38,8 @@ class OKPKey extends Key { return OKP_PRIVATE } + // https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys no need for any special + // JSON.stringify handling in V8 [THUMBPRINT_MATERIAL] () { return { crv: this.crv, kty: 'OKP', x: this.x } } diff --git a/lib/jwk/key/rsa.js b/lib/jwk/key/rsa.js index 5134aac0b0..9d161f7e73 100644 --- a/lib/jwk/key/rsa.js +++ b/lib/jwk/key/rsa.js @@ -75,6 +75,8 @@ class RSAKey extends Key { return RSA_PRIVATE } + // https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys no need for any special + // JSON.stringify handling in V8 [THUMBPRINT_MATERIAL] () { return { e: this.e, kty: 'RSA', n: this.n } } diff --git a/test/jwk/oct.test.js b/test/jwk/oct.test.js index 48c328d701..01244fbe0e 100644 --- a/test/jwk/oct.test.js +++ b/test/jwk/oct.test.js @@ -136,7 +136,7 @@ test('they may be imported from (no kid)', t => { t.deepEqual([...key.algorithms()], []) t.throws(() => { key.kid // eslint-disable-line no-unused-expressions - }, { instanceOf: TypeError, message: 'reference "oct" keys without "k" cannot have their "kid" calculated' }) + }, { instanceOf: TypeError, message: 'reference "oct" keys without "k" cannot have their thumbprint calculated' }) }) test('they may be imported so long as there was no k', t => {