UNPKG

1.29 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.base64Encode = exports.base64Decode = exports.isBase64 = exports.base64Validate = void 0;
4const base_1 = require("@scure/base");
5const helpers_js_1 = require("../base32/helpers.js");
6const config = {
7 chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
8 coder: base_1.base64,
9 type: 'base64',
10 withPadding: true
11};
12/**
13 * @name base64Validate
14 * @summary Validates a base64 value.
15 * @description
16 * Validates that the supplied value is valid base64
17 */
18exports.base64Validate = (0, helpers_js_1.createValidate)(config);
19/**
20 * @name isBase64
21 * @description Checks if the input is in base64, returning true/false
22 */
23exports.isBase64 = (0, helpers_js_1.createIs)(exports.base64Validate);
24/**
25 * @name base64Decode
26 * @summary Decodes a base64 value.
27 * @description
28 * From the provided input, decode the base64 and return the result as an `Uint8Array`.
29 */
30exports.base64Decode = (0, helpers_js_1.createDecode)(config, exports.base64Validate);
31/**
32 * @name base64Encode
33 * @summary Creates a base64 value.
34 * @description
35 * From the provided input, create the base64 and return the result as a string.
36 */
37exports.base64Encode = (0, helpers_js_1.createEncode)(config);