askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
1,545 lines (1,530 loc) • 4.66 MB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod2) => function __require2() {
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
};
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 __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
mod2
));
// node_modules/ms/index.js
var require_ms = __commonJS({
"node_modules/ms/index.js"(exports, module) {
var s2 = 1e3;
var m = s2 * 60;
var h2 = m * 60;
var d2 = h2 * 24;
var w2 = d2 * 7;
var y2 = d2 * 365.25;
module.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse5(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
throw new Error(
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
function parse5(str2) {
str2 = String(str2);
if (str2.length > 100) {
return;
}
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str2
);
if (!match) {
return;
}
var n2 = parseFloat(match[1]);
var type = (match[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n2 * y2;
case "weeks":
case "week":
case "w":
return n2 * w2;
case "days":
case "day":
case "d":
return n2 * d2;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n2 * h2;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n2 * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n2 * s2;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n2;
default:
return void 0;
}
}
function fmtShort(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d2) {
return Math.round(ms / d2) + "d";
}
if (msAbs >= h2) {
return Math.round(ms / h2) + "h";
}
if (msAbs >= m) {
return Math.round(ms / m) + "m";
}
if (msAbs >= s2) {
return Math.round(ms / s2) + "s";
}
return ms + "ms";
}
function fmtLong(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d2) {
return plural(ms, msAbs, d2, "day");
}
if (msAbs >= h2) {
return plural(ms, msAbs, h2, "hour");
}
if (msAbs >= m) {
return plural(ms, msAbs, m, "minute");
}
if (msAbs >= s2) {
return plural(ms, msAbs, s2, "second");
}
return ms + " ms";
}
function plural(ms, msAbs, n2, name) {
var isPlural = msAbs >= n2 * 1.5;
return Math.round(ms / n2) + " " + name + (isPlural ? "s" : "");
}
}
});
// node_modules/debug/src/common.js
var require_common = __commonJS({
"node_modules/debug/src/common.js"(exports, module) {
function setup(env) {
createDebug.debug = createDebug;
createDebug.default = createDebug;
createDebug.coerce = coerce2;
createDebug.disable = disable;
createDebug.enable = enable;
createDebug.enabled = enabled;
createDebug.humanize = require_ms();
createDebug.destroy = destroy;
Object.keys(env).forEach((key) => {
createDebug[key] = env[key];
});
createDebug.names = [];
createDebug.skips = [];
createDebug.formatters = {};
function selectColor(namespace) {
let hash4 = 0;
for (let i3 = 0; i3 < namespace.length; i3++) {
hash4 = (hash4 << 5) - hash4 + namespace.charCodeAt(i3);
hash4 |= 0;
}
return createDebug.colors[Math.abs(hash4) % createDebug.colors.length];
}
createDebug.selectColor = selectColor;
function createDebug(namespace) {
let prevTime;
let enableOverride = null;
let namespacesCache;
let enabledCache;
function debug2(...args) {
if (!debug2.enabled) {
return;
}
const self2 = debug2;
const curr = Number(/* @__PURE__ */ new Date());
const ms = curr - (prevTime || curr);
self2.diff = ms;
self2.prev = prevTime;
self2.curr = curr;
prevTime = curr;
args[0] = createDebug.coerce(args[0]);
if (typeof args[0] !== "string") {
args.unshift("%O");
}
let index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
if (match === "%%") {
return "%";
}
index++;
const formatter = createDebug.formatters[format];
if (typeof formatter === "function") {
const val = args[index];
match = formatter.call(self2, val);
args.splice(index, 1);
index--;
}
return match;
});
createDebug.formatArgs.call(self2, args);
const logFn = self2.log || createDebug.log;
logFn.apply(self2, args);
}
debug2.namespace = namespace;
debug2.useColors = createDebug.useColors();
debug2.color = createDebug.selectColor(namespace);
debug2.extend = extend;
debug2.destroy = createDebug.destroy;
Object.defineProperty(debug2, "enabled", {
enumerable: true,
configurable: false,
get: () => {
if (enableOverride !== null) {
return enableOverride;
}
if (namespacesCache !== createDebug.namespaces) {
namespacesCache = createDebug.namespaces;
enabledCache = createDebug.enabled(namespace);
}
return enabledCache;
},
set: (v) => {
enableOverride = v;
}
});
if (typeof createDebug.init === "function") {
createDebug.init(debug2);
}
return debug2;
}
function extend(namespace, delimiter) {
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
newDebug.log = this.log;
return newDebug;
}
function enable(namespaces) {
createDebug.save(namespaces);
createDebug.namespaces = namespaces;
createDebug.names = [];
createDebug.skips = [];
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
for (const ns of split) {
if (ns[0] === "-") {
createDebug.skips.push(ns.slice(1));
} else {
createDebug.names.push(ns);
}
}
}
function matchesTemplate(search, template) {
let searchIndex = 0;
let templateIndex = 0;
let starIndex = -1;
let matchIndex = 0;
while (searchIndex < search.length) {
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
if (template[templateIndex] === "*") {
starIndex = templateIndex;
matchIndex = searchIndex;
templateIndex++;
} else {
searchIndex++;
templateIndex++;
}
} else if (starIndex !== -1) {
templateIndex = starIndex + 1;
matchIndex++;
searchIndex = matchIndex;
} else {
return false;
}
}
while (templateIndex < template.length && template[templateIndex] === "*") {
templateIndex++;
}
return templateIndex === template.length;
}
function disable() {
const namespaces = [
...createDebug.names,
...createDebug.skips.map((namespace) => "-" + namespace)
].join(",");
createDebug.enable("");
return namespaces;
}
function enabled(name) {
for (const skip of createDebug.skips) {
if (matchesTemplate(name, skip)) {
return false;
}
}
for (const ns of createDebug.names) {
if (matchesTemplate(name, ns)) {
return true;
}
}
return false;
}
function coerce2(val) {
if (val instanceof Error) {
return val.stack || val.message;
}
return val;
}
function destroy() {
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
}
createDebug.enable(createDebug.load());
return createDebug;
}
module.exports = setup;
}
});
// node_modules/debug/src/browser.js
var require_browser = __commonJS({
"node_modules/debug/src/browser.js"(exports, module) {
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = localstorage();
exports.destroy = /* @__PURE__ */ (() => {
let warned = false;
return () => {
if (!warned) {
warned = true;
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
}
};
})();
exports.colors = [
"#0000CC",
"#0000FF",
"#0033CC",
"#0033FF",
"#0066CC",
"#0066FF",
"#0099CC",
"#0099FF",
"#00CC00",
"#00CC33",
"#00CC66",
"#00CC99",
"#00CCCC",
"#00CCFF",
"#3300CC",
"#3300FF",
"#3333CC",
"#3333FF",
"#3366CC",
"#3366FF",
"#3399CC",
"#3399FF",
"#33CC00",
"#33CC33",
"#33CC66",
"#33CC99",
"#33CCCC",
"#33CCFF",
"#6600CC",
"#6600FF",
"#6633CC",
"#6633FF",
"#66CC00",
"#66CC33",
"#9900CC",
"#9900FF",
"#9933CC",
"#9933FF",
"#99CC00",
"#99CC33",
"#CC0000",
"#CC0033",
"#CC0066",
"#CC0099",
"#CC00CC",
"#CC00FF",
"#CC3300",
"#CC3333",
"#CC3366",
"#CC3399",
"#CC33CC",
"#CC33FF",
"#CC6600",
"#CC6633",
"#CC9900",
"#CC9933",
"#CCCC00",
"#CCCC33",
"#FF0000",
"#FF0033",
"#FF0066",
"#FF0099",
"#FF00CC",
"#FF00FF",
"#FF3300",
"#FF3333",
"#FF3366",
"#FF3399",
"#FF33CC",
"#FF33FF",
"#FF6600",
"#FF6633",
"#FF9900",
"#FF9933",
"#FFCC00",
"#FFCC33"
];
function useColors() {
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
return true;
}
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
return false;
}
let m;
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
}
function formatArgs(args) {
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
if (!this.useColors) {
return;
}
const c = "color: " + this.color;
args.splice(1, 0, c, "color: inherit");
let index = 0;
let lastC = 0;
args[0].replace(/%[a-zA-Z%]/g, (match) => {
if (match === "%%") {
return;
}
index++;
if (match === "%c") {
lastC = index;
}
});
args.splice(lastC, 0, c);
}
exports.log = console.debug || console.log || (() => {
});
function save(namespaces) {
try {
if (namespaces) {
exports.storage.setItem("debug", namespaces);
} else {
exports.storage.removeItem("debug");
}
} catch (error) {
}
}
function load() {
let r2;
try {
r2 = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
} catch (error) {
}
if (!r2 && typeof process !== "undefined" && "env" in process) {
r2 = process.env.DEBUG;
}
return r2;
}
function localstorage() {
try {
return localStorage;
} catch (error) {
}
}
module.exports = require_common()(exports);
var { formatters: formatters2 } = module.exports;
formatters2.j = function(v) {
try {
return JSON.stringify(v);
} catch (error) {
return "[UnexpectedJSONParseError]: " + error.message;
}
};
}
});
// ../../../node_modules/has-flag/index.js
var require_has_flag = __commonJS({
"../../../node_modules/has-flag/index.js"(exports, module) {
"use strict";
module.exports = (flag, argv) => {
argv = argv || process.argv;
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
const pos = argv.indexOf(prefix + flag);
const terminatorPos = argv.indexOf("--");
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
};
}
});
// ../../../node_modules/supports-color/index.js
var require_supports_color = __commonJS({
"../../../node_modules/supports-color/index.js"(exports, module) {
"use strict";
var os2 = __require("os");
var hasFlag = require_has_flag();
var env = process.env;
var forceColor;
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
forceColor = false;
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
forceColor = true;
}
if ("FORCE_COLOR" in env) {
forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
}
function translateLevel(level) {
if (level === 0) {
return false;
}
return {
level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3
};
}
function supportsColor(stream) {
if (forceColor === false) {
return 0;
}
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
return 3;
}
if (hasFlag("color=256")) {
return 2;
}
if (stream && !stream.isTTY && forceColor !== true) {
return 0;
}
const min = forceColor ? 1 : 0;
if (process.platform === "win32") {
const osRelease = os2.release().split(".");
if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
return Number(osRelease[2]) >= 14931 ? 3 : 2;
}
return 1;
}
if ("CI" in env) {
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
return 1;
}
return min;
}
if ("TEAMCITY_VERSION" in env) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}
if (env.COLORTERM === "truecolor") {
return 3;
}
if ("TERM_PROGRAM" in env) {
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
switch (env.TERM_PROGRAM) {
case "iTerm.app":
return version >= 3 ? 3 : 2;
case "Apple_Terminal":
return 2;
}
}
if (/-256(color)?$/i.test(env.TERM)) {
return 2;
}
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
return 1;
}
if ("COLORTERM" in env) {
return 1;
}
if (env.TERM === "dumb") {
return min;
}
return min;
}
function getSupportLevel(stream) {
const level = supportsColor(stream);
return translateLevel(level);
}
module.exports = {
supportsColor: getSupportLevel,
stdout: getSupportLevel(process.stdout),
stderr: getSupportLevel(process.stderr)
};
}
});
// node_modules/debug/src/node.js
var require_node = __commonJS({
"node_modules/debug/src/node.js"(exports, module) {
var tty = __require("tty");
var util2 = __require("util");
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.destroy = util2.deprecate(
() => {
},
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
);
exports.colors = [6, 2, 3, 4, 5, 1];
try {
const supportsColor = require_supports_color();
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
exports.colors = [
20,
21,
26,
27,
32,
33,
38,
39,
40,
41,
42,
43,
44,
45,
56,
57,
62,
63,
68,
69,
74,
75,
76,
77,
78,
79,
80,
81,
92,
93,
98,
99,
112,
113,
128,
129,
134,
135,
148,
149,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169,
170,
171,
172,
173,
178,
179,
184,
185,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208,
209,
214,
215,
220,
221
];
}
} catch (error) {
}
exports.inspectOpts = Object.keys(process.env).filter((key) => {
return /^debug_/i.test(key);
}).reduce((obj, key) => {
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
return k.toUpperCase();
});
let val = process.env[key];
if (/^(yes|on|true|enabled)$/i.test(val)) {
val = true;
} else if (/^(no|off|false|disabled)$/i.test(val)) {
val = false;
} else if (val === "null") {
val = null;
} else {
val = Number(val);
}
obj[prop] = val;
return obj;
}, {});
function useColors() {
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
}
function formatArgs(args) {
const { namespace: name, useColors: useColors2 } = this;
if (useColors2) {
const c = this.color;
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
} else {
args[0] = getDate() + name + " " + args[0];
}
}
function getDate() {
if (exports.inspectOpts.hideDate) {
return "";
}
return (/* @__PURE__ */ new Date()).toISOString() + " ";
}
function log(...args) {
return process.stderr.write(util2.formatWithOptions(exports.inspectOpts, ...args) + "\n");
}
function save(namespaces) {
if (namespaces) {
process.env.DEBUG = namespaces;
} else {
delete process.env.DEBUG;
}
}
function load() {
return process.env.DEBUG;
}
function init(debug2) {
debug2.inspectOpts = {};
const keys = Object.keys(exports.inspectOpts);
for (let i3 = 0; i3 < keys.length; i3++) {
debug2.inspectOpts[keys[i3]] = exports.inspectOpts[keys[i3]];
}
}
module.exports = require_common()(exports);
var { formatters: formatters2 } = module.exports;
formatters2.o = function(v) {
this.inspectOpts.colors = this.useColors;
return util2.inspect(v, this.inspectOpts).split("\n").map((str2) => str2.trim()).join(" ");
};
formatters2.O = function(v) {
this.inspectOpts.colors = this.useColors;
return util2.inspect(v, this.inspectOpts);
};
}
});
// node_modules/debug/src/index.js
var require_src = __commonJS({
"node_modules/debug/src/index.js"(exports, module) {
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
module.exports = require_browser();
} else {
module.exports = require_node();
}
}
});
// node_modules/create-hash/index.js
var require_create_hash = __commonJS({
"node_modules/create-hash/index.js"(exports, module) {
module.exports = __require("crypto").createHash;
}
});
// node_modules/bech32/index.js
var require_bech32 = __commonJS({
"node_modules/bech32/index.js"(exports, module) {
"use strict";
var ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
var ALPHABET_MAP = {};
for (z2 = 0; z2 < ALPHABET.length; z2++) {
x = ALPHABET.charAt(z2);
if (ALPHABET_MAP[x] !== void 0)
throw new TypeError(x + " is ambiguous");
ALPHABET_MAP[x] = z2;
}
var x;
var z2;
function polymodStep(pre) {
var b = pre >> 25;
return (pre & 33554431) << 5 ^ -(b >> 0 & 1) & 996825010 ^ -(b >> 1 & 1) & 642813549 ^ -(b >> 2 & 1) & 513874426 ^ -(b >> 3 & 1) & 1027748829 ^ -(b >> 4 & 1) & 705979059;
}
function prefixChk(prefix) {
var chk = 1;
for (var i3 = 0; i3 < prefix.length; ++i3) {
var c = prefix.charCodeAt(i3);
if (c < 33 || c > 126)
return "Invalid prefix (" + prefix + ")";
chk = polymodStep(chk) ^ c >> 5;
}
chk = polymodStep(chk);
for (i3 = 0; i3 < prefix.length; ++i3) {
var v = prefix.charCodeAt(i3);
chk = polymodStep(chk) ^ v & 31;
}
return chk;
}
function encode3(prefix, words, LIMIT) {
LIMIT = LIMIT || 90;
if (prefix.length + 7 + words.length > LIMIT)
throw new TypeError("Exceeds length limit");
prefix = prefix.toLowerCase();
var chk = prefixChk(prefix);
if (typeof chk === "string")
throw new Error(chk);
var result = prefix + "1";
for (var i3 = 0; i3 < words.length; ++i3) {
var x2 = words[i3];
if (x2 >> 5 !== 0)
throw new Error("Non 5-bit word");
chk = polymodStep(chk) ^ x2;
result += ALPHABET.charAt(x2);
}
for (i3 = 0; i3 < 6; ++i3) {
chk = polymodStep(chk);
}
chk ^= 1;
for (i3 = 0; i3 < 6; ++i3) {
var v = chk >> (5 - i3) * 5 & 31;
result += ALPHABET.charAt(v);
}
return result;
}
function __decode(str2, LIMIT) {
LIMIT = LIMIT || 90;
if (str2.length < 8)
return str2 + " too short";
if (str2.length > LIMIT)
return "Exceeds length limit";
var lowered = str2.toLowerCase();
var uppered = str2.toUpperCase();
if (str2 !== lowered && str2 !== uppered)
return "Mixed-case string " + str2;
str2 = lowered;
var split = str2.lastIndexOf("1");
if (split === -1)
return "No separator character for " + str2;
if (split === 0)
return "Missing prefix for " + str2;
var prefix = str2.slice(0, split);
var wordChars = str2.slice(split + 1);
if (wordChars.length < 6)
return "Data too short";
var chk = prefixChk(prefix);
if (typeof chk === "string")
return chk;
var words = [];
for (var i3 = 0; i3 < wordChars.length; ++i3) {
var c = wordChars.charAt(i3);
var v = ALPHABET_MAP[c];
if (v === void 0)
return "Unknown character " + c;
chk = polymodStep(chk) ^ v;
if (i3 + 6 >= wordChars.length)
continue;
words.push(v);
}
if (chk !== 1)
return "Invalid checksum for " + str2;
return { prefix, words };
}
function decodeUnsafe() {
var res = __decode.apply(null, arguments);
if (typeof res === "object")
return res;
}
function decode5(str2) {
var res = __decode.apply(null, arguments);
if (typeof res === "object")
return res;
throw new Error(res);
}
function convert(data, inBits, outBits, pad3) {
var value = 0;
var bits = 0;
var maxV = (1 << outBits) - 1;
var result = [];
for (var i3 = 0; i3 < data.length; ++i3) {
value = value << inBits | data[i3];
bits += inBits;
while (bits >= outBits) {
bits -= outBits;
result.push(value >> bits & maxV);
}
}
if (pad3) {
if (bits > 0) {
result.push(value << outBits - bits & maxV);
}
} else {
if (bits >= inBits)
return "Excess padding";
if (value << outBits - bits & maxV)
return "Non-zero padding";
}
return result;
}
function toWordsUnsafe(bytes6) {
var res = convert(bytes6, 8, 5, true);
if (Array.isArray(res))
return res;
}
function toWords(bytes6) {
var res = convert(bytes6, 8, 5, true);
if (Array.isArray(res))
return res;
throw new Error(res);
}
function fromWordsUnsafe(words) {
var res = convert(words, 5, 8, false);
if (Array.isArray(res))
return res;
}
function fromWords(words) {
var res = convert(words, 5, 8, false);
if (Array.isArray(res))
return res;
throw new Error(res);
}
module.exports = {
decodeUnsafe,
decode: decode5,
encode: encode3,
toWordsUnsafe,
toWords,
fromWordsUnsafe,
fromWords
};
}
});
// node_modules/node-gyp-build/node-gyp-build.js
var require_node_gyp_build = __commonJS({
"node_modules/node-gyp-build/node-gyp-build.js"(exports, module) {
var fs = __require("fs");
var path3 = __require("path");
var os2 = __require("os");
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
var vars = process.config && process.config.variables || {};
var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
var abi = process.versions.modules;
var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
var arch = process.env.npm_config_arch || os2.arch();
var platform = process.env.npm_config_platform || os2.platform();
var libc = process.env.LIBC || (isAlpine(platform) ? "musl" : "glibc");
var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
var uv = (process.versions.uv || "").split(".")[0];
module.exports = load;
function load(dir) {
return runtimeRequire(load.resolve(dir));
}
load.resolve = load.path = function(dir) {
dir = path3.resolve(dir || ".");
try {
var name = runtimeRequire(path3.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
if (process.env[name + "_PREBUILD"])
dir = process.env[name + "_PREBUILD"];
} catch (err) {
}
if (!prebuildsOnly) {
var release = getFirst(path3.join(dir, "build/Release"), matchBuild);
if (release)
return release;
var debug2 = getFirst(path3.join(dir, "build/Debug"), matchBuild);
if (debug2)
return debug2;
}
var prebuild = resolve(dir);
if (prebuild)
return prebuild;
var nearby = resolve(path3.dirname(process.execPath));
if (nearby)
return nearby;
var target = [
"platform=" + platform,
"arch=" + arch,
"runtime=" + runtime,
"abi=" + abi,
"uv=" + uv,
armv ? "armv=" + armv : "",
"libc=" + libc,
"node=" + process.versions.node,
process.versions.electron ? "electron=" + process.versions.electron : "",
typeof __webpack_require__ === "function" ? "webpack=true" : ""
// eslint-disable-line
].filter(Boolean).join(" ");
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
function resolve(dir2) {
var tuples = readdirSync(path3.join(dir2, "prebuilds")).map(parseTuple);
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
if (!tuple)
return;
var prebuilds = path3.join(dir2, "prebuilds", tuple.name);
var parsed = readdirSync(prebuilds).map(parseTags);
var candidates = parsed.filter(matchTags(runtime, abi));
var winner = candidates.sort(compareTags(runtime))[0];
if (winner)
return path3.join(prebuilds, winner.file);
}
};
function readdirSync(dir) {
try {
return fs.readdirSync(dir);
} catch (err) {
return [];
}
}
function getFirst(dir, filter) {
var files = readdirSync(dir).filter(filter);
return files[0] && path3.join(dir, files[0]);
}
function matchBuild(name) {
return /\.node$/.test(name);
}
function parseTuple(name) {
var arr = name.split("-");
if (arr.length !== 2)
return;
var platform2 = arr[0];
var architectures = arr[1].split("+");
if (!platform2)
return;
if (!architectures.length)
return;
if (!architectures.every(Boolean))
return;
return { name, platform: platform2, architectures };
}
function matchTuple(platform2, arch2) {
return function(tuple) {
if (tuple == null)
return false;
if (tuple.platform !== platform2)
return false;
return tuple.architectures.includes(arch2);
};
}
function compareTuples(a, b) {
return a.architectures.length - b.architectures.length;
}
function parseTags(file) {
var arr = file.split(".");
var extension = arr.pop();
var tags = { file, specificity: 0 };
if (extension !== "node")
return;
for (var i3 = 0; i3 < arr.length; i3++) {
var tag = arr[i3];
if (tag === "node" || tag === "electron" || tag === "node-webkit") {
tags.runtime = tag;
} else if (tag === "napi") {
tags.napi = true;
} else if (tag.slice(0, 3) === "abi") {
tags.abi = tag.slice(3);
} else if (tag.slice(0, 2) === "uv") {
tags.uv = tag.slice(2);
} else if (tag.slice(0, 4) === "armv") {
tags.armv = tag.slice(4);
} else if (tag === "glibc" || tag === "musl") {
tags.libc = tag;
} else {
continue;
}
tags.specificity++;
}
return tags;
}
function matchTags(runtime2, abi2) {
return function(tags) {
if (tags == null)
return false;
if (tags.runtime && tags.runtime !== runtime2 && !runtimeAgnostic(tags))
return false;
if (tags.abi && tags.abi !== abi2 && !tags.napi)
return false;
if (tags.uv && tags.uv !== uv)
return false;
if (tags.armv && tags.armv !== armv)
return false;
if (tags.libc && tags.libc !== libc)
return false;
return true;
};
}
function runtimeAgnostic(tags) {
return tags.runtime === "node" && tags.napi;
}
function compareTags(runtime2) {
return function(a, b) {
if (a.runtime !== b.runtime) {
return a.runtime === runtime2 ? -1 : 1;
} else if (a.abi !== b.abi) {
return a.abi ? -1 : 1;
} else if (a.specificity !== b.specificity) {
return a.specificity > b.specificity ? -1 : 1;
} else {
return 0;
}
};
}
function isNwjs() {
return !!(process.versions && process.versions.nw);
}
function isElectron() {
if (process.versions && process.versions.electron)
return true;
if (process.env.ELECTRON_RUN_AS_NODE)
return true;
return typeof window !== "undefined" && window.process && window.process.type === "renderer";
}
function isAlpine(platform2) {
return platform2 === "linux" && fs.existsSync("/etc/alpine-release");
}
load.parseTags = parseTags;
load.matchTags = matchTags;
load.compareTags = compareTags;
load.parseTuple = parseTuple;
load.matchTuple = matchTuple;
load.compareTuples = compareTuples;
}
});
// node_modules/node-gyp-build/index.js
var require_node_gyp_build2 = __commonJS({
"node_modules/node-gyp-build/index.js"(exports, module) {
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
if (typeof runtimeRequire.addon === "function") {
module.exports = runtimeRequire.addon.bind(runtimeRequire);
} else {
module.exports = require_node_gyp_build();
}
}
});
// node_modules/secp256k1/lib/index.js
var require_lib = __commonJS({
"node_modules/secp256k1/lib/index.js"(exports, module) {
var errors = {
IMPOSSIBLE_CASE: "Impossible case. Please create issue.",
TWEAK_ADD: "The tweak was out of range or the resulted private key is invalid",
TWEAK_MUL: "The tweak was out of range or equal to zero",
CONTEXT_RANDOMIZE_UNKNOW: "Unknow error on context randomization",
SECKEY_INVALID: "Private Key is invalid",
PUBKEY_PARSE: "Public Key could not be parsed",
PUBKEY_SERIALIZE: "Public Key serialization error",
PUBKEY_COMBINE: "The sum of the public keys is not valid",
SIG_PARSE: "Signature could not be parsed",
SIGN: "The nonce generation function failed, or the private key was invalid",
RECOVER: "Public key could not be recover",
ECDH: "Scalar was invalid (zero or overflow)"
};
function assert3(cond, msg) {
if (!cond)
throw new Error(msg);
}
function isUint8Array(name, value, length) {
assert3(value instanceof Uint8Array, `Expected ${name} to be an Uint8Array`);
if (length !== void 0) {
if (Array.isArray(length)) {
const numbers = length.join(", ");
const msg = `Expected ${name} to be an Uint8Array with length [${numbers}]`;
assert3(length.includes(value.length), msg);
} else {
const msg = `Expected ${name} to be an Uint8Array with length ${length}`;
assert3(value.length === length, msg);
}
}
}
function isCompressed(value) {
assert3(toTypeString(value) === "Boolean", "Expected compressed to be a Boolean");
}
function getAssertedOutput(output6 = (len) => new Uint8Array(len), length) {
if (typeof output6 === "function")
output6 = output6(length);
isUint8Array("output", output6, length);
return output6;
}
function toTypeString(value) {
return Object.prototype.toString.call(value).slice(8, -1);
}
module.exports = (secp256k12) => {
return {
contextRandomize(seed) {
assert3(
seed === null || seed instanceof Uint8Array,
"Expected seed to be an Uint8Array or null"
);
if (seed !== null)
isUint8Array("seed", seed, 32);
switch (secp256k12.contextRandomize(seed)) {
case 1:
throw new Error(errors.CONTEXT_RANDOMIZE_UNKNOW);
}
},
privateKeyVerify(seckey) {
isUint8Array("private key", seckey, 32);
return secp256k12.privateKeyVerify(seckey) === 0;
},
privateKeyNegate(seckey) {
isUint8Array("private key", seckey, 32);
switch (secp256k12.privateKeyNegate(seckey)) {
case 0:
return seckey;
case 1:
throw new Error(errors.IMPOSSIBLE_CASE);
}
},
privateKeyTweakAdd(seckey, tweak) {
isUint8Array("private key", seckey, 32);
isUint8Array("tweak", tweak, 32);
switch (secp256k12.privateKeyTweakAdd(seckey, tweak)) {
case 0:
return seckey;
case 1:
throw new Error(errors.TWEAK_ADD);
}
},
privateKeyTweakMul(seckey, tweak) {
isUint8Array("private key", seckey, 32);
isUint8Array("tweak", tweak, 32);
switch (secp256k12.privateKeyTweakMul(seckey, tweak)) {
case 0:
return seckey;
case 1:
throw new Error(errors.TWEAK_MUL);
}
},
publicKeyVerify(pubkey) {
isUint8Array("public key", pubkey, [33, 65]);
return secp256k12.publicKeyVerify(pubkey) === 0;
},
publicKeyCreate(seckey, compressed = true, output6) {
isUint8Array("private key", seckey, 32);
isCompressed(compressed);
output6 = getAssertedOutput(output6, compressed ? 33 : 65);
switch (secp256k12.publicKeyCreate(output6, seckey)) {
case 0:
return output6;
case 1:
throw new Error(errors.SECKEY_INVALID);
case 2:
throw new Error(errors.PUBKEY_SERIALIZE);
}
},
publicKeyConvert(pubkey, compressed = true, output6) {
isUint8Array("public key", pubkey, [33, 65]);
isCompressed(compressed);
output6 = getAssertedOutput(output6, compressed ? 33 : 65);
switch (secp256k12.publicKeyConvert(output6, pubkey)) {
case 0:
return output6;
case 1:
throw new Error(errors.PUBKEY_PARSE);
case 2:
throw new Error(errors.PUBKEY_SERIALIZE);
}
},
publicKeyNegate(pubkey, compressed = true, output6) {
isUint8Array("public key", pubkey, [33, 65]);
isCompressed(compressed);
output6 = getAssertedOutput(output6, compressed ? 33 : 65);
switch (secp256k12.publicKeyNegate(output6, pubkey)) {
case 0:
return output6;
case 1:
throw new Error(errors.PUBKEY_PARSE);
case 2:
throw new Error(errors.IMPOSSIBLE_CASE);
case 3:
throw new Error(errors.PUBKEY_SERIALIZE);
}
},
publicKeyCombine(pubkeys, compressed = true, output6) {
assert3(Array.isArray(pubkeys), "Expected public keys to be an Array");
assert3(pubkeys.length > 0, "Expected public keys array will have more than zero items");
for (const pubkey of pubkeys) {
isUint8Array("public key", pubkey, [33, 65]);
}
isCompressed(compressed);
output6 = getAssertedOutput(output6, compressed ? 33 : 65);
switch (secp256k12.publicKeyCombine(output6, pubkeys)) {
case 0:
return output6;
case 1:
throw new Error(errors.PUBKEY_PARSE);
case 2:
throw new Error(errors.PUBKEY_COMBINE);
case 3:
throw new Error(errors.PUBKEY_SERIALIZE);
}
},
publicKeyTweakAdd(pubkey, tweak, compressed = true, output6) {
isUint8Array("public key", pubkey, [33, 65]);
isUint8Array("tweak", tweak, 32);
isCompressed(compressed);
output6 = getAssertedOutput(output6, compressed ? 33 : 65);
switch (secp256k12.publicKeyTweakAdd(output6, pubkey, tweak)) {
case 0:
return output6;
case 1:
throw new Error(errors.PUBKEY_PARSE);
case 2:
throw new Error(errors.TWEAK_ADD);
}
},
publicKeyTweakMul(pubkey, tweak, compressed = true, output6) {
isUint8Array("public key", pubkey, [33, 65]);
isUint8Array("tweak", tweak, 32);
isCompressed(compressed);
output6 = getAssertedOutput(output6, compressed ? 33 : 65);
switch (secp256k12.publicKeyTweakMul(output6, pubkey, tweak)) {
case 0:
return output6;
case 1:
throw new Error(errors.PUBKEY_PARSE);
case 2:
throw new Error(errors.TWEAK_MUL);
}
},
signatureNormalize(sig) {
isUint8Array("signature", sig, 64);
switch (secp256k12.signatureNormalize(sig)) {
case 0:
return sig;
case 1:
throw new Error(errors.SIG_PARSE);
}
},
signatureExport(sig, output6) {
isUint8Array("signature", sig, 64);
output6 = getAssertedOutput(output6, 72);
const obj = { output: output6, outputlen: 72 };
switch (secp256k12.signatureExport(obj, sig)) {
case 0:
return output6.slice(0, obj.outputlen);
case 1:
throw new Error(errors.SIG_PARSE);
case 2:
throw new Error(errors.IMPOSSIBLE_CASE);
}
},
signatureImport(sig, output6) {
isUint8Array("signature", sig);
output6 = getAssertedOutput(output6, 64);
switch (secp256k12.signatureImport(output6, sig)) {
case 0:
return output6;
case 1:
throw new Error(errors.SIG_PARSE);
case 2:
throw new Error(errors.IMPOSSIBLE_CASE);
}
},
ecdsaSign(msg32, seckey, options = {}, output6) {
isUint8Array("message", msg32, 32);
isUint8Array("private key", seckey, 32);
assert3(toTypeString(options) === "Object", "Expected options to be an Object");
if (options.data !== void 0)
isUint8Array("options.data", options.data);
if (options.noncefn !== void 0)
assert3(toTypeString(options.noncefn) === "Function", "Expected options.noncefn to be a Function");
output6 = getAssertedOutput(output6, 64);
const obj = { signature: output6, recid: null };
switch (secp256k12.ecdsaSign(obj, msg32, seckey, options.data, options.noncefn)) {
case 0:
return obj;
case 1:
throw new Error(errors.SIGN);
case 2:
throw new Error(errors.IMPOSSIBLE_CASE);
}
},
ecdsaVerify(sig, msg32, pubkey) {
isUint8Array("signature", sig, 64);
isUint8Array("message", msg32, 32);
isUint8Array("public key", pubkey, [33, 65]);
switch (secp256k12.ecdsaVerify(sig, msg32, pubkey)) {
case 0:
return true;
case 3:
return false;
case 1:
throw new Error(errors.SIG_PARSE);
case 2:
throw new Error(errors.PUBKEY_PARSE);
}
},
ecdsaRecover(sig, recid, msg32, compressed = true, output6) {
isUint8Array("signature", sig, 64);
assert3(
toTypeString(recid) === "Number" && recid >= 0 && recid <= 3,
"Expected recovery id to be a Number within interval [0, 3]"
);
isUint8Array("message", msg32, 32);
isCompressed(compressed);
output6 = getAssertedOutput(output6, compressed ? 33 : 65);
switch (secp256k12.ecdsaRecover(output6, sig, recid, msg32)) {
case 0:
return output6;
case 1:
throw new Error(errors.SIG_PARSE);
case 2:
throw new Error(errors.RECOVER);
case 3:
throw new Error(errors.IMPOSSIBLE_CASE);
}
},
ecdh(pubkey, seckey, options = {}, output6) {
isUint8Array("public key", pubkey, [33, 65]);
isUint8Array("private key", seckey, 32);
assert3(toTypeString(options) === "Object", "Expected options to be an Object");
if (options.data !== void 0)
isUint8Array("options.data", options.data);
if (options.hashfn !== void 0) {
assert3(toTypeString(options.hashfn) === "Function", "Expected options.hashfn to be a Function");
if (options.xbuf !== void 0)
isUint8Array("options.xbuf", options.xbuf, 32);
if (options.ybuf !== void 0)
isUint8Array("options.ybuf", options.ybuf, 32);
isUint8Array("output", output6);
} else {
output6 = getAssertedOutput(output6, 32);
}
switch (secp256k12.ecdh(output6, pubkey, seckey, options.data, options.hashfn, options.xbuf, options.ybuf)) {
case 0:
return output6;
case 1:
throw new Error(errors.PUBKEY_PARSE);
case 2:
throw new Error(errors.ECDH);
}
}
};
};
}
});
// node_modules/secp256k1/bindings.js
var require_bindings = __commonJS({
"node_modules/secp256k1/bindings.js"(exports, module) {
var addon = require_node_gyp_build2()(__dirname);
module.exports = require_lib()(new addon.Secp256k1());
}
});
// node_modules/elliptic/package.json
var require_package = __commonJS({
"node_modules/elliptic/package.json"(exports, module) {
module.exports = {
name: "elliptic",
version: "6.6.1",
description: "EC cryptography",
main: "lib/elliptic.js",
files: [
"lib"
],
scripts: {
lint: "eslint lib test",
"lint:fix": "npm run lint -- --fix",
unit: "istanbul test _mocha --reporter=spec test/index.js",
test: "npm run lint && npm run unit",
version: "grunt dist && git add dist/"
},
repository: {
type: "git",
url: "git@github.com:indutny/elliptic"
},
keywords: [
"EC",
"Elliptic",
"curve",
"Cryptography"
],
author: "Fedor Indutny <fedor@indutny.com>",
license: "MIT",
bugs: {
url: "https://github.com/indutny/elliptic/issues"
},
homepage: "https://github.com/indutny/elliptic",
devDependencies: {
brfs: "^2.0.2",
coveralls: "^3.1.0",
eslint: "^7.6.0",
grunt: "^1.2.1",
"grunt-browserify": "^5.3.0",
"grunt-cli": "^1.3.2",
"grunt-contrib-connect": "^3.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^5.0.0",
"grunt-mocha-istanbul": "^5.0.2",
"grunt-saucelabs": "^9.0.1",
istanbul: "^0.4.5",
mocha: "^8.0.1"
},
dependencies: {
"bn.js": "^4.11.9",
brorand: "^1.1.0",
"hash.js": "^1.0.0",
"hmac-drbg": "^1.0.1",
inherits: "^2.0.4",
"minimalistic-assert": "^1.0.1",
"minimalistic-crypto-utils": "^1.0.1"
}
};
}
});
// node_m