Skip to content

Commit

Permalink
refactor: mention thumbprint rather then kid in ref oct key thumbprint
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Mar 1, 2019
1 parent c30e936 commit 46eb7ed
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/jwk/key/ec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down
4 changes: 3 additions & 1 deletion lib/jwk/key/oct.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
Expand Down
2 changes: 2 additions & 0 deletions lib/jwk/key/okp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down
2 changes: 2 additions & 0 deletions lib/jwk/key/rsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down
2 changes: 1 addition & 1 deletion test/jwk/oct.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 46eb7ed

Please sign in to comment.