diff options
Diffstat (limited to 'alarm/node_modules/abab')
-rw-r--r-- | alarm/node_modules/abab/LICENSE.md | 13 | ||||
-rw-r--r-- | alarm/node_modules/abab/README.md | 51 | ||||
-rw-r--r-- | alarm/node_modules/abab/index.d.ts | 2 | ||||
-rw-r--r-- | alarm/node_modules/abab/index.js | 9 | ||||
-rw-r--r-- | alarm/node_modules/abab/lib/atob.js | 101 | ||||
-rw-r--r-- | alarm/node_modules/abab/lib/btoa.js | 62 | ||||
-rw-r--r-- | alarm/node_modules/abab/package.json | 42 |
7 files changed, 0 insertions, 280 deletions
diff --git a/alarm/node_modules/abab/LICENSE.md b/alarm/node_modules/abab/LICENSE.md deleted file mode 100644 index aac4aac..0000000 --- a/alarm/node_modules/abab/LICENSE.md +++ /dev/null @@ -1,13 +0,0 @@ -Copyright © 2019 W3C and Jeff Carpenter \<jeffcarp@chromium.org\> - -Both the original source code and new contributions in this repository are released under the [3-Clause BSD license](https://opensource.org/licenses/BSD-3-Clause). - -# The 3-Clause BSD License - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/alarm/node_modules/abab/README.md b/alarm/node_modules/abab/README.md deleted file mode 100644 index 6f32eb0..0000000 --- a/alarm/node_modules/abab/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# abab [![npm version](https://badge.fury.io/js/abab.svg)](https://www.npmjs.com/package/abab) [![Build Status](https://travis-ci.org/jsdom/abab.svg?branch=master)](https://travis-ci.org/jsdom/abab) - -A JavaScript module that implements `window.atob` and `window.btoa` according the forgiving-base64 algorithm in the [Infra Standard](https://infra.spec.whatwg.org/#forgiving-base64). The original code was forked from [w3c/web-platform-tests](https://github.com/w3c/web-platform-tests/blob/master/html/webappapis/atob/base64.html). - -Compatibility: Node.js version 3+ and all major browsers. - -Install with `npm`: - -```sh -npm install abab -``` - -## API - -### `btoa` (base64 encode) - -```js -const { btoa } = require('abab'); -btoa('Hello, world!'); // 'SGVsbG8sIHdvcmxkIQ==' -``` - -### `atob` (base64 decode) - -```js -const { atob } = require('abab'); -atob('SGVsbG8sIHdvcmxkIQ=='); // 'Hello, world!' -``` - -#### Valid characters - -[Per the spec](https://html.spec.whatwg.org/multipage/webappapis.html#atob:dom-windowbase64-btoa-3), `btoa` will accept strings "containing only characters in the range `U+0000` to `U+00FF`." If passed a string with characters above `U+00FF`, `btoa` will return `null`. If `atob` is passed a string that is not base64-valid, it will also return `null`. In both cases when `null` is returned, the spec calls for throwing a `DOMException` of type `InvalidCharacterError`. - -## Browsers - -If you want to include just one of the methods to save bytes in your client-side code, you can `require` the desired module directly. - -```js -const atob = require('abab/lib/atob'); -const btoa = require('abab/lib/btoa'); -``` - -## Development - -If you're **submitting a PR** or **deploying to npm**, please use the [checklists in CONTRIBUTING.md](CONTRIBUTING.md#checklists). - -## Remembering what `atob` and `btoa` stand for - -Base64 comes from IETF [RFC 4648](https://tools.ietf.org/html/rfc4648#section-4) (2006). - -- **`btoa`**, the encoder function, stands for **binary** to **ASCII**, meaning it converts any binary input into a subset of **ASCII** (Base64). -- **`atob`**, the decoder function, converts **ASCII** (or Base64) to its original **binary** format. diff --git a/alarm/node_modules/abab/index.d.ts b/alarm/node_modules/abab/index.d.ts deleted file mode 100644 index 665a6ad..0000000 --- a/alarm/node_modules/abab/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export function atob(encodedData: string): string | null -export function btoa(stringToEncode: string): string | null diff --git a/alarm/node_modules/abab/index.js b/alarm/node_modules/abab/index.js deleted file mode 100644 index 49d5ae9..0000000 --- a/alarm/node_modules/abab/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -const atob = require("./lib/atob"); -const btoa = require("./lib/btoa"); - -module.exports = { - atob, - btoa -}; diff --git a/alarm/node_modules/abab/lib/atob.js b/alarm/node_modules/abab/lib/atob.js deleted file mode 100644 index c8f753a..0000000 --- a/alarm/node_modules/abab/lib/atob.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; - -/** - * Implementation of atob() according to the HTML and Infra specs, except that - * instead of throwing INVALID_CHARACTER_ERR we return null. - */ -function atob(data) { - if (arguments.length === 0) { - throw new TypeError("1 argument required, but only 0 present."); - } - - // Web IDL requires DOMStrings to just be converted using ECMAScript - // ToString, which in our case amounts to using a template literal. - data = `${data}`; - // "Remove all ASCII whitespace from data." - data = data.replace(/[ \t\n\f\r]/g, ""); - // "If data's length divides by 4 leaving no remainder, then: if data ends - // with one or two U+003D (=) code points, then remove them from data." - if (data.length % 4 === 0) { - data = data.replace(/==?$/, ""); - } - // "If data's length divides by 4 leaving a remainder of 1, then return - // failure." - // - // "If data contains a code point that is not one of - // - // U+002B (+) - // U+002F (/) - // ASCII alphanumeric - // - // then return failure." - if (data.length % 4 === 1 || /[^+/0-9A-Za-z]/.test(data)) { - return null; - } - // "Let output be an empty byte sequence." - let output = ""; - // "Let buffer be an empty buffer that can have bits appended to it." - // - // We append bits via left-shift and or. accumulatedBits is used to track - // when we've gotten to 24 bits. - let buffer = 0; - let accumulatedBits = 0; - // "Let position be a position variable for data, initially pointing at the - // start of data." - // - // "While position does not point past the end of data:" - for (let i = 0; i < data.length; i++) { - // "Find the code point pointed to by position in the second column of - // Table 1: The Base 64 Alphabet of RFC 4648. Let n be the number given in - // the first cell of the same row. - // - // "Append to buffer the six bits corresponding to n, most significant bit - // first." - // - // atobLookup() implements the table from RFC 4648. - buffer <<= 6; - buffer |= atobLookup(data[i]); - accumulatedBits += 6; - // "If buffer has accumulated 24 bits, interpret them as three 8-bit - // big-endian numbers. Append three bytes with values equal to those - // numbers to output, in the same order, and then empty buffer." - if (accumulatedBits === 24) { - output += String.fromCharCode((buffer & 0xff0000) >> 16); - output += String.fromCharCode((buffer & 0xff00) >> 8); - output += String.fromCharCode(buffer & 0xff); - buffer = accumulatedBits = 0; - } - // "Advance position by 1." - } - // "If buffer is not empty, it contains either 12 or 18 bits. If it contains - // 12 bits, then discard the last four and interpret the remaining eight as - // an 8-bit big-endian number. If it contains 18 bits, then discard the last - // two and interpret the remaining 16 as two 8-bit big-endian numbers. Append - // the one or two bytes with values equal to those one or two numbers to - // output, in the same order." - if (accumulatedBits === 12) { - buffer >>= 4; - output += String.fromCharCode(buffer); - } else if (accumulatedBits === 18) { - buffer >>= 2; - output += String.fromCharCode((buffer & 0xff00) >> 8); - output += String.fromCharCode(buffer & 0xff); - } - // "Return output." - return output; -} -/** - * A lookup table for atob(), which converts an ASCII character to the - * corresponding six-bit number. - */ - -const keystr = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -function atobLookup(chr) { - const index = keystr.indexOf(chr); - // Throw exception if character is not in the lookup string; should not be hit in tests - return index < 0 ? undefined : index; -} - -module.exports = atob; diff --git a/alarm/node_modules/abab/lib/btoa.js b/alarm/node_modules/abab/lib/btoa.js deleted file mode 100644 index 8d385d7..0000000 --- a/alarm/node_modules/abab/lib/btoa.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; - -/** - * btoa() as defined by the HTML and Infra specs, which mostly just references - * RFC 4648. - */ -function btoa(s) { - if (arguments.length === 0) { - throw new TypeError("1 argument required, but only 0 present."); - } - - let i; - // String conversion as required by Web IDL. - s = `${s}`; - // "The btoa() method must throw an "InvalidCharacterError" DOMException if - // data contains any character whose code point is greater than U+00FF." - for (i = 0; i < s.length; i++) { - if (s.charCodeAt(i) > 255) { - return null; - } - } - let out = ""; - for (i = 0; i < s.length; i += 3) { - const groupsOfSix = [undefined, undefined, undefined, undefined]; - groupsOfSix[0] = s.charCodeAt(i) >> 2; - groupsOfSix[1] = (s.charCodeAt(i) & 0x03) << 4; - if (s.length > i + 1) { - groupsOfSix[1] |= s.charCodeAt(i + 1) >> 4; - groupsOfSix[2] = (s.charCodeAt(i + 1) & 0x0f) << 2; - } - if (s.length > i + 2) { - groupsOfSix[2] |= s.charCodeAt(i + 2) >> 6; - groupsOfSix[3] = s.charCodeAt(i + 2) & 0x3f; - } - for (let j = 0; j < groupsOfSix.length; j++) { - if (typeof groupsOfSix[j] === "undefined") { - out += "="; - } else { - out += btoaLookup(groupsOfSix[j]); - } - } - } - return out; -} - -/** - * Lookup table for btoa(), which converts a six-bit number into the - * corresponding ASCII character. - */ -const keystr = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -function btoaLookup(index) { - if (index >= 0 && index < 64) { - return keystr[index]; - } - - // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the tests. - return undefined; -} - -module.exports = btoa; diff --git a/alarm/node_modules/abab/package.json b/alarm/node_modules/abab/package.json deleted file mode 100644 index 71602db..0000000 --- a/alarm/node_modules/abab/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "abab", - "version": "2.0.6", - "description": "WHATWG spec-compliant implementations of window.atob and window.btoa.", - "main": "index.js", - "files": [ - "index.d.ts", - "index.js", - "lib/" - ], - "scripts": { - "mocha": "mocha test/node", - "karma": "karma start", - "test": "npm run lint && npm run mocha && npm run karma", - "lint": "eslint ." - }, - "repository": { - "type": "git", - "url": "git+https://github.com/jsdom/abab.git" - }, - "keywords": [ - "atob", - "btoa", - "browser" - ], - "author": "Jeff Carpenter <gcarpenterv@gmail.com>", - "license": "BSD-3-Clause", - "bugs": { - "url": "https://github.com/jsdom/abab/issues" - }, - "homepage": "https://github.com/jsdom/abab#readme", - "devDependencies": { - "eslint": "^4.19.1", - "karma": "^2.0.0", - "karma-cli": "^1.0.1", - "karma-firefox-launcher": "^1.1.0", - "karma-mocha": "^1.3.0", - "karma-webpack": "^3.0.0", - "mocha": "^5.1.0", - "webpack": "^4.5.0" - } -} |