import { ensureString } from '../types/string.js';
import { normalizeToU8a, u8aToU8a } from '../types/bytes.js';
import { catchFnErrorWith } from '../error.js';
import 'crypto';
import '../interfaces.js';
import '../assert.js';
import '../types/iterable.js';
import '../types/object.js';
import '../inheritance.js';
import '../types/set.js';

/**
 * Encodes supplied bytes as base64 string.
 * @param {Uint8Array} bytes
 * @returns {string}
 */
const encodeAsBase64 = (bytes) => Buffer.from(normalizeToU8a(bytes)).toString('base64');
/**
 * Decodes bytes of the supplied base64 string.
 * @param {string} string
 * @returns {Uint8Array}
 */
const decodeFromBase64 = catchFnErrorWith(
  'Invalid base64 string',
  (string) => u8aToU8a(Buffer.from(ensureString(string), 'base64')),
);

export { decodeFromBase64, encodeAsBase64 };
//# sourceMappingURL=base-64.js.map
