You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A JavaScript implementation of the JSON Object Signing and Encryption (JOSE) for current web browsers and node.js-based servers. This library implements (wherever possible) all algorithms, formats, and options in [JWS](https://tools.ietf.org/html/rfc7515"Jones, M., J. Bradley and N. Sakimura, 'JSON Web Signature (JWS)' RFC 7515, May 2015"), [JWE](https://tools.ietf.org/html/rfc7516"Jones, M. and J. Hildebrand 'JSON Web Encryption (JWE)', RFC 7516, May 2015"), [JWK](https://tools.ietf.org/html/rfc7517"Jones, M., 'JSON Web Key (JWK)', RFC 7517, May 2015"), and [JWA](https://tools.ietf.org/html/rfc7518"Jones, M., 'JSON Web Algorithms (JWA)', RFC 7518, May 2015") and uses native cryptographic support ([WebCrypto API](http://www.w3.org/TR/WebCryptoAPI/) or node.js' "[crypto](https://nodejs.org/api/crypto.html)" module) where feasible.
6
7
@@ -19,11 +20,15 @@ A JavaScript implementation of the JSON Object Signing and Encryption (JOSE) for
19
20
-[Importing and Exporting a Single Key](#importing-and-exporting-a-single-key)
20
21
-[Obtaining a Key's Thumbprint](#obtaining-a-keys-thumbprint)
21
22
-[Signatures](#signatures)
23
+
-[Keys Used for Signing and Verifying](#keys-used-for-signing-and-verifying)
@@ -293,6 +298,19 @@ When importing or generating a key that does not have a "kid" defined, a
293
298
294
299
## Signatures ##
295
300
301
+
### Keys Used for Signing and Verifying ###
302
+
303
+
When signing content, the key is expected to meet one of the following:
304
+
305
+
1. A secret key (e.g, `"kty":"oct"`)
306
+
2. The **private** key from a PKI (`"kty":"EC"` or `"kty":"RSA"`) key pair
307
+
308
+
When verifying content, the key is expected to meet one of the following:
309
+
310
+
1. A secret key (e.g, `"kty":"oct"`)
311
+
2. The **public** key from a PKI (`"kty":"EC"` or `"kty":"RSA"`) key pair
312
+
313
+
296
314
### Signing Content ###
297
315
298
316
At its simplest, to create a JWS:
@@ -418,7 +436,7 @@ The key can be embedded using either 'jwk' or 'x5c', and can be located in eithe
418
436
419
437
To accept 'crit' field members, add the `handlers` member to the options Object. The `handlers` member is itself an Object, where its member names are the `crit` header member, and the value is one of:
420
438
421
-
*`Boolean`: accepts (if `true`) -- or rejects (if `false`) -- the JWS if the member is present.
439
+
*`Boolean`: accepts (if `true`) -- or rejects (if `false`) -- the JWS if the member is present.
422
440
*`Function`: takes the JWE decrypt output (just prior to decrypting) and returns a Promise for the processing of the member.
423
441
*`Object`: An object with the following `Function` members:
424
442
* "prepare" -- takes the JWE decrypt output (just prior to decrypting) and returns a Promise for the processing of the member.
// * header: the combined 'protected' and 'unprotected' header members
567
-
// * protected: an array of the member names from the "protected" member
599
+
// * protected: an array of the member names from the "protected" member
568
600
// * key: Key used to decrypt
569
601
// * payload: Buffer of the decrypted content
570
602
// * plaintext: Buffer of the decrypted content (alternate)
@@ -585,7 +617,7 @@ jose.JWE.createDecrypt(key).
585
617
586
618
To accept 'crit' field members, add the `handlers` member to the options Object. The `handlers` member is itself an Object, where its member names are the `crit` header member, and the value is one of:
587
619
588
-
*`Boolean`: accepts (if `true`) -- or rejects (if `false`) -- the JWE if the member is present.
620
+
*`Boolean`: accepts (if `true`) -- or rejects (if `false`) -- the JWE if the member is present.
589
621
*`Function`: takes the JWE decrypt output (just prior to decrypting) and returns a Promise for the processing of the member.
590
622
*`Object`: An object with the following `Function` members:
591
623
* "prepare" -- takes the JWE decrypt output (just prior to decrypting) and returns a Promise for the processing of the member.
0 commit comments