| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1d80ab7 commit c964177
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | SafeSet, | |
| 5 | + StringPrototypeToLowerCase, | ||
| 5 | 6 | } = primordials; | |
| 6 | 7 | ||
| 7 | 8 | const { Buffer } = require('buffer'); | |
@@ -332,7 +333,7 @@ function cfrgImportKey( | |||
| 332 | 333 | return undefined; | |
| 333 | 334 | } | |
| 334 | 335 | ||
| 335 | - if (keyObject.asymmetricKeyType !== name.toLowerCase()) { | ||
| 336 | + if (keyObject.asymmetricKeyType !== StringPrototypeToLowerCase(name)) { | ||
| 336 | 337 | throw lazyDOMException('Invalid key type', 'DataError'); | |
| 337 | 338 | } | |
| 338 | 339 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | SafeSet, | |
| 5 | + StringPrototypeToLowerCase, | ||
| 5 | 6 | TypedArrayPrototypeGetBuffer, | |
| 6 | 7 | TypedArrayPrototypeSet, | |
| 7 | 8 | Uint8Array, | |
@@ -276,7 +277,7 @@ function mlDsaImportKey( | |||
| 276 | 277 | return undefined; | |
| 277 | 278 | } | |
| 278 | 279 | ||
| 279 | - if (keyObject.asymmetricKeyType !== name.toLowerCase()) { | ||
| 280 | + if (keyObject.asymmetricKeyType !== StringPrototypeToLowerCase(name)) { | ||
| 280 | 281 | throw lazyDOMException('Invalid key type', 'DataError'); | |
| 281 | 282 | } | |
| 282 | 283 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | const { | |
| 4 | 4 | PromiseWithResolvers, | |
| 5 | 5 | SafeSet, | |
| 6 | + StringPrototypeToLowerCase, | ||
| 6 | 7 | TypedArrayPrototypeGetBuffer, | |
| 7 | 8 | TypedArrayPrototypeSet, | |
| 8 | 9 | Uint8Array, | |
@@ -209,7 +210,7 @@ function mlKemImportKey( | |||
| 209 | 210 | return undefined; | |
| 210 | 211 | } | |
| 211 | 212 | ||
| 212 | - if (keyObject.asymmetricKeyType !== name.toLowerCase()) { | ||
| 213 | + if (keyObject.asymmetricKeyType !== StringPrototypeToLowerCase(name)) { | ||
| 213 | 214 | throw lazyDOMException('Invalid key type', 'DataError'); | |
| 214 | 215 | } | |
| 215 | 216 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ const { | |||
| 15 | 15 | ObjectEntries, | |
| 16 | 16 | ObjectKeys, | |
| 17 | 17 | ObjectPrototypeHasOwnProperty, | |
| 18 | - Promise, | ||
| 18 | + PromiseWithResolvers, | ||
| 19 | 19 | StringPrototypeToUpperCase, | |
| 20 | 20 | Symbol, | |
| 21 | 21 | TypedArrayPrototypeGetBuffer, | |
@@ -656,15 +656,15 @@ function onDone(resolve, reject, err, result) { | |||
| 656 | 656 | } | |
| 657 | 657 | ||
| 658 | 658 | function jobPromise(getJob) { | |
| 659 | - return new Promise((resolve, reject) => { | ||
| 660 | - try { | ||
| 661 | - const job = getJob(); | ||
| 662 | - job.ondone = FunctionPrototypeBind(onDone, job, resolve, reject); | ||
| 663 | - job.run(); | ||
| 664 | - } catch (err) { | ||
| 665 | - onDone(resolve, reject, err); | ||
| 666 | - } | ||
| 667 | - }); | ||
| 659 | + const { promise, resolve, reject } = PromiseWithResolvers(); | ||
| 660 | + try { | ||
| 661 | + const job = getJob(); | ||
| 662 | + job.ondone = FunctionPrototypeBind(onDone, job, resolve, reject); | ||
| 663 | + job.run(); | ||
| 664 | + } catch (err) { | ||
| 665 | + onDone(resolve, reject, err); | ||
| 666 | + } | ||
| 667 | + return promise; | ||
| 668 | 668 | } | |
| 669 | 669 | ||
| 670 | 670 | // In WebCrypto, the publicExponent option in RSA is represented as a | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -195,12 +195,14 @@ converters.object = (V, opts) => { | |||
| 195 | 195 | ||
| 196 | 196 | const isNonSharedArrayBuffer = isArrayBuffer; | |
| 197 | 197 | ||
| 198 | + /** | ||
| 199 | + * @param {string | object} V - The hash algorithm identifier (string or object). | ||
| 200 | + * @param {string} label - The dictionary name for the error message. | ||
| 201 | + */ | ||
| 198 | 202 | function ensureSHA(V, label) { | |
| 199 | - if ( | ||
| 200 | - typeof V === 'string' ? | ||
| 201 | - !StringPrototypeStartsWith(StringPrototypeToLowerCase(V), 'sha') : | ||
| 202 | - V.name?.toLowerCase?.().startsWith('sha') === false | ||
| 203 | - ) | ||
| 203 | + const name = typeof V === 'string' ? V : V.name; | ||
| 204 | + if (typeof name !== 'string' || | ||
| 205 | + !StringPrototypeStartsWith(StringPrototypeToLowerCase(name), 'sha')) | ||
| 204 | 206 | throw lazyDOMException( | |
| 205 | 207 | `Only SHA hashes are supported in ${label}`, 'NotSupportedError'); | |
| 206 | 208 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments