UNPKG

@etherna/sdk-js

Version:

Etherna SDKs for operations on the network

64 lines (63 loc) 1.87 kB
function r(e) { if (!Number.isSafeInteger(e) || e < 0) throw new Error(`positive integer expected, not ${e}`); } function s(e) { return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array"; } function o(e, ...t) { if (!s(e)) throw new Error("Uint8Array expected"); if (t.length > 0 && !t.includes(e.length)) throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`); } function f(e) { if (typeof e != "function" || typeof e.create != "function") throw new Error("Hash should be wrapped by utils.wrapConstructor"); r(e.outputLen), r(e.blockLen); } function a(e, t = !0) { if (e.destroyed) throw new Error("Hash instance has been destroyed"); if (t && e.finished) throw new Error("Hash#digest() has already been called"); } function w(e, t) { o(e); const n = t.outputLen; if (e.length < n) throw new Error(`digestInto() expects output buffer of length at least ${n}`); } /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const p = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), y = (e, t) => e << 32 - t | e >>> t; new Uint8Array(new Uint32Array([287454020]).buffer)[0]; function u(e) { if (typeof e != "string") throw new Error(`utf8ToBytes expected string, got ${typeof e}`); return new Uint8Array(new TextEncoder().encode(e)); } function c(e) { return typeof e == "string" && (e = u(e)), o(e), e; } class h { // Safe version that clones internal state clone() { return this._cloneInto(); } } function l(e) { const t = (i) => e().update(c(i)).digest(), n = e(); return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t; } export { h as H, o as b, p as c, a as e, f as h, w as o, y as r, c as t, l as w }; //# sourceMappingURL=utils-nt_aP_dH.mjs.map