Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2bb433d

Browse files
panvatargos
authored andcommittedMay 16, 2025
doc: fix CryptoKey.algorithm type and other interfaces in webcrypto.md
PR-URL: #58294 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent f04f09d commit 2bb433d

File tree

3 files changed

+175
-35
lines changed

3 files changed

+175
-35
lines changed
 

‎doc/api/crypto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ added:
21462146

21472147
<!--lint disable maximum-line-length remark-lint-->
21482148

2149-
* `algorithm`: {AlgorithmIdentifier|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}
2149+
* `algorithm`: {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}
21502150

21512151
<!--lint enable maximum-line-length remark-lint-->
21522152

‎doc/api/webcrypto.md

Lines changed: 167 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ added: v15.0.0
441441

442442
<!--lint disable maximum-line-length remark-lint-->
443443

444-
* Type: {AesKeyGenParams|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams}
444+
* Type: {KeyAlgorithm|RsaHashedKeyAlgorithm|EcKeyAlgorithm|AesKeyAlgorithm|HmacKeyAlgorithm}
445445

446446
<!--lint enable maximum-line-length remark-lint-->
447447

@@ -635,7 +635,7 @@ changes:
635635

636636
* `algorithm`: {EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params}
637637
* `baseKey`: {CryptoKey}
638-
* `derivedKeyAlgorithm`: {string|AlgorithmIdentifier|HmacImportParams|AesDerivedKeyParams}
638+
* `derivedKeyAlgorithm`: {string|Algorithm|HmacImportParams|AesDerivedKeyParams}
639639
* `extractable`: {boolean}
640640
* `keyUsages`: {string\[]} See [Key usages][].
641641
* Returns: {Promise} Fulfills with a {CryptoKey} upon success.
@@ -665,7 +665,7 @@ The algorithms currently supported include:
665665
added: v15.0.0
666666
-->
667667

668-
* `algorithm`: {string|AlgorithmIdentifier}
668+
* `algorithm`: {string|Algorithm}
669669
* `data`: {ArrayBuffer|TypedArray|DataView|Buffer}
670670
* Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.
671671

@@ -761,7 +761,7 @@ added: v15.0.0
761761

762762
<!--lint disable maximum-line-length remark-lint-->
763763

764-
* `algorithm`: {string|AlgorithmIdentifier|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams}
764+
* `algorithm`: {string|Algorithm|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams}
765765

766766
<!--lint enable maximum-line-length remark-lint-->
767767

@@ -815,7 +815,7 @@ changes:
815815

816816
<!--lint disable maximum-line-length remark-lint-->
817817

818-
* `algorithm`: {string|AlgorithmIdentifier|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}
818+
* `algorithm`: {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}
819819

820820
<!--lint enable maximum-line-length remark-lint-->
821821

@@ -865,7 +865,7 @@ changes:
865865

866866
<!--lint disable maximum-line-length remark-lint-->
867867

868-
* `algorithm`: {string|AlgorithmIdentifier|RsaPssParams|EcdsaParams|Ed448Params}
868+
* `algorithm`: {string|Algorithm|RsaPssParams|EcdsaParams|Ed448Params}
869869
* `key`: {CryptoKey}
870870
* `data`: {ArrayBuffer|TypedArray|DataView|Buffer}
871871
* Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.
@@ -898,8 +898,8 @@ added: v15.0.0
898898

899899
<!--lint disable maximum-line-length remark-lint-->
900900

901-
* `unwrapAlgo`: {string|AlgorithmIdentifier|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}
902-
* `unwrappedKeyAlgo`: {string|AlgorithmIdentifier|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}
901+
* `unwrapAlgo`: {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}
902+
* `unwrappedKeyAlgo`: {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}
903903

904904
<!--lint enable maximum-line-length remark-lint-->
905905

@@ -955,7 +955,7 @@ changes:
955955

956956
<!--lint disable maximum-line-length remark-lint-->
957957

958-
* `algorithm`: {string|AlgorithmIdentifier|RsaPssParams|EcdsaParams|Ed448Params}
958+
* `algorithm`: {string|Algorithm|RsaPssParams|EcdsaParams|Ed448Params}
959959
* `key`: {CryptoKey}
960960
* `signature`: {ArrayBuffer|TypedArray|DataView|Buffer}
961961
* `data`: {ArrayBuffer|TypedArray|DataView|Buffer}
@@ -988,7 +988,7 @@ added: v15.0.0
988988
* `format`: {string} Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
989989
* `key`: {CryptoKey}
990990
* `wrappingKey`: {CryptoKey}
991-
* `wrapAlgo`: {string|AlgorithmIdentifier|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}
991+
* `wrapAlgo`: {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}
992992
* Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.
993993

994994
<!--lint enable maximum-line-length remark-lint-->
@@ -1017,13 +1017,13 @@ The algorithm parameter objects define the methods and parameters used by
10171017
the various {SubtleCrypto} methods. While described here as "classes", they
10181018
are simple JavaScript dictionary objects.
10191019

1020-
### Class: `AlgorithmIdentifier`
1020+
### Class: `Algorithm`
10211021

10221022
<!-- YAML
10231023
added: v15.0.0
10241024
-->
10251025

1026-
#### `algorithmIdentifier.name`
1026+
#### `Algorithm.name`
10271027

10281028
<!-- YAML
10291029
added: v15.0.0
@@ -1171,6 +1171,30 @@ added: v15.0.0
11711171
This values must be one of `32`, `64`, `96`, `104`, `112`, `120`, or
11721172
`128`. **Default:** `128`.
11731173

1174+
### Class: `AesKeyAlgorithm`
1175+
1176+
<!-- YAML
1177+
added: v15.0.0
1178+
-->
1179+
1180+
#### `aesKeyAlgorithm.length`
1181+
1182+
<!-- YAML
1183+
added: v15.0.0
1184+
-->
1185+
1186+
* Type: {number}
1187+
1188+
The length of the AES key in bits.
1189+
1190+
#### `aesKeyAlgorithm.name`
1191+
1192+
<!-- YAML
1193+
added: v15.0.0
1194+
-->
1195+
1196+
* Type: {string}
1197+
11741198
### Class: `AesKeyGenParams`
11751199

11761200
<!-- YAML
@@ -1236,7 +1260,7 @@ added: v15.0.0
12361260
added: v15.0.0
12371261
-->
12381262

1239-
* Type: {string|Object}
1263+
* Type: {string|Algorithm}
12401264

12411265
If represented as a {string}, the value must be one of:
12421266

@@ -1245,8 +1269,8 @@ If represented as a {string}, the value must be one of:
12451269
* `'SHA-384'`
12461270
* `'SHA-512'`
12471271

1248-
If represented as an {Object}, the object must have a `name` property
1249-
whose value is one of the above listed values.
1272+
If represented as an {Algorithm}, the object's `name` property
1273+
must be one of the above listed values.
12501274

12511275
#### `ecdsaParams.name`
12521276

@@ -1256,6 +1280,28 @@ added: v15.0.0
12561280

12571281
* Type: {string} Must be `'ECDSA'`.
12581282

1283+
### Class: `EcKeyAlgorithm`
1284+
1285+
<!-- YAML
1286+
added: v15.0.0
1287+
-->
1288+
1289+
#### `ecKeyAlgorithm.name`
1290+
1291+
<!-- YAML
1292+
added: v15.0.0
1293+
-->
1294+
1295+
* Type: {string}
1296+
1297+
#### `ecKeyAlgorithm.namedCurve`
1298+
1299+
<!-- YAML
1300+
added: v15.0.0
1301+
-->
1302+
1303+
* Type: {string}
1304+
12591305
### Class: `EcKeyGenParams`
12601306

12611307
<!-- YAML
@@ -1343,7 +1389,7 @@ added: v15.0.0
13431389
added: v15.0.0
13441390
-->
13451391

1346-
* Type: {string|Object}
1392+
* Type: {string|Algorithm}
13471393

13481394
If represented as a {string}, the value must be one of:
13491395

@@ -1352,8 +1398,8 @@ If represented as a {string}, the value must be one of:
13521398
* `'SHA-384'`
13531399
* `'SHA-512'`
13541400

1355-
If represented as an {Object}, the object must have a `name` property
1356-
whose value is one of the above listed values.
1401+
If represented as an {Algorithm}, the object's `name` property
1402+
must be one of the above listed values.
13571403

13581404
#### `hkdfParams.info`
13591405

@@ -1399,7 +1445,7 @@ added: v15.0.0
13991445
added: v15.0.0
14001446
-->
14011447

1402-
* Type: {string|Object}
1448+
* Type: {string|Algorithm}
14031449

14041450
If represented as a {string}, the value must be one of:
14051451

@@ -1408,8 +1454,8 @@ If represented as a {string}, the value must be one of:
14081454
* `'SHA-384'`
14091455
* `'SHA-512'`
14101456

1411-
If represented as an {Object}, the object must have a `name` property
1412-
whose value is one of the above listed values.
1457+
If represented as an {Algorithm}, the object's `name` property
1458+
must be one of the above listed values.
14131459

14141460
#### `hmacImportParams.length`
14151461

@@ -1430,6 +1476,38 @@ added: v15.0.0
14301476

14311477
* Type: {string} Must be `'HMAC'`.
14321478

1479+
### Class: `HmacKeyAlgorithm`
1480+
1481+
<!-- YAML
1482+
added: v15.0.0
1483+
-->
1484+
1485+
#### `hmacKeyAlgorithm.hash`
1486+
1487+
<!-- YAML
1488+
added: v15.0.0
1489+
-->
1490+
1491+
* Type: {Algorithm}
1492+
1493+
#### `hmacKeyAlgorithm.length`
1494+
1495+
<!-- YAML
1496+
added: v15.0.0
1497+
-->
1498+
1499+
* Type: {number}
1500+
1501+
The length of the HMAC key in bits.
1502+
1503+
#### `hmacKeyAlgorithm.name`
1504+
1505+
<!-- YAML
1506+
added: v15.0.0
1507+
-->
1508+
1509+
* Type: {string}
1510+
14331511
### Class: `HmacKeyGenParams`
14341512

14351513
<!-- YAML
@@ -1442,7 +1520,7 @@ added: v15.0.0
14421520
added: v15.0.0
14431521
-->
14441522

1445-
* Type: {string|Object}
1523+
* Type: {string|Algorithm}
14461524

14471525
If represented as a {string}, the value must be one of:
14481526

@@ -1451,8 +1529,8 @@ If represented as a {string}, the value must be one of:
14511529
* `'SHA-384'`
14521530
* `'SHA-512'`
14531531

1454-
If represented as an {Object}, the object must have a `name` property
1455-
whose value is one of the above listed values.
1532+
If represented as an {Algorithm}, the object's `name` property
1533+
must be one of the above listed values.
14561534

14571535
#### `hmacKeyGenParams.length`
14581536

@@ -1474,6 +1552,20 @@ added: v15.0.0
14741552

14751553
* Type: {string} Must be `'HMAC'`.
14761554

1555+
### Class: `KeyAlgorithm`
1556+
1557+
<!-- YAML
1558+
added: v15.0.0
1559+
-->
1560+
1561+
#### `keyAlgorithm.name`
1562+
1563+
<!-- YAML
1564+
added: v15.0.0
1565+
-->
1566+
1567+
* Type: {string}
1568+
14771569
### Class: `Pbkdf2Params`
14781570

14791571
<!-- YAML
@@ -1486,7 +1578,7 @@ added: v15.0.0
14861578
added: v15.0.0
14871579
-->
14881580

1489-
* Type: {string|Object}
1581+
* Type: {string|Algorithm}
14901582

14911583
If represented as a {string}, the value must be one of:
14921584

@@ -1495,8 +1587,8 @@ If represented as a {string}, the value must be one of:
14951587
* `'SHA-384'`
14961588
* `'SHA-512'`
14971589

1498-
If represented as an {Object}, the object must have a `name` property
1499-
whose value is one of the above listed values.
1590+
If represented as an {Algorithm}, the object's `name` property
1591+
must be one of the above listed values.
15001592

15011593
#### `pbkdf2Params.iterations`
15021594

@@ -1538,7 +1630,7 @@ added: v15.0.0
15381630
added: v15.0.0
15391631
-->
15401632

1541-
* Type: {string|Object}
1633+
* Type: {string|Algorithm}
15421634

15431635
If represented as a {string}, the value must be one of:
15441636

@@ -1547,8 +1639,8 @@ If represented as a {string}, the value must be one of:
15471639
* `'SHA-384'`
15481640
* `'SHA-512'`
15491641

1550-
If represented as an {Object}, the object must have a `name` property
1551-
whose value is one of the above listed values.
1642+
If represented as an {Algorithm}, the object's `name` property
1643+
must be one of the above listed values.
15521644

15531645
#### `rsaHashedImportParams.name`
15541646

@@ -1559,6 +1651,48 @@ added: v15.0.0
15591651
* Type: {string} Must be one of `'RSASSA-PKCS1-v1_5'`, `'RSA-PSS'`, or
15601652
`'RSA-OAEP'`.
15611653

1654+
### Class: `RsaHashedKeyAlgorithm`
1655+
1656+
<!-- YAML
1657+
added: v15.0.0
1658+
-->
1659+
1660+
#### `rsaHashedKeyAlgorithm.hash`
1661+
1662+
<!-- YAML
1663+
added: v15.0.0
1664+
-->
1665+
1666+
* Type: {Algorithm}
1667+
1668+
#### `rsaHashedKeyAlgorithm.modulusLength`
1669+
1670+
<!-- YAML
1671+
added: v15.0.0
1672+
-->
1673+
1674+
* Type: {number}
1675+
1676+
The length in bits of the RSA modulus.
1677+
1678+
#### `rsaHashedKeyAlgorithm.name`
1679+
1680+
<!-- YAML
1681+
added: v15.0.0
1682+
-->
1683+
1684+
* Type: {string}
1685+
1686+
#### `rsaHashedKeyAlgorithm.publicExponent`
1687+
1688+
<!-- YAML
1689+
added: v15.0.0
1690+
-->
1691+
1692+
* Type: {Uint8Array}
1693+
1694+
The RSA public exponent.
1695+
15621696
### Class: `RsaHashedKeyGenParams`
15631697

15641698
<!-- YAML
@@ -1571,7 +1705,7 @@ added: v15.0.0
15711705
added: v15.0.0
15721706
-->
15731707

1574-
* Type: {string|Object}
1708+
* Type: {string|Algorithm}
15751709

15761710
If represented as a {string}, the value must be one of:
15771711

@@ -1580,8 +1714,8 @@ If represented as a {string}, the value must be one of:
15801714
* `'SHA-384'`
15811715
* `'SHA-512'`
15821716

1583-
If represented as an {Object}, the object must have a `name` property
1584-
whose value is one of the above listed values.
1717+
If represented as an {Algorithm}, the object's `name` property
1718+
must be one of the above listed values.
15851719

15861720
#### `rsaHashedKeyGenParams.modulusLength`
15871721

‎tools/doc/type-parser.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,29 @@ const customTypesMap = {
8787
'Verify': 'crypto.html#class-verify',
8888
'crypto.constants': 'crypto.html#cryptoconstants',
8989

90+
'Algorithm': 'webcrypto.html#class-algorithm',
9091
'CryptoKey': 'webcrypto.html#class-cryptokey',
9192
'CryptoKeyPair': 'webcrypto.html#class-cryptokeypair',
9293
'Crypto': 'webcrypto.html#class-crypto',
9394
'SubtleCrypto': 'webcrypto.html#class-subtlecrypto',
9495
'RsaOaepParams': 'webcrypto.html#class-rsaoaepparams',
95-
'AlgorithmIdentifier': 'webcrypto.html#class-algorithmidentifier',
9696
'AesCtrParams': 'webcrypto.html#class-aesctrparams',
9797
'AesCbcParams': 'webcrypto.html#class-aescbcparams',
9898
'AesDerivedKeyParams': 'webcrypto.html#class-aesderivedkeyparams',
9999
'AesGcmParams': 'webcrypto.html#class-aesgcmparams',
100100
'EcdhKeyDeriveParams': 'webcrypto.html#class-ecdhkeyderiveparams',
101101
'HkdfParams': 'webcrypto.html#class-hkdfparams',
102+
'KeyAlgorithm': 'webcrypto.html#class-keyalgorithm',
102103
'Pbkdf2Params': 'webcrypto.html#class-pbkdf2params',
104+
'HmacKeyAlgorithm': 'webcrypto.html#class-hmackeyalgorithm',
103105
'HmacKeyGenParams': 'webcrypto.html#class-hmackeygenparams',
106+
'AesKeyAlgorithm': 'webcrypto.html#class-aeskeyalgorithm',
104107
'AesKeyGenParams': 'webcrypto.html#class-aeskeygenparams',
108+
'RsaHashedKeyAlgorithm':
109+
'webcrypto.html#class-rsahashedkeyalgorithm',
105110
'RsaHashedKeyGenParams':
106111
'webcrypto.html#class-rsahashedkeygenparams',
112+
'EcKeyAlgorithm': 'webcrypto.html#class-eckeyalgorithm',
107113
'EcKeyGenParams': 'webcrypto.html#class-eckeygenparams',
108114
'RsaHashedImportParams':
109115
'webcrypto.html#class-rsahashedimportparams',

0 commit comments

Comments
 (0)
Please sign in to comment.