UNPKG

owltech

Version:
134 lines (133 loc) 4.42 kB
/** * @license * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export declare const base64: { /** * Maps bytes to characters. * @type {Object} * @private */ byteToCharMap_: any; /** * Maps characters to bytes. * @type {Object} * @private */ charToByteMap_: any; /** * Maps bytes to websafe characters. * @type {Object} * @private */ byteToCharMapWebSafe_: any; /** * Maps websafe characters to bytes. * @type {Object} * @private */ charToByteMapWebSafe_: any; /** * Our default alphabet, shared between * ENCODED_VALS and ENCODED_VALS_WEBSAFE * @type {string} */ ENCODED_VALS_BASE: string; /** * Our default alphabet. Value 64 (=) is special; it means "nothing." * @type {string} */ readonly ENCODED_VALS: string; /** * Our websafe alphabet. * @type {string} */ readonly ENCODED_VALS_WEBSAFE: string; /** * Whether this browser supports the atob and btoa functions. This extension * started at Mozilla but is now implemented by many browsers. We use the * ASSUME_* variables to avoid pulling in the full useragent detection library * but still allowing the standard per-browser compilations. * * @type {boolean} */ HAS_NATIVE_SUPPORT: boolean; /** * Base64-encode an array of bytes. * * @param {Array<number>|Uint8Array} input An array of bytes (numbers with * value in [0, 255]) to encode. * @param {boolean=} opt_webSafe Boolean indicating we should use the * alternative alphabet. * @return {string} The base64 encoded string. */ encodeByteArray(input: any, opt_webSafe?: any): string; /** * Base64-encode a string. * * @param {string} input A string to encode. * @param {boolean=} opt_webSafe If true, we should use the * alternative alphabet. * @return {string} The base64 encoded string. */ encodeString(input: any, opt_webSafe: any): any; /** * Base64-decode a string. * * @param {string} input to decode. * @param {boolean=} opt_webSafe True if we should use the * alternative alphabet. * @return {string} string representing the decoded value. */ decodeString(input: any, opt_webSafe: any): string; /** * Base64-decode a string. * * In base-64 decoding, groups of four characters are converted into three * bytes. If the encoder did not apply padding, the input length may not * be a multiple of 4. * * In this case, the last group will have fewer than 4 characters, and * padding will be inferred. If the group has one or two characters, it decodes * to one byte. If the group has three characters, it decodes to two bytes. * * @param {string} input Input to decode. * @param {boolean=} opt_webSafe True if we should use the web-safe alphabet. * @return {!Array<number>} bytes representing the decoded value. */ decodeStringToByteArray(input: any, opt_webSafe: any): any[]; /** * Lazy static initialization function. Called before * accessing any of the static map variables. * @private */ init_(): void; }; /** * URL-safe base64 encoding * @param {!string} str * @return {!string} */ export declare const base64Encode: (str: string) => string; /** * URL-safe base64 decoding * * NOTE: DO NOT use the global atob() function - it does NOT support the * base64Url variant encoding. * * @param {string} str To be decoded * @return {?string} Decoded result, if possible */ export declare const base64Decode: (str: string) => string;