Initial
This commit is contained in:
28
resources/app/node_modules/@smithy/util-base64/dist-es/constants.browser.js
generated
vendored
Normal file
28
resources/app/node_modules/@smithy/util-base64/dist-es/constants.browser.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
const alphabetByEncoding = {};
|
||||
const alphabetByValue = new Array(64);
|
||||
for (let i = 0, start = "A".charCodeAt(0), limit = "Z".charCodeAt(0); i + start <= limit; i++) {
|
||||
const char = String.fromCharCode(i + start);
|
||||
alphabetByEncoding[char] = i;
|
||||
alphabetByValue[i] = char;
|
||||
}
|
||||
for (let i = 0, start = "a".charCodeAt(0), limit = "z".charCodeAt(0); i + start <= limit; i++) {
|
||||
const char = String.fromCharCode(i + start);
|
||||
const index = i + 26;
|
||||
alphabetByEncoding[char] = index;
|
||||
alphabetByValue[index] = char;
|
||||
}
|
||||
for (let i = 0; i < 10; i++) {
|
||||
alphabetByEncoding[i.toString(10)] = i + 52;
|
||||
const char = i.toString(10);
|
||||
const index = i + 52;
|
||||
alphabetByEncoding[char] = index;
|
||||
alphabetByValue[index] = char;
|
||||
}
|
||||
alphabetByEncoding["+"] = 62;
|
||||
alphabetByValue[62] = "+";
|
||||
alphabetByEncoding["/"] = 63;
|
||||
alphabetByValue[63] = "/";
|
||||
const bitsPerLetter = 6;
|
||||
const bitsPerByte = 8;
|
||||
const maxLetterValue = 0b111111;
|
||||
export { alphabetByEncoding, alphabetByValue, bitsPerLetter, bitsPerByte, maxLetterValue };
|
||||
36
resources/app/node_modules/@smithy/util-base64/dist-es/fromBase64.browser.js
generated
vendored
Normal file
36
resources/app/node_modules/@smithy/util-base64/dist-es/fromBase64.browser.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { alphabetByEncoding, bitsPerByte, bitsPerLetter } from "./constants.browser";
|
||||
export const fromBase64 = (input) => {
|
||||
let totalByteLength = (input.length / 4) * 3;
|
||||
if (input.slice(-2) === "==") {
|
||||
totalByteLength -= 2;
|
||||
}
|
||||
else if (input.slice(-1) === "=") {
|
||||
totalByteLength--;
|
||||
}
|
||||
const out = new ArrayBuffer(totalByteLength);
|
||||
const dataView = new DataView(out);
|
||||
for (let i = 0; i < input.length; i += 4) {
|
||||
let bits = 0;
|
||||
let bitLength = 0;
|
||||
for (let j = i, limit = i + 3; j <= limit; j++) {
|
||||
if (input[j] !== "=") {
|
||||
if (!(input[j] in alphabetByEncoding)) {
|
||||
throw new TypeError(`Invalid character ${input[j]} in base64 string.`);
|
||||
}
|
||||
bits |= alphabetByEncoding[input[j]] << ((limit - j) * bitsPerLetter);
|
||||
bitLength += bitsPerLetter;
|
||||
}
|
||||
else {
|
||||
bits >>= bitsPerLetter;
|
||||
}
|
||||
}
|
||||
const chunkOffset = (i / 4) * 3;
|
||||
bits >>= bitLength % bitsPerByte;
|
||||
const byteLength = Math.floor(bitLength / bitsPerByte);
|
||||
for (let k = 0; k < byteLength; k++) {
|
||||
const offset = (byteLength - k - 1) * bitsPerByte;
|
||||
dataView.setUint8(chunkOffset + k, (bits & (255 << offset)) >> offset);
|
||||
}
|
||||
}
|
||||
return new Uint8Array(out);
|
||||
};
|
||||
12
resources/app/node_modules/@smithy/util-base64/dist-es/fromBase64.js
generated
vendored
Normal file
12
resources/app/node_modules/@smithy/util-base64/dist-es/fromBase64.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { fromString } from "@smithy/util-buffer-from";
|
||||
const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
|
||||
export const fromBase64 = (input) => {
|
||||
if ((input.length * 3) % 4 !== 0) {
|
||||
throw new TypeError(`Incorrect padding on base64 string.`);
|
||||
}
|
||||
if (!BASE64_REGEX.exec(input)) {
|
||||
throw new TypeError(`Invalid base64 string.`);
|
||||
}
|
||||
const buffer = fromString(input, "base64");
|
||||
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
||||
};
|
||||
2
resources/app/node_modules/@smithy/util-base64/dist-es/index.js
generated
vendored
Normal file
2
resources/app/node_modules/@smithy/util-base64/dist-es/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./fromBase64";
|
||||
export * from "./toBase64";
|
||||
35
resources/app/node_modules/@smithy/util-base64/dist-es/toBase64.browser.js
generated
vendored
Normal file
35
resources/app/node_modules/@smithy/util-base64/dist-es/toBase64.browser.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { fromUtf8 } from "@smithy/util-utf8";
|
||||
import { alphabetByValue, bitsPerByte, bitsPerLetter, maxLetterValue } from "./constants.browser";
|
||||
export function toBase64(_input) {
|
||||
let input;
|
||||
if (typeof _input === "string") {
|
||||
input = fromUtf8(_input);
|
||||
}
|
||||
else {
|
||||
input = _input;
|
||||
}
|
||||
const isArrayLike = typeof input === "object" && typeof input.length === "number";
|
||||
const isUint8Array = typeof input === "object" &&
|
||||
typeof input.byteOffset === "number" &&
|
||||
typeof input.byteLength === "number";
|
||||
if (!isArrayLike && !isUint8Array) {
|
||||
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
||||
}
|
||||
let str = "";
|
||||
for (let i = 0; i < input.length; i += 3) {
|
||||
let bits = 0;
|
||||
let bitLength = 0;
|
||||
for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) {
|
||||
bits |= input[j] << ((limit - j - 1) * bitsPerByte);
|
||||
bitLength += bitsPerByte;
|
||||
}
|
||||
const bitClusterCount = Math.ceil(bitLength / bitsPerLetter);
|
||||
bits <<= bitClusterCount * bitsPerLetter - bitLength;
|
||||
for (let k = 1; k <= bitClusterCount; k++) {
|
||||
const offset = (bitClusterCount - k) * bitsPerLetter;
|
||||
str += alphabetByValue[(bits & (maxLetterValue << offset)) >> offset];
|
||||
}
|
||||
str += "==".slice(0, 4 - bitClusterCount);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
15
resources/app/node_modules/@smithy/util-base64/dist-es/toBase64.js
generated
vendored
Normal file
15
resources/app/node_modules/@smithy/util-base64/dist-es/toBase64.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { fromArrayBuffer } from "@smithy/util-buffer-from";
|
||||
import { fromUtf8 } from "@smithy/util-utf8";
|
||||
export const toBase64 = (_input) => {
|
||||
let input;
|
||||
if (typeof _input === "string") {
|
||||
input = fromUtf8(_input);
|
||||
}
|
||||
else {
|
||||
input = _input;
|
||||
}
|
||||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
|
||||
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
|
||||
}
|
||||
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64");
|
||||
};
|
||||
Reference in New Issue
Block a user