@@ -4,7 +4,7 @@ import * as assert from 'power-assert';
4
4
describe ( 'jwk-thumbprint' , ( ) => {
5
5
it ( 'should return the same thumbprint as an example in RFC7638' , ( ) => {
6
6
// (from: https://tools.ietf.org/html/rfc7638#section-3.1)
7
- const jwk : JsonWebKey & { kty : "RSA" , kid : string } = {
7
+ const jwk : JsonWebKey & { kty : "RSA" , kid : string } = {
8
8
"kty" : "RSA" ,
9
9
"n" : "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw" ,
10
10
"e" : "AQAB" ,
@@ -32,7 +32,7 @@ describe('jwk-thumbprint', () => {
32
32
// NOTE: The return-type must not be undefined
33
33
const actual : Uint8Array = jwkThumbprint ( jwk , "SHA-256" ) ;
34
34
// NOTE: This expectation is also on https://tools.ietf.org/html/rfc7638#section-3.1
35
- const expect = new Uint8Array ( expectNumbers ) ;
35
+ const expect = new Uint8Array ( expectNumbers ) ;
36
36
assert . deepStrictEqual ( actual , expect ) ;
37
37
}
38
38
@@ -44,4 +44,31 @@ describe('jwk-thumbprint', () => {
44
44
assert . deepStrictEqual ( actual , expect ) ;
45
45
}
46
46
} ) ;
47
+
48
+ it ( 'should return symmetric key thumbprint' , ( ) => {
49
+ const jwk : JsonWebKey & { kty : "oct" } = {
50
+ "alg" : "A128GCM" ,
51
+ "ext" : true ,
52
+ "k" : "9wcPr5BVF6hku5Fx3IrejQ" ,
53
+ "key_ops" : [ "encrypt" , "decrypt" ] ,
54
+ "kty" : "oct"
55
+ } ;
56
+
57
+ // NOTE: The return-type must not be undefined
58
+ const actual : string = jwkThumbprintByEncoding ( jwk , "SHA-256" , 'base64url' ) ;
59
+ // NOTE: This expectation is calculated by a Ruby library, 'json/jwt'
60
+ //
61
+ // require 'json/jwt'
62
+ //
63
+ // jwk = JSON::JWK.new ({
64
+ // "alg": "A128GCM",
65
+ // "ext": true,
66
+ // "k": "9wcPr5BVF6hku5Fx3IrejQ",
67
+ // "key_ops": ["encrypt", "decrypt"],
68
+ // "kty": "oct"
69
+ // })
70
+ // puts(jwk.thumbprint)
71
+ const expect = "O0ohsAio8Tj1lGR2SoX3Xa90quibp6j3vSe71e0LXRY" ;
72
+ assert . deepStrictEqual ( actual , expect ) ;
73
+ } ) ;
47
74
} ) ;
0 commit comments