UNPKG

@hiero-ledger/sdk

Version:
38 lines (33 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _rfc = require("rfc4648"); // SPDX-License-Identifier: Apache-2.0 // HIP-32: https://hips.hedera.com/hip/hip-32 const decodeOpts = { loose: true }; const encodeOpts = { pad: false }; /** * Decodes the rfc4648 base32 string into a {@link Uint8Array}. If the input string is null, returns null. * @param {string} str the base32 string. * @returns {Uint8Array | ''} */ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call const decode = str => str && _rfc.base32.parse(str, decodeOpts); /** * Encodes the byte array into a rfc4648 base32 string without padding. If the input is null, returns null. Note with * the rfc4648 loose = true option, it allows lower case letters, padding, and auto corrects 0 -> O, 1 -> L, 8 -> B * @param {Buffer|Uint8Array} data * @returns {string} */ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call const encode = data => data && _rfc.base32.stringify(data, encodeOpts); var _default = exports.default = { decode, encode };