UNPKG

1.82 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2017 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17interface Base64 {
18 byteToCharMap_: {
19 [key: number]: string;
20 } | null;
21 charToByteMap_: {
22 [key: string]: number;
23 } | null;
24 byteToCharMapWebSafe_: {
25 [key: number]: string;
26 } | null;
27 charToByteMapWebSafe_: {
28 [key: string]: number;
29 } | null;
30 ENCODED_VALS_BASE: string;
31 readonly ENCODED_VALS: string;
32 readonly ENCODED_VALS_WEBSAFE: string;
33 HAS_NATIVE_SUPPORT: boolean;
34 encodeByteArray(input: number[] | Uint8Array, webSafe?: boolean): string;
35 encodeString(input: string, webSafe?: boolean): string;
36 decodeString(input: string, webSafe: boolean): string;
37 decodeStringToByteArray(input: string, webSafe: boolean): number[];
38 init_(): void;
39}
40export declare const base64: Base64;
41/**
42 * URL-safe base64 encoding
43 */
44export declare const base64Encode: (str: string) => string;
45/**
46 * URL-safe base64 decoding
47 *
48 * NOTE: DO NOT use the global atob() function - it does NOT support the
49 * base64Url variant encoding.
50 *
51 * @param str To be decoded
52 * @return Decoded result, if possible
53 */
54export declare const base64Decode: (str: string) => string | null;
55export {};