jwk-thumbprint
JWK Thumbprint for JavaScript/TypeScript on both Web Browser and Node.js
Installation
npm i -S jwk-thumbprint
Usage
Here is an usage to reproduce the example in RFC7638 3.1.
// TypeScript// (Remove types to use it in JavaScript) ; ; console.logjwkThumbprintmyJwk, 'SHA-256';// => new Uint8Array([55, 54, 203, 177, 120, 124, 184, 48, 156, 119, 238, 140, 55, 5, 197, 225, 111, 251, 158, 133, 151, 21, 144, 31, 30, 76, 89, 177, 17, 130, 245, 123])
Thumbprints in number array, hex and base64url encodings
First, import the following.
;
You can get different encodings by 'number'
, 'hex'
, 'base64url'
or 'uint8array'
in type-safe way. The return types are properly typed by the encodings.
;console.logthumbprint// => 55, 54, 203, 177, 120, 124, 184, 48, 156, 119, 238, 140, 55, 5, 197, 225, 111, 251, 158, 133, 151, 21, 144, 31, 30, 76, 89, 177, 17, 130, 245, 123]
;console.logthumbprint// => 3736cbb1787cb8309c77ee8c3705c5e16ffb9e859715901f1e4c59b11182f57b
;console.logthumbprint// => NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs";
;console.logthumbprint// => new Uint8Array([55, 54, 203, 177, 120, 124, 184, 48, 156, 119, 238, 140, 55, 5, 197, 225, 111, 251, 158, 133, 151, 21, 144, 31, 30, 76, 89, 177, 17, 130, 245, 123])