| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | + ArrayBufferPrototypeSlice, | ||
| 4 | 5 | ArrayFrom, | |
| 5 | 6 | ArrayPrototypeIncludes, | |
| 6 | 7 | ArrayPrototypePush, | |
@@ -182,8 +183,8 @@ function asyncAesGcmCipher( | |||
| 182 | 183 | let tag; | |
| 183 | 184 | switch (mode) { | |
| 184 | 185 | case kWebCryptoCipherDecrypt: | |
| 185 | - tag = data.slice(-tagByteLength); | ||
| 186 | - data = data.slice(0, -tagByteLength); | ||
| 186 | + tag = ArrayBufferPrototypeSlice(data, -tagByteLength); | ||
| 187 | + data = ArrayBufferPrototypeSlice(data, 0, -tagByteLength); | ||
| 187 | 188 | break; | |
| 188 | 189 | case kWebCryptoCipherEncrypt: | |
| 189 | 190 | tag = tagByteLength; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | ObjectSetPrototypeOf, | |
| 5 | + ReflectApply, | ||
| 6 | + StringPrototypeToLowerCase, | ||
| 5 | 7 | } = primordials; | |
| 6 | 8 | ||
| 7 | 9 | const { | |
@@ -118,22 +120,22 @@ function createCipherBase(cipher, credential, options, decipher, iv) { | |||
| 118 | 120 | } | |
| 119 | 121 | this._decoder = null; | |
| 120 | 122 | ||
| 121 | - LazyTransform.call(this, options); | ||
| 123 | + ReflectApply(LazyTransform, this, [options]); | ||
| 122 | 124 | } | |
| 123 | 125 | ||
| 124 | 126 | function createCipher(cipher, password, options, decipher) { | |
| 125 | 127 | validateString(cipher, 'cipher'); | |
| 126 | 128 | password = getArrayBufferOrView(password, 'password'); | |
| 127 | 129 | ||
| 128 | - createCipherBase.call(this, cipher, password, options, decipher); | ||
| 130 | + ReflectApply(createCipherBase, this, [cipher, password, options, decipher]); | ||
| 129 | 131 | } | |
| 130 | 132 | ||
| 131 | 133 | function createCipherWithIV(cipher, key, options, decipher, iv) { | |
| 132 | 134 | validateString(cipher, 'cipher'); | |
| 133 | 135 | const encoding = getStringOption(options, 'encoding'); | |
| 134 | 136 | key = prepareSecretKey(key, encoding); | |
| 135 | 137 | iv = iv === null ? null : getArrayBufferOrView(iv, 'iv'); | |
| 136 | - createCipherBase.call(this, cipher, key, options, decipher, iv); | ||
| 138 | + ReflectApply(createCipherBase, this, [cipher, key, options, decipher, iv]); | ||
| 137 | 139 | } | |
| 138 | 140 | ||
| 139 | 141 | // The Cipher class is part of the legacy Node.js crypto API. It exposes | |
@@ -145,7 +147,7 @@ function Cipher(cipher, password, options) { | |||
| 145 | 147 | if (!(this instanceof Cipher)) | |
| 146 | 148 | return new Cipher(cipher, password, options); | |
| 147 | 149 | ||
| 148 | - createCipher.call(this, cipher, password, options, true); | ||
| 150 | + ReflectApply(createCipher, this, [cipher, password, options, true]); | ||
| 149 | 151 | } | |
| 150 | 152 | ||
| 151 | 153 | ObjectSetPrototypeOf(Cipher.prototype, LazyTransform.prototype); | |
@@ -241,7 +243,7 @@ function Cipheriv(cipher, key, iv, options) { | |||
| 241 | 243 | if (!(this instanceof Cipheriv)) | |
| 242 | 244 | return new Cipheriv(cipher, key, iv, options); | |
| 243 | 245 | ||
| 244 | - createCipherWithIV.call(this, cipher, key, options, true, iv); | ||
| 246 | + ReflectApply(createCipherWithIV, this, [cipher, key, options, true, iv]); | ||
| 245 | 247 | } | |
| 246 | 248 | ||
| 247 | 249 | function addCipherPrototypeFunctions(constructor) { | |
@@ -271,7 +273,7 @@ function Decipher(cipher, password, options) { | |||
| 271 | 273 | if (!(this instanceof Decipher)) | |
| 272 | 274 | return new Decipher(cipher, password, options); | |
| 273 | 275 | ||
| 274 | - createCipher.call(this, cipher, password, options, false); | ||
| 276 | + ReflectApply(createCipher, this, [cipher, password, options, false]); | ||
| 275 | 277 | } | |
| 276 | 278 | ||
| 277 | 279 | ObjectSetPrototypeOf(Decipher.prototype, LazyTransform.prototype); | |
@@ -287,7 +289,7 @@ function Decipheriv(cipher, key, iv, options) { | |||
| 287 | 289 | if (!(this instanceof Decipheriv)) | |
| 288 | 290 | return new Decipheriv(cipher, key, iv, options); | |
| 289 | 291 | ||
| 290 | - createCipherWithIV.call(this, cipher, key, options, false, iv); | ||
| 292 | + ReflectApply(createCipherWithIV, this, [cipher, key, options, false, iv]); | ||
| 291 | 293 | } | |
| 292 | 294 | ||
| 293 | 295 | ObjectSetPrototypeOf(Decipheriv.prototype, LazyTransform.prototype); | |
@@ -315,8 +317,8 @@ function getCipherInfo(nameOrNid, options) { | |||
| 315 | 317 | ||
| 316 | 318 | const ret = _getCipherInfo({}, nameOrNid, keyLength, ivLength); | |
| 317 | 319 | if (ret !== undefined) { | |
| 318 | - if (ret.name) ret.name = ret.name.toLowerCase(); | ||
| 319 | - if (ret.type) ret.type = ret.type.toLowerCase(); | ||
| 320 | + if (ret.name) ret.name = StringPrototypeToLowerCase(ret.name); | ||
| 321 | + if (ret.type) ret.type = StringPrototypeToLowerCase(ret.type); | ||
| 320 | 322 | } | |
| 321 | 323 | return ret; | |
| 322 | 324 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | + ArrayBufferPrototypeSlice, | ||
| 4 | 5 | FunctionPrototypeCall, | |
| 5 | 6 | MathFloor, | |
| 6 | 7 | ObjectDefineProperty, | |
@@ -475,7 +476,9 @@ async function asyncDeriveBitsECDH(algorithm, baseKey, length) { | |||
| 475 | 476 | if (byteLength < length) | |
| 476 | 477 | throw lazyDOMException('derived bit length is too small', 'OperationError'); | |
| 477 | 478 | ||
| 478 | - return length === byteLength ? bits : bits.slice(0, length); | ||
| 479 | + return length === byteLength ? | ||
| 480 | + bits : | ||
| 481 | + ArrayBufferPrototypeSlice(bits, 0, length); | ||
| 479 | 482 | } | |
| 480 | 483 | ||
| 481 | 484 | async function asyncDeriveBitsDH(algorithm, baseKey, length) { | |
@@ -528,7 +531,9 @@ async function asyncDeriveBitsDH(algorithm, baseKey, length) { | |||
| 528 | 531 | if (byteLength < length) | |
| 529 | 532 | throw lazyDOMException('derived bit length is too small', 'OperationError'); | |
| 530 | 533 | ||
| 531 | - return length === byteLength ? bits : bits.slice(0, length); | ||
| 534 | + return length === byteLength ? | ||
| 535 | + bits : | ||
| 536 | + ArrayBufferPrototypeSlice(bits, 0, length); | ||
| 532 | 537 | } | |
| 533 | 538 | ||
| 534 | 539 | function dhExportKey(key, format) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | ObjectSetPrototypeOf, | |
| 5 | + ReflectApply, | ||
| 5 | 6 | Symbol, | |
| 6 | 7 | } = primordials; | |
| 7 | 8 | ||
@@ -67,7 +68,7 @@ function Hash(algorithm, options) { | |||
| 67 | 68 | this[kState] = { | |
| 68 | 69 | [kFinalized]: false | |
| 69 | 70 | }; | |
| 70 | - LazyTransform.call(this, options); | ||
| 71 | + ReflectApply(LazyTransform, this, [options]); | ||
| 71 | 72 | } | |
| 72 | 73 | ||
| 73 | 74 | ObjectSetPrototypeOf(Hash.prototype, LazyTransform.prototype); | |
@@ -134,7 +135,7 @@ function Hmac(hmac, key, options) { | |||
| 134 | 135 | this[kState] = { | |
| 135 | 136 | [kFinalized]: false | |
| 136 | 137 | }; | |
| 137 | - LazyTransform.call(this, options); | ||
| 138 | + ReflectApply(LazyTransform, this, [options]); | ||
| 138 | 139 | } | |
| 139 | 140 | ||
| 140 | 141 | ObjectSetPrototypeOf(Hmac.prototype, LazyTransform.prototype); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | ObjectSetPrototypeOf, | |
| 5 | + ReflectApply, | ||
| 5 | 6 | } = primordials; | |
| 6 | 7 | ||
| 7 | 8 | const { | |
@@ -50,7 +51,7 @@ function Sign(algorithm, options) { | |||
| 50 | 51 | this[kHandle] = new _Sign(); | |
| 51 | 52 | this[kHandle].init(algorithm); | |
| 52 | 53 | ||
| 53 | - Writable.call(this, options); | ||
| 54 | + ReflectApply(Writable, this, [options]); | ||
| 54 | 55 | } | |
| 55 | 56 | ||
| 56 | 57 | ObjectSetPrototypeOf(Sign.prototype, Writable.prototype); | |
@@ -164,7 +165,7 @@ function Verify(algorithm, options) { | |||
| 164 | 165 | this[kHandle] = new _Verify(); | |
| 165 | 166 | this[kHandle].init(algorithm); | |
| 166 | 167 | ||
| 167 | - Writable.call(this, options); | ||
| 168 | + ReflectApply(Writable, this, [options]); | ||
| 168 | 169 | } | |
| 169 | 170 | ||
| 170 | 171 | ObjectSetPrototypeOf(Verify.prototype, Writable.prototype); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ const { | |||
| 7 | 7 | ObjectDefineProperties, | |
| 8 | 8 | SafeSet, | |
| 9 | 9 | SymbolToStringTag, | |
| 10 | + StringPrototypeRepeat, | ||
| 10 | 11 | } = primordials; | |
| 11 | 12 | ||
| 12 | 13 | const { | |
@@ -494,7 +495,7 @@ async function wrapKey(format, key, wrappingKey, algorithm) { | |||
| 494 | 495 | throw lazyDOMException('Invalid exported JWK key', 'DataError'); | |
| 495 | 496 | const ec = new TextEncoder(); | |
| 496 | 497 | const raw = JSONStringify(keyData); | |
| 497 | - keyData = ec.encode(raw + ' '.repeat(8 - (raw.length % 8))); | ||
| 498 | + keyData = ec.encode(raw + StringPrototypeRepeat(' ', 8 - (raw.length % 8))); | ||
| 498 | 499 | } | |
| 499 | 500 | ||
| 500 | 501 | return cipherOrWrap( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments