var __bare_os_bundle_exports__ = (() => { 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, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.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 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __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 || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../../node_modules/bare-semver/lib/constants.js var require_constants = __commonJS({ "../../node_modules/bare-semver/lib/constants.js"(exports, module) { module.exports = { EQ: 1, LT: 2, LTE: 3, GT: 4, GTE: 5 }; } }); // ../../node_modules/bare-semver/lib/errors.js var require_errors = __commonJS({ "../../node_modules/bare-semver/lib/errors.js"(exports, module) { module.exports = class SemVerError extends Error { constructor(msg, code, fn = SemVerError) { super(`${code}: ${msg}`); this.code = code; if (Error.captureStackTrace) { Error.captureStackTrace(this, fn); } } get name() { return "SemVerError"; } static INVALID_VERSION(msg, fn = SemVerError.INVALID_VERSION) { return new SemVerError(msg, "INVALID_VERSION", fn); } static INVALID_RANGE(msg, fn = SemVerError.INVALID_RANGE) { return new SemVerError(msg, "INVALID_RANGE", fn); } }; } }); // ../../node_modules/bare-semver/lib/version.js var require_version = __commonJS({ "../../node_modules/bare-semver/lib/version.js"(exports, module) { var errors = require_errors(); var Version = class { constructor(major, minor, patch, opts = {}) { const { prerelease = [], build = [] } = opts; this.major = major; this.minor = minor; this.patch = patch; this.prerelease = prerelease; this.build = build; } compare(version) { return exports.compare(this, version); } toString() { let result = `${this.major}.${this.minor}.${this.patch}`; if (this.prerelease.length) { result += "-" + this.prerelease.join("."); } if (this.build.length) { result += "+" + this.build.join("."); } return result; } }; module.exports = exports = Version; exports.parse = function parse(input, state = { position: 0, partial: false, range: false }) { let i = state.position; let c; const unexpected = (expected) => { let msg; if (i >= input.length) { msg = `Unexpected end of input in '${input}'`; } else { msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`; } if (expected) msg += `, ${expected}`; throw errors.INVALID_VERSION(msg, unexpected); }; const components = [0, 0, 0]; let k = 0; while (k < 3) { c = input[i]; if (k > 0) { if (c === ".") c = input[++i]; else if (state.range) break; else unexpected("expected '.'"); } if (c === "0") { i++; k++; } else if (c >= "1" && c <= "9") { let j = 0; do c = input[i + ++j]; while (c >= "0" && c <= "9"); components[k++] = parseInt(input.substring(i, i + j)); i += j; } else unexpected("expected /[0-9]/"); } const prerelease = []; if (k === 3 && input[i] === "-") { i++; while (true) { c = input[i]; let tag = ""; let j = 0; while (c >= "0" && c <= "9") c = input[i + ++j]; let isNumeric = false; if (j) { tag += input.substring(i, i + j); c = input[i += j]; isNumeric = tag[0] !== "0" || tag.length === 1; } j = 0; while (c >= "0" && c <= "9" || c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "-") c = input[i + ++j]; if (j) { tag += input.substring(i, i + j); c = input[i += j]; } else if (!isNumeric) unexpected("expected /[a-zA-Z-]/"); prerelease.push(tag); if (c === ".") c = input[++i]; else break; } } const build = []; if (k === 3 && input[i] === "+") { i++; while (true) { c = input[i]; let tag = ""; let j = 0; while (c >= "0" && c <= "9" || c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "-") c = input[i + ++j]; if (j) { tag += input.substring(i, i + j); c = input[i += j]; } else unexpected("expected /[0-9a-zA-Z-]/"); build.push(tag); if (c === ".") c = input[++i]; else break; } } if (i < input.length && state.partial === false) { unexpected("expected end of input"); } state.position = i; return new Version(...components, { prerelease, build }); }; var integer = /^[0-9]+$/; exports.compare = function compare(a, b) { if (a.major > b.major) return 1; if (a.major < b.major) return -1; if (a.minor > b.minor) return 1; if (a.minor < b.minor) return -1; if (a.patch > b.patch) return 1; if (a.patch < b.patch) return -1; if (a.prerelease.length === 0) return b.prerelease.length === 0 ? 0 : 1; if (b.prerelease.length === 0) return -1; let i = 0; do { let x = a.prerelease[i]; let y = b.prerelease[i]; if (x === void 0) return y === void 0 ? 0 : -1; if (y === void 0) return 1; if (x === y) continue; const xInt = integer.test(x); const yInt = integer.test(y); if (xInt && yInt) { x = +x; y = +y; } else { if (xInt) return -1; if (yInt) return 1; } return x > y ? 1 : -1; } while (++i); }; } }); // ../../node_modules/bare-semver/lib/comparator.js var require_comparator = __commonJS({ "../../node_modules/bare-semver/lib/comparator.js"(exports, module) { var constants = require_constants(); var symbols = { [constants.EQ]: "=", [constants.LT]: "<", [constants.LTE]: "<=", [constants.GT]: ">", [constants.GTE]: ">=" }; module.exports = class Comparator { constructor(operator, version) { this.operator = operator; this.version = version; } test(version) { const result = version.compare(this.version); switch (this.operator) { case constants.LT: return result < 0; case constants.LTE: return result <= 0; case constants.GT: return result > 0; case constants.GTE: return result >= 0; default: return result === 0; } } toString() { return symbols[this.operator] + this.version; } }; } }); // ../../node_modules/bare-semver/lib/range.js var require_range = __commonJS({ "../../node_modules/bare-semver/lib/range.js"(exports, module) { var constants = require_constants(); var errors = require_errors(); var Version = require_version(); var Comparator = require_comparator(); var Range = class { constructor(comparators = []) { this.comparators = comparators; } test(version) { for (const set of this.comparators) { let matches = true; for (const comparator of set) { if (comparator.test(version)) continue; matches = false; break; } if (matches) return true; } return false; } toString() { let result = ""; let first = true; for (const set of this.comparators) { if (first) first = false; else result += " || "; result += set.join(" "); } return result; } }; module.exports = exports = Range; exports.parse = function parse(input, state = { position: 0, partial: false }) { let i = state.position; let c; const unexpected = (expected) => { let msg; if (i >= input.length) { msg = `Unexpected end of input in '${input}'`; } else { msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`; } if (expected) msg += `, ${expected}`; throw errors.INVALID_VERSION(msg, unexpected); }; const comparators = []; while (i < input.length) { const set = []; while (i < input.length) { c = input[i]; let operator = constants.EQ; if (c === "<") { operator = constants.LT; c = input[++i]; if (c === "=") { operator = constants.LTE; c = input[++i]; } } else if (c === ">") { operator = constants.GT; c = input[++i]; if (c === "=") { operator = constants.GTE; c = input[++i]; } } else if (c === "=") { c = input[++i]; } const state2 = { position: i, partial: true, range: true }; set.push(new Comparator(operator, Version.parse(input, state2))); c = input[i = state2.position]; while (c === " ") c = input[++i]; if (c === "|" && input[i + 1] === "|") { c = input[i += 2]; while (c === " ") c = input[++i]; break; } if (c && c !== "<" && c !== ">") unexpected("expected '||', '<', or '>'"); } if (set.length) comparators.push(set); } if (i < input.length && state.partial === false) { unexpected("expected end of input"); } state.position = i; return new Range(comparators); }; } }); // ../../node_modules/bare-semver/index.js var require_bare_semver = __commonJS({ "../../node_modules/bare-semver/index.js"(exports) { exports.constants = require_constants(); exports.errors = require_errors(); var Version = exports.Version = require_version(); var Range = exports.Range = require_range(); exports.Comparator = require_comparator(); exports.satisfies = function satisfies(version, range) { if (typeof version === "string") version = Version.parse(version); if (typeof range === "string") range = Range.parse(range); return range.test(version); }; } }); // ../../node_modules/bare-module-resolve/lib/errors.js var require_errors2 = __commonJS({ "../../node_modules/bare-module-resolve/lib/errors.js"(exports, module) { module.exports = class ModuleResolveError extends Error { constructor(msg, code, fn = ModuleResolveError) { super(`${code}: ${msg}`); this.code = code; if (Error.captureStackTrace) { Error.captureStackTrace(this, fn); } } get name() { return "ModuleResolveError"; } static INVALID_MODULE_SPECIFIER(msg) { return new ModuleResolveError( msg, "INVALID_MODULE_SPECIFIER", ModuleResolveError.INVALID_MODULE_SPECIFIER ); } static INVALID_PACKAGE_TARGET(msg) { return new ModuleResolveError( msg, "INVALID_PACKAGE_TARGET", ModuleResolveError.INVALID_PACKAGE_TARGET ); } static PACKAGE_PATH_NOT_EXPORTED(msg) { return new ModuleResolveError( msg, "PACKAGE_PATH_NOT_EXPORTED", ModuleResolveError.PACKAGE_PATH_NOT_EXPORTED ); } static PACKAGE_IMPORT_NOT_DEFINED(msg) { return new ModuleResolveError( msg, "PACKAGE_IMPORT_NOT_DEFINED", ModuleResolveError.PACKAGE_IMPORT_NOT_DEFINED ); } static UNSUPPORTED_ENGINE(msg) { return new ModuleResolveError(msg, "UNSUPPORTED_ENGINE", ModuleResolveError.UNSUPPORTED_ENGINE); } }; } }); // ../../node_modules/bare-module-resolve/index.js var require_bare_module_resolve = __commonJS({ "../../node_modules/bare-module-resolve/index.js"(exports, module) { var { satisfies } = require_bare_semver(); var errors = require_errors2(); module.exports = exports = function resolve(specifier, parentURL, opts, readPackage) { if (typeof opts === "function") { readPackage = opts; opts = {}; } else if (typeof readPackage !== "function") { readPackage = defaultReadPackage; } return { *[Symbol.iterator]() { const generator = exports.module(specifier, parentURL, opts); let next = generator.next(); while (next.done !== true) { const value = next.value; if (value.package) { next = generator.next(readPackage(value.package)); } else { next = generator.next(yield value.resolution); } } return next.value; }, async *[Symbol.asyncIterator]() { const generator = exports.module(specifier, parentURL, opts); let next = generator.next(); while (next.done !== true) { const value = next.value; if (value.package) { next = generator.next(await readPackage(value.package)); } else { next = generator.next(yield value.resolution); } } return next.value; } }; }; function defaultReadPackage() { return null; } var UNRESOLVED = 0; var YIELDED = 1; var RESOLVED = YIELDED | 2; exports.constants = { UNRESOLVED, YIELDED, RESOLVED }; exports.module = function* (specifier, parentURL, opts = {}) { const { resolutions = null, imports = null } = opts; if (exports.startsWithWindowsDriveLetter(specifier)) { specifier = "/" + specifier; } let status; if (resolutions) { status = yield* exports.preresolved(specifier, resolutions, parentURL, opts); if (status) return status; } status = yield* exports.url(specifier, parentURL, opts); if (status) return status; status = yield* exports.packageImports(specifier, parentURL, opts); if (status) return status; if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier[0] === "\\" || specifier.startsWith("./") || specifier.startsWith(".\\") || specifier.startsWith("../") || specifier.startsWith("..\\")) { if (imports) { status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts); if (status) return status; } status = yield* exports.deferred(specifier, opts); if (status) return status; status = yield* exports.file(specifier, parentURL, false, opts); if (status === RESOLVED) return status; return yield* exports.directory(specifier, parentURL, opts); } return yield* exports.package(specifier, parentURL, opts); }; exports.url = function* (url, parentURL, opts = {}) { const { imports = null, deferredProtocol = "deferred:", resolutions = null } = opts; let resolution; try { resolution = new URL(url); } catch { return UNRESOLVED; } if (imports) { const status = yield* exports.packageImportsExports( resolution.href, imports, parentURL, true, opts ); if (status) return status; } if (resolution.protocol === deferredProtocol) { const specifier = resolution.pathname; if (resolutions) { const imports2 = resolutions[parentURL.href]; if (typeof imports2 === "object" && imports2 !== null) { opts = { ...opts, resolutions: { ...resolutions, [parentURL.href]: { ...imports2, [specifier]: null } } }; } } return yield* exports.module(specifier, parentURL, opts); } if (resolution.protocol === "node:") { const specifier = resolution.pathname; if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier.startsWith("./") || specifier.startsWith("../")) { throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${url}' is not a valid package name`); } return yield* exports.package(specifier, parentURL, opts); } const resolved = yield { resolution }; return resolved ? RESOLVED : YIELDED; }; exports.preresolved = function* (specifier, resolutions, parentURL, opts = {}) { const imports = resolutions[parentURL.href]; if (typeof imports === "object" && imports !== null) { return yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts); } return UNRESOLVED; }; exports.deferred = function* (specifier, opts = {}) { const { deferredProtocol = "deferred:", defer = [] } = opts; if (defer.includes(specifier)) { const resolved = yield { resolution: new URL(deferredProtocol + specifier) }; return resolved ? RESOLVED : YIELDED; } return UNRESOLVED; }; exports.package = function* (packageSpecifier, parentURL, opts = {}) { const { builtins = [] } = opts; if (packageSpecifier === "") { throw errors.INVALID_MODULE_SPECIFIER( `Module specifier '${packageSpecifier}' is not a valid package name` ); } let packageName; if (packageSpecifier[0] !== "@") { packageName = packageSpecifier.split("/", 1).join(); } else { if (!packageSpecifier.includes("/")) { throw errors.INVALID_MODULE_SPECIFIER( `Module specifier '${packageSpecifier}' is not a valid package name` ); } packageName = packageSpecifier.split("/", 2).join("/"); } if (packageName[0] === "." || packageName.includes("\\") || packageName.includes("%")) { throw errors.INVALID_MODULE_SPECIFIER( `Module specifier '${packageSpecifier}' is not a valid package name` ); } let status; status = yield* exports.builtinTarget(packageSpecifier, null, builtins, opts); if (status) return status; status = yield* exports.deferred(packageSpecifier, opts); if (status) return status; let packageSubpath = "." + packageSpecifier.substring(packageName.length); status = yield* exports.packageSelf(packageName, packageSubpath, parentURL, opts); if (status) return status; parentURL = new URL(parentURL.href); for (const packageURL of exports.lookupPackageRoot(packageName, parentURL)) { const info = yield { package: packageURL }; if (info) { if (info.engines) exports.validateEngines(packageURL, info.engines, opts); if (info.exports) { return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts); } if (packageSubpath === ".") { if (typeof info.main === "string" && info.main !== "") { packageSubpath = info.main; } else { return yield* exports.file("index", packageURL, true, opts); } } status = yield* exports.file(packageSubpath, packageURL, false, opts); if (status === RESOLVED) return status; return yield* exports.directory(packageSubpath, packageURL, opts); } } return UNRESOLVED; }; exports.packageSelf = function* (packageName, packageSubpath, parentURL, opts = {}) { for (const packageURL of exports.lookupPackageScope(parentURL, opts)) { const info = yield { package: packageURL }; if (info) { if (info.name !== packageName) return false; if (info.exports) { return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts); } if (packageSubpath === ".") { if (typeof info.main === "string" && info.main !== "") { packageSubpath = info.main; } else { return yield* exports.file("index", packageURL, true, opts); } } const status = yield* exports.file(packageSubpath, packageURL, false, opts); if (status === RESOLVED) return status; return yield* exports.directory(packageSubpath, packageURL, opts); } } return UNRESOLVED; }; exports.packageExports = function* (packageURL, subpath, packageExports, opts = {}) { if (subpath === ".") { let mainExport; if (typeof packageExports === "string" || Array.isArray(packageExports)) { mainExport = packageExports; } else if (typeof packageExports === "object" && packageExports !== null) { const keys = Object.keys(packageExports); if (keys.some((key) => key.startsWith("."))) { if ("." in packageExports) mainExport = packageExports["."]; } else { mainExport = packageExports; } } if (mainExport) { const status = yield* exports.packageTarget(packageURL, mainExport, null, false, opts); if (status) return status; } } else if (typeof packageExports === "object" && packageExports !== null) { const keys = Object.keys(packageExports); if (keys.every((key) => key.startsWith("."))) { const status = yield* exports.packageImportsExports( subpath, packageExports, packageURL, false, opts ); if (status) return status; } } throw errors.PACKAGE_PATH_NOT_EXPORTED( `Package subpath '${subpath}' is not defined by "exports" in '${packageURL}'` ); }; exports.packageImports = function* (specifier, parentURL, opts = {}) { const { imports = null } = opts; if (specifier === "#" || specifier.startsWith("#/")) { throw errors.INVALID_MODULE_SPECIFIER( `Module specifier '${specifier}' is not a valid internal imports specifier` ); } for (const packageURL of exports.lookupPackageScope(parentURL, opts)) { const info = yield { package: packageURL }; if (info) { if (info.imports) { const status = yield* exports.packageImportsExports( specifier, info.imports, packageURL, true, opts ); if (status) return status; } if (specifier.startsWith("#")) { throw errors.PACKAGE_IMPORT_NOT_DEFINED( `Package import specifier '${specifier}' is not defined by "imports" in '${packageURL}'` ); } break; } } if (imports) { const status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts); if (status) return status; } return UNRESOLVED; }; exports.packageImportsExports = function* (matchKey, matchObject, packageURL, isImports, opts = {}) { if (matchKey in matchObject && !matchKey.includes("*")) { const target = matchObject[matchKey]; return yield* exports.packageTarget(packageURL, target, null, isImports, opts); } const expansionKeys = Object.keys(matchObject).filter((key) => key.includes("*")).sort(exports.patternKeyCompare); for (const expansionKey of expansionKeys) { const patternIndex = expansionKey.indexOf("*"); const patternBase = expansionKey.substring(0, patternIndex); if (matchKey.startsWith(patternBase) && matchKey !== patternBase) { const patternTrailer = expansionKey.substring(patternIndex + 1); if (patternTrailer === "" || matchKey.endsWith(patternTrailer) && matchKey.length >= expansionKey.length) { const target = matchObject[expansionKey]; const patternMatch = matchKey.substring( patternBase.length, matchKey.length - patternTrailer.length ); return yield* exports.packageTarget(packageURL, target, patternMatch, isImports, opts); } } } return UNRESOLVED; }; exports.validateEngines = function validateEngines(packageURL, packageEngines, opts = {}) { const { engines = {} } = opts; for (const [engine, range] of Object.entries(packageEngines)) { if (engine in engines) { const version = engines[engine]; if (!satisfies(version, range)) { throw errors.UNSUPPORTED_ENGINE( `Package not compatible with engine '${engine}' ${version}, requires range '${range}' defined by "engines" in '${packageURL}'` ); } } } }; exports.patternKeyCompare = function patternKeyCompare(keyA, keyB) { const patternIndexA = keyA.indexOf("*"); const patternIndexB = keyB.indexOf("*"); const baseLengthA = patternIndexA === -1 ? keyA.length : patternIndexA + 1; const baseLengthB = patternIndexB === -1 ? keyB.length : patternIndexB + 1; if (baseLengthA > baseLengthB) return -1; if (baseLengthB > baseLengthA) return 1; if (patternIndexA === -1) return 1; if (patternIndexB === -1) return -1; if (keyA.length > keyB.length) return -1; if (keyB.length > keyA.length) return 1; return 0; }; exports.packageTarget = function* (packageURL, target, patternMatch, isImports, opts = {}) { const { conditions = [], matchedConditions = [] } = opts; if (typeof target === "string") { if (!target.startsWith("./") && !isImports) { throw errors.INVALID_PACKAGE_TARGET( `Invalid target '${target}' defined by "exports" in '${packageURL}'` ); } if (patternMatch !== null) { target = target.replaceAll("*", patternMatch); } const status = yield* exports.url(target, packageURL, opts); if (status) return status; if (target === "." || target === ".." || target[0] === "/" || target.startsWith("./") || target.startsWith("../")) { const resolved = yield { resolution: new URL(target, packageURL) }; return resolved ? RESOLVED : YIELDED; } return yield* exports.package(target, packageURL, opts); } if (Array.isArray(target)) { for (const targetValue of target) { const status = yield* exports.packageTarget( packageURL, targetValue, patternMatch, isImports, opts ); if (status) return status; } } else if (typeof target === "object" && target !== null) { let status = UNRESOLVED; for (const [condition, targetValue, subset] of exports.conditionMatches( target, conditions, opts )) { matchedConditions.push(condition); status |= yield* exports.packageTarget(packageURL, targetValue, patternMatch, isImports, { ...opts, conditions: subset }); matchedConditions.pop(); } if (status) return status; } return UNRESOLVED; }; exports.builtinTarget = function* (packageSpecifier, packageVersion, target, opts = {}) { const { builtinProtocol = "builtin:", conditions = [], matchedConditions = [] } = opts; if (typeof target === "string") { const targetParts = target.split("@"); let targetName; let targetVersion; if (target[0] !== "@") { targetName = targetParts[0]; targetVersion = targetParts[1] || null; } else { targetName = targetParts.slice(0, 2).join("@"); targetVersion = targetParts[2] || null; } if (packageSpecifier === targetName) { if (packageVersion === null && targetVersion === null) { const resolved = yield { resolution: new URL(builtinProtocol + packageSpecifier) }; return resolved ? RESOLVED : YIELDED; } let version = null; if (packageVersion === null) { version = targetVersion; } else if (targetVersion === null || packageVersion === targetVersion) { version = packageVersion; } if (version !== null) { const resolved = yield { resolution: new URL(builtinProtocol + packageSpecifier + "@" + version) }; return resolved ? RESOLVED : YIELDED; } } } else if (Array.isArray(target)) { for (const targetValue of target) { const status = yield* exports.builtinTarget( packageSpecifier, packageVersion, targetValue, opts ); if (status) return status; } } else if (typeof target === "object" && target !== null) { let status = UNRESOLVED; for (const [condition, targetValue, subset] of exports.conditionMatches( target, conditions, opts )) { matchedConditions.push(condition); status |= yield* exports.builtinTarget(packageSpecifier, packageVersion, targetValue, { ...opts, conditions: subset }); matchedConditions.pop(); } if (status) return status; } return UNRESOLVED; }; exports.conditionMatches = function* conditionMatches(target, conditions, opts = {}) { if (conditions.every((condition) => typeof condition === "string")) { const keys = Object.keys(target); for (const condition of keys) { if (condition === "default" || conditions.includes(condition)) { yield [condition, target[condition], conditions]; return true; } } return false; } let yielded = false; for (const subset of conditions) { if (yield* conditionMatches(target, subset, opts)) { yielded = true; } } return yielded; }; exports.lookupPackageRoot = function* (packageName, parentURL) { parentURL = new URL(parentURL.href); do { const packageURL = new URL("node_modules/" + packageName + "/", parentURL); const info = yield new URL("package.json", packageURL); if (info) return info; parentURL.pathname = parentURL.pathname.substring(0, parentURL.pathname.lastIndexOf("/")); if (parentURL.pathname.length === 3 && exports.isWindowsDriveLetter(parentURL.pathname.substring(1))) { break; } } while (parentURL.pathname !== "" && parentURL.pathname !== "/"); return null; }; exports.lookupPackageScope = function* lookupPackageScope(scopeURL, opts = {}) { const { resolutions = null } = opts; if (resolutions) { for (const { resolution } of exports.preresolved("#package", resolutions, scopeURL, opts)) { if (resolution) return yield resolution; } } scopeURL = new URL(scopeURL.href); do { if (scopeURL.pathname.endsWith("/node_modules")) break; const info = yield new URL("package.json", scopeURL); if (info) return info; scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf("/")); if (scopeURL.pathname.length === 3 && exports.isWindowsDriveLetter(scopeURL.pathname.substring(1))) { break; } } while (scopeURL.pathname !== "" && scopeURL.pathname !== "/"); return null; }; exports.file = function* (filename, parentURL, isIndex, opts = {}) { if (filename === "." || filename === ".." || filename[filename.length - 1] === "/" || filename[filename.length - 1] === "\\") { return UNRESOLVED; } if (parentURL.protocol === "file:" && /%2f|%5c/i.test(filename)) { throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${filename}' is invalid`); } const { extensions = [] } = opts; let status = UNRESOLVED; if (!isIndex) { if (yield { resolution: new URL(filename, parentURL) }) { return RESOLVED; } status = YIELDED; } for (const ext of extensions) { if (filename.endsWith(ext)) continue; if (yield { resolution: new URL(filename + ext, parentURL) }) { return RESOLVED; } status = YIELDED; } return status; }; exports.directory = function* (dirname, parentURL, opts = {}) { let directoryURL; if (dirname[dirname.length - 1] === "/" || dirname[dirname.length - 1] === "\\") { directoryURL = new URL(dirname, parentURL); } else { directoryURL = new URL(dirname + "/", parentURL); } const info = yield { package: new URL("package.json", directoryURL) }; if (info) { if (info.exports) { return yield* exports.packageExports(directoryURL, ".", info.exports, opts); } if (typeof info.main === "string" && info.main !== "") { const status = yield* exports.file(info.main, directoryURL, false, opts); if (status === RESOLVED) return status; return yield* exports.directory(info.main, directoryURL, opts); } } return yield* exports.file("index", directoryURL, true, opts); }; function isASCIIUpperAlpha(c) { return c >= 65 && c <= 90; } function isASCIILowerAlpha(c) { return c >= 97 && c <= 122; } function isASCIIAlpha(c) { return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c); } exports.isWindowsDriveLetter = function isWindowsDriveLetter(input) { return input.length >= 2 && isASCIIAlpha(input.charCodeAt(0)) && (input.charCodeAt(1) === 58 || input.charCodeAt(1) === 124); }; exports.startsWithWindowsDriveLetter = function startsWithWindowsDriveLetter(input) { return input.length >= 2 && exports.isWindowsDriveLetter(input) && (input.length === 2 || input.charCodeAt(2) === 47 || input.charCodeAt(2) === 92 || input.charCodeAt(2) === 63 || input.charCodeAt(2) === 35); }; } }); // ../../node_modules/bare-addon-resolve/lib/errors.js var require_errors3 = __commonJS({ "../../node_modules/bare-addon-resolve/lib/errors.js"(exports, module) { module.exports = class AddonResolveError extends Error { constructor(msg, code, fn = AddonResolveError) { super(`${code}: ${msg}`); this.code = code; if (Error.captureStackTrace) { Error.captureStackTrace(this, fn); } } get name() { return "AddonResolveError"; } static INVALID_ADDON_SPECIFIER(msg) { return new AddonResolveError( msg, "INVALID_ADDON_SPECIFIER", AddonResolveError.INVALID_ADDON_SPECIFIER ); } static INVALID_PACKAGE_NAME(msg) { return new AddonResolveError( msg, "INVALID_PACKAGE_NAME", AddonResolveError.INVALID_PACKAGE_NAME ); } }; } }); // ../../node_modules/bare-addon-resolve/index.js var require_bare_addon_resolve = __commonJS({ "../../node_modules/bare-addon-resolve/index.js"(exports, module) { var resolve = require_bare_module_resolve(); var { Version } = require_bare_semver(); var errors = require_errors3(); module.exports = exports = function resolve2(specifier, parentURL, opts, readPackage) { if (typeof opts === "function") { readPackage = opts; opts = {}; } else if (typeof readPackage !== "function") { readPackage = defaultReadPackage; } return { *[Symbol.iterator]() { const generator = exports.addon(specifier, parentURL, opts); let next = generator.next(); while (next.done !== true) { const value = next.value; if (value.package) { next = generator.next(readPackage(value.package)); } else { next = generator.next(yield value.resolution); } } return next.value; }, async *[Symbol.asyncIterator]() { const generator = exports.addon(specifier, parentURL, opts); let next = generator.next(); while (next.done !== true) { const value = next.value; if (value.package) { next = generator.next(await readPackage(value.package)); } else { next = generator.next(yield value.resolution); } } return next.value; } }; }; function defaultReadPackage() { return null; } var { UNRESOLVED, YIELDED, RESOLVED } = resolve.constants; exports.constants = { UNRESOLVED, YIELDED, RESOLVED }; exports.addon = function* (specifier, parentURL, opts = {}) { const { resolutions = null } = opts; if (exports.startsWithWindowsDriveLetter(specifier)) { specifier = "/" + specifier; } let status; if (resolutions) { status = yield* resolve.preresolved(specifier, resolutions, parentURL, opts); if (status) return status; } status = yield* exports.url(specifier, parentURL, opts); if (status) return status; let version = null; const i = specifier.lastIndexOf("@"); if (i > 0) { version = specifier.substring(i + 1); try { Version.parse(version); specifier = specifier.substring(0, i); } catch { version = null; } } if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier[0] === "\\" || specifier.startsWith("./") || specifier.startsWith(".\\") || specifier.startsWith("../") || specifier.startsWith("..\\")) { status = yield* exports.file(specifier, parentURL, opts); if (status === RESOLVED) return status; return yield* exports.directory(specifier, version, parentURL, opts); } return yield* exports.package(specifier, version, parentURL, opts); }; exports.url = function* (url, parentURL, opts = {}) { let resolution; try { resolution = new URL(url); } catch { return UNRESOLVED; } const resolved = yield { resolution }; return resolved ? RESOLVED : YIELDED; }; exports.package = function* (packageSpecifier, packageVersion, parentURL, opts = {}) { if (packageSpecifier === "") { throw errors.INVALID_ADDON_SPECIFIER( `Addon specifier '${packageSpecifier}' is not a valid package name` ); } let packageName; if (packageSpecifier[0] !== "@") { packageName = packageSpecifier.split("/", 1).join(); } else { if (!packageSpecifier.includes("/")) { throw errors.INVALID_ADDON_SPECIFIER( `Addon specifier '${packageSpecifier}' is not a valid package name` ); } packageName = packageSpecifier.split("/", 2).join("/"); } if (packageName[0] === "." || packageName.includes("\\") || packageName.includes("%")) { throw errors.INVALID_ADDON_SPECIFIER( `Addon specifier '${packageSpecifier}' is not a valid package name` ); } const packageSubpath = "." + packageSpecifier.substring(packageName.length); const status = yield* exports.packageSelf( packageName, packageSubpath, packageVersion, parentURL, opts ); if (status) return status; parentURL = new URL(parentURL.href); do { const packageURL = new URL("node_modules/" + packageName + "/", parentURL); parentURL.pathname = parentURL.pathname.substring(0, parentURL.pathname.lastIndexOf("/")); const info = yield { package: new URL("package.json", packageURL) }; if (info) { return yield* exports.directory(packageSubpath, packageVersion, packageURL, opts); } } while (parentURL.pathname !== "" && parentURL.pathname !== "/"); return UNRESOLVED; }; exports.packageSelf = function* (packageName, packageSubpath, packageVersion, parentURL, opts = {}) { for (const packageURL of resolve.lookupPackageScope(parentURL, opts)) { const info = yield { package: packageURL }; if (info) { if (info.name === packageName) { return yield* exports.directory(packageSubpath, packageVersion, packageURL, opts); } break; } } return UNRESOLVED; }; exports.lookupPrebuildsScope = function* lookupPrebuildsScope(url, opts = {}) { const scopeURL = new URL(url.href); do { yield new URL("prebuilds/", scopeURL); scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf("/")); if (scopeURL.pathname.length === 3 && exports.isWindowsDriveLetter(scopeURL.pathname.substring(1))) { break; } } while (scopeURL.pathname !== "" && scopeURL.pathname !== "/"); }; exports.file = function* (filename, parentURL, opts = {}) { if (filename === "." || filename === ".." || filename[filename.length - 1] === "/" || filename[filename.length - 1] === "\\") { return UNRESOLVED; } if (parentURL.protocol === "file:" && /%2f|%5c/i.test(filename)) { throw errors.INVALID_ADDON_SPECIFIER(`Addon specifier '${filename}' is invalid`); } const { extensions = [] } = opts; let status = UNRESOLVED; for (let ext of extensions) { if (filename.endsWith(ext)) ext = ""; if (yield { resolution: new URL(filename + ext, parentURL) }) { return RESOLVED; } status = YIELDED; } return status; }; exports.directory = function* (dirname, version, parentURL, opts = {}) { const { host = null, // Shorthand for single host resolution hosts = host !== null ? [host] : [], builtins = [], matchedConditions = [] } = opts; let directoryURL; if (dirname[dirname.length - 1] === "/" || dirname[dirname.length - 1] === "\\") { directoryURL = new URL(dirname, parentURL); } else { directoryURL = new URL(dirname + "/", parentURL); } const unversioned = version === null; let name = null; const info = yield { package: new URL("package.json", directoryURL) }; if (info) { if (typeof info.name === "string" && info.name !== "") { if (info.name.includes("__")) { throw errors.INVALID_PACKAGE_NAME(`Package name '${info.name}' is invalid`); } name = info.name.replace(/\//g, "__").replace(/^@/, ""); } else { return UNRESOLVED; } if (typeof info.version === "string" && info.version !== "") { if (version !== null && info.version !== version) return UNRESOLVED; version = info.version; } } else { return UNRESOLVED; } let status; status = yield* resolve.builtinTarget(name, version, builtins, opts); if (status) return status; for (const prebuildsURL of exports.lookupPrebuildsScope(directoryURL, opts)) { status = UNRESOLVED; for (const host2 of hosts) { const conditions = host2.split("-"); const universal = supportsUniversalPrebuilds(host2) ? conditions.with(1, "universal").join("-") : null; matchedConditions.push(...conditions); if (version !== null) { status |= yield* exports.file(host2 + "/" + name + "@" + version, prebuildsURL, opts); if (universal) { status |= yield* exports.file(universal + "/" + name + "@" + version, prebuildsURL, opts); } } if (unversioned) { status |= yield* exports.file(host2 + "/" + name, prebuildsURL, opts); if (universal) { status |= yield* exports.file(universal + "/" + name, prebuildsURL, opts); } } for (const _ of conditions) matchedConditions.pop(); } if (status === RESOLVED) return status; } return yield* exports.linked(name, version, opts); }; exports.linked = function* (name, version = null, opts = {}) { const { linked = true, host = null, // Shorthand for single host resolution hosts = host !== null ? [host] : [], matchedConditions = [] } = opts; if (linked === false || hosts.length === 0) return UNRESOLVED; let status = UNRESOLVED; for (const host2 of hosts) { const [platform = null] = host2.split("-", 1); if (platform === null) continue; matchedConditions.push(platform); status |= yield* platformArtefact(name, version, platform, opts); matchedConditions.pop(); } return status; }; function* platformArtefact(name, version = null, platform, opts = {}) { const { linkedProtocol = "linked:" } = opts; if (platform === "darwin" || platform === "ios") { if (version !== null) { if (yield { resolution: new URL(`${linkedProtocol}${name}.${version}.framework/${name}.${version}`) }) { return RESOLVED; } if (platform === "darwin") { if (yield { resolution: new URL(`${linkedProtocol}lib${name}.${version}.dylib`) }) { return RESOLVED; } } } if (yield { resolution: new URL(`${linkedProtocol}${name}.framework/${name}`) }) { return RESOLVED; } if (platform === "darwin") { if (yield { resolution: new URL(`${linkedProtocol}lib${name}.dylib`) }) { return RESOLVED; } } return YIELDED; } if (platform === "linux" || platform === "android") { if (version !== null) { if (yield { resolution: new URL(`${linkedProtocol}lib${name}.${version}.so`) }) { return RESOLVED; } } if (yield { resolution: new URL(`${linkedProtocol}lib${name}.so`) }) { return RESOLVED; } return YIELDED; } if (platform === "win32") { if (version !== null) { if (yield { resolution: new URL(`${linkedProtocol}${name}-${version}.dll`) }) { return RESOLVED; } } if (yield { resolution: new URL(`${linkedProtocol}${name}.dll`) }) { return RESOLVED; } } return UNRESOLVED; } exports.isWindowsDriveLetter = resolve.isWindowsDriveLetter; exports.startsWithWindowsDriveLetter = resolve.startsWithWindowsDriveLetter; function supportsUniversalPrebuilds(host) { return host === "darwin-arm64" || host === "darwin-x64" || host === "ios-arm64-simulator" || host === "ios-x64-simulator"; } } }); // ../../node_modules/require-addon/lib/node.js var require_node = __commonJS({ "../../node_modules/require-addon/lib/node.js"(exports, module) { if (typeof __require.addon === "function") { module.exports = __require.addon.bind(__require); } else { let readPackage2 = function(packageURL) { try { return __require(url.fileURLToPath(packageURL)); } catch (err) { return null; } }, isAlpine2 = function() { return process.platform === "linux" && fs.existsSync("/etc/alpine-release"); }; readPackage = readPackage2, isAlpine = isAlpine2; const url = __require("url"); const fs = __require("fs"); const resolve = require_bare_addon_resolve(); let host = process.platform + "-" + process.arch; const conditions = ["addon", "node", process.platform, process.arch]; const extensions = [".node"]; if (isAlpine2()) { host += "-musl"; conditions.push("musl"); } module.exports = function addon(specifier, parentURL) { if (typeof parentURL === "string") parentURL = url.pathToFileURL(parentURL); const candidates = []; let cause; for (const resolution of resolve( specifier, parentURL, { host, conditions, extensions }, readPackage2 )) { candidates.push(resolution); switch (resolution.protocol) { case "file:": try { return __require(url.fileURLToPath(resolution)); } catch (err2) { cause = err2; continue; } } } let message = `Cannot find addon '${specifier}' imported from '${parentURL.href}'`; if (candidates.length > 0) { message += "\nCandidates:"; message += "\n" + candidates.map((url2) => "- " + url2.href).join("\n"); } const err = new Error(message, cause ? { cause } : {}); err.code = "ADDON_NOT_FOUND"; err.specifier = specifier; err.referrer = parentURL; err.candidates = candidates; throw err; }; } var readPackage; var isAlpine; } }); // ../../node_modules/bare-module-lexer/lib/binding/node.js var require_node2 = __commonJS({ "../../node_modules/bare-module-lexer/lib/binding/node.js"(exports, module) { __require.addon = require_node(); module.exports = __require.addon("../..", __filename); } }); // ../../node_modules/bare-module-lexer/index.js var require_bare_module_lexer = __commonJS({ "../../node_modules/bare-module-lexer/index.js"(exports, module) { var binding = require_node2(); module.exports = exports = function lex(input, encoding, opts = {}) { if (typeof encoding === "object" && encoding !== null) { opts = encoding; encoding = null; } if (typeof input !== "string" && !ArrayBuffer.isView(input)) { throw new TypeError( `Input must be a string or buffer. Received type ${typeof input}` ); } return binding.lex( typeof input === "string" ? Buffer.from(input, encoding) : input ); }; exports.constants = { /** * CommonJS `require()`. */ REQUIRE: binding.REQUIRE, /** * ES module `import`. */ IMPORT: binding.IMPORT, /** * ES module `import()` if `IMPORT` is set. */ DYNAMIC: binding.DYNAMIC, /** * CommonJS `require.addon()` if `REQUIRE` is set, or ES module `import.meta.addon()` if `IMPORT` is set. */ ADDON: binding.ADDON, /** * CommonJS `require.asset()` if `REQUIRE` is set, or ES module `import.meta.asset()` if `IMPORT` is set. */ ASSET: binding.ASSET, /** * CommonJS `require.resolve()` or `require.addon.resolve()` if `REQUIRE` and optionally `ADDON` are set, or ES module * `import.meta.resolve()` or `import.meta.addon.resolve()` if `IMPORT` and optionally `ADDON` are set. */ RESOLVE: binding.RESOLVE, /** * Re-export of a CommonJS `require()` if `REQUIRE` is set. */ REEXPORT: binding.REEXPORT }; } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve/default.js var require_default = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve/default.js"(exports, module) { var lex = require_bare_module_lexer(); var resolve = require_resolve(); module.exports = function(entry, parentURL, opts) { if (entry.type & lex.constants.ADDON) { return resolve.addon(entry.specifier || ".", parentURL, opts); } return resolve.module(entry.specifier, parentURL, opts); }; } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/lib/runtime/node.js var require_node3 = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/lib/runtime/node.js"(exports) { exports.platform = process.platform; exports.arch = process.arch; exports.simulator = false; } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/lib/runtime.js var require_runtime = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/lib/runtime.js"(exports, module) { module.exports = require_node3(); } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve/bare.js var require_bare = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve/bare.js"(exports, module) { var lex = require_bare_module_lexer(); var resolve = require_resolve(); var runtime = require_runtime(); module.exports = function(entry, parentURL, opts = {}) { if (opts.target) { const { target, ...rest } = opts; rest.hosts = target; opts = rest; } const { linked = false, platform = runtime.platform, arch = runtime.arch, simulator = runtime.simulator, host = `${platform}-${arch}${simulator ? "-simulator" : ""}`, hosts = [host] } = opts; let extensions; let conditions = hosts.map((host2) => ["bare", "node", ...host2.split("-")]); if (entry.type & lex.constants.ADDON) { extensions = linked ? [] : [".bare", ".node"]; conditions = conditions.map((conditions2) => ["addon", ...conditions2]); return resolve.addon(entry.specifier || ".", parentURL, { extensions, conditions, hosts, linked, ...opts }); } if (entry.type & lex.constants.ASSET) { conditions = conditions.map((conditions2) => ["asset", ...conditions2]); } else { extensions = [".js", ".cjs", ".mjs", ".json", ".bare", ".node"]; if (entry.type & lex.constants.REQUIRE) { conditions = conditions.map((conditions2) => ["require", ...conditions2]); } else if (entry.type & lex.constants.IMPORT) { conditions = conditions.map((conditions2) => ["import", ...conditions2]); } } return resolve.module(entry.specifier, parentURL, { extensions, conditions, ...opts }); }; } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve/node.js var require_node4 = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve/node.js"(exports, module) { var lex = require_bare_module_lexer(); var resolve = require_resolve(); var runtime = require_runtime(); module.exports = function(entry, parentURL, opts = {}) { if (opts.target) { const { target, ...rest } = opts; rest.hosts = target; opts = rest; } const { platform = runtime.platform, arch = runtime.arch, simulator = runtime.simulator, host = `${platform}-${arch}${simulator ? "-simulator" : ""}`, hosts = [host] } = opts; let extensions; let conditions; if (entry.type & lex.constants.ADDON) { extensions = [".node"]; conditions = hosts.map((host2) => ["node", "addon", ...host2.split("-")]); return resolve.addon(entry.specifier || ".", parentURL, { extensions, conditions, hosts, ...opts }); } if (entry.type & lex.constants.ASSET) { conditions = ["node", "asset"]; } else if (entry.type & lex.constants.REQUIRE) { extensions = [".js", ".json", ".node"]; conditions = ["node", "require"]; } else if (entry.type & lex.constants.IMPORT) { conditions = ["node", "import"]; } else { conditions = ["node"]; } return resolve.module(entry.specifier, parentURL, { extensions, conditions, ...opts }); }; } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve.js var require_resolve = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/lib/resolve.js"(exports) { exports.module = require_bare_module_resolve().module; exports.addon = require_bare_addon_resolve().addon; exports.default = require_default(); exports.bare = require_bare(); exports.node = require_node4(); } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/lib/errors.js var require_errors4 = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/lib/errors.js"(exports, module) { module.exports = class ModuleTraverseError extends Error { constructor(msg, fn = ModuleTraverseError, code = fn.name) { super(`${code}: ${msg}`); this.code = code; if (Error.captureStackTrace) { Error.captureStackTrace(this, fn); } } get name() { return "ModuleTraverseError"; } static MODULE_NOT_FOUND(msg, specifier, referrer = null, candidates = []) { const err = new ModuleTraverseError(msg, ModuleTraverseError.MODULE_NOT_FOUND); err.specifier = specifier; err.referrer = referrer; err.candidates = candidates; return err; } static ADDON_NOT_FOUND(msg, specifier, referrer = null, candidates = []) { const err = new ModuleTraverseError(msg, ModuleTraverseError.ADDON_NOT_FOUND); err.specifier = specifier; err.referrer = referrer; err.candidates = candidates; return err; } static ASSET_NOT_FOUND(msg, specifier, referrer = null, candidates = []) { const err = new ModuleTraverseError(msg, ModuleTraverseError.ASSET_NOT_FOUND); err.specifier = specifier; err.referrer = referrer; err.candidates = candidates; return err; } static INVALID_IMPORTS_MAP(msg) { return new ModuleTraverseError(msg, ModuleTraverseError.INVALID_IMPORTS_MAP); } }; } }); // ../../node_modules/bare-run/node_modules/bare-module-traverse/index.js var require_bare_module_traverse = __commonJS({ "../../node_modules/bare-run/node_modules/bare-module-traverse/index.js"(exports, module) { var { lookupPackageScope, conditionMatches } = require_bare_module_resolve(); var lex = require_bare_module_lexer(); var resolve = require_resolve(); var errors = require_errors4(); var constants = { SCRIPT: 1, MODULE: 2, JSON: 3, BUNDLE: 4, ADDON: 5, BINARY: 6, TEXT: 7, ASSET: 8 }; module.exports = exports = function traverse(entry, opts, readModule, listPrefix) { if (typeof opts === "function") { listPrefix = readModule; readModule = opts; opts = {}; } return { *[Symbol.iterator]() { const artifacts = { addons: [], assets: [] }; const queue = [exports.module(entry, null, {}, artifacts, /* @__PURE__ */ new Set(), opts)]; while (queue.length > 0) { const generator = queue.pop(); let next = generator.next(); while (next.done !== true) { const value = next.value; if (value.module) { next = generator.next(readModule(value.module)); } else if (value.prefix) { const result = []; if (typeof listPrefix === "function") { for (const url of listPrefix(value.prefix)) { result.push(url); } } else { if (readModule(value.prefix) !== null) { result.push(value.prefix); } } next = generator.next(result); } else { if (value.children) queue.push(value.children); else yield value.dependency; next = generator.next(); } } } return artifacts; }, async *[Symbol.asyncIterator]() { const artifacts = { addons: [], assets: [] }; const queue = [exports.module(entry, null, {}, artifacts, /* @__PURE__ */ new Set(), opts)]; while (queue.length > 0) { const generator = queue.pop(); let next = generator.next(); while (next.done !== true) { const value = next.value; if (value.module) { next = generator.next(await readModule(value.module)); } else if (value.prefix) { const result = []; if (typeof listPrefix === "function") { for await (const url of listPrefix(value.prefix)) { result.push(url); } } else { if (await readModule(value.prefix) !== null) { result.push(value.prefix); } } next = generator.next(result); } else { if (value.children) queue.push(value.children); else yield value.dependency; next = generator.next(); } } } return artifacts; } }; }; exports.constants = constants; exports.resolve = resolve; exports.module = function* (url, source, attributes, artifacts, visited, opts = {}) { const { resolutions = null, defaultType = constants.SCRIPT } = opts; if (visited.has(url.href)) return false; if (source === null) { source = yield { module: url }; if (source === null) { throw errors.MODULE_NOT_FOUND(`Cannot find module '${url.href}'`, url.href); } } visited.add(url.href); if (resolutions) { if (yield* exports.preresolved(url, source, resolutions, artifacts, visited, opts)) { return true; } } attributes = attributes || {}; const imports = {}; let info = null; for (const packageURL of lookupPackageScope(url, opts)) { const source2 = yield { module: packageURL }; if (source2 !== null) { info = JSON.parse(source2); imports["#package"] = packageURL.href; yield { children: exports.package(packageURL, source2, artifacts, visited, opts) }; break; } } if (typeof attributes.imports === "string") { const url2 = new URL(attributes.imports); const source2 = yield { module: url2 }; if (source2 !== null) { opts = { ...opts, imports: mixinImports(opts.imports, JSON.parse(source2), url2) }; } } let type = 0; if (typeof attributes.type === "string") { switch (attributes.type) { case "script": type = constants.SCRIPT; break; case "module": type = constants.MODULE; break; case "json": type = constants.JSON; break; case "bundle": type = constants.BUNDLE; break; case "addon": type = constants.ADDON; break; case "binary": type = constants.BINARY; break; case "text": type = constants.TEXT; break; } } else { const match = url.pathname.match(/\.[a-z]+$/); if (match !== null) { const [extension] = match; switch (extension) { case ".js": const isESM = defaultType === constants.MODULE || info !== null && info.type === "module"; type = isESM ? constants.MODULE : constants.SCRIPT; break; case ".cjs": type = constants.SCRIPT; break; case ".mjs": type = constants.MODULE; break; case ".json": type = constants.JSON; break; case ".bundle": type = constants.BUNDLE; break; case ".bare": case ".node": type = constants.ADDON; break; case ".bin": type = constants.BINARY; break; case ".txt": type = constants.TEXT; break; } } } const lexer = { imports: [] }; if (type === constants.SCRIPT || type === constants.MODULE) { yield* exports.imports(url, source, imports, artifacts, lexer, visited, opts); } else if (type === constants.ADDON) { yield* exports.addons(url, artifacts, visited, opts); } yield { dependency: { url, source, imports: compressImportsMap(imports), lexer } }; return true; }; exports.package = function* (url, source, artifacts, visited, opts = {}) { if (visited.has(url.href)) return false; if (source === null) { source = yield { module: url }; if (source === null) return false; } visited.add(url.href); const info = JSON.parse(source); if (info) { yield { dependency: { url, source, imports: {}, lexer: { imports: [] } } }; if (info.assets) { yield { children: exports.assets(info.assets, url, artifacts, visited, opts) }; } return true; } return false; }; exports.preresolved = function* (url, source, resolutions, artifacts, visited, opts = {}) { const { builtinProtocol = "builtin:", linkedProtocol = "linked:", deferredProtocol = "deferred:" } = opts; const imports = resolutions[url.href]; if (typeof imports !== "object" || imports === null) return false; for (const [specifier, entry] of Object.entries(imports)) { const stack = [entry]; while (stack.length > 0) { const entry2 = stack.pop(); if (typeof entry2 === "string") { const url2 = new URL(entry2); if (specifier === "#package") { yield { children: exports.package(url2, null, artifacts, visited, opts) }; } else if (url2.protocol !== builtinProtocol && url2.protocol !== linkedProtocol && url2.protocol !== deferredProtocol) { yield { children: exports.module(url2, null, {}, artifacts, visited, opts) }; } } else { stack.unshift(...Object.values(entry2)); } } } yield { dependency: { url, source, imports: compressImportsMap(imports), lexer: { imports: [] } } }; return true; }; exports.imports = function* (parentURL, source, imports, artifacts, lexer, visited, opts = {}) { if (opts.target) opts = { ...opts, hosts: opts.target }; const { resolve: resolve2 = exports.resolve.default, builtinProtocol = "builtin:", linkedProtocol = "linked:", deferredProtocol = "deferred:", matchedConditions = [] } = opts; let yielded = false; const queue = []; for (const entry of lex(source).imports) { let specifier = entry.specifier; let condition = "default"; if (entry.type & lex.constants.ADDON) { specifier = specifier || "."; condition = "addon"; } else if (entry.type & lex.constants.ASSET) { condition = "asset"; } if (entry.attributes.imports) { const specifier2 = entry.attributes.imports; queue.push({ entry: { type: 0, specifier: specifier2, names: [], attributes: {}, position: [0, 0, 0] }, specifier: specifier2, condition: "default" }); } lexer.imports.push(entry); queue.push({ entry, specifier, condition }); } while (queue.length > 0) { const { entry, specifier, condition } = queue.shift(); matchedConditions.push(condition); const resolver = resolve2(entry, parentURL, { ...opts, matchedConditions }); const candidates = []; let next = resolver.next(); let resolutions = 0; while (next.done !== true) { const value = next.value; if (value.package) { next = resolver.next(JSON.parse(yield { module: value.package })); } else { const url = value.resolution; candidates.push(url); let resolved = false; if (url.protocol === builtinProtocol || url.protocol === linkedProtocol || url.protocol === deferredProtocol) { addResolution(imports, specifier, matchedConditions, url); resolved = yielded = true; } else if (condition === "asset") { const prefix = url; for (const url2 of yield { prefix }) { yield { children: exports.module(url2, null, {}, artifacts, visited, opts) }; addURL(artifacts.assets, url2); resolved = yielded = true; } if (resolved) addResolution(imports, specifier, matchedConditions, url); } else { const source2 = yield { module: url }; if (source2 !== null) { addResolution(imports, specifier, matchedConditions, url); let attributes = entry.attributes; if (attributes.imports) { attributes = { ...attributes, imports: imports[attributes.imports].default }; } yield { children: exports.module(url, source2, attributes, artifacts, visited, opts) }; resolved = yielded = true; } } if (resolved) { if (condition === "addon") addURL(artifacts.addons, url); resolutions++; } next = resolver.next(resolved); } } matchedConditions.pop(); if (resolutions === 0) { let message = `Cannot find ${condition === "default" ? "module" : condition} '${specifier}' imported from '${parentURL.href}'`; if (candidates.length > 0) { message += "\nCandidates:"; message += "\n" + candidates.map((url) => "- " + url.href).join("\n"); } switch (condition) { case "addon": throw errors.ADDON_NOT_FOUND(message, specifier, parentURL, candidates); case "asset": throw errors.ASSET_NOT_FOUND(message, specifier, parentURL, candidates); default: throw errors.MODULE_NOT_FOUND(message, specifier, parentURL, candidates); } } } return yielded; }; var ADDON_EXTENSION = /\.(bare|node)$/; exports.addons = function* (parentURL, artifacts, visited, opts = {}) { let yielded = false; if (ADDON_EXTENSION.test(parentURL.pathname)) { const prefix = new URL(parentURL); prefix.pathname = prefix.pathname.replace(ADDON_EXTENSION, "") + "/"; for (const url of yield { prefix }) { yield { children: exports.module(url, null, {}, artifacts, visited, opts) }; addURL(artifacts.addons, url); yielded = true; } } return yielded; }; exports.assets = function* (patterns, parentURL, artifacts, visited, opts = {}) { const matches = yield* exports.patternMatches(patterns, parentURL, [], opts); let yielded = false; for (const url of matches) { const source = yield { module: url }; if (source !== null) { addURL(artifacts.assets, url); yield { children: exports.module(url, source, {}, artifacts, visited, opts) }; yielded = true; } } return yielded; }; exports.patternMatches = function* patternMatches(pattern, parentURL, matches, opts = {}) { const { conditions = [], matchedConditions = [] } = opts; if (typeof pattern === "string") { let patternNegate = false; let patternBase; let patternTrailer; if (pattern[0] === "!") { pattern = pattern.substring(1); patternNegate = true; } const patternIndex = pattern.indexOf("*"); if (patternIndex === -1) { patternBase = pattern; patternTrailer = ""; } else { patternBase = pattern.substring(0, patternIndex); patternTrailer = pattern.substring(patternIndex + 1); } const prefix = new URL(patternBase, parentURL); for (const url of yield { prefix }) { if (patternIndex === -1) { if (patternNegate) removeURL(matches, url); else addURL(matches, url); } else if (patternTrailer === "" || url.href.endsWith(patternTrailer)) { addURL(matches, url); } else if (patternNegate) { removeURL(matches, url); } } } else if (Array.isArray(pattern)) { for (const patternValue of pattern) { yield* patternMatches(patternValue, parentURL, matches, opts); } } else if (typeof pattern === "object" && pattern !== null) { let yielded = false; for (const [condition, patternValue, subset] of conditionMatches(pattern, conditions, opts)) { matchedConditions.push(condition); if (yield* patternMatches(patternValue, parentURL, matches, { ...opts, conditions: subset })) { yielded = true; } matchedConditions.pop(); } if (yielded) return true; } return matches; }; function addURL(array, url) { let lo = 0; let hi = array.length - 1; while (lo <= hi) { const mid = lo + (hi - lo >> 1); const found = array[mid]; if (found.href === url.href) return; if (found.href < url.href) { lo = mid + 1; } else { hi = mid - 1; } } array.splice(lo, 0, url); } function removeURL(array, url) { let lo = 0; let hi = array.length - 1; while (lo <= hi) { const mid = lo + (hi - lo >> 1); const found = array[mid]; if (found.href === url.href) break; if (found.href < url.href) { lo = mid + 1; } else { hi = mid - 1; } } if (array[lo].href === url.href) array.splice(lo, 1); } function addResolution(imports, specifier, conditions, url) { imports[specifier] = imports[specifier] || {}; let current = imports[specifier]; for (let i = 0, n = conditions.length - 1; i < n; i++) { const key = conditions[i]; if (key in current === false) { current[key] = {}; } else if (typeof current[key] !== "object") { current[key] = { default: current[key] }; } current = current[key]; } const last = conditions[conditions.length - 1]; current[last] = url.href; if ("default" in current) { const value = current.default; delete current.default; current.default = value; } } function compressImportsMap(imports) { const entries = []; for (const entry of Object.entries(imports)) { entry[1] = compressImportsMapEntry(entry[1]); entries.push(entry); } return Object.fromEntries(entries); } function compressImportsMapEntry(resolved) { if (typeof resolved === "string") return resolved; let entries = []; let primary = null; for (const entry of Object.entries(resolved)) { entry[1] = compressImportsMapEntry(entry[1]); entries.push(entry); if (entry[0] === "default") primary = entry[1]; } entries = entries.filter( ([condition, resolved2]) => condition === "default" || resolved2 !== primary ); if (entries.length === 1) return entries[0][1]; return Object.fromEntries(entries); } function mixinImports(target, imports, url) { if (typeof imports === "object" && imports !== null && "imports" in imports) { imports = imports.imports; } if (typeof imports !== "object" || imports === null) { throw errors.INVALID_IMPORTS_MAP(`Imports map at '${url.href}' is not valid`); } return { ...target, ...imports }; } } }); // ../../node_modules/sodium-native/binding.js var require_binding = __commonJS({ "../../node_modules/sodium-native/binding.js"(exports, module) { __require.addon = require_node(); module.exports = __require.addon(".", __filename); } }); // ../../node_modules/which-runtime/index.js var require_which_runtime = __commonJS({ "../../node_modules/which-runtime/index.js"(exports) { var { runtime, platform, arch } = typeof Bare !== "undefined" ? { runtime: "bare", platform: global.Bare.platform, arch: global.Bare.arch } : typeof process !== "undefined" ? { runtime: "node", platform: global.process.platform, arch: global.process.arch } : typeof Window !== "undefined" ? { runtime: "browser", platform: "unknown", arch: "unknown" } : { runtime: "unknown", platform: "unknown", arch: "unknown" }; exports.runtime = runtime; exports.platform = platform; exports.arch = arch; exports.isBare = runtime === "bare"; exports.isBareKit = exports.isBare && typeof BareKit !== "undefined"; exports.isPear = typeof Pear !== "undefined"; exports.isNode = runtime === "node"; exports.isBrowser = runtime === "browser"; exports.isWindows = platform === "win32"; exports.isLinux = platform === "linux"; exports.isMac = platform === "darwin"; exports.isIOS = platform === "ios" || platform === "ios-simulator"; exports.isAndroid = platform === "android"; exports.isElectron = typeof process !== "undefined" && !!global.process.versions?.electron; exports.isElectronRenderer = exports.isElectron && global.process.type === "renderer"; exports.isElectronWorker = exports.isElectron && global.process.type === "worker"; } }); // ../../node_modules/sodium-native/index.js var require_sodium_native = __commonJS({ "../../node_modules/sodium-native/index.js"(exports, module) { var assert = __require("assert"); var binding = require_binding(); var { isNode } = require_which_runtime(); var OPTIONAL = Buffer.from(new ArrayBuffer(0)); module.exports = exports = { ...binding }; exports.sodium_memzero = function(buf) { assert(ArrayBuffer.isView(buf), "buf must be a typed array"); binding.sodium_memzero(buf); }; exports.sodium_mlock = function(buf) { assert(ArrayBuffer.isView(buf), "buf must be a typed array"); const res = binding.sodium_mlock(buf); if (res !== 0) throw new Error("memory lock failed"); }; exports.sodium_munlock = function(buf) { assert(ArrayBuffer.isView(buf), "buf must be a typed array"); const res = binding.sodium_munlock(buf); if (res !== 0) throw new Error("memory unlock failed"); }; exports.sodium_malloc = function(size) { assert(size >= 0, "invalid size"); const buf = Buffer.from(binding.sodium_malloc(size)); buf.secure = true; return buf; }; exports.sodium_free = function(buf) { if (!buf || !buf.secure) return; binding.sodium_free(buf.buffer); }; exports.sodium_mprotect_noaccess = function(buf) { const res = binding.sodium_mprotect_noaccess(buf.buffer); if (res !== 0) throw new Error("failed to lock buffer"); }; exports.sodium_mprotect_readonly = function(buf) { const res = binding.sodium_mprotect_readonly(buf.buffer); if (res !== 0) throw new Error("failed to unlock buffer"); }; exports.sodium_mprotect_readwrite = function(buf) { const res = binding.sodium_mprotect_readwrite(buf.buffer); if (res !== 0) throw new Error("failed to unlock buffer"); }; exports.randombytes_buf = function(buffer) { assert(ArrayBuffer.isView(buffer), "buffer must be a typed array"); binding.randombytes_buf(buffer.buffer, buffer.byteOffset, buffer.byteLength); }; exports.randombytes_buf_deterministic = function(buffer, seed) { assert(ArrayBuffer.isView(buffer), "buffer must be a typed array"); assert(ArrayBuffer.isView(seed), "seed must be a typed array"); assert( seed.byteLength === binding.randombytes_SEEDBYTES, "seed must be 'randombytes_SEEDBYTES' bytes" ); binding.randombytes_buf_deterministic( buffer.buffer, buffer.byteOffset, buffer.byteLength, seed.buffer, seed.byteOffset, seed.byteLength ); }; exports.sodium_memcmp = function(a, b) { assert(ArrayBuffer.isView(a), "a must be a typed array"); assert(ArrayBuffer.isView(b), "b must be a typed array"); assert(a.byteLength === b.byteLength, "buffers must be of same length"); return binding.sodium_memcmp(a, b); }; exports.sodium_add = function(a, b) { assert(ArrayBuffer.isView(a), "a must be a typed array"); assert(ArrayBuffer.isView(b), "b must be a typed array"); assert(a.byteLength === b.byteLength, "buffers must be of same length"); binding.sodium_add(a, b); }; exports.sodium_sub = function(a, b) { assert(ArrayBuffer.isView(a), "a must be a typed array"); assert(ArrayBuffer.isView(b), "b must be a typed array"); assert(a.byteLength === b.byteLength, "buffers must be of same length"); binding.sodium_sub(a, b); }; exports.sodium_compare = function(a, b) { assert(ArrayBuffer.isView(a), "a must be a typed array"); assert(ArrayBuffer.isView(b), "b must be a typed array"); assert(a.byteLength === b.byteLength, "buffers must be of same length"); return binding.sodium_compare(a, b); }; exports.sodium_is_zero = function(buffer, length) { if (length === void 0) length = buffer.byteLength; assert(ArrayBuffer.isView(buffer), "buffer must be a typed array"); assert(length >= 0 && length <= buffer.byteLength, "invalid length"); return binding.sodium_is_zero(buffer, length); }; exports.sodium_pad = function(buffer, unpaddedBuflen, blockSize) { assert(ArrayBuffer.isView(buffer), "buffer must be a typed array"); assert(unpaddedBuflen <= buffer.byteLength, "unpadded length cannot exceed buffer length"); assert(blockSize <= buffer.byteLength, "block size cannot exceed buffer length"); assert(blockSize >= 1, "block size must be at least 1 byte"); assert( buffer.byteLength >= unpaddedBuflen + (blockSize - unpaddedBuflen % blockSize), "buf not long enough" ); return binding.sodium_pad(buffer, unpaddedBuflen, blockSize); }; exports.sodium_unpad = function(buffer, paddedBuflen, blockSize) { assert(ArrayBuffer.isView(buffer), "buffer must be a typed array"); assert(paddedBuflen <= buffer.byteLength, "unpadded length cannot exceed buffer length"); assert(blockSize <= buffer.byteLength, "block size cannot exceed buffer length"); assert(blockSize >= 1, "block size must be at least 1 byte"); return binding.sodium_unpad(buffer, paddedBuflen, blockSize); }; exports.crypto_sign_keypair = function(pk, sk) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes" ); const res = binding.crypto_sign_keypair(pk, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_sign_seed_keypair = function(pk, sk, seed) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert(ArrayBuffer.isView(seed), "seed must be a typed array"); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes" ); assert( seed.byteLength === binding.crypto_sign_SEEDBYTES, "seed must be 'crypto_sign_SEEDBYTES' bytes" ); const res = binding.crypto_sign_seed_keypair(pk, sk, seed); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_sign = function(sm, m, sk) { assert(ArrayBuffer.isView(sm), "sm must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( sm.byteLength === binding.crypto_sign_BYTES + m.byteLength, "sm must be 'm.byteLength + crypto_sign_BYTES' bytes" ); assert( sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes" ); const res = binding.crypto_sign(sm, m, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_sign_open = function(m, sm, pk) { assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(sm), "sm must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( sm.byteLength >= binding.crypto_sign_BYTES, "sm must be at least 'crypto_sign_BYTES' bytes" ); assert( m.byteLength === sm.byteLength - binding.crypto_sign_BYTES, "m must be 'sm.byteLength - crypto_sign_BYTES' bytes" ); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); const res = binding.crypto_sign_open(m, sm, pk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_sign_open = function(m, sm, pk) { assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(sm), "sm must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( sm.byteLength >= binding.crypto_sign_BYTES, "sm must be at least 'crypto_sign_BYTES' bytes" ); assert( m.byteLength === sm.byteLength - binding.crypto_sign_BYTES, "m must be 'sm.byteLength - crypto_sign_BYTES' bytes" ); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); return binding.crypto_sign_open(m, sm, pk); }; exports.crypto_sign_detached = function(sig, m, sk) { assert(ArrayBuffer.isView(sig), "sig must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert(sig.byteLength === binding.crypto_sign_BYTES, "sig must be 'crypto_sign_BYTES' bytes"); assert( sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes" ); const res = binding.crypto_sign_detached(sig, m, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_sign_verify_detached = function(sig, m, pk) { assert(ArrayBuffer.isView(sig), "sig must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( sig.byteLength >= binding.crypto_sign_BYTES, "sig must be at least 'crypto_sign_BYTES' bytes" ); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); return binding.crypto_sign_verify_detached( sig.buffer, sig.byteOffset, sig.byteLength, m.buffer, m.byteOffset, m.byteLength, pk.buffer, pk.byteOffset, pk.byteLength ); }; exports.crypto_sign_ed25519_sk_to_pk = function(pk, sk) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes" ); const res = binding.crypto_sign_ed25519_sk_to_pk(pk, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_sign_ed25519_pk_to_curve25519 = function(x25519pk, ed25519pk) { assert(ArrayBuffer.isView(x25519pk), "x25519pk must be a typed array"); assert(ArrayBuffer.isView(ed25519pk), "ed25519pk must be a typed array"); assert( x25519pk.byteLength === binding.crypto_box_PUBLICKEYBYTES, "x25519pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert( ed25519pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "ed25519pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); const res = binding.crypto_sign_ed25519_pk_to_curve25519(x25519pk, ed25519pk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_sign_ed25519_sk_to_curve25519 = function(x25519sk, ed25519sk) { assert(ArrayBuffer.isView(x25519sk), "x25519sk must be a typed array"); assert(ArrayBuffer.isView(ed25519sk), "ed25519sk must be a typed array"); assert( x25519sk.byteLength === binding.crypto_box_SECRETKEYBYTES, "x25519sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); const edLen = ed25519sk.byteLength; assert( edLen === binding.crypto_sign_SECRETKEYBYTES || edLen === binding.crypto_box_SECRETKEYBYTES, "ed25519sk must be 'crypto_sign_SECRETKEYBYTES' or 'crypto_sign_SECRETKEYBYTES - crypto_sign_PUBLICKEYBYTES' bytes" ); const res = binding.crypto_sign_ed25519_sk_to_curve25519(x25519sk, ed25519sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_box_keypair = function(pk, sk) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( pk.byteLength === binding.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( sk.byteLength === binding.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); const res = binding.crypto_box_keypair(pk, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_box_seed_keypair = function(pk, sk, seed) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( pk.byteLength === binding.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( sk.byteLength === binding.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); assert(ArrayBuffer.isView(seed), "seed must be a typed array"); assert( seed.byteLength === binding.crypto_box_SEEDBYTES, "seed must be 'crypto_box_SEEDBYTES' bytes" ); const res = binding.crypto_box_seed_keypair(pk, sk, seed); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_box_easy = function(c, m, n, pk, sk) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( c.byteLength === m.byteLength + exports.crypto_box_MACBYTES, "c must be 'm.byteLength + crypto_box_MACBYTES' bytes" ); assert(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes"); assert( pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); const res = binding.crypto_box_easy(c, m, n, pk, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_box_detached = function(c, mac, m, n, pk, sk) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert(mac.byteLength === exports.crypto_box_MACBYTES, "mac must be 'crypto_box_MACBYTES' bytes"); assert(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes"); assert( pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); const res = binding.crypto_box_detached(c, mac, m, n, pk, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_box_open_easy = function(m, c, n, pk, sk) { assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( c.byteLength >= exports.crypto_box_MACBYTES, "c must be at least 'crypto_box_MACBYTES' bytes" ); assert( m.byteLength === c.byteLength - exports.crypto_box_MACBYTES, "m must be 'c.byteLength - crypto_box_MACBYTES' bytes" ); assert(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes"); assert( pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); return binding.crypto_box_open_easy(m, c, n, pk, sk); }; exports.crypto_box_open_detached = function(m, c, mac, n, pk, sk) { assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes"); assert(mac.byteLength === exports.crypto_box_MACBYTES, "mac must be 'crypto_box_MACBYTES' bytes"); assert(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes"); assert( pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); return binding.crypto_box_open_detached(m, c, mac, n, pk, sk); }; exports.crypto_box_seal = function(c, m, pk) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( c.byteLength === m.byteLength + exports.crypto_box_SEALBYTES, "c must be 'm.byteLength + crypto_box_SEALBYTES' bytes" ); assert( pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); const res = binding.crypto_box_seal(c, m, pk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_box_seal_open = function(m, c, pk, sk) { assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( c.byteLength >= exports.crypto_box_SEALBYTES, "c must be at least 'crypto_box_SEALBYTES' bytes" ); assert( m.byteLength === c.byteLength - exports.crypto_box_SEALBYTES, "m must be 'c.byteLength - crypto_box_SEALBYTES' bytes" ); assert( pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes" ); return binding.crypto_box_seal_open( m.buffer, m.byteOffset, m.byteLength, c.buffer, c.byteOffset, c.byteLength, pk.buffer, pk.byteOffset, pk.byteLength, sk.buffer, sk.byteOffset, sk.byteLength ); }; exports.crypto_secretbox_easy = function(c, m, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( c.byteLength === m.byteLength + binding.crypto_secretbox_MACBYTES, "c must be 'm.byteLength + crypto_secretbox_MACBYTES' bytes" ); assert( n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes" ); const res = binding.crypto_secretbox_easy(c, m, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_secretbox_open_easy = function(m, c, n, k) { assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( c.byteLength >= binding.crypto_secretbox_MACBYTES, "c must be at least 'crypto_secretbox_MACBYTES' bytes" ); assert( m.byteLength === c.byteLength - binding.crypto_secretbox_MACBYTES, "m must be 'c.byteLength - crypto_secretbox_MACBYTES' bytes" ); assert( n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes" ); return binding.crypto_secretbox_open_easy(m, c, n, k); }; exports.crypto_secretbox_detached = function(c, mac, m, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( mac.byteLength === binding.crypto_secretbox_MACBYTES, "mac must be 'crypto_secretbox_MACBYTES' bytes" ); assert( n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes" ); const res = binding.crypto_secretbox_detached(c, mac, m, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_secretbox_open_detached = function(m, c, mac, n, k) { assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes"); assert( mac.byteLength === binding.crypto_secretbox_MACBYTES, "mac must be 'crypto_secretbox_MACBYTES' bytes" ); assert( n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes" ); return binding.crypto_secretbox_open_detached(m, c, mac, n, k); }; exports.crypto_generichash = function(output, input, key) { if (!key) key = OPTIONAL; assert(ArrayBuffer.isView(output), "output must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( output.byteLength >= binding.crypto_generichash_BYTES_MIN && output.byteLength <= binding.crypto_generichash_BYTES_MAX, "output must be between crypto_generichash_BYTES_MIN and crypto_generichash_BYTES_MAX bytes" ); if (key !== OPTIONAL) { assert(ArrayBuffer.isView(key), "key must be a typed array"); assert( key.byteLength >= binding.crypto_generichash_KEYBYTES_MIN && key.byteLength <= binding.crypto_generichash_KEYBYTES_MAX, "key must be between crypto_generichash_KEYBYTES_MIN and crypto_generichash_KEYBYTES_MAX bytes" ); } const res = binding.crypto_generichash( output.buffer, output.byteOffset, output.byteLength, input.buffer, input.byteOffset, input.byteLength, key.buffer, key.byteOffset, key.byteLength ); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_generichash_batch = function(output, batch, key) { assert(ArrayBuffer.isView(output), "output must be a typed array"); if (isNode || batch.length < 4) { const res = binding.crypto_generichash_batch(output, batch, !!key, key || OPTIONAL); if (res !== 0) throw new Error("status: " + res); } else { const state = Buffer.alloc(binding.crypto_generichash_STATEBYTES); exports.crypto_generichash_init(state, key, output.byteLength); for (const buf of batch) { exports.crypto_generichash_update(state, buf); } exports.crypto_generichash_final(state, output); } }; exports.crypto_generichash_keygen = function(key) { assert(ArrayBuffer.isView(key), "key must be a typed array"); assert( key.byteLength === binding.crypto_generichash_KEYBYTES, "key must be 'crypto_generichash_KEYBYTES' bytes" ); const res = binding.crypto_generichash_keygen(key.buffer, key.byteOffset, key.byteLength); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_generichash_init = function(state, key, outputLength) { if (!key) key = OPTIONAL; assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_generichash_STATEBYTES, "state must be 'crypto_generichash_STATEBYTES' bytes" ); const res = binding.crypto_generichash_init( state.buffer, state.byteOffset, state.byteLength, key.buffer, key.byteOffset, key.byteLength, outputLength ); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_generichash_update = function(state, input) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( state.byteLength === binding.crypto_generichash_STATEBYTES, "state must be 'crypto_generichash_STATEBYTES' bytes" ); const res = binding.crypto_generichash_update( state.buffer, state.byteOffset, state.byteLength, input.buffer, input.byteOffset, input.byteLength ); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_generichash_final = function(state, output) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(output), "output must be a typed array"); assert( state.byteLength === binding.crypto_generichash_STATEBYTES, "state must be 'crypto_generichash_STATEBYTES' bytes" ); const res = binding.crypto_generichash_final( state.buffer, state.byteOffset, state.byteLength, output.buffer, output.byteOffset, output.byteLength ); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_secretstream_xchacha20poly1305_keygen = function(k) { assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_secretstream_xchacha20poly1305_KEYBYTES, "k must be 'crypto_secretstream_xchacha20poly1305_KEYBYTES' bytes" ); binding.crypto_secretstream_xchacha20poly1305_keygen(k.buffer, k.byteOffset, k.byteLength); }; exports.crypto_secretstream_xchacha20poly1305_init_push = function(state, header, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(header), "header must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes" ); assert( header.byteLength === binding.crypto_secretstream_xchacha20poly1305_HEADERBYTES, "header must be 'crypto_secretstream_xchacha20poly1305_HEADERBYTES' bytes" ); assert( k.byteLength === binding.crypto_secretstream_xchacha20poly1305_KEYBYTES, "k must be 'crypto_secretstream_xchacha20poly1305_KEYBYTES' bytes" ); const res = binding.crypto_secretstream_xchacha20poly1305_init_push( state.buffer, state.byteOffset, state.byteLength, header.buffer, header.byteOffset, header.byteLength, k.buffer, k.byteOffset, k.byteLength ); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_secretstream_xchacha20poly1305_init_pull = function(state, header, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(header), "header must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes" ); assert( header.byteLength === binding.crypto_secretstream_xchacha20poly1305_HEADERBYTES, "header must be 'crypto_secretstream_xchacha20poly1305_HEADERBYTES' bytes" ); assert( k.byteLength === binding.crypto_secretstream_xchacha20poly1305_KEYBYTES, "k must be 'crypto_secretstream_xchacha20poly1305_KEYBYTES' bytes" ); const res = binding.crypto_secretstream_xchacha20poly1305_init_pull( state.buffer, state.byteOffset, state.byteLength, header.buffer, header.byteOffset, header.byteLength, k.buffer, k.byteOffset, k.byteLength ); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_secretstream_xchacha20poly1305_push = function(state, c, m, ad, tag) { if (!ad) ad = OPTIONAL; assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert( state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes" ); assert( c.byteLength === m.byteLength + binding.crypto_secretstream_xchacha20poly1305_ABYTES, "c must be 'm.byteLength + crypto_secretstream_xchacha20poly1305_ABYTES' bytes" ); const res = binding.crypto_secretstream_xchacha20poly1305_push( state.buffer, state.byteOffset, state.byteLength, c.buffer, c.byteOffset, c.byteLength, m.buffer, m.byteOffset, m.byteLength, ad.buffer, ad.byteOffset, ad.byteLength, tag ); if (res < 0) throw new Error("push failed"); return res; }; exports.crypto_secretstream_xchacha20poly1305_pull = function(state, m, tag, c, ad) { if (!ad) ad = OPTIONAL; assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(tag), "tag must be a typed array"); assert(tag.byteLength === 1, "tag must be 1 byte"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert( c.byteLength >= binding.crypto_secretstream_xchacha20poly1305_ABYTES, "c must be at least 'crypto_secretstream_xchacha20poly1305_ABYTES' bytes" ); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert( m.byteLength === c.byteLength - binding.crypto_secretstream_xchacha20poly1305_ABYTES, "m must be 'c.byteLength - crypto_secretstream_xchacha20poly1305_ABYTES' bytes" ); const res = binding.crypto_secretstream_xchacha20poly1305_pull( state.buffer, state.byteOffset, state.byteLength, m.buffer, m.byteOffset, m.byteLength, tag.buffer, tag.byteOffset, tag.byteLength, c.buffer, c.byteOffset, c.byteLength, ad.buffer, ad.byteOffset, ad.byteLength ); if (res < 0) throw new Error("pull failed"); return res; }; exports.crypto_secretstream_xchacha20poly1305_rekey = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes" ); binding.crypto_secretstream_xchacha20poly1305_rekey( state.buffer, state.byteOffset, state.byteLength ); }; exports.crypto_stream = function(c, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( n.byteLength === binding.crypto_stream_NONCEBYTES, "n must be 'crypto_stream_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_KEYBYTES, "k must be 'crypto_stream_KEYBYTES' bytes" ); const res = binding.crypto_stream(c, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_xor = function(c, m, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_NONCEBYTES, "n must be 'crypto_stream_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_KEYBYTES, "k must be 'crypto_stream_KEYBYTES' bytes" ); const res = binding.crypto_stream_xor( c.buffer, c.byteOffset, c.byteLength, m.buffer, m.byteOffset, m.byteLength, n.buffer, n.byteOffset, n.byteLength, k.buffer, k.byteOffset, k.byteLength ); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_chacha20 = function(c, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes" ); const res = binding.crypto_stream_chacha20(c, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_chacha20_xor = function(c, m, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes" ); const res = binding.crypto_stream_chacha20_xor(c, m, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_chacha20_xor_ic = function(c, m, n, ic, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes" ); const res = binding.crypto_stream_chacha20_xor_ic(c, m, n, ic, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_chacha20_ietf = function(c, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes" ); const res = binding.crypto_stream_chacha20_ietf(c, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_chacha20_ietf_xor = function(c, m, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes" ); const res = binding.crypto_stream_chacha20_ietf_xor(c, m, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_chacha20_ietf_xor_ic = function(c, m, n, ic, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes" ); const res = binding.crypto_stream_chacha20_ietf_xor_ic(c, m, n, ic, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_xchacha20 = function(c, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes" ); const res = binding.crypto_stream_xchacha20(c, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_xchacha20_xor = function(c, m, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes" ); const res = binding.crypto_stream_xchacha20_xor(c, m, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_xchacha20_xor_ic = function(c, m, n, ic, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes" ); const res = binding.crypto_stream_xchacha20_xor_ic(c, m, n, ic, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_salsa20 = function(c, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes" ); const res = binding.crypto_stream_salsa20(c, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_salsa20_xor = function(c, m, n, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes" ); const res = binding.crypto_stream_salsa20_xor(c, m, n, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_stream_salsa20_xor_ic = function(c, m, n, ic, k) { assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert( n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes" ); assert( k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes" ); const res = binding.crypto_stream_salsa20_xor_ic(c, m, n, ic, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_auth = function(out, input, k) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(out.byteLength === binding.crypto_auth_BYTES, "out must be 'crypto_auth_BYTES' bytes"); assert(k.byteLength === binding.crypto_auth_KEYBYTES, "k must be 'crypto_auth_KEYBYTES' bytes"); const res = binding.crypto_auth(out, input, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_auth_verify = function(h, input, k) { assert(ArrayBuffer.isView(h), "h must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert(h.byteLength === binding.crypto_auth_BYTES, "h must be 'crypto_auth_BYTES' bytes"); assert(k.byteLength === binding.crypto_auth_KEYBYTES, "k must be 'crypto_auth_KEYBYTES' bytes"); return binding.crypto_auth_verify(h, input, k); }; exports.crypto_onetimeauth = function(out, input, k) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( out.byteLength === binding.crypto_onetimeauth_BYTES, "out must be 'crypto_onetimeauth_BYTES' bytes" ); assert( k.byteLength === binding.crypto_onetimeauth_KEYBYTES, "k must be 'crypto_onetimeauth_KEYBYTES' bytes" ); const res = binding.crypto_onetimeauth(out, input, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_onetimeauth_init = function(state, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( state.byteLength === binding.crypto_onetimeauth_STATEBYTES, "state must be 'crypto_onetimeauth_STATEBYTES' bytes" ); assert( k.byteLength === binding.crypto_onetimeauth_KEYBYTES, "k must be 'crypto_onetimeauth_KEYBYTES' bytes" ); const res = binding.crypto_onetimeauth_init(state, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_onetimeauth_update = function(state, input) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( state.byteLength === binding.crypto_onetimeauth_STATEBYTES, "state must be 'crypto_onetimeauth_STATEBYTES' bytes" ); const res = binding.crypto_onetimeauth_update(state, input); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_onetimeauth_final = function(state, out) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(out), "out must be a typed array"); assert( state.byteLength === binding.crypto_onetimeauth_STATEBYTES, "state must be 'crypto_onetimeauth_STATEBYTES' bytes" ); assert( out.byteLength === binding.crypto_onetimeauth_BYTES, "out must be 'crypto_onetimeauth_BYTES' bytes" ); const res = binding.crypto_onetimeauth_final(state, out); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_onetimeauth_verify = function(h, input, k) { assert(ArrayBuffer.isView(h), "h must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( h.byteLength === binding.crypto_onetimeauth_BYTES, "h must be 'crypto_onetimeauth_BYTES' bytes" ); assert( k.byteLength === binding.crypto_onetimeauth_KEYBYTES, "k must be 'crypto_onetimeauth_KEYBYTES' bytes" ); return binding.crypto_onetimeauth_verify(h, input, k); }; exports.crypto_pwhash = function(out, passwd, salt, opslimit, memlimit, alg) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert(ArrayBuffer.isView(salt), "salt must be a typed array"); assert( out.byteLength >= binding.crypto_pwhash_BYTES_MIN, "out must be at least 'crypto_pwhash_BYTES_MIN' bytes" ); assert( out.byteLength <= binding.crypto_pwhash_BYTES_MAX, "out must be at most 'crypto_pwhash_BYTES_MAX' bytes" ); assert( salt.byteLength === binding.crypto_pwhash_SALTBYTES, "salt must be 'crypto_pwhash_SALTBYTES' bytes" ); assert( opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'" ); assert(alg >= 1 && alg <= 2, "alg must be either Argon2i 1.3 or Argon2id 1.3"); const res = binding.crypto_pwhash(out, passwd, salt, opslimit, memlimit, alg); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_pwhash_async = function(out, passwd, salt, opslimit, memlimit, alg, callback = void 0) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert(ArrayBuffer.isView(salt), "salt must be a typed array"); assert( out.byteLength >= binding.crypto_pwhash_BYTES_MIN, "out must be at least 'crypto_pwhash_BYTES_MIN' bytes" ); assert( out.byteLength <= binding.crypto_pwhash_BYTES_MAX, "out must be at most 'crypto_pwhash_BYTES_MAX' bytes" ); assert( salt.byteLength === binding.crypto_pwhash_SALTBYTES, "salt must be 'crypto_pwhash_SALTBYTES' bytes" ); assert( opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'" ); assert(alg >= 1 && alg <= 2, "alg must be either Argon2i 1.3 or Argon2id 1.3"); const [done, promise] = checkStatus(callback); binding.crypto_pwhash_async( out.buffer, out.byteOffset, out.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, salt.buffer, salt.byteOffset, salt.byteLength, opslimit, memlimit, alg, done ); return promise; }; exports.crypto_pwhash_str = function(out, passwd, opslimit, memlimit) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( out.byteLength === binding.crypto_pwhash_STRBYTES, "out must be 'crypto_pwhash_STRBYTES' bytes" ); assert(typeof opslimit === "number", "opslimit must be a number"); assert( opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'" ); assert(typeof memlimit === "number", "memlimit must be a number"); assert( memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'" ); const res = binding.crypto_pwhash_str(out, passwd, opslimit, memlimit); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_pwhash_str_async = function(out, passwd, opslimit, memlimit, callback = void 0) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( out.byteLength === binding.crypto_pwhash_STRBYTES, "out must be 'crypto_pwhash_STRBYTES' bytes" ); assert(passwd.byteLength > 0, "passwd must not be empty"); assert(typeof opslimit === "number", "opslimit must be a number"); assert( opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'" ); assert(typeof memlimit === "number", "memlimit must be a number"); assert( memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'" ); const [done, promise] = checkStatus(callback); binding.crypto_pwhash_str_async( out.buffer, out.byteOffset, out.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, opslimit, memlimit, done ); return promise; }; exports.crypto_pwhash_str_verify = function(str, passwd) { assert(ArrayBuffer.isView(str), "str must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( str.byteLength === binding.crypto_pwhash_STRBYTES, "str must be 'crypto_pwhash_STRBYTES' bytes" ); return binding.crypto_pwhash_str_verify(str, passwd); }; exports.crypto_pwhash_str_verify_async = function(str, passwd, callback = void 0) { assert(ArrayBuffer.isView(str), "str must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( str.byteLength === binding.crypto_pwhash_STRBYTES, "str must be 'crypto_pwhash_STRBYTES' bytes" ); assert(passwd.byteLength > 0, "passwd must not be empty"); const [done, promise] = checkStatus(callback, true); binding.crypto_pwhash_str_verify_async( str.buffer, str.byteOffset, str.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, done ); return promise; }; exports.crypto_pwhash_str_needs_rehash = function(str, opslimit, memlimit) { assert(ArrayBuffer.isView(str), "str must be a typed array"); assert( str.byteLength === binding.crypto_pwhash_STRBYTES, "str must be 'crypto_pwhash_STRBYTES' bytes" ); assert( opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'" ); return binding.crypto_pwhash_str_needs_rehash(str, opslimit, memlimit); }; exports.crypto_pwhash_scryptsalsa208sha256 = function(out, passwd, salt, opslimit, memlimit) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert(ArrayBuffer.isView(salt), "salt must be a typed array"); assert( out.byteLength >= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MIN, "out must be at least 'crypto_pwhash_scryptsalsa208sha256_BYTES_MIN' bytes" ); assert( out.byteLength <= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MAX, "out must be at most 'crypto_pwhash_scryptsalsa208sha256_BYTES_MAX' bytes" ); assert( salt.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_SALTBYTES, "salt must be 'crypto_pwhash_scryptsalsa208sha256_SALTBYTES' bytes" ); assert( opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'" ); const res = binding.crypto_pwhash_scryptsalsa208sha256(out, passwd, salt, opslimit, memlimit); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_pwhash_scryptsalsa208sha256_async = function(out, passwd, salt, opslimit, memlimit, callback = void 0) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert(ArrayBuffer.isView(salt), "salt must be a typed array"); assert( out.byteLength >= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MIN, "out must be at least 'crypto_pwhash_scryptsalsa208sha256_BYTES_MIN' bytes" ); assert( out.byteLength <= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MAX, "out must be at most 'crypto_pwhash_scryptsalsa208sha256_BYTES_MAX' bytes" ); assert(passwd.byteLength > 0, "passwd must not be empty"); assert( salt.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_SALTBYTES, "salt must be 'crypto_pwhash_scryptsalsa208sha256_SALTBYTES' bytes" ); assert( opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'" ); const [done, promise] = checkStatus(callback); binding.crypto_pwhash_scryptsalsa208sha256_async( out.buffer, out.byteOffset, out.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, salt.buffer, salt.byteOffset, salt.byteLength, opslimit, memlimit, done ); return promise; }; exports.crypto_pwhash_scryptsalsa208sha256_str_async = function(out, passwd, opslimit, memlimit, callback = void 0) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( out.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "out must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes" ); assert(passwd.byteLength > 0, "passwd must not be empty"); assert( opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'" ); const [done, promise] = checkStatus(callback); binding.crypto_pwhash_scryptsalsa208sha256_str_async( out.buffer, out.byteOffset, out.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, opslimit, memlimit, done ); return promise; }; exports.crypto_pwhash_scryptsalsa208sha256_str = function(out, passwd, opslimit, memlimit) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( out.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "out must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes" ); assert(passwd.byteLength > 0, "passwd must not be empty"); assert( opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'" ); const res = binding.crypto_pwhash_scryptsalsa208sha256_str(out, passwd, opslimit, memlimit); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_pwhash_scryptsalsa208sha256_str_verify_async = function(str, passwd, callback = void 0) { assert(ArrayBuffer.isView(str), "str must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( str.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "str must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes" ); assert(passwd.byteLength > 0, "passwd must not be empty"); const [done, promise] = checkStatus(callback, true); binding.crypto_pwhash_scryptsalsa208sha256_str_verify_async( str.buffer, str.byteOffset, str.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, done ); return promise; }; exports.crypto_pwhash_scryptsalsa208sha256_str_verify = function(str, passwd) { assert(ArrayBuffer.isView(str), "str must be a typed array"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert( str.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "str must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes" ); assert(passwd.byteLength > 0, "passwd must not be empty"); return binding.crypto_pwhash_scryptsalsa208sha256_str_verify(str, passwd); }; exports.crypto_pwhash_scryptsalsa208sha256_str_needs_rehash = function(str, opslimit, memlimit) { assert(ArrayBuffer.isView(str), "str must be a typed array"); assert( str.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "str must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes" ); assert( opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'" ); assert( opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'" ); assert( memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'" ); assert( memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'" ); return binding.crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(str, opslimit, memlimit); }; exports.crypto_kx_keypair = function(pk, sk) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( pk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "pk must be 'crypto_kx_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "sk must be 'crypto_kx_SECRETKEYBYTES' bytes" ); const res = binding.crypto_kx_keypair(pk, sk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_kx_seed_keypair = function(pk, sk, seed) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert(ArrayBuffer.isView(seed), "seed must be a typed array"); assert( pk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "pk must be 'crypto_kx_PUBLICKEYBYTES' bytes" ); assert( sk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "sk must be 'crypto_kx_SECRETKEYBYTES' bytes" ); assert( seed.byteLength === binding.crypto_kx_SEEDBYTES, "seed must be 'crypto_kx_SEEDBYTES' bytes" ); const res = binding.crypto_kx_seed_keypair(pk, sk, seed); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_kx_client_session_keys = function(rx, tx, clientPk, clientSk, serverPk) { if (!rx) rx = void 0; if (!tx) tx = void 0; assert(rx || tx, "at least one session key must be specified"); if (rx) { assert(ArrayBuffer.isView(rx), "rx must be a typed array"); assert( rx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "rx must be 'crypto_kx_SESSIONKEYBYTES' bytes" ); } if (tx) { assert(ArrayBuffer.isView(tx), "tx must be a typed array"); assert( tx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "tx must be 'crypto_kx_SESSIONKEYBYTES' bytes" ); } assert(ArrayBuffer.isView(clientPk), "clientPk must be a typed array"); assert(ArrayBuffer.isView(clientSk), "clientSk must be a typed array"); assert(ArrayBuffer.isView(serverPk), "serverPk must be a typed array"); assert( clientPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "clientPk must be 'crypto_kx_PUBLICKEYBYTES' bytes" ); assert( clientSk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "clientSk must be 'crypto_kx_SECRETKEYBYTES' bytes" ); assert( serverPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "serverPk must be 'crypto_kx_PUBLICKEYBYTES' bytes" ); const res = binding.crypto_kx_client_session_keys(rx, tx, clientPk, clientSk, serverPk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_kx_server_session_keys = function(rx, tx, serverPk, serverSk, clientPk) { if (!rx) rx = void 0; if (!tx) tx = void 0; assert(rx || tx, "at least one session key must be specified"); if (rx) { assert(ArrayBuffer.isView(rx), "rx must be a typed array"); assert( rx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "rx must be 'crypto_kx_SESSIONKEYBYTES' bytes" ); } if (tx) { assert(ArrayBuffer.isView(tx), "tx must be a typed array"); assert( tx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "tx must be 'crypto_kx_SESSIONKEYBYTES' bytes" ); } assert(ArrayBuffer.isView(serverPk), "serverPk must be a typed array"); assert(ArrayBuffer.isView(serverSk), "serverSk must be a typed array"); assert(ArrayBuffer.isView(clientPk), "clientPk must be a typed array"); assert( serverPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "serverPk must be 'crypto_kx_PUBLICKEYBYTES' bytes" ); assert( serverSk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "serverSk must be 'crypto_kx_SECRETKEYBYTES' bytes" ); assert( clientPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "clientPk must be 'crypto_kx_PUBLICKEYBYTES' bytes" ); const res = binding.crypto_kx_server_session_keys(rx, tx, serverPk, serverSk, clientPk); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_scalarmult_base = function(q, n) { assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_scalarmult_BYTES, "q must be 'crypto_scalarmult_BYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_scalarmult_SCALARBYTES, "n must be 'crypto_scalarmult_SCALARBYTES' bytes" ); const res = binding.crypto_scalarmult_base(q, n); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_scalarmult = function(q, n, p) { assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_scalarmult_BYTES, "q must be 'crypto_scalarmult_BYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_scalarmult_SCALARBYTES, "n must be 'crypto_scalarmult_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_scalarmult_BYTES, "p must be 'crypto_scalarmult_BYTES' bytes" ); const res = binding.crypto_scalarmult(q, n, p); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_scalarmult_ed25519_base = function(q, n) { assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes" ); const res = binding.crypto_scalarmult_ed25519_base(q, n); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_scalarmult_ed25519 = function(q, n, p) { assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "p must be 'crypto_scalarmult_ed25519_BYTES' bytes" ); const res = binding.crypto_scalarmult_ed25519(q, n, p); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_core_ed25519_is_valid_point = function(p) { assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes" ); return binding.crypto_core_ed25519_is_valid_point(p); }; exports.crypto_core_ed25519_from_uniform = function(p, r) { assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(r), "r must be a typed array"); assert( r.byteLength === binding.crypto_core_ed25519_UNIFORMBYTES, "r must be 'crypto_core_ed25519_UNIFORMBYTES' bytes" ); const res = binding.crypto_core_ed25519_from_uniform(p, r); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_scalarmult_ed25519_base_noclamp = function(q, n) { assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes" ); const res = binding.crypto_scalarmult_ed25519_base_noclamp(q, n); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_scalarmult_ed25519_noclamp = function(q, n, p) { assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "p must be 'crypto_scalarmult_ed25519_BYTES' bytes" ); const res = binding.crypto_scalarmult_ed25519_noclamp(q, n, p); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_core_ed25519_add = function(r, p, q) { assert(ArrayBuffer.isView(r), "r must be a typed array"); assert( r.byteLength === binding.crypto_core_ed25519_BYTES, "r must be 'crypto_core_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_core_ed25519_BYTES, "q must be 'crypto_core_ed25519_BYTES' bytes" ); const res = binding.crypto_core_ed25519_add(r, p, q); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_core_ed25519_sub = function(r, p, q) { assert(ArrayBuffer.isView(r), "r must be a typed array"); assert( r.byteLength === binding.crypto_core_ed25519_BYTES, "r must be 'crypto_core_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(q), "q must be a typed array"); assert( q.byteLength === binding.crypto_core_ed25519_BYTES, "q must be 'crypto_core_ed25519_BYTES' bytes" ); const res = binding.crypto_core_ed25519_sub(r, p, q); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_core_ed25519_scalar_random = function(r) { assert(ArrayBuffer.isView(r), "r must be a typed array"); assert( r.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "r must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); binding.crypto_core_ed25519_scalar_random(r); }; exports.crypto_core_ed25519_scalar_reduce = function(r, s) { assert(ArrayBuffer.isView(r), "r must be a typed array"); assert( r.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "r must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(s), "s must be a typed array"); assert( s.byteLength === binding.crypto_core_ed25519_NONREDUCEDSCALARBYTES, "s must be 'crypto_core_ed25519_NONREDUCEDSCALARBYTES' bytes" ); binding.crypto_core_ed25519_scalar_reduce(r, s); }; exports.crypto_core_ed25519_scalar_invert = function(recip, s) { assert(ArrayBuffer.isView(recip), "recip must be a typed array"); assert( recip.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "recip must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(s), "s must be a typed array"); assert( s.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "s must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); binding.crypto_core_ed25519_scalar_invert(recip, s); }; exports.crypto_core_ed25519_scalar_negate = function(neg, s) { assert(ArrayBuffer.isView(neg), "neg must be a typed array"); assert( neg.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "neg must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(s), "s must be a typed array"); assert( s.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "s must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); binding.crypto_core_ed25519_scalar_negate(neg, s); }; exports.crypto_core_ed25519_scalar_complement = function(comp, s) { assert(ArrayBuffer.isView(comp), "comp must be a typed array"); assert( comp.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "comp must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(s), "s must be a typed array"); assert( s.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "s must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); binding.crypto_core_ed25519_scalar_complement(comp, s); }; exports.crypto_core_ed25519_scalar_add = function(z, x, y) { assert(ArrayBuffer.isView(z), "z must be a typed array"); assert( z.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "z must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(x), "x must be a typed array"); assert( x.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "x must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(y), "y must be a typed array"); assert( y.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "y must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); binding.crypto_core_ed25519_scalar_add(z, x, y); }; exports.crypto_core_ed25519_scalar_sub = function(z, x, y) { assert(ArrayBuffer.isView(z), "z must be a typed array"); assert( z.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "z must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(x), "x must be a typed array"); assert( x.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "x must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(y), "y must be a typed array"); assert( y.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "y must be 'crypto_core_ed25519_SCALARBYTES' bytes" ); binding.crypto_core_ed25519_scalar_sub(z, x, y); }; exports.crypto_shorthash = function(out, input, k) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( out.byteLength === binding.crypto_shorthash_BYTES, "out must be 'crypto_shorthash_BYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_shorthash_KEYBYTES, "k must be 'crypto_shorthash_KEYBYTES' bytes" ); const res = binding.crypto_shorthash(out, input, k); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_kdf_keygen = function(key) { assert(ArrayBuffer.isView(key), "key must be a typed array"); assert(key.byteLength === binding.crypto_kdf_KEYBYTES, "key must be 'crypto_kdf_KEYBYTES' bytes"); binding.crypto_kdf_keygen(key); }; exports.crypto_kdf_derive_from_key = function(subkey, subkeyId, ctx, key) { assert(ArrayBuffer.isView(subkey), "subkey must be a typed array"); assert( subkey.byteLength >= binding.crypto_kdf_BYTES_MIN, "subkey must be at least 'crypto_kdf_BYTES_MIN' bytes" ); assert( subkey.byteLength <= binding.crypto_kdf_BYTES_MAX, "subkey must be at most 'crypto_kdf_BYTES_MAX' bytes" ); assert(ArrayBuffer.isView(ctx), "ctx must be a typed array"); assert( ctx.byteLength === binding.crypto_kdf_CONTEXTBYTES, "ctx must be 'crypto_kdf_CONTEXTBYTES' bytes" ); assert(ArrayBuffer.isView(key), "key must be a typed array"); assert(key.byteLength === binding.crypto_kdf_KEYBYTES, "key must be 'crypto_kdf_KEYBYTES' bytes"); const res = binding.crypto_kdf_derive_from_key(subkey, subkeyId, ctx, key); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash = function(out, input) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert(out.byteLength === binding.crypto_hash_BYTES, "out must be 'crypto_hash_BYTES' bytes"); const res = binding.crypto_hash(out, input); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha256 = function(out, input) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( out.byteLength === binding.crypto_hash_sha256_BYTES, "out must be 'crypto_hash_sha256_BYTES' bytes" ); const res = binding.crypto_hash_sha256(out, input); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha256_init = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_hash_sha256_STATEBYTES, "state must be 'crypto_hash_sha256_STATEBYTES' bytes" ); const res = binding.crypto_hash_sha256_init(state); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha256_update = function(state, input) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( state.byteLength === binding.crypto_hash_sha256_STATEBYTES, "state must be 'crypto_hash_sha256_STATEBYTES' bytes" ); const res = binding.crypto_hash_sha256_update(state, input); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha256_final = function(state, out) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_hash_sha256_STATEBYTES, "state must be 'crypto_hash_sha256_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(out), "out must be a typed array"); assert( out.byteLength === binding.crypto_hash_sha256_BYTES, "out must be 'crypto_hash_sha256_BYTES' bytes" ); const res = binding.crypto_hash_sha256_final(state, out); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha512 = function(out, input) { assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( out.byteLength === binding.crypto_hash_sha512_BYTES, "out must be 'crypto_hash_sha512_BYTES' bytes" ); const res = binding.crypto_hash_sha512(out, input); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha512_init = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_hash_sha512_STATEBYTES, "state must be 'crypto_hash_sha512_STATEBYTES' bytes" ); const res = binding.crypto_hash_sha512_init(state); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha512_update = function(state, input) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert(ArrayBuffer.isView(input), "input must be a typed array"); assert( state.byteLength === binding.crypto_hash_sha512_STATEBYTES, "state must be 'crypto_hash_sha512_STATEBYTES' bytes" ); const res = binding.crypto_hash_sha512_update(state, input); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_hash_sha512_final = function(state, out) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_hash_sha512_STATEBYTES, "state must be 'crypto_hash_sha512_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(out), "out must be a typed array"); assert( out.byteLength === binding.crypto_hash_sha512_BYTES, "out must be 'crypto_hash_sha512_BYTES' bytes" ); const res = binding.crypto_hash_sha512_final(state, out); if (res !== 0) throw new Error("status: " + res); }; exports.crypto_aead_xchacha20poly1305_ietf_keygen = function(k) { assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes" ); binding.crypto_aead_xchacha20poly1305_ietf_keygen(k); }; exports.crypto_aead_xchacha20poly1305_ietf_encrypt = function(c, m, ad, nsec, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert( c.byteLength === m.byteLength + binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "c must be 'm.byteLength + crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes" ); assert(c.byteLength <= 4294967295, "c.byteLength must be a 32bit integer"); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_xchacha20poly1305_ietf_encrypt(c, m, ad, npub, k); if (res < 0) throw new Error("could not encrypt data"); return res; }; exports.crypto_aead_xchacha20poly1305_ietf_decrypt = function(m, nsec, c, ad, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert( m.byteLength === c.byteLength - binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "m must be 'c.byteLength - crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes" ); assert(m.byteLength <= 4294967295, "m.byteLength must be a 32bit integer"); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_xchacha20poly1305_ietf_decrypt(m, c, ad, npub, k); if (res < 0) throw new Error("could not verify data"); return res; }; exports.crypto_aead_xchacha20poly1305_ietf_encrypt_detached = function(c, mac, m, ad, nsec, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert( mac.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes" ); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_xchacha20poly1305_ietf_encrypt_detached(c, mac, m, ad, npub, k); if (res < 0) throw new Error("could not encrypt data"); return res; }; exports.crypto_aead_xchacha20poly1305_ietf_decrypt_detached = function(m, nsec, c, mac, ad, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert( mac.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes" ); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_xchacha20poly1305_ietf_decrypt_detached(m, c, mac, ad, npub, k); if (res !== 0) throw new Error("could not verify data"); }; exports.crypto_aead_chacha20poly1305_ietf_keygen = function(k) { assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes" ); binding.crypto_aead_chacha20poly1305_ietf_keygen(k); }; exports.crypto_aead_chacha20poly1305_ietf_encrypt = function(c, m, ad, nsec, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert( c.byteLength === m.byteLength + binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "c must be 'm.byteLength + crypto_aead_chacha20poly1305_ietf_ABYTES' bytes" ); assert(c.byteLength <= 4294967295, "c.byteLength must be a 32bit integer"); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_chacha20poly1305_ietf_encrypt(c, m, ad, npub, k); if (res < 0) throw new Error("could not encrypt data"); return res; }; exports.crypto_aead_chacha20poly1305_ietf_decrypt = function(m, nsec, c, ad, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert( m.byteLength === c.byteLength - binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "m must be 'c.byteLength - crypto_aead_chacha20poly1305_ietf_ABYTES' bytes" ); assert(m.byteLength <= 4294967295, "m.byteLength must be a 32bit integer"); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_chacha20poly1305_ietf_decrypt(m, c, ad, npub, k); if (res < 0) throw new Error("could not verify data"); return res; }; exports.crypto_aead_chacha20poly1305_ietf_encrypt_detached = function(c, mac, m, ad, nsec, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert( mac.byteLength === binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_chacha20poly1305_ietf_ABYTES' bytes" ); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_chacha20poly1305_ietf_encrypt_detached(c, mac, m, ad, npub, k); if (res < 0) throw new Error("could not encrypt data"); return res; }; exports.crypto_aead_chacha20poly1305_ietf_decrypt_detached = function(m, nsec, c, mac, ad, npub, k) { if (!ad) ad = void 0; assert(nsec === null, "nsec must always be set to null"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes"); assert(ArrayBuffer.isView(mac), "mac must be a typed array"); assert( mac.byteLength === binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_chacha20poly1305_ietf_ABYTES' bytes" ); assert(ArrayBuffer.isView(npub), "npub must be a typed array"); assert( npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes" ); const res = binding.crypto_aead_chacha20poly1305_ietf_decrypt_detached(m, c, mac, ad, npub, k); if (res !== 0) throw new Error("could not verify data"); }; exports.crypto_stream_xor_wrap_init = function(state, n, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.sn_crypto_stream_xor_STATEBYTES, "state must be 'sn_crypto_stream_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_stream_NONCEBYTES, "n must be 'crypto_stream_NONCEBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_stream_KEYBYTES, "k must be 'crypto_stream_KEYBYTES' bytes" ); binding.crypto_stream_xor_wrap_init(state, n, k); }; exports.crypto_stream_xor_wrap_update = function(state, c, m) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.sn_crypto_stream_xor_STATEBYTES, "state must be 'sn_crypto_stream_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); binding.crypto_stream_xor_wrap_update(state, c, m); }; exports.crypto_stream_xor_wrap_final = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.sn_crypto_stream_xor_STATEBYTES, "state must be 'sn_crypto_stream_xor_STATEBYTES' bytes" ); binding.crypto_stream_xor_wrap_final(state); }; exports.crypto_stream_chacha20_xor_wrap_init = function(state, n, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_chacha20_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes" ); binding.crypto_stream_chacha20_xor_wrap_init(state, n, k); }; exports.crypto_stream_chacha20_xor_wrap_update = function(state, c, m) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_chacha20_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); binding.crypto_stream_chacha20_xor_wrap_update(state, c, m); }; exports.crypto_stream_chacha20_xor_wrap_final = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_chacha20_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_xor_STATEBYTES' bytes" ); binding.crypto_stream_chacha20_xor_wrap_final(state); }; exports.crypto_stream_chacha20_ietf_xor_wrap_init = function(state, n, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_chacha20_ietf_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_ietf_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes" ); binding.crypto_stream_chacha20_ietf_xor_wrap_init(state, n, k); }; exports.crypto_stream_chacha20_ietf_xor_wrap_update = function(state, c, m) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_chacha20_ietf_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_ietf_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); binding.crypto_stream_chacha20_ietf_xor_wrap_update(state, c, m); }; exports.crypto_stream_chacha20_ietf_xor_wrap_final = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_chacha20_ietf_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_ietf_xor_STATEBYTES' bytes" ); binding.crypto_stream_chacha20_ietf_xor_wrap_final(state); }; exports.crypto_stream_xchacha20_xor_wrap_init = function(state, n, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_xchacha20_xor_STATEBYTES, "state must be 'crypto_stream_xchacha20_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes" ); binding.crypto_stream_xchacha20_xor_wrap_init(state, n, k); }; exports.crypto_stream_xchacha20_xor_wrap_update = function(state, c, m) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_xchacha20_xor_STATEBYTES, "state must be 'crypto_stream_xchacha20_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); binding.crypto_stream_xchacha20_xor_wrap_update(state, c, m); }; exports.crypto_stream_xchacha20_xor_wrap_final = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_xchacha20_xor_STATEBYTES, "state must be 'crypto_stream_xchacha20_xor_STATEBYTES' bytes" ); binding.crypto_stream_xchacha20_xor_wrap_final(state); }; exports.crypto_stream_salsa20_xor_wrap_init = function(state, n, k) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_salsa20_xor_STATEBYTES, "state must be 'crypto_stream_salsa20_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes" ); assert(ArrayBuffer.isView(k), "k must be a typed array"); assert( k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes" ); binding.crypto_stream_salsa20_xor_wrap_init(state, n, k); }; exports.crypto_stream_salsa20_xor_wrap_update = function(state, c, m) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_salsa20_xor_STATEBYTES, "state must be 'crypto_stream_salsa20_xor_STATEBYTES' bytes" ); assert(ArrayBuffer.isView(c), "c must be a typed array"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes"); binding.crypto_stream_salsa20_xor_wrap_update(state, c, m); }; exports.crypto_stream_salsa20_xor_wrap_final = function(state) { assert(ArrayBuffer.isView(state), "state must be a typed array"); assert( state.byteLength === binding.crypto_stream_salsa20_xor_STATEBYTES, "state must be 'crypto_stream_salsa20_xor_STATEBYTES' bytes" ); binding.crypto_stream_salsa20_xor_wrap_final(state); }; exports.extension_tweak_ed25519_base = function(n, p, ns) { assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "n must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.extension_tweak_ed25519_BYTES, "p must be 'extension_tweak_ed25519_BYTES' bytes" ); binding.extension_tweak_ed25519_base(n, p, ns); }; exports.extension_tweak_ed25519_sign_detached = function(sig, m, scalar, pk) { assert(ArrayBuffer.isView(sig), "sig must be a typed array"); assert(sig.byteLength === binding.crypto_sign_BYTES, "sig must be 'crypto_sign_BYTES' bytes"); assert(ArrayBuffer.isView(m), "m must be a typed array"); assert(ArrayBuffer.isView(scalar), "scalar must be a typed array"); assert( scalar.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalar must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); if (pk) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); } const res = binding.extension_tweak_ed25519_sign_detached(sig, m, scalar, pk); if (res !== 0) throw new Error("failed to compute signature"); }; exports.extension_tweak_ed25519_sk_to_scalar = function(n, sk) { assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "n must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(sk), "sk must be a typed array"); assert( sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes" ); binding.extension_tweak_ed25519_sk_to_scalar(n, sk); }; exports.extension_tweak_ed25519_scalar = function(scalarOut, scalar, ns) { assert(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array"); assert( scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(scalar), "scalar must be a typed array"); assert( scalar.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalar must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); binding.extension_tweak_ed25519_scalar(scalarOut, scalar, ns); }; exports.extension_tweak_ed25519_pk = function(tpk, pk, ns) { assert(ArrayBuffer.isView(tpk), "tpk must be a typed array"); assert( tpk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "tpk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); const res = binding.extension_tweak_ed25519_pk(tpk, pk, ns); if (res !== 0) throw new Error("failed to tweak public key"); }; exports.extension_tweak_ed25519_keypair = function(pk, scalarOut, scalarIn, ns) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( pk.byteLength === binding.extension_tweak_ed25519_BYTES, "pk must be 'extension_tweak_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array"); assert( scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(scalarIn), "scalarIn must be a typed array"); assert( scalarIn.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarIn must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); binding.extension_tweak_ed25519_keypair(pk, scalarOut, scalarIn, ns); }; exports.extension_tweak_ed25519_scalar_add = function(scalarOut, scalar, n) { assert(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array"); assert( scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(scalar), "scalar must be a typed array"); assert( scalar.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalar must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(n), "n must be a typed array"); assert( n.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "n must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); binding.extension_tweak_ed25519_scalar_add(scalarOut, scalar, n); }; exports.extension_tweak_ed25519_pk_add = function(tpk, pk, p) { assert(ArrayBuffer.isView(tpk), "tpk must be a typed array"); assert( tpk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "tpk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); assert(ArrayBuffer.isView(p), "p must be a typed array"); assert( p.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "p must be 'crypto_sign_PUBLICKEYBYTES' bytes" ); const res = binding.extension_tweak_ed25519_pk_add(tpk, pk, p); if (res !== 0) throw new Error("failed to add tweak to public key"); }; exports.extension_tweak_ed25519_keypair_add = function(pk, scalarOut, scalarIn, tweak) { assert(ArrayBuffer.isView(pk), "pk must be a typed array"); assert( pk.byteLength === binding.extension_tweak_ed25519_BYTES, "pk must be 'extension_tweak_ed25519_BYTES' bytes" ); assert(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array"); assert( scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(scalarIn), "scalarIn must be a typed array"); assert( scalarIn.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarIn must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); assert(ArrayBuffer.isView(tweak), "tweak must be a typed array"); assert( tweak.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "tweak must be 'extension_tweak_ed25519_SCALARBYTES' bytes" ); const res = binding.extension_tweak_ed25519_keypair_add(pk, scalarOut, scalarIn, tweak); if (res !== 0) throw new Error("failed to add tweak to keypair"); }; exports.extension_pbkdf2_sha512_async = function(out, passwd, salt, iter, outlen, callback) { assert( iter >= binding.extension_pbkdf2_sha512_ITERATIONS_MIN, "iter must be at least 'extension_pbkdf2_sha512_ITERATIONS_MIN'" ); assert( outlen <= binding.extension_pbkdf2_sha512_BYTES_MAX, "outlen must be at most 'extension_pbkdf2_sha512_BYTES_MAX'" ); assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(out.byteLength >= outlen, "out must be at least 'outlen' bytes"); assert(out.byteLength > 0, "out must not be empty"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert(passwd.byteLength > 0, "passwd must not be empty"); assert(ArrayBuffer.isView(salt), "salt must be a typed array"); assert(salt.byteLength > 0, "salt must not be empty"); const [done, promise] = checkStatus(callback); binding.extension_pbkdf2_sha512_async( out.buffer, out.byteOffset, out.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, salt.buffer, salt.byteOffset, salt.byteLength, iter, outlen, done ); return promise; }; exports.extension_pbkdf2_sha512 = function(out, passwd, salt, iter, outlen) { assert( iter >= binding.extension_pbkdf2_sha512_ITERATIONS_MIN, "iter must be at least 'extension_pbkdf2_sha512_ITERATIONS_MIN'" ); assert( outlen <= binding.extension_pbkdf2_sha512_BYTES_MAX, "outlen must be at most 'extension_pbkdf2_sha512_BYTES_MAX'" ); assert(ArrayBuffer.isView(out), "out must be a typed array"); assert(out.byteLength >= outlen, "out must be at least 'outlen' bytes"); assert(out.byteLength > 0, "out must not be empty"); assert(ArrayBuffer.isView(passwd), "passwd must be a typed array"); assert(passwd.byteLength > 0, "passwd must not be empty"); assert(ArrayBuffer.isView(salt), "salt must be a typed array"); assert(salt.byteLength > 0, "salt must not be empty"); const res = binding.extension_pbkdf2_sha512(out, passwd, salt, iter, outlen); if (res !== 0) throw new Error("failed to add tweak to public key"); }; function checkStatus(callback, booleanResult = false) { let done, promise; if (typeof callback === "function") { done = function(status) { if (booleanResult) callback(null, status === 0); else if (status === 0) callback(null); else callback(new Error("status: " + status)); }; } else { promise = new Promise(function(resolve, reject) { done = function(status) { if (booleanResult) resolve(status === 0); else if (status === 0) resolve(); else reject(new Error("status: " + status)); }; }); } return [done, promise]; } } }); // ../../node_modules/bare-bundle-id/index.js var require_bare_bundle_id = __commonJS({ "../../node_modules/bare-bundle-id/index.js"(exports, module) { var sodium = require_sodium_native(); var slab = Buffer.allocUnsafe( 1 + // Delimiter 4 + // Temporary sodium.crypto_generichash_STATEBYTES ); var delim = slab.subarray(0, 1).fill(0); var tmp = slab.subarray(1, 5); var state = slab.subarray(5); module.exports = function id(bundle, out = Buffer.allocUnsafe(32)) { sodium.crypto_generichash_init(state, null, out.byteLength); const files = [...bundle].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0); for (const [key, data, mode] of files) { const buf = Buffer.from(key); sodium.crypto_generichash_update(state, tmp.subarray(0, tmp.writeUInt32LE(buf.byteLength))); sodium.crypto_generichash_update(state, buf); sodium.crypto_generichash_update(state, tmp.subarray(0, tmp.writeUInt32LE(data.byteLength))); sodium.crypto_generichash_update(state, data); sodium.crypto_generichash_update(state, tmp.subarray(0, tmp.writeUInt16LE(mode))); sodium.crypto_generichash_update(state, delim); } sodium.crypto_generichash_final(state, out); return out; }; } }); // ../../node_modules/promaphore/index.js var require_promaphore = __commonJS({ "../../node_modules/promaphore/index.js"(exports, module) { var DONE = Promise.resolve(true); var DESTROYED = Promise.resolve(false); module.exports = class Semaphore { constructor(limit = 1) { this.limit = limit; this.active = 0; this.waiting = []; this.destroyed = false; this._onwait = (resolve) => { this.waiting.push(resolve); }; } wait() { if (this.destroyed === true) return DESTROYED; if (this.active < this.limit && this.waiting.length === 0) { this.active++; return DONE; } return new Promise(this._onwait); } signal() { if (this.destroyed === true) return; this.active--; while (this.active < this.limit && this.waiting.length > 0 && this.destroyed === false) { this.active++; this.waiting.shift()(true); } } async flush() { if (this.destroyed === true) return; this.limit = 1; await this.wait(); this.signal(); } destroy() { this.destroyed = true; this.active = 0; while (this.waiting.length) this.waiting.pop()(false); } }; } }); // ../../node_modules/bare-bundle/lib/errors.js var require_errors5 = __commonJS({ "../../node_modules/bare-bundle/lib/errors.js"(exports, module) { module.exports = class BundleError extends Error { constructor(msg, fn = BundleError, opts = {}) { const { cause, code = fn.name } = opts; super(`${code}: ${msg}`, { cause }); this.code = code; if (Error.captureStackTrace) { Error.captureStackTrace(this, fn); } } get name() { return "BundleError"; } static INVALID_BUNDLE_HEADER(msg, cause) { return new BundleError(msg, BundleError.INVALID_BUNDLE_HEADER, { cause }); } }; } }); // ../../node_modules/bare-bundle/index.js var require_bare_bundle = __commonJS({ "../../node_modules/bare-bundle/index.js"(exports, module) { var errors = require_errors5(); var kind = Symbol.for("bare.bundle.kind"); var MemoryFile = class _MemoryFile { constructor(data, opts = {}) { const { executable = false, mode = executable ? 493 : 420 } = opts; this._data = typeof data === "string" ? Buffer.from(data) : data; this._mode = mode; } size() { return this._data.byteLength; } mode() { return this._mode; } read() { return this._data; } inspect() { return { __proto__: { constructor: _MemoryFile }, data: this._data, mode: this._mode.toString(8) }; } [Symbol.for("bare.inspect")]() { return this.inspect(); } [Symbol.for("nodejs.util.inspect.custom")]() { return this.inspect(); } }; module.exports = exports = class Bundle2 { static get [kind]() { return 0; } static get version() { return 0; } constructor(opts = {}) { const { File = MemoryFile } = opts; this._File = File; this._id = null; this._main = null; this._imports = {}; this._resolutions = {}; this._addons = []; this._assets = []; this._files = /* @__PURE__ */ new Map(); } get [kind]() { return Bundle2[kind]; } get version() { return Bundle2.version; } get id() { return this._id; } set id(value) { if (typeof value !== "string" && value !== null) { throw new TypeError(`ID must be a string or null. Received type ${typeof value} (${value})`); } this._id = value; } get main() { return this._main; } set main(value) { if (typeof value !== "string" && value !== null) { throw new TypeError(`Main must be a string or null. Received type ${typeof value} (${value})`); } this._main = value; } get imports() { return this._imports; } set imports(value) { this._imports = cloneImportsMap(value); } get resolutions() { return this._resolutions; } set resolutions(value) { this._resolutions = cloneResolutionsMap(value); } get addons() { return this._addons; } set addons(value) { this._addons = cloneFilesList(value, "Addons"); } get assets() { return this._assets; } set assets(value) { this._assets = cloneFilesList(value, "Assets"); } get files() { return Object.fromEntries(this._files.entries()); } *[Symbol.iterator]() { for (const [key, file] of this._files) { yield [key, file.read(), file.mode()]; } } empty() { return this._files.size === 0; } keys() { return this._files.keys(); } exists(key) { return this._files.has(key); } size(key) { const file = this._files.get(key) || null; if (file === null) return 0; return file.size(); } mode(key) { const file = this._files.get(key) || null; if (file === null) return 0; return file.mode(); } read(key) { const file = this._files.get(key) || null; if (file === null) return null; return file.read(); } write(key, data, opts = {}) { if (typeof key !== "string") { throw new TypeError(`File path must be a string. Received type ${typeof key} (${key})`); } const { main = false, alias = null, imports = null, addon = false, asset = false } = opts; this._files.set(key, new MemoryFile(data, opts)); if (main) this._main = key; if (alias) this._imports[alias] = key; if (imports) this._resolutions[key] = cloneImportsMap(imports); if (addon) this._addons.push(key); if (asset) this._assets.push(key); return this; } mount(root, opts = {}) { const bundle = new Bundle2(); bundle._File = this._File; bundle._id = this._id; if (this._main) bundle._main = mountSpecifier(this._main, root); bundle._imports = transformImportsMap(this._imports, root, null, opts, mountSpecifier); bundle._resolutions = transformResolutionsMap(this._resolutions, root, opts, mountSpecifier); for (const [key, file] of this._files) { bundle._files.set(mountSpecifier(key, root), file); } bundle._addons = transformFilesList(this._addons, root, mountSpecifier); bundle._assets = transformFilesList(this._assets, root, mountSpecifier); return bundle; } unmount(root, opts = {}) { const bundle = new Bundle2(); bundle._File = this._File; bundle._id = this._id; if (this._main) bundle._main = unmountSpecifier(this._main, root); bundle._imports = transformImportsMap(this._imports, root, null, opts, unmountSpecifier); bundle._resolutions = transformResolutionsMap(this._resolutions, root, opts, unmountSpecifier); for (const [key, file] of this._files) { bundle._files.set(unmountSpecifier(key, root), file); } bundle._addons = transformFilesList(this._addons, root, unmountSpecifier); bundle._assets = transformFilesList(this._assets, root, unmountSpecifier); return bundle; } toBuffer(opts = {}) { const { indent = 0, shared = false } = opts; const header = { version: Bundle2.version, id: this._id, main: this._main, imports: cloneImportsMap(this._imports), resolutions: cloneResolutionsMap(this._resolutions), addons: cloneFilesList(this._addons, "Addons"), assets: cloneFilesList(this._assets, "Assets"), files: {} }; const keys = [...this._files.keys()].sort(); let offset = 0; for (const key of keys) { const length2 = this.size(key); header.files[key] = { offset, length: length2, mode: this.mode(key) }; offset += length2; } const json = Buffer.from(` ${JSON.stringify(header, null, indent)} `); const length = Buffer.from(json.byteLength.toString(10)); const total = length.byteLength + json.byteLength + offset; const storage = shared ? new SharedArrayBuffer(total) : new ArrayBuffer(total); const buffer = Buffer.from(storage); offset = 0; buffer.set(length, offset); offset += length.byteLength; buffer.set(json, offset); offset += json.byteLength; for (const key of keys) { buffer.set(this.read(key), offset); offset += this.size(key); } return buffer; } inspect() { return { __proto__: { constructor: Bundle2 }, version: this.version, id: this.id, main: this.main, imports: this.imports, resolutions: this.resolutions, addons: this.addons, assets: this.assets, files: this.files }; } [Symbol.for("bare.inspect")]() { return this.inspect(); } [Symbol.for("nodejs.util.inspect.custom")]() { return this.inspect(); } }; var Bundle = exports; exports.errors = errors; exports.isBundle = function isBundle(value) { if (value instanceof Bundle) return true; return typeof value === "object" && value !== null && value[kind] === Bundle[kind]; }; exports.from = function from(value) { if (typeof value === "string") return fromString(value); if (Buffer.isBuffer(value)) return fromBuffer(value); return value; }; function fromString(string) { return fromBuffer(Buffer.from(string)); } function fromBuffer(buffer) { if (buffer[0] === 35 && buffer[1] === 33) { let end2 = 2; while (buffer[end2] !== 10) end2++; buffer = buffer.subarray(end2 + 1); } let end = 0; while (isDecimal(buffer[end])) end++; const len = parseInt(buffer.toString("utf8", 0, end), 10); let header; try { header = JSON.parse(buffer.toString("utf8", end, end + len)); } catch (err) { throw errors.INVALID_BUNDLE_HEADER("Invalid bundle header", err); } const bundle = new Bundle(); if (header.id) bundle.id = header.id; if (header.main) bundle.main = header.main; if (header.imports) bundle.imports = header.imports; if (header.resolutions) bundle.resolutions = header.resolutions; if (header.addons) bundle.addons = header.addons; if (header.assets) bundle.assets = header.assets; let offset = end + len; for (const [file, info] of Object.entries(header.files)) { bundle.write(file, buffer.subarray(offset, offset + info.length), { mode: info.mode || 420 }); offset += info.length; } return bundle; } function isDecimal(c) { return c >= 48 && c <= 57; } function compareKeys([a], [b]) { return a > b ? 1 : a < b ? -1 : 0; } function cloneImportsMap(value) { if (typeof value === "object" && value !== null) { const imports = {}; for (const entry of Object.entries(value).sort(compareKeys)) { imports[entry[0]] = cloneImportsMapEntry(entry[1]); } return imports; } throw new TypeError(`Imports map must be an object. Received type ${typeof value} (${value})`); } function cloneImportsMapEntry(value) { if (typeof value === "string") return value; if (typeof value === "object" && value !== null) { const imports = {}; for (const entry of Object.entries(value)) { imports[entry[0]] = cloneImportsMapEntry(entry[1]); } return imports; } throw new TypeError( `Imports map entry must be a string or object. Received type ${typeof value} (${value})` ); } function cloneResolutionsMap(value) { if (typeof value === "object" && value !== null) { const resolutions = {}; for (const entry of Object.entries(value).sort(compareKeys)) { resolutions[entry[0]] = cloneImportsMap(entry[1]); } return resolutions; } throw new TypeError(`Resolutions map must be an object. Received type ${typeof value} (${value})`); } function cloneFilesList(value, name) { if (Array.isArray(value)) { const files = []; for (const entry of value) { if (typeof entry !== "string") { throw new TypeError( `${name} entry must be a string. Received type ${typeof entry} (${entry})` ); } files.push(entry); } return files.sort(); } throw new TypeError(`${name} list must be an array. Received type ${typeof value} (${value})`); } function transformImportsMap(value, root, conditionalRoot, opts, fn) { const { conditions = {} } = opts; const imports = {}; for (const entry of Object.entries(value)) { const condition = entry[0]; imports[condition] = transformImportsMapEntry( entry[1], root, conditionalRoot || conditions[condition], opts, fn ); } return imports; } function transformImportsMapEntry(value, root, conditionalRoot, opts, fn) { const { conditions = {} } = opts; if (typeof value === "string") { return fn(value, conditionalRoot || conditions.default || root); } return transformImportsMap(value, root, conditionalRoot, opts, fn); } function transformResolutionsMap(value, root, opts, fn) { const resolutions = {}; for (const entry of Object.entries(value)) { resolutions[fn(entry[0], root)] = transformImportsMap(entry[1], root, null, opts, fn); } return resolutions; } function transformFilesList(value, root, fn) { const files = []; for (const entry of value) { files.push(fn(entry, root)); } return files; } function mountSpecifier(specifier, root) { if (startsWithWindowsDriveLetter(specifier)) { specifier = "/" + specifier; } if (specifier[0] === "/" || specifier[0] === "\\") { specifier = "." + specifier; } if (specifier.startsWith("./") || specifier.startsWith(".\\")) { return new URL(specifier, root).href; } return specifier; } function unmountSpecifier(specifier, root) { specifier = new URL(specifier); if (typeof root === "string") root = new URL(root); if (specifier.protocol !== root.protocol || specifier.host !== root.host || specifier.port !== root.port) { return specifier.href; } const specifierPath = splitPath(specifier.pathname); const rootPath = splitPath(root.pathname); while (specifierPath.length > 0 && rootPath[0] === specifierPath[0]) { specifierPath.shift(); rootPath.shift(); } rootPath.fill(".."); return "/" + rootPath.concat(specifierPath).join("/"); } function splitPath(path) { const parts = path.split("/"); if (!parts[0]) parts.shift(); if (!parts[parts.length - 1]) parts.pop(); return parts; } function isASCIIUpperAlpha(c) { return c >= 65 && c <= 90; } function isASCIILowerAlpha(c) { return c >= 97 && c <= 122; } function isASCIIAlpha(c) { return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c); } function isWindowsDriveLetter(input) { return input.length >= 2 && isASCIIAlpha(input.charCodeAt(0)) && (input.charCodeAt(1) === 58 || input.charCodeAt(1) === 124); } function startsWithWindowsDriveLetter(input) { return input.length >= 2 && isWindowsDriveLetter(input) && (input.length === 2 || input.charCodeAt(2) === 47 || input.charCodeAt(2) === 92 || input.charCodeAt(2) === 63 || input.charCodeAt(2) === 35); } } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset/android.js var require_android = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset/android.js"(exports, module) { module.exports = { linked: true, target: ["android-arm", "android-arm64", "android-ia32", "android-x64"] }; } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset/darwin.js var require_darwin = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset/darwin.js"(exports, module) { module.exports = { target: ["darwin-arm64", "darwin-x64"] }; } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset/desktop.js var require_desktop = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset/desktop.js"(exports, module) { module.exports = { target: [ "darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64", "win32-arm64", "win32-x64" ] }; } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset/ios.js var require_ios = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset/ios.js"(exports, module) { module.exports = { linked: true, target: ["ios-arm64", "ios-arm64-simulator", "ios-x64-simulator"] }; } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset/linux.js var require_linux = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset/linux.js"(exports, module) { module.exports = { target: ["linux-arm64", "linux-x64"] }; } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset/mobile.js var require_mobile = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset/mobile.js"(exports, module) { module.exports = { linked: true, target: [ "android-arm", "android-arm64", "android-ia32", "android-x64", "ios-arm64", "ios-arm64-simulator", "ios-x64-simulator" ] }; } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset/win32.js var require_win32 = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset/win32.js"(exports, module) { module.exports = { target: ["win32-arm64", "win32-x64"] }; } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/preset.js var require_preset = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/preset.js"(exports) { exports.android = require_android(); exports.darwin = require_darwin(); exports.desktop = require_desktop(); exports.ios = require_ios(); exports.linux = require_linux(); exports.mobile = require_mobile(); exports.win32 = require_win32(); } }); // ../../node_modules/bare-run/node_modules/bare-pack/index.js var require_bare_pack = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/index.js"(exports, module) { var Semaphore = require_promaphore(); var Bundle = require_bare_bundle(); var traverse = require_bare_module_traverse(); var preset = require_preset(); module.exports = async function pack(entry, opts, readModule, listPrefix) { if (typeof opts === "function") { listPrefix = readModule; readModule = opts; opts = {}; } opts = withPreset(opts); const { concurrency = 0 } = opts; const semaphore = concurrency > 0 ? new Semaphore(concurrency) : null; const bundle = new Bundle(); const addons = []; const assets = []; await process2( traverse.module( entry, await readModule(entry), null, { addons, assets }, /* @__PURE__ */ new Set(), opts ) ); bundle.addons = addons.map((url) => url.href); bundle.assets = assets.map((url) => url.href); return bundle; async function process2(generator) { if (semaphore !== null) await semaphore.wait(); const queue = []; let next = generator.next(); while (next.done !== true) { const value = next.value; if (value.module) { next = generator.next(await readModule(value.module)); } else if (value.prefix) { const result = []; if (typeof listPrefix === "function") { for await (const url of listPrefix(value.prefix)) { result.push(url); } } else { if (await readModule(value.prefix) !== null) { result.push(value.prefix); } } next = generator.next(result); } else { if (value.children) { queue.push(value.children); } else { const { url, source, imports } = value.dependency; bundle.write(url.href, source, { main: url.href === entry.href, imports }); } next = generator.next(); } } if (semaphore !== null) semaphore.signal(); await Promise.all(queue.map(process2)); } }; function withPreset(opts = {}) { if (opts.preset) { if (opts.preset in preset === false) { throw new Error(`Unknown preset '${opts.preset}'`); } opts = Object.assign({}, opts, preset[opts.preset]); } return opts; } } }); // ../../node_modules/bare-run/node_modules/bare-pack/lib/fs.js var require_fs = __commonJS({ "../../node_modules/bare-run/node_modules/bare-pack/lib/fs.js"(exports) { var { fileURLToPath } = __require("url"); var fs = __require("fs"); exports.write = async function write(fd, data) { return new Promise((resolve) => { fs.write(fd, data, (err, written) => { resolve(err ? 0 : written); }); }); }; exports.writeFile = async function writeFile(url, data) { return new Promise((resolve) => { fs.writeFile(fileURLToPath(url), data, (err) => { resolve(!err); }); }); }; exports.readFile = async function readFile(url) { return new Promise((resolve) => { fs.readFile(fileURLToPath(url), (err, data) => { resolve(err ? null : data); }); }); }; exports.makeDir = async function makeDir(url) { return new Promise((resolve, reject) => { fs.mkdir(fileURLToPath(url), { recursive: true }, (err) => { err ? reject(err) : resolve(); }); }); }; exports.openDir = async function openDir(url) { return new Promise((resolve, reject) => { fs.opendir(fileURLToPath(url), (err, dir) => { err ? reject(err) : resolve(dir); }); }); }; exports.readModule = async function readModule(url) { return exports.readFile(url); }; async function isFile(url) { return new Promise((resolve) => { fs.stat(fileURLToPath(url), (err, stat) => { resolve(err === null && stat.isFile()); }); }); } async function isDir(url) { return new Promise((resolve) => { fs.stat(fileURLToPath(url), (err, stat) => { resolve(err === null && stat.isDirectory()); }); }); } exports.listPrefix = async function* listPrefix(url) { if (await isFile(url)) return yield url; if (url.pathname[url.pathname.length - 1] !== "/") { url.pathname += "/"; } if (await isDir(url)) { for await (const entry of await exports.openDir(url)) { if (entry.isDirectory()) { yield* listPrefix(new URL(entry.name, url)); } else { yield new URL(entry.name, url); } } } }; } }); // ../../node_modules/bare-run/lib/errors.js var require_errors6 = __commonJS({ "../../node_modules/bare-run/lib/errors.js"(exports, module) { module.exports = class TestError extends Error { constructor(msg, fn = TestError, code = fn.name) { super(`${code}: ${msg}`); this.code = code; if (Error.captureStackTrace) { Error.captureStackTrace(this, fn); } } get name() { return "TestError"; } static UNKNOWN_DEVICE(msg) { return new TestError(msg, TestError.UNKNOWN_DEVICE); } }; } }); // ../../node_modules/require-asset/lib/node.js var require_node5 = __commonJS({ "../../node_modules/require-asset/lib/node.js"(exports, module) { if (typeof __require.asset === "function") { module.exports = __require.asset.bind(__require); } else { let readPackage2 = function(packageURL) { try { return __require(url.fileURLToPath(packageURL)); } catch (err) { return null; } }, isAlpine2 = function() { return process.platform === "linux" && fs.existsSync("/etc/alpine-release"); }; readPackage = readPackage2, isAlpine = isAlpine2; const url = __require("url"); const fs = __require("fs"); const resolve = require_bare_module_resolve(); const conditions = ["asset", "node", process.platform, process.arch]; if (isAlpine2()) conditions.push("musl"); module.exports = function asset(specifier, parentURL) { if (typeof parentURL === "string") parentURL = url.pathToFileURL(parentURL); const candidates = []; for (const resolution of resolve(specifier, parentURL, { conditions }, readPackage2)) { switch (resolution.protocol) { case "file:": try { return __require.resolve(url.fileURLToPath(resolution)); } catch { continue; } } } let message = `Cannot find asset '${specifier}' imported from '${parentURL.href}'`; if (candidates.length > 0) { message += "\nCandidates:"; message += "\n" + candidates.map((url2) => "- " + url2.href).join("\n"); } const err = new Error(message); err.code = "ASSET_NOT_FOUND"; err.specifier = specifier; err.referrer = parentURL; err.candidates = candidates; throw err; }; } var readPackage; var isAlpine; } }); // ../../node_modules/bare-run/lib/prebuilds.js var require_prebuilds = __commonJS({ "../../node_modules/bare-run/lib/prebuilds.js"(exports) { var fs = __require("fs"); __require.asset = require_node5(); exports["ios-arm64-simulator"] = () => { return executable( __require.asset("../prebuilds/ios-arm64-simulator/bare-run", __filename) ); }; exports["ios-x64-simulator"] = () => { return executable( __require.asset("../prebuilds/ios-x64-simulator/bare-run", __filename) ); }; exports["android-arm"] = () => { return executable( __require.asset("../prebuilds/android-arm/bare-run", __filename) ); }; exports["android-arm64"] = () => { return executable( __require.asset("../prebuilds/android-arm64/bare-run", __filename) ); }; exports["android-ia32"] = () => { return executable( __require.asset("../prebuilds/android-ia32/bare-run", __filename) ); }; exports["android-x64"] = () => { return executable( __require.asset("../prebuilds/android-x64/bare-run", __filename) ); }; exports["darwin-x64"] = () => { return executable( __require.asset("../prebuilds/darwin-x64/bare-run", __filename) ); }; exports["darwin-arm64"] = () => { return executable( __require.asset("../prebuilds/darwin-arm64/bare-run", __filename) ); }; exports["linux-x64"] = () => { return executable( __require.asset("../prebuilds/linux-x64/bare-run", __filename) ); }; exports["linux-arm64"] = () => { return executable( __require.asset("../prebuilds/linux-arm64/bare-run", __filename) ); }; exports["win32-x64"] = () => { return executable( __require.asset("../prebuilds/win32-x64/bare-run.exe", __filename) ); }; exports["win32-arm64"] = () => { return executable( __require.asset("../prebuilds/win32-arm64/bare-run.exe", __filename) ); }; function executable(file) { try { fs.accessSync(file, fs.constants.X_OK); } catch { fs.chmodSync(file, 493); } return file; } } }); // ../../node_modules/bare-which/lib/executable.js var require_executable = __commonJS({ "../../node_modules/bare-which/lib/executable.js"(exports, module) { var fs = __require("fs"); var process2 = __require("process"); var { isWindows } = require_which_runtime(); function isExecutableSync(path, options) { try { const stat = fs.statSync(path); const checker = isWindows ? isWin32Executable : isPosixExecutableSync; return stat.isFile() && checker({ path, options }); } catch (err) { if (options.ignoreErrors || ["ENOENT", "EACCES"].includes(err.code)) return false; throw err; } } async function isExecutable(path, options) { try { const stat = await fs.promises.stat(path); const checker = isWindows ? isWin32Executable : isPosixExecutable; return stat.isFile() && await checker({ path, options }); } catch (err) { if (options.ignoreErrors || ["ENOENT", "EACCES"].includes(err.code)) return false; throw err; } } function isWin32Executable({ path, options }) { const { pathExt = process2.env.PATHEXT || "" } = options; const exts = pathExt.split(";"); if (exts.includes("")) return true; return exts.some((ext) => path.toLowerCase().endsWith(ext.toLowerCase())); } async function isPosixExecutable({ path }) { await fs.promises.access(path, fs.constants.X_OK); return true; } function isPosixExecutableSync({ path }) { fs.accessSync(path, fs.constants.X_OK); return true; } isExecutable.sync = isExecutableSync; module.exports = isExecutable; } }); // ../../node_modules/bare-which/index.js var require_bare_which = __commonJS({ "../../node_modules/bare-which/index.js"(exports, module) { var { join, delimiter } = __require("path"); var process2 = __require("process"); var { isWindows } = require_which_runtime(); var isExecutable = require_executable(); var pathMatcher = isWindows ? /[/\\]/ : /\//; var relativePathMatcher = new RegExp(`^\\.${pathMatcher.source}`); var isPath = (path) => pathMatcher.test(path); var isRelative = (path) => relativePathMatcher.test(path); var ErrorNotFound = class extends Error { constructor(command) { super(`Command not found: ${command}`); this.code = "ENOENT"; } }; function getPathInfo(cmd, { path: optPath = process2.env.PATH, pathExt: optPathExt = process2.env.PATHEXT, delimiter: optDelimiter = delimiter }) { const pathEnv = !isPath(cmd) ? [...isWindows ? [process2.cwd()] : [], ...(optPath || "").split(optDelimiter)] : [""]; if (!isWindows) return { pathEnv, pathExt: [""] }; const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter); const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]); if (cmd.includes(".") && pathExt[0] !== "") pathExt.unshift(""); return { pathEnv, pathExt, pathExtExe }; } function joinPathCommand(path, cmd) { const pathPart = /^".*"$/.test(path) ? path.slice(1, -1) : path; const prefix = !pathPart && isRelative(cmd) ? cmd.slice(0, 2) : ""; return prefix + join(pathPart, cmd); } function whichSync(cmd, options = {}) { const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, options); const { all, nothrow } = options; const found = []; for (const pathEnvPart of pathEnv) { const pathCommand = joinPathCommand(pathEnvPart, cmd); for (const ext of pathExt) { const withExt = pathCommand + ext; if (isExecutable.sync( withExt, { pathExt: pathExtExe, ignoreErrors: true } )) { if (!all) return withExt; found.push(withExt); } } } if (all && found.length) return found; if (nothrow) return null; throw new ErrorNotFound(cmd); } async function whichAsync(cmd, options = {}) { const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, options); const { all, nothrow } = options; const foundPromises = []; for (const pathEnvPart of pathEnv) { const pathCommand = joinPathCommand(pathEnvPart, cmd); for (const ext of pathExt) { const withExt = pathCommand + ext; if (all) { foundPromises.push( isExecutable(withExt, { pathExt: pathExtExe, ignoreErrors: true }).then((isExec) => isExec ? withExt : null) ); } else if (await isExecutable( withExt, { pathExt: pathExtExe, ignoreErrors: true } )) return withExt; } } const found = (await Promise.all(foundPromises)).filter((item) => item !== null); if (all && found.length > 0) return found; if (nothrow) return null; throw new ErrorNotFound(cmd); } whichAsync.sync = whichSync; module.exports = whichAsync; } }); // ../../node_modules/bare-run/lib/spawn.js var require_spawn = __commonJS({ "../../node_modules/bare-run/lib/spawn.js"(exports, module) { var process2 = __require("process"); var path = __require("path"); var childProcess = __require("child_process"); module.exports = function spawn(file, args = [], opts = {}) { const { env = process2.env, cwd = path.resolve("."), input, stdio = [input ? null : "ignore", "pipe", "inherit"], shell = requiresShell(file) } = opts; return childProcess.spawnSync(file, args, { encoding: "utf-8", stdio, env, cwd, input, shell }); }; function requiresShell(cmd) { if (process2.platform !== "win32") return false; const ext = path.extname(cmd).toLowerCase(); return ext === ".bat" || ext === ".cmd"; } } }); // ../../node_modules/bare-run/lib/android/sdk.js var require_sdk = __commonJS({ "../../node_modules/bare-run/lib/android/sdk.js"(exports) { var process2 = __require("process"); var path = __require("path"); var os = __require("os"); exports.path = process2.env.ANDROID_HOME || path.join(os.homedir(), ".android/sdk"); } }); // ../../node_modules/bare-run/lib/android/adb.js var require_adb = __commonJS({ "../../node_modules/bare-run/lib/android/adb.js"(exports, module) { var path = __require("path"); var os = __require("os"); var which = require_bare_which(); var spawn = require_spawn(); var sdk = require_sdk(); function adb() { return which.sync("adb", { path: path.join(sdk.path, "platform-tools") }); } module.exports = exports = adb; exports.devices = function devices(opts = {}) { const lines = spawn(adb(), ["devices", "-l"], opts).stdout.toString().split(os.EOL).filter(Boolean).slice(1); const devices2 = []; for (const line of lines) { const [id, kind] = line.split(/[\s,]+/).filter(Boolean); if (kind !== "device") continue; const type = id.startsWith("emulator-") ? "emulator" : "device"; devices2.push({ id, type, name: name(id, { type }), arch: arch(id), state: "booted" }); } return devices2; }; exports.push = function push(device, local, remote, opts = {}) { if (device === "number") device = `emulator-${device}`; spawn(adb(), ["-s", device, "push", local, remote], opts); }; exports.shell = function shell(device, command, args = [], opts = {}) { if (device === "number") device = `emulator-${device}`; spawn(adb(), ["-s", device, "shell", command, ...args], opts); }; function name(device, opts = {}) { const { type = "emulator" } = opts; if (typeof device === "number") device = `emulator-${device}`; let name2; switch (type) { case "device": ; [name2] = spawn( adb(), ["-s", device, "shell", "getprop", "ro.product.model"], opts ).stdout.toString().split(os.EOL); break; case "emulator": ; [name2] = exec(adb(), ["-s", device, "emu", "avd", "name"], opts).stdout.toString().split(os.EOL); break; } return name2.trim(); } function arch(device, opts = {}) { if (typeof device === "number") device = `emulator-${device}`; const [abi] = spawn( adb(), ["-s", device, "shell", "getprop", "ro.product.cpu.abi"], opts ).stdout.toString().split(os.EOL); switch (abi) { case "armeabi-v7a": return "arm"; case "arm64-v8a": return "arm64"; case "x86": return "ia32"; case "x86_64": return "x64"; default: return null; } } } }); // ../../node_modules/bare-run/lib/android.js var require_android2 = __commonJS({ "../../node_modules/bare-run/lib/android.js"(exports) { var path = __require("path"); var fs = __require("fs"); var os = __require("os"); var errors = require_errors6(); var prebuilds = require_prebuilds(); var adb = require_adb(); exports.run = async function run(bundle, opts) { let device = null; for (const candidate of adb.devices()) { if (typeof opts.device === "string") { if (candidate.name.toLowerCase().includes(opts.device.toLowerCase())) { device = candidate; break; } } else if (candidate.state === "booted") { device = candidate; break; } } if (device === null) { throw errors.UNKNOWN_DEVICE("Could not find a device"); } const root = "/data/local/tmp/bare-run"; adb.shell(device.id, "mkdir", ["-p", root]); const tmp = path.join(os.tmpdir(), `${bundle.id}.bundle`); fs.writeFileSync(tmp, bundle.toBuffer()); const filename = path.join(root, `${bundle.id}.bundle`); adb.push(device.id, tmp, filename, { stdio: "ignore" }); adb.push(device.id, prebuilds[`android-${device.arch}`](), root, { stdio: "ignore" }); const driver = path.join(root, "bare-run"); adb.shell(device.id, driver, [filename], { stdio: "inherit" }); adb.shell(device.id, "rm", [filename]); adb.shell(device.id, "rm", [driver]); fs.rmSync(tmp); }; } }); // ../../node_modules/bare-run/lib/ios/xcrun.js var require_xcrun = __commonJS({ "../../node_modules/bare-run/lib/ios/xcrun.js"(exports, module) { var which = require_bare_which(); var spawn = require_spawn(); function xcrun() { return which.sync("xcrun"); } module.exports = exports = xcrun; exports.find = function find(tool, opts = {}) { return spawn(xcrun(), ["--find", tool], opts).stdout.toString().trim(); }; } }); // ../../node_modules/bare-run/lib/ios/simctl.js var require_simctl = __commonJS({ "../../node_modules/bare-run/lib/ios/simctl.js"(exports, module) { var which = require_bare_which(); var spawn = require_spawn(); var xcrun = require_xcrun(); function simctl() { return xcrun.find("simctl"); } module.exports = exports = simctl; exports.list = function list(opts) { const json = JSON.parse( spawn( simctl(), ["list", "--json", "--no-escape-slashes", "devices", "available"], opts ).stdout.toString() ); return Object.values(json.devices).flatMap( (devices) => devices.map((device) => { return { id: device.udid, name: device.name, state: device.state.toLowerCase(), data: device.dataPath }; }) ); }; exports.spawn = function launch(device, command, args, opts) { spawn(simctl(), ["spawn", device, command, ...args], opts); }; exports.launch = function launch(device, opts = {}) { const { open = false } = opts; spawn(simctl(), ["boot", device], opts); if (open) { spawn(which.sync("open"), ["-a", "Simulator.app"], opts); } }; } }); // ../../node_modules/bare-run/lib/ios.js var require_ios2 = __commonJS({ "../../node_modules/bare-run/lib/ios.js"(exports) { var process2 = __require("process"); var path = __require("path"); var fs = __require("fs"); var errors = require_errors6(); var prebuilds = require_prebuilds(); var simctl = require_simctl(); exports.run = async function run(bundle, opts) { const { arch = process2.arch } = opts; let device = null; for (const candidate of simctl.list()) { if (typeof opts.device === "string") { if (candidate.name.toLowerCase().includes(opts.device.toLowerCase())) { device = candidate; break; } } else if (candidate.state === "booted") { device = candidate; break; } } if (device === null) { throw errors.UNKNOWN_DEVICE("Could not find a device"); } const root = path.join(device.data, "tmp", "bare-run"); fs.mkdirSync(root, { recursive: true }); const filename = path.join(root, `${bundle.id}.bundle`); fs.writeFileSync(filename, bundle.toBuffer()); simctl.spawn(device.id, prebuilds[`ios-${arch}-simulator`](), [filename], { stdio: "inherit" }); fs.rmSync(filename); }; } }); // ../../node_modules/bare-run/lib/desktop.js var require_desktop2 = __commonJS({ "../../node_modules/bare-run/lib/desktop.js"(exports) { var process2 = __require("process"); var path = __require("path"); var fs = __require("fs"); var os = __require("os"); var prebuilds = require_prebuilds(); var spawn = require_spawn(); exports.run = async function run(bundle, opts) { const { arch = process2.arch, platform = process2.platform } = opts; const root = path.join(os.tmpdir(), "bare-run"); fs.mkdirSync(root, { recursive: true }); const filename = path.join(root, `${bundle.id}.bundle`); fs.writeFileSync(filename, bundle.toBuffer()); spawn(prebuilds[`${platform}-${arch}`](), [filename], { stdio: "inherit" }); fs.rmSync(filename); }; } }); // ../../node_modules/bare-run/index.js var require_bare_run = __commonJS({ "../../node_modules/bare-run/index.js"(exports, module) { var process2 = __require("process"); var { pathToFileURL } = __require("url"); var { resolve } = require_bare_module_traverse(); var id = require_bare_bundle_id(); var pack = require_bare_pack(); var fs = require_fs(); var android = require_android2(); var ios = require_ios2(); var desktop = require_desktop2(); module.exports = async function run(entry, opts = {}) { const { base = ".", platform = process2.platform, arch = process2.arch } = opts; let bundle = await pack( pathToFileURL(entry), { platform, arch, simulator: platform === "ios", resolve: resolve.bare }, fs.readModule, fs.listPrefix ); bundle = bundle.unmount(pathToFileURL(base)); bundle.id = id(bundle).toString("hex"); switch (platform) { case "android": return android.run(bundle, opts); case "ios": return ios.run(bundle, opts); default: return desktop.run(bundle, opts); } }; } }); // ../../bare-lib-entry-bareRun.js var bare_lib_entry_bareRun_exports = {}; __export(bare_lib_entry_bareRun_exports, { default: () => bare_lib_entry_bareRun_default }); var import_bare_run = __toESM(require_bare_run()); var bare_lib_entry_bareRun_default = import_bare_run.default; return __toCommonJS(bare_lib_entry_bareRun_exports); })(); ;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["bareRun"]=v;})();