@opendatalabs/vana-sdk
Version:
A TypeScript library for interacting with Vana Network smart contracts.
66 lines • 2.38 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var encoding_exports = {};
__export(encoding_exports, {
fromBase64: () => fromBase64,
isBrowserEnvironment: () => isBrowserEnvironment,
isNodeEnvironment: () => isNodeEnvironment,
toBase64: () => toBase64
});
module.exports = __toCommonJS(encoding_exports);
function toBase64(data) {
if (typeof Buffer !== "undefined" && Buffer.from) {
return Buffer.from(data).toString("base64");
}
if (typeof btoa !== "undefined") {
const binary = Array.from(data, (byte) => String.fromCharCode(byte)).join(
""
);
return btoa(binary);
}
throw new Error("No base64 encoding method available in this environment");
}
function fromBase64(str) {
if (typeof Buffer !== "undefined" && Buffer.from) {
return new Uint8Array(Buffer.from(str, "base64"));
}
if (typeof atob !== "undefined") {
const binary = atob(str);
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i++) {
bytes[i] = binary.charCodeAt(i);
}
return bytes;
}
throw new Error("No base64 decoding method available in this environment");
}
function isNodeEnvironment() {
return typeof Buffer !== "undefined" && typeof Buffer.from === "function" && typeof process !== "undefined" && process.versions?.node !== void 0;
}
function isBrowserEnvironment() {
return typeof window !== "undefined" && typeof window.document !== "undefined";
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
fromBase64,
isBrowserEnvironment,
isNodeEnvironment,
toBase64
});
//# sourceMappingURL=encoding.cjs.map