@agenttech/tpay-cli 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +9 -1
  3. package/dist/index.js +34 -2945
  4. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -33978,8 +33978,8 @@ var require_v35 = __commonJS((exports) => {
33978
33978
  }
33979
33979
  var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
33980
33980
  exports.DNS = DNS;
33981
- var URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
33982
- exports.URL = URL2;
33981
+ var URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
33982
+ exports.URL = URL;
33983
33983
  function _default(name, version, hashfunc) {
33984
33984
  function generateUUID(value, namespace, buf, offset) {
33985
33985
  if (typeof value === "string") {
@@ -34010,7 +34010,7 @@ var require_v35 = __commonJS((exports) => {
34010
34010
  generateUUID.name = name;
34011
34011
  } catch (err) {}
34012
34012
  generateUUID.DNS = DNS;
34013
- generateUUID.URL = URL2;
34013
+ generateUUID.URL = URL;
34014
34014
  return generateUUID;
34015
34015
  }
34016
34016
  });
@@ -35930,8 +35930,8 @@ var require_URL = __commonJS((exports, module) => {
35930
35930
  var utils = require_utils3();
35931
35931
  var Impl = require_URL_impl();
35932
35932
  var impl = utils.implSymbol;
35933
- function URL2(url) {
35934
- if (!this || this[impl] || !(this instanceof URL2)) {
35933
+ function URL(url) {
35934
+ if (!this || this[impl] || !(this instanceof URL)) {
35935
35935
  throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
35936
35936
  }
35937
35937
  if (arguments.length < 1) {
@@ -35947,7 +35947,7 @@ var require_URL = __commonJS((exports, module) => {
35947
35947
  }
35948
35948
  module.exports.setup(this, args);
35949
35949
  }
35950
- URL2.prototype.toJSON = function toJSON() {
35950
+ URL.prototype.toJSON = function toJSON() {
35951
35951
  if (!this || !module.exports.is(this)) {
35952
35952
  throw new TypeError("Illegal invocation");
35953
35953
  }
@@ -35957,7 +35957,7 @@ var require_URL = __commonJS((exports, module) => {
35957
35957
  }
35958
35958
  return this[impl].toJSON.apply(this[impl], args);
35959
35959
  };
35960
- Object.defineProperty(URL2.prototype, "href", {
35960
+ Object.defineProperty(URL.prototype, "href", {
35961
35961
  get() {
35962
35962
  return this[impl].href;
35963
35963
  },
@@ -35968,20 +35968,20 @@ var require_URL = __commonJS((exports, module) => {
35968
35968
  enumerable: true,
35969
35969
  configurable: true
35970
35970
  });
35971
- URL2.prototype.toString = function() {
35971
+ URL.prototype.toString = function() {
35972
35972
  if (!this || !module.exports.is(this)) {
35973
35973
  throw new TypeError("Illegal invocation");
35974
35974
  }
35975
35975
  return this.href;
35976
35976
  };
35977
- Object.defineProperty(URL2.prototype, "origin", {
35977
+ Object.defineProperty(URL.prototype, "origin", {
35978
35978
  get() {
35979
35979
  return this[impl].origin;
35980
35980
  },
35981
35981
  enumerable: true,
35982
35982
  configurable: true
35983
35983
  });
35984
- Object.defineProperty(URL2.prototype, "protocol", {
35984
+ Object.defineProperty(URL.prototype, "protocol", {
35985
35985
  get() {
35986
35986
  return this[impl].protocol;
35987
35987
  },
@@ -35992,7 +35992,7 @@ var require_URL = __commonJS((exports, module) => {
35992
35992
  enumerable: true,
35993
35993
  configurable: true
35994
35994
  });
35995
- Object.defineProperty(URL2.prototype, "username", {
35995
+ Object.defineProperty(URL.prototype, "username", {
35996
35996
  get() {
35997
35997
  return this[impl].username;
35998
35998
  },
@@ -36003,7 +36003,7 @@ var require_URL = __commonJS((exports, module) => {
36003
36003
  enumerable: true,
36004
36004
  configurable: true
36005
36005
  });
36006
- Object.defineProperty(URL2.prototype, "password", {
36006
+ Object.defineProperty(URL.prototype, "password", {
36007
36007
  get() {
36008
36008
  return this[impl].password;
36009
36009
  },
@@ -36014,7 +36014,7 @@ var require_URL = __commonJS((exports, module) => {
36014
36014
  enumerable: true,
36015
36015
  configurable: true
36016
36016
  });
36017
- Object.defineProperty(URL2.prototype, "host", {
36017
+ Object.defineProperty(URL.prototype, "host", {
36018
36018
  get() {
36019
36019
  return this[impl].host;
36020
36020
  },
@@ -36025,7 +36025,7 @@ var require_URL = __commonJS((exports, module) => {
36025
36025
  enumerable: true,
36026
36026
  configurable: true
36027
36027
  });
36028
- Object.defineProperty(URL2.prototype, "hostname", {
36028
+ Object.defineProperty(URL.prototype, "hostname", {
36029
36029
  get() {
36030
36030
  return this[impl].hostname;
36031
36031
  },
@@ -36036,7 +36036,7 @@ var require_URL = __commonJS((exports, module) => {
36036
36036
  enumerable: true,
36037
36037
  configurable: true
36038
36038
  });
36039
- Object.defineProperty(URL2.prototype, "port", {
36039
+ Object.defineProperty(URL.prototype, "port", {
36040
36040
  get() {
36041
36041
  return this[impl].port;
36042
36042
  },
@@ -36047,7 +36047,7 @@ var require_URL = __commonJS((exports, module) => {
36047
36047
  enumerable: true,
36048
36048
  configurable: true
36049
36049
  });
36050
- Object.defineProperty(URL2.prototype, "pathname", {
36050
+ Object.defineProperty(URL.prototype, "pathname", {
36051
36051
  get() {
36052
36052
  return this[impl].pathname;
36053
36053
  },
@@ -36058,7 +36058,7 @@ var require_URL = __commonJS((exports, module) => {
36058
36058
  enumerable: true,
36059
36059
  configurable: true
36060
36060
  });
36061
- Object.defineProperty(URL2.prototype, "search", {
36061
+ Object.defineProperty(URL.prototype, "search", {
36062
36062
  get() {
36063
36063
  return this[impl].search;
36064
36064
  },
@@ -36069,7 +36069,7 @@ var require_URL = __commonJS((exports, module) => {
36069
36069
  enumerable: true,
36070
36070
  configurable: true
36071
36071
  });
36072
- Object.defineProperty(URL2.prototype, "hash", {
36072
+ Object.defineProperty(URL.prototype, "hash", {
36073
36073
  get() {
36074
36074
  return this[impl].hash;
36075
36075
  },
@@ -36085,7 +36085,7 @@ var require_URL = __commonJS((exports, module) => {
36085
36085
  return !!obj && obj[impl] instanceof Impl.implementation;
36086
36086
  },
36087
36087
  create(constructorArgs, privateData) {
36088
- let obj = Object.create(URL2.prototype);
36088
+ let obj = Object.create(URL.prototype);
36089
36089
  this.setup(obj, constructorArgs, privateData);
36090
36090
  return obj;
36091
36091
  },
@@ -36096,10 +36096,10 @@ var require_URL = __commonJS((exports, module) => {
36096
36096
  obj[impl] = new Impl.implementation(constructorArgs, privateData);
36097
36097
  obj[impl][utils.wrapperSymbol] = obj;
36098
36098
  },
36099
- interface: URL2,
36099
+ interface: URL,
36100
36100
  expose: {
36101
- Window: { URL: URL2 },
36102
- Worker: { URL: URL2 }
36101
+ Window: { URL },
36102
+ Worker: { URL }
36103
36103
  }
36104
36104
  };
36105
36105
  });
@@ -36834,12 +36834,12 @@ var require_lib3 = __commonJS((exports, module) => {
36834
36834
  configurable: true
36835
36835
  });
36836
36836
  var INTERNALS$2 = Symbol("Request internals");
36837
- var URL2 = Url.URL || whatwgUrl.URL;
36837
+ var URL = Url.URL || whatwgUrl.URL;
36838
36838
  var parse_url = Url.parse;
36839
36839
  var format_url = Url.format;
36840
36840
  function parseURL(urlStr) {
36841
36841
  if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
36842
- urlStr = new URL2(urlStr).toString();
36842
+ urlStr = new URL(urlStr).toString();
36843
36843
  }
36844
36844
  return parse_url(urlStr);
36845
36845
  }
@@ -39090,7 +39090,7 @@ var require_websocket = __commonJS((exports, module) => {
39090
39090
  var tls = __require("tls");
39091
39091
  var { randomBytes: randomBytes2, createHash } = __require("crypto");
39092
39092
  var { Duplex, Readable } = __require("stream");
39093
- var { URL: URL2 } = __require("url");
39093
+ var { URL } = __require("url");
39094
39094
  var PerMessageDeflate = require_permessage_deflate();
39095
39095
  var Receiver = require_receiver();
39096
39096
  var Sender = require_sender();
@@ -39457,11 +39457,11 @@ var require_websocket = __commonJS((exports, module) => {
39457
39457
  throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} ` + `(supported versions: ${protocolVersions.join(", ")})`);
39458
39458
  }
39459
39459
  let parsedUrl;
39460
- if (address instanceof URL2) {
39460
+ if (address instanceof URL) {
39461
39461
  parsedUrl = address;
39462
39462
  } else {
39463
39463
  try {
39464
- parsedUrl = new URL2(address);
39464
+ parsedUrl = new URL(address);
39465
39465
  } catch (e) {
39466
39466
  throw new SyntaxError(`Invalid URL: ${address}`);
39467
39467
  }
@@ -39594,7 +39594,7 @@ var require_websocket = __commonJS((exports, module) => {
39594
39594
  req.abort();
39595
39595
  let addr;
39596
39596
  try {
39597
- addr = new URL2(location, address);
39597
+ addr = new URL(location, address);
39598
39598
  } catch (e) {
39599
39599
  const err = new SyntaxError(`Invalid URL: ${location}`);
39600
39600
  emitErrorAndClose(websocket, err);
@@ -58720,2917 +58720,6 @@ var init_slip10 = __esm(() => {
58720
58720
  slip10_default = HDKey;
58721
58721
  });
58722
58722
 
58723
- // node_modules/bare-semver/lib/constants.js
58724
- var require_constants2 = __commonJS((exports, module) => {
58725
- module.exports = {
58726
- EQ: 1,
58727
- LT: 2,
58728
- LTE: 3,
58729
- GT: 4,
58730
- GTE: 5
58731
- };
58732
- });
58733
-
58734
- // node_modules/bare-semver/lib/errors.js
58735
- var require_errors = __commonJS((exports, module) => {
58736
- module.exports = class SemVerError extends Error {
58737
- constructor(msg, code, fn = SemVerError) {
58738
- super(`${code}: ${msg}`);
58739
- this.code = code;
58740
- if (Error.captureStackTrace) {
58741
- Error.captureStackTrace(this, fn);
58742
- }
58743
- }
58744
- get name() {
58745
- return "SemVerError";
58746
- }
58747
- static INVALID_VERSION(msg, fn = SemVerError.INVALID_VERSION) {
58748
- return new SemVerError(msg, "INVALID_VERSION", fn);
58749
- }
58750
- static INVALID_RANGE(msg, fn = SemVerError.INVALID_RANGE) {
58751
- return new SemVerError(msg, "INVALID_RANGE", fn);
58752
- }
58753
- };
58754
- });
58755
-
58756
- // node_modules/bare-semver/lib/version.js
58757
- var require_version3 = __commonJS((exports, module) => {
58758
- var errors = require_errors();
58759
-
58760
- class Version {
58761
- constructor(major, minor, patch, opts = {}) {
58762
- const { prerelease = [], build = [] } = opts;
58763
- this.major = major;
58764
- this.minor = minor;
58765
- this.patch = patch;
58766
- this.prerelease = prerelease;
58767
- this.build = build;
58768
- }
58769
- compare(version) {
58770
- return exports.compare(this, version);
58771
- }
58772
- toString() {
58773
- let result = `${this.major}.${this.minor}.${this.patch}`;
58774
- if (this.prerelease.length) {
58775
- result += "-" + this.prerelease.join(".");
58776
- }
58777
- if (this.build.length) {
58778
- result += "+" + this.build.join(".");
58779
- }
58780
- return result;
58781
- }
58782
- }
58783
- module.exports = exports = Version;
58784
- exports.parse = function parse(input, state = { position: 0, partial: false, range: false }) {
58785
- let i = state.position;
58786
- let c;
58787
- const unexpected = (expected) => {
58788
- let msg;
58789
- if (i >= input.length) {
58790
- msg = `Unexpected end of input in '${input}'`;
58791
- } else {
58792
- msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`;
58793
- }
58794
- if (expected)
58795
- msg += `, ${expected}`;
58796
- throw errors.INVALID_VERSION(msg, unexpected);
58797
- };
58798
- const components = [0, 0, 0];
58799
- let k = 0;
58800
- while (k < 3) {
58801
- c = input[i];
58802
- if (k > 0) {
58803
- if (c === ".")
58804
- c = input[++i];
58805
- else if (state.range)
58806
- break;
58807
- else
58808
- unexpected("expected '.'");
58809
- }
58810
- if (c === "0") {
58811
- i++;
58812
- k++;
58813
- } else if (c >= "1" && c <= "9") {
58814
- let j = 0;
58815
- do
58816
- c = input[i + ++j];
58817
- while (c >= "0" && c <= "9");
58818
- components[k++] = parseInt(input.substring(i, i + j));
58819
- i += j;
58820
- } else
58821
- unexpected("expected /[0-9]/");
58822
- }
58823
- const prerelease = [];
58824
- if (k === 3 && input[i] === "-") {
58825
- i++;
58826
- while (true) {
58827
- c = input[i];
58828
- let tag = "";
58829
- let j = 0;
58830
- while (c >= "0" && c <= "9")
58831
- c = input[i + ++j];
58832
- let isNumeric = false;
58833
- if (j) {
58834
- tag += input.substring(i, i + j);
58835
- c = input[i += j];
58836
- isNumeric = tag[0] !== "0" || tag.length === 1;
58837
- }
58838
- j = 0;
58839
- while (c >= "0" && c <= "9" || c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "-")
58840
- c = input[i + ++j];
58841
- if (j) {
58842
- tag += input.substring(i, i + j);
58843
- c = input[i += j];
58844
- } else if (!isNumeric)
58845
- unexpected("expected /[a-zA-Z-]/");
58846
- prerelease.push(tag);
58847
- if (c === ".")
58848
- c = input[++i];
58849
- else
58850
- break;
58851
- }
58852
- }
58853
- const build = [];
58854
- if (k === 3 && input[i] === "+") {
58855
- i++;
58856
- while (true) {
58857
- c = input[i];
58858
- let tag = "";
58859
- let j = 0;
58860
- while (c >= "0" && c <= "9" || c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "-")
58861
- c = input[i + ++j];
58862
- if (j) {
58863
- tag += input.substring(i, i + j);
58864
- c = input[i += j];
58865
- } else
58866
- unexpected("expected /[0-9a-zA-Z-]/");
58867
- build.push(tag);
58868
- if (c === ".")
58869
- c = input[++i];
58870
- else
58871
- break;
58872
- }
58873
- }
58874
- if (i < input.length && state.partial === false) {
58875
- unexpected("expected end of input");
58876
- }
58877
- state.position = i;
58878
- return new Version(...components, { prerelease, build });
58879
- };
58880
- var integer = /^[0-9]+$/;
58881
- exports.compare = function compare(a, b) {
58882
- if (a.major > b.major)
58883
- return 1;
58884
- if (a.major < b.major)
58885
- return -1;
58886
- if (a.minor > b.minor)
58887
- return 1;
58888
- if (a.minor < b.minor)
58889
- return -1;
58890
- if (a.patch > b.patch)
58891
- return 1;
58892
- if (a.patch < b.patch)
58893
- return -1;
58894
- if (a.prerelease.length === 0)
58895
- return b.prerelease.length === 0 ? 0 : 1;
58896
- if (b.prerelease.length === 0)
58897
- return -1;
58898
- let i = 0;
58899
- do {
58900
- let x = a.prerelease[i];
58901
- let y = b.prerelease[i];
58902
- if (x === undefined)
58903
- return y === undefined ? 0 : -1;
58904
- if (y === undefined)
58905
- return 1;
58906
- if (x === y)
58907
- continue;
58908
- const xInt = integer.test(x);
58909
- const yInt = integer.test(y);
58910
- if (xInt && yInt) {
58911
- x = +x;
58912
- y = +y;
58913
- } else {
58914
- if (xInt)
58915
- return -1;
58916
- if (yInt)
58917
- return 1;
58918
- }
58919
- return x > y ? 1 : -1;
58920
- } while (++i);
58921
- };
58922
- });
58923
-
58924
- // node_modules/bare-semver/lib/comparator.js
58925
- var require_comparator = __commonJS((exports, module) => {
58926
- var constants2 = require_constants2();
58927
- var symbols = {
58928
- [constants2.EQ]: "=",
58929
- [constants2.LT]: "<",
58930
- [constants2.LTE]: "<=",
58931
- [constants2.GT]: ">",
58932
- [constants2.GTE]: ">="
58933
- };
58934
- module.exports = class Comparator {
58935
- constructor(operator, version) {
58936
- this.operator = operator;
58937
- this.version = version;
58938
- }
58939
- test(version) {
58940
- const result = version.compare(this.version);
58941
- switch (this.operator) {
58942
- case constants2.LT:
58943
- return result < 0;
58944
- case constants2.LTE:
58945
- return result <= 0;
58946
- case constants2.GT:
58947
- return result > 0;
58948
- case constants2.GTE:
58949
- return result >= 0;
58950
- default:
58951
- return result === 0;
58952
- }
58953
- }
58954
- toString() {
58955
- return symbols[this.operator] + this.version;
58956
- }
58957
- };
58958
- });
58959
-
58960
- // node_modules/bare-semver/lib/range.js
58961
- var require_range = __commonJS((exports, module) => {
58962
- var constants2 = require_constants2();
58963
- var errors = require_errors();
58964
- var Version = require_version3();
58965
- var Comparator = require_comparator();
58966
-
58967
- class Range {
58968
- constructor(comparators = []) {
58969
- this.comparators = comparators;
58970
- }
58971
- test(version) {
58972
- for (const set of this.comparators) {
58973
- let matches = true;
58974
- for (const comparator of set) {
58975
- if (comparator.test(version))
58976
- continue;
58977
- matches = false;
58978
- break;
58979
- }
58980
- if (matches)
58981
- return true;
58982
- }
58983
- return false;
58984
- }
58985
- toString() {
58986
- let result = "";
58987
- let first = true;
58988
- for (const set of this.comparators) {
58989
- if (first)
58990
- first = false;
58991
- else
58992
- result += " || ";
58993
- result += set.join(" ");
58994
- }
58995
- return result;
58996
- }
58997
- }
58998
- module.exports = exports = Range;
58999
- exports.parse = function parse(input, state = { position: 0, partial: false }) {
59000
- let i = state.position;
59001
- let c;
59002
- const unexpected = (expected) => {
59003
- let msg;
59004
- if (i >= input.length) {
59005
- msg = `Unexpected end of input in '${input}'`;
59006
- } else {
59007
- msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`;
59008
- }
59009
- if (expected)
59010
- msg += `, ${expected}`;
59011
- throw errors.INVALID_VERSION(msg, unexpected);
59012
- };
59013
- const comparators = [];
59014
- while (i < input.length) {
59015
- const set = [];
59016
- while (i < input.length) {
59017
- c = input[i];
59018
- let operator = constants2.EQ;
59019
- if (c === "<") {
59020
- operator = constants2.LT;
59021
- c = input[++i];
59022
- if (c === "=") {
59023
- operator = constants2.LTE;
59024
- c = input[++i];
59025
- }
59026
- } else if (c === ">") {
59027
- operator = constants2.GT;
59028
- c = input[++i];
59029
- if (c === "=") {
59030
- operator = constants2.GTE;
59031
- c = input[++i];
59032
- }
59033
- } else if (c === "=") {
59034
- c = input[++i];
59035
- }
59036
- const state2 = { position: i, partial: true, range: true };
59037
- set.push(new Comparator(operator, Version.parse(input, state2)));
59038
- c = input[i = state2.position];
59039
- while (c === " ")
59040
- c = input[++i];
59041
- if (c === "|" && input[i + 1] === "|") {
59042
- c = input[i += 2];
59043
- while (c === " ")
59044
- c = input[++i];
59045
- break;
59046
- }
59047
- if (c && c !== "<" && c !== ">")
59048
- unexpected("expected '||', '<', or '>'");
59049
- }
59050
- if (set.length)
59051
- comparators.push(set);
59052
- }
59053
- if (i < input.length && state.partial === false) {
59054
- unexpected("expected end of input");
59055
- }
59056
- state.position = i;
59057
- return new Range(comparators);
59058
- };
59059
- });
59060
-
59061
- // node_modules/bare-semver/index.js
59062
- var require_bare_semver = __commonJS((exports) => {
59063
- exports.constants = require_constants2();
59064
- exports.errors = require_errors();
59065
- var Version = exports.Version = require_version3();
59066
- var Range = exports.Range = require_range();
59067
- exports.Comparator = require_comparator();
59068
- exports.satisfies = function satisfies(version, range) {
59069
- if (typeof version === "string")
59070
- version = Version.parse(version);
59071
- if (typeof range === "string")
59072
- range = Range.parse(range);
59073
- return range.test(version);
59074
- };
59075
- });
59076
-
59077
- // node_modules/bare-module-resolve/lib/errors.js
59078
- var require_errors2 = __commonJS((exports, module) => {
59079
- module.exports = class ModuleResolveError extends Error {
59080
- constructor(msg, code, fn = ModuleResolveError) {
59081
- super(`${code}: ${msg}`);
59082
- this.code = code;
59083
- if (Error.captureStackTrace) {
59084
- Error.captureStackTrace(this, fn);
59085
- }
59086
- }
59087
- get name() {
59088
- return "ModuleResolveError";
59089
- }
59090
- static INVALID_MODULE_SPECIFIER(msg) {
59091
- return new ModuleResolveError(msg, "INVALID_MODULE_SPECIFIER", ModuleResolveError.INVALID_MODULE_SPECIFIER);
59092
- }
59093
- static INVALID_PACKAGE_TARGET(msg) {
59094
- return new ModuleResolveError(msg, "INVALID_PACKAGE_TARGET", ModuleResolveError.INVALID_PACKAGE_TARGET);
59095
- }
59096
- static PACKAGE_PATH_NOT_EXPORTED(msg) {
59097
- return new ModuleResolveError(msg, "PACKAGE_PATH_NOT_EXPORTED", ModuleResolveError.PACKAGE_PATH_NOT_EXPORTED);
59098
- }
59099
- static PACKAGE_IMPORT_NOT_DEFINED(msg) {
59100
- return new ModuleResolveError(msg, "PACKAGE_IMPORT_NOT_DEFINED", ModuleResolveError.PACKAGE_IMPORT_NOT_DEFINED);
59101
- }
59102
- static UNSUPPORTED_ENGINE(msg) {
59103
- return new ModuleResolveError(msg, "UNSUPPORTED_ENGINE", ModuleResolveError.UNSUPPORTED_ENGINE);
59104
- }
59105
- };
59106
- });
59107
-
59108
- // node_modules/bare-module-resolve/index.js
59109
- var require_bare_module_resolve = __commonJS((exports, module) => {
59110
- var { satisfies } = require_bare_semver();
59111
- var errors = require_errors2();
59112
- module.exports = exports = function resolve(specifier, parentURL, opts, readPackage) {
59113
- if (typeof opts === "function") {
59114
- readPackage = opts;
59115
- opts = {};
59116
- } else if (typeof readPackage !== "function") {
59117
- readPackage = defaultReadPackage;
59118
- }
59119
- return {
59120
- *[Symbol.iterator]() {
59121
- const generator = exports.module(specifier, parentURL, opts);
59122
- let next = generator.next();
59123
- while (next.done !== true) {
59124
- const value = next.value;
59125
- if (value.package) {
59126
- next = generator.next(readPackage(value.package));
59127
- } else {
59128
- next = generator.next(yield value.resolution);
59129
- }
59130
- }
59131
- return next.value;
59132
- },
59133
- async* [Symbol.asyncIterator]() {
59134
- const generator = exports.module(specifier, parentURL, opts);
59135
- let next = generator.next();
59136
- while (next.done !== true) {
59137
- const value = next.value;
59138
- if (value.package) {
59139
- next = generator.next(await readPackage(value.package));
59140
- } else {
59141
- next = generator.next(yield value.resolution);
59142
- }
59143
- }
59144
- return next.value;
59145
- }
59146
- };
59147
- };
59148
- function defaultReadPackage() {
59149
- return null;
59150
- }
59151
- var UNRESOLVED = 0;
59152
- var YIELDED = 1;
59153
- var RESOLVED = YIELDED | 2;
59154
- exports.constants = {
59155
- UNRESOLVED,
59156
- YIELDED,
59157
- RESOLVED
59158
- };
59159
- exports.module = function* (specifier, parentURL, opts = {}) {
59160
- const { resolutions = null, imports = null } = opts;
59161
- if (exports.startsWithWindowsDriveLetter(specifier)) {
59162
- specifier = "/" + specifier;
59163
- }
59164
- let status;
59165
- if (resolutions) {
59166
- status = yield* exports.preresolved(specifier, resolutions, parentURL, opts);
59167
- if (status)
59168
- return status;
59169
- }
59170
- status = yield* exports.url(specifier, parentURL, opts);
59171
- if (status)
59172
- return status;
59173
- status = yield* exports.packageImports(specifier, parentURL, opts);
59174
- if (status)
59175
- return status;
59176
- if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier[0] === "\\" || specifier.startsWith("./") || specifier.startsWith(".\\") || specifier.startsWith("../") || specifier.startsWith("..\\")) {
59177
- if (imports) {
59178
- status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts);
59179
- if (status)
59180
- return status;
59181
- }
59182
- status = yield* exports.deferred(specifier, opts);
59183
- if (status)
59184
- return status;
59185
- status = yield* exports.file(specifier, parentURL, false, opts);
59186
- if (status === RESOLVED)
59187
- return status;
59188
- return yield* exports.directory(specifier, parentURL, opts);
59189
- }
59190
- return yield* exports.package(specifier, parentURL, opts);
59191
- };
59192
- exports.url = function* (url, parentURL, opts = {}) {
59193
- const { imports = null, deferredProtocol = "deferred:", resolutions = null } = opts;
59194
- let resolution;
59195
- try {
59196
- resolution = new URL(url);
59197
- } catch {
59198
- return UNRESOLVED;
59199
- }
59200
- if (imports) {
59201
- const status = yield* exports.packageImportsExports(resolution.href, imports, parentURL, true, opts);
59202
- if (status)
59203
- return status;
59204
- }
59205
- if (resolution.protocol === deferredProtocol) {
59206
- const specifier = resolution.pathname;
59207
- if (resolutions) {
59208
- const imports2 = resolutions[parentURL.href];
59209
- if (typeof imports2 === "object" && imports2 !== null) {
59210
- opts = {
59211
- ...opts,
59212
- resolutions: { ...resolutions, [parentURL.href]: { ...imports2, [specifier]: null } }
59213
- };
59214
- }
59215
- }
59216
- return yield* exports.module(specifier, parentURL, opts);
59217
- }
59218
- if (resolution.protocol === "node:") {
59219
- const specifier = resolution.pathname;
59220
- if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier.startsWith("./") || specifier.startsWith("../")) {
59221
- throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${url}' is not a valid package name`);
59222
- }
59223
- return yield* exports.package(specifier, parentURL, opts);
59224
- }
59225
- const resolved = yield { resolution };
59226
- return resolved ? RESOLVED : YIELDED;
59227
- };
59228
- exports.preresolved = function* (specifier, resolutions, parentURL, opts = {}) {
59229
- const imports = resolutions[parentURL.href];
59230
- if (typeof imports === "object" && imports !== null) {
59231
- return yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts);
59232
- }
59233
- return UNRESOLVED;
59234
- };
59235
- exports.deferred = function* (specifier, opts = {}) {
59236
- const { deferredProtocol = "deferred:", defer = [] } = opts;
59237
- if (defer.includes(specifier)) {
59238
- const resolved = yield { resolution: new URL(deferredProtocol + specifier) };
59239
- return resolved ? RESOLVED : YIELDED;
59240
- }
59241
- return UNRESOLVED;
59242
- };
59243
- exports.package = function* (packageSpecifier, parentURL, opts = {}) {
59244
- const { builtins = [] } = opts;
59245
- if (packageSpecifier === "") {
59246
- throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${packageSpecifier}' is not a valid package name`);
59247
- }
59248
- let packageName;
59249
- if (packageSpecifier[0] !== "@") {
59250
- packageName = packageSpecifier.split("/", 1).join();
59251
- } else {
59252
- if (!packageSpecifier.includes("/")) {
59253
- throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${packageSpecifier}' is not a valid package name`);
59254
- }
59255
- packageName = packageSpecifier.split("/", 2).join("/");
59256
- }
59257
- if (packageName[0] === "." || packageName.includes("\\") || packageName.includes("%")) {
59258
- throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${packageSpecifier}' is not a valid package name`);
59259
- }
59260
- let status;
59261
- status = yield* exports.builtinTarget(packageSpecifier, null, builtins, opts);
59262
- if (status)
59263
- return status;
59264
- status = yield* exports.deferred(packageSpecifier, opts);
59265
- if (status)
59266
- return status;
59267
- let packageSubpath = "." + packageSpecifier.substring(packageName.length);
59268
- status = yield* exports.packageSelf(packageName, packageSubpath, parentURL, opts);
59269
- if (status)
59270
- return status;
59271
- parentURL = new URL(parentURL.href);
59272
- for (const packageURL of exports.lookupPackageRoot(packageName, parentURL)) {
59273
- const info = yield { package: packageURL };
59274
- if (info) {
59275
- if (info.engines)
59276
- exports.validateEngines(packageURL, info.engines, opts);
59277
- if (info.exports) {
59278
- return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts);
59279
- }
59280
- if (packageSubpath === ".") {
59281
- if (typeof info.main === "string" && info.main !== "") {
59282
- packageSubpath = info.main;
59283
- } else {
59284
- return yield* exports.file("index", packageURL, true, opts);
59285
- }
59286
- }
59287
- status = yield* exports.file(packageSubpath, packageURL, false, opts);
59288
- if (status === RESOLVED)
59289
- return status;
59290
- return yield* exports.directory(packageSubpath, packageURL, opts);
59291
- }
59292
- }
59293
- return UNRESOLVED;
59294
- };
59295
- exports.packageSelf = function* (packageName, packageSubpath, parentURL, opts = {}) {
59296
- for (const packageURL of exports.lookupPackageScope(parentURL, opts)) {
59297
- const info = yield { package: packageURL };
59298
- if (info) {
59299
- if (info.name !== packageName)
59300
- return false;
59301
- if (info.exports) {
59302
- return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts);
59303
- }
59304
- if (packageSubpath === ".") {
59305
- if (typeof info.main === "string" && info.main !== "") {
59306
- packageSubpath = info.main;
59307
- } else {
59308
- return yield* exports.file("index", packageURL, true, opts);
59309
- }
59310
- }
59311
- const status = yield* exports.file(packageSubpath, packageURL, false, opts);
59312
- if (status === RESOLVED)
59313
- return status;
59314
- return yield* exports.directory(packageSubpath, packageURL, opts);
59315
- }
59316
- }
59317
- return UNRESOLVED;
59318
- };
59319
- exports.packageExports = function* (packageURL, subpath, packageExports, opts = {}) {
59320
- if (subpath === ".") {
59321
- let mainExport;
59322
- if (typeof packageExports === "string" || Array.isArray(packageExports)) {
59323
- mainExport = packageExports;
59324
- } else if (typeof packageExports === "object" && packageExports !== null) {
59325
- const keys = Object.keys(packageExports);
59326
- if (keys.some((key) => key.startsWith("."))) {
59327
- if ("." in packageExports)
59328
- mainExport = packageExports["."];
59329
- } else {
59330
- mainExport = packageExports;
59331
- }
59332
- }
59333
- if (mainExport) {
59334
- const status = yield* exports.packageTarget(packageURL, mainExport, null, false, opts);
59335
- if (status)
59336
- return status;
59337
- }
59338
- } else if (typeof packageExports === "object" && packageExports !== null) {
59339
- const keys = Object.keys(packageExports);
59340
- if (keys.every((key) => key.startsWith("."))) {
59341
- const status = yield* exports.packageImportsExports(subpath, packageExports, packageURL, false, opts);
59342
- if (status)
59343
- return status;
59344
- }
59345
- }
59346
- throw errors.PACKAGE_PATH_NOT_EXPORTED(`Package subpath '${subpath}' is not defined by "exports" in '${packageURL}'`);
59347
- };
59348
- exports.packageImports = function* (specifier, parentURL, opts = {}) {
59349
- const { imports = null } = opts;
59350
- if (specifier === "#" || specifier.startsWith("#/")) {
59351
- throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${specifier}' is not a valid internal imports specifier`);
59352
- }
59353
- for (const packageURL of exports.lookupPackageScope(parentURL, opts)) {
59354
- const info = yield { package: packageURL };
59355
- if (info) {
59356
- if (info.imports) {
59357
- const status = yield* exports.packageImportsExports(specifier, info.imports, packageURL, true, opts);
59358
- if (status)
59359
- return status;
59360
- }
59361
- if (specifier.startsWith("#")) {
59362
- throw errors.PACKAGE_IMPORT_NOT_DEFINED(`Package import specifier '${specifier}' is not defined by "imports" in '${packageURL}'`);
59363
- }
59364
- break;
59365
- }
59366
- }
59367
- if (imports) {
59368
- const status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts);
59369
- if (status)
59370
- return status;
59371
- }
59372
- return UNRESOLVED;
59373
- };
59374
- exports.packageImportsExports = function* (matchKey, matchObject, packageURL, isImports, opts = {}) {
59375
- if (matchKey in matchObject && !matchKey.includes("*")) {
59376
- const target = matchObject[matchKey];
59377
- return yield* exports.packageTarget(packageURL, target, null, isImports, opts);
59378
- }
59379
- const expansionKeys = Object.keys(matchObject).filter((key) => key.includes("*")).sort(exports.patternKeyCompare);
59380
- for (const expansionKey of expansionKeys) {
59381
- const patternIndex = expansionKey.indexOf("*");
59382
- const patternBase = expansionKey.substring(0, patternIndex);
59383
- if (matchKey.startsWith(patternBase) && matchKey !== patternBase) {
59384
- const patternTrailer = expansionKey.substring(patternIndex + 1);
59385
- if (patternTrailer === "" || matchKey.endsWith(patternTrailer) && matchKey.length >= expansionKey.length) {
59386
- const target = matchObject[expansionKey];
59387
- const patternMatch = matchKey.substring(patternBase.length, matchKey.length - patternTrailer.length);
59388
- return yield* exports.packageTarget(packageURL, target, patternMatch, isImports, opts);
59389
- }
59390
- }
59391
- }
59392
- return UNRESOLVED;
59393
- };
59394
- exports.validateEngines = function validateEngines(packageURL, packageEngines, opts = {}) {
59395
- const { engines = {} } = opts;
59396
- for (const [engine, range] of Object.entries(packageEngines)) {
59397
- if (engine in engines) {
59398
- const version = engines[engine];
59399
- if (!satisfies(version, range)) {
59400
- throw errors.UNSUPPORTED_ENGINE(`Package not compatible with engine '${engine}' ${version}, requires range '${range}' defined by "engines" in '${packageURL}'`);
59401
- }
59402
- }
59403
- }
59404
- };
59405
- exports.patternKeyCompare = function patternKeyCompare(keyA, keyB) {
59406
- const patternIndexA = keyA.indexOf("*");
59407
- const patternIndexB = keyB.indexOf("*");
59408
- const baseLengthA = patternIndexA === -1 ? keyA.length : patternIndexA + 1;
59409
- const baseLengthB = patternIndexB === -1 ? keyB.length : patternIndexB + 1;
59410
- if (baseLengthA > baseLengthB)
59411
- return -1;
59412
- if (baseLengthB > baseLengthA)
59413
- return 1;
59414
- if (patternIndexA === -1)
59415
- return 1;
59416
- if (patternIndexB === -1)
59417
- return -1;
59418
- if (keyA.length > keyB.length)
59419
- return -1;
59420
- if (keyB.length > keyA.length)
59421
- return 1;
59422
- return 0;
59423
- };
59424
- exports.packageTarget = function* (packageURL, target, patternMatch, isImports, opts = {}) {
59425
- const { conditions = [], matchedConditions = [] } = opts;
59426
- if (typeof target === "string") {
59427
- if (!target.startsWith("./") && !isImports) {
59428
- throw errors.INVALID_PACKAGE_TARGET(`Invalid target '${target}' defined by "exports" in '${packageURL}'`);
59429
- }
59430
- if (patternMatch !== null) {
59431
- target = target.replaceAll("*", patternMatch);
59432
- }
59433
- const status = yield* exports.url(target, packageURL, opts);
59434
- if (status)
59435
- return status;
59436
- if (target === "." || target === ".." || target[0] === "/" || target.startsWith("./") || target.startsWith("../")) {
59437
- const resolved = yield { resolution: new URL(target, packageURL) };
59438
- return resolved ? RESOLVED : YIELDED;
59439
- }
59440
- return yield* exports.package(target, packageURL, opts);
59441
- }
59442
- if (Array.isArray(target)) {
59443
- for (const targetValue of target) {
59444
- const status = yield* exports.packageTarget(packageURL, targetValue, patternMatch, isImports, opts);
59445
- if (status)
59446
- return status;
59447
- }
59448
- } else if (typeof target === "object" && target !== null) {
59449
- let status = UNRESOLVED;
59450
- for (const [condition, targetValue, subset] of exports.conditionMatches(target, conditions, opts)) {
59451
- matchedConditions.push(condition);
59452
- status |= yield* exports.packageTarget(packageURL, targetValue, patternMatch, isImports, {
59453
- ...opts,
59454
- conditions: subset
59455
- });
59456
- matchedConditions.pop();
59457
- }
59458
- if (status)
59459
- return status;
59460
- }
59461
- return UNRESOLVED;
59462
- };
59463
- exports.builtinTarget = function* (packageSpecifier, packageVersion, target, opts = {}) {
59464
- const { builtinProtocol = "builtin:", conditions = [], matchedConditions = [] } = opts;
59465
- if (typeof target === "string") {
59466
- const targetParts = target.split("@");
59467
- let targetName;
59468
- let targetVersion;
59469
- if (target[0] !== "@") {
59470
- targetName = targetParts[0];
59471
- targetVersion = targetParts[1] || null;
59472
- } else {
59473
- targetName = targetParts.slice(0, 2).join("@");
59474
- targetVersion = targetParts[2] || null;
59475
- }
59476
- if (packageSpecifier === targetName) {
59477
- if (packageVersion === null && targetVersion === null) {
59478
- const resolved = yield {
59479
- resolution: new URL(builtinProtocol + packageSpecifier)
59480
- };
59481
- return resolved ? RESOLVED : YIELDED;
59482
- }
59483
- let version = null;
59484
- if (packageVersion === null) {
59485
- version = targetVersion;
59486
- } else if (targetVersion === null || packageVersion === targetVersion) {
59487
- version = packageVersion;
59488
- }
59489
- if (version !== null) {
59490
- const resolved = yield {
59491
- resolution: new URL(builtinProtocol + packageSpecifier + "@" + version)
59492
- };
59493
- return resolved ? RESOLVED : YIELDED;
59494
- }
59495
- }
59496
- } else if (Array.isArray(target)) {
59497
- for (const targetValue of target) {
59498
- const status = yield* exports.builtinTarget(packageSpecifier, packageVersion, targetValue, opts);
59499
- if (status)
59500
- return status;
59501
- }
59502
- } else if (typeof target === "object" && target !== null) {
59503
- let status = UNRESOLVED;
59504
- for (const [condition, targetValue, subset] of exports.conditionMatches(target, conditions, opts)) {
59505
- matchedConditions.push(condition);
59506
- status |= yield* exports.builtinTarget(packageSpecifier, packageVersion, targetValue, {
59507
- ...opts,
59508
- conditions: subset
59509
- });
59510
- matchedConditions.pop();
59511
- }
59512
- if (status)
59513
- return status;
59514
- }
59515
- return UNRESOLVED;
59516
- };
59517
- exports.conditionMatches = function* conditionMatches(target, conditions, opts = {}) {
59518
- if (conditions.every((condition) => typeof condition === "string")) {
59519
- const keys = Object.keys(target);
59520
- for (const condition of keys) {
59521
- if (condition === "default" || conditions.includes(condition)) {
59522
- yield [condition, target[condition], conditions];
59523
- return true;
59524
- }
59525
- }
59526
- return false;
59527
- }
59528
- let yielded = false;
59529
- for (const subset of conditions) {
59530
- if (yield* conditionMatches(target, subset, opts)) {
59531
- yielded = true;
59532
- }
59533
- }
59534
- return yielded;
59535
- };
59536
- exports.lookupPackageRoot = function* (packageName, parentURL) {
59537
- parentURL = new URL(parentURL.href);
59538
- do {
59539
- const packageURL = new URL("node_modules/" + packageName + "/", parentURL);
59540
- const info = yield new URL("package.json", packageURL);
59541
- if (info)
59542
- return info;
59543
- parentURL.pathname = parentURL.pathname.substring(0, parentURL.pathname.lastIndexOf("/"));
59544
- if (parentURL.pathname.length === 3 && exports.isWindowsDriveLetter(parentURL.pathname.substring(1))) {
59545
- break;
59546
- }
59547
- } while (parentURL.pathname !== "" && parentURL.pathname !== "/");
59548
- return null;
59549
- };
59550
- exports.lookupPackageScope = function* lookupPackageScope(scopeURL, opts = {}) {
59551
- const { resolutions = null } = opts;
59552
- if (resolutions) {
59553
- for (const { resolution } of exports.preresolved("#package", resolutions, scopeURL, opts)) {
59554
- if (resolution)
59555
- return yield resolution;
59556
- }
59557
- }
59558
- scopeURL = new URL(scopeURL.href);
59559
- do {
59560
- if (scopeURL.pathname.endsWith("/node_modules"))
59561
- break;
59562
- const info = yield new URL("package.json", scopeURL);
59563
- if (info)
59564
- return info;
59565
- scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf("/"));
59566
- if (scopeURL.pathname.length === 3 && exports.isWindowsDriveLetter(scopeURL.pathname.substring(1))) {
59567
- break;
59568
- }
59569
- } while (scopeURL.pathname !== "" && scopeURL.pathname !== "/");
59570
- return null;
59571
- };
59572
- exports.file = function* (filename, parentURL, isIndex, opts = {}) {
59573
- if (filename === "." || filename === ".." || filename[filename.length - 1] === "/" || filename[filename.length - 1] === "\\") {
59574
- return UNRESOLVED;
59575
- }
59576
- if (parentURL.protocol === "file:" && /%2f|%5c/i.test(filename)) {
59577
- throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${filename}' is invalid`);
59578
- }
59579
- const { extensions = [] } = opts;
59580
- let status = UNRESOLVED;
59581
- if (!isIndex) {
59582
- if (yield { resolution: new URL(filename, parentURL) }) {
59583
- return RESOLVED;
59584
- }
59585
- status = YIELDED;
59586
- }
59587
- for (const ext of extensions) {
59588
- if (filename.endsWith(ext))
59589
- continue;
59590
- if (yield { resolution: new URL(filename + ext, parentURL) }) {
59591
- return RESOLVED;
59592
- }
59593
- status = YIELDED;
59594
- }
59595
- return status;
59596
- };
59597
- exports.directory = function* (dirname2, parentURL, opts = {}) {
59598
- let directoryURL;
59599
- if (dirname2[dirname2.length - 1] === "/" || dirname2[dirname2.length - 1] === "\\") {
59600
- directoryURL = new URL(dirname2, parentURL);
59601
- } else {
59602
- directoryURL = new URL(dirname2 + "/", parentURL);
59603
- }
59604
- const info = yield { package: new URL("package.json", directoryURL) };
59605
- if (info) {
59606
- if (info.exports) {
59607
- return yield* exports.packageExports(directoryURL, ".", info.exports, opts);
59608
- }
59609
- if (typeof info.main === "string" && info.main !== "") {
59610
- const status = yield* exports.file(info.main, directoryURL, false, opts);
59611
- if (status === RESOLVED)
59612
- return status;
59613
- return yield* exports.directory(info.main, directoryURL, opts);
59614
- }
59615
- }
59616
- return yield* exports.file("index", directoryURL, true, opts);
59617
- };
59618
- function isASCIIUpperAlpha(c) {
59619
- return c >= 65 && c <= 90;
59620
- }
59621
- function isASCIILowerAlpha(c) {
59622
- return c >= 97 && c <= 122;
59623
- }
59624
- function isASCIIAlpha(c) {
59625
- return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c);
59626
- }
59627
- exports.isWindowsDriveLetter = function isWindowsDriveLetter(input) {
59628
- return input.length >= 2 && isASCIIAlpha(input.charCodeAt(0)) && (input.charCodeAt(1) === 58 || input.charCodeAt(1) === 124);
59629
- };
59630
- exports.startsWithWindowsDriveLetter = function startsWithWindowsDriveLetter(input) {
59631
- 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);
59632
- };
59633
- });
59634
-
59635
- // node_modules/bare-addon-resolve/lib/errors.js
59636
- var require_errors3 = __commonJS((exports, module) => {
59637
- module.exports = class AddonResolveError extends Error {
59638
- constructor(msg, code, fn = AddonResolveError) {
59639
- super(`${code}: ${msg}`);
59640
- this.code = code;
59641
- if (Error.captureStackTrace) {
59642
- Error.captureStackTrace(this, fn);
59643
- }
59644
- }
59645
- get name() {
59646
- return "AddonResolveError";
59647
- }
59648
- static INVALID_ADDON_SPECIFIER(msg) {
59649
- return new AddonResolveError(msg, "INVALID_ADDON_SPECIFIER", AddonResolveError.INVALID_ADDON_SPECIFIER);
59650
- }
59651
- static INVALID_PACKAGE_NAME(msg) {
59652
- return new AddonResolveError(msg, "INVALID_PACKAGE_NAME", AddonResolveError.INVALID_PACKAGE_NAME);
59653
- }
59654
- };
59655
- });
59656
-
59657
- // node_modules/bare-addon-resolve/index.js
59658
- var require_bare_addon_resolve = __commonJS((exports, module) => {
59659
- var resolve = require_bare_module_resolve();
59660
- var { Version } = require_bare_semver();
59661
- var errors = require_errors3();
59662
- module.exports = exports = function resolve(specifier, parentURL, opts, readPackage) {
59663
- if (typeof opts === "function") {
59664
- readPackage = opts;
59665
- opts = {};
59666
- } else if (typeof readPackage !== "function") {
59667
- readPackage = defaultReadPackage;
59668
- }
59669
- return {
59670
- *[Symbol.iterator]() {
59671
- const generator = exports.addon(specifier, parentURL, opts);
59672
- let next = generator.next();
59673
- while (next.done !== true) {
59674
- const value = next.value;
59675
- if (value.package) {
59676
- next = generator.next(readPackage(value.package));
59677
- } else {
59678
- next = generator.next(yield value.resolution);
59679
- }
59680
- }
59681
- return next.value;
59682
- },
59683
- async* [Symbol.asyncIterator]() {
59684
- const generator = exports.addon(specifier, parentURL, opts);
59685
- let next = generator.next();
59686
- while (next.done !== true) {
59687
- const value = next.value;
59688
- if (value.package) {
59689
- next = generator.next(await readPackage(value.package));
59690
- } else {
59691
- next = generator.next(yield value.resolution);
59692
- }
59693
- }
59694
- return next.value;
59695
- }
59696
- };
59697
- };
59698
- function defaultReadPackage() {
59699
- return null;
59700
- }
59701
- var { UNRESOLVED, YIELDED, RESOLVED } = resolve.constants;
59702
- exports.constants = {
59703
- UNRESOLVED,
59704
- YIELDED,
59705
- RESOLVED
59706
- };
59707
- exports.addon = function* (specifier, parentURL, opts = {}) {
59708
- const { resolutions = null } = opts;
59709
- if (exports.startsWithWindowsDriveLetter(specifier)) {
59710
- specifier = "/" + specifier;
59711
- }
59712
- let status;
59713
- if (resolutions) {
59714
- status = yield* resolve.preresolved(specifier, resolutions, parentURL, opts);
59715
- if (status)
59716
- return status;
59717
- }
59718
- status = yield* exports.url(specifier, parentURL, opts);
59719
- if (status)
59720
- return status;
59721
- let version = null;
59722
- const i = specifier.lastIndexOf("@");
59723
- if (i > 0) {
59724
- version = specifier.substring(i + 1);
59725
- try {
59726
- Version.parse(version);
59727
- specifier = specifier.substring(0, i);
59728
- } catch {
59729
- version = null;
59730
- }
59731
- }
59732
- if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier[0] === "\\" || specifier.startsWith("./") || specifier.startsWith(".\\") || specifier.startsWith("../") || specifier.startsWith("..\\")) {
59733
- status = yield* exports.file(specifier, parentURL, opts);
59734
- if (status === RESOLVED)
59735
- return status;
59736
- return yield* exports.directory(specifier, version, parentURL, opts);
59737
- }
59738
- return yield* exports.package(specifier, version, parentURL, opts);
59739
- };
59740
- exports.url = function* (url, parentURL, opts = {}) {
59741
- let resolution;
59742
- try {
59743
- resolution = new URL(url);
59744
- } catch {
59745
- return UNRESOLVED;
59746
- }
59747
- const resolved = yield { resolution };
59748
- return resolved ? RESOLVED : YIELDED;
59749
- };
59750
- exports.package = function* (packageSpecifier, packageVersion, parentURL, opts = {}) {
59751
- if (packageSpecifier === "") {
59752
- throw errors.INVALID_ADDON_SPECIFIER(`Addon specifier '${packageSpecifier}' is not a valid package name`);
59753
- }
59754
- let packageName;
59755
- if (packageSpecifier[0] !== "@") {
59756
- packageName = packageSpecifier.split("/", 1).join();
59757
- } else {
59758
- if (!packageSpecifier.includes("/")) {
59759
- throw errors.INVALID_ADDON_SPECIFIER(`Addon specifier '${packageSpecifier}' is not a valid package name`);
59760
- }
59761
- packageName = packageSpecifier.split("/", 2).join("/");
59762
- }
59763
- if (packageName[0] === "." || packageName.includes("\\") || packageName.includes("%")) {
59764
- throw errors.INVALID_ADDON_SPECIFIER(`Addon specifier '${packageSpecifier}' is not a valid package name`);
59765
- }
59766
- const packageSubpath = "." + packageSpecifier.substring(packageName.length);
59767
- const status = yield* exports.packageSelf(packageName, packageSubpath, packageVersion, parentURL, opts);
59768
- if (status)
59769
- return status;
59770
- parentURL = new URL(parentURL.href);
59771
- do {
59772
- const packageURL = new URL("node_modules/" + packageName + "/", parentURL);
59773
- parentURL.pathname = parentURL.pathname.substring(0, parentURL.pathname.lastIndexOf("/"));
59774
- const info = yield { package: new URL("package.json", packageURL) };
59775
- if (info) {
59776
- return yield* exports.directory(packageSubpath, packageVersion, packageURL, opts);
59777
- }
59778
- } while (parentURL.pathname !== "" && parentURL.pathname !== "/");
59779
- return UNRESOLVED;
59780
- };
59781
- exports.packageSelf = function* (packageName, packageSubpath, packageVersion, parentURL, opts = {}) {
59782
- for (const packageURL of resolve.lookupPackageScope(parentURL, opts)) {
59783
- const info = yield { package: packageURL };
59784
- if (info) {
59785
- if (info.name === packageName) {
59786
- return yield* exports.directory(packageSubpath, packageVersion, packageURL, opts);
59787
- }
59788
- break;
59789
- }
59790
- }
59791
- return UNRESOLVED;
59792
- };
59793
- exports.lookupPrebuildsScope = function* lookupPrebuildsScope(url, opts = {}) {
59794
- const scopeURL = new URL(url.href);
59795
- do {
59796
- yield new URL("prebuilds/", scopeURL);
59797
- scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf("/"));
59798
- if (scopeURL.pathname.length === 3 && exports.isWindowsDriveLetter(scopeURL.pathname.substring(1))) {
59799
- break;
59800
- }
59801
- } while (scopeURL.pathname !== "" && scopeURL.pathname !== "/");
59802
- };
59803
- exports.file = function* (filename, parentURL, opts = {}) {
59804
- if (filename === "." || filename === ".." || filename[filename.length - 1] === "/" || filename[filename.length - 1] === "\\") {
59805
- return UNRESOLVED;
59806
- }
59807
- if (parentURL.protocol === "file:" && /%2f|%5c/i.test(filename)) {
59808
- throw errors.INVALID_ADDON_SPECIFIER(`Addon specifier '${filename}' is invalid`);
59809
- }
59810
- const { extensions = [] } = opts;
59811
- let status = UNRESOLVED;
59812
- for (let ext of extensions) {
59813
- if (filename.endsWith(ext))
59814
- ext = "";
59815
- if (yield { resolution: new URL(filename + ext, parentURL) }) {
59816
- return RESOLVED;
59817
- }
59818
- status = YIELDED;
59819
- }
59820
- return status;
59821
- };
59822
- exports.directory = function* (dirname2, version, parentURL, opts = {}) {
59823
- const {
59824
- host = null,
59825
- hosts = host !== null ? [host] : [],
59826
- builtins = [],
59827
- matchedConditions = []
59828
- } = opts;
59829
- let directoryURL;
59830
- if (dirname2[dirname2.length - 1] === "/" || dirname2[dirname2.length - 1] === "\\") {
59831
- directoryURL = new URL(dirname2, parentURL);
59832
- } else {
59833
- directoryURL = new URL(dirname2 + "/", parentURL);
59834
- }
59835
- const unversioned = version === null;
59836
- let name = null;
59837
- const info = yield { package: new URL("package.json", directoryURL) };
59838
- if (info) {
59839
- if (typeof info.name === "string" && info.name !== "") {
59840
- if (info.name.includes("__")) {
59841
- throw errors.INVALID_PACKAGE_NAME(`Package name '${info.name}' is invalid`);
59842
- }
59843
- name = info.name.replace(/\//g, "__").replace(/^@/, "");
59844
- } else {
59845
- return UNRESOLVED;
59846
- }
59847
- if (typeof info.version === "string" && info.version !== "") {
59848
- if (version !== null && info.version !== version)
59849
- return UNRESOLVED;
59850
- version = info.version;
59851
- }
59852
- } else {
59853
- return UNRESOLVED;
59854
- }
59855
- let status;
59856
- status = yield* resolve.builtinTarget(name, version, builtins, opts);
59857
- if (status)
59858
- return status;
59859
- for (const prebuildsURL of exports.lookupPrebuildsScope(directoryURL, opts)) {
59860
- status = UNRESOLVED;
59861
- for (const host2 of hosts) {
59862
- const conditions = host2.split("-");
59863
- const universal = supportsUniversalPrebuilds(host2) ? conditions.with(1, "universal").join("-") : null;
59864
- matchedConditions.push(...conditions);
59865
- if (version !== null) {
59866
- status |= yield* exports.file(host2 + "/" + name + "@" + version, prebuildsURL, opts);
59867
- if (universal) {
59868
- status |= yield* exports.file(universal + "/" + name + "@" + version, prebuildsURL, opts);
59869
- }
59870
- }
59871
- if (unversioned) {
59872
- status |= yield* exports.file(host2 + "/" + name, prebuildsURL, opts);
59873
- if (universal) {
59874
- status |= yield* exports.file(universal + "/" + name, prebuildsURL, opts);
59875
- }
59876
- }
59877
- for (const _ of conditions)
59878
- matchedConditions.pop();
59879
- }
59880
- if (status === RESOLVED)
59881
- return status;
59882
- }
59883
- return yield* exports.linked(name, version, opts);
59884
- };
59885
- exports.linked = function* (name, version = null, opts = {}) {
59886
- const {
59887
- linked = true,
59888
- host = null,
59889
- hosts = host !== null ? [host] : [],
59890
- matchedConditions = []
59891
- } = opts;
59892
- if (linked === false || hosts.length === 0)
59893
- return UNRESOLVED;
59894
- let status = UNRESOLVED;
59895
- for (const host2 of hosts) {
59896
- const [platform = null] = host2.split("-", 1);
59897
- if (platform === null)
59898
- continue;
59899
- matchedConditions.push(platform);
59900
- status |= yield* platformArtefact(name, version, platform, opts);
59901
- matchedConditions.pop();
59902
- }
59903
- return status;
59904
- };
59905
- function* platformArtefact(name, version = null, platform, opts = {}) {
59906
- const { linkedProtocol = "linked:" } = opts;
59907
- if (platform === "darwin" || platform === "ios") {
59908
- if (version !== null) {
59909
- if (yield {
59910
- resolution: new URL(`${linkedProtocol}${name}.${version}.framework/${name}.${version}`)
59911
- }) {
59912
- return RESOLVED;
59913
- }
59914
- if (platform === "darwin") {
59915
- if (yield {
59916
- resolution: new URL(`${linkedProtocol}lib${name}.${version}.dylib`)
59917
- }) {
59918
- return RESOLVED;
59919
- }
59920
- }
59921
- }
59922
- if (yield {
59923
- resolution: new URL(`${linkedProtocol}${name}.framework/${name}`)
59924
- }) {
59925
- return RESOLVED;
59926
- }
59927
- if (platform === "darwin") {
59928
- if (yield {
59929
- resolution: new URL(`${linkedProtocol}lib${name}.dylib`)
59930
- }) {
59931
- return RESOLVED;
59932
- }
59933
- }
59934
- return YIELDED;
59935
- }
59936
- if (platform === "linux" || platform === "android") {
59937
- if (version !== null) {
59938
- if (yield {
59939
- resolution: new URL(`${linkedProtocol}lib${name}.${version}.so`)
59940
- }) {
59941
- return RESOLVED;
59942
- }
59943
- }
59944
- if (yield {
59945
- resolution: new URL(`${linkedProtocol}lib${name}.so`)
59946
- }) {
59947
- return RESOLVED;
59948
- }
59949
- return YIELDED;
59950
- }
59951
- if (platform === "win32") {
59952
- if (version !== null) {
59953
- if (yield {
59954
- resolution: new URL(`${linkedProtocol}${name}-${version}.dll`)
59955
- }) {
59956
- return RESOLVED;
59957
- }
59958
- }
59959
- if (yield {
59960
- resolution: new URL(`${linkedProtocol}${name}.dll`)
59961
- }) {
59962
- return RESOLVED;
59963
- }
59964
- }
59965
- return UNRESOLVED;
59966
- }
59967
- exports.isWindowsDriveLetter = resolve.isWindowsDriveLetter;
59968
- exports.startsWithWindowsDriveLetter = resolve.startsWithWindowsDriveLetter;
59969
- function supportsUniversalPrebuilds(host) {
59970
- return host === "darwin-arm64" || host === "darwin-x64" || host === "ios-arm64-simulator" || host === "ios-x64-simulator";
59971
- }
59972
- });
59973
-
59974
- // node_modules/require-addon/lib/node.js
59975
- var require_node = __commonJS((exports, module) => {
59976
- if (typeof __require.addon === "function") {
59977
- module.exports = __require.addon.bind(__require);
59978
- } else {
59979
- let readPackage2 = function(packageURL) {
59980
- try {
59981
- return __require(url.fileURLToPath(packageURL));
59982
- } catch (err) {
59983
- return null;
59984
- }
59985
- }, isAlpine2 = function() {
59986
- return process.platform === "linux" && fs.existsSync("/etc/alpine-release");
59987
- };
59988
- readPackage = readPackage2, isAlpine = isAlpine2;
59989
- const url = __require("url");
59990
- const fs = __require("fs");
59991
- const resolve = require_bare_addon_resolve();
59992
- let host = process.platform + "-" + process.arch;
59993
- const conditions = ["addon", "node", process.platform, process.arch];
59994
- const extensions = [".node"];
59995
- if (isAlpine2()) {
59996
- host += "-musl";
59997
- conditions.push("musl");
59998
- }
59999
- module.exports = function addon(specifier, parentURL) {
60000
- if (typeof parentURL === "string")
60001
- parentURL = url.pathToFileURL(parentURL);
60002
- const candidates = [];
60003
- let cause;
60004
- for (const resolution of resolve(specifier, parentURL, { host, conditions, extensions }, readPackage2)) {
60005
- candidates.push(resolution);
60006
- switch (resolution.protocol) {
60007
- case "file:":
60008
- try {
60009
- return __require(url.fileURLToPath(resolution));
60010
- } catch (err2) {
60011
- cause = err2;
60012
- continue;
60013
- }
60014
- }
60015
- }
60016
- let message = `Cannot find addon '${specifier}' imported from '${parentURL.href}'`;
60017
- if (candidates.length > 0) {
60018
- message += `
60019
- Candidates:`;
60020
- message += `
60021
- ` + candidates.map((url2) => "- " + url2.href).join(`
60022
- `);
60023
- }
60024
- const err = new Error(message, cause ? { cause } : {});
60025
- err.code = "ADDON_NOT_FOUND";
60026
- err.specifier = specifier;
60027
- err.referrer = parentURL;
60028
- err.candidates = candidates;
60029
- throw err;
60030
- };
60031
- }
60032
- var readPackage;
60033
- var isAlpine;
60034
- });
60035
-
60036
- // node_modules/sodium-native/binding.js
60037
- var require_binding = __commonJS((exports, module) => {
60038
- var __filename = "H:\\project\\outsourcing\\t402-cli\\node_modules\\sodium-native\\binding.js";
60039
- __require.addon = require_node();
60040
- module.exports = __require.addon(".", __filename);
60041
- });
60042
-
60043
- // node_modules/which-runtime/index.js
60044
- var require_which_runtime = __commonJS((exports) => {
60045
- 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" };
60046
- exports.runtime = runtime;
60047
- exports.platform = platform;
60048
- exports.arch = arch;
60049
- exports.isBare = runtime === "bare";
60050
- exports.isBareKit = exports.isBare && typeof BareKit !== "undefined";
60051
- exports.isPear = typeof Pear !== "undefined";
60052
- exports.isNode = runtime === "node";
60053
- exports.isBrowser = runtime === "browser";
60054
- exports.isWindows = platform === "win32";
60055
- exports.isLinux = platform === "linux";
60056
- exports.isMac = platform === "darwin";
60057
- exports.isIOS = platform === "ios" || platform === "ios-simulator";
60058
- exports.isAndroid = platform === "android";
60059
- exports.isElectron = typeof process !== "undefined" && !!global.process.versions?.electron;
60060
- exports.isElectronRenderer = exports.isElectron && global.process.type === "renderer";
60061
- exports.isElectronWorker = exports.isElectron && global.process.type === "worker";
60062
- });
60063
-
60064
- // node_modules/sodium-native/index.js
60065
- var require_sodium_native = __commonJS((exports, module) => {
60066
- var assert2 = __require("assert");
60067
- var binding = require_binding();
60068
- var { isNode } = require_which_runtime();
60069
- var OPTIONAL = Buffer.from(new ArrayBuffer(0));
60070
- module.exports = exports = { ...binding };
60071
- exports.sodium_memzero = function(buf) {
60072
- assert2(ArrayBuffer.isView(buf), "buf must be a typed array");
60073
- binding.sodium_memzero(buf);
60074
- };
60075
- exports.sodium_mlock = function(buf) {
60076
- assert2(ArrayBuffer.isView(buf), "buf must be a typed array");
60077
- const res = binding.sodium_mlock(buf);
60078
- if (res !== 0)
60079
- throw new Error("memory lock failed");
60080
- };
60081
- exports.sodium_munlock = function(buf) {
60082
- assert2(ArrayBuffer.isView(buf), "buf must be a typed array");
60083
- const res = binding.sodium_munlock(buf);
60084
- if (res !== 0)
60085
- throw new Error("memory unlock failed");
60086
- };
60087
- exports.sodium_malloc = function(size) {
60088
- assert2(size >= 0, "invalid size");
60089
- const buf = Buffer.from(binding.sodium_malloc(size));
60090
- buf.secure = true;
60091
- return buf;
60092
- };
60093
- exports.sodium_free = function(buf) {
60094
- if (!buf || !buf.secure)
60095
- return;
60096
- binding.sodium_free(buf.buffer);
60097
- };
60098
- exports.sodium_mprotect_noaccess = function(buf) {
60099
- const res = binding.sodium_mprotect_noaccess(buf.buffer);
60100
- if (res !== 0)
60101
- throw new Error("failed to lock buffer");
60102
- };
60103
- exports.sodium_mprotect_readonly = function(buf) {
60104
- const res = binding.sodium_mprotect_readonly(buf.buffer);
60105
- if (res !== 0)
60106
- throw new Error("failed to unlock buffer");
60107
- };
60108
- exports.sodium_mprotect_readwrite = function(buf) {
60109
- const res = binding.sodium_mprotect_readwrite(buf.buffer);
60110
- if (res !== 0)
60111
- throw new Error("failed to unlock buffer");
60112
- };
60113
- exports.randombytes_buf = function(buffer2) {
60114
- assert2(ArrayBuffer.isView(buffer2), "buffer must be a typed array");
60115
- binding.randombytes_buf(buffer2.buffer, buffer2.byteOffset, buffer2.byteLength);
60116
- };
60117
- exports.randombytes_buf_deterministic = function(buffer2, seed) {
60118
- assert2(ArrayBuffer.isView(buffer2), "buffer must be a typed array");
60119
- assert2(ArrayBuffer.isView(seed), "seed must be a typed array");
60120
- assert2(seed.byteLength === binding.randombytes_SEEDBYTES, "seed must be 'randombytes_SEEDBYTES' bytes");
60121
- binding.randombytes_buf_deterministic(buffer2.buffer, buffer2.byteOffset, buffer2.byteLength, seed.buffer, seed.byteOffset, seed.byteLength);
60122
- };
60123
- exports.sodium_memcmp = function(a, b) {
60124
- assert2(ArrayBuffer.isView(a), "a must be a typed array");
60125
- assert2(ArrayBuffer.isView(b), "b must be a typed array");
60126
- assert2(a.byteLength === b.byteLength, "buffers must be of same length");
60127
- return binding.sodium_memcmp(a, b);
60128
- };
60129
- exports.sodium_add = function(a, b) {
60130
- assert2(ArrayBuffer.isView(a), "a must be a typed array");
60131
- assert2(ArrayBuffer.isView(b), "b must be a typed array");
60132
- assert2(a.byteLength === b.byteLength, "buffers must be of same length");
60133
- binding.sodium_add(a, b);
60134
- };
60135
- exports.sodium_sub = function(a, b) {
60136
- assert2(ArrayBuffer.isView(a), "a must be a typed array");
60137
- assert2(ArrayBuffer.isView(b), "b must be a typed array");
60138
- assert2(a.byteLength === b.byteLength, "buffers must be of same length");
60139
- binding.sodium_sub(a, b);
60140
- };
60141
- exports.sodium_compare = function(a, b) {
60142
- assert2(ArrayBuffer.isView(a), "a must be a typed array");
60143
- assert2(ArrayBuffer.isView(b), "b must be a typed array");
60144
- assert2(a.byteLength === b.byteLength, "buffers must be of same length");
60145
- return binding.sodium_compare(a, b);
60146
- };
60147
- exports.sodium_is_zero = function(buffer2, length) {
60148
- if (length === undefined)
60149
- length = buffer2.byteLength;
60150
- assert2(ArrayBuffer.isView(buffer2), "buffer must be a typed array");
60151
- assert2(length >= 0 && length <= buffer2.byteLength, "invalid length");
60152
- return binding.sodium_is_zero(buffer2, length);
60153
- };
60154
- exports.sodium_pad = function(buffer2, unpaddedBuflen, blockSize) {
60155
- assert2(ArrayBuffer.isView(buffer2), "buffer must be a typed array");
60156
- assert2(unpaddedBuflen <= buffer2.byteLength, "unpadded length cannot exceed buffer length");
60157
- assert2(blockSize <= buffer2.byteLength, "block size cannot exceed buffer length");
60158
- assert2(blockSize >= 1, "block size must be at least 1 byte");
60159
- assert2(buffer2.byteLength >= unpaddedBuflen + (blockSize - unpaddedBuflen % blockSize), "buf not long enough");
60160
- return binding.sodium_pad(buffer2, unpaddedBuflen, blockSize);
60161
- };
60162
- exports.sodium_unpad = function(buffer2, paddedBuflen, blockSize) {
60163
- assert2(ArrayBuffer.isView(buffer2), "buffer must be a typed array");
60164
- assert2(paddedBuflen <= buffer2.byteLength, "unpadded length cannot exceed buffer length");
60165
- assert2(blockSize <= buffer2.byteLength, "block size cannot exceed buffer length");
60166
- assert2(blockSize >= 1, "block size must be at least 1 byte");
60167
- return binding.sodium_unpad(buffer2, paddedBuflen, blockSize);
60168
- };
60169
- exports.crypto_sign_keypair = function(pk, sk) {
60170
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60171
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60172
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
60173
- assert2(sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes");
60174
- const res = binding.crypto_sign_keypair(pk, sk);
60175
- if (res !== 0)
60176
- throw new Error("status: " + res);
60177
- };
60178
- exports.crypto_sign_seed_keypair = function(pk, sk, seed) {
60179
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60180
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60181
- assert2(ArrayBuffer.isView(seed), "seed must be a typed array");
60182
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
60183
- assert2(sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes");
60184
- assert2(seed.byteLength === binding.crypto_sign_SEEDBYTES, "seed must be 'crypto_sign_SEEDBYTES' bytes");
60185
- const res = binding.crypto_sign_seed_keypair(pk, sk, seed);
60186
- if (res !== 0)
60187
- throw new Error("status: " + res);
60188
- };
60189
- exports.crypto_sign = function(sm, m, sk) {
60190
- assert2(ArrayBuffer.isView(sm), "sm must be a typed array");
60191
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60192
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60193
- assert2(sm.byteLength === binding.crypto_sign_BYTES + m.byteLength, "sm must be 'm.byteLength + crypto_sign_BYTES' bytes");
60194
- assert2(sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes");
60195
- const res = binding.crypto_sign(sm, m, sk);
60196
- if (res !== 0)
60197
- throw new Error("status: " + res);
60198
- };
60199
- exports.crypto_sign_open = function(m, sm, pk) {
60200
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60201
- assert2(ArrayBuffer.isView(sm), "sm must be a typed array");
60202
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60203
- assert2(sm.byteLength >= binding.crypto_sign_BYTES, "sm must be at least 'crypto_sign_BYTES' bytes");
60204
- assert2(m.byteLength === sm.byteLength - binding.crypto_sign_BYTES, "m must be 'sm.byteLength - crypto_sign_BYTES' bytes");
60205
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
60206
- const res = binding.crypto_sign_open(m, sm, pk);
60207
- if (res !== 0)
60208
- throw new Error("status: " + res);
60209
- };
60210
- exports.crypto_sign_open = function(m, sm, pk) {
60211
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60212
- assert2(ArrayBuffer.isView(sm), "sm must be a typed array");
60213
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60214
- assert2(sm.byteLength >= binding.crypto_sign_BYTES, "sm must be at least 'crypto_sign_BYTES' bytes");
60215
- assert2(m.byteLength === sm.byteLength - binding.crypto_sign_BYTES, "m must be 'sm.byteLength - crypto_sign_BYTES' bytes");
60216
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
60217
- return binding.crypto_sign_open(m, sm, pk);
60218
- };
60219
- exports.crypto_sign_detached = function(sig, m, sk) {
60220
- assert2(ArrayBuffer.isView(sig), "sig must be a typed array");
60221
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60222
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60223
- assert2(sig.byteLength === binding.crypto_sign_BYTES, "sig must be 'crypto_sign_BYTES' bytes");
60224
- assert2(sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes");
60225
- const res = binding.crypto_sign_detached(sig, m, sk);
60226
- if (res !== 0)
60227
- throw new Error("status: " + res);
60228
- };
60229
- exports.crypto_sign_verify_detached = function(sig, m, pk) {
60230
- assert2(ArrayBuffer.isView(sig), "sig must be a typed array");
60231
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60232
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60233
- assert2(sig.byteLength >= binding.crypto_sign_BYTES, "sig must be at least 'crypto_sign_BYTES' bytes");
60234
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
60235
- return binding.crypto_sign_verify_detached(sig.buffer, sig.byteOffset, sig.byteLength, m.buffer, m.byteOffset, m.byteLength, pk.buffer, pk.byteOffset, pk.byteLength);
60236
- };
60237
- exports.crypto_sign_ed25519_sk_to_pk = function(pk, sk) {
60238
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60239
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60240
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
60241
- assert2(sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes");
60242
- const res = binding.crypto_sign_ed25519_sk_to_pk(pk, sk);
60243
- if (res !== 0)
60244
- throw new Error("status: " + res);
60245
- };
60246
- exports.crypto_sign_ed25519_pk_to_curve25519 = function(x25519pk, ed25519pk) {
60247
- assert2(ArrayBuffer.isView(x25519pk), "x25519pk must be a typed array");
60248
- assert2(ArrayBuffer.isView(ed25519pk), "ed25519pk must be a typed array");
60249
- assert2(x25519pk.byteLength === binding.crypto_box_PUBLICKEYBYTES, "x25519pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60250
- assert2(ed25519pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "ed25519pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
60251
- const res = binding.crypto_sign_ed25519_pk_to_curve25519(x25519pk, ed25519pk);
60252
- if (res !== 0)
60253
- throw new Error("status: " + res);
60254
- };
60255
- exports.crypto_sign_ed25519_sk_to_curve25519 = function(x25519sk, ed25519sk) {
60256
- assert2(ArrayBuffer.isView(x25519sk), "x25519sk must be a typed array");
60257
- assert2(ArrayBuffer.isView(ed25519sk), "ed25519sk must be a typed array");
60258
- assert2(x25519sk.byteLength === binding.crypto_box_SECRETKEYBYTES, "x25519sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60259
- const edLen = ed25519sk.byteLength;
60260
- assert2(edLen === binding.crypto_sign_SECRETKEYBYTES || edLen === binding.crypto_box_SECRETKEYBYTES, "ed25519sk must be 'crypto_sign_SECRETKEYBYTES' or 'crypto_sign_SECRETKEYBYTES - crypto_sign_PUBLICKEYBYTES' bytes");
60261
- const res = binding.crypto_sign_ed25519_sk_to_curve25519(x25519sk, ed25519sk);
60262
- if (res !== 0)
60263
- throw new Error("status: " + res);
60264
- };
60265
- exports.crypto_box_keypair = function(pk, sk) {
60266
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60267
- assert2(pk.byteLength === binding.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60268
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60269
- assert2(sk.byteLength === binding.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60270
- const res = binding.crypto_box_keypair(pk, sk);
60271
- if (res !== 0)
60272
- throw new Error("status: " + res);
60273
- };
60274
- exports.crypto_box_seed_keypair = function(pk, sk, seed) {
60275
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60276
- assert2(pk.byteLength === binding.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60277
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60278
- assert2(sk.byteLength === binding.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60279
- assert2(ArrayBuffer.isView(seed), "seed must be a typed array");
60280
- assert2(seed.byteLength === binding.crypto_box_SEEDBYTES, "seed must be 'crypto_box_SEEDBYTES' bytes");
60281
- const res = binding.crypto_box_seed_keypair(pk, sk, seed);
60282
- if (res !== 0)
60283
- throw new Error("status: " + res);
60284
- };
60285
- exports.crypto_box_easy = function(c, m, n, pk, sk) {
60286
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60287
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60288
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60289
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60290
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60291
- assert2(c.byteLength === m.byteLength + exports.crypto_box_MACBYTES, "c must be 'm.byteLength + crypto_box_MACBYTES' bytes");
60292
- assert2(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes");
60293
- assert2(pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60294
- assert2(sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60295
- const res = binding.crypto_box_easy(c, m, n, pk, sk);
60296
- if (res !== 0)
60297
- throw new Error("status: " + res);
60298
- };
60299
- exports.crypto_box_detached = function(c, mac, m, n, pk, sk) {
60300
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60301
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
60302
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60303
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60304
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60305
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60306
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60307
- assert2(mac.byteLength === exports.crypto_box_MACBYTES, "mac must be 'crypto_box_MACBYTES' bytes");
60308
- assert2(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes");
60309
- assert2(pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60310
- assert2(sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60311
- const res = binding.crypto_box_detached(c, mac, m, n, pk, sk);
60312
- if (res !== 0)
60313
- throw new Error("status: " + res);
60314
- };
60315
- exports.crypto_box_open_easy = function(m, c, n, pk, sk) {
60316
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60317
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60318
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60319
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60320
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60321
- assert2(c.byteLength >= exports.crypto_box_MACBYTES, "c must be at least 'crypto_box_MACBYTES' bytes");
60322
- assert2(m.byteLength === c.byteLength - exports.crypto_box_MACBYTES, "m must be 'c.byteLength - crypto_box_MACBYTES' bytes");
60323
- assert2(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes");
60324
- assert2(pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60325
- assert2(sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60326
- return binding.crypto_box_open_easy(m, c, n, pk, sk);
60327
- };
60328
- exports.crypto_box_open_detached = function(m, c, mac, n, pk, sk) {
60329
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60330
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60331
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
60332
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60333
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60334
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60335
- assert2(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes");
60336
- assert2(mac.byteLength === exports.crypto_box_MACBYTES, "mac must be 'crypto_box_MACBYTES' bytes");
60337
- assert2(n.byteLength === exports.crypto_box_NONCEBYTES, "n must be 'crypto_box_NONCEBYTES' bytes");
60338
- assert2(pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60339
- assert2(sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60340
- return binding.crypto_box_open_detached(m, c, mac, n, pk, sk);
60341
- };
60342
- exports.crypto_box_seal = function(c, m, pk) {
60343
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60344
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60345
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60346
- assert2(c.byteLength === m.byteLength + exports.crypto_box_SEALBYTES, "c must be 'm.byteLength + crypto_box_SEALBYTES' bytes");
60347
- assert2(pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60348
- const res = binding.crypto_box_seal(c, m, pk);
60349
- if (res !== 0)
60350
- throw new Error("status: " + res);
60351
- };
60352
- exports.crypto_box_seal_open = function(m, c, pk, sk) {
60353
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60354
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60355
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60356
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60357
- assert2(c.byteLength >= exports.crypto_box_SEALBYTES, "c must be at least 'crypto_box_SEALBYTES' bytes");
60358
- assert2(m.byteLength === c.byteLength - exports.crypto_box_SEALBYTES, "m must be 'c.byteLength - crypto_box_SEALBYTES' bytes");
60359
- assert2(pk.byteLength === exports.crypto_box_PUBLICKEYBYTES, "pk must be 'crypto_box_PUBLICKEYBYTES' bytes");
60360
- assert2(sk.byteLength === exports.crypto_box_SECRETKEYBYTES, "sk must be 'crypto_box_SECRETKEYBYTES' bytes");
60361
- 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);
60362
- };
60363
- exports.crypto_secretbox_easy = function(c, m, n, k) {
60364
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60365
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60366
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60367
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60368
- assert2(c.byteLength === m.byteLength + binding.crypto_secretbox_MACBYTES, "c must be 'm.byteLength + crypto_secretbox_MACBYTES' bytes");
60369
- assert2(n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes");
60370
- assert2(k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes");
60371
- const res = binding.crypto_secretbox_easy(c, m, n, k);
60372
- if (res !== 0)
60373
- throw new Error("status: " + res);
60374
- };
60375
- exports.crypto_secretbox_open_easy = function(m, c, n, k) {
60376
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60377
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60378
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60379
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60380
- assert2(c.byteLength >= binding.crypto_secretbox_MACBYTES, "c must be at least 'crypto_secretbox_MACBYTES' bytes");
60381
- assert2(m.byteLength === c.byteLength - binding.crypto_secretbox_MACBYTES, "m must be 'c.byteLength - crypto_secretbox_MACBYTES' bytes");
60382
- assert2(n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes");
60383
- assert2(k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes");
60384
- return binding.crypto_secretbox_open_easy(m, c, n, k);
60385
- };
60386
- exports.crypto_secretbox_detached = function(c, mac, m, n, k) {
60387
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60388
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
60389
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60390
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60391
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60392
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60393
- assert2(mac.byteLength === binding.crypto_secretbox_MACBYTES, "mac must be 'crypto_secretbox_MACBYTES' bytes");
60394
- assert2(n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes");
60395
- assert2(k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes");
60396
- const res = binding.crypto_secretbox_detached(c, mac, m, n, k);
60397
- if (res !== 0)
60398
- throw new Error("status: " + res);
60399
- };
60400
- exports.crypto_secretbox_open_detached = function(m, c, mac, n, k) {
60401
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60402
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60403
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
60404
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60405
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60406
- assert2(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes");
60407
- assert2(mac.byteLength === binding.crypto_secretbox_MACBYTES, "mac must be 'crypto_secretbox_MACBYTES' bytes");
60408
- assert2(n.byteLength === binding.crypto_secretbox_NONCEBYTES, "n must be 'crypto_secretbox_NONCEBYTES' bytes");
60409
- assert2(k.byteLength === binding.crypto_secretbox_KEYBYTES, "k must be 'crypto_secretbox_KEYBYTES' bytes");
60410
- return binding.crypto_secretbox_open_detached(m, c, mac, n, k);
60411
- };
60412
- exports.crypto_generichash = function(output2, input, key) {
60413
- if (!key)
60414
- key = OPTIONAL;
60415
- assert2(ArrayBuffer.isView(output2), "output must be a typed array");
60416
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
60417
- assert2(output2.byteLength >= binding.crypto_generichash_BYTES_MIN && output2.byteLength <= binding.crypto_generichash_BYTES_MAX, "output must be between crypto_generichash_BYTES_MIN and crypto_generichash_BYTES_MAX bytes");
60418
- if (key !== OPTIONAL) {
60419
- assert2(ArrayBuffer.isView(key), "key must be a typed array");
60420
- assert2(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");
60421
- }
60422
- const res = binding.crypto_generichash(output2.buffer, output2.byteOffset, output2.byteLength, input.buffer, input.byteOffset, input.byteLength, key.buffer, key.byteOffset, key.byteLength);
60423
- if (res !== 0)
60424
- throw new Error("status: " + res);
60425
- };
60426
- exports.crypto_generichash_batch = function(output2, batch, key) {
60427
- assert2(ArrayBuffer.isView(output2), "output must be a typed array");
60428
- if (isNode || batch.length < 4) {
60429
- const res = binding.crypto_generichash_batch(output2, batch, !!key, key || OPTIONAL);
60430
- if (res !== 0)
60431
- throw new Error("status: " + res);
60432
- } else {
60433
- const state = Buffer.alloc(binding.crypto_generichash_STATEBYTES);
60434
- exports.crypto_generichash_init(state, key, output2.byteLength);
60435
- for (const buf of batch) {
60436
- exports.crypto_generichash_update(state, buf);
60437
- }
60438
- exports.crypto_generichash_final(state, output2);
60439
- }
60440
- };
60441
- exports.crypto_generichash_keygen = function(key) {
60442
- assert2(ArrayBuffer.isView(key), "key must be a typed array");
60443
- assert2(key.byteLength === binding.crypto_generichash_KEYBYTES, "key must be 'crypto_generichash_KEYBYTES' bytes");
60444
- const res = binding.crypto_generichash_keygen(key.buffer, key.byteOffset, key.byteLength);
60445
- if (res !== 0)
60446
- throw new Error("status: " + res);
60447
- };
60448
- exports.crypto_generichash_init = function(state, key, outputLength) {
60449
- if (!key)
60450
- key = OPTIONAL;
60451
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60452
- assert2(state.byteLength === binding.crypto_generichash_STATEBYTES, "state must be 'crypto_generichash_STATEBYTES' bytes");
60453
- const res = binding.crypto_generichash_init(state.buffer, state.byteOffset, state.byteLength, key.buffer, key.byteOffset, key.byteLength, outputLength);
60454
- if (res !== 0)
60455
- throw new Error("status: " + res);
60456
- };
60457
- exports.crypto_generichash_update = function(state, input) {
60458
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60459
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
60460
- assert2(state.byteLength === binding.crypto_generichash_STATEBYTES, "state must be 'crypto_generichash_STATEBYTES' bytes");
60461
- const res = binding.crypto_generichash_update(state.buffer, state.byteOffset, state.byteLength, input.buffer, input.byteOffset, input.byteLength);
60462
- if (res !== 0)
60463
- throw new Error("status: " + res);
60464
- };
60465
- exports.crypto_generichash_final = function(state, output2) {
60466
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60467
- assert2(ArrayBuffer.isView(output2), "output must be a typed array");
60468
- assert2(state.byteLength === binding.crypto_generichash_STATEBYTES, "state must be 'crypto_generichash_STATEBYTES' bytes");
60469
- const res = binding.crypto_generichash_final(state.buffer, state.byteOffset, state.byteLength, output2.buffer, output2.byteOffset, output2.byteLength);
60470
- if (res !== 0)
60471
- throw new Error("status: " + res);
60472
- };
60473
- exports.crypto_secretstream_xchacha20poly1305_keygen = function(k) {
60474
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60475
- assert2(k.byteLength === binding.crypto_secretstream_xchacha20poly1305_KEYBYTES, "k must be 'crypto_secretstream_xchacha20poly1305_KEYBYTES' bytes");
60476
- binding.crypto_secretstream_xchacha20poly1305_keygen(k.buffer, k.byteOffset, k.byteLength);
60477
- };
60478
- exports.crypto_secretstream_xchacha20poly1305_init_push = function(state, header, k) {
60479
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60480
- assert2(ArrayBuffer.isView(header), "header must be a typed array");
60481
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60482
- assert2(state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes");
60483
- assert2(header.byteLength === binding.crypto_secretstream_xchacha20poly1305_HEADERBYTES, "header must be 'crypto_secretstream_xchacha20poly1305_HEADERBYTES' bytes");
60484
- assert2(k.byteLength === binding.crypto_secretstream_xchacha20poly1305_KEYBYTES, "k must be 'crypto_secretstream_xchacha20poly1305_KEYBYTES' bytes");
60485
- 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);
60486
- if (res !== 0)
60487
- throw new Error("status: " + res);
60488
- };
60489
- exports.crypto_secretstream_xchacha20poly1305_init_pull = function(state, header, k) {
60490
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60491
- assert2(ArrayBuffer.isView(header), "header must be a typed array");
60492
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60493
- assert2(state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes");
60494
- assert2(header.byteLength === binding.crypto_secretstream_xchacha20poly1305_HEADERBYTES, "header must be 'crypto_secretstream_xchacha20poly1305_HEADERBYTES' bytes");
60495
- assert2(k.byteLength === binding.crypto_secretstream_xchacha20poly1305_KEYBYTES, "k must be 'crypto_secretstream_xchacha20poly1305_KEYBYTES' bytes");
60496
- 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);
60497
- if (res !== 0)
60498
- throw new Error("status: " + res);
60499
- };
60500
- exports.crypto_secretstream_xchacha20poly1305_push = function(state, c, m, ad, tag) {
60501
- if (!ad)
60502
- ad = OPTIONAL;
60503
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60504
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60505
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60506
- assert2(state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes");
60507
- assert2(c.byteLength === m.byteLength + binding.crypto_secretstream_xchacha20poly1305_ABYTES, "c must be 'm.byteLength + crypto_secretstream_xchacha20poly1305_ABYTES' bytes");
60508
- 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);
60509
- if (res < 0)
60510
- throw new Error("push failed");
60511
- return res;
60512
- };
60513
- exports.crypto_secretstream_xchacha20poly1305_pull = function(state, m, tag, c, ad) {
60514
- if (!ad)
60515
- ad = OPTIONAL;
60516
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60517
- assert2(state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes");
60518
- assert2(ArrayBuffer.isView(tag), "tag must be a typed array");
60519
- assert2(tag.byteLength === 1, "tag must be 1 byte");
60520
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60521
- assert2(c.byteLength >= binding.crypto_secretstream_xchacha20poly1305_ABYTES, "c must be at least 'crypto_secretstream_xchacha20poly1305_ABYTES' bytes");
60522
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60523
- assert2(m.byteLength === c.byteLength - binding.crypto_secretstream_xchacha20poly1305_ABYTES, "m must be 'c.byteLength - crypto_secretstream_xchacha20poly1305_ABYTES' bytes");
60524
- 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);
60525
- if (res < 0)
60526
- throw new Error("pull failed");
60527
- return res;
60528
- };
60529
- exports.crypto_secretstream_xchacha20poly1305_rekey = function(state) {
60530
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60531
- assert2(state.byteLength === binding.crypto_secretstream_xchacha20poly1305_STATEBYTES, "state must be 'crypto_secretstream_xchacha20poly1305_STATEBYTES' bytes");
60532
- binding.crypto_secretstream_xchacha20poly1305_rekey(state.buffer, state.byteOffset, state.byteLength);
60533
- };
60534
- exports.crypto_stream = function(c, n, k) {
60535
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60536
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60537
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60538
- assert2(n.byteLength === binding.crypto_stream_NONCEBYTES, "n must be 'crypto_stream_NONCEBYTES' bytes");
60539
- assert2(k.byteLength === binding.crypto_stream_KEYBYTES, "k must be 'crypto_stream_KEYBYTES' bytes");
60540
- const res = binding.crypto_stream(c, n, k);
60541
- if (res !== 0)
60542
- throw new Error("status: " + res);
60543
- };
60544
- exports.crypto_stream_xor = function(c, m, n, k) {
60545
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60546
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60547
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60548
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60549
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60550
- assert2(n.byteLength === binding.crypto_stream_NONCEBYTES, "n must be 'crypto_stream_NONCEBYTES' bytes");
60551
- assert2(k.byteLength === binding.crypto_stream_KEYBYTES, "k must be 'crypto_stream_KEYBYTES' bytes");
60552
- 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);
60553
- if (res !== 0)
60554
- throw new Error("status: " + res);
60555
- };
60556
- exports.crypto_stream_chacha20 = function(c, n, k) {
60557
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60558
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60559
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60560
- assert2(n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes");
60561
- assert2(k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes");
60562
- const res = binding.crypto_stream_chacha20(c, n, k);
60563
- if (res !== 0)
60564
- throw new Error("status: " + res);
60565
- };
60566
- exports.crypto_stream_chacha20_xor = function(c, m, n, k) {
60567
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60568
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60569
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60570
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60571
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60572
- assert2(n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes");
60573
- assert2(k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes");
60574
- const res = binding.crypto_stream_chacha20_xor(c, m, n, k);
60575
- if (res !== 0)
60576
- throw new Error("status: " + res);
60577
- };
60578
- exports.crypto_stream_chacha20_xor_ic = function(c, m, n, ic, k) {
60579
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60580
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60581
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60582
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60583
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60584
- assert2(n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes");
60585
- assert2(k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes");
60586
- const res = binding.crypto_stream_chacha20_xor_ic(c, m, n, ic, k);
60587
- if (res !== 0)
60588
- throw new Error("status: " + res);
60589
- };
60590
- exports.crypto_stream_chacha20_ietf = function(c, n, k) {
60591
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60592
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60593
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60594
- assert2(n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes");
60595
- assert2(k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes");
60596
- const res = binding.crypto_stream_chacha20_ietf(c, n, k);
60597
- if (res !== 0)
60598
- throw new Error("status: " + res);
60599
- };
60600
- exports.crypto_stream_chacha20_ietf_xor = function(c, m, n, k) {
60601
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60602
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60603
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60604
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60605
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60606
- assert2(n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes");
60607
- assert2(k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes");
60608
- const res = binding.crypto_stream_chacha20_ietf_xor(c, m, n, k);
60609
- if (res !== 0)
60610
- throw new Error("status: " + res);
60611
- };
60612
- exports.crypto_stream_chacha20_ietf_xor_ic = function(c, m, n, ic, k) {
60613
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60614
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60615
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60616
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60617
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60618
- assert2(n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes");
60619
- assert2(k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes");
60620
- const res = binding.crypto_stream_chacha20_ietf_xor_ic(c, m, n, ic, k);
60621
- if (res !== 0)
60622
- throw new Error("status: " + res);
60623
- };
60624
- exports.crypto_stream_xchacha20 = function(c, n, k) {
60625
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60626
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60627
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60628
- assert2(n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes");
60629
- assert2(k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes");
60630
- const res = binding.crypto_stream_xchacha20(c, n, k);
60631
- if (res !== 0)
60632
- throw new Error("status: " + res);
60633
- };
60634
- exports.crypto_stream_xchacha20_xor = function(c, m, n, k) {
60635
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60636
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60637
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60638
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60639
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60640
- assert2(n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes");
60641
- assert2(k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes");
60642
- const res = binding.crypto_stream_xchacha20_xor(c, m, n, k);
60643
- if (res !== 0)
60644
- throw new Error("status: " + res);
60645
- };
60646
- exports.crypto_stream_xchacha20_xor_ic = function(c, m, n, ic, k) {
60647
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60648
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60649
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60650
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60651
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60652
- assert2(n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes");
60653
- assert2(k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes");
60654
- const res = binding.crypto_stream_xchacha20_xor_ic(c, m, n, ic, k);
60655
- if (res !== 0)
60656
- throw new Error("status: " + res);
60657
- };
60658
- exports.crypto_stream_salsa20 = function(c, n, k) {
60659
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60660
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60661
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60662
- assert2(n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes");
60663
- assert2(k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes");
60664
- const res = binding.crypto_stream_salsa20(c, n, k);
60665
- if (res !== 0)
60666
- throw new Error("status: " + res);
60667
- };
60668
- exports.crypto_stream_salsa20_xor = function(c, m, n, k) {
60669
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60670
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60671
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60672
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60673
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60674
- assert2(n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes");
60675
- assert2(k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes");
60676
- const res = binding.crypto_stream_salsa20_xor(c, m, n, k);
60677
- if (res !== 0)
60678
- throw new Error("status: " + res);
60679
- };
60680
- exports.crypto_stream_salsa20_xor_ic = function(c, m, n, ic, k) {
60681
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
60682
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
60683
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60684
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60685
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
60686
- assert2(n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes");
60687
- assert2(k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes");
60688
- const res = binding.crypto_stream_salsa20_xor_ic(c, m, n, ic, k);
60689
- if (res !== 0)
60690
- throw new Error("status: " + res);
60691
- };
60692
- exports.crypto_auth = function(out, input, k) {
60693
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60694
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
60695
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60696
- assert2(out.byteLength === binding.crypto_auth_BYTES, "out must be 'crypto_auth_BYTES' bytes");
60697
- assert2(k.byteLength === binding.crypto_auth_KEYBYTES, "k must be 'crypto_auth_KEYBYTES' bytes");
60698
- const res = binding.crypto_auth(out, input, k);
60699
- if (res !== 0)
60700
- throw new Error("status: " + res);
60701
- };
60702
- exports.crypto_auth_verify = function(h, input, k) {
60703
- assert2(ArrayBuffer.isView(h), "h must be a typed array");
60704
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
60705
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60706
- assert2(h.byteLength === binding.crypto_auth_BYTES, "h must be 'crypto_auth_BYTES' bytes");
60707
- assert2(k.byteLength === binding.crypto_auth_KEYBYTES, "k must be 'crypto_auth_KEYBYTES' bytes");
60708
- return binding.crypto_auth_verify(h, input, k);
60709
- };
60710
- exports.crypto_onetimeauth = function(out, input, k) {
60711
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60712
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
60713
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60714
- assert2(out.byteLength === binding.crypto_onetimeauth_BYTES, "out must be 'crypto_onetimeauth_BYTES' bytes");
60715
- assert2(k.byteLength === binding.crypto_onetimeauth_KEYBYTES, "k must be 'crypto_onetimeauth_KEYBYTES' bytes");
60716
- const res = binding.crypto_onetimeauth(out, input, k);
60717
- if (res !== 0)
60718
- throw new Error("status: " + res);
60719
- };
60720
- exports.crypto_onetimeauth_init = function(state, k) {
60721
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60722
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60723
- assert2(state.byteLength === binding.crypto_onetimeauth_STATEBYTES, "state must be 'crypto_onetimeauth_STATEBYTES' bytes");
60724
- assert2(k.byteLength === binding.crypto_onetimeauth_KEYBYTES, "k must be 'crypto_onetimeauth_KEYBYTES' bytes");
60725
- const res = binding.crypto_onetimeauth_init(state, k);
60726
- if (res !== 0)
60727
- throw new Error("status: " + res);
60728
- };
60729
- exports.crypto_onetimeauth_update = function(state, input) {
60730
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60731
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
60732
- assert2(state.byteLength === binding.crypto_onetimeauth_STATEBYTES, "state must be 'crypto_onetimeauth_STATEBYTES' bytes");
60733
- const res = binding.crypto_onetimeauth_update(state, input);
60734
- if (res !== 0)
60735
- throw new Error("status: " + res);
60736
- };
60737
- exports.crypto_onetimeauth_final = function(state, out) {
60738
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
60739
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60740
- assert2(state.byteLength === binding.crypto_onetimeauth_STATEBYTES, "state must be 'crypto_onetimeauth_STATEBYTES' bytes");
60741
- assert2(out.byteLength === binding.crypto_onetimeauth_BYTES, "out must be 'crypto_onetimeauth_BYTES' bytes");
60742
- const res = binding.crypto_onetimeauth_final(state, out);
60743
- if (res !== 0)
60744
- throw new Error("status: " + res);
60745
- };
60746
- exports.crypto_onetimeauth_verify = function(h, input, k) {
60747
- assert2(ArrayBuffer.isView(h), "h must be a typed array");
60748
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
60749
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
60750
- assert2(h.byteLength === binding.crypto_onetimeauth_BYTES, "h must be 'crypto_onetimeauth_BYTES' bytes");
60751
- assert2(k.byteLength === binding.crypto_onetimeauth_KEYBYTES, "k must be 'crypto_onetimeauth_KEYBYTES' bytes");
60752
- return binding.crypto_onetimeauth_verify(h, input, k);
60753
- };
60754
- exports.crypto_pwhash = function(out, passwd, salt, opslimit, memlimit, alg) {
60755
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60756
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60757
- assert2(ArrayBuffer.isView(salt), "salt must be a typed array");
60758
- assert2(out.byteLength >= binding.crypto_pwhash_BYTES_MIN, "out must be at least 'crypto_pwhash_BYTES_MIN' bytes");
60759
- assert2(out.byteLength <= binding.crypto_pwhash_BYTES_MAX, "out must be at most 'crypto_pwhash_BYTES_MAX' bytes");
60760
- assert2(salt.byteLength === binding.crypto_pwhash_SALTBYTES, "salt must be 'crypto_pwhash_SALTBYTES' bytes");
60761
- assert2(opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'");
60762
- assert2(opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'");
60763
- assert2(memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'");
60764
- assert2(memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'");
60765
- assert2(alg >= 1 && alg <= 2, "alg must be either Argon2i 1.3 or Argon2id 1.3");
60766
- const res = binding.crypto_pwhash(out, passwd, salt, opslimit, memlimit, alg);
60767
- if (res !== 0)
60768
- throw new Error("status: " + res);
60769
- };
60770
- exports.crypto_pwhash_async = function(out, passwd, salt, opslimit, memlimit, alg, callback = undefined) {
60771
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60772
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60773
- assert2(ArrayBuffer.isView(salt), "salt must be a typed array");
60774
- assert2(out.byteLength >= binding.crypto_pwhash_BYTES_MIN, "out must be at least 'crypto_pwhash_BYTES_MIN' bytes");
60775
- assert2(out.byteLength <= binding.crypto_pwhash_BYTES_MAX, "out must be at most 'crypto_pwhash_BYTES_MAX' bytes");
60776
- assert2(salt.byteLength === binding.crypto_pwhash_SALTBYTES, "salt must be 'crypto_pwhash_SALTBYTES' bytes");
60777
- assert2(opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'");
60778
- assert2(opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'");
60779
- assert2(memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'");
60780
- assert2(memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'");
60781
- assert2(alg >= 1 && alg <= 2, "alg must be either Argon2i 1.3 or Argon2id 1.3");
60782
- const [done, promise] = checkStatus(callback);
60783
- 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);
60784
- return promise;
60785
- };
60786
- exports.crypto_pwhash_str = function(out, passwd, opslimit, memlimit) {
60787
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60788
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60789
- assert2(out.byteLength === binding.crypto_pwhash_STRBYTES, "out must be 'crypto_pwhash_STRBYTES' bytes");
60790
- assert2(typeof opslimit === "number", "opslimit must be a number");
60791
- assert2(opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'");
60792
- assert2(opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'");
60793
- assert2(typeof memlimit === "number", "memlimit must be a number");
60794
- assert2(memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'");
60795
- assert2(memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'");
60796
- const res = binding.crypto_pwhash_str(out, passwd, opslimit, memlimit);
60797
- if (res !== 0)
60798
- throw new Error("status: " + res);
60799
- };
60800
- exports.crypto_pwhash_str_async = function(out, passwd, opslimit, memlimit, callback = undefined) {
60801
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60802
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60803
- assert2(out.byteLength === binding.crypto_pwhash_STRBYTES, "out must be 'crypto_pwhash_STRBYTES' bytes");
60804
- assert2(passwd.byteLength > 0, "passwd must not be empty");
60805
- assert2(typeof opslimit === "number", "opslimit must be a number");
60806
- assert2(opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'");
60807
- assert2(opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'");
60808
- assert2(typeof memlimit === "number", "memlimit must be a number");
60809
- assert2(memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'");
60810
- assert2(memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'");
60811
- const [done, promise] = checkStatus(callback);
60812
- binding.crypto_pwhash_str_async(out.buffer, out.byteOffset, out.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, opslimit, memlimit, done);
60813
- return promise;
60814
- };
60815
- exports.crypto_pwhash_str_verify = function(str, passwd) {
60816
- assert2(ArrayBuffer.isView(str), "str must be a typed array");
60817
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60818
- assert2(str.byteLength === binding.crypto_pwhash_STRBYTES, "str must be 'crypto_pwhash_STRBYTES' bytes");
60819
- return binding.crypto_pwhash_str_verify(str, passwd);
60820
- };
60821
- exports.crypto_pwhash_str_verify_async = function(str, passwd, callback = undefined) {
60822
- assert2(ArrayBuffer.isView(str), "str must be a typed array");
60823
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60824
- assert2(str.byteLength === binding.crypto_pwhash_STRBYTES, "str must be 'crypto_pwhash_STRBYTES' bytes");
60825
- assert2(passwd.byteLength > 0, "passwd must not be empty");
60826
- const [done, promise] = checkStatus(callback, true);
60827
- binding.crypto_pwhash_str_verify_async(str.buffer, str.byteOffset, str.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, done);
60828
- return promise;
60829
- };
60830
- exports.crypto_pwhash_str_needs_rehash = function(str, opslimit, memlimit) {
60831
- assert2(ArrayBuffer.isView(str), "str must be a typed array");
60832
- assert2(str.byteLength === binding.crypto_pwhash_STRBYTES, "str must be 'crypto_pwhash_STRBYTES' bytes");
60833
- assert2(opslimit >= binding.crypto_pwhash_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_OPSLIMIT_MIN'");
60834
- assert2(opslimit <= binding.crypto_pwhash_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_OPSLIMIT_MAX'");
60835
- assert2(memlimit >= binding.crypto_pwhash_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_MEMLIMIT_MIN'");
60836
- assert2(memlimit <= binding.crypto_pwhash_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_MEMLIMIT_MAX'");
60837
- return binding.crypto_pwhash_str_needs_rehash(str, opslimit, memlimit);
60838
- };
60839
- exports.crypto_pwhash_scryptsalsa208sha256 = function(out, passwd, salt, opslimit, memlimit) {
60840
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60841
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60842
- assert2(ArrayBuffer.isView(salt), "salt must be a typed array");
60843
- assert2(out.byteLength >= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MIN, "out must be at least 'crypto_pwhash_scryptsalsa208sha256_BYTES_MIN' bytes");
60844
- assert2(out.byteLength <= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MAX, "out must be at most 'crypto_pwhash_scryptsalsa208sha256_BYTES_MAX' bytes");
60845
- assert2(salt.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_SALTBYTES, "salt must be 'crypto_pwhash_scryptsalsa208sha256_SALTBYTES' bytes");
60846
- assert2(opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'");
60847
- assert2(opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'");
60848
- assert2(memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'");
60849
- assert2(memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'");
60850
- const res = binding.crypto_pwhash_scryptsalsa208sha256(out, passwd, salt, opslimit, memlimit);
60851
- if (res !== 0)
60852
- throw new Error("status: " + res);
60853
- };
60854
- exports.crypto_pwhash_scryptsalsa208sha256_async = function(out, passwd, salt, opslimit, memlimit, callback = undefined) {
60855
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60856
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60857
- assert2(ArrayBuffer.isView(salt), "salt must be a typed array");
60858
- assert2(out.byteLength >= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MIN, "out must be at least 'crypto_pwhash_scryptsalsa208sha256_BYTES_MIN' bytes");
60859
- assert2(out.byteLength <= binding.crypto_pwhash_scryptsalsa208sha256_BYTES_MAX, "out must be at most 'crypto_pwhash_scryptsalsa208sha256_BYTES_MAX' bytes");
60860
- assert2(passwd.byteLength > 0, "passwd must not be empty");
60861
- assert2(salt.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_SALTBYTES, "salt must be 'crypto_pwhash_scryptsalsa208sha256_SALTBYTES' bytes");
60862
- assert2(opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'");
60863
- assert2(opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'");
60864
- assert2(memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'");
60865
- assert2(memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'");
60866
- const [done, promise] = checkStatus(callback);
60867
- 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);
60868
- return promise;
60869
- };
60870
- exports.crypto_pwhash_scryptsalsa208sha256_str_async = function(out, passwd, opslimit, memlimit, callback = undefined) {
60871
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60872
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60873
- assert2(out.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "out must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes");
60874
- assert2(passwd.byteLength > 0, "passwd must not be empty");
60875
- assert2(opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'");
60876
- assert2(opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'");
60877
- assert2(memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'");
60878
- assert2(memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'");
60879
- const [done, promise] = checkStatus(callback);
60880
- binding.crypto_pwhash_scryptsalsa208sha256_str_async(out.buffer, out.byteOffset, out.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, opslimit, memlimit, done);
60881
- return promise;
60882
- };
60883
- exports.crypto_pwhash_scryptsalsa208sha256_str = function(out, passwd, opslimit, memlimit) {
60884
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
60885
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60886
- assert2(out.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "out must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes");
60887
- assert2(passwd.byteLength > 0, "passwd must not be empty");
60888
- assert2(opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'");
60889
- assert2(opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'");
60890
- assert2(memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'");
60891
- assert2(memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'");
60892
- const res = binding.crypto_pwhash_scryptsalsa208sha256_str(out, passwd, opslimit, memlimit);
60893
- if (res !== 0)
60894
- throw new Error("status: " + res);
60895
- };
60896
- exports.crypto_pwhash_scryptsalsa208sha256_str_verify_async = function(str, passwd, callback = undefined) {
60897
- assert2(ArrayBuffer.isView(str), "str must be a typed array");
60898
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60899
- assert2(str.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "str must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes");
60900
- assert2(passwd.byteLength > 0, "passwd must not be empty");
60901
- const [done, promise] = checkStatus(callback, true);
60902
- binding.crypto_pwhash_scryptsalsa208sha256_str_verify_async(str.buffer, str.byteOffset, str.byteLength, passwd.buffer, passwd.byteOffset, passwd.byteLength, done);
60903
- return promise;
60904
- };
60905
- exports.crypto_pwhash_scryptsalsa208sha256_str_verify = function(str, passwd) {
60906
- assert2(ArrayBuffer.isView(str), "str must be a typed array");
60907
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
60908
- assert2(str.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "str must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes");
60909
- assert2(passwd.byteLength > 0, "passwd must not be empty");
60910
- return binding.crypto_pwhash_scryptsalsa208sha256_str_verify(str, passwd);
60911
- };
60912
- exports.crypto_pwhash_scryptsalsa208sha256_str_needs_rehash = function(str, opslimit, memlimit) {
60913
- assert2(ArrayBuffer.isView(str), "str must be a typed array");
60914
- assert2(str.byteLength === binding.crypto_pwhash_scryptsalsa208sha256_STRBYTES, "str must be 'crypto_pwhash_scryptsalsa208sha256_STRBYTES' bytes");
60915
- assert2(opslimit >= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN, "opslimit must be at least 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN'");
60916
- assert2(opslimit <= binding.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX, "opslimit must be at most 'crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX'");
60917
- assert2(memlimit >= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN, "memlimit must be at least 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN'");
60918
- assert2(memlimit <= binding.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX, "memlimit must be at most 'crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX'");
60919
- return binding.crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(str, opslimit, memlimit);
60920
- };
60921
- exports.crypto_kx_keypair = function(pk, sk) {
60922
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60923
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60924
- assert2(pk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "pk must be 'crypto_kx_PUBLICKEYBYTES' bytes");
60925
- assert2(sk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "sk must be 'crypto_kx_SECRETKEYBYTES' bytes");
60926
- const res = binding.crypto_kx_keypair(pk, sk);
60927
- if (res !== 0)
60928
- throw new Error("status: " + res);
60929
- };
60930
- exports.crypto_kx_seed_keypair = function(pk, sk, seed) {
60931
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
60932
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
60933
- assert2(ArrayBuffer.isView(seed), "seed must be a typed array");
60934
- assert2(pk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "pk must be 'crypto_kx_PUBLICKEYBYTES' bytes");
60935
- assert2(sk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "sk must be 'crypto_kx_SECRETKEYBYTES' bytes");
60936
- assert2(seed.byteLength === binding.crypto_kx_SEEDBYTES, "seed must be 'crypto_kx_SEEDBYTES' bytes");
60937
- const res = binding.crypto_kx_seed_keypair(pk, sk, seed);
60938
- if (res !== 0)
60939
- throw new Error("status: " + res);
60940
- };
60941
- exports.crypto_kx_client_session_keys = function(rx, tx, clientPk, clientSk, serverPk) {
60942
- if (!rx)
60943
- rx = undefined;
60944
- if (!tx)
60945
- tx = undefined;
60946
- assert2(rx || tx, "at least one session key must be specified");
60947
- if (rx) {
60948
- assert2(ArrayBuffer.isView(rx), "rx must be a typed array");
60949
- assert2(rx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "rx must be 'crypto_kx_SESSIONKEYBYTES' bytes");
60950
- }
60951
- if (tx) {
60952
- assert2(ArrayBuffer.isView(tx), "tx must be a typed array");
60953
- assert2(tx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "tx must be 'crypto_kx_SESSIONKEYBYTES' bytes");
60954
- }
60955
- assert2(ArrayBuffer.isView(clientPk), "clientPk must be a typed array");
60956
- assert2(ArrayBuffer.isView(clientSk), "clientSk must be a typed array");
60957
- assert2(ArrayBuffer.isView(serverPk), "serverPk must be a typed array");
60958
- assert2(clientPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "clientPk must be 'crypto_kx_PUBLICKEYBYTES' bytes");
60959
- assert2(clientSk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "clientSk must be 'crypto_kx_SECRETKEYBYTES' bytes");
60960
- assert2(serverPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "serverPk must be 'crypto_kx_PUBLICKEYBYTES' bytes");
60961
- const res = binding.crypto_kx_client_session_keys(rx, tx, clientPk, clientSk, serverPk);
60962
- if (res !== 0)
60963
- throw new Error("status: " + res);
60964
- };
60965
- exports.crypto_kx_server_session_keys = function(rx, tx, serverPk, serverSk, clientPk) {
60966
- if (!rx)
60967
- rx = undefined;
60968
- if (!tx)
60969
- tx = undefined;
60970
- assert2(rx || tx, "at least one session key must be specified");
60971
- if (rx) {
60972
- assert2(ArrayBuffer.isView(rx), "rx must be a typed array");
60973
- assert2(rx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "rx must be 'crypto_kx_SESSIONKEYBYTES' bytes");
60974
- }
60975
- if (tx) {
60976
- assert2(ArrayBuffer.isView(tx), "tx must be a typed array");
60977
- assert2(tx.byteLength === binding.crypto_kx_SESSIONKEYBYTES, "tx must be 'crypto_kx_SESSIONKEYBYTES' bytes");
60978
- }
60979
- assert2(ArrayBuffer.isView(serverPk), "serverPk must be a typed array");
60980
- assert2(ArrayBuffer.isView(serverSk), "serverSk must be a typed array");
60981
- assert2(ArrayBuffer.isView(clientPk), "clientPk must be a typed array");
60982
- assert2(serverPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "serverPk must be 'crypto_kx_PUBLICKEYBYTES' bytes");
60983
- assert2(serverSk.byteLength === binding.crypto_kx_SECRETKEYBYTES, "serverSk must be 'crypto_kx_SECRETKEYBYTES' bytes");
60984
- assert2(clientPk.byteLength === binding.crypto_kx_PUBLICKEYBYTES, "clientPk must be 'crypto_kx_PUBLICKEYBYTES' bytes");
60985
- const res = binding.crypto_kx_server_session_keys(rx, tx, serverPk, serverSk, clientPk);
60986
- if (res !== 0)
60987
- throw new Error("status: " + res);
60988
- };
60989
- exports.crypto_scalarmult_base = function(q, n) {
60990
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
60991
- assert2(q.byteLength === binding.crypto_scalarmult_BYTES, "q must be 'crypto_scalarmult_BYTES' bytes");
60992
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
60993
- assert2(n.byteLength === binding.crypto_scalarmult_SCALARBYTES, "n must be 'crypto_scalarmult_SCALARBYTES' bytes");
60994
- const res = binding.crypto_scalarmult_base(q, n);
60995
- if (res !== 0)
60996
- throw new Error("status: " + res);
60997
- };
60998
- exports.crypto_scalarmult = function(q, n, p) {
60999
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
61000
- assert2(q.byteLength === binding.crypto_scalarmult_BYTES, "q must be 'crypto_scalarmult_BYTES' bytes");
61001
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61002
- assert2(n.byteLength === binding.crypto_scalarmult_SCALARBYTES, "n must be 'crypto_scalarmult_SCALARBYTES' bytes");
61003
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61004
- assert2(p.byteLength === binding.crypto_scalarmult_BYTES, "p must be 'crypto_scalarmult_BYTES' bytes");
61005
- const res = binding.crypto_scalarmult(q, n, p);
61006
- if (res !== 0)
61007
- throw new Error("status: " + res);
61008
- };
61009
- exports.crypto_scalarmult_ed25519_base = function(q, n) {
61010
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
61011
- assert2(q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes");
61012
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61013
- assert2(n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes");
61014
- const res = binding.crypto_scalarmult_ed25519_base(q, n);
61015
- if (res !== 0)
61016
- throw new Error("status: " + res);
61017
- };
61018
- exports.crypto_scalarmult_ed25519 = function(q, n, p) {
61019
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
61020
- assert2(q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes");
61021
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61022
- assert2(n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes");
61023
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61024
- assert2(p.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "p must be 'crypto_scalarmult_ed25519_BYTES' bytes");
61025
- const res = binding.crypto_scalarmult_ed25519(q, n, p);
61026
- if (res !== 0)
61027
- throw new Error("status: " + res);
61028
- };
61029
- exports.crypto_core_ed25519_is_valid_point = function(p) {
61030
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61031
- assert2(p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes");
61032
- return binding.crypto_core_ed25519_is_valid_point(p);
61033
- };
61034
- exports.crypto_core_ed25519_from_uniform = function(p, r) {
61035
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61036
- assert2(p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes");
61037
- assert2(ArrayBuffer.isView(r), "r must be a typed array");
61038
- assert2(r.byteLength === binding.crypto_core_ed25519_UNIFORMBYTES, "r must be 'crypto_core_ed25519_UNIFORMBYTES' bytes");
61039
- const res = binding.crypto_core_ed25519_from_uniform(p, r);
61040
- if (res !== 0)
61041
- throw new Error("status: " + res);
61042
- };
61043
- exports.crypto_scalarmult_ed25519_base_noclamp = function(q, n) {
61044
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
61045
- assert2(q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes");
61046
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61047
- assert2(n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes");
61048
- const res = binding.crypto_scalarmult_ed25519_base_noclamp(q, n);
61049
- if (res !== 0)
61050
- throw new Error("status: " + res);
61051
- };
61052
- exports.crypto_scalarmult_ed25519_noclamp = function(q, n, p) {
61053
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
61054
- assert2(q.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "q must be 'crypto_scalarmult_ed25519_BYTES' bytes");
61055
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61056
- assert2(n.byteLength === binding.crypto_scalarmult_ed25519_SCALARBYTES, "n must be 'crypto_scalarmult_ed25519_SCALARBYTES' bytes");
61057
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61058
- assert2(p.byteLength === binding.crypto_scalarmult_ed25519_BYTES, "p must be 'crypto_scalarmult_ed25519_BYTES' bytes");
61059
- const res = binding.crypto_scalarmult_ed25519_noclamp(q, n, p);
61060
- if (res !== 0)
61061
- throw new Error("status: " + res);
61062
- };
61063
- exports.crypto_core_ed25519_add = function(r, p, q) {
61064
- assert2(ArrayBuffer.isView(r), "r must be a typed array");
61065
- assert2(r.byteLength === binding.crypto_core_ed25519_BYTES, "r must be 'crypto_core_ed25519_BYTES' bytes");
61066
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61067
- assert2(p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes");
61068
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
61069
- assert2(q.byteLength === binding.crypto_core_ed25519_BYTES, "q must be 'crypto_core_ed25519_BYTES' bytes");
61070
- const res = binding.crypto_core_ed25519_add(r, p, q);
61071
- if (res !== 0)
61072
- throw new Error("status: " + res);
61073
- };
61074
- exports.crypto_core_ed25519_sub = function(r, p, q) {
61075
- assert2(ArrayBuffer.isView(r), "r must be a typed array");
61076
- assert2(r.byteLength === binding.crypto_core_ed25519_BYTES, "r must be 'crypto_core_ed25519_BYTES' bytes");
61077
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61078
- assert2(p.byteLength === binding.crypto_core_ed25519_BYTES, "p must be 'crypto_core_ed25519_BYTES' bytes");
61079
- assert2(ArrayBuffer.isView(q), "q must be a typed array");
61080
- assert2(q.byteLength === binding.crypto_core_ed25519_BYTES, "q must be 'crypto_core_ed25519_BYTES' bytes");
61081
- const res = binding.crypto_core_ed25519_sub(r, p, q);
61082
- if (res !== 0)
61083
- throw new Error("status: " + res);
61084
- };
61085
- exports.crypto_core_ed25519_scalar_random = function(r) {
61086
- assert2(ArrayBuffer.isView(r), "r must be a typed array");
61087
- assert2(r.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "r must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61088
- binding.crypto_core_ed25519_scalar_random(r);
61089
- };
61090
- exports.crypto_core_ed25519_scalar_reduce = function(r, s) {
61091
- assert2(ArrayBuffer.isView(r), "r must be a typed array");
61092
- assert2(r.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "r must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61093
- assert2(ArrayBuffer.isView(s), "s must be a typed array");
61094
- assert2(s.byteLength === binding.crypto_core_ed25519_NONREDUCEDSCALARBYTES, "s must be 'crypto_core_ed25519_NONREDUCEDSCALARBYTES' bytes");
61095
- binding.crypto_core_ed25519_scalar_reduce(r, s);
61096
- };
61097
- exports.crypto_core_ed25519_scalar_invert = function(recip, s) {
61098
- assert2(ArrayBuffer.isView(recip), "recip must be a typed array");
61099
- assert2(recip.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "recip must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61100
- assert2(ArrayBuffer.isView(s), "s must be a typed array");
61101
- assert2(s.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "s must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61102
- binding.crypto_core_ed25519_scalar_invert(recip, s);
61103
- };
61104
- exports.crypto_core_ed25519_scalar_negate = function(neg, s) {
61105
- assert2(ArrayBuffer.isView(neg), "neg must be a typed array");
61106
- assert2(neg.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "neg must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61107
- assert2(ArrayBuffer.isView(s), "s must be a typed array");
61108
- assert2(s.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "s must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61109
- binding.crypto_core_ed25519_scalar_negate(neg, s);
61110
- };
61111
- exports.crypto_core_ed25519_scalar_complement = function(comp, s) {
61112
- assert2(ArrayBuffer.isView(comp), "comp must be a typed array");
61113
- assert2(comp.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "comp must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61114
- assert2(ArrayBuffer.isView(s), "s must be a typed array");
61115
- assert2(s.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "s must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61116
- binding.crypto_core_ed25519_scalar_complement(comp, s);
61117
- };
61118
- exports.crypto_core_ed25519_scalar_add = function(z, x, y) {
61119
- assert2(ArrayBuffer.isView(z), "z must be a typed array");
61120
- assert2(z.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "z must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61121
- assert2(ArrayBuffer.isView(x), "x must be a typed array");
61122
- assert2(x.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "x must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61123
- assert2(ArrayBuffer.isView(y), "y must be a typed array");
61124
- assert2(y.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "y must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61125
- binding.crypto_core_ed25519_scalar_add(z, x, y);
61126
- };
61127
- exports.crypto_core_ed25519_scalar_sub = function(z, x, y) {
61128
- assert2(ArrayBuffer.isView(z), "z must be a typed array");
61129
- assert2(z.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "z must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61130
- assert2(ArrayBuffer.isView(x), "x must be a typed array");
61131
- assert2(x.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "x must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61132
- assert2(ArrayBuffer.isView(y), "y must be a typed array");
61133
- assert2(y.byteLength === binding.crypto_core_ed25519_SCALARBYTES, "y must be 'crypto_core_ed25519_SCALARBYTES' bytes");
61134
- binding.crypto_core_ed25519_scalar_sub(z, x, y);
61135
- };
61136
- exports.crypto_shorthash = function(out, input, k) {
61137
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61138
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
61139
- assert2(out.byteLength === binding.crypto_shorthash_BYTES, "out must be 'crypto_shorthash_BYTES' bytes");
61140
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61141
- assert2(k.byteLength === binding.crypto_shorthash_KEYBYTES, "k must be 'crypto_shorthash_KEYBYTES' bytes");
61142
- const res = binding.crypto_shorthash(out, input, k);
61143
- if (res !== 0)
61144
- throw new Error("status: " + res);
61145
- };
61146
- exports.crypto_kdf_keygen = function(key) {
61147
- assert2(ArrayBuffer.isView(key), "key must be a typed array");
61148
- assert2(key.byteLength === binding.crypto_kdf_KEYBYTES, "key must be 'crypto_kdf_KEYBYTES' bytes");
61149
- binding.crypto_kdf_keygen(key);
61150
- };
61151
- exports.crypto_kdf_derive_from_key = function(subkey, subkeyId, ctx, key) {
61152
- assert2(ArrayBuffer.isView(subkey), "subkey must be a typed array");
61153
- assert2(subkey.byteLength >= binding.crypto_kdf_BYTES_MIN, "subkey must be at least 'crypto_kdf_BYTES_MIN' bytes");
61154
- assert2(subkey.byteLength <= binding.crypto_kdf_BYTES_MAX, "subkey must be at most 'crypto_kdf_BYTES_MAX' bytes");
61155
- assert2(ArrayBuffer.isView(ctx), "ctx must be a typed array");
61156
- assert2(ctx.byteLength === binding.crypto_kdf_CONTEXTBYTES, "ctx must be 'crypto_kdf_CONTEXTBYTES' bytes");
61157
- assert2(ArrayBuffer.isView(key), "key must be a typed array");
61158
- assert2(key.byteLength === binding.crypto_kdf_KEYBYTES, "key must be 'crypto_kdf_KEYBYTES' bytes");
61159
- const res = binding.crypto_kdf_derive_from_key(subkey, subkeyId, ctx, key);
61160
- if (res !== 0)
61161
- throw new Error("status: " + res);
61162
- };
61163
- exports.crypto_hash = function(out, input) {
61164
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61165
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
61166
- assert2(out.byteLength === binding.crypto_hash_BYTES, "out must be 'crypto_hash_BYTES' bytes");
61167
- const res = binding.crypto_hash(out, input);
61168
- if (res !== 0)
61169
- throw new Error("status: " + res);
61170
- };
61171
- exports.crypto_hash_sha256 = function(out, input) {
61172
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61173
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
61174
- assert2(out.byteLength === binding.crypto_hash_sha256_BYTES, "out must be 'crypto_hash_sha256_BYTES' bytes");
61175
- const res = binding.crypto_hash_sha256(out, input);
61176
- if (res !== 0)
61177
- throw new Error("status: " + res);
61178
- };
61179
- exports.crypto_hash_sha256_init = function(state) {
61180
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61181
- assert2(state.byteLength === binding.crypto_hash_sha256_STATEBYTES, "state must be 'crypto_hash_sha256_STATEBYTES' bytes");
61182
- const res = binding.crypto_hash_sha256_init(state);
61183
- if (res !== 0)
61184
- throw new Error("status: " + res);
61185
- };
61186
- exports.crypto_hash_sha256_update = function(state, input) {
61187
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61188
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
61189
- assert2(state.byteLength === binding.crypto_hash_sha256_STATEBYTES, "state must be 'crypto_hash_sha256_STATEBYTES' bytes");
61190
- const res = binding.crypto_hash_sha256_update(state, input);
61191
- if (res !== 0)
61192
- throw new Error("status: " + res);
61193
- };
61194
- exports.crypto_hash_sha256_final = function(state, out) {
61195
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61196
- assert2(state.byteLength === binding.crypto_hash_sha256_STATEBYTES, "state must be 'crypto_hash_sha256_STATEBYTES' bytes");
61197
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61198
- assert2(out.byteLength === binding.crypto_hash_sha256_BYTES, "out must be 'crypto_hash_sha256_BYTES' bytes");
61199
- const res = binding.crypto_hash_sha256_final(state, out);
61200
- if (res !== 0)
61201
- throw new Error("status: " + res);
61202
- };
61203
- exports.crypto_hash_sha512 = function(out, input) {
61204
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61205
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
61206
- assert2(out.byteLength === binding.crypto_hash_sha512_BYTES, "out must be 'crypto_hash_sha512_BYTES' bytes");
61207
- const res = binding.crypto_hash_sha512(out, input);
61208
- if (res !== 0)
61209
- throw new Error("status: " + res);
61210
- };
61211
- exports.crypto_hash_sha512_init = function(state) {
61212
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61213
- assert2(state.byteLength === binding.crypto_hash_sha512_STATEBYTES, "state must be 'crypto_hash_sha512_STATEBYTES' bytes");
61214
- const res = binding.crypto_hash_sha512_init(state);
61215
- if (res !== 0)
61216
- throw new Error("status: " + res);
61217
- };
61218
- exports.crypto_hash_sha512_update = function(state, input) {
61219
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61220
- assert2(ArrayBuffer.isView(input), "input must be a typed array");
61221
- assert2(state.byteLength === binding.crypto_hash_sha512_STATEBYTES, "state must be 'crypto_hash_sha512_STATEBYTES' bytes");
61222
- const res = binding.crypto_hash_sha512_update(state, input);
61223
- if (res !== 0)
61224
- throw new Error("status: " + res);
61225
- };
61226
- exports.crypto_hash_sha512_final = function(state, out) {
61227
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61228
- assert2(state.byteLength === binding.crypto_hash_sha512_STATEBYTES, "state must be 'crypto_hash_sha512_STATEBYTES' bytes");
61229
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61230
- assert2(out.byteLength === binding.crypto_hash_sha512_BYTES, "out must be 'crypto_hash_sha512_BYTES' bytes");
61231
- const res = binding.crypto_hash_sha512_final(state, out);
61232
- if (res !== 0)
61233
- throw new Error("status: " + res);
61234
- };
61235
- exports.crypto_aead_xchacha20poly1305_ietf_keygen = function(k) {
61236
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61237
- assert2(k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes");
61238
- binding.crypto_aead_xchacha20poly1305_ietf_keygen(k);
61239
- };
61240
- exports.crypto_aead_xchacha20poly1305_ietf_encrypt = function(c, m, ad, nsec, npub, k) {
61241
- if (!ad)
61242
- ad = undefined;
61243
- assert2(nsec === null, "nsec must always be set to null");
61244
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61245
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61246
- assert2(c.byteLength === m.byteLength + binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "c must be 'm.byteLength + crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes");
61247
- assert2(c.byteLength <= 4294967295, "c.byteLength must be a 32bit integer");
61248
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61249
- assert2(npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes");
61250
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61251
- assert2(k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes");
61252
- const res = binding.crypto_aead_xchacha20poly1305_ietf_encrypt(c, m, ad, npub, k);
61253
- if (res < 0)
61254
- throw new Error("could not encrypt data");
61255
- return res;
61256
- };
61257
- exports.crypto_aead_xchacha20poly1305_ietf_decrypt = function(m, nsec, c, ad, npub, k) {
61258
- if (!ad)
61259
- ad = undefined;
61260
- assert2(nsec === null, "nsec must always be set to null");
61261
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61262
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61263
- assert2(m.byteLength === c.byteLength - binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "m must be 'c.byteLength - crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes");
61264
- assert2(m.byteLength <= 4294967295, "m.byteLength must be a 32bit integer");
61265
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61266
- assert2(npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes");
61267
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61268
- assert2(k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes");
61269
- const res = binding.crypto_aead_xchacha20poly1305_ietf_decrypt(m, c, ad, npub, k);
61270
- if (res < 0)
61271
- throw new Error("could not verify data");
61272
- return res;
61273
- };
61274
- exports.crypto_aead_xchacha20poly1305_ietf_encrypt_detached = function(c, mac, m, ad, nsec, npub, k) {
61275
- if (!ad)
61276
- ad = undefined;
61277
- assert2(nsec === null, "nsec must always be set to null");
61278
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61279
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61280
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
61281
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
61282
- assert2(mac.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes");
61283
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61284
- assert2(npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes");
61285
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61286
- assert2(k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes");
61287
- const res = binding.crypto_aead_xchacha20poly1305_ietf_encrypt_detached(c, mac, m, ad, npub, k);
61288
- if (res < 0)
61289
- throw new Error("could not encrypt data");
61290
- return res;
61291
- };
61292
- exports.crypto_aead_xchacha20poly1305_ietf_decrypt_detached = function(m, nsec, c, mac, ad, npub, k) {
61293
- if (!ad)
61294
- ad = undefined;
61295
- assert2(nsec === null, "nsec must always be set to null");
61296
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61297
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61298
- assert2(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes");
61299
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
61300
- assert2(mac.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_xchacha20poly1305_ietf_ABYTES' bytes");
61301
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61302
- assert2(npub.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_xchacha20poly1305_ietf_NPUBBYTES' bytes");
61303
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61304
- assert2(k.byteLength === binding.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_xchacha20poly1305_ietf_KEYBYTES' bytes");
61305
- const res = binding.crypto_aead_xchacha20poly1305_ietf_decrypt_detached(m, c, mac, ad, npub, k);
61306
- if (res !== 0)
61307
- throw new Error("could not verify data");
61308
- };
61309
- exports.crypto_aead_chacha20poly1305_ietf_keygen = function(k) {
61310
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61311
- assert2(k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes");
61312
- binding.crypto_aead_chacha20poly1305_ietf_keygen(k);
61313
- };
61314
- exports.crypto_aead_chacha20poly1305_ietf_encrypt = function(c, m, ad, nsec, npub, k) {
61315
- if (!ad)
61316
- ad = undefined;
61317
- assert2(nsec === null, "nsec must always be set to null");
61318
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61319
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61320
- assert2(c.byteLength === m.byteLength + binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "c must be 'm.byteLength + crypto_aead_chacha20poly1305_ietf_ABYTES' bytes");
61321
- assert2(c.byteLength <= 4294967295, "c.byteLength must be a 32bit integer");
61322
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61323
- assert2(npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes");
61324
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61325
- assert2(k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes");
61326
- const res = binding.crypto_aead_chacha20poly1305_ietf_encrypt(c, m, ad, npub, k);
61327
- if (res < 0)
61328
- throw new Error("could not encrypt data");
61329
- return res;
61330
- };
61331
- exports.crypto_aead_chacha20poly1305_ietf_decrypt = function(m, nsec, c, ad, npub, k) {
61332
- if (!ad)
61333
- ad = undefined;
61334
- assert2(nsec === null, "nsec must always be set to null");
61335
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61336
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61337
- assert2(m.byteLength === c.byteLength - binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "m must be 'c.byteLength - crypto_aead_chacha20poly1305_ietf_ABYTES' bytes");
61338
- assert2(m.byteLength <= 4294967295, "m.byteLength must be a 32bit integer");
61339
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61340
- assert2(npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes");
61341
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61342
- assert2(k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes");
61343
- const res = binding.crypto_aead_chacha20poly1305_ietf_decrypt(m, c, ad, npub, k);
61344
- if (res < 0)
61345
- throw new Error("could not verify data");
61346
- return res;
61347
- };
61348
- exports.crypto_aead_chacha20poly1305_ietf_encrypt_detached = function(c, mac, m, ad, nsec, npub, k) {
61349
- if (!ad)
61350
- ad = undefined;
61351
- assert2(nsec === null, "nsec must always be set to null");
61352
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61353
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61354
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
61355
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
61356
- assert2(mac.byteLength === binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_chacha20poly1305_ietf_ABYTES' bytes");
61357
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61358
- assert2(npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes");
61359
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61360
- assert2(k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes");
61361
- const res = binding.crypto_aead_chacha20poly1305_ietf_encrypt_detached(c, mac, m, ad, npub, k);
61362
- if (res < 0)
61363
- throw new Error("could not encrypt data");
61364
- return res;
61365
- };
61366
- exports.crypto_aead_chacha20poly1305_ietf_decrypt_detached = function(m, nsec, c, mac, ad, npub, k) {
61367
- if (!ad)
61368
- ad = undefined;
61369
- assert2(nsec === null, "nsec must always be set to null");
61370
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61371
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61372
- assert2(m.byteLength === c.byteLength, "m must be 'c.byteLength' bytes");
61373
- assert2(ArrayBuffer.isView(mac), "mac must be a typed array");
61374
- assert2(mac.byteLength === binding.crypto_aead_chacha20poly1305_ietf_ABYTES, "mac must be 'crypto_aead_chacha20poly1305_ietf_ABYTES' bytes");
61375
- assert2(ArrayBuffer.isView(npub), "npub must be a typed array");
61376
- assert2(npub.byteLength === binding.crypto_aead_chacha20poly1305_ietf_NPUBBYTES, "npub must be 'crypto_aead_chacha20poly1305_ietf_NPUBBYTES' bytes");
61377
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61378
- assert2(k.byteLength === binding.crypto_aead_chacha20poly1305_ietf_KEYBYTES, "k must be 'crypto_aead_chacha20poly1305_ietf_KEYBYTES' bytes");
61379
- const res = binding.crypto_aead_chacha20poly1305_ietf_decrypt_detached(m, c, mac, ad, npub, k);
61380
- if (res !== 0)
61381
- throw new Error("could not verify data");
61382
- };
61383
- exports.crypto_stream_xor_wrap_init = function(state, n, k) {
61384
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61385
- assert2(state.byteLength === binding.sn_crypto_stream_xor_STATEBYTES, "state must be 'sn_crypto_stream_xor_STATEBYTES' bytes");
61386
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61387
- assert2(n.byteLength === binding.crypto_stream_NONCEBYTES, "n must be 'crypto_stream_NONCEBYTES' bytes");
61388
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61389
- assert2(k.byteLength === binding.crypto_stream_KEYBYTES, "k must be 'crypto_stream_KEYBYTES' bytes");
61390
- binding.crypto_stream_xor_wrap_init(state, n, k);
61391
- };
61392
- exports.crypto_stream_xor_wrap_update = function(state, c, m) {
61393
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61394
- assert2(state.byteLength === binding.sn_crypto_stream_xor_STATEBYTES, "state must be 'sn_crypto_stream_xor_STATEBYTES' bytes");
61395
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61396
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61397
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
61398
- binding.crypto_stream_xor_wrap_update(state, c, m);
61399
- };
61400
- exports.crypto_stream_xor_wrap_final = function(state) {
61401
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61402
- assert2(state.byteLength === binding.sn_crypto_stream_xor_STATEBYTES, "state must be 'sn_crypto_stream_xor_STATEBYTES' bytes");
61403
- binding.crypto_stream_xor_wrap_final(state);
61404
- };
61405
- exports.crypto_stream_chacha20_xor_wrap_init = function(state, n, k) {
61406
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61407
- assert2(state.byteLength === binding.crypto_stream_chacha20_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_xor_STATEBYTES' bytes");
61408
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61409
- assert2(n.byteLength === binding.crypto_stream_chacha20_NONCEBYTES, "n must be 'crypto_stream_chacha20_NONCEBYTES' bytes");
61410
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61411
- assert2(k.byteLength === binding.crypto_stream_chacha20_KEYBYTES, "k must be 'crypto_stream_chacha20_KEYBYTES' bytes");
61412
- binding.crypto_stream_chacha20_xor_wrap_init(state, n, k);
61413
- };
61414
- exports.crypto_stream_chacha20_xor_wrap_update = function(state, c, m) {
61415
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61416
- assert2(state.byteLength === binding.crypto_stream_chacha20_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_xor_STATEBYTES' bytes");
61417
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61418
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61419
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
61420
- binding.crypto_stream_chacha20_xor_wrap_update(state, c, m);
61421
- };
61422
- exports.crypto_stream_chacha20_xor_wrap_final = function(state) {
61423
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61424
- assert2(state.byteLength === binding.crypto_stream_chacha20_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_xor_STATEBYTES' bytes");
61425
- binding.crypto_stream_chacha20_xor_wrap_final(state);
61426
- };
61427
- exports.crypto_stream_chacha20_ietf_xor_wrap_init = function(state, n, k) {
61428
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61429
- assert2(state.byteLength === binding.crypto_stream_chacha20_ietf_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_ietf_xor_STATEBYTES' bytes");
61430
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61431
- assert2(n.byteLength === binding.crypto_stream_chacha20_ietf_NONCEBYTES, "n must be 'crypto_stream_chacha20_ietf_NONCEBYTES' bytes");
61432
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61433
- assert2(k.byteLength === binding.crypto_stream_chacha20_ietf_KEYBYTES, "k must be 'crypto_stream_chacha20_ietf_KEYBYTES' bytes");
61434
- binding.crypto_stream_chacha20_ietf_xor_wrap_init(state, n, k);
61435
- };
61436
- exports.crypto_stream_chacha20_ietf_xor_wrap_update = function(state, c, m) {
61437
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61438
- assert2(state.byteLength === binding.crypto_stream_chacha20_ietf_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_ietf_xor_STATEBYTES' bytes");
61439
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61440
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61441
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
61442
- binding.crypto_stream_chacha20_ietf_xor_wrap_update(state, c, m);
61443
- };
61444
- exports.crypto_stream_chacha20_ietf_xor_wrap_final = function(state) {
61445
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61446
- assert2(state.byteLength === binding.crypto_stream_chacha20_ietf_xor_STATEBYTES, "state must be 'crypto_stream_chacha20_ietf_xor_STATEBYTES' bytes");
61447
- binding.crypto_stream_chacha20_ietf_xor_wrap_final(state);
61448
- };
61449
- exports.crypto_stream_xchacha20_xor_wrap_init = function(state, n, k) {
61450
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61451
- assert2(state.byteLength === binding.crypto_stream_xchacha20_xor_STATEBYTES, "state must be 'crypto_stream_xchacha20_xor_STATEBYTES' bytes");
61452
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61453
- assert2(n.byteLength === binding.crypto_stream_xchacha20_NONCEBYTES, "n must be 'crypto_stream_xchacha20_NONCEBYTES' bytes");
61454
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61455
- assert2(k.byteLength === binding.crypto_stream_xchacha20_KEYBYTES, "k must be 'crypto_stream_xchacha20_KEYBYTES' bytes");
61456
- binding.crypto_stream_xchacha20_xor_wrap_init(state, n, k);
61457
- };
61458
- exports.crypto_stream_xchacha20_xor_wrap_update = function(state, c, m) {
61459
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61460
- assert2(state.byteLength === binding.crypto_stream_xchacha20_xor_STATEBYTES, "state must be 'crypto_stream_xchacha20_xor_STATEBYTES' bytes");
61461
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61462
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61463
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
61464
- binding.crypto_stream_xchacha20_xor_wrap_update(state, c, m);
61465
- };
61466
- exports.crypto_stream_xchacha20_xor_wrap_final = function(state) {
61467
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61468
- assert2(state.byteLength === binding.crypto_stream_xchacha20_xor_STATEBYTES, "state must be 'crypto_stream_xchacha20_xor_STATEBYTES' bytes");
61469
- binding.crypto_stream_xchacha20_xor_wrap_final(state);
61470
- };
61471
- exports.crypto_stream_salsa20_xor_wrap_init = function(state, n, k) {
61472
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61473
- assert2(state.byteLength === binding.crypto_stream_salsa20_xor_STATEBYTES, "state must be 'crypto_stream_salsa20_xor_STATEBYTES' bytes");
61474
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61475
- assert2(n.byteLength === binding.crypto_stream_salsa20_NONCEBYTES, "n must be 'crypto_stream_salsa20_NONCEBYTES' bytes");
61476
- assert2(ArrayBuffer.isView(k), "k must be a typed array");
61477
- assert2(k.byteLength === binding.crypto_stream_salsa20_KEYBYTES, "k must be 'crypto_stream_salsa20_KEYBYTES' bytes");
61478
- binding.crypto_stream_salsa20_xor_wrap_init(state, n, k);
61479
- };
61480
- exports.crypto_stream_salsa20_xor_wrap_update = function(state, c, m) {
61481
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61482
- assert2(state.byteLength === binding.crypto_stream_salsa20_xor_STATEBYTES, "state must be 'crypto_stream_salsa20_xor_STATEBYTES' bytes");
61483
- assert2(ArrayBuffer.isView(c), "c must be a typed array");
61484
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61485
- assert2(c.byteLength === m.byteLength, "c must be 'm.byteLength' bytes");
61486
- binding.crypto_stream_salsa20_xor_wrap_update(state, c, m);
61487
- };
61488
- exports.crypto_stream_salsa20_xor_wrap_final = function(state) {
61489
- assert2(ArrayBuffer.isView(state), "state must be a typed array");
61490
- assert2(state.byteLength === binding.crypto_stream_salsa20_xor_STATEBYTES, "state must be 'crypto_stream_salsa20_xor_STATEBYTES' bytes");
61491
- binding.crypto_stream_salsa20_xor_wrap_final(state);
61492
- };
61493
- exports.extension_tweak_ed25519_base = function(n, p, ns) {
61494
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61495
- assert2(n.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "n must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61496
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61497
- assert2(p.byteLength === binding.extension_tweak_ed25519_BYTES, "p must be 'extension_tweak_ed25519_BYTES' bytes");
61498
- binding.extension_tweak_ed25519_base(n, p, ns);
61499
- };
61500
- exports.extension_tweak_ed25519_sign_detached = function(sig, m, scalar, pk) {
61501
- assert2(ArrayBuffer.isView(sig), "sig must be a typed array");
61502
- assert2(sig.byteLength === binding.crypto_sign_BYTES, "sig must be 'crypto_sign_BYTES' bytes");
61503
- assert2(ArrayBuffer.isView(m), "m must be a typed array");
61504
- assert2(ArrayBuffer.isView(scalar), "scalar must be a typed array");
61505
- assert2(scalar.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalar must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61506
- if (pk) {
61507
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
61508
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
61509
- }
61510
- const res = binding.extension_tweak_ed25519_sign_detached(sig, m, scalar, pk);
61511
- if (res !== 0)
61512
- throw new Error("failed to compute signature");
61513
- };
61514
- exports.extension_tweak_ed25519_sk_to_scalar = function(n, sk) {
61515
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61516
- assert2(n.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "n must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61517
- assert2(ArrayBuffer.isView(sk), "sk must be a typed array");
61518
- assert2(sk.byteLength === binding.crypto_sign_SECRETKEYBYTES, "sk must be 'crypto_sign_SECRETKEYBYTES' bytes");
61519
- binding.extension_tweak_ed25519_sk_to_scalar(n, sk);
61520
- };
61521
- exports.extension_tweak_ed25519_scalar = function(scalarOut, scalar, ns) {
61522
- assert2(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array");
61523
- assert2(scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61524
- assert2(ArrayBuffer.isView(scalar), "scalar must be a typed array");
61525
- assert2(scalar.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalar must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61526
- binding.extension_tweak_ed25519_scalar(scalarOut, scalar, ns);
61527
- };
61528
- exports.extension_tweak_ed25519_pk = function(tpk, pk, ns) {
61529
- assert2(ArrayBuffer.isView(tpk), "tpk must be a typed array");
61530
- assert2(tpk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "tpk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
61531
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
61532
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
61533
- const res = binding.extension_tweak_ed25519_pk(tpk, pk, ns);
61534
- if (res !== 0)
61535
- throw new Error("failed to tweak public key");
61536
- };
61537
- exports.extension_tweak_ed25519_keypair = function(pk, scalarOut, scalarIn, ns) {
61538
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
61539
- assert2(pk.byteLength === binding.extension_tweak_ed25519_BYTES, "pk must be 'extension_tweak_ed25519_BYTES' bytes");
61540
- assert2(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array");
61541
- assert2(scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61542
- assert2(ArrayBuffer.isView(scalarIn), "scalarIn must be a typed array");
61543
- assert2(scalarIn.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarIn must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61544
- binding.extension_tweak_ed25519_keypair(pk, scalarOut, scalarIn, ns);
61545
- };
61546
- exports.extension_tweak_ed25519_scalar_add = function(scalarOut, scalar, n) {
61547
- assert2(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array");
61548
- assert2(scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61549
- assert2(ArrayBuffer.isView(scalar), "scalar must be a typed array");
61550
- assert2(scalar.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalar must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61551
- assert2(ArrayBuffer.isView(n), "n must be a typed array");
61552
- assert2(n.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "n must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61553
- binding.extension_tweak_ed25519_scalar_add(scalarOut, scalar, n);
61554
- };
61555
- exports.extension_tweak_ed25519_pk_add = function(tpk, pk, p) {
61556
- assert2(ArrayBuffer.isView(tpk), "tpk must be a typed array");
61557
- assert2(tpk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "tpk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
61558
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
61559
- assert2(pk.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "pk must be 'crypto_sign_PUBLICKEYBYTES' bytes");
61560
- assert2(ArrayBuffer.isView(p), "p must be a typed array");
61561
- assert2(p.byteLength === binding.crypto_sign_PUBLICKEYBYTES, "p must be 'crypto_sign_PUBLICKEYBYTES' bytes");
61562
- const res = binding.extension_tweak_ed25519_pk_add(tpk, pk, p);
61563
- if (res !== 0)
61564
- throw new Error("failed to add tweak to public key");
61565
- };
61566
- exports.extension_tweak_ed25519_keypair_add = function(pk, scalarOut, scalarIn, tweak) {
61567
- assert2(ArrayBuffer.isView(pk), "pk must be a typed array");
61568
- assert2(pk.byteLength === binding.extension_tweak_ed25519_BYTES, "pk must be 'extension_tweak_ed25519_BYTES' bytes");
61569
- assert2(ArrayBuffer.isView(scalarOut), "scalarOut must be a typed array");
61570
- assert2(scalarOut.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarOut must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61571
- assert2(ArrayBuffer.isView(scalarIn), "scalarIn must be a typed array");
61572
- assert2(scalarIn.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "scalarIn must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61573
- assert2(ArrayBuffer.isView(tweak), "tweak must be a typed array");
61574
- assert2(tweak.byteLength === binding.extension_tweak_ed25519_SCALARBYTES, "tweak must be 'extension_tweak_ed25519_SCALARBYTES' bytes");
61575
- const res = binding.extension_tweak_ed25519_keypair_add(pk, scalarOut, scalarIn, tweak);
61576
- if (res !== 0)
61577
- throw new Error("failed to add tweak to keypair");
61578
- };
61579
- exports.extension_pbkdf2_sha512_async = function(out, passwd, salt, iter, outlen, callback) {
61580
- assert2(iter >= binding.extension_pbkdf2_sha512_ITERATIONS_MIN, "iter must be at least 'extension_pbkdf2_sha512_ITERATIONS_MIN'");
61581
- assert2(outlen <= binding.extension_pbkdf2_sha512_BYTES_MAX, "outlen must be at most 'extension_pbkdf2_sha512_BYTES_MAX'");
61582
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61583
- assert2(out.byteLength >= outlen, "out must be at least 'outlen' bytes");
61584
- assert2(out.byteLength > 0, "out must not be empty");
61585
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
61586
- assert2(passwd.byteLength > 0, "passwd must not be empty");
61587
- assert2(ArrayBuffer.isView(salt), "salt must be a typed array");
61588
- assert2(salt.byteLength > 0, "salt must not be empty");
61589
- const [done, promise] = checkStatus(callback);
61590
- 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);
61591
- return promise;
61592
- };
61593
- exports.extension_pbkdf2_sha512 = function(out, passwd, salt, iter, outlen) {
61594
- assert2(iter >= binding.extension_pbkdf2_sha512_ITERATIONS_MIN, "iter must be at least 'extension_pbkdf2_sha512_ITERATIONS_MIN'");
61595
- assert2(outlen <= binding.extension_pbkdf2_sha512_BYTES_MAX, "outlen must be at most 'extension_pbkdf2_sha512_BYTES_MAX'");
61596
- assert2(ArrayBuffer.isView(out), "out must be a typed array");
61597
- assert2(out.byteLength >= outlen, "out must be at least 'outlen' bytes");
61598
- assert2(out.byteLength > 0, "out must not be empty");
61599
- assert2(ArrayBuffer.isView(passwd), "passwd must be a typed array");
61600
- assert2(passwd.byteLength > 0, "passwd must not be empty");
61601
- assert2(ArrayBuffer.isView(salt), "salt must be a typed array");
61602
- assert2(salt.byteLength > 0, "salt must not be empty");
61603
- const res = binding.extension_pbkdf2_sha512(out, passwd, salt, iter, outlen);
61604
- if (res !== 0)
61605
- throw new Error("failed to add tweak to public key");
61606
- };
61607
- function checkStatus(callback, booleanResult = false) {
61608
- let done, promise;
61609
- if (typeof callback === "function") {
61610
- done = function(status) {
61611
- if (booleanResult)
61612
- callback(null, status === 0);
61613
- else if (status === 0)
61614
- callback(null);
61615
- else
61616
- callback(new Error("status: " + status));
61617
- };
61618
- } else {
61619
- promise = new Promise(function(resolve, reject) {
61620
- done = function(status) {
61621
- if (booleanResult)
61622
- resolve(status === 0);
61623
- else if (status === 0)
61624
- resolve();
61625
- else
61626
- reject(new Error("status: " + status));
61627
- };
61628
- });
61629
- }
61630
- return [done, promise];
61631
- }
61632
- });
61633
-
61634
58723
  // node_modules/@solana/codecs/node_modules/@solana/codecs-core/dist/index.node.mjs
61635
58724
  function createDecoder5(decoder) {
61636
58725
  return Object.freeze({
@@ -63081,7 +60170,8 @@ var init_wallet_account_read_only_solana = __esm(() => {
63081
60170
  });
63082
60171
 
63083
60172
  // node_modules/@tetherto/wdk-wallet-solana/src/wallet-account-solana.js
63084
- var bip392, import_sodium_universal, BIP_44_SOL_DERIVATION_PATH_PREFIX = "m/44'/501'", WalletAccountSolana;
60173
+ import { sodium_memzero } from "sodium-native";
60174
+ var bip392, BIP_44_SOL_DERIVATION_PATH_PREFIX = "m/44'/501'", WalletAccountSolana;
63085
60175
  var init_wallet_account_solana = __esm(() => {
63086
60176
  init_index_node38();
63087
60177
  init_index_node37();
@@ -63090,7 +60180,6 @@ var init_wallet_account_solana = __esm(() => {
63090
60180
  init_slip10();
63091
60181
  init_wallet_account_read_only_solana();
63092
60182
  bip392 = __toESM(require_src(), 1);
63093
- import_sodium_universal = __toESM(require_sodium_native(), 1);
63094
60183
  WalletAccountSolana = class WalletAccountSolana extends WalletAccountReadOnlySolana {
63095
60184
  constructor(seed, path, config = {}) {
63096
60185
  if (typeof seed === "string") {
@@ -63115,7 +60204,7 @@ var init_wallet_account_solana = __esm(() => {
63115
60204
  const publicKey2 = await crypto.subtle.exportKey("raw", account._signer.keyPair.publicKey);
63116
60205
  account._rawPublicKey = new Uint8Array(publicKey2);
63117
60206
  account._rawPrivateKey = new Uint8Array(privateKey);
63118
- import_sodium_universal.sodium_memzero(privateKey);
60207
+ sodium_memzero(privateKey);
63119
60208
  return account;
63120
60209
  }
63121
60210
  get index() {
@@ -63200,7 +60289,7 @@ var init_wallet_account_solana = __esm(() => {
63200
60289
  return readOnlyAccount;
63201
60290
  }
63202
60291
  dispose() {
63203
- import_sodium_universal.sodium_memzero(this._rawPrivateKey);
60292
+ sodium_memzero(this._rawPrivateKey);
63204
60293
  this._rawPrivateKey = undefined;
63205
60294
  this._signer = undefined;
63206
60295
  this._seed = undefined;
@@ -64037,7 +61126,7 @@ async function runHelp(ctx) {
64037
61126
  async function runVersion(ctx) {
64038
61127
  output(ctx.format, {
64039
61128
  name: "@agenttech/tpay-cli",
64040
- version: "0.0.3"
61129
+ version: "0.0.5"
64041
61130
  });
64042
61131
  return 0;
64043
61132
  }
@@ -64422,7 +61511,7 @@ function createProgram() {
64422
61511
  const program2 = new Command;
64423
61512
  const versionInfo = {
64424
61513
  name: "@agenttech/tpay-cli",
64425
- version: "0.0.3"
61514
+ version: "0.0.5"
64426
61515
  };
64427
61516
  const versionString = typeof versionInfo === "string" ? versionInfo : versionInfo.version;
64428
61517
  program2.name("tpay").version(versionString, "-v, --version", "Show version").option("--verbose", "Enable debug logging to stderr").option("--format <fmt>", "Output format: json | text", "json");