diff --git a/src/common/utils/base64.ts b/src/common/utils/base64.ts index 8484e128b1..9bae5f79bf 100755 --- a/src/common/utils/base64.ts +++ b/src/common/utils/base64.ts @@ -23,11 +23,20 @@ import * as Base64 from "crypto-js/enc-base64"; import * as Utf8 from "crypto-js/enc-utf8"; -export const base64 = { - decode(data: string) { - return Base64.parse(data).toString(Utf8); - }, - encode(data: string) { - return Utf8.parse(data).toString(Base64); - }, -}; +/** + * Computes utf-8 from base64 + * @param data A Base64 encoded string + * @returns The original utf-8 string + */ +export function decode(data: string): string { + return Base64.parse(data).toString(Utf8); +} + +/** + * Computes base64 from utf-8 + * @param data A normal string + * @returns A base64 encoded version + */ +export function encode(data: string): string { + return Utf8.parse(data).toString(Base64); +} diff --git a/src/common/utils/index.ts b/src/common/utils/index.ts index 2875877a16..733867f1cb 100644 --- a/src/common/utils/index.ts +++ b/src/common/utils/index.ts @@ -28,7 +28,6 @@ export function noop(...args: T): void { export * from "./app-version"; export * from "./autobind"; -export * from "./base64"; export * from "./camelCase"; export * from "./cloneJson"; export * from "./cluster-id-url-parsing"; @@ -62,9 +61,11 @@ export * from "./types"; import * as iter from "./iter"; import * as array from "./array"; import * as tuple from "./tuple"; +import * as base64 from "./base64"; export { iter, array, tuple, + base64, };