Skip to content

Commit cd06359

Browse files
committed
docs: improve generate key/secret and import function descriptions
1 parent df99550 commit cd06359

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

docs/key/generate_secret/functions/generateSecret.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Generates a symmetric secret key for a given JWA algorithm identifier.
1010

1111
Note: The secret key is generated with `extractable` set to `false` by default.
1212

13+
Note: Because A128CBC-HS256, A192CBC-HS384, and A256CBC-HS512 secrets cannot be represented as
14+
[CryptoKey](https://developer.mozilla.org/docs/Web/API/CryptoKey) this method yields a [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) for them instead.
15+
1316
This function is exported (as a named export) from the main `'jose'` module entry point as well
1417
as from its subpath export `'jose/generate/secret'`.
1518

docs/key/generate_secret/interfaces/GenerateSecretOptions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ Secret generation function options.
1313
`optional` **extractable**: `boolean`
1414

1515
The value to use as [SubtleCrypto.generateKey](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) `extractable` argument. Default is false.
16+
17+
Note: Because A128CBC-HS256, A192CBC-HS384, and A256CBC-HS512 secrets cannot be represented as
18+
[CryptoKey](https://developer.mozilla.org/docs/Web/API/CryptoKey) this option has no effect for them.

docs/key/import/functions/importJWK.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ Support from the community to continue maintaining and improving this module is
77
**importJWK**(`jwk`, `alg`?, `options`?): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`CryptoKey`](../../../types/type-aliases/CryptoKey.md) \| [`Uint8Array`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)\>
88

99
Imports a JWK to a [CryptoKey](https://developer.mozilla.org/docs/Web/API/CryptoKey). Either the JWK "alg" (Algorithm) Parameter, or the optional
10-
"alg" argument, must be present.
10+
"alg" argument, must be present for asymmetric JSON Web Key imports.
1111

1212
Note: The JSON Web Key parameters "use", "key_ops", and "ext" are also used in the
1313
[CryptoKey](https://developer.mozilla.org/docs/Web/API/CryptoKey) import process.
1414

15+
Note: Symmetric JSON Web Keys (i.e. `kty: "oct"`) yield back an [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instead of a
16+
[CryptoKey](https://developer.mozilla.org/docs/Web/API/CryptoKey).
17+
1518
This function is exported (as a named export) from the main `'jose'` module entry point as well
1619
as from its subpath export `'jose/key/import'`.
1720

docs/key/import/interfaces/KeyImportOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ Key Import Function options.
1313
`optional` **extractable**: `boolean`
1414

1515
The value to use as [SubtleCrypto.importKey](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) `extractable` argument. Default is false for
16-
private and secret keys, true otherwise.
16+
private keys, true otherwise.

src/key/generate_secret.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import type * as types from '../types.d.ts'
1010

1111
/** Secret generation function options. */
1212
export interface GenerateSecretOptions {
13-
/** The value to use as {@link !SubtleCrypto.generateKey} `extractable` argument. Default is false. */
13+
/**
14+
* The value to use as {@link !SubtleCrypto.generateKey} `extractable` argument. Default is false.
15+
*
16+
* Note: Because A128CBC-HS256, A192CBC-HS384, and A256CBC-HS512 secrets cannot be represented as
17+
* {@link !CryptoKey} this option has no effect for them.
18+
*/
1419
extractable?: boolean
1520
}
1621

@@ -19,6 +24,9 @@ export interface GenerateSecretOptions {
1924
*
2025
* Note: The secret key is generated with `extractable` set to `false` by default.
2126
*
27+
* Note: Because A128CBC-HS256, A192CBC-HS384, and A256CBC-HS512 secrets cannot be represented as
28+
* {@link !CryptoKey} this method yields a {@link !Uint8Array} for them instead.
29+
*
2230
* This function is exported (as a named export) from the main `'jose'` module entry point as well
2331
* as from its subpath export `'jose/generate/secret'`.
2432
*

src/key/import.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type * as types from '../types.d.ts'
1616
export interface KeyImportOptions {
1717
/**
1818
* The value to use as {@link !SubtleCrypto.importKey} `extractable` argument. Default is false for
19-
* private and secret keys, true otherwise.
19+
* private keys, true otherwise.
2020
*/
2121
extractable?: boolean
2222
}
@@ -138,11 +138,14 @@ export async function importPKCS8(
138138

139139
/**
140140
* Imports a JWK to a {@link !CryptoKey}. Either the JWK "alg" (Algorithm) Parameter, or the optional
141-
* "alg" argument, must be present.
141+
* "alg" argument, must be present for asymmetric JSON Web Key imports.
142142
*
143143
* Note: The JSON Web Key parameters "use", "key_ops", and "ext" are also used in the
144144
* {@link !CryptoKey} import process.
145145
*
146+
* Note: Symmetric JSON Web Keys (i.e. `kty: "oct"`) yield back an {@link !Uint8Array} instead of a
147+
* {@link !CryptoKey}.
148+
*
146149
* This function is exported (as a named export) from the main `'jose'` module entry point as well
147150
* as from its subpath export `'jose/key/import'`.
148151
*

0 commit comments

Comments
 (0)