@@ -29,6 +29,7 @@ I can continue maintaining it and adding new features carefree. You may also don
2929 - [ key.alg] ( #keyalg )
3030 - [ key.use] ( #keyuse )
3131 - [ key.kid] ( #keykid )
32+ - [ key.key_ops] ( #keykey_ops )
3233 - [ key.thumbprint] ( #keythumbprint )
3334 - [ key.type] ( #keytype )
3435 - [ key.public] ( #keypublic )
@@ -116,6 +117,16 @@ defined in [RFC7638][spec-thumbprint].
116117
117118---
118119
120+ #### ` key.key_ops `
121+
122+ Returns the key's JWK Key Operations Parameter if set. If set the key can only be used for the
123+ specified operations. Supported values are 'sign', 'verify', 'encrypt', 'decrypt', 'wrapKey',
124+ 'unwrapKey' and 'deriveKey'.
125+
126+ - ` string[] `
127+
128+ ---
129+
119130#### ` key.thumbprint `
120131
121132Returns the key's JWK Key thumbprint calculated using the method defined in [ RFC7638] [ spec-thumbprint ] .
@@ -415,11 +426,15 @@ Securely generates a new RSA, EC, OKP or oct key.
415426- ` crvOrSize ` : ` <number> ` &vert ; ` <string> ` key's bit size or in case of OKP and EC keys the curve
416427 ** Default:** 2048 for RSA, 'P-256' for EC, 'Ed25519' for OKP and 256 for oct.
417428- ` options ` : ` <Object> `
418- - ` alg ` : ` <string> ` option identifies the algorithm intended for use with the key.
429+ - ` alg ` : ` <string> ` Key Algorithm Parameter. It identifies the algorithm intended for use with the
430+ key.
419431 - ` kid ` : ` <string> ` Key ID Parameter. When not provided is computed using the method defined in
420- [ RFC7638] [ spec-thumbprint ]
421- - ` use ` : ` <string> ` option indicates whether the key is to be used for encrypting & decrypting
422- data or signing & verifying data. Must be 'sig' or 'enc'.
432+ [ RFC7638] [ spec-thumbprint ] .
433+ - ` use ` : ` <string> ` Public Key Use Parameter. Indicates whether the key is to be used for
434+ encrypting & decrypting data or signing & verifying data. Must be 'sig' or 'enc'.
435+ - ` key_ops ` : ` string[] ` Key Operations Parameter. If set, the key can only be used for the
436+ specified operations. Supported values are 'sign', 'verify', 'encrypt', 'decrypt', 'wrapKey',
437+ 'unwrapKey' and 'deriveKey'.
423438- ` private ` : ` <boolean> ` ** Default** 'true'. Is the resulting key private or public (when
424439 asymmetrical)
425440- Returns: ` Promise<JWK.RSAKey> ` &vert ; ` Promise<JWK.ECKey> ` &vert ; ` Promise<JWK.OKPKey> ` &vert ; ` Promise<JWK.OctKey> `
@@ -454,11 +469,15 @@ Synchronous version of `JWK.generate()`
454469- ` crvOrSize ` : ` <number> ` &vert ; ` <string> ` key's bit size or in case of OKP and EC keys the curve.
455470 ** Default:** 2048 for RSA, 'P-256' for EC, 'Ed25519' for OKP and 256 for oct.
456471- ` options ` : ` <Object> `
457- - ` alg ` : ` <string> ` option identifies the algorithm intended for use with the key.
458- - ` use ` : ` <string> ` option indicates whether the key is to be used for encrypting & decrypting
459- data or signing & verifying data. Must be 'sig' or 'enc'.
472+ - ` alg ` : ` <string> ` Key Algorithm Parameter. It identifies the algorithm intended for use with the
473+ key.
460474 - ` kid ` : ` <string> ` Key ID Parameter. When not provided is computed using the method defined in
461- [ RFC7638] [ spec-thumbprint ]
475+ [ RFC7638] [ spec-thumbprint ] .
476+ - ` use ` : ` <string> ` Public Key Use Parameter. Indicates whether the key is to be used for
477+ encrypting & decrypting data or signing & verifying data. Must be 'sig' or 'enc'.
478+ - ` key_ops ` : ` string[] ` Key Operations Parameter. If set, the key can only be used for the
479+ specified operations. Supported values are 'sign', 'verify', 'encrypt', 'decrypt', 'wrapKey',
480+ 'unwrapKey' and 'deriveKey'.
462481- ` private ` : ` <boolean> ` ** Default** 'true'. Is the resulting key private or public (when
463482 asymmetrical)
464483- Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` &vert ; ` <JWK.OctKey> `
@@ -551,10 +570,12 @@ specified by the parameters are first.
551570- ` parameters ` : ` <Object> `
552571 - ` kty ` : ` <string> ` Key Type to filter for.
553572 - ` alg ` : ` <string> ` Key supported algorithm to filter for.
554- - ` use ` : ` <string> ` Key use to filter for.
555573 - ` kid ` : ` <string> ` Key ID to filter for.
556- - ` operation ` : ` <string> ` Further specify the operation a given alg must be valid for. Must be one
557- of 'encrypt', 'decrypt', 'sign', 'verify', 'wrapKey', 'unwrapKey'
574+ - ` use ` : ` <string> ` Filter keys with the specified use defined. Keys missing "use" parameter will
575+ be matched but rank lower then ones with an exact match.
576+ - ` key_ops ` : ` string[] ` Filter keys with specified key_ops defined (if key_ops is defined on the
577+ key). Keys missing "key_ops" parameter will be matched but rank lower then ones with matching
578+ entries.
558579- Returns: ` <Key[]> ` Array of key instances or an empty array when none are matching the parameters.
559580
560581---
@@ -567,10 +588,12 @@ parameters is returned.
567588- ` parameters ` : ` <Object> `
568589 - ` kty ` : ` <string> ` Key Type to filter for.
569590 - ` alg ` : ` <string> ` Key supported algorithm to filter for.
570- - ` use ` : ` <string> ` Key use to filter for.
571591 - ` kid ` : ` <string> ` Key ID to filter for.
572- - ` operation ` : ` <string> ` Further specify the operation a given alg must be valid for. Must be one
573- of 'encrypt', 'decrypt', 'sign', 'verify', 'wrapKey', 'unwrapKey'
592+ - ` use ` : ` <string> ` Filter keys with the specified use defined. Keys missing "use" parameter will
593+ be matched but rank lower then ones with an exact match.
594+ - ` key_ops ` : ` string[] ` Filter keys with specified key_ops defined (if key_ops is defined on the
595+ key). Keys missing "key_ops" parameter will be matched but rank lower then ones with matching
596+ entries.
574597- Returns: ` <JWK.RSAKey> ` &vert ; ` <JWK.ECKey> ` &vert ; ` <JWK.OKPKey> ` &vert ; ` <JWK.OctKey> ` &vert ; ` <undefined> `
575598
576599---
@@ -1206,6 +1229,7 @@ Verifies the provided JWE in either serialization with a given `<JWK.Key>` or `<
12061229- [ Class: < ; JWEDecryptionFailed> ; ] ( #class-jwedecryptionfailed )
12071230- [ Class: < ; JWEInvalid> ; ] ( #class-jweinvalid )
12081231- [ Class: < ; JWKImportFailed> ; ] ( #class-jwkimportfailed )
1232+ - [ Class: < ; JWKKeyInvalid> ; ] ( #class-jwkkeyinvalid )
12091233- [ Class: < ; JWKKeySupport> ; ] ( #class-jwkkeysupport )
12101234- [ Class: < ; JWKSNoMatchingKey> ; ] ( #class-jwksnomatchingkey )
12111235- [ Class: < ; JWSInvalid> ; ] ( #class-jwsinvalid )
@@ -1311,6 +1335,16 @@ if (err.code === 'ERR_JWK_IMPORT_FAILED') {
13111335}
13121336```
13131337
1338+ #### Class: ` JWKKeyInvalid `
1339+
1340+ Thrown when key's parameters are invalid, e.g. key_ops and use values are inconsistent.
1341+
1342+ ``` js
1343+ if (err .code === ' ERR_JWK_INVALID' ) {
1344+ // ...
1345+ }
1346+ ```
1347+
13141348#### Class: ` JWKKeySupport `
13151349
13161350Thrown when a key does not support the request algorithm.
0 commit comments