algolia-uploader 0.0.15-beta.1 → 0.0.15-beta.2
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.
- package/dist/index.mjs +39 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e from"node:fs";import t from"node:path";import{defineCommand as n,runMain as r}from"citty";import{algoliasearch as i}from"algoliasearch";import{isEqual as a}from"es-toolkit";var o=`algolia-uploader`,s=`0.0.15-beta.1`,c=`command-line util to upload Algolia source`;function l(e){return typeof e==`object`&&!!e&&`objectID`in e&&typeof e.objectID==`string`}function u(e){let t=Object.keys(e).sort(),n={objectID:e.objectID};for(let r of t)r!==`objectID`&&(n[r]=e[r]);return n}function d(e){return e.map(u).sort((e,t)=>e.objectID.localeCompare(t.objectID))}const f={ALGOLIA_APP_ID:`ALGOLIA_APP_ID`,ALGOLIA_ADMIN_API_KEY:`ALGOLIA_ADMIN_API_KEY`,ALGOLIA_INDEX_NAME:`ALGOLIA_INDEX_NAME`,DATA_DIR:`DATA_DIR`};var p=class e{constructor(){this.envVars={},Object.values(f).forEach(e=>{let t=process.env[e];if(t==null)throw Error(`Missing required environment variable: ${e}`);this.envVars[e]=t})}static getInstance(){return e.instance||=new e,e.instance}getConfig(e){return this.envVars[e]}},m=class e{constructor(e,t){this.client=t(e.getConfig(`ALGOLIA_APP_ID`),e.getConfig(`ALGOLIA_ADMIN_API_KEY`)),this.indexName=e.getConfig(`ALGOLIA_INDEX_NAME`)}static getInstance(){if(!this.instance){let t=p.getInstance();this.instance=new e(t,i)}return this.instance}getClient(){return this.client}getIndexName(){return this.indexName}};function h(n){return e.readdirSync(n).filter(e=>e.endsWith(`.json`)).map(r=>{let i=e.readFileSync(t.join(n,r),`utf8`);return JSON.parse(i)})}var g=class{constructor(e){this.client=e.getClient(),this.indexName=e.getIndexName()}async uploadObjects(e){if(e.length===0){console.error(`No items are included in the target JSON file. More than 1 item is necessary.`);return}let t=await this.getAllObjects();t=d(t);let n=d(e),r=this.determineOperations(t,n);if(r.update.length===0&&r.add.length===0&&r.delete.length===0){console.log(`No updates needed. All objects are up to date.`);return}if(r.update.length>0){let e=await this.client.partialUpdateObjects({indexName:this.indexName,objects:r.update,createIfNotExists:!0});console.log(`Updated ${e[0].objectIDs.length} objects`)}if(r.add.length>0){let e=await this.client.saveObjects({indexName:this.indexName,objects:r.add});console.log(`Added ${e[0].objectIDs.length} objects`)}if(r.delete.length>0){let e=r.delete.map(e=>e.objectID),t=await this.client.deleteObjects({indexName:this.indexName,objectIDs:e});console.log(`Deleted ${t[0].objectIDs.length} objects`)}}async getAllObjects(){let e=[];return await this.client.browseObjects({indexName:this.indexName,aggregator:t=>{Array.isArray(t.hits)&&t.hits.forEach(t=>{l(t)&&e.push(t)})}}),e}determineOperations(e,t){let n=new Map(e.map(e=>[e.objectID,e])),r=new Map(t.map(e=>[e.objectID,e])),i={update:[],add:[],delete:[]};for(let e of t){let t=n.get(e.objectID);t==null?i.add.push(e):a(t,e)||i.update.push(e)}for(let t of e)r.has(t.objectID)||i.delete.push(t);return i}};r(n({meta:{name:o,version:s,description:c},args:{},async run(){try{let n=p.getInstance().getConfig(`DATA_DIR`);n=t.join(process.cwd(),n),e.existsSync(n)&&e.statSync(n).isDirectory()||(console.error(`Error: provided directory does not exist - ${n}`),process.exit(1));let r=h(n);r.length===0&&(console.error(`Error: no .json files found in directory - ${n}`),process.exit(1));let i=r[0];Array.isArray(i)||(console.error(`The content of the provided json file is incompatible. Check the file: ${n}`),process.exit(1)),i.every(e=>l(e))||(console.error(`The content of the provided json file is incompatible. Check the file: ${n}`),process.exit(1)),await new g(m.getInstance()).uploadObjects(i)}catch(e){console.error(`Some errors occured: `,e),process.exit(1)}}}));export{};
|
|
2
|
+
import{createRequire as e}from"node:module";import t from"node:fs";import n from"node:path";import{defineCommand as r,runMain as i}from"citty";import{algoliasearch as a}from"algoliasearch";import{isEqual as o}from"es-toolkit";var s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=e(import.meta.url),l=`algolia-uploader`,u=`0.0.15-beta.2`,d=`command-line util to upload Algolia source`;function f(e){return typeof e==`object`&&!!e&&`objectID`in e&&typeof e.objectID==`string`}function p(e){let t=Object.keys(e).sort(),n={objectID:e.objectID};for(let r of t)r!==`objectID`&&(n[r]=e[r]);return n}function m(e){return e.map(p).sort((e,t)=>e.objectID.localeCompare(t.objectID))}var h=s(((e,t)=>{t.exports={version:`1.66.0`,name:`@dotenvx/dotenvx`,description:"secrets for agents–from the creator of `dotenv`",author:`@motdotla`,keywords:[`dotenv`,`env`],homepage:`https://github.com/dotenvx/dotenvx`,repository:{type:`git`,url:`git+https://github.com/dotenvx/dotenvx.git`},license:`BSD-3-Clause`,files:[`src/**/*`,`CHANGELOG.md`],main:`src/lib/main.js`,types:`src/lib/main.d.ts`,exports:{".":{types:`./src/lib/main.d.ts`,require:`./src/lib/main.js`,default:`./src/lib/main.js`},"./config":`./src/lib/config.js`,"./config.js":`./src/lib/config.js`,"./package.json":`./package.json`},bin:{dotenvx:`./src/cli/dotenvx.js`},scripts:{standard:`standard`,"standard:fix":`standard --fix`,test:`tap run --test-env=DOTENVX_NO_OPS=true --allow-empty-coverage --disable-coverage --timeout=60000`,"test-coverage":`tap run --test-env=DOTENVX_NO_OPS=true --show-full-coverage --timeout=60000`,testshell:`bash shellspec`,prerelease:`npm test && npm run testshell`,release:`standard-version`},funding:`https://dotenvx.com`,dependencies:{commander:`^11.1.0`,dotenv:`^17.2.1`,eciesjs:`^0.4.10`,execa:`^5.1.1`,fdir:`^6.2.0`,ignore:`^5.3.0`,"object-treeify":`1.1.33`,picomatch:`^4.0.4`,which:`^4.0.0`,"yocto-spinner":`^1.1.0`},devDependencies:{"@yao-pkg/pkg":`^6.14.2`,"capture-console":`^1.0.2`,esbuild:`^0.25.8`,proxyquire:`^2.1.3`,sinon:`^14.0.1`,standard:`^17.1.0`,"standard-version":`^9.5.0`,tap:`^21.0.1`},publishConfig:{access:`public`,provenance:!0}}})),g=s(((e,t)=>{let{name:n,version:r,description:i}=h();t.exports={name:n,version:r,description:i}})),_=s(((e,t)=>{function n(e,t=7){return e&&e.length>0?e.slice(0,t)+`…`:``}t.exports=n})),v=s(((e,t)=>{let n=_(),r={COMMAND_EXITED_WITH_CODE:`https://github.com/dotenvx/dotenvx/issues/new`,COMMAND_SUBSTITUTION_FAILED:`https://github.com/dotenvx/dotenvx/issues/532`,DECRYPTION_FAILED:`https://github.com/dotenvx/dotenvx/issues/757`,DANGEROUS_DEPENDENCY_HOIST:`https://github.com/dotenvx/dotenvx/issues/622`,INVALID_COLOR:`must be 256 colors`,INVALID_CONVENTION:`https://github.com/dotenvx/dotenvx/issues/761`,INVALID_PRIVATE_KEY:`https://github.com/dotenvx/dotenvx/issues/465`,INVALID_PUBLIC_KEY:`https://github.com/dotenvx/dotenvx/issues/756`,MALFORMED_ENCRYPTED_DATA:`https://github.com/dotenvx/dotenvx/issues/467`,MISPAIRED_PRIVATE_KEY:`https://github.com/dotenvx/dotenvx/issues/752`,MISSING_DIRECTORY:`https://github.com/dotenvx/dotenvx/issues/758`,MISSING_ENV_FILE:`https://github.com/dotenvx/dotenvx/issues/484`,MISSING_ENV_KEYS_FILE:`https://github.com/dotenvx/dotenvx/issues/775`,MISSING_ENV_FILES:`https://github.com/dotenvx/dotenvx/issues/760`,MISSING_KEY:`https://github.com/dotenvx/dotenvx/issues/759`,MISSING_LOG_LEVEL:`must be valid log level`,MISSING_PRIVATE_KEY:`https://github.com/dotenvx/dotenvx/issues/464`,PRECOMMIT_HOOK_MODIFY_FAILED:`try again or report error`,WRONG_PRIVATE_KEY:`https://github.com/dotenvx/dotenvx/issues/466`};var i=class{constructor(e={}){this.filepath=e.filepath,this.envFilepath=e.envFilepath,this.envKeysFilepath=e.envKeysFilepath,this.key=e.key,this.privateKey=e.privateKey,this.privateKeyName=e.privateKeyName,this.publicKeyName=e.publicKeyName,this.publicKey=e.publicKey,this.publicKeyExisting=e.publicKeyExisting,this.command=e.command,this.message=e.message,this.code=e.code,this.help=e.help,this.debug=e.debug,this.convention=e.convention,this.directory=e.directory,this.exitCode=e.exitCode,this.level=e.level,this.color=e.color,this.error=e.error}custom(){let e=Error(this.message);return this.code&&(e.code=this.code),this.help&&(e.help=this.help),this.code&&!e.help&&(e.help=`fix: [${r[this.code]}]`),e.messageWithHelp=`${e.message}. ${e.help}`,this.debug&&(e.debug=this.debug),e}commandExitedWithCode(){let e=`COMMAND_EXITED_WITH_CODE`,t=`[${e}] Command exited with exit code ${this.exitCode}`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}commandSubstitutionFailed(){let e=`COMMAND_SUBSTITUTION_FAILED`,t=`[${e}] could not eval ${this.key} containing command '${this.command}': ${this.message}`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}decryptionFailed(){let e=`DECRYPTION_FAILED`,t=`[${e}] ${this.message}`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}dangerousDependencyHoist(){let e=`DANGEROUS_DEPENDENCY_HOIST`,t=`[${e}] your environment has hoisted an incompatible version of a dotenvx dependency: ${this.message}`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}invalidColor(){let e=`INVALID_COLOR`,t=`[${e}] Invalid color ${this.color}`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}invalidConvention(){let e=`INVALID_CONVENTION`,t=`[${e}] invalid convention (${this.convention})`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}invalidPrivateKey(){let e=`INVALID_PRIVATE_KEY`,t=`[${e}] could not decrypt ${this.key} using private key '${this.privateKeyName}=${n(this.privateKey)}'`,i=`fix: [${r[e]}]`,a=Error(t);return a.code=e,a.help=i,a.messageWithHelp=`${t}. ${i}`,a}invalidPublicKey(){let e=`INVALID_PUBLIC_KEY`,t=`[${e}] could not encrypt using public key '${this.publicKeyName}=${n(this.publicKey)}'`,i=`fix: [${r[e]}]`,a=Error(t);return a.code=e,a.help=i,a.messageWithHelp=`${t}. ${i}`,a}malformedEncryptedData(){let e=`MALFORMED_ENCRYPTED_DATA`,t=`[${e}] could not decrypt ${this.key} because encrypted data appears malformed`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}mispairedPrivateKey(){let e=`MISPAIRED_PRIVATE_KEY`,t=`[${e}] private key's derived public key (${n(this.publicKey)}) does not match the existing public key (${n(this.publicKeyExisting)})`,i=`fix: [${r[e]}]`,a=Error(t);return a.code=e,a.help=i,a.messageWithHelp=`${t}. ${i}`,a}missingDirectory(){let e=`MISSING_DIRECTORY`,t=`[${e}] missing directory (${this.directory})`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}missingEnvFile(){let e=`MISSING_ENV_FILE`,t=`[${e}] missing file (${this.envFilepath||`.env`})`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}missingEnvKeysFile(){let e=`MISSING_ENV_KEYS_FILE`,t=`[${e}] missing file (${this.envKeysFilepath||`.env.keys`})`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}missingEnvFiles(){let e=`MISSING_ENV_FILES`,t=`[${e}] no .env* files found`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}missingKey(){let e=`MISSING_KEY`,t=`[${e}] missing key (${this.key})`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}missingLogLevel(){let e=`MISSING_LOG_LEVEL`,t=`[${e}] missing log level '${this.level}'. implement in logger`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}missingPrivateKey(){let e=`MISSING_PRIVATE_KEY`,t=`[${e}] could not decrypt ${this.key} using private key '${this.privateKeyName}=${n(this.privateKey)}'`,i=`fix: [${r[e]}]`,a=Error(t);return a.code=e,a.help=i,a.messageWithHelp=`${t}. ${i}`,a}precommitHookModifyFailed(){let e=`PRECOMMIT_HOOK_MODIFY_FAILED`,t=`[${e}] failed to modify pre-commit hook: ${this.error.message}`,n=`fix: [${r[e]}]`,i=Error(t);return i.code=e,i.help=n,i.messageWithHelp=`${t}. ${n}`,i}wrongPrivateKey(){let e=`WRONG_PRIVATE_KEY`,t=`[${e}] could not decrypt ${this.key} using private key '${this.privateKeyName}=${n(this.privateKey)}'`,i=`fix: [${r[e]}]`,a=Error(t);return a.code=e,a.help=i,a.messageWithHelp=`${t}. ${i}`,a}};i.ISSUE_BY_CODE=r,t.exports=i})),y=s(((e,t)=>{let{WriteStream:n}=c(`tty`);t.exports={getColorDepth:()=>{try{return n.prototype.getColorDepth()}catch{let e=process.env.TERM;return e&&(e.includes(`256color`)||e.includes(`xterm`))?8:4}}}})),b=s(((e,t)=>{let n=y(),r=v(),i=new Map([[`amber`,33],[`blue`,34],[`gray`,37],[`green`,32],[`olive`,33],[`orangered`,33],[`plum`,35],[`red`,31],[`electricblue`,36],[`dodgerblue`,36]]),a=new Map([[`amber`,136],[`blue`,21],[`gray`,244],[`green`,34],[`olive`,142],[`orangered`,130],[`plum`,182],[`red`,124],[`electricblue`,45],[`dodgerblue`,33]]),o=new Map([[`amber`,[236,213,63]],[`orangered`,[138,90,43]],[`red`,[140,35,50]]]);function s(e){let t=n.getColorDepth();if(!a.has(e))throw new r({color:e}).invalidColor();if(t>=24&&o.has(e)){let[t,n,r]=o.get(e);return e=>`\x1b[38;2;${t};${n};${r}m${e}\x1b[39m`}if(t>=8){let t=a.get(e);return e=>`\x1b[38;5;${t}m${e}\x1b[39m`}if(t>=4){let t=i.get(e);return e=>`\x1b[${t}m${e}\x1b[39m`}return e=>e}function c(e){return n.getColorDepth()>=4?`\x1b[1m${e}\x1b[22m`:e}t.exports={getColor:s,bold:c}})),x=s(((e,t)=>{let n=g(),r=v(),{getColor:i,bold:a}=b(),o={error:0,warn:1,success:2,successv:2,info:2,help:2,verbose:4,debug:5,silly:6},s=e=>a(i(`red`)(`☠ ${e}`)),c=e=>i(`orangered`)(`⚠ ${e}`),l=i(`amber`),u=e=>i(`amber`)(`⟐ ${e}`),d=i(`gray`),f=i(`dodgerblue`),p=e=>i(`plum`)(`┆ ${e}`),m=e=>i(`plum`)(`┆ ${e}`),h=o.info,_=`dotenvx`,y=n.version;function x(e,t){let n=C(e,t);console.error(n)}function S(e,t){if(o[e]===void 0)throw new r({level:e}).missingLogLevel();if(o[e]<=h){let n=C(e,t);console.log(n)}}function C(e,t){let n=typeof t==`object`?JSON.stringify(t):t;switch(e.toLowerCase()){case`error`:return s(n);case`warn`:return c(n);case`success`:return l(n);case`successv`:return u(`${n} · ${_}@${y}`);case`info`:return d(n);case`help`:return f(n);case`verbose`:return p(n);case`debug`:return m(n)}}let w={level:`info`,error:e=>x(`error`,e),warn:e=>S(`warn`,e),success:e=>S(`success`,e),successv:e=>S(`successv`,e),info:e=>S(`info`,e),help:e=>S(`help`,e),verbose:e=>S(`verbose`,e),debug:e=>S(`debug`,e),setLevel:e=>{o[e]!==void 0&&(h=o[e],w.level=e)},setName:e=>{_=e,w.name=e},setVersion:e=>{y=e,w.version=e}};function T(e){let t=e.debug?`debug`:e.verbose?`verbose`:e.quiet?`error`:e.logLevel;t&&(w.setLevel(t),(!e.quiet||e.quiet&&t!==`error`)&&w.debug(`setting log level to: ${t}`))}function E(e){let t=e.logName;t&&w.setName(t)}function D(e){let t=e.logVersion;t&&w.setVersion(t)}t.exports={logger:w,getColor:i,setLogLevel:T,setLogName:E,setLogVersion:D,levels:o}})),S=s(((e,t)=>{let n=`[^\\\\/]`,r=`[^/]`,i=`(?:\\/|$)`,a=`(?:^|\\/)`,o=`\\.{1,2}${i}`,s={DOT_LITERAL:`\\.`,PLUS_LITERAL:`\\+`,QMARK_LITERAL:`\\?`,SLASH_LITERAL:`\\/`,ONE_CHAR:`(?=.)`,QMARK:r,END_ANCHOR:i,DOTS_SLASH:o,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!${a}${o})`,NO_DOT_SLASH:`(?!\\.{0,1}${i})`,NO_DOTS_SLASH:`(?!${o})`,QMARK_NO_DOT:`[^.\\/]`,STAR:`${r}*?`,START_ANCHOR:a,SEP:`/`},c={...s,SLASH_LITERAL:`[\\\\/]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`\\.{1,2}(?:[\\\\/]|$)`,NO_DOT:`(?!\\.)`,NO_DOTS:`(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))`,NO_DOT_SLASH:`(?!\\.{0,1}(?:[\\\\/]|$))`,NO_DOTS_SLASH:`(?!\\.{1,2}(?:[\\\\/]|$))`,QMARK_NO_DOT:`[^.\\\\/]`,START_ANCHOR:`(?:^|[\\\\/])`,END_ANCHOR:`(?:[\\\\/]|$)`,SEP:`\\`};t.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:{__proto__:null,alnum:`a-zA-Z0-9`,alpha:`a-zA-Z`,ascii:`\\x00-\\x7F`,blank:` \\t`,cntrl:`\\x00-\\x1F\\x7F`,digit:`0-9`,graph:`\\x21-\\x7E`,lower:`a-z`,print:`\\x20-\\x7E `,punct:`\\-!"#$%&'()\\*+,./:;<=>?@[\\]^_\`{|}~`,space:` \\t\\r\\n\\v\\f`,upper:`A-Z`,word:`A-Za-z0-9_`,xdigit:`A-Fa-f0-9`},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":`*`,"**/**":`**`,"**/**/**":`**`},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return{"!":{type:`negate`,open:`(?:(?!(?:`,close:`))${e.STAR})`},"?":{type:`qmark`,open:`(?:`,close:`)?`},"+":{type:`plus`,open:`(?:`,close:`)+`},"*":{type:`star`,open:`(?:`,close:`)*`},"@":{type:`at`,open:`(?:`,close:`)`}}},globChars(e){return e===!0?c:s}}})),C=s((e=>{let{REGEX_BACKSLASH:t,REGEX_REMOVE_BACKSLASH:n,REGEX_SPECIAL_CHARS:r,REGEX_SPECIAL_CHARS_GLOBAL:i}=S();e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e),e.hasRegexChars=e=>r.test(e),e.isRegexChar=t=>t.length===1&&e.hasRegexChars(t),e.escapeRegex=e=>e.replace(i,`\\$1`),e.toPosixSlashes=e=>e.replace(t,`/`),e.isWindows=()=>{if(typeof navigator<`u`&&navigator.platform){let e=navigator.platform.toLowerCase();return e===`win32`||e===`windows`}return typeof process<`u`&&process.platform?process.platform===`win32`:!1},e.removeBackslashes=e=>e.replace(n,e=>e===`\\`?``:e),e.escapeLast=(t,n,r)=>{let i=t.lastIndexOf(n,r);return i===-1?t:t[i-1]===`\\`?e.escapeLast(t,n,i-1):`${t.slice(0,i)}\\${t.slice(i)}`},e.removePrefix=(e,t={})=>{let n=e;return n.startsWith(`./`)&&(n=n.slice(2),t.prefix=`./`),n},e.wrapOutput=(e,t={},n={})=>{let r=`${n.contains?``:`^`}(?:${e})${n.contains?``:`$`}`;return t.negated===!0&&(r=`(?:^(?!${r}).*$)`),r},e.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:`/`),r=n[n.length-1];return r===``?n[n.length-2]:r}})),w=s(((e,t)=>{let n=C(),{CHAR_ASTERISK:r,CHAR_AT:i,CHAR_BACKWARD_SLASH:a,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:c,CHAR_FORWARD_SLASH:l,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:d,CHAR_LEFT_SQUARE_BRACKET:f,CHAR_PLUS:p,CHAR_QUESTION_MARK:m,CHAR_RIGHT_CURLY_BRACE:h,CHAR_RIGHT_PARENTHESES:g,CHAR_RIGHT_SQUARE_BRACKET:_}=S(),v=e=>e===l||e===a,y=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)};t.exports=(e,t)=>{let b=t||{},x=e.length-1,S=b.parts===!0||b.scanToEnd===!0,C=[],w=[],T=[],E=e,D=-1,O=0,k=0,A=!1,j=!1,M=!1,N=!1,P=!1,F=!1,I=!1,L=!1,R=!1,z=!1,B=0,V,H,U={value:``,depth:0,isGlob:!1},W=()=>D>=x,G=()=>E.charCodeAt(D+1),K=()=>(V=H,E.charCodeAt(++D));for(;D<x;){H=K();let e;if(H===a){I=U.backslashes=!0,H=K(),H===u&&(F=!0);continue}if(F===!0||H===u){for(B++;W()!==!0&&(H=K());){if(H===a){I=U.backslashes=!0,K();continue}if(H===u){B++;continue}if(F!==!0&&H===s&&(H=K())===s){if(A=U.isBrace=!0,M=U.isGlob=!0,z=!0,S===!0)continue;break}if(F!==!0&&H===o){if(A=U.isBrace=!0,M=U.isGlob=!0,z=!0,S===!0)continue;break}if(H===h&&(B--,B===0)){F=!1,A=U.isBrace=!0,z=!0;break}}if(S===!0)continue;break}if(H===l){if(C.push(D),w.push(U),U={value:``,depth:0,isGlob:!1},z===!0)continue;if(V===s&&D===O+1){O+=2;continue}k=D+1;continue}if(b.noext!==!0&&(H===p||H===i||H===r||H===m||H===c)&&G()===d){if(M=U.isGlob=!0,N=U.isExtglob=!0,z=!0,H===c&&D===O&&(R=!0),S===!0){for(;W()!==!0&&(H=K());){if(H===a){I=U.backslashes=!0,H=K();continue}if(H===g){M=U.isGlob=!0,z=!0;break}}continue}break}if(H===r){if(V===r&&(P=U.isGlobstar=!0),M=U.isGlob=!0,z=!0,S===!0)continue;break}if(H===m){if(M=U.isGlob=!0,z=!0,S===!0)continue;break}if(H===f){for(;W()!==!0&&(e=K());){if(e===a){I=U.backslashes=!0,K();continue}if(e===_){j=U.isBracket=!0,M=U.isGlob=!0,z=!0;break}}if(S===!0)continue;break}if(b.nonegate!==!0&&H===c&&D===O){L=U.negated=!0,O++;continue}if(b.noparen!==!0&&H===d){if(M=U.isGlob=!0,S===!0){for(;W()!==!0&&(H=K());){if(H===d){I=U.backslashes=!0,H=K();continue}if(H===g){z=!0;break}}continue}break}if(M===!0){if(z=!0,S===!0)continue;break}}b.noext===!0&&(N=!1,M=!1);let q=E,J=``,Y=``;O>0&&(J=E.slice(0,O),E=E.slice(O),k-=O),q&&M===!0&&k>0?(q=E.slice(0,k),Y=E.slice(k)):M===!0?(q=``,Y=E):q=E,q&&q!==``&&q!==`/`&&q!==E&&v(q.charCodeAt(q.length-1))&&(q=q.slice(0,-1)),b.unescape===!0&&(Y&&=n.removeBackslashes(Y),q&&I===!0&&(q=n.removeBackslashes(q)));let X={prefix:J,input:e,start:O,base:q,glob:Y,isBrace:A,isBracket:j,isGlob:M,isExtglob:N,isGlobstar:P,negated:L,negatedExtglob:R};if(b.tokens===!0&&(X.maxDepth=0,v(H)||w.push(U),X.tokens=w),b.parts===!0||b.tokens===!0){let t;for(let n=0;n<C.length;n++){let r=t?t+1:O,i=C[n],a=e.slice(r,i);b.tokens&&(n===0&&O!==0?(w[n].isPrefix=!0,w[n].value=J):w[n].value=a,y(w[n]),X.maxDepth+=w[n].depth),(n!==0||a!==``)&&T.push(a),t=i}if(t&&t+1<e.length){let n=e.slice(t+1);T.push(n),b.tokens&&(w[w.length-1].value=n,y(w[w.length-1]),X.maxDepth+=w[w.length-1].depth)}X.slashes=C,X.parts=T}return X}})),T=s(((e,t)=>{let n=S(),r=C(),{MAX_LENGTH:i,POSIX_REGEX_SOURCE:a,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:c}=n,l=(e,t)=>{if(typeof t.expandRange==`function`)return t.expandRange(...e,t);e.sort();let n=`[${e.join(`-`)}]`;try{new RegExp(n)}catch{return e.map(e=>r.escapeRegex(e)).join(`..`)}return n},u=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,d=e=>{let t=[],n=0,r=0,i=0,a=``,o=!1;for(let s of e){if(o===!0){a+=s,o=!1;continue}if(s===`\\`){a+=s,o=!0;continue}if(s===`"`){i=i===1?0:1,a+=s;continue}if(i===0){if(s===`[`)n++;else if(s===`]`&&n>0)n--;else if(n===0){if(s===`(`)r++;else if(s===`)`&&r>0)r--;else if(s===`|`&&r===0){t.push(a),a=``;continue}}}a+=s}return t.push(a),t},f=e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n===`\\`){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},p=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(f(t))return t.replace(/\\(.)/g,`$1`)},m=e=>{let t=e.map(p).filter(Boolean);for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let r=t[e],i=t[n],a=r[0];if(!(!a||r!==a.repeat(r.length)||i!==a.repeat(i.length))&&(r===i||r.startsWith(i)||i.startsWith(r)))return!0}return!1},h=(e,t=!0)=>{if(e[0]!==`+`&&e[0]!==`*`||e[1]!==`(`)return;let n=0,r=0,i=0,a=!1;for(let o=1;o<e.length;o++){let s=e[o];if(a===!0){a=!1;continue}if(s===`\\`){a=!0;continue}if(s===`"`){i=i===1?0:1;continue}if(i!==1){if(s===`[`){n++;continue}if(s===`]`&&n>0){n--;continue}if(!(n>0)){if(s===`(`){r++;continue}if(s===`)`&&(r--,r===0))return t===!0&&o!==e.length-1?void 0:{type:e[0],body:e.slice(2,o),end:o}}}}},g=e=>{let t=0,n=[];for(;t<e.length;){let r=h(e.slice(t),!1);if(!r||r.type!==`*`)return;let i=d(r.body).map(e=>e.trim());if(i.length!==1)return;let a=p(i[0]);if(!a||a.length!==1)return;n.push(a),t+=r.end+1}if(!(n.length<1))return`${n.length===1?r.escapeRegex(n[0]):`[${n.map(e=>r.escapeRegex(e)).join(``)}]`}*`},_=e=>{let t=0,n=e.trim(),r=h(n);for(;r;)t++,n=r.body.trim(),r=h(n);return t},v=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let r=typeof t.maxExtglobRecursion==`number`?t.maxExtglobRecursion:n.DEFAULT_MAX_EXTGLOB_RECURSION,i=d(e).map(e=>e.trim());if(i.length>1&&(i.some(e=>e===``)||i.some(e=>/^[*?]+$/.test(e))||m(i)))return{risky:!0};for(let e of i){let t=g(e);if(t)return{risky:!0,safeOutput:t};if(_(e)>r)return{risky:!0}}return{risky:!1}},y=(e,t)=>{if(typeof e!=`string`)throw TypeError(`Expected a string`);e=c[e]||e;let d={...t},f=typeof d.maxLength==`number`?Math.min(i,d.maxLength):i,p=e.length;if(p>f)throw SyntaxError(`Input length: ${p}, exceeds maximum allowed length: ${f}`);let m={type:`bos`,value:``,output:d.prepend||``},h=[m],g=d.capture?``:`?:`,_=n.globChars(d.windows),b=n.extglobChars(_),{DOT_LITERAL:x,PLUS_LITERAL:S,SLASH_LITERAL:C,ONE_CHAR:w,DOTS_SLASH:T,NO_DOT:E,NO_DOT_SLASH:D,NO_DOTS_SLASH:O,QMARK:k,QMARK_NO_DOT:A,STAR:j,START_ANCHOR:M}=_,N=e=>`(${g}(?:(?!${M}${e.dot?T:x}).)*?)`,P=d.dot?``:E,F=d.dot?k:A,I=d.bash===!0?N(d):j;d.capture&&(I=`(${I})`),typeof d.noext==`boolean`&&(d.noextglob=d.noext);let L={input:e,index:-1,start:0,dot:d.dot===!0,consumed:``,output:``,prefix:``,backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:h};e=r.removePrefix(e,L),p=e.length;let R=[],z=[],B=[],V=m,H,U=()=>L.index===p-1,W=L.peek=(t=1)=>e[L.index+t],G=L.advance=()=>e[++L.index]||``,K=()=>e.slice(L.index+1),q=(e=``,t=0)=>{L.consumed+=e,L.index+=t},J=e=>{L.output+=e.output==null?e.value:e.output,q(e.value)},Y=()=>{let e=1;for(;W()===`!`&&(W(2)!==`(`||W(3)===`?`);)G(),L.start++,e++;return e%2==0?!1:(L.negated=!0,L.start++,!0)},X=e=>{L[e]++,B.push(e)},Z=e=>{L[e]--,B.pop()},Q=e=>{if(V.type===`globstar`){let t=L.braces>0&&(e.type===`comma`||e.type===`brace`),n=e.extglob===!0||R.length&&(e.type===`pipe`||e.type===`paren`);e.type!==`slash`&&e.type!==`paren`&&!t&&!n&&(L.output=L.output.slice(0,-V.output.length),V.type=`star`,V.value=`*`,V.output=I,L.output+=V.output)}if(R.length&&e.type!==`paren`&&(R[R.length-1].inner+=e.value),(e.value||e.output)&&J(e),V&&V.type===`text`&&e.type===`text`){V.output=(V.output||V.value)+e.value,V.value+=e.value;return}e.prev=V,h.push(e),V=e},ee=(e,t)=>{let n={...b[t],conditions:1,inner:``};n.prev=V,n.parens=L.parens,n.output=L.output,n.startIndex=L.index,n.tokensIndex=h.length;let r=(d.capture?`(`:``)+n.open;X(`parens`),Q({type:e,value:t,output:L.output?``:w}),Q({type:`paren`,extglob:!0,value:G(),output:r}),R.push(n)},te=n=>{let i=e.slice(n.startIndex,L.index+1),a=v(e.slice(n.startIndex+2,L.index),d);if((n.type===`plus`||n.type===`star`)&&a.risky){let e=a.safeOutput?(n.output?``:w)+(d.capture?`(${a.safeOutput})`:a.safeOutput):void 0,t=h[n.tokensIndex];t.type=`text`,t.value=i,t.output=e||r.escapeRegex(i);for(let e=n.tokensIndex+1;e<h.length;e++)h[e].value=``,h[e].output=``,delete h[e].suffix;L.output=n.output+t.output,L.backtrack=!0,Q({type:`paren`,extglob:!0,value:H,output:``}),Z(`parens`);return}let o=n.close+(d.capture?`)`:``),s;if(n.type===`negate`){let e=I;n.inner&&n.inner.length>1&&n.inner.includes(`/`)&&(e=N(d)),(e!==I||U()||/^\)+$/.test(K()))&&(o=n.close=`)$))${e}`),n.inner.includes(`*`)&&(s=K())&&/^\.[^\\/.]+$/.test(s)&&(o=n.close=`)${y(s,{...t,fastpaths:!1}).output})${e})`),n.prev.type===`bos`&&(L.negatedExtglob=!0)}Q({type:`paren`,extglob:!0,value:H,output:o}),Z(`parens`)};if(d.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let n=!1,i=e.replace(s,(e,t,r,i,a,o)=>i===`\\`?(n=!0,e):i===`?`?t?t+i+(a?k.repeat(a.length):``):o===0?F+(a?k.repeat(a.length):``):k.repeat(r.length):i===`.`?x.repeat(r.length):i===`*`?t?t+i+(a?I:``):I:t?e:`\\${e}`);return n===!0&&(i=d.unescape===!0?i.replace(/\\/g,``):i.replace(/\\+/g,e=>e.length%2==0?`\\\\`:e?`\\`:``)),i===e&&d.contains===!0?(L.output=e,L):(L.output=r.wrapOutput(i,L,t),L)}for(;!U();){if(H=G(),H===`\0`)continue;if(H===`\\`){let e=W();if(e===`/`&&d.bash!==!0||e===`.`||e===`;`)continue;if(!e){H+=`\\`,Q({type:`text`,value:H});continue}let t=/^\\+/.exec(K()),n=0;if(t&&t[0].length>2&&(n=t[0].length,L.index+=n,n%2!=0&&(H+=`\\`)),d.unescape===!0?H=G():H+=G(),L.brackets===0){Q({type:`text`,value:H});continue}}if(L.brackets>0&&(H!==`]`||V.value===`[`||V.value===`[^`)){if(d.posix!==!1&&H===`:`){let e=V.value.slice(1);if(e.includes(`[`)&&(V.posix=!0,e.includes(`:`))){let e=V.value.lastIndexOf(`[`),t=V.value.slice(0,e),n=a[V.value.slice(e+2)];if(n){V.value=t+n,L.backtrack=!0,G(),!m.output&&h.indexOf(V)===1&&(m.output=w);continue}}}(H===`[`&&W()!==`:`||H===`-`&&W()===`]`)&&(H=`\\${H}`),H===`]`&&(V.value===`[`||V.value===`[^`)&&(H=`\\${H}`),d.posix===!0&&H===`!`&&V.value===`[`&&(H=`^`),V.value+=H,J({value:H});continue}if(L.quotes===1&&H!==`"`){H=r.escapeRegex(H),V.value+=H,J({value:H});continue}if(H===`"`){L.quotes=L.quotes===1?0:1,d.keepQuotes===!0&&Q({type:`text`,value:H});continue}if(H===`(`){X(`parens`),Q({type:`paren`,value:H});continue}if(H===`)`){if(L.parens===0&&d.strictBrackets===!0)throw SyntaxError(u(`opening`,`(`));let e=R[R.length-1];if(e&&L.parens===e.parens+1){te(R.pop());continue}Q({type:`paren`,value:H,output:L.parens?`)`:`\\)`}),Z(`parens`);continue}if(H===`[`){if(d.nobracket===!0||!K().includes(`]`)){if(d.nobracket!==!0&&d.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));H=`\\${H}`}else X(`brackets`);Q({type:`bracket`,value:H});continue}if(H===`]`){if(d.nobracket===!0||V&&V.type===`bracket`&&V.value.length===1){Q({type:`text`,value:H,output:`\\${H}`});continue}if(L.brackets===0){if(d.strictBrackets===!0)throw SyntaxError(u(`opening`,`[`));Q({type:`text`,value:H,output:`\\${H}`});continue}Z(`brackets`);let e=V.value.slice(1);if(V.posix!==!0&&e[0]===`^`&&!e.includes(`/`)&&(H=`/${H}`),V.value+=H,J({value:H}),d.literalBrackets===!1||r.hasRegexChars(e))continue;let t=r.escapeRegex(V.value);if(L.output=L.output.slice(0,-V.value.length),d.literalBrackets===!0){L.output+=t,V.value=t;continue}V.value=`(${g}${t}|${V.value})`,L.output+=V.value;continue}if(H===`{`&&d.nobrace!==!0){X(`braces`);let e={type:`brace`,value:H,output:`(`,outputIndex:L.output.length,tokensIndex:L.tokens.length};z.push(e),Q(e);continue}if(H===`}`){let e=z[z.length-1];if(d.nobrace===!0||!e){Q({type:`text`,value:H,output:H});continue}let t=`)`;if(e.dots===!0){let e=h.slice(),n=[];for(let t=e.length-1;t>=0&&(h.pop(),e[t].type!==`brace`);t--)e[t].type!==`dots`&&n.unshift(e[t].value);t=l(n,d),L.backtrack=!0}if(e.comma!==!0&&e.dots!==!0){let n=L.output.slice(0,e.outputIndex),r=L.tokens.slice(e.tokensIndex);e.value=e.output=`\\{`,H=t=`\\}`,L.output=n;for(let e of r)L.output+=e.output||e.value}Q({type:`brace`,value:H,output:t}),Z(`braces`),z.pop();continue}if(H===`|`){R.length>0&&R[R.length-1].conditions++,Q({type:`text`,value:H});continue}if(H===`,`){let e=H,t=z[z.length-1];t&&B[B.length-1]===`braces`&&(t.comma=!0,e=`|`),Q({type:`comma`,value:H,output:e});continue}if(H===`/`){if(V.type===`dot`&&L.index===L.start+1){L.start=L.index+1,L.consumed=``,L.output=``,h.pop(),V=m;continue}Q({type:`slash`,value:H,output:C});continue}if(H===`.`){if(L.braces>0&&V.type===`dot`){V.value===`.`&&(V.output=x);let e=z[z.length-1];V.type=`dots`,V.output+=H,V.value+=H,e.dots=!0;continue}if(L.braces+L.parens===0&&V.type!==`bos`&&V.type!==`slash`){Q({type:`text`,value:H,output:x});continue}Q({type:`dot`,value:H,output:x});continue}if(H===`?`){if(!(V&&V.value===`(`)&&d.noextglob!==!0&&W()===`(`&&W(2)!==`?`){ee(`qmark`,H);continue}if(V&&V.type===`paren`){let e=W(),t=H;(V.value===`(`&&!/[!=<:]/.test(e)||e===`<`&&!/<([!=]|\w+>)/.test(K()))&&(t=`\\${H}`),Q({type:`text`,value:H,output:t});continue}if(d.dot!==!0&&(V.type===`slash`||V.type===`bos`)){Q({type:`qmark`,value:H,output:A});continue}Q({type:`qmark`,value:H,output:k});continue}if(H===`!`){if(d.noextglob!==!0&&W()===`(`&&(W(2)!==`?`||!/[!=<:]/.test(W(3)))){ee(`negate`,H);continue}if(d.nonegate!==!0&&L.index===0){Y();continue}}if(H===`+`){if(d.noextglob!==!0&&W()===`(`&&W(2)!==`?`){ee(`plus`,H);continue}if(V&&V.value===`(`||d.regex===!1){Q({type:`plus`,value:H,output:S});continue}if(V&&(V.type===`bracket`||V.type===`paren`||V.type===`brace`)||L.parens>0){Q({type:`plus`,value:H});continue}Q({type:`plus`,value:S});continue}if(H===`@`){if(d.noextglob!==!0&&W()===`(`&&W(2)!==`?`){Q({type:`at`,extglob:!0,value:H,output:``});continue}Q({type:`text`,value:H});continue}if(H!==`*`){(H===`$`||H===`^`)&&(H=`\\${H}`);let e=o.exec(K());e&&(H+=e[0],L.index+=e[0].length),Q({type:`text`,value:H});continue}if(V&&(V.type===`globstar`||V.star===!0)){V.type=`star`,V.star=!0,V.value+=H,V.output=I,L.backtrack=!0,L.globstar=!0,q(H);continue}let t=K();if(d.noextglob!==!0&&/^\([^?]/.test(t)){ee(`star`,H);continue}if(V.type===`star`){if(d.noglobstar===!0){q(H);continue}let n=V.prev,r=n.prev,i=n.type===`slash`||n.type===`bos`,a=r&&(r.type===`star`||r.type===`globstar`);if(d.bash===!0&&(!i||t[0]&&t[0]!==`/`)){Q({type:`star`,value:H,output:``});continue}let o=L.braces>0&&(n.type===`comma`||n.type===`brace`),s=R.length&&(n.type===`pipe`||n.type===`paren`);if(!i&&n.type!==`paren`&&!o&&!s){Q({type:`star`,value:H,output:``});continue}for(;t.slice(0,3)===`/**`;){let n=e[L.index+4];if(n&&n!==`/`)break;t=t.slice(3),q(`/**`,3)}if(n.type===`bos`&&U()){V.type=`globstar`,V.value+=H,V.output=N(d),L.output=V.output,L.globstar=!0,q(H);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&!a&&U()){L.output=L.output.slice(0,-(n.output+V.output).length),n.output=`(?:${n.output}`,V.type=`globstar`,V.output=N(d)+(d.strictSlashes?`)`:`|$)`),V.value+=H,L.globstar=!0,L.output+=n.output+V.output,q(H);continue}if(n.type===`slash`&&n.prev.type!==`bos`&&t[0]===`/`){let e=t[1]===void 0?``:`|$`;L.output=L.output.slice(0,-(n.output+V.output).length),n.output=`(?:${n.output}`,V.type=`globstar`,V.output=`${N(d)}${C}|${C}${e})`,V.value+=H,L.output+=n.output+V.output,L.globstar=!0,q(H+G()),Q({type:`slash`,value:`/`,output:``});continue}if(n.type===`bos`&&t[0]===`/`){V.type=`globstar`,V.value+=H,V.output=`(?:^|${C}|${N(d)}${C})`,L.output=V.output,L.globstar=!0,q(H+G()),Q({type:`slash`,value:`/`,output:``});continue}L.output=L.output.slice(0,-V.output.length),V.type=`globstar`,V.output=N(d),V.value+=H,L.output+=V.output,L.globstar=!0,q(H);continue}let n={type:`star`,value:H,output:I};if(d.bash===!0){n.output=`.*?`,(V.type===`bos`||V.type===`slash`)&&(n.output=P+n.output),Q(n);continue}if(V&&(V.type===`bracket`||V.type===`paren`)&&d.regex===!0){n.output=H,Q(n);continue}(L.index===L.start||V.type===`slash`||V.type===`dot`)&&(V.type===`dot`?(L.output+=D,V.output+=D):d.dot===!0?(L.output+=O,V.output+=O):(L.output+=P,V.output+=P),W()!==`*`&&(L.output+=w,V.output+=w)),Q(n)}for(;L.brackets>0;){if(d.strictBrackets===!0)throw SyntaxError(u(`closing`,`]`));L.output=r.escapeLast(L.output,`[`),Z(`brackets`)}for(;L.parens>0;){if(d.strictBrackets===!0)throw SyntaxError(u(`closing`,`)`));L.output=r.escapeLast(L.output,`(`),Z(`parens`)}for(;L.braces>0;){if(d.strictBrackets===!0)throw SyntaxError(u(`closing`,`}`));L.output=r.escapeLast(L.output,`{`),Z(`braces`)}if(d.strictSlashes!==!0&&(V.type===`star`||V.type===`bracket`)&&Q({type:`maybe_slash`,value:``,output:`${C}?`}),L.backtrack===!0){L.output=``;for(let e of L.tokens)L.output+=e.output==null?e.value:e.output,e.suffix&&(L.output+=e.suffix)}return L};y.fastpaths=(e,t)=>{let a={...t},o=typeof a.maxLength==`number`?Math.min(i,a.maxLength):i,s=e.length;if(s>o)throw SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${o}`);e=c[e]||e;let{DOT_LITERAL:l,SLASH_LITERAL:u,ONE_CHAR:d,DOTS_SLASH:f,NO_DOT:p,NO_DOTS:m,NO_DOTS_SLASH:h,STAR:g,START_ANCHOR:_}=n.globChars(a.windows),v=a.dot?m:p,y=a.dot?h:p,b=a.capture?``:`?:`,x={negated:!1,prefix:``},S=a.bash===!0?`.*?`:g;a.capture&&(S=`(${S})`);let C=e=>e.noglobstar===!0?S:`(${b}(?:(?!${_}${e.dot?f:l}).)*?)`,w=e=>{switch(e){case`*`:return`${v}${d}${S}`;case`.*`:return`${l}${d}${S}`;case`*.*`:return`${v}${S}${l}${d}${S}`;case`*/*`:return`${v}${S}${u}${d}${y}${S}`;case`**`:return v+C(a);case`**/*`:return`(?:${v}${C(a)}${u})?${y}${d}${S}`;case`**/*.*`:return`(?:${v}${C(a)}${u})?${y}${S}${l}${d}${S}`;case`**/.*`:return`(?:${v}${C(a)}${u})?${l}${d}${S}`;default:{let t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;let n=w(t[1]);return n?n+l+t[2]:void 0}}},T=w(r.removePrefix(e,x));return T&&a.strictSlashes!==!0&&(T+=`${u}?`),T},t.exports=y})),E=s(((e,t)=>{let n=w(),r=T(),i=C(),a=S(),o=e=>e&&typeof e==`object`&&!Array.isArray(e),s=(e,t,n=!1)=>{if(Array.isArray(e)){let r=e.map(e=>s(e,t,n));return e=>{for(let t of r){let n=t(e);if(n)return n}return!1}}let r=o(e)&&e.tokens&&e.input;if(e===``||typeof e!=`string`&&!r)throw TypeError(`Expected pattern to be a non-empty string`);let i=t||{},a=i.windows,c=r?s.compileRe(e,t):s.makeRe(e,t,!1,!0),l=c.state;delete c.state;let u=()=>!1;if(i.ignore){let e={...t,ignore:null,onMatch:null,onResult:null};u=s(i.ignore,e,n)}let d=(n,r=!1)=>{let{isMatch:o,match:d,output:f}=s.test(n,c,t,{glob:e,posix:a}),p={glob:e,state:l,regex:c,posix:a,input:n,output:f,match:d,isMatch:o};return typeof i.onResult==`function`&&i.onResult(p),o===!1?(p.isMatch=!1,r?p:!1):u(n)?(typeof i.onIgnore==`function`&&i.onIgnore(p),p.isMatch=!1,r?p:!1):(typeof i.onMatch==`function`&&i.onMatch(p),r?p:!0)};return n&&(d.state=l),d};s.test=(e,t,n,{glob:r,posix:a}={})=>{if(typeof e!=`string`)throw TypeError(`Expected input to be a string`);if(e===``)return{isMatch:!1,output:``};let o=n||{},c=o.format||(a?i.toPosixSlashes:null),l=e===r,u=l&&c?c(e):e;return l===!1&&(u=c?c(e):e,l=u===r),(l===!1||o.capture===!0)&&(l=o.matchBase===!0||o.basename===!0?s.matchBase(e,t,n,a):t.exec(u)),{isMatch:!!l,match:l,output:u}},s.matchBase=(e,t,n)=>(t instanceof RegExp?t:s.makeRe(t,n)).test(i.basename(e)),s.isMatch=(e,t,n)=>s(t,n)(e),s.parse=(e,t)=>Array.isArray(e)?e.map(e=>s.parse(e,t)):r(e,{...t,fastpaths:!1}),s.scan=(e,t)=>n(e,t),s.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let i=t||{},a=i.contains?``:`^`,o=i.contains?``:`$`,c=`${a}(?:${e.output})${o}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let l=s.toRegex(c,t);return r===!0&&(l.state=e),l},s.makeRe=(e,t={},n=!1,i=!1)=>{if(!e||typeof e!=`string`)throw TypeError(`Expected a non-empty string`);let a={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]===`.`||e[0]===`*`)&&(a.output=r.fastpaths(e,t)),a.output||(a=r(e,t)),s.compileRe(a,t,n,i)},s.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?`i`:``))}catch(e){if(t&&t.debug===!0)throw e;return/$^/}},s.constants=a,t.exports=s})),D=s(((e,t)=>{let n=E(),r=C();function i(e,t,i=!1){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:r.isWindows()}),n(e,t,i)}Object.assign(i,n),t.exports=i})),O=s((e=>{var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),s(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e));let u=l(c(`path`)),d=l(c(`fs`));function f(e){let t=(0,u.normalize)(e);return t.length>1&&t[t.length-1]===u.sep&&(t=t.substring(0,t.length-1)),t}let p=/[\\/]/g;function m(e,t){return e.replace(p,t)}let h=/^[a-z]:[\\/]$/i;function g(e){return e===`/`||h.test(e)}function _(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=(0,u.resolve)(e)),(r||a)&&(e=f(e)),e===`.`?``:m(e[e.length-1]===i?e:e+i,i)}function v(e,t){return t+e}function y(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:m((0,u.relative)(e,r),t.pathSeparator)+t.pathSeparator+n}}function b(e){return e}function x(e,t,n){return t+e+n}function S(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?y(e,t):r?v:b}function C(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function w(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}let T=(e,t)=>{t.push(e||`.`)},E=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},O=()=>{};function k(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?w(e):C(e):r&&r.length?E:T:O}let A=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},j=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},M=(e,t,n,r)=>{n.files++},N=(e,t)=>{t.push(e)},P=()=>{};function F(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?P:n&&n.length?r?A:j:r?M:N}let I=e=>e,L=()=>[``].slice(0,0);function R(e){return e.group?L:I}let z=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},B=()=>{};function V(e){return e.group?z:B}let H=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&G(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},U=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&G(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function W(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?U:H}function G(e,t,n){if(n.options.useRealPaths)return K(t,n);let r=(0,u.dirname)(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=(0,u.dirname)(r)}return n.symlinks.set(e,t),i>1}function K(e,t){return t.visited.includes(e+t.options.pathSeparator)}let q=e=>e.counts,J=e=>e.groups,Y=e=>e.paths,X=e=>e.paths.slice(0,e.options.maxFiles),Z=(e,t,n)=>(ne(t,n,e.counts,e.options.suppressErrors),null),Q=(e,t,n)=>(ne(t,n,e.paths,e.options.suppressErrors),null),ee=(e,t,n)=>(ne(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),te=(e,t,n)=>(ne(t,n,e.groups,e.options.suppressErrors),null);function ne(e,t,n,r){t(e&&!r?e:null,n)}function re(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?q:Z:r?t?J:te:i?t?X:ee:t?Y:Q}let ie={withFileTypes:!0},ae=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,ie,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},oe=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,ie)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function se(e){return e?oe:ae}var ce=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},le=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}get dirs(){return this._directories}},ue=class{aborted=!1;abort(){this.aborted=!0}},de=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,t,n){this.isSynchronous=!n,this.callbackInvoker=re(t,this.isSynchronous),this.root=_(e,t),this.state={root:g(this.root)?this.root:this.root.slice(0,-1),paths:[``].slice(0,0),groups:[],counts:new le,options:t,queue:new ce((e,t)=>this.callbackInvoker(t,e,n)),symlinks:new Map,visited:[``].slice(0,0),controller:new ue,fs:t.fs||d},this.joinPath=S(this.root,t),this.pushDirectory=k(this.root,t),this.pushFile=F(t),this.getArray=R(t),this.groupFiles=V(t),this.resolveSymlink=W(t,this.isSynchronous),this.walkDirectory=se(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,t,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:a,excludeSymlinks:o,exclude:s,maxFiles:c,signal:l,useRealPaths:d,pathSeparator:f},controller:p}=this.state;if(p.aborted||l&&l.aborted||c&&r.length>c)return;let m=this.getArray(this.state.paths);for(let c=0;c<e.length;++c){let l=e[c];if(l.isFile()||l.isSymbolicLink()&&!a&&!o){let e=this.joinPath(l.name,t);this.pushFile(e,m,this.state.counts,i)}else if(l.isDirectory()){let e=x(l.name,t,this.state.options.pathSeparator);if(s&&s(l.name,e))continue;this.pushDirectory(e,r,i),this.walkDirectory(this.state,e,e,n-1,this.walk)}else if(this.resolveSymlink&&l.isSymbolicLink()){let e=v(l.name,t);this.resolveSymlink(e,this.state,(t,r)=>{if(t.isDirectory()){if(r=_(r,this.state.options),s&&s(l.name,d?r:e+f))return;this.walkDirectory(this.state,r,d?r:e+f,n-1,this.walk)}else{r=d?r:e;let t=(0,u.basename)(r),n=_((0,u.dirname)(r),this.state.options);r=this.joinPath(t,n),this.pushFile(r,m,this.state.counts,i)}})}}this.groupFiles(this.state.groups,t,m)}};function fe(e,t){return new Promise((n,r)=>{pe(e,t,(e,t)=>{if(e)return r(e);n(t)})})}function pe(e,t,n){new de(e,t,n).start()}function me(e,t){return new de(e,t).start()}var he=class{constructor(e,t){this.root=e,this.options=t}withPromise(){return fe(this.root,this.options)}withCallback(e){pe(this.root,this.options,e)}sync(){return me(this.root,this.options)}};let ge=null;try{c.resolve(`picomatch`),ge=D()}catch{}e.fdir=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:u.sep,filters:[]};globFunction;constructor(e){this.options={...this.options,...e},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(e){return this.options.pathSeparator=e,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(e){return this.options.maxDepth=e,this}withMaxFiles(e){return this.options.maxFiles=e,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:e=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=e,this.withFullPaths()}withAbortSignal(e){return this.options.signal=e,this}normalize(){return this.options.normalizePath=!0,this}filter(e){return this.options.filters.push(e),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(e){return this.options.exclude=e,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(e){return new he(e||`.`,this.options)}withGlobFunction(e){return this.globFunction=e,this}crawlWithOptions(e,t){return this.options={...this.options,...t},new he(e||`.`,this.options)}glob(...e){return this.globFunction?this.globWithOptions(e):this.globWithOptions(e,{dot:!0})}globWithOptions(e,...t){let n=this.globFunction||ge;if(!n)throw Error(`Please specify a glob function to use glob matching.`);var r=this.globCache[e.join(`\0`)];return r||(r=n(e,...t),this.globCache[e.join(`\0`)]=r),this.options.filters.push(e=>r(e)),this}}})),k=s(((e,t)=>{let{fdir:n}=O(),r=c(`path`),i=D();t.exports=class{constructor(e=`./`,t=[`.env*`],n=[]){this.ignore=[`node_modules/**`,`.git/**`],this.cwd=r.resolve(e),this.envFile=t,this.excludeEnvFile=n}run(){return this._filepaths()}_filepaths(){let e=i(this._exclude()),t=i(this._patterns(),{ignore:this._exclude()});return new n().withRelativePaths().exclude((t,n)=>e(n)).filter(e=>t(e)).crawl(this.cwd).sync()}_patterns(){return Array.isArray(this.envFile)?this.envFile.map(e=>`**/${e}`):[`**/${this.envFile}`]}_excludePatterns(){return Array.isArray(this.excludeEnvFile)?this.excludeEnvFile.map(e=>`**/${e}`):[`**/${this.excludeEnvFile}`]}_exclude(){return this._excludePatterns().length>0?this.ignore.concat(this._excludePatterns()):this.ignore}}})),A=s(((e,t)=>{let n=c(`fs`),r=`utf8`;async function i(e,t=null){return t||=r,n.promises.readFile(e,t)}function a(e,t=null){return t||=r,n.readFileSync(e,t)}function o(e,t){return n.writeFileSync(e,t,r)}async function s(e,t){return n.promises.writeFile(e,t,r)}async function l(e){try{return await n.promises.access(e),!0}catch{return!1}}t.exports={chmodSync:n.chmodSync,exists:l,existsSync:n.existsSync,readdirSync:n.readdirSync,readFileSync:n.readFileSync,writeFileSync:n.writeFileSync,appendFileSync:n.appendFileSync,readFileX:i,readFileXSync:a,writeFileX:s,writeFileXSync:o}})),j=s(((e,t)=>{let{fdir:n}=O(),r=c(`path`),i=D(),a=A(),o=[{lang:`Python`,file:/\.py$/,match:/load_dotenv\s*\([^)]*\)/,msg:`found python-dotenv load call`},{lang:`Python`,file:/\.py$/,match:/dotenv_values\s*\([^)]*\)/,msg:`found python-dotenv values call`},{lang:`Node`,file:/\.(js|cjs|mjs|ts)$/,match:/require\(['"]dotenv['"]\)\.config\s*\([^)]*\)/,msg:`found dotenv config require call`},{lang:`Node`,file:/\.(js|cjs|mjs|ts)$/,match:/import\s+['"]dotenv\/config['"]/,msg:`found dotenv/config import`},{lang:`Node`,file:/\.(js|cjs|mjs|ts)$/,match:/dotenv\.config\s*\([^)]*\)/,msg:`found dotenv config call`},{lang:`Ruby`,file:/\.rb$/,match:/Dotenv\.(load|overload)\s*\([^)]*\)/,msg:`found ruby dotenv load call`},{lang:`Go`,file:/\.go$/,match:/godotenv\.(Load|Overload)\s*\([^)]*\)/,msg:`found godotenv load call`},{lang:`PHP`,file:/\.php$/,match:/Dotenv\\Dotenv::create\w*\s*\([^)]*\)/,msg:`found vlucas/phpdotenv loader`},{lang:`Rust`,file:/\.rs$/,match:/dotenvy?::dotenv\s*\([^)]*\)/,msg:`found Rust dotenv load call`},{lang:`Java`,file:/\.java$/,match:/Dotenv\.(load|configure)\s*\([^)]*\)/,msg:`found java-dotenv load call`},{lang:`Kotlin`,file:/\.kt$/,match:/Dotenv\.(load|configure)\s*\([^)]*\)/,msg:`found java-dotenv load call`},{lang:`.NET`,file:/\.(cs|fs|vb)$/,match:/(?:DotNetEnv\.)?Env\.Load\s*\([^)]*\)/,msg:`found DotNetEnv load call`}];var s=class{constructor(e=`./`){this.cwd=r.resolve(e),this.ignore=[`**/node_modules/**`,`**/.git/**`,`**/vendor/**`,`**/dist/**`,`**/build/**`,`**/coverage/**`,`**/.next/**`],this.exclude=i(this.ignore)}run(){let e=[];for(let t of this._filepaths())e.push(...this._scanFile(t));return e}_filepaths(){return new n().withRelativePaths().exclude((e,t)=>this._ignored(t)).filter(e=>this._patternsFor(e).length>0).crawl(this.cwd).sync().sort()}_scanFile(e){let t=a.readFileXSync(r.join(this.cwd,e)).split(/\r?\n/),n=[];return t.forEach((t,r)=>{for(let i of this._patternsFor(e))if(i.match.test(t)){let a=t.match(i.match);n.push({lang:i.lang,filepath:e,line:r+1,code:a[0].trim(),msg:i.msg})}}),n}_patternsFor(e){return o.filter(t=>t.file.test(e))}_ignored(e){return this.exclude(e)}};s.patterns=o,t.exports=s})),M=s((e=>{
|
|
3
|
+
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
|
4
|
+
Object.defineProperty(e,`__esModule`,{value:!0}),e.wrapCipher=e.Hash=e.nextTick=e.isLE=void 0,e.isBytes=t,e.abool=n,e.anumber=r,e.abytes=i,e.ahash=a,e.aexists=o,e.aoutput=s,e.u8=c,e.u32=l,e.clean=u,e.createView=d,e.bytesToHex=m,e.hexToBytes=_,e.hexToNumber=v,e.bytesToNumberBE=y,e.numberToBytesBE=b,e.utf8ToBytes=x,e.bytesToUtf8=S,e.toBytes=C,e.overlapBytes=w,e.complexOverlapBytes=T,e.concatBytes=E,e.checkOpts=D,e.equalBytes=O,e.getOutput=k,e.setBigUint64=A,e.u64Lengths=j,e.isAligned32=M,e.copyBytes=N;function t(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function n(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}function r(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function i(e,...n){if(!t(e))throw Error(`Uint8Array expected`);if(n.length>0&&!n.includes(e.length))throw Error(`Uint8Array expected of length `+n+`, got length=`+e.length)}function a(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);r(e.outputLen),r(e.blockLen)}function o(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function s(e,t){i(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function c(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function l(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function d(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;let f=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,p=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function m(e){if(i(e),f)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=p[e[n]];return t}let h={_0:48,_9:57,A:65,F:70,a:97,f:102};function g(e){if(e>=h._0&&e<=h._9)return e-h._0;if(e>=h.A&&e<=h.F)return e-(h.A-10);if(e>=h.a&&e<=h.f)return e-(h.a-10)}function _(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(f)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=g(e.charCodeAt(i)),a=g(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function v(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x`+e)}function y(e){return v(m(e))}function b(e,t){return _(e.toString(16).padStart(t*2,`0`))}e.nextTick=async()=>{};function x(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function S(e){return new TextDecoder().decode(e)}function C(e){if(typeof e==`string`)e=x(e);else if(t(e))e=N(e);else throw Error(`Uint8Array expected, got `+typeof e);return e}function w(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function T(e,t){if(w(e,t)&&e.byteOffset<t.byteOffset)throw Error(`complex overlap of input and output is not supported`)}function E(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];i(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function D(e,t){if(typeof t!=`object`||!t)throw Error(`options must be defined`);return Object.assign(e,t)}function O(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}e.Hash=class{},e.wrapCipher=(t,n)=>{function r(r,...a){if(i(r),!e.isLE)throw Error(`Non little-endian hardware is not yet supported`);if(t.nonceLength!==void 0){let e=a[0];if(!e)throw Error(`nonce / iv required`);t.varSizeNonce?i(e):i(e,t.nonceLength)}let o=t.tagLength;o&&a[1]!==void 0&&i(a[1]);let s=n(r,...a),c=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);i(t)}},l=!1;return{encrypt(e,t){if(l)throw Error(`cannot encrypt() twice with same key + nonce`);return l=!0,i(e),c(s.encrypt.length,t),s.encrypt(e,t)},decrypt(e,t){if(i(e),o&&e.length<o)throw Error(`invalid ciphertext length: smaller than tagLength=`+o);return c(s.decrypt.length,t),s.decrypt(e,t)}}}return Object.assign(r,t),r};function k(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`invalid output length, expected `+e+`, got: `+t.length);if(n&&!M(t))throw Error(`invalid output, must be aligned`);return t}function A(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function j(e,t,r){n(r);let i=new Uint8Array(16),a=d(i);return A(a,0,BigInt(t),r),A(a,8,BigInt(e),r),i}function M(e){return e.byteOffset%4==0}function N(e){return Uint8Array.from(e)}})),N=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AEAD_TAG_LENGTH=e.XCHACHA20_NONCE_LENGTH=e.CURVE25519_PUBLIC_KEY_SIZE=e.ETH_PUBLIC_KEY_SIZE=e.UNCOMPRESSED_PUBLIC_KEY_SIZE=e.COMPRESSED_PUBLIC_KEY_SIZE=e.SECRET_KEY_LENGTH=void 0,e.SECRET_KEY_LENGTH=32,e.COMPRESSED_PUBLIC_KEY_SIZE=33,e.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,e.ETH_PUBLIC_KEY_SIZE=64,e.CURVE25519_PUBLIC_KEY_SIZE=32,e.XCHACHA20_NONCE_LENGTH=24,e.AEAD_TAG_LENGTH=16})),P=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ephemeralKeySize=e.symmetricNonceLength=e.symmetricAlgorithm=e.isHkdfKeyCompressed=e.isEphemeralKeyCompressed=e.ellipticCurve=e.ECIES_CONFIG=void 0;var t=N();e.ECIES_CONFIG=new(function(){function e(){this.ellipticCurve=`secp256k1`,this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm=`aes-256-gcm`,this.symmetricNonceLength=16}return e}()),e.ellipticCurve=function(){return e.ECIES_CONFIG.ellipticCurve},e.isEphemeralKeyCompressed=function(){return e.ECIES_CONFIG.isEphemeralKeyCompressed},e.isHkdfKeyCompressed=function(){return e.ECIES_CONFIG.isHkdfKeyCompressed},e.symmetricAlgorithm=function(){return e.ECIES_CONFIG.symmetricAlgorithm},e.symmetricNonceLength=function(){return e.ECIES_CONFIG.symmetricNonceLength},e.ephemeralKeySize=function(){var n={secp256k1:e.ECIES_CONFIG.isEphemeralKeyCompressed?t.COMPRESSED_PUBLIC_KEY_SIZE:t.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:t.CURVE25519_PUBLIC_KEY_SIZE,ed25519:t.CURVE25519_PUBLIC_KEY_SIZE};if(e.ECIES_CONFIG.ellipticCurve in n)return n[e.ECIES_CONFIG.ellipticCurve];throw Error(`Not implemented`)}})),F=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.crypto=void 0;let t=c(`node:crypto`);e.crypto=t&&typeof t==`object`&&`webcrypto`in t?t.webcrypto:t&&typeof t==`object`&&`randomBytes`in t?t:void 0})),I=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.gcm=e.ctr=e.cbc=e.utils=void 0,e.randomBytes=r,e.getWebcryptoSubtle=i,e.managedNonce=a;let t=F(),n=M();function r(e=32){if(t.crypto&&typeof t.crypto.getRandomValues==`function`)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&typeof t.crypto.randomBytes==`function`)return Uint8Array.from(t.crypto.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}function i(){if(t.crypto&&typeof t.crypto.subtle==`object`&&t.crypto.subtle!=null)return t.crypto.subtle;throw Error(`crypto.subtle must be defined`)}function a(e){let{nonceLength:t}=e;return(0,n.anumber)(t),((i,...a)=>({encrypt(o,...s){let c=r(t),l=e(i,c,...a).encrypt(o,...s),u=(0,n.concatBytes)(c,l);return l.fill(0),u},decrypt(n,...r){let o=n.subarray(0,t),s=n.subarray(t);return e(i,o,...a).decrypt(s,...r)}}))}e.utils={async encrypt(e,t,n,r){let a=i(),o=await a.importKey(`raw`,e,t,!0,[`encrypt`]),s=await a.encrypt(n,o,r);return new Uint8Array(s)},async decrypt(e,t,n,r){let a=i(),o=await a.importKey(`raw`,e,t,!0,[`decrypt`]),s=await a.decrypt(n,o,r);return new Uint8Array(s)}};let o={CBC:`AES-CBC`,CTR:`AES-CTR`,GCM:`AES-GCM`};function s(e,t,n){if(e===o.CBC)return{name:o.CBC,iv:t};if(e===o.CTR)return{name:o.CTR,counter:t,length:64};if(e===o.GCM)return n?{name:o.GCM,iv:t,additionalData:n}:{name:o.GCM,iv:t};throw Error(`unknown aes block mode`)}function c(t){return(r,i,a)=>{(0,n.abytes)(r),(0,n.abytes)(i);let o={name:t,length:r.length*8},c=s(t,i,a),l=!1;return{encrypt(t){if((0,n.abytes)(t),l)throw Error(`Cannot encrypt() twice with same key / nonce`);return l=!0,e.utils.encrypt(r,o,c,t)},decrypt(t){return(0,n.abytes)(t),e.utils.decrypt(r,o,c,t)}}}}e.cbc=c(o.CBC),e.ctr=c(o.CTR),e.gcm=c(o.GCM)})),L=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.crypto=void 0;let t=c(`node:crypto`);e.crypto=t&&typeof t==`object`&&`webcrypto`in t?t.webcrypto:t&&typeof t==`object`&&`randomBytes`in t?t:void 0})),R=s((e=>{
|
|
5
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6
|
+
Object.defineProperty(e,`__esModule`,{value:!0}),e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.Hash=e.nextTick=e.swap32IfBE=e.byteSwapIfBE=e.swap8IfBE=e.isLE=void 0,e.isBytes=n,e.anumber=r,e.abytes=i,e.ahash=a,e.aexists=o,e.aoutput=s,e.u8=c,e.u32=l,e.clean=u,e.createView=d,e.rotr=f,e.rotl=p,e.byteSwap=m,e.byteSwap32=h,e.bytesToHex=v,e.hexToBytes=x,e.asyncLoop=S,e.utf8ToBytes=C,e.bytesToUtf8=w,e.toBytes=T,e.kdfInputToBytes=E,e.concatBytes=D,e.checkOpts=O,e.createHasher=k,e.createOptHasher=A,e.createXOFer=j,e.randomBytes=M;let t=L();function n(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function r(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function i(e,...t){if(!n(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function a(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);r(e.outputLen),r(e.blockLen)}function o(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function s(e,t){i(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function c(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function l(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function d(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}function p(e,t){return e<<t|e>>>32-t>>>0}e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function m(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}e.swap8IfBE=e.isLE?e=>e:e=>m(e),e.byteSwapIfBE=e.swap8IfBE;function h(e){for(let t=0;t<e.length;t++)e[t]=m(e[t]);return e}e.swap32IfBE=e.isLE?e=>e:h;let g=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,_=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function v(e){if(i(e),g)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=_[e[n]];return t}let y={_0:48,_9:57,A:65,F:70,a:97,f:102};function b(e){if(e>=y._0&&e<=y._9)return e-y._0;if(e>=y.A&&e<=y.F)return e-(y.A-10);if(e>=y.a&&e<=y.f)return e-(y.a-10)}function x(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(g)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=b(e.charCodeAt(i)),a=b(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}e.nextTick=async()=>{};async function S(t,n,r){let i=Date.now();for(let a=0;a<t;a++){r(a);let t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}}function C(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function w(e){return new TextDecoder().decode(e)}function T(e){return typeof e==`string`&&(e=C(e)),i(e),e}function E(e){return typeof e==`string`&&(e=C(e)),i(e),e}function D(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];i(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function O(e,t){if(t!==void 0&&{}.toString.call(t)!==`[object Object]`)throw Error(`options should be object or undefined`);return Object.assign(e,t)}e.Hash=class{};function k(e){let t=t=>e().update(T(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function A(e){let t=(t,n)=>e(n).update(T(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function j(e){let t=(t,n)=>e(n).update(T(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}e.wrapConstructor=k,e.wrapConstructorWithOpts=A,e.wrapXOFConstructorWithOpts=j;function M(e=32){if(t.crypto&&typeof t.crypto.getRandomValues==`function`)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&typeof t.crypto.randomBytes==`function`)return Uint8Array.from(t.crypto.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}})),z=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SHA512_IV=e.SHA384_IV=e.SHA224_IV=e.SHA256_IV=e.HashMD=void 0,e.setBigUint64=n,e.Chi=r,e.Maj=i;let t=R();function n(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function r(e,t,n){return e&t^~e&n}function i(e,t,n){return e&t^e&n^t&n}e.HashMD=class extends t.Hash{constructor(e,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=(0,t.createView)(this.buffer)}update(e){(0,t.aexists)(this),e=(0,t.toBytes)(e),(0,t.abytes)(e);let{view:n,buffer:r,blockLen:i}=this,a=e.length;for(let o=0;o<a;){let s=Math.min(i-this.pos,a-o);if(s===i){let n=(0,t.createView)(e);for(;i<=a-o;o+=i)this.process(n,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,t.aexists)(this),(0,t.aoutput)(e,this),this.finished=!0;let{buffer:r,view:i,blockLen:a,isLE:o}=this,{pos:s}=this;r[s++]=128,(0,t.clean)(this.buffer.subarray(s)),this.padOffset>a-s&&(this.process(i,0),s=0);for(let e=s;e<a;e++)r[e]=0;n(i,a-8,BigInt(this.length*8),o),this.process(i,0);let c=(0,t.createView)(e),l=this.outputLen;if(l%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let u=l/4,d=this.get();if(u>d.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<u;e++)c.setUint32(4*e,d[e],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},e.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),e.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),e.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),e.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])})),B=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.toBig=e.shrSL=e.shrSH=e.rotrSL=e.rotrSH=e.rotrBL=e.rotrBH=e.rotr32L=e.rotr32H=e.rotlSL=e.rotlSH=e.rotlBL=e.rotlBH=e.add5L=e.add5H=e.add4L=e.add4H=e.add3L=e.add3H=void 0,e.add=v,e.fromBig=r,e.split=i;let t=BigInt(2**32-1),n=BigInt(32);function r(e,r=!1){return r?{h:Number(e&t),l:Number(e>>n&t)}:{h:Number(e>>n&t)|0,l:Number(e&t)|0}}function i(e,t=!1){let n=e.length,i=new Uint32Array(n),a=new Uint32Array(n);for(let o=0;o<n;o++){let{h:n,l:s}=r(e[o],t);[i[o],a[o]]=[n,s]}return[i,a]}let a=(e,t)=>BigInt(e>>>0)<<n|BigInt(t>>>0);e.toBig=a;let o=(e,t,n)=>e>>>n;e.shrSH=o;let s=(e,t,n)=>e<<32-n|t>>>n;e.shrSL=s;let c=(e,t,n)=>e>>>n|t<<32-n;e.rotrSH=c;let l=(e,t,n)=>e<<32-n|t>>>n;e.rotrSL=l;let u=(e,t,n)=>e<<64-n|t>>>n-32;e.rotrBH=u;let d=(e,t,n)=>e>>>n-32|t<<64-n;e.rotrBL=d;let f=(e,t)=>t;e.rotr32H=f;let p=(e,t)=>e;e.rotr32L=p;let m=(e,t,n)=>e<<n|t>>>32-n;e.rotlSH=m;let h=(e,t,n)=>t<<n|e>>>32-n;e.rotlSL=h;let g=(e,t,n)=>t<<n-32|e>>>64-n;e.rotlBH=g;let _=(e,t,n)=>e<<n-32|t>>>64-n;e.rotlBL=_;function v(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}let y=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);e.add3L=y;let b=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;e.add3H=b;let x=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);e.add4L=x;let S=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;e.add4H=S;let C=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);e.add5L=C;let w=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0;e.add5H=w,e.default={fromBig:r,split:i,toBig:a,shrSH:o,shrSL:s,rotrSH:c,rotrSL:l,rotrBH:u,rotrBL:d,rotr32H:f,rotr32L:p,rotlSH:m,rotlSL:h,rotlBH:g,rotlBL:_,add:v,add3L:y,add3H:b,add4L:x,add4H:S,add5H:w,add5L:C}})),V=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.sha512_224=e.sha512_256=e.sha384=e.sha512=e.sha224=e.sha256=e.SHA512_256=e.SHA512_224=e.SHA384=e.SHA512=e.SHA224=e.SHA256=void 0;let t=z(),n=B(),r=R(),i=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=new Uint32Array(64);var o=class extends t.HashMD{constructor(e=32){super(64,e,8,!1),this.A=t.SHA256_IV[0]|0,this.B=t.SHA256_IV[1]|0,this.C=t.SHA256_IV[2]|0,this.D=t.SHA256_IV[3]|0,this.E=t.SHA256_IV[4]|0,this.F=t.SHA256_IV[5]|0,this.G=t.SHA256_IV[6]|0,this.H=t.SHA256_IV[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,n){for(let t=0;t<16;t++,n+=4)a[t]=e.getUint32(n,!1);for(let e=16;e<64;e++){let t=a[e-15],n=a[e-2],i=(0,r.rotr)(t,7)^(0,r.rotr)(t,18)^t>>>3;a[e]=((0,r.rotr)(n,17)^(0,r.rotr)(n,19)^n>>>10)+a[e-7]+i+a[e-16]|0}let{A:o,B:s,C:c,D:l,E:u,F:d,G:f,H:p}=this;for(let e=0;e<64;e++){let n=(0,r.rotr)(u,6)^(0,r.rotr)(u,11)^(0,r.rotr)(u,25),m=p+n+(0,t.Chi)(u,d,f)+i[e]+a[e]|0,h=((0,r.rotr)(o,2)^(0,r.rotr)(o,13)^(0,r.rotr)(o,22))+(0,t.Maj)(o,s,c)|0;p=f,f=d,d=u,u=l+m|0,l=c,c=s,s=o,o=m+h|0}o=o+this.A|0,s=s+this.B|0,c=c+this.C|0,l=l+this.D|0,u=u+this.E|0,d=d+this.F|0,f=f+this.G|0,p=p+this.H|0,this.set(o,s,c,l,u,d,f,p)}roundClean(){(0,r.clean)(a)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,r.clean)(this.buffer)}};e.SHA256=o;var s=class extends o{constructor(){super(28),this.A=t.SHA224_IV[0]|0,this.B=t.SHA224_IV[1]|0,this.C=t.SHA224_IV[2]|0,this.D=t.SHA224_IV[3]|0,this.E=t.SHA224_IV[4]|0,this.F=t.SHA224_IV[5]|0,this.G=t.SHA224_IV[6]|0,this.H=t.SHA224_IV[7]|0}};e.SHA224=s;let c=n.split(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),l=c[0],u=c[1],d=new Uint32Array(80),f=new Uint32Array(80);var p=class extends t.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=t.SHA512_IV[0]|0,this.Al=t.SHA512_IV[1]|0,this.Bh=t.SHA512_IV[2]|0,this.Bl=t.SHA512_IV[3]|0,this.Ch=t.SHA512_IV[4]|0,this.Cl=t.SHA512_IV[5]|0,this.Dh=t.SHA512_IV[6]|0,this.Dl=t.SHA512_IV[7]|0,this.Eh=t.SHA512_IV[8]|0,this.El=t.SHA512_IV[9]|0,this.Fh=t.SHA512_IV[10]|0,this.Fl=t.SHA512_IV[11]|0,this.Gh=t.SHA512_IV[12]|0,this.Gl=t.SHA512_IV[13]|0,this.Hh=t.SHA512_IV[14]|0,this.Hl=t.SHA512_IV[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)d[n]=e.getUint32(t),f[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=d[e-15]|0,r=f[e-15]|0,i=n.rotrSH(t,r,1)^n.rotrSH(t,r,8)^n.shrSH(t,r,7),a=n.rotrSL(t,r,1)^n.rotrSL(t,r,8)^n.shrSL(t,r,7),o=d[e-2]|0,s=f[e-2]|0,c=n.rotrSH(o,s,19)^n.rotrBH(o,s,61)^n.shrSH(o,s,6),l=n.rotrSL(o,s,19)^n.rotrBL(o,s,61)^n.shrSL(o,s,6),u=n.add4L(a,l,f[e-7],f[e-16]);d[e]=n.add4H(u,i,c,d[e-7],d[e-16])|0,f[e]=u|0}let{Ah:r,Al:i,Bh:a,Bl:o,Ch:s,Cl:c,Dh:p,Dl:m,Eh:h,El:g,Fh:_,Fl:v,Gh:y,Gl:b,Hh:x,Hl:S}=this;for(let e=0;e<80;e++){let t=n.rotrSH(h,g,14)^n.rotrSH(h,g,18)^n.rotrBH(h,g,41),C=n.rotrSL(h,g,14)^n.rotrSL(h,g,18)^n.rotrBL(h,g,41),w=h&_^~h&y,T=g&v^~g&b,E=n.add5L(S,C,T,u[e],f[e]),D=n.add5H(E,x,t,w,l[e],d[e]),O=E|0,k=n.rotrSH(r,i,28)^n.rotrBH(r,i,34)^n.rotrBH(r,i,39),A=n.rotrSL(r,i,28)^n.rotrBL(r,i,34)^n.rotrBL(r,i,39),j=r&a^r&s^a&s,M=i&o^i&c^o&c;x=y|0,S=b|0,y=_|0,b=v|0,_=h|0,v=g|0,{h,l:g}=n.add(p|0,m|0,D|0,O|0),p=s|0,m=c|0,s=a|0,c=o|0,a=r|0,o=i|0;let N=n.add3L(O,A,M);r=n.add3H(N,D,k,j),i=N|0}({h:r,l:i}=n.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:a,l:o}=n.add(this.Bh|0,this.Bl|0,a|0,o|0),{h:s,l:c}=n.add(this.Ch|0,this.Cl|0,s|0,c|0),{h:p,l:m}=n.add(this.Dh|0,this.Dl|0,p|0,m|0),{h,l:g}=n.add(this.Eh|0,this.El|0,h|0,g|0),{h:_,l:v}=n.add(this.Fh|0,this.Fl|0,_|0,v|0),{h:y,l:b}=n.add(this.Gh|0,this.Gl|0,y|0,b|0),{h:x,l:S}=n.add(this.Hh|0,this.Hl|0,x|0,S|0),this.set(r,i,a,o,s,c,p,m,h,g,_,v,y,b,x,S)}roundClean(){(0,r.clean)(d,f)}destroy(){(0,r.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};e.SHA512=p;var m=class extends p{constructor(){super(48),this.Ah=t.SHA384_IV[0]|0,this.Al=t.SHA384_IV[1]|0,this.Bh=t.SHA384_IV[2]|0,this.Bl=t.SHA384_IV[3]|0,this.Ch=t.SHA384_IV[4]|0,this.Cl=t.SHA384_IV[5]|0,this.Dh=t.SHA384_IV[6]|0,this.Dl=t.SHA384_IV[7]|0,this.Eh=t.SHA384_IV[8]|0,this.El=t.SHA384_IV[9]|0,this.Fh=t.SHA384_IV[10]|0,this.Fl=t.SHA384_IV[11]|0,this.Gh=t.SHA384_IV[12]|0,this.Gl=t.SHA384_IV[13]|0,this.Hh=t.SHA384_IV[14]|0,this.Hl=t.SHA384_IV[15]|0}};e.SHA384=m;let h=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),g=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);var _=class extends p{constructor(){super(28),this.Ah=h[0]|0,this.Al=h[1]|0,this.Bh=h[2]|0,this.Bl=h[3]|0,this.Ch=h[4]|0,this.Cl=h[5]|0,this.Dh=h[6]|0,this.Dl=h[7]|0,this.Eh=h[8]|0,this.El=h[9]|0,this.Fh=h[10]|0,this.Fl=h[11]|0,this.Gh=h[12]|0,this.Gl=h[13]|0,this.Hh=h[14]|0,this.Hl=h[15]|0}};e.SHA512_224=_;var v=class extends p{constructor(){super(32),this.Ah=g[0]|0,this.Al=g[1]|0,this.Bh=g[2]|0,this.Bl=g[3]|0,this.Ch=g[4]|0,this.Cl=g[5]|0,this.Dh=g[6]|0,this.Dl=g[7]|0,this.Eh=g[8]|0,this.El=g[9]|0,this.Fh=g[10]|0,this.Fl=g[11]|0,this.Gh=g[12]|0,this.Gl=g[13]|0,this.Hh=g[14]|0,this.Hl=g[15]|0}};e.SHA512_256=v,e.sha256=(0,r.createHasher)(()=>new o),e.sha224=(0,r.createHasher)(()=>new s),e.sha512=(0,r.createHasher)(()=>new p),e.sha384=(0,r.createHasher)(()=>new m),e.sha512_256=(0,r.createHasher)(()=>new v),e.sha512_224=(0,r.createHasher)(()=>new _)})),H=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.notImplemented=e.bitMask=e.utf8ToBytes=e.randomBytes=e.isBytes=e.hexToBytes=e.concatBytes=e.bytesToUtf8=e.bytesToHex=e.anumber=e.abytes=void 0,e.abool=a,e._abool2=o,e._abytes2=s,e.numberToHexUnpadded=c,e.hexToNumber=l,e.bytesToNumberBE=u,e.bytesToNumberLE=d,e.numberToBytesBE=f,e.numberToBytesLE=p,e.numberToVarBytesBE=m,e.ensureBytes=h,e.equalBytes=g,e.copyBytes=_,e.asciiToBytes=v,e.inRange=b,e.aInRange=x,e.bitLen=S,e.bitGet=C,e.bitSet=w,e.createHmacDrbg=T,e.validateObject=D,e.isHash=O,e._validateObject=k,e.memoized=A;
|
|
7
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
8
|
+
let t=R();var n=R();Object.defineProperty(e,`abytes`,{enumerable:!0,get:function(){return n.abytes}}),Object.defineProperty(e,`anumber`,{enumerable:!0,get:function(){return n.anumber}}),Object.defineProperty(e,`bytesToHex`,{enumerable:!0,get:function(){return n.bytesToHex}}),Object.defineProperty(e,`bytesToUtf8`,{enumerable:!0,get:function(){return n.bytesToUtf8}}),Object.defineProperty(e,`concatBytes`,{enumerable:!0,get:function(){return n.concatBytes}}),Object.defineProperty(e,`hexToBytes`,{enumerable:!0,get:function(){return n.hexToBytes}}),Object.defineProperty(e,`isBytes`,{enumerable:!0,get:function(){return n.isBytes}}),Object.defineProperty(e,`randomBytes`,{enumerable:!0,get:function(){return n.randomBytes}}),Object.defineProperty(e,`utf8ToBytes`,{enumerable:!0,get:function(){return n.utf8ToBytes}});let r=BigInt(0),i=BigInt(1);function a(e,t){if(typeof t!=`boolean`)throw Error(e+` boolean expected, got `+t)}function o(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}"`;throw Error(n+`expected boolean, got type=`+typeof e)}return e}function s(e,n,r=``){let i=(0,t.isBytes)(e),a=e?.length,o=n!==void 0;if(!i||o&&a!==n){let t=r&&`"${r}" `,s=o?` of length ${n}`:``,c=i?`length=${a}`:`type=${typeof e}`;throw Error(t+`expected Uint8Array`+s+`, got `+c)}return e}function c(e){let t=e.toString(16);return t.length&1?`0`+t:t}function l(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return e===``?r:BigInt(`0x`+e)}function u(e){return l((0,t.bytesToHex)(e))}function d(e){return(0,t.abytes)(e),l((0,t.bytesToHex)(Uint8Array.from(e).reverse()))}function f(e,n){return(0,t.hexToBytes)(e.toString(16).padStart(n*2,`0`))}function p(e,t){return f(e,t).reverse()}function m(e){return(0,t.hexToBytes)(c(e))}function h(e,n,r){let i;if(typeof n==`string`)try{i=(0,t.hexToBytes)(n)}catch(t){throw Error(e+` must be hex string or Uint8Array, cause: `+t)}else if((0,t.isBytes)(n))i=Uint8Array.from(n);else throw Error(e+` must be hex string or Uint8Array`);let a=i.length;if(typeof r==`number`&&a!==r)throw Error(e+` of length `+r+` expected, got `+a);return i}function g(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function _(e){return Uint8Array.from(e)}function v(e){return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw Error(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}let y=e=>typeof e==`bigint`&&r<=e;function b(e,t,n){return y(e)&&y(t)&&y(n)&&t<=e&&e<n}function x(e,t,n,r){if(!b(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function S(e){let t;for(t=0;e>r;e>>=i,t+=1);return t}function C(e,t){return e>>BigInt(t)&i}function w(e,t,n){return e|(n?i:r)<<BigInt(t)}e.bitMask=e=>(i<<BigInt(e))-i;function T(e,n,r){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof n!=`number`||n<2)throw Error(`qByteLen must be a number`);if(typeof r!=`function`)throw Error(`hmacFn must be a function`);let i=e=>new Uint8Array(e),a=e=>Uint8Array.of(e),o=i(e),s=i(e),c=0,l=()=>{o.fill(1),s.fill(0),c=0},u=(...e)=>r(s,o,...e),d=(e=i(0))=>{s=u(a(0),e),o=u(),e.length!==0&&(s=u(a(1),e),o=u())},f=()=>{if(c++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,r=[];for(;e<n;){o=u();let t=o.slice();r.push(t),e+=o.length}return(0,t.concatBytes)(...r)};return(e,t)=>{l(),d(e);let n;for(;!(n=t(f()));)d();return l(),n}}let E={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,stringOrUint8Array:e=>typeof e==`string`||(0,t.isBytes)(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function D(e,t,n={}){let r=(t,n,r)=>{let i=E[n];if(typeof i!=`function`)throw Error(`invalid validator function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`param `+String(t)+` is invalid. Expected `+n+`, got `+a)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}function O(e){return typeof e==`function`&&Number.isSafeInteger(e.outputLen)}function k(e,t,n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}e.notImplemented=()=>{throw Error(`not implemented`)};function A(e){let t=new WeakMap;return(n,...r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e(n,...r);return t.set(n,a),a}}})),U=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isNegativeLE=void 0,e.mod=f,e.pow=p,e.pow2=m,e.invert=h,e.tonelliShanks=b,e.FpSqrt=x,e.validateField=C,e.FpPow=w,e.FpInvertBatch=T,e.FpDiv=E,e.FpLegendre=D,e.FpIsSquare=O,e.nLength=k,e.Field=A,e.FpSqrtOdd=j,e.FpSqrtEven=M,e.hashToPrivateScalar=N,e.getFieldBytesLength=P,e.getMinHashLength=F,e.mapHashToField=I;
|
|
9
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
10
|
+
let t=H(),n=BigInt(0),r=BigInt(1),i=BigInt(2),a=BigInt(3),o=BigInt(4),s=BigInt(5),c=BigInt(7),l=BigInt(8),u=BigInt(9),d=BigInt(16);function f(e,t){let r=e%t;return r>=n?r:t+r}function p(e,t,n){return w(A(n),e,t)}function m(e,t,r){let i=e;for(;t-- >n;)i*=i,i%=r;return i}function h(e,t){if(e===n)throw Error(`invert: expected non-zero number`);if(t<=n)throw Error(`invert: expected positive modulus, got `+t);let i=f(e,t),a=t,o=n,s=r,c=r,l=n;for(;i!==n;){let e=a/i,t=a%i,n=o-c*e,r=s-l*e;a=i,i=t,o=c,s=l,c=n,l=r}if(a!==r)throw Error(`invert: does not exist`);return f(o,t)}function g(e,t,n){if(!e.eql(e.sqr(t),n))throw Error(`Cannot find square root`)}function _(e,t){let n=(e.ORDER+r)/o,i=e.pow(t,n);return g(e,i,t),i}function v(e,t){let n=(e.ORDER-s)/l,r=e.mul(t,i),a=e.pow(r,n),o=e.mul(t,a),c=e.mul(e.mul(o,i),a),u=e.mul(o,e.sub(c,e.ONE));return g(e,u,t),u}function y(e){let t=A(e),n=b(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+c)/d;return(e,t)=>{let n=e.pow(t,o),s=e.mul(n,r),c=e.mul(n,i),l=e.mul(n,a),u=e.eql(e.sqr(s),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,s,u),s=e.cmov(l,c,d);let f=e.eql(e.sqr(s),t),p=e.cmov(n,s,f);return g(e,p,t),p}}function b(e){if(e<a)throw Error(`sqrt is not defined for small field`);let t=e-r,o=0;for(;t%i===n;)t/=i,o++;let s=i,c=A(e);for(;D(c,s)===1;)if(s++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(o===1)return _;let l=c.pow(s,t),u=(t+r)/i;return function(e,n){if(e.is0(n))return n;if(D(e,n)!==1)throw Error(`Cannot find square root`);let i=o,a=e.mul(e.ONE,l),s=e.pow(n,t),c=e.pow(n,u);for(;!e.eql(s,e.ONE);){if(e.is0(s))return e.ZERO;let t=1,n=e.sqr(s);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw Error(`Cannot find square root`);let o=r<<BigInt(i-t-1),l=e.pow(a,o);i=t,a=e.sqr(l),s=e.mul(s,a),c=e.mul(c,l)}return c}}function x(e){return e%o===a?_:e%l===s?v:e%d===u?y(e):b(e)}e.isNegativeLE=(e,t)=>(f(e,t)&r)===r;let S=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function C(e){let n=S.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`number`,BITS:`number`});return(0,t._validateObject)(e,n),e}function w(e,t,i){if(i<n)throw Error(`invalid exponent, negatives unsupported`);if(i===n)return e.ONE;if(i===r)return t;let a=e.ONE,o=t;for(;i>n;)i&r&&(a=e.mul(a,o)),o=e.sqr(o),i>>=r;return a}function T(e,t,n=!1){let r=Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),a=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),a),r}function E(e,t,n){return e.mul(t,typeof n==`bigint`?h(n,e.ORDER):e.inv(n))}function D(e,t){let n=(e.ORDER-r)/i,a=e.pow(t,n),o=e.eql(a,e.ONE),s=e.eql(a,e.ZERO),c=e.eql(a,e.neg(e.ONE));if(!o&&!s&&!c)throw Error(`invalid Legendre symbol result`);return o?1:s?0:-1}function O(e,t){return D(e,t)===1}function k(e,n){n!==void 0&&(0,t.anumber)(n);let r=n===void 0?e.toString(2).length:n;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function A(e,i,a=!1,o={}){if(e<=n)throw Error(`invalid field: expected ORDER > 0, got `+e);let s,c,l=!1,u;if(typeof i==`object`&&i){if(o.sqrt||a)throw Error(`cannot specify opts in two arguments`);let e=i;e.BITS&&(s=e.BITS),e.sqrt&&(c=e.sqrt),typeof e.isLE==`boolean`&&(a=e.isLE),typeof e.modFromBytes==`boolean`&&(l=e.modFromBytes),u=e.allowedLengths}else typeof i==`number`&&(s=i),o.sqrt&&(c=o.sqrt);let{nBitLength:d,nByteLength:p}=k(e,s);if(p>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);let m,g=Object.freeze({ORDER:e,isLE:a,BITS:d,BYTES:p,MASK:(0,t.bitMask)(d),ZERO:n,ONE:r,allowedLengths:u,create:t=>f(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`invalid field element: expected bigint, got `+typeof t);return n<=t&&t<e},is0:e=>e===n,isValidNot0:e=>!g.is0(e)&&g.isValid(e),isOdd:e=>(e&r)===r,neg:t=>f(-t,e),eql:(e,t)=>e===t,sqr:t=>f(t*t,e),add:(t,n)=>f(t+n,e),sub:(t,n)=>f(t-n,e),mul:(t,n)=>f(t*n,e),pow:(e,t)=>w(g,e,t),div:(t,n)=>f(t*h(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>h(t,e),sqrt:c||(t=>(m||=x(e),m(g,t))),toBytes:e=>a?(0,t.numberToBytesLE)(e,p):(0,t.numberToBytesBE)(e,p),fromBytes:(n,r=!0)=>{if(u){if(!u.includes(n.length)||n.length>p)throw Error(`Field.fromBytes: expected `+u+` bytes, got `+n.length);let e=new Uint8Array(p);e.set(n,a?0:e.length-n.length),n=e}if(n.length!==p)throw Error(`Field.fromBytes: expected `+p+` bytes, got `+n.length);let i=a?(0,t.bytesToNumberLE)(n):(0,t.bytesToNumberBE)(n);if(l&&(i=f(i,e)),!r&&!g.isValid(i))throw Error(`invalid field element: outside of range 0..ORDER`);return i},invertBatch:e=>T(g,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(g)}function j(e,t){if(!e.isOdd)throw Error(`Field doesn't have isOdd`);let n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)}function M(e,t){if(!e.isOdd)throw Error(`Field doesn't have isOdd`);let n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n}function N(e,n,i=!1){e=(0,t.ensureBytes)(`privateHash`,e);let a=e.length,o=k(n).nByteLength+8;if(o<24||a<o||a>1024)throw Error(`hashToPrivateScalar: expected `+o+`-1024 bytes of input, got `+a);return f(i?(0,t.bytesToNumberLE)(e):(0,t.bytesToNumberBE)(e),n-r)+r}function P(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function F(e){let t=P(e);return t+Math.ceil(t/2)}function I(e,n,i=!1){let a=e.length,o=P(n),s=F(n);if(a<16||a<s||a>1024)throw Error(`expected `+s+`-1024 bytes of input, got `+a);let c=f(i?(0,t.bytesToNumberLE)(e):(0,t.bytesToNumberBE)(e),n-r)+r;return i?(0,t.numberToBytesLE)(c,o):(0,t.numberToBytesBE)(c,o)}})),W=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.wNAF=void 0,e.negateCt=a,e.normalizeZ=o,e.mulEndoUnsafe=g,e.pippenger=_,e.precomputeMSMUnsafe=v,e.validateBasic=y,e._createCurveFields=x;
|
|
11
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
12
|
+
let t=H(),n=U(),r=BigInt(0),i=BigInt(1);function a(e,t){let n=t.negate();return e?n:t}function o(e,t){let r=(0,n.FpInvertBatch)(e.Fp,t.map(e=>e.Z));return t.map((t,n)=>e.fromAffine(t.toAffine(r[n])))}function s(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function c(e,n){s(e,n);let r=Math.ceil(n/e)+1,i=2**(e-1),a=2**e;return{windows:r,windowSize:i,mask:(0,t.bitMask)(e),maxNumber:a,shiftBy:BigInt(e)}}function l(e,t,n){let{windowSize:r,mask:a,maxNumber:o,shiftBy:s}=n,c=Number(e&a),l=e>>s;c>r&&(c-=o,l+=i);let u=t*r,d=u+Math.abs(c)-1,f=c===0,p=c<0,m=t%2!=0;return{nextN:l,offset:d,isZero:f,isNeg:p,isNegF:m,offsetF:u}}function u(e,t){if(!Array.isArray(e))throw Error(`array expected`);e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function d(e,t){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,n)=>{if(!t.isValid(e))throw Error(`invalid scalar at index `+n)})}let f=new WeakMap,p=new WeakMap;function m(e){return p.get(e)||1}function h(e){if(e!==r)throw Error(`invalid wNAF`)}e.wNAF=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let a=e;for(;t>r;)t&i&&(n=n.add(a)),a=a.double(),t>>=i;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=c(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,o=c(e,this.bits);for(let e=0;e<o.windows;e++){let{nextN:s,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:p}=l(n,e,o);n=s,u?i=i.add(a(f,t[p])):r=r.add(a(d,t[c]))}return h(n),{p:r,f:i}}wNAFUnsafe(e,t,n,i=this.ZERO){let a=c(e,this.bits);for(let e=0;e<a.windows&&n!==r;e++){let{nextN:r,offset:o,isZero:s,isNeg:c}=l(n,e,a);if(n=r,!s){let e=t[o];i=i.add(c?e.negate():e)}}return h(n),i}getPrecomputes(e,t,n){let r=f.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),f.set(t,r))),r}cached(e,t,n){let r=m(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=m(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){s(t,this.bits),p.set(e,t),f.delete(e)}hasCache(e){return m(e)!==1}};function g(e,t,n,a){let o=t,s=e.ZERO,c=e.ZERO;for(;n>r||a>r;)n&i&&(s=s.add(o)),a&i&&(c=c.add(o)),o=o.double(),n>>=i,a>>=i;return{p1:s,p2:c}}function _(e,n,r,i){u(r,e),d(i,n);let a=r.length,o=i.length;if(a!==o)throw Error(`arrays of points and scalars must have equal length`);let s=e.ZERO,c=(0,t.bitLen)(BigInt(a)),l=1;c>12?l=c-3:c>4?l=c-2:c>0&&(l=2);let f=(0,t.bitMask)(l),p=Array(Number(f)+1).fill(s),m=Math.floor((n.BITS-1)/l)*l,h=s;for(let e=m;e>=0;e-=l){p.fill(s);for(let t=0;t<o;t++){let n=i[t],a=Number(n>>BigInt(e)&f);p[a]=p[a].add(r[t])}let t=s;for(let e=p.length-1,n=s;e>0;e--)n=n.add(p[e]),t=t.add(n);if(h=h.add(t),e!==0)for(let e=0;e<l;e++)h=h.double()}return h}function v(e,n,r,i){s(i,n.BITS),u(r,e);let a=e.ZERO,o=2**i-1,c=Math.ceil(n.BITS/i),l=(0,t.bitMask)(i),f=r.map(e=>{let t=[];for(let n=0,r=e;n<o;n++)t.push(r),r=r.add(e);return t});return e=>{if(d(e,n),e.length>r.length)throw Error(`array of scalars must be smaller than array of points`);let t=a;for(let n=0;n<c;n++){if(t!==a)for(let e=0;e<i;e++)t=t.double();let r=BigInt(c*i-(n+1)*i);for(let n=0;n<e.length;n++){let i=e[n],a=Number(i>>r&l);a&&(t=t.add(f[n][a-1]))}}return t}}function y(e){return(0,n.validateField)(e.Fp),(0,t.validateObject)(e,{n:`bigint`,h:`bigint`,Gx:`field`,Gy:`field`},{nBitLength:`isSafeInteger`,nByteLength:`isSafeInteger`}),Object.freeze({...(0,n.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function b(e,t,r){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return(0,n.validateField)(t),t}else return(0,n.Field)(e,{isLE:r})}function x(e,t,n={},i){if(i===void 0&&(i=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>r))throw Error(`CURVE.${e} must be positive bigint`)}let a=b(t.p,n.Fp,i),o=b(t.n,n.Fn,i),s=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of s)if(!a.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:a,Fn:o}}})),G=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PrimeEdwardsPoint=void 0,e.edwards=l,e.eddsa=u,e.twistedEdwards=p;
|
|
13
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14
|
+
let t=H(),n=W(),r=U(),i=BigInt(0),a=BigInt(1),o=BigInt(2),s=BigInt(8);function c(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function l(e,r={}){let l=(0,n._createCurveFields)(`edwards`,e,r,r.FpFnLE),{Fp:u,Fn:d}=l,f=l.CURVE,{h:p}=f;(0,t._validateObject)(r,{},{uvRatio:`function`});let m=o<<BigInt(d.BYTES*8)-a,h=e=>u.create(e),g=r.uvRatio||((e,t)=>{try{return{isValid:!0,value:u.sqrt(u.div(e,t))}}catch{return{isValid:!1,value:i}}});if(!c(u,f,f.Gx,f.Gy))throw Error(`bad curve params: generator point`);function _(e,n,r=!1){let o=r?a:i;return(0,t.aInRange)(`coordinate `+e,n,o,m),n}function v(e){if(!(e instanceof x))throw Error(`ExtendedPoint expected`)}let y=(0,t.memoized)((e,t)=>{let{X:n,Y:r,Z:o}=e,c=e.is0();t??=c?s:u.inv(o);let l=h(n*t),d=h(r*t),f=u.mul(o,t);if(c)return{x:i,y:a};if(f!==a)throw Error(`invZ was invalid`);return{x:l,y:d}}),b=(0,t.memoized)(e=>{let{a:t,d:n}=f;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:i,Z:a,T:o}=e,s=h(r*r),c=h(i*i),l=h(a*a),u=h(l*l);if(h(l*h(h(s*t)+c))!==h(u+h(n*h(s*c))))throw Error(`bad point: equation left != right (1)`);if(h(r*i)!==h(a*o))throw Error(`bad point: equation left != right (2)`);return!0});class x{constructor(e,t,n,r){this.X=_(`x`,e),this.Y=_(`y`,t),this.Z=_(`z`,n,!0),this.T=_(`t`,r),Object.freeze(this)}static CURVE(){return f}static fromAffine(e){if(e instanceof x)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return _(`x`,t),_(`y`,n),new x(t,n,a,h(t*n))}static fromBytes(e,n=!1){let r=u.BYTES,{a:o,d:s}=f;e=(0,t.copyBytes)((0,t._abytes2)(e,r,`point`)),(0,t._abool2)(n,`zip215`);let c=(0,t.copyBytes)(e),l=e[r-1];c[r-1]=l&-129;let d=(0,t.bytesToNumberLE)(c),p=n?m:u.ORDER;(0,t.aInRange)(`point.y`,d,i,p);let _=h(d*d),{isValid:v,value:y}=g(h(_-a),h(s*_-o));if(!v)throw Error(`bad point: invalid y coordinate`);let b=(y&a)===a,S=(l&128)!=0;if(!n&&y===i&&S)throw Error(`bad point: x=0 and x_0=1`);return S!==b&&(y=h(-y)),x.fromAffine({x:y,y:d})}static fromHex(e,n=!1){return x.fromBytes((0,t.ensureBytes)(`point`,e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return S.createCache(this,e),t||this.multiply(o),this}assertValidity(){b(this)}equals(e){v(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=e,s=h(t*o),c=h(i*r),l=h(n*o),u=h(a*r);return s===c&&l===u}is0(){return this.equals(x.ZERO)}negate(){return new x(h(-this.X),this.Y,this.Z,h(-this.T))}double(){let{a:e}=f,{X:t,Y:n,Z:r}=this,i=h(t*t),a=h(n*n),s=h(o*h(r*r)),c=h(e*i),l=t+n,u=h(h(l*l)-i-a),d=c+a,p=d-s,m=c-a,g=h(u*p),_=h(d*m),v=h(u*m);return new x(g,_,h(p*d),v)}add(e){v(e);let{a:t,d:n}=f,{X:r,Y:i,Z:a,T:o}=this,{X:s,Y:c,Z:l,T:u}=e,d=h(r*s),p=h(i*c),m=h(o*n*u),g=h(a*l),_=h((r+i)*(s+c)-d-p),y=g-m,b=g+m,S=h(p-t*d),C=h(_*y),w=h(b*S),T=h(_*S);return new x(C,w,h(y*b),T)}subtract(e){return this.add(e.negate())}multiply(e){if(!d.isValidNot0(e))throw Error(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:r}=S.cached(this,e,e=>(0,n.normalizeZ)(x,e));return(0,n.normalizeZ)(x,[t,r])[0]}multiplyUnsafe(e,t=x.ZERO){if(!d.isValid(e))throw Error(`invalid scalar: expected 0 <= sc < curve.n`);return e===i?x.ZERO:this.is0()||e===a?this:S.unsafe(this,e,e=>(0,n.normalizeZ)(x,e),t)}isSmallOrder(){return this.multiplyUnsafe(p).is0()}isTorsionFree(){return S.unsafe(this,f.n).is0()}toAffine(e){return y(this,e)}clearCofactor(){return p===a?this:this.multiplyUnsafe(p)}toBytes(){let{x:e,y:t}=this.toAffine(),n=u.toBytes(t);return n[n.length-1]|=e&a?128:0,n}toHex(){return(0,t.bytesToHex)(this.toBytes())}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return(0,n.normalizeZ)(x,e)}static msm(e,t){return(0,n.pippenger)(x,d,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}x.BASE=new x(f.Gx,f.Gy,a,h(f.Gx*f.Gy)),x.ZERO=new x(i,a,a,i),x.Fp=u,x.Fn=d;let S=new n.wNAF(x,d.BITS);return x.BASE.precompute(8),x}e.PrimeEdwardsPoint=class{constructor(e){this.ep=e}static fromBytes(e){(0,t.notImplemented)()}static fromHex(e){(0,t.notImplemented)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return(0,t.bytesToHex)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}};function u(e,n,r={}){if(typeof n!=`function`)throw Error(`"hash" function param is required`);(0,t._validateObject)(r,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,mapToCurve:`function`});let{prehash:i}=r,{BASE:o,Fp:s,Fn:c}=e,l=r.randomBytes||t.randomBytes,u=r.adjustScalarBytes||(e=>e),d=r.domain||((e,n,r)=>{if((0,t._abool2)(r,`phflag`),n.length||r)throw Error(`Contexts/pre-hash are not supported`);return e});function f(e){return c.create((0,t.bytesToNumberLE)(e))}function p(e){let r=x.secretKey;e=(0,t.ensureBytes)(`private key`,e,r);let i=(0,t.ensureBytes)(`hashed private key`,n(e),2*r),a=u(i.slice(0,r));return{head:a,prefix:i.slice(r,2*r),scalar:f(a)}}function m(e){let{head:t,prefix:n,scalar:r}=p(e),i=o.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}}function h(e){return m(e).pointBytes}function g(e=Uint8Array.of(),...r){return f(n(d((0,t.concatBytes)(...r),(0,t.ensureBytes)(`context`,e),!!i)))}function _(e,n,r={}){e=(0,t.ensureBytes)(`message`,e),i&&(e=i(e));let{prefix:a,scalar:s,pointBytes:l}=m(n),u=g(r.context,a,e),d=o.multiply(u).toBytes(),f=g(r.context,d,l,e),p=c.create(u+f*s);if(!c.isValid(p))throw Error(`sign failed: invalid s`);let h=(0,t.concatBytes)(d,c.toBytes(p));return(0,t._abytes2)(h,x.signature,`result`)}let v={zip215:!0};function y(n,r,a,s=v){let{context:c,zip215:l}=s,u=x.signature;n=(0,t.ensureBytes)(`signature`,n,u),r=(0,t.ensureBytes)(`message`,r),a=(0,t.ensureBytes)(`publicKey`,a,x.publicKey),l!==void 0&&(0,t._abool2)(l,`zip215`),i&&(r=i(r));let d=u/2,f=n.subarray(0,d),p=(0,t.bytesToNumberLE)(n.subarray(d,u)),m,h,_;try{m=e.fromBytes(a,l),h=e.fromBytes(f,l),_=o.multiplyUnsafe(p)}catch{return!1}if(!l&&m.isSmallOrder())return!1;let y=g(c,h.toBytes(),m.toBytes(),r);return h.add(m.multiplyUnsafe(y)).subtract(_).clearCofactor().is0()}let b=s.BYTES,x={secretKey:b,publicKey:b,signature:2*b,seed:b};function S(e=l(x.seed)){return(0,t._abytes2)(e,x.seed,`seed`)}function C(e){let t=E.randomSecretKey(e);return{secretKey:t,publicKey:h(t)}}function w(e){return(0,t.isBytes)(e)&&e.length===c.BYTES}function T(t,n){try{return!!e.fromBytes(t,n)}catch{return!1}}let E={getExtendedPublicKey:m,randomSecretKey:S,isValidSecretKey:w,isValidPublicKey:T,toMontgomery(t){let{y:n}=e.fromBytes(t),r=x.publicKey,i=r===32;if(!i&&r!==57)throw Error(`only defined for 25519 and 448`);let o=i?s.div(a+n,a-n):s.div(n-a,n+a);return s.toBytes(o)},toMontgomerySecret(e){let r=x.secretKey;return(0,t._abytes2)(e,r),u(n(e.subarray(0,r))).subarray(0,r)},randomPrivateKey:S,precompute(t=8,n=e.BASE){return n.precompute(t,!1)}};return Object.freeze({keygen:C,getPublicKey:h,sign:_,verify:y,utils:E,Point:e,lengths:x})}function d(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:(0,r.Field)(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},i={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:i}}function f(e,t){let n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function p(e){let{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=d(e);return f(e,u(l(t,n),r,i))}})),K=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e._DST_scalar=void 0,e.expand_message_xmd=c,e.expand_message_xof=l,e.hash_to_field=u,e.isogenyMap=d,e.createHasher=f;let t=H(),n=U(),r=t.bytesToNumberBE;function i(e,t){if(o(e),o(t),e<0||e>=1<<8*t)throw Error(`invalid I2OSP input: `+e);let n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function a(e,t){let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function o(e){if(!Number.isSafeInteger(e))throw Error(`number expected`)}function s(e){if(!(0,t.isBytes)(e)&&typeof e!=`string`)throw Error(`DST must be Uint8Array or string`);return typeof e==`string`?(0,t.utf8ToBytes)(e):e}function c(e,n,r,c){(0,t.abytes)(e),o(r),n=s(n),n.length>255&&(n=c((0,t.concatBytes)((0,t.utf8ToBytes)(`H2C-OVERSIZE-DST-`),n)));let{outputLen:l,blockLen:u}=c,d=Math.ceil(r/l);if(r>65535||d>255)throw Error(`expand_message_xmd: invalid lenInBytes`);let f=(0,t.concatBytes)(n,i(n.length,1)),p=i(0,u),m=i(r,2),h=Array(d),g=c((0,t.concatBytes)(p,e,m,i(0,1),f));h[0]=c((0,t.concatBytes)(g,i(1,1),f));for(let e=1;e<=d;e++){let n=[a(g,h[e-1]),i(e+1,1),f];h[e]=c((0,t.concatBytes)(...n))}return(0,t.concatBytes)(...h).slice(0,r)}function l(e,n,r,a,c){if((0,t.abytes)(e),o(r),n=s(n),n.length>255){let e=Math.ceil(2*a/8);n=c.create({dkLen:e}).update((0,t.utf8ToBytes)(`H2C-OVERSIZE-DST-`)).update(n).digest()}if(r>65535||n.length>255)throw Error(`expand_message_xof: invalid lenInBytes`);return c.create({dkLen:r}).update(e).update(i(r,2)).update(n).update(i(n.length,1)).digest()}function u(e,i,a){(0,t._validateObject)(a,{p:`bigint`,m:`number`,k:`number`,hash:`function`});let{p:s,k:u,m:d,hash:f,expand:p,DST:m}=a;if(!(0,t.isHash)(a.hash))throw Error(`expected valid hash`);(0,t.abytes)(e),o(i);let h=s.toString(2).length,g=Math.ceil((h+u)/8),_=i*d*g,v;if(p===`xmd`)v=c(e,m,_,f);else if(p===`xof`)v=l(e,m,_,u,f);else if(p===`_internal_pass`)v=e;else throw Error(`expand must be "xmd" or "xof"`);let y=Array(i);for(let e=0;e<i;e++){let t=Array(d);for(let i=0;i<d;i++){let a=g*(i+e*d),o=v.subarray(a,a+g);t[i]=(0,n.mod)(r(o),s)}y[e]=t}return y}function d(e,t){let r=t.map(e=>Array.from(e).reverse());return(t,i)=>{let[a,o,s,c]=r.map(n=>n.reduce((n,r)=>e.add(e.mul(n,t),r))),[l,u]=(0,n.FpInvertBatch)(e,[o,c],!0);return t=e.mul(a,l),i=e.mul(i,e.mul(s,u)),{x:t,y:i}}}e._DST_scalar=(0,t.utf8ToBytes)(`HashToScalar-`);function f(t,n,r){if(typeof n!=`function`)throw Error(`mapToCurve() must be defined`);function i(e){return t.fromAffine(n(e))}function a(e){let n=e.clearCofactor();return n.equals(t.ZERO)?t.ZERO:(n.assertValidity(),n)}return{defaults:r,hashToCurve(e,t){let n=u(e,2,Object.assign({},r,t)),o=i(n[0]),s=i(n[1]);return a(o.add(s))},encodeToCurve(e,t){let n=r.encodeDST?{DST:r.encodeDST}:{};return a(i(u(e,1,Object.assign({},r,n,t))[0]))},mapToCurve(e){if(!Array.isArray(e))throw Error(`expected array of bigints`);for(let t of e)if(typeof t!=`bigint`)throw Error(`expected array of bigints`);return a(i(e))},hashToScalar(n,i){let a=t.Fn.ORDER;return u(n,1,Object.assign({},r,{p:a,m:1,DST:e._DST_scalar},i))[0][0]}}}})),q=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.montgomery=s;
|
|
15
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
16
|
+
let t=H(),n=U(),r=BigInt(0),i=BigInt(1),a=BigInt(2);function o(e){return(0,t._validateObject)(e,{adjustScalarBytes:`function`,powPminus2:`function`}),Object.freeze({...e})}function s(e){let{P:s,type:c,adjustScalarBytes:l,powPminus2:u,randomBytes:d}=o(e),f=c===`x25519`;if(!f&&c!==`x448`)throw Error(`invalid type`);let p=d||t.randomBytes,m=f?255:448,h=f?32:56,g=BigInt(f?9:5),_=BigInt(f?121665:39081),v=f?a**BigInt(254):a**BigInt(447),y=v+(f?BigInt(8)*a**BigInt(251)-i:BigInt(4)*a**BigInt(445)-i)+i,b=e=>(0,n.mod)(e,s),x=S(g);function S(e){return(0,t.numberToBytesLE)(b(e),h)}function C(e){let n=(0,t.ensureBytes)(`u coordinate`,e,h);return f&&(n[31]&=127),b((0,t.bytesToNumberLE)(n))}function w(e){return(0,t.bytesToNumberLE)(l((0,t.ensureBytes)(`scalar`,e,h)))}function T(e,t){let n=O(C(t),w(e));if(n===r)throw Error(`invalid private or public key received`);return S(n)}function E(e){return T(e,x)}function D(e,t,n){let r=b(e*(t-n));return t=b(t-r),n=b(n+r),{x_2:t,x_3:n}}function O(e,n){(0,t.aInRange)(`u`,e,r,s),(0,t.aInRange)(`scalar`,n,v,y);let a=n,o=e,c=i,l=r,d=e,f=i,p=r;for(let e=BigInt(m-1);e>=r;e--){let t=a>>e&i;p^=t,{x_2:c,x_3:d}=D(p,c,d),{x_2:l,x_3:f}=D(p,l,f),p=t;let n=c+l,r=b(n*n),s=c-l,u=b(s*s),m=r-u,h=d+f,g=b((d-f)*n),v=b(h*s),y=g+v,x=g-v;d=b(y*y),f=b(o*b(x*x)),c=b(r*u),l=b(m*(r+b(_*m)))}({x_2:c,x_3:d}=D(p,c,d)),{x_2:l,x_3:f}=D(p,l,f);let h=u(l);return b(c*h)}let k={secretKey:h,publicKey:h,seed:h},A=(e=p(h))=>((0,t.abytes)(e,k.seed),e);function j(e){let t=A(e);return{secretKey:t,publicKey:E(t)}}return{keygen:j,getSharedSecret:(e,t)=>T(e,t),getPublicKey:e=>E(e),scalarMult:T,scalarMultBase:E,utils:{randomSecretKey:A,randomPrivateKey:A},GuBytes:x.slice(),lengths:k}}})),J=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.hash_to_ristretto255=e.hashToRistretto255=e.encodeToCurve=e.hashToCurve=e.RistrettoPoint=e.edwardsToMontgomery=e.ED25519_TORSION_SUBGROUP=e.ristretto255_hasher=e.ristretto255=e.ed25519_hasher=e.x25519=e.ed25519ph=e.ed25519ctx=e.ed25519=void 0,e.edwardsToMontgomeryPub=X,e.edwardsToMontgomeryPriv=Z;
|
|
17
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
18
|
+
let t=V(),n=R(),r=W(),i=G(),a=K(),o=U(),s=q(),c=H(),l=BigInt(0),u=BigInt(1),d=BigInt(2),f=BigInt(3),p=BigInt(5),m=BigInt(8),h=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),g={p:h,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:m,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function _(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=h,s=e*e%a*e%a,c=(0,o.pow2)(s,d,a)*s%a,l=(0,o.pow2)(c,u,a)*e%a,f=(0,o.pow2)(l,p,a)*l%a,m=(0,o.pow2)(f,t,a)*f%a,g=(0,o.pow2)(m,n,a)*m%a,_=(0,o.pow2)(g,r,a)*g%a,v=(0,o.pow2)(_,i,a)*_%a,y=(0,o.pow2)(v,i,a)*_%a,b=(0,o.pow2)(y,t,a)*f%a;return{pow_p_5_8:(0,o.pow2)(b,d,a)*e%a,b2:s}}function v(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}let y=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function b(e,t){let n=h,r=(0,o.mod)(t*t*t,n),i=_(e*(0,o.mod)(r*r*t,n)).pow_p_5_8,a=(0,o.mod)(e*r*i,n),s=(0,o.mod)(t*a*a,n),c=a,l=(0,o.mod)(a*y,n),u=s===e,d=s===(0,o.mod)(-e,n),f=s===(0,o.mod)(-e*y,n);return u&&(a=c),(d||f)&&(a=l),(0,o.isNegativeLE)(a,n)&&(a=(0,o.mod)(-a,n)),{isValid:u||d,value:a}}let x=(0,o.Field)(g.p,{isLE:!0}),S=(0,o.Field)(g.n,{isLE:!0}),C={...g,Fp:x,hash:t.sha512,adjustScalarBytes:v,uvRatio:b};e.ed25519=(0,i.twistedEdwards)(C);function w(e,t,r){if(t.length>255)throw Error(`Context is too big`);return(0,n.concatBytes)((0,n.utf8ToBytes)(`SigEd25519 no Ed25519 collisions`),new Uint8Array([+!!r,t.length]),t,e)}e.ed25519ctx=(0,i.twistedEdwards)({...C,domain:w}),e.ed25519ph=(0,i.twistedEdwards)(Object.assign({},C,{domain:w,prehash:t.sha512})),e.x25519=(()=>{let e=x.ORDER;return(0,s.montgomery)({P:e,type:`x25519`,powPminus2:t=>{let{pow_p_5_8:n,b2:r}=_(t);return(0,o.mod)((0,o.pow2)(n,f,e)*r,e)},adjustScalarBytes:v})})();let T=(h+f)/m,E=x.pow(d,T),D=x.sqrt(x.neg(x.ONE));function O(e){let t=(h-p)/m,n=BigInt(486662),r=x.sqr(e);r=x.mul(r,d);let i=x.add(r,x.ONE),a=x.neg(n),o=x.sqr(i),s=x.mul(o,i),c=x.mul(r,n);c=x.mul(c,a),c=x.add(c,o),c=x.mul(c,a);let l=x.sqr(s);o=x.sqr(l),l=x.mul(l,s),l=x.mul(l,c),o=x.mul(o,l);let f=x.pow(o,t);f=x.mul(f,l);let g=x.mul(f,D);o=x.sqr(f),o=x.mul(o,s);let _=x.eql(o,c),v=x.cmov(g,f,_),y=x.mul(a,r),b=x.mul(f,e);b=x.mul(b,E);let S=x.mul(b,D),C=x.mul(c,r);o=x.sqr(b),o=x.mul(o,s);let w=x.eql(o,C),T=x.cmov(S,b,w);o=x.sqr(v),o=x.mul(o,s);let O=x.eql(o,c),k=x.cmov(y,a,O),A=x.cmov(T,v,O),j=x.isOdd(A);return A=x.cmov(A,x.neg(A),O!==j),{xMn:k,xMd:i,yMn:A,yMd:u}}let k=(0,o.FpSqrtEven)(x,x.neg(BigInt(486664)));function A(e){let{xMn:t,xMd:n,yMn:r,yMd:i}=O(e),a=x.mul(t,i);a=x.mul(a,k);let s=x.mul(n,r),c=x.sub(t,n),l=x.add(t,n),u=x.mul(s,l),d=x.eql(u,x.ZERO);a=x.cmov(a,x.ZERO,d),s=x.cmov(s,x.ONE,d),c=x.cmov(c,x.ONE,d),l=x.cmov(l,x.ONE,d);let[f,p]=(0,o.FpInvertBatch)(x,[s,l],!0);return{x:x.mul(a,f),y:x.mul(c,p)}}e.ed25519_hasher=(0,a.createHasher)(e.ed25519.Point,e=>A(e[0]),{DST:`edwards25519_XMD:SHA-512_ELL2_RO_`,encodeDST:`edwards25519_XMD:SHA-512_ELL2_NU_`,p:h,m:1,k:128,expand:`xmd`,hash:t.sha512});let j=y,M=BigInt(`25063068953384623474111414158702152701244531502492656460079210482610430750235`),N=BigInt(`54469307008909316920995813868745141605393597292927456921205312896311721017578`),P=BigInt(`1159843021668779879193775521855586647937357759715417654439879720876111806838`),F=BigInt(`40440834346308536858101042469323190826248399146238708352240133220865137265952`),I=e=>b(u,e),L=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),z=t=>e.ed25519.Point.Fp.create((0,c.bytesToNumberLE)(t)&L);function B(t){let{d:n}=g,r=h,i=e=>x.create(e),a=i(j*t*t),s=i((a+u)*P),c=BigInt(-1),l=i((c-n*a)*i(a+n)),{isValid:d,value:f}=b(s,l),p=i(f*t);(0,o.isNegativeLE)(p,r)||(p=i(-p)),d||(f=p),d||(c=a);let m=i(c*(a-u)*F-l),_=f*f,v=i((f+f)*l),y=i(m*M),S=i(u-_),C=i(u+_);return new e.ed25519.Point(i(v*C),i(S*y),i(y*C),i(v*S))}function J(e){(0,n.abytes)(e,64);let t=B(z(e.subarray(0,32))),r=B(z(e.subarray(32,64)));return new Y(t.add(r))}var Y=class t extends i.PrimeEdwardsPoint{constructor(e){super(e)}static fromAffine(n){return new t(e.ed25519.Point.fromAffine(n))}assertSame(e){if(!(e instanceof t))throw Error(`RistrettoPoint expected`)}init(e){return new t(e)}static hashToCurve(e){return J((0,c.ensureBytes)(`ristrettoHash`,e,64))}static fromBytes(r){(0,n.abytes)(r,32);let{a:i,d:a}=g,s=h,d=e=>x.create(e),f=z(r);if(!(0,c.equalBytes)(x.toBytes(f),r)||(0,o.isNegativeLE)(f,s))throw Error(`invalid ristretto255 encoding 1`);let p=d(f*f),m=d(u+i*p),_=d(u-i*p),v=d(m*m),y=d(_*_),b=d(i*a*v-y),{isValid:S,value:C}=I(d(b*y)),w=d(C*_),T=d(C*w*b),E=d((f+f)*w);(0,o.isNegativeLE)(E,s)&&(E=d(-E));let D=d(m*T),O=d(E*D);if(!S||(0,o.isNegativeLE)(O,s)||D===l)throw Error(`invalid ristretto255 encoding 2`);return new t(new e.ed25519.Point(E,D,u,O))}static fromHex(e){return t.fromBytes((0,c.ensureBytes)(`ristrettoHex`,e,32))}static msm(n,i){return(0,r.pippenger)(t,e.ed25519.Point.Fn,n,i)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep,i=h,a=e=>x.create(e),s=a(a(n+t)*a(n-t)),c=a(e*t),{value:l}=I(a(s*a(c*c))),u=a(l*s),d=a(l*c),f=a(u*d*r),p;if((0,o.isNegativeLE)(r*f,i)){let n=a(t*j),r=a(e*j);e=n,t=r,p=a(u*N)}else p=d;(0,o.isNegativeLE)(e*f,i)&&(t=a(-t));let m=a((n-t)*p);return(0,o.isNegativeLE)(m,i)&&(m=a(-m)),x.toBytes(m)}equals(e){this.assertSame(e);let{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,a=e=>x.create(e),o=a(t*i)===a(n*r),s=a(n*i)===a(t*r);return o||s}is0(){return this.equals(t.ZERO)}};Y.BASE=new Y(e.ed25519.Point.BASE),Y.ZERO=new Y(e.ed25519.Point.ZERO),Y.Fp=x,Y.Fn=S,e.ristretto255={Point:Y},e.ristretto255_hasher={hashToCurve(e,n){let r=n?.DST||`ristretto255_XMD:SHA-512_R255MAP_RO_`;return J((0,a.expand_message_xmd)(e,r,64,t.sha512))},hashToScalar(e,n={DST:a._DST_scalar}){let r=(0,a.expand_message_xmd)(e,n.DST,64,t.sha512);return S.create((0,c.bytesToNumberLE)(r))}},e.ED25519_TORSION_SUBGROUP=[`0100000000000000000000000000000000000000000000000000000000000000`,`c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a`,`0000000000000000000000000000000000000000000000000000000000000080`,`26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05`,`ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f`,`26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85`,`0000000000000000000000000000000000000000000000000000000000000000`,`c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa`];function X(t){return e.ed25519.utils.toMontgomery((0,c.ensureBytes)(`pub`,t))}e.edwardsToMontgomery=X;function Z(t){return e.ed25519.utils.toMontgomerySecret((0,c.ensureBytes)(`pub`,t))}e.RistrettoPoint=Y,e.hashToCurve=e.ed25519_hasher.hashToCurve,e.encodeToCurve=e.ed25519_hasher.encodeToCurve,e.hashToRistretto255=e.ristretto255_hasher.hashToCurve,e.hash_to_ristretto255=e.ristretto255_hasher.hashToCurve})),Y=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.hmac=e.HMAC=void 0;let t=R();var n=class extends t.Hash{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,(0,t.ahash)(e);let r=(0,t.toBytes)(n);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,a=new Uint8Array(i);a.set(r.length>i?e.create().update(r).digest():r);for(let e=0;e<a.length;e++)a[e]^=54;this.iHash.update(a),this.oHash=e.create();for(let e=0;e<a.length;e++)a[e]^=106;this.oHash.update(a),(0,t.clean)(a)}update(e){return(0,t.aexists)(this),this.iHash.update(e),this}digestInto(e){(0,t.aexists)(this),(0,t.abytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};e.HMAC=n,e.hmac=(e,t,r)=>new n(e,t).update(r).digest(),e.hmac.create=(e,t)=>new n(e,t)})),X=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DER=e.DERErr=void 0,e._splitEndoScalar=s,e._normFnElement=g,e.weierstrassN=_,e.SWUFpSqrtRatio=y,e.mapToCurveSimpleSWU=b,e.ecdh=S,e.ecdsa=C,e.weierstrassPoints=w,e._legacyHelperEquat=D,e.weierstrass=A;
|
|
19
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
20
|
+
let t=Y(),n=R(),r=H(),i=W(),a=U(),o=(e,t)=>(e+(e>=0?t:-t)/p)/t;function s(e,t,n){let[[i,a],[s,c]]=t,l=o(c*e,n),u=o(-a*e,n),p=e-l*i-u*s,m=-l*a-u*c,h=p<d,g=m<d;h&&(p=-p),g&&(m=-m);let _=(0,r.bitMask)(Math.ceil((0,r.bitLen)(n)/2))+f;if(p<d||p>=_||m<d||m>=_)throw Error(`splitScalar (endomorphism): failed, k=`+e);return{k1neg:h,k1:p,k2neg:g,k2:m}}function c(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function l(e,t){let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return(0,r._abool2)(n.lowS,`lowS`),(0,r._abool2)(n.prehash,`prehash`),n.format!==void 0&&c(n.format),n}var u=class extends Error{constructor(e=``){super(e)}};e.DERErr=u,e.DER={Err:u,_tlv:{encode:(t,n)=>{let{Err:i}=e.DER;if(t<0||t>256)throw new i(`tlv.encode: wrong tag`);if(n.length&1)throw new i(`tlv.encode: unpadded data`);let a=n.length/2,o=(0,r.numberToHexUnpadded)(a);if(o.length/2&128)throw new i(`tlv.encode: long form length too big`);let s=a>127?(0,r.numberToHexUnpadded)(o.length/2|128):``;return(0,r.numberToHexUnpadded)(t)+s+o+n},decode(t,n){let{Err:r}=e.DER,i=0;if(t<0||t>256)throw new r(`tlv.encode: wrong tag`);if(n.length<2||n[i++]!==t)throw new r(`tlv.decode: wrong tlv`);let a=n[i++],o=!!(a&128),s=0;if(!o)s=a;else{let e=a&127;if(!e)throw new r(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new r(`tlv.decode(long): byte length is too big`);let t=n.subarray(i,i+e);if(t.length!==e)throw new r(`tlv.decode: length bytes not complete`);if(t[0]===0)throw new r(`tlv.decode(long): zero leftmost byte`);for(let e of t)s=s<<8|e;if(i+=e,s<128)throw new r(`tlv.decode(long): not minimal encoding`)}let c=n.subarray(i,i+s);if(c.length!==s)throw new r(`tlv.decode: wrong value length`);return{v:c,l:n.subarray(i+s)}}},_int:{encode(t){let{Err:n}=e.DER;if(t<d)throw new n(`integer: negative integers are not allowed`);let i=(0,r.numberToHexUnpadded)(t);if(Number.parseInt(i[0],16)&8&&(i=`00`+i),i.length&1)throw new n(`unexpected DER parsing assertion: unpadded hex`);return i},decode(t){let{Err:n}=e.DER;if(t[0]&128)throw new n(`invalid signature integer: negative`);if(t[0]===0&&!(t[1]&128))throw new n(`invalid signature integer: unnecessary leading zero`);return(0,r.bytesToNumberBE)(t)}},toSig(t){let{Err:n,_int:i,_tlv:a}=e.DER,o=(0,r.ensureBytes)(`signature`,t),{v:s,l:c}=a.decode(48,o);if(c.length)throw new n(`invalid signature: left bytes after parsing`);let{v:l,l:u}=a.decode(2,s),{v:d,l:f}=a.decode(2,u);if(f.length)throw new n(`invalid signature: left bytes after parsing`);return{r:i.decode(l),s:i.decode(d)}},hexFromSig(t){let{_tlv:n,_int:r}=e.DER,i=n.encode(2,r.encode(t.r))+n.encode(2,r.encode(t.s));return n.encode(48,i)}};let d=BigInt(0),f=BigInt(1),p=BigInt(2),m=BigInt(3),h=BigInt(4);function g(e,t){let{BYTES:n}=e,i;if(typeof t==`bigint`)i=t;else{let a=(0,r.ensureBytes)(`private key`,t);try{i=e.fromBytes(a)}catch{throw Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(i))throw Error(`invalid private key: out of range [1..N-1]`);return i}function _(e,t={}){let n=(0,i._createCurveFields)(`weierstrass`,e,t),{Fp:a,Fn:o}=n,c=n.CURVE,{h:l,n:u}=c;(0,r._validateObject)(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,wrapPrivateKey:`boolean`});let{endo:p}=t;if(p&&(!a.is0(c.a)||typeof p.beta!=`bigint`||!Array.isArray(p.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let _=x(a,o);function y(){if(!a.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function b(e,t,n){let{x:i,y:o}=t.toAffine(),s=a.toBytes(i);if((0,r._abool2)(n,`isCompressed`),n){y();let e=!a.isOdd(o);return(0,r.concatBytes)(v(e),s)}else return(0,r.concatBytes)(Uint8Array.of(4),s,a.toBytes(o))}function S(e){(0,r._abytes2)(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=_,i=e.length,o=e[0],s=e.subarray(1);if(i===t&&(o===2||o===3)){let e=a.fromBytes(s);if(!a.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=T(e),n;try{n=a.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}y();let r=a.isOdd(n);return(o&1)==1!==r&&(n=a.neg(n)),{x:e,y:n}}else if(i===n&&o===4){let e=a.BYTES,t=a.fromBytes(s.subarray(0,e)),n=a.fromBytes(s.subarray(e,e*2));if(!E(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let C=t.toBytes||b,w=t.fromBytes||S;function T(e){let t=a.sqr(e),n=a.mul(t,e);return a.add(a.add(n,a.mul(e,c.a)),c.b)}function E(e,t){let n=a.sqr(t),r=T(e);return a.eql(n,r)}if(!E(c.Gx,c.Gy))throw Error(`bad curve params: generator point`);let D=a.mul(a.pow(c.a,m),h),O=a.mul(a.sqr(c.b),BigInt(27));if(a.is0(a.add(D,O)))throw Error(`bad curve params: a or b`);function k(e,t,n=!1){if(!a.isValid(t)||n&&a.is0(t))throw Error(`bad point coordinate ${e}`);return t}function A(e){if(!(e instanceof F))throw Error(`ProjectivePoint expected`)}function j(e){if(!p||!p.basises)throw Error(`no endo`);return s(e,p.basises,o.ORDER)}let M=(0,r.memoized)((e,t)=>{let{X:n,Y:r,Z:i}=e;if(a.eql(i,a.ONE))return{x:n,y:r};let o=e.is0();t??=o?a.ONE:a.inv(i);let s=a.mul(n,t),c=a.mul(r,t),l=a.mul(i,t);if(o)return{x:a.ZERO,y:a.ZERO};if(!a.eql(l,a.ONE))throw Error(`invZ was invalid`);return{x:s,y:c}}),N=(0,r.memoized)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!a.is0(e.Y))return;throw Error(`bad point: ZERO`)}let{x:n,y:r}=e.toAffine();if(!a.isValid(n)||!a.isValid(r))throw Error(`bad point: x or y not field elements`);if(!E(n,r))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);return!0});function P(e,t,n,r,o){return n=new F(a.mul(n.X,e),n.Y,n.Z),t=(0,i.negateCt)(r,t),n=(0,i.negateCt)(o,n),t.add(n)}class F{constructor(e,t,n){this.X=k(`x`,e),this.Y=k(`y`,t,!0),this.Z=k(`z`,n),Object.freeze(this)}static CURVE(){return c}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!a.isValid(t)||!a.isValid(n))throw Error(`invalid affine point`);if(e instanceof F)throw Error(`projective point not allowed`);return a.is0(t)&&a.is0(n)?F.ZERO:new F(t,n,a.ONE)}static fromBytes(e){let t=F.fromAffine(w((0,r._abytes2)(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return F.fromBytes((0,r.ensureBytes)(`pointHex`,e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return L.createCache(this,e),t||this.multiply(m),this}assertValidity(){N(this)}hasEvenY(){let{y:e}=this.toAffine();if(!a.isOdd)throw Error(`Field doesn't support isOdd`);return!a.isOdd(e)}equals(e){A(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:o,Z:s}=e,c=a.eql(a.mul(t,s),a.mul(i,r)),l=a.eql(a.mul(n,s),a.mul(o,r));return c&&l}negate(){return new F(this.X,a.neg(this.Y),this.Z)}double(){let{a:e,b:t}=c,n=a.mul(t,m),{X:r,Y:i,Z:o}=this,s=a.ZERO,l=a.ZERO,u=a.ZERO,d=a.mul(r,r),f=a.mul(i,i),p=a.mul(o,o),h=a.mul(r,i);return h=a.add(h,h),u=a.mul(r,o),u=a.add(u,u),s=a.mul(e,u),l=a.mul(n,p),l=a.add(s,l),s=a.sub(f,l),l=a.add(f,l),l=a.mul(s,l),s=a.mul(h,s),u=a.mul(n,u),p=a.mul(e,p),h=a.sub(d,p),h=a.mul(e,h),h=a.add(h,u),u=a.add(d,d),d=a.add(u,d),d=a.add(d,p),d=a.mul(d,h),l=a.add(l,d),p=a.mul(i,o),p=a.add(p,p),d=a.mul(p,h),s=a.sub(s,d),u=a.mul(p,f),u=a.add(u,u),u=a.add(u,u),new F(s,l,u)}add(e){A(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:o,Z:s}=e,l=a.ZERO,u=a.ZERO,d=a.ZERO,f=c.a,p=a.mul(c.b,m),h=a.mul(t,i),g=a.mul(n,o),_=a.mul(r,s),v=a.add(t,n),y=a.add(i,o);v=a.mul(v,y),y=a.add(h,g),v=a.sub(v,y),y=a.add(t,r);let b=a.add(i,s);return y=a.mul(y,b),b=a.add(h,_),y=a.sub(y,b),b=a.add(n,r),l=a.add(o,s),b=a.mul(b,l),l=a.add(g,_),b=a.sub(b,l),d=a.mul(f,y),l=a.mul(p,_),d=a.add(l,d),l=a.sub(g,d),d=a.add(g,d),u=a.mul(l,d),g=a.add(h,h),g=a.add(g,h),_=a.mul(f,_),y=a.mul(p,y),g=a.add(g,_),_=a.sub(h,_),_=a.mul(f,_),y=a.add(y,_),h=a.mul(g,y),u=a.add(u,h),h=a.mul(b,y),l=a.mul(v,l),l=a.sub(l,h),h=a.mul(v,g),d=a.mul(b,d),d=a.add(d,h),new F(l,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(F.ZERO)}multiply(e){let{endo:n}=t;if(!o.isValidNot0(e))throw Error(`invalid scalar: out of range`);let r,a,s=e=>L.cached(this,e,e=>(0,i.normalizeZ)(F,e));if(n){let{k1neg:t,k1:i,k2neg:o,k2:c}=j(e),{p:l,f:u}=s(i),{p:d,f}=s(c);a=u.add(f),r=P(n.beta,l,d,t,o)}else{let{p:t,f:n}=s(e);r=t,a=n}return(0,i.normalizeZ)(F,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this;if(!o.isValid(e))throw Error(`invalid scalar: out of range`);if(e===d||r.is0())return F.ZERO;if(e===f)return r;if(L.hasCache(this))return this.multiply(e);if(n){let{k1neg:t,k1:a,k2neg:o,k2:s}=j(e),{p1:c,p2:l}=(0,i.mulEndoUnsafe)(F,r,a,s);return P(n.beta,c,l,t,o)}else return L.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){let r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return M(this,e)}isTorsionFree(){let{isTorsionFree:e}=t;return l===f?!0:e?e(F,this):L.unsafe(this,u).is0()}clearCofactor(){let{clearCofactor:e}=t;return l===f?this:e?e(F,this):this.multiplyUnsafe(l)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}toBytes(e=!0){return(0,r._abool2)(e,`isCompressed`),this.assertValidity(),C(F,this,e)}toHex(e=!0){return(0,r.bytesToHex)(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return(0,i.normalizeZ)(F,e)}static msm(e,t){return(0,i.pippenger)(F,o,e,t)}static fromPrivateKey(e){return F.BASE.multiply(g(o,e))}}F.BASE=new F(c.Gx,c.Gy,a.ONE),F.ZERO=new F(a.ZERO,a.ONE,a.ZERO),F.Fp=a,F.Fn=o;let I=o.BITS,L=new i.wNAF(F,t.endo?Math.ceil(I/2):I);return F.BASE.precompute(8),F}function v(e){return Uint8Array.of(e?2:3)}function y(e,t){let n=e.ORDER,r=d;for(let e=n-f;e%p===d;e/=p)r+=f;let i=r,a=p<<i-f-f,o=a*p,s=(n-f)/o,c=(s-f)/p,l=o-f,u=a,g=e.pow(t,s),_=e.pow(t,(s+f)/p),v=(t,n)=>{let r=g,a=e.pow(n,l),o=e.sqr(a);o=e.mul(o,n);let s=e.mul(t,o);s=e.pow(s,c),s=e.mul(s,a),a=e.mul(s,n),o=e.mul(s,t);let d=e.mul(o,a);s=e.pow(d,u);let m=e.eql(s,e.ONE);a=e.mul(o,_),s=e.mul(d,r),o=e.cmov(a,o,m),d=e.cmov(s,d,m);for(let t=i;t>f;t--){let n=t-p;n=p<<n-f;let i=e.pow(d,n),s=e.eql(i,e.ONE);a=e.mul(o,r),r=e.mul(r,r),i=e.mul(d,r),o=e.cmov(a,o,s),d=e.cmov(i,d,s)}return{isValid:m,value:o}};if(e.ORDER%h===m){let n=(e.ORDER-m)/h,r=e.sqrt(e.neg(t));v=(t,i)=>{let a=e.sqr(i),o=e.mul(t,i);a=e.mul(a,o);let s=e.pow(a,n);s=e.mul(s,o);let c=e.mul(s,r),l=e.mul(e.sqr(s),i),u=e.eql(l,t);return{isValid:u,value:e.cmov(c,s,u)}}}return v}function b(e,t){(0,a.validateField)(e);let{A:n,B:r,Z:i}=t;if(!e.isValid(n)||!e.isValid(r)||!e.isValid(i))throw Error(`mapToCurveSimpleSWU: invalid opts`);let o=y(e,i);if(!e.isOdd)throw Error(`Field does not have .isOdd()`);return t=>{let s,c,l,u,d,f,p,m;s=e.sqr(t),s=e.mul(s,i),c=e.sqr(s),c=e.add(c,s),l=e.add(c,e.ONE),l=e.mul(l,r),u=e.cmov(i,e.neg(c),!e.eql(c,e.ZERO)),u=e.mul(u,n),c=e.sqr(l),f=e.sqr(u),d=e.mul(f,n),c=e.add(c,d),c=e.mul(c,l),f=e.mul(f,u),d=e.mul(f,r),c=e.add(c,d),p=e.mul(s,l);let{isValid:h,value:g}=o(c,f);m=e.mul(s,t),m=e.mul(m,g),p=e.cmov(p,l,h),m=e.cmov(m,g,h);let _=e.isOdd(t)===e.isOdd(m);m=e.cmov(e.neg(m),m,_);let v=(0,a.FpInvertBatch)(e,[u],!0)[0];return p=e.mul(p,v),{x:p,y:m}}}function x(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function S(e,t={}){let{Fn:n}=e,i=t.randomBytes||r.randomBytes,o=Object.assign(x(e.Fp,n),{seed:(0,a.getMinHashLength)(n.ORDER)});function s(e){try{return!!g(n,e)}catch{return!1}}function c(t,n){let{publicKey:r,publicKeyUncompressed:i}=o;try{let a=t.length;return n===!0&&a!==r||n===!1&&a!==i?!1:!!e.fromBytes(t)}catch{return!1}}function l(e=i(o.seed)){return(0,a.mapHashToField)((0,r._abytes2)(e,o.seed,`seed`),n.ORDER)}function u(t,r=!0){return e.BASE.multiply(g(n,t)).toBytes(r)}function d(e){let t=l(e);return{secretKey:t,publicKey:u(t)}}function f(t){if(typeof t==`bigint`)return!1;if(t instanceof e)return!0;let{secretKey:i,publicKey:a,publicKeyUncompressed:s}=o;if(n.allowedLengths||i===a)return;let c=(0,r.ensureBytes)(`key`,t).length;return c===a||c===s}function p(t,r,i=!0){if(f(t)===!0)throw Error(`first arg must be private key`);if(f(r)===!1)throw Error(`second arg must be public key`);let a=g(n,t);return e.fromHex(r).multiply(a).toBytes(i)}return Object.freeze({getPublicKey:u,getSharedSecret:p,keygen:d,Point:e,utils:{isValidSecretKey:s,isValidPublicKey:c,randomSecretKey:l,isValidPrivateKey:s,randomPrivateKey:l,normPrivateKeyToScalar:e=>g(n,e),precompute(t=8,n=e.BASE){return n.precompute(t,!1)}},lengths:o})}function C(i,a,o={}){(0,n.ahash)(a),(0,r._validateObject)(o,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let s=o.randomBytes||r.randomBytes,u=o.hmac||((e,...n)=>(0,t.hmac)(a,e,(0,r.concatBytes)(...n))),{Fp:m,Fn:h}=i,{ORDER:_,BITS:y}=h,{keygen:b,getPublicKey:x,getSharedSecret:C,utils:w,lengths:T}=S(i,o),E={prehash:!1,lowS:typeof o.lowS==`boolean`?o.lowS:!1,format:void 0,extraEntropy:!1},D=`compact`;function O(e){return e>_>>f}function k(e,t){if(!h.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function A(e,t){c(t);let n=T.signature,i=t===`compact`?n:t===`recovered`?n+1:void 0;return(0,r._abytes2)(e,i,`${t} signature`)}class j{constructor(e,t,n){this.r=k(`r`,e),this.s=k(`s`,t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(t,n=D){A(t,n);let i;if(n===`der`){let{r:n,s:i}=e.DER.toSig((0,r._abytes2)(t));return new j(n,i)}n===`recovered`&&(i=t[0],n=`compact`,t=t.subarray(1));let a=h.BYTES,o=t.subarray(0,a),s=t.subarray(a,a*2);return new j(h.fromBytes(o),h.fromBytes(s),i)}static fromHex(e,t){return this.fromBytes((0,r.hexToBytes)(e),t)}addRecoveryBit(e){return new j(this.r,this.s,e)}recoverPublicKey(e){let t=m.ORDER,{r:n,s:a,recovery:o}=this;if(o==null||![0,1,2,3].includes(o))throw Error(`recovery id invalid`);if(_*p<t&&o>1)throw Error(`recovery id is ambiguous for h>1 curve`);let s=o===2||o===3?n+_:n;if(!m.isValid(s))throw Error(`recovery id 2 or 3 invalid`);let c=m.toBytes(s),l=i.fromBytes((0,r.concatBytes)(v((o&1)==0),c)),u=h.inv(s),d=N((0,r.ensureBytes)(`msgHash`,e)),f=h.create(-d*u),g=h.create(a*u),y=i.BASE.multiplyUnsafe(f).add(l.multiplyUnsafe(g));if(y.is0())throw Error(`point at infinify`);return y.assertValidity(),y}hasHighS(){return O(this.s)}toBytes(t=D){if(c(t),t===`der`)return(0,r.hexToBytes)(e.DER.hexFromSig(this));let n=h.toBytes(this.r),i=h.toBytes(this.s);if(t===`recovered`){if(this.recovery==null)throw Error(`recovery bit must be present`);return(0,r.concatBytes)(Uint8Array.of(this.recovery),n,i)}return(0,r.concatBytes)(n,i)}toHex(e){return(0,r.bytesToHex)(this.toBytes(e))}assertValidity(){}static fromCompact(e){return j.fromBytes((0,r.ensureBytes)(`sig`,e),`compact`)}static fromDER(e){return j.fromBytes((0,r.ensureBytes)(`sig`,e),`der`)}normalizeS(){return this.hasHighS()?new j(this.r,h.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes(`der`)}toDERHex(){return(0,r.bytesToHex)(this.toBytes(`der`))}toCompactRawBytes(){return this.toBytes(`compact`)}toCompactHex(){return(0,r.bytesToHex)(this.toBytes(`compact`))}}let M=o.bits2int||function(e){if(e.length>8192)throw Error(`input is too large`);let t=(0,r.bytesToNumberBE)(e),n=e.length*8-y;return n>0?t>>BigInt(n):t},N=o.bits2int_modN||function(e){return h.create(M(e))},P=(0,r.bitMask)(y);function F(e){return(0,r.aInRange)(`num < 2^`+y,e,d,P),h.toBytes(e)}function I(e,t){return(0,r._abytes2)(e,void 0,`message`),t?(0,r._abytes2)(a(e),void 0,`prehashed message`):e}function L(e,t,n){if([`recovered`,`canonical`].some(e=>e in n))throw Error(`sign() legacy options not supported`);let{lowS:a,prehash:o,extraEntropy:c}=l(n,E);e=I(e,o);let u=N(e),p=g(h,t),m=[F(p),F(u)];if(c!=null&&c!==!1){let e=c===!0?s(T.secretKey):c;m.push((0,r.ensureBytes)(`extraEntropy`,e))}let _=(0,r.concatBytes)(...m),v=u;function y(e){let t=M(e);if(!h.isValidNot0(t))return;let n=h.inv(t),r=i.BASE.multiply(t).toAffine(),o=h.create(r.x);if(o===d)return;let s=h.create(n*h.create(v+o*p));if(s===d)return;let c=(r.x===o?0:2)|Number(r.y&f),l=s;return a&&O(s)&&(l=h.neg(s),c^=1),new j(o,l,c)}return{seed:_,k2sig:y}}function R(e,t,n={}){e=(0,r.ensureBytes)(`message`,e);let{seed:i,k2sig:o}=L(e,t,n);return(0,r.createHmacDrbg)(a.outputLen,h.BYTES,u)(i,o)}function z(t){let n,i=typeof t==`string`||(0,r.isBytes)(t),a=!i&&typeof t==`object`&&!!t&&typeof t.r==`bigint`&&typeof t.s==`bigint`;if(!i&&!a)throw Error(`invalid signature, expected Uint8Array, hex string or Signature instance`);if(a)n=new j(t.r,t.s);else if(i){try{n=j.fromBytes((0,r.ensureBytes)(`sig`,t),`der`)}catch(t){if(!(t instanceof e.DER.Err))throw t}if(!n)try{n=j.fromBytes((0,r.ensureBytes)(`sig`,t),`compact`)}catch{return!1}}return n||!1}function B(e,t,n,a={}){let{lowS:o,prehash:s,format:c}=l(a,E);if(n=(0,r.ensureBytes)(`publicKey`,n),t=I((0,r.ensureBytes)(`message`,t),s),`strict`in a)throw Error(`options.strict was renamed to lowS`);let u=c===void 0?z(e):j.fromBytes((0,r.ensureBytes)(`sig`,e),c);if(u===!1)return!1;try{let e=i.fromBytes(n);if(o&&u.hasHighS())return!1;let{r,s:a}=u,s=N(t),c=h.inv(a),l=h.create(s*c),d=h.create(r*c),f=i.BASE.multiplyUnsafe(l).add(e.multiplyUnsafe(d));return f.is0()?!1:h.create(f.x)===r}catch{return!1}}function V(e,t,n={}){let{prehash:r}=l(n,E);return t=I(t,r),j.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:b,getPublicKey:x,getSharedSecret:C,utils:w,lengths:T,Point:i,sign:R,verify:B,recoverPublicKey:V,Signature:j,hash:a})}function w(e){let{CURVE:t,curveOpts:n}=T(e);return O(e,_(t,n))}function T(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:(0,a.Field)(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function E(e){let{CURVE:t,curveOpts:n}=T(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function D(e,t,n){function r(r){let i=e.sqr(r),a=e.mul(i,r);return e.add(e.add(a,e.mul(r,t)),n)}return r}function O(e,t){let{Fp:n,Fn:i}=t;function a(e){return(0,r.inRange)(e,f,i.ORDER)}let o=D(n,e.a,e.b);return Object.assign({},{CURVE:e,Point:t,ProjectivePoint:t,normPrivateKeyToScalar:e=>g(i,e),weierstrassEquation:o,isWithinCurveOrder:a})}function k(e,t){let n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,(0,a.nLength)(n.Fn.ORDER,n.Fn.BITS))})}function A(e){let{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=E(e);return k(e,C(_(t,n),r,i))}})),Z=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getHash=n,e.createCurve=r;
|
|
21
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
22
|
+
let t=X();function n(e){return{hash:e}}function r(e,n){let r=n=>(0,t.weierstrass)({...e,hash:n});return{...r(n),create:r}}})),Q=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.encodeToCurve=e.hashToCurve=e.secp256k1_hasher=e.schnorr=e.secp256k1=void 0;
|
|
23
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
24
|
+
let t=V(),n=R(),r=Z(),i=K(),a=U(),o=X(),s=H(),c={p:BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),n:BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt(`0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`),Gy:BigInt(`0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8`)},l={beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),basises:[[BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),-BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`)],[BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),BigInt(`0x3086d221a7d46bcde86c90e49284eb15`)]]},u=BigInt(0),d=BigInt(1),f=BigInt(2);function p(e){let t=c.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),l=BigInt(44),u=BigInt(88),d=e*e*e%t,p=d*d*e%t,h=(0,a.pow2)(p,n,t)*p%t,g=(0,a.pow2)(h,n,t)*p%t,_=(0,a.pow2)(g,f,t)*d%t,v=(0,a.pow2)(_,i,t)*_%t,y=(0,a.pow2)(v,o,t)*v%t,b=(0,a.pow2)(y,l,t)*y%t,x=(0,a.pow2)(b,u,t)*b%t,S=(0,a.pow2)(x,l,t)*y%t,C=(0,a.pow2)(S,n,t)*p%t,w=(0,a.pow2)(C,s,t)*v%t,T=(0,a.pow2)(w,r,t)*d%t,E=(0,a.pow2)(T,f,t);if(!m.eql(m.sqr(E),e))throw Error(`Cannot find square root`);return E}let m=(0,a.Field)(c.p,{sqrt:p});e.secp256k1=(0,r.createCurve)({...c,Fp:m,lowS:!0,endo:l},t.sha256);let h={};function g(e,...n){let r=h[e];if(r===void 0){let n=(0,t.sha256)((0,s.utf8ToBytes)(e));r=(0,s.concatBytes)(n,n),h[e]=r}return(0,t.sha256)((0,s.concatBytes)(r,...n))}let _=e=>e.toBytes(!0).slice(1),v=e.secp256k1.Point,y=e=>e%f===u;function b(e){let{Fn:t,BASE:n}=v,r=(0,o._normFnElement)(t,e),i=n.multiply(r);return{scalar:y(i.y)?r:t.neg(r),bytes:_(i)}}function x(e){let t=m;if(!t.isValidNot0(e))throw Error(`invalid x: Fail if x ≥ p`);let n=t.create(e*e),r=t.create(n*e+BigInt(7)),i=t.sqrt(r);y(i)||(i=t.neg(i));let a=v.fromAffine({x:e,y:i});return a.assertValidity(),a}let S=s.bytesToNumberBE;function C(...e){return v.Fn.create(S(g(`BIP0340/challenge`,...e)))}function w(e){return b(e).bytes}function T(e,t,r=(0,n.randomBytes)(32)){let{Fn:i}=v,a=(0,s.ensureBytes)(`message`,e),{bytes:o,scalar:c}=b(t),l=(0,s.ensureBytes)(`auxRand`,r,32),{bytes:u,scalar:d}=b(g(`BIP0340/nonce`,i.toBytes(c^S(g(`BIP0340/aux`,l))),o,a)),f=C(u,o,a),p=new Uint8Array(64);if(p.set(u,0),p.set(i.toBytes(i.create(d+f*c)),32),!E(p,a,o))throw Error(`sign: Invalid signature produced`);return p}function E(e,t,n){let{Fn:r,BASE:i}=v,a=(0,s.ensureBytes)(`signature`,e,64),o=(0,s.ensureBytes)(`message`,t),l=(0,s.ensureBytes)(`publicKey`,n,32);try{let e=x(S(l)),t=S(a.subarray(0,32));if(!(0,s.inRange)(t,d,c.p))return!1;let n=S(a.subarray(32,64));if(!(0,s.inRange)(n,d,c.n))return!1;let u=C(r.toBytes(t),_(e),o),f=i.multiplyUnsafe(n).add(e.multiplyUnsafe(r.neg(u))),{x:p,y:m}=f.toAffine();return!(f.is0()||!y(m)||p!==t)}catch{return!1}}e.schnorr=(()=>{let t=(e=(0,n.randomBytes)(48))=>(0,a.mapHashToField)(e,c.n);e.secp256k1.utils.randomSecretKey;function r(e){let n=t(e);return{secretKey:n,publicKey:w(n)}}return{keygen:r,getPublicKey:w,sign:T,verify:E,Point:v,utils:{randomSecretKey:t,randomPrivateKey:t,taggedHash:g,lift_x:x,pointToBytes:_,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,mod:a.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();let D=(0,i.isogenyMap)(m,[[`0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7`,`0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581`,`0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262`,`0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c`],[`0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b`,`0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14`,`0x0000000000000000000000000000000000000000000000000000000000000001`],[`0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c`,`0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3`,`0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931`,`0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84`],[`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b`,`0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573`,`0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f`,`0x0000000000000000000000000000000000000000000000000000000000000001`]].map(e=>e.map(e=>BigInt(e)))),O=(0,o.mapToCurveSimpleSWU)(m,{A:BigInt(`0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533`),B:BigInt(`1771`),Z:m.create(BigInt(`-11`))});e.secp256k1_hasher=(0,i.createHasher)(e.secp256k1.Point,e=>{let{x:t,y:n}=O(m.create(e[0]));return D(t,n)},{DST:`secp256k1_XMD:SHA-256_SSWU_RO_`,encodeDST:`secp256k1_XMD:SHA-256_SSWU_NU_`,p:m.ORDER,m:1,k:128,expand:`xmd`,hash:t.sha256}),e.hashToCurve=e.secp256k1_hasher.hashToCurve,e.encodeToCurve=e.secp256k1_hasher.encodeToCurve})),ee=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.decodeHex=e.remove0x=void 0;var t=M();e.remove0x=function(e){return e.startsWith(`0x`)||e.startsWith(`0X`)?e.slice(2):e},e.decodeHex=function(n){return(0,t.hexToBytes)((0,e.remove0x)(n))}})),te=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.hexToPublicKey=e.convertPublicKeyFormat=e.getSharedPoint=e.getPublicKey=e.isValidPrivateKey=e.getValidSecret=void 0;var t=I(),n=J(),r=Q(),i=P(),a=N(),o=ee();e.getValidSecret=function(n){var r;do r=(0,t.randomBytes)(a.SECRET_KEY_LENGTH);while(!(0,e.isValidPrivateKey)(r,n));return r},e.isValidPrivateKey=function(e,t){return s(t,function(t){return t.utils.isValidSecretKey(e)},function(){return!0},function(){return!0})},e.getPublicKey=function(e,t){return s(t,function(t){return t.getPublicKey(e)},function(t){return t.getPublicKey(e)},function(t){return t.getPublicKey(e)})},e.getSharedPoint=function(e,t,n,r){return s(r,function(r){return r.getSharedSecret(e,t,n)},function(n){return n.getSharedSecret(e,t)},function(n){return l(n,e,t)})},e.convertPublicKeyFormat=function(e,t,n){return s(n,function(n){return n.getSharedSecret(Uint8Array.from(Array(31).fill(0).concat([1])),e,t)},function(){return e},function(){return e})},e.hexToPublicKey=function(e,t){var n=(0,o.decodeHex)(e);return s(t,function(){return c(n)},function(){return n},function(){return n})};function s(e,t,a,o){var s=e||(0,i.ellipticCurve)();if(s===`secp256k1`)return t(r.secp256k1);if(s===`x25519`)return a(n.x25519);if(s===`ed25519`)return o(n.ed25519);throw Error(`Not implemented`)}var c=function(e){if(e.length===a.ETH_PUBLIC_KEY_SIZE){var t=new Uint8Array(1+e.length);return t.set([4]),t.set(e,1),t}return e},l=function(e,t,n){var r=e.utils.getExtendedPublicKey(t).scalar;return e.Point.fromBytes(n).multiply(r).toBytes()}})),ne=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.hkdf=void 0,e.extract=r,e.expand=o;let t=Y(),n=R();function r(e,r,i){return(0,n.ahash)(e),i===void 0&&(i=new Uint8Array(e.outputLen)),(0,t.hmac)(e,(0,n.toBytes)(i),(0,n.toBytes)(r))}let i=Uint8Array.from([0]),a=Uint8Array.of();function o(e,r,o,s=32){(0,n.ahash)(e),(0,n.anumber)(s);let c=e.outputLen;if(s>255*c)throw Error(`Length should be <= 255*HashLen`);let l=Math.ceil(s/c);o===void 0&&(o=a);let u=new Uint8Array(l*c),d=t.hmac.create(e,r),f=d._cloneInto(),p=new Uint8Array(d.outputLen);for(let e=0;e<l;e++)i[0]=e+1,f.update(e===0?a:p).update(o).update(i).digestInto(p),u.set(p,c*e),d._cloneInto(f);return d.destroy(),f.destroy(),(0,n.clean)(p,i),u.slice(0,s)}e.hkdf=(e,t,n,i,a)=>o(e,r(e,t,n),i,a)})),re=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSharedKey=e.deriveKey=void 0;var t=M(),n=ne(),r=V();e.deriveKey=function(e,t,i){return(0,n.hkdf)(r.sha256,e,t,i,32)},e.getSharedKey=function(){var n=[...arguments];return(0,e.deriveKey)(t.concatBytes.apply(void 0,n))}})),ie=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e._compat=void 0;var t=M(),n=c(`node:crypto`),r=16,i=globalThis.Deno!==void 0;e._compat=function(e,a,o,s){var c=e===`aes-256-gcm`||e===`chacha20-poly1305`,l=c?r:0,u=c?{authTagLength:l}:void 0;return{encrypt:function(r){var i=(0,n.createCipheriv)(e,a,o,u);c&&s!==void 0&&i.setAAD(s);var l=i.update(r),d=i.final(),f=c?i.getAuthTag():new Uint8Array;return(0,t.concatBytes)(l,d,f)},decrypt:function(r){var d=r.subarray(0,r.length-l),f=r.subarray(r.length-l),p=(0,n.createDecipheriv)(e,a,o,u);c&&(s!==void 0&&p.setAAD(s),p.setAuthTag(f)),!c&&i&&p.setAutoPadding(!1);var m=p.update(d),h=p.final();return(0,t.concatBytes)(m,h)}}}})),ae=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.aes256cbc=e.aes256gcm=void 0;var t=ie();e.aes256gcm=function(e,n,r){return(0,t._compat)(`aes-256-gcm`,e,n,r)},e.aes256cbc=function(e,n,r){return(0,t._compat)(`aes-256-cbc`,e,n)}})),oe=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e._hchacha20=void 0,e._hchacha20=function(e,n,r,i){for(var a=e[0],o=e[1],s=e[2],c=e[3],l=n[0],u=n[1],d=n[2],f=n[3],p=n[4],m=n[5],h=n[6],g=n[7],_=r[0],v=r[1],y=r[2],b=r[3],x=0;x<20;x+=2)a=a+l|0,_=t(_^a,16),p=p+_|0,l=t(l^p,12),a=a+l|0,_=t(_^a,8),p=p+_|0,l=t(l^p,7),o=o+u|0,v=t(v^o,16),m=m+v|0,u=t(u^m,12),o=o+u|0,v=t(v^o,8),m=m+v|0,u=t(u^m,7),s=s+d|0,y=t(y^s,16),h=h+y|0,d=t(d^h,12),s=s+d|0,y=t(y^s,8),h=h+y|0,d=t(d^h,7),c=c+f|0,b=t(b^c,16),g=g+b|0,f=t(f^g,12),c=c+f|0,b=t(b^c,8),g=g+b|0,f=t(f^g,7),a=a+u|0,b=t(b^a,16),h=h+b|0,u=t(u^h,12),a=a+u|0,b=t(b^a,8),h=h+b|0,u=t(u^h,7),o=o+d|0,_=t(_^o,16),g=g+_|0,d=t(d^g,12),o=o+d|0,_=t(_^o,8),g=g+_|0,d=t(d^g,7),s=s+f|0,v=t(v^s,16),p=p+v|0,f=t(f^p,12),s=s+f|0,v=t(v^s,8),p=p+v|0,f=t(f^p,7),c=c+l|0,y=t(y^c,16),m=m+y|0,l=t(l^m,12),c=c+l|0,y=t(y^c,8),m=m+y|0,l=t(l^m,7);var S=0;i[S++]=a,i[S++]=o,i[S++]=s,i[S++]=c,i[S++]=_,i[S++]=v,i[S++]=y,i[S++]=b};var t=function(e,t){return e<<t|e>>>32-t}})),se=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.chacha20=e.xchacha20=void 0;var t=M(),n=ie(),r=oe();e.xchacha20=function(e,i,a){if(i.length!==24)throw Error(`xchacha20's nonce must be 24 bytes`);var o=new Uint32Array([1634760805,857760878,2036477234,1797285236]),s=new Uint32Array(8);(0,r._hchacha20)(o,(0,t.u32)(e),(0,t.u32)(i.subarray(0,16)),s);var c=new Uint8Array(12);return c.set([0,0,0,0]),c.set(i.subarray(16),4),(0,n._compat)(`chacha20-poly1305`,(0,t.u8)(s),c,a)},e.chacha20=function(e,t,r){if(t.length!==12)throw Error(`chacha20's nonce must be 12 bytes`);return(0,n._compat)(`chacha20-poly1305`,e,t,r)}})),ce=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.aesDecrypt=e.aesEncrypt=e.symDecrypt=e.symEncrypt=void 0;var t=ae(),n=se(),r=M(),i=I(),a=P(),o=N();e.symEncrypt=function(e,t,n){return s(c,e,t,n)},e.symDecrypt=function(e,t,n){return s(l,e,t,n)},e.aesEncrypt=e.symEncrypt,e.aesDecrypt=e.symDecrypt;function s(e,r,i,s){var c=(0,a.symmetricAlgorithm)();if(c===`aes-256-gcm`)return e(t.aes256gcm,r,i,(0,a.symmetricNonceLength)(),o.AEAD_TAG_LENGTH,s);if(c===`xchacha20`)return e(n.xchacha20,r,i,o.XCHACHA20_NONCE_LENGTH,o.AEAD_TAG_LENGTH,s);if(c===`aes-256-cbc`)return e(t.aes256cbc,r,i,16,0);throw Error(`Not implemented`)}function c(e,t,n,a,o,s){var c=(0,i.randomBytes)(a),l=e(t,c,s).encrypt(n);if(o===0)return(0,r.concatBytes)(c,l);var u=l.length-o,d=l.subarray(0,u),f=l.subarray(u);return(0,r.concatBytes)(c,f,d)}function l(e,t,n,i,a,o){var s=n.subarray(0,i),c=e(t,Uint8Array.from(s),o),l=n.subarray(i);if(a===0)return c.decrypt(l);var u=l.subarray(0,a),d=l.subarray(a);return c.decrypt((0,r.concatBytes)(d,u))}})),le=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(te(),e),n(re(),e),n(ee(),e),n(ce(),e)})),ue=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PublicKey=void 0;var t=M(),n=le();e.PublicKey=function(){function e(e,t){var r=(0,n.convertPublicKeyFormat)(e,!0,t),i=(0,n.convertPublicKeyFormat)(e,!1,t);this.data=r,this.dataUncompressed=r.length===i.length?null:i}return e.fromHex=function(t,r){return new e((0,n.hexToPublicKey)(t,r),r)},Object.defineProperty(e.prototype,`_uncompressed`,{get:function(){return this.dataUncompressed===null?this.data:this.dataUncompressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`uncompressed`,{get:function(){return Buffer.from(this._uncompressed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`compressed`,{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toBytes=function(e){return e===void 0&&(e=!0),e?this.data:this._uncompressed},e.prototype.toHex=function(e){return e===void 0&&(e=!0),(0,t.bytesToHex)(this.toBytes(e))},e.prototype.decapsulate=function(e,t){t===void 0&&(t=!1);var r=this.toBytes(t),i=e.multiply(this,t);return(0,n.getSharedKey)(r,i)},e.prototype.equals=function(e){return(0,t.equalBytes)(this.data,e.data)},e}()})),de=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PrivateKey=void 0;var t=M(),n=le(),r=ue();e.PrivateKey=function(){function e(e,t){if(this.curve=t,e===void 0)this.data=(0,n.getValidSecret)(t);else if((0,n.isValidPrivateKey)(e,t))this.data=e;else throw Error(`Invalid private key`);this.publicKey=new r.PublicKey((0,n.getPublicKey)(this.data,t),t)}return e.fromHex=function(t,r){return new e((0,n.decodeHex)(t),r)},Object.defineProperty(e.prototype,`secret`,{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(){return(0,t.bytesToHex)(this.data)},e.prototype.encapsulate=function(e,t){t===void 0&&(t=!1);var r=this.publicKey.toBytes(t),i=this.multiply(e,t);return(0,n.getSharedKey)(r,i)},e.prototype.multiply=function(e,t){return t===void 0&&(t=!1),(0,n.getSharedPoint)(this.data,e.toBytes(!0),t,this.curve)},e.prototype.equals=function(e){return(0,t.equalBytes)(this.data,e.data)},e}()})),fe=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PublicKey=e.PrivateKey=void 0;var t=de();Object.defineProperty(e,`PrivateKey`,{enumerable:!0,get:function(){return t.PrivateKey}});var n=ue();Object.defineProperty(e,`PublicKey`,{enumerable:!0,get:function(){return n.PublicKey}})})),pe=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.utils=e.PublicKey=e.PrivateKey=e.ECIES_CONFIG=void 0,e.encrypt=a,e.decrypt=s;var t=M(),n=P(),r=fe(),i=le();function a(e,t){return Buffer.from(o(e,t))}function o(e,a){var o=(0,n.ellipticCurve)(),s=new r.PrivateKey(void 0,o),c=e instanceof Uint8Array?new r.PublicKey(e,o):r.PublicKey.fromHex(e,o),l=s.encapsulate(c,(0,n.isHkdfKeyCompressed)()),u=s.publicKey.toBytes((0,n.isEphemeralKeyCompressed)()),d=(0,i.symEncrypt)(l,a);return(0,t.concatBytes)(u,d)}function s(e,t){return Buffer.from(c(e,t))}function c(e,t){var a=(0,n.ellipticCurve)(),o=e instanceof Uint8Array?new r.PrivateKey(e,a):r.PrivateKey.fromHex(e,a),s=(0,n.ephemeralKeySize)(),c=new r.PublicKey(t.subarray(0,s),a),l=t.subarray(s),u=c.decapsulate(o,(0,n.isHkdfKeyCompressed)());return(0,i.symDecrypt)(u,l)}var l=P();Object.defineProperty(e,`ECIES_CONFIG`,{enumerable:!0,get:function(){return l.ECIES_CONFIG}});var u=fe();Object.defineProperty(e,`PrivateKey`,{enumerable:!0,get:function(){return u.PrivateKey}}),Object.defineProperty(e,`PublicKey`,{enumerable:!0,get:function(){return u.PublicKey}}),e.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}})),me=s(((e,t)=>{let{decrypt:n}=pe(),r=v();function i(e,t,i,a){let o,s;if(!t.startsWith(`encrypted:`))return t;if(a||=``,a.length<=0)s=new r({key:e,privateKeyName:i,privateKey:a}).missingPrivateKey();else{let c=a.split(`,`);for(let l of c){let c=Buffer.from(l,`hex`),u=t.substring(10),d=Buffer.from(u,`base64`);try{o=n(c,d).toString(),s=null;break}catch(t){s=t.message===`Invalid private key`?new r({key:e,privateKeyName:i,privateKey:a}).invalidPrivateKey():t.message===`Unsupported state or unable to authenticate data`?new r({key:e,privateKeyName:i,privateKey:a}).wrongPrivateKey():t.message===`Point of length 65 was invalid. Expected 33 compressed bytes or 65 uncompressed bytes`?new r({key:e,privateKeyName:i,privateKey:a}).malformedEncryptedData():new r({key:e,privateKeyName:i,privateKey:a,message:t.message}).decryptionFailed()}}}if(s)throw s;return o}t.exports=i})),he=s(((e,t)=>{let n=/^encrypted:.+/;function r(e){return n.test(e)}t.exports=r})),ge=s(((e,t)=>{function n(e){return e.replace(/[\r\n]+$/,``)}t.exports=n})),_e=s(((e,t)=>{let{execSync:n}=c(`child_process`),r=ge(),i=v();function a(e,t,a,o){return(t.match(/\$\(([^)]+(?:\)[^(]*)*)\)/g)||[]).reduce((t,s)=>{let c=s.slice(2,-1),l;try{l=n(c,{env:{...a,...o}}).toString()}catch(t){throw new i({key:e,command:c,message:t.message.trim()}).commandSubstitutionFailed()}return l=r(l),t.replace(s,l)},t)}t.exports=a})),ve=s(((e,t)=>{function n(e){return e.replace(/\\\$/g,`$`)}t.exports=n})),ye=s(((e,t)=>{let n=me(),r=he(),i=_e(),a=ve();t.exports=class e{static LINE=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;constructor(e,t=null,n=process.env,r=!1,i=null){this.src=e,this.privateKey=t,this.privateKeyName=i,this.processEnv=n,this.overload=r,this.parsed={},this.preExisted={},this.injected={},this.errors=[],this.runningParsed={},this.literals={}}run(){let t=this.getLines(),n;for(;(n=e.LINE.exec(t))!==null;){let e=n[1],t=n[2],i=this.quote(t);this.parsed[e]=this.clean(t,i),!this.overload&&this.inProcessEnv(e)&&(this.parsed[e]=this.processEnv[e]);try{this.parsed[e]=this.decrypt(e,this.parsed[e])}catch(e){this.errors.push(e)}let o=r(this.parsed[e]),s=!1;if(!o&&i!==`'`&&(!this.inProcessEnv(e)||this.processEnv[e]===this.parsed[e])){let t=this.parsed[e];try{this.parsed[e]=this.eval(e,t)}catch(e){this.errors.push(e)}t!==this.parsed[e]&&(s=!0)}!o&&!s&&i!==`'`&&(!this.processEnv[e]||this.overload)&&(this.parsed[e]=a(this.expand(this.parsed[e]))),i===`'`&&(this.literals[e]=this.parsed[e]),this.runningParsed[e]=this.parsed[e],Object.prototype.hasOwnProperty.call(this.processEnv,e)&&!this.overload?this.preExisted[e]=this.processEnv[e]:this.injected[e]=this.parsed[e]}return{parsed:this.parsed,processEnv:this.processEnv,injected:this.injected,preExisted:this.preExisted,errors:this.errors}}trimmer(e){return(e||``).trim()}quote(e){let t=this.trimmer(e)[0],n=``;switch(t){case`'`:n=`'`;break;case`"`:n=`"`;break;case"`":n="`";break;default:n=``}return n}clean(e,t){let n=this.trimmer(e);return n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),t===`"`&&(n=n.replace(/\\n/g,`
|
|
25
|
+
`),n=n.replace(/\\r/g,`\r`),n=n.replace(/\\t/g,` `)),n}decrypt(e,t){return n(e,t,this.privateKeyName,this.privateKey)}eval(e,t){return i(e,t,this.processEnv,this.runningParsed)}expand(e){let t={...this.runningParsed,...this.processEnv};this.overload&&(t={...this.processEnv,...this.runningParsed});let n=/(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g,r=e,i;for(;(i=n.exec(r))!==null;){let[e,a,o]=i,s=a||o,c=s.match(/(:\+|\+|:-|-)/),l=c?c[0]:null,u=s.split(l),d,f,p=u.shift();if([`:+`,`+`].includes(l)?(d=t[p]?u.join(l):``,f=null):(d=u.join(l),f=t[p]),r=f?r.replace(e,f):r.replace(e,d),r===t[p]||this.literals[p]&&/\$\{[^}]+\}|\$[A-Za-z_][A-Za-z0-9_]*/.test(this.literals[p]))break;n.lastIndex=0}return r}inProcessEnv(e){return Object.prototype.hasOwnProperty.call(this.processEnv,e)}getLines(){return(this.src||``).toString().replace(/\r\n?/gm,`
|
|
26
|
+
`)}}})),be=s(((e,t)=>{let n=c(`fs`);async function r(e){let t=await n.promises.readFile(e);return t.length>=2&&t[0]===255&&t[1]===254?`utf16le`:(t.length>=3&&t[0]===239&&t[1]===187&&t[2],`utf8`)}t.exports=r})),xe=s(((e,t)=>{let n=c(`fs`);function r(e){let t=n.readFileSync(e);return t.length>=2&&t[0]===255&&t[1]===254?`utf16le`:(t.length>=3&&t[0]===239&&t[1]===187&&t[2],`utf8`)}t.exports=r})),Se=s(((e,t)=>{let n=c(`path`);function r(e){let t=n.basename(e).toLowerCase();return t.startsWith(`.env`)&&t.endsWith(`.txt`)&&(t=t.slice(0,-4)),t}t.exports=r})),Ce=s(((e,t)=>{let n=Se();function r(e){let t=n(e),r=[...t.split(`.`).slice(2)];return r.length===0?t.replace(`.env`,`development`):r.length===1?r[0]:r.length===2?r.join(`_`):r.slice(0,2).join(`_`)}t.exports=r})),we=s(((e,t)=>{let n=Se(),r=Ce();function i(e){let t=n(e);if(t===`.env`)return{publicKeyName:`DOTENV_PUBLIC_KEY`,privateKeyName:`DOTENV_PRIVATE_KEY`};let i=r(t).toUpperCase();return{publicKeyName:`DOTENV_PUBLIC_KEY_${i}`,privateKeyName:`DOTENV_PRIVATE_KEY_${i}`}}t.exports=i})),$=s(((e,t)=>{let n=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function r(e,t=!1,r=!1,i=!1){let a={},o=e.toString();r||(o=o.replace(/\r\n?/gm,`
|
|
27
|
+
`));let s;for(;(s=n.exec(o))!=null;){let e=s[1],n=s[2]||``;n=n.trim();let r=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),r===`"`&&!t&&(n=n.replace(/\\n/g,`
|
|
28
|
+
`),n=n.replace(/\\r/g,`\r`),n=n.replace(/\\t/g,` `)),i?(a[e]=a[e]||[],a[e].push(n)):a[e]=n}return a}t.exports=r})),Te=s(((e,t)=>{function n(e){if(process.env[e]&&process.env[e].length>0)return process.env[e]}t.exports=n})),Ee=s(((e,t)=>{let n=A(),r=$();async function i(e,t){if(!await n.exists(t))return;let i=r(await n.readFileX(t));if(i[e]&&i[e].length>0)return i[e]}t.exports=i})),De=s(((e,t)=>{let n=c(`path`),r=c(`child_process`),i=c(`util`),{logger:a}=x(),o=i.promisify(r.execFile);t.exports=class{async status(){if(this._isForcedOff())return`off`;let e=await this._resolveBinary();if(!e)return`off`;try{return await this._exec(e,[`status`])}catch{return`off`}}statusSync(){if(this._isForcedOff())return`off`;let e=this._resolveBinarySync();if(!e)return`off`;try{return this._execSync(e,[`status`])}catch{return`off`}}async keypair(e,t={}){if(this._isForcedOff())return{};let n=await this._resolveBinary();if(!n)return{};let r=[`keypair`];t.noSpinner&&r.push(`--no-spinner`),e&&r.push(e);try{return JSON.parse(await this._execInteractive(n,r))}catch{return{}}}keypairSync(e,t={}){if(this._isForcedOff())return{};let n=this._resolveBinarySync();if(!n)return{};let r=[`keypair`];t.noSpinner&&r.push(`--no-spinner`),e&&r.push(e);try{return JSON.parse(this._execInteractiveSync(n,r))}catch{return{}}}observe(e){if(this._isForcedOff())return;let t=this._resolveBinarySync();if(!t)return;let n=`off`;try{n=this._execSync(t,[`status`])}catch{return}if(n===`off`)return;let i=Buffer.from(JSON.stringify(e)).toString(`base64`);try{r.spawn(t,[`observe`,i],{stdio:`ignore`,detached:!0}).unref()}catch{}}async _exec(e,t){let{stdout:n,stderr:r}=await o(e,t);return r&&r.length>0&&process.stderr.write(r.toString()),n.toString().trim()}_execSync(e,t){return a.debug(e),a.debug(t),r.execFileSync(e,t).toString().trim()}_execInteractive(e,t){return new Promise((n,i)=>{let a=r.spawn(e,t,{stdio:[`inherit`,`pipe`,`inherit`]}),o=``;a.stdout.on(`data`,e=>{o+=e.toString()}),a.on(`error`,i),a.on(`close`,r=>{if(r!==0){i(Error(`${e} ${t.join(` `)} exited with code ${r}`));return}n(o.trim())})})}_execInteractiveSync(e,t){return a.debug(e),a.debug(t),r.execFileSync(e,t,{stdio:[`inherit`,`pipe`,`inherit`]}).toString().trim()}async _resolveBinary(){return this._binaryPromise||=(async()=>{let e=n.resolve(process.cwd(),`node_modules/.bin/dotenvx-ops`);try{return await this._exec(e,[`--version`]),e}catch{}try{return await this._exec(`dotenvx-ops`,[`--version`]),`dotenvx-ops`}catch{}return null})(),this._binaryPromise}_resolveBinarySync(){if(this._binarySync!==void 0)return this._binarySync;let e=n.resolve(process.cwd(),`node_modules/.bin/dotenvx-ops`);try{return this._execSync(e,[`--version`]),this._binarySync=e,this._binarySync}catch(e){a.debug(e.message)}try{return this._execSync(`dotenvx-ops`,[`--version`]),this._binarySync=`dotenvx-ops`,this._binarySync}catch(e){a.debug(e.message)}return this._binarySync=null,null}_isForcedOff(){return process.env.DOTENVX_NO_OPS===`true`}}})),Oe=s(((e,t)=>{let n=De();async function r(e,t={}){t.beforeOpsKeypair&&await t.beforeOpsKeypair();let r;try{r=t.beforeOpsKeypair||t.afterOpsKeypair?await new n().keypair(e,{noSpinner:!0}):await new n().keypair(e)}finally{t.afterOpsKeypair&&await t.afterOpsKeypair()}return{publicKey:r.public_key,privateKey:r.private_key}}t.exports=r})),ke=s(((e,t)=>{let n=c(`path`),r=A(),i=$(),a=we(),o=Te(),s=Ee(),l=Oe();async function u(e){let t=`DOTENV_PUBLIC_KEY`;if(!await r.exists(e))return null;let n=i(await r.readFileX(e)),a;for(let e of Object.keys(n))(e===t||e.startsWith(t))&&(a=e);return a?a.replace(t,`DOTENV_PRIVATE_KEY`):null}async function d(e,t={}){let r=t.keysFilepath||null,i=t.noOps===!0,c=a(e),d=c.publicKeyName,f=c.privateKeyName,p=null,m=null;return p=o(d),p||=await s(d,e)||null,m=o(f),m||=(r=r?n.resolve(r):n.resolve(n.dirname(e),`.env.keys`),await s(f,r)),m||(f=await u(e),f&&(m=o(f),m||=await s(f,r))),!i&&!m&&p&&p.length>0&&(m=(await l(p,{beforeOpsKeypair:t.beforeOpsKeypair,afterOpsKeypair:t.afterOpsKeypair})).privateKey),{publicKeyValue:p||null,privateKeyValue:m||null}}t.exports=d})),Ae=s(((e,t)=>{let n=A(),r=$();function i(e,t){if(n.existsSync(t)){let i=r(n.readFileXSync(t));if(i[e]&&i[e].length>0)return i[e]}}t.exports=i})),je=s(((e,t)=>{let n=De();function r(e,t={}){let r=new n,i=Object.keys(t).length>0?r.keypairSync(e,t):r.keypairSync(e);return{publicKey:i.public_key,privateKey:i.private_key}}t.exports=r})),Me=s(((e,t)=>{let n=c(`path`),r=A(),i=$(),a=we(),o=Te(),s=Ae(),l=je();function u(e){let t=`DOTENV_PUBLIC_KEY`;if(!r.existsSync(e))return null;let n=i(r.readFileXSync(e)),a;for(let e of Object.keys(n))(e===t||e.startsWith(t))&&(a=e);return a?a.replace(t,`DOTENV_PRIVATE_KEY`):null}function d(e,t={}){let r=t.keysFilepath||null,i=t.noOps===!0,c=a(e),d=c.publicKeyName,f=c.privateKeyName,p=null,m=null;if(p=o(d),p||=s(d,e)||null,m=o(f),m||=(r=r?n.resolve(r):n.resolve(n.dirname(e),`.env.keys`),s(f,r)),m||(f=u(e),f&&(m=o(f),m||=s(f,r))),!i&&!m&&p&&p.length>0){let e={};t.noSpinner&&(e.noSpinner=!0),m=(Object.keys(e).length>0?l(p,e):l(p)).privateKey}return{publicKeyValue:p||null,privateKeyValue:m||null}}t.exports=d})),Ne=s(((e,t)=>{let n=c(`path`),r=$(),i=Ae(),a=je(),o=`DOTENV_PUBLIC_KEY`;function s(e,t){if(e[t]&&e[t].length>0)return e[t]}function l(e){for(let t of Object.keys(e))if(t===o||t.startsWith(o))return t;return null}function u(e,t=null,c={}){let u=c.keysFilepath||null,d=c.noOps===!0,f=c.processEnv||process.env,p=r(e),m=l(p),h=m&&(s(f,m)||p[m])||null;!t&&m&&(t=m.replace(o,`DOTENV_PRIVATE_KEY`));let g=null;return t&&(g=s(f,t),g||=(u=u?n.resolve(u):n.resolve(`.env.keys`),i(t,u))),!d&&!g&&h&&h.length>0&&(g=a(h).privateKey),{publicKeyValue:h||null,privateKeyValue:g||null,privateKeyName:t||null}}t.exports=u})),Pe=s(((e,t)=>{let n=`DOTENV_PRIVATE_KEY`;function r(e){return e===n?`.env`:`.env.${e.substring(`${n}_`.length).split(`_`).join(`.`).toLowerCase()}`}t.exports=r})),Fe=s(((e,t)=>{function n(e){return Object.keys(e).filter(e=>e.startsWith(`DOTENV_PRIVATE_KEY`))}t.exports=n})),Ie=s(((e,t)=>{t.exports={keyNames:we(),keyValues:ke(),keyValuesSync:Me(),keyValuesFromEnvSrc:Ne(),readProcessKey:Te(),readFileKey:Ee(),readFileKeySync:Ae(),guessPrivateKeyFilename:Pe(),dotenvPrivateKeyNames:Fe()}})),Le=s(((e,t)=>{let n=A(),r=c(`path`),i=`envFile`,a=ye(),o=v(),s=be(),l=xe(),{keyNames:u,keyValues:d,keyValuesSync:f,keyValuesFromEnvSrc:p}=Ie();t.exports=class{constructor(e=[],t=!1,n=process.env,r=null,i=!1,a={}){this.envs=e,this.overload=t,this.processEnv=n,this.envKeysFilepath=r,this.noOps=i,this.noSpinner=a.noSpinner,this.beforeOpsKeypair=a.beforeOpsKeypair,this.afterOpsKeypair=a.afterOpsKeypair,this.processedEnvs=[],this.readableFilepaths=new Set,this.readableStrings=new Set,this.uniqueInjectedKeys=new Set,this.beforeEnv={...this.processEnv}}runSync(){for(let e of this.envs)e.type===i?this._injectEnvFileSync(e.value):e.type===`env`&&this._injectEnv(e.value,e.privateKeyName);return{processedEnvs:this.processedEnvs,readableStrings:[...this.readableStrings],readableFilepaths:[...this.readableFilepaths],uniqueInjectedKeys:[...this.uniqueInjectedKeys],beforeEnv:this.beforeEnv,afterEnv:{...this.processEnv}}}async run(){for(let e of this.envs)e.type===i?await this._injectEnvFile(e.value):e.type===`env`&&this._injectEnv(e.value,e.privateKeyName);return{processedEnvs:this.processedEnvs,readableStrings:[...this.readableStrings],readableFilepaths:[...this.readableFilepaths],uniqueInjectedKeys:[...this.uniqueInjectedKeys],beforeEnv:this.beforeEnv,afterEnv:{...this.processEnv}}}_injectEnv(e,t=null){let n={};n.type=`env`,n.string=e;try{let{privateKeyName:r,privateKeyValue:i}=p(e,t,{keysFilepath:this.envKeysFilepath,noOps:this.noOps,processEnv:this.processEnv}),{parsed:o,errors:s,injected:c,preExisted:l}=new a(e,i,this.processEnv,this.overload,r).run();n.privateKeyName=r,n.privateKey=i,n.parsed=o,n.errors=s,n.injected=c,n.preExisted=l,this.inject(n.parsed),this.readableStrings.add(e);for(let e of Object.keys(c))this.uniqueInjectedKeys.add(e)}catch(e){n.errors=[e]}this.processedEnvs.push(n)}_injectEnvFileSync(e){let t={};t.type=i,t.filepath=e;let s=r.resolve(e);try{let r=l(s),i=n.readFileXSync(s,{encoding:r});this.readableFilepaths.add(e);let{privateKeyName:o}=u(s),{privateKeyValue:c}=f(s,{keysFilepath:this.envKeysFilepath,noOps:this.noOps,noSpinner:this.noSpinner}),{parsed:d,errors:p,injected:m,preExisted:h}=new a(i,c,this.processEnv,this.overload,o).run();t.privateKeyName=o,t.privateKey=c,t.src=i,t.parsed=d,t.errors=p,t.injected=m,t.preExisted=h,this.inject(t.parsed);for(let e of Object.keys(m))this.uniqueInjectedKeys.add(e)}catch(n){n.code===`ENOENT`||n.code===`EISDIR`?t.errors=[new o({envFilepath:e,filepath:s}).missingEnvFile()]:t.errors=[n]}this.processedEnvs.push(t)}async _injectEnvFile(e){let t={};t.type=i,t.filepath=e;let c=r.resolve(e);try{let r=await s(c),i=await n.readFileX(c,{encoding:r});this.readableFilepaths.add(e);let{privateKeyName:o}=u(c),{privateKeyValue:l}=await d(c,{keysFilepath:this.envKeysFilepath,noOps:this.noOps,beforeOpsKeypair:this.beforeOpsKeypair,afterOpsKeypair:this.afterOpsKeypair}),{parsed:f,errors:p,injected:m,preExisted:h}=new a(i,l,this.processEnv,this.overload,o).run();t.privateKeyName=o,t.privateKey=l,t.src=i,t.parsed=f,t.errors=p,t.injected=m,t.preExisted=h,this.inject(t.parsed);for(let e of Object.keys(m))this.uniqueInjectedKeys.add(e)}catch(n){n.code===`ENOENT`||n.code===`EISDIR`?t.errors=[new o({envFilepath:e,filepath:c}).missingEnvFile()]:t.errors=[n]}this.processedEnvs.push(t)}inject(e){for(let t of Object.keys(e))this.processEnv[t]=e[t]}}})),Re=s(((e,t)=>{let n=v();function r(e){let t=process.env.DOTENV_ENV||process.env.NODE_ENV||`development`;if(e===`nextjs`){let e=[`development`,`test`,`production`].includes(t)&&t;return[e&&{type:`envFile`,value:`.env.${e}.local`},e!==`test`&&{type:`envFile`,value:`.env.local`},e&&{type:`envFile`,value:`.env.${e}`},{type:`envFile`,value:`.env`}].filter(Boolean)}else if(e===`flow`)return[{type:`envFile`,value:`.env.${t}.local`},{type:`envFile`,value:`.env.${t}`},{type:`envFile`,value:`.env.local`},{type:`envFile`,value:`.env`},{type:`envFile`,value:`.env.defaults`}];else throw new n({convention:e}).invalidConvention()}t.exports=r})),ze=s(((e,t)=>{let n=c(`os`),r=c(`path`);function i(e){return e[0]===`~`?r.join(n.homedir(),e.slice(1)):e}t.exports=i})),Be=s(((e,t)=>{let n=ze();function r(e){let t=[];if(e&&e.path)if(!Array.isArray(e.path))t=[n(e.path)];else{t=[];for(let r of e.path)t.push(n(r))}return t}t.exports=r})),Ve=s(((e,t)=>{let n=Re(),r=Be();function i(e){if(e.envs)return e.envs;let t=r(e),i=[];e.convention&&(i=n(e.convention).concat(i));for(let e of t)i.push({type:`envFile`,value:e});return i}t.exports=i})),He=s(((e,t)=>{let n=Fe(),r=Pe(),i=`envFile`,a=[{type:i,value:`.env`}];function o(e){let t=[];for(let n of e){let e=r(n);t.push({type:i,value:e})}return t}function s(e=[],t){let r=n(t);if(!e||e.length<=0)return r.length>0?o(r):a;{let t=!1;for(let n of e)n.type===i&&(t=!0);return t?e:[...a,...e]}}t.exports=s})),Ue=s(((e,t)=>{let n=A(),r=v(),i=[`.env.project`,`.env.keys`,`.env.me`,`.env.x`,`.env.example`];function a(e){try{return n.readdirSync(e).filter(e=>e.startsWith(`.env`)&&!e.endsWith(`.previous`)&&!i.includes(e))}catch(t){throw t.code===`ENOENT`?new r({directory:e}).missingDirectory():t}}t.exports=a})),We=s(((e,t)=>{t.exports={buildEnvs:Ve(),determine:He(),findEnvFiles:Ue(),dotenvOptionPaths:Be(),environment:Ce(),conventions:Re()}})),Ge=s(((e,t)=>{let{PrivateKey:n}=pe();function r(e){let t;return t=e?new n(Buffer.from(e,`hex`)):new n,{publicKey:t.publicKey.toHex(),privateKey:t.secret.toString(`hex`)}}t.exports=r})),Ke=s(((e,t)=>{let{encrypt:n}=pe();function r(e,t){let r=n(t,Buffer.from(e));return`encrypted:${Buffer.from(r,`hex`).toString(`base64`)}`}t.exports=r})),qe=s(((e,t)=>{let n=/^DOTENV_PUBLIC_KEY/;function r(e){return n.test(e)}t.exports=r})),Je=s(((e,t)=>{let n=[`#/------------------!DOTENV_PRIVATE_KEYS!-------------------/`,`#/ private decryption keys. DO NOT commit to source control /`,`#/ [how it works](https://dotenvx.com/encryption) /`,`#/----------------------------------------------------------/`].join(`
|
|
29
|
+
`),r=c(`path`),i=A();async function a({envFilepath:e,keysFilepath:t,privateKeyName:a,privateKeyValue:o}){let s=r.basename(e),c=r.resolve(e),l=r.join(r.dirname(c),`.env.keys`);t&&(l=r.resolve(t));let u=[`# ${s}`,`${a}=${o}`,``].join(`
|
|
30
|
+
`),d=``;await i.exists(l)&&(d=await i.readFileX(l)),d=d.length>1?d:`${n}\n`,d=`${d}\n${u}`,await i.writeFileX(l,d);let f=t||r.join(r.dirname(e),r.basename(l));return{keysSrc:d,envKeysFilepath:f}}t.exports=a})),Ye=s(((e,t)=>{let n=[`#/------------------!DOTENV_PRIVATE_KEYS!-------------------/`,`#/ private decryption keys. DO NOT commit to source control /`,`#/ [how it works](https://dotenvx.com/encryption) /`,`#/----------------------------------------------------------/`].join(`
|
|
31
|
+
`),r=c(`path`),i=A();function a({envFilepath:e,keysFilepath:t,privateKeyName:a,privateKeyValue:o}){let s=r.basename(e),c=r.resolve(e),l=r.join(r.dirname(c),`.env.keys`);t&&(l=r.resolve(t));let u=[`# ${s}`,`${a}=${o}`,``].join(`
|
|
32
|
+
`),d=``;i.existsSync(l)&&(d=i.readFileXSync(l)),d=d.length>1?d:`${n}\n`,d=`${d}\n${u}`,i.writeFileXSync(l,d);let f=t||r.join(r.dirname(e),r.basename(l));return{keysSrc:d,envKeysFilepath:f}}t.exports=a})),Xe=s(((e,t)=>{function n(e){let[t,...n]=e.split(`
|
|
33
|
+
`),r=``;return t.startsWith(`#!`)&&(r=t+`
|
|
34
|
+
`,e=n.join(`
|
|
35
|
+
`)),{firstLinePreserved:r,envSrc:e}}t.exports=n})),Ze=s(((e,t)=>{function n(e,t,n,r=`.env.keys`){return[`#/-------------------[DOTENV_PUBLIC_KEY]--------------------/`,`#/ public-key encryption for .env files /`,`#/ [how it works](https://dotenvx.com/encryption) /`,`#/----------------------------------------------------------/`,`${e}="${t}"${r===`.env.keys`?``:` # -fk ${r}`}`,``,`# ${n}`].join(`
|
|
36
|
+
`)}t.exports=n})),Qe=s(((e,t)=>{let n=c(`path`),r=Xe(),i=Ze();function a({envSrc:e,envFilepath:t,keysFilepath:a,publicKeyName:o,publicKeyValue:s}){let c=n.basename(t),l=n.resolve(t),u=n.join(n.dirname(l),`.env.keys`);a&&(u=n.resolve(a));let d=n.relative(n.dirname(l),u),f=r(e),p=i(o,s,c,d);return e=`${f.firstLinePreserved}${p}\n${f.envSrc}`,{envSrc:e}}t.exports=a})),$e=s(((e,t)=>{let n=Qe(),r=Je(),i=Oe(),a=Ge(),{keyNames:o}=Ie();async function s({envSrc:e,envFilepath:t,keysFilepath:s,noOps:c}){c=c!==!1;let{publicKeyName:l,privateKeyName:u}=o(t),d,f,p,m,h=!1,g=!1;if(c){let e=a();d=e.publicKey,f=e.privateKey}else{let e=await i();d=e.publicKey,f=e.privateKey}if(e=n({envSrc:e,envFilepath:t,keysFilepath:s,publicKeyName:l,publicKeyValue:d}).envSrc,c){let e=await r({envFilepath:t,keysFilepath:s,privateKeyName:u,privateKeyValue:f});p=e.keysSrc,m=e.envKeysFilepath,h=!0}else g=!0;return{envSrc:e,keysSrc:p,publicKey:d,privateKey:f,envKeysFilepath:m,localPrivateKeyAdded:h,remotePrivateKeyAdded:g}}t.exports=s})),et=s(((e,t)=>{let n=Qe(),r=Ye(),i=je(),a=Ge(),{keyNames:o}=Ie();function s({envSrc:e,envFilepath:t,keysFilepath:s,noOps:c}){c=c!==!1;let{publicKeyName:l,privateKeyName:u}=o(t),d,f,p,m,h=!1,g=!1;if(c){let e=a();d=e.publicKey,f=e.privateKey}else{let e=i();d=e.publicKey,f=e.privateKey}if(e=n({envSrc:e,envFilepath:t,keysFilepath:s,publicKeyName:l,publicKeyValue:d}).envSrc,c){let e=r({envFilepath:t,keysFilepath:s,privateKeyName:u,privateKeyValue:f});p=e.keysSrc,m=e.envKeysFilepath,h=!0}else g=!0;return{envSrc:e,keysSrc:p,publicKey:d,privateKey:f,envKeysFilepath:m,localPrivateKeyAdded:h,remotePrivateKeyAdded:g}}t.exports=s})),tt=s(((e,t)=>{let n=v(),r=Qe(),i=Ge();function a({envSrc:e,envFilepath:t,keysFilepath:a,privateKeyValue:o,publicKeyValue:s,publicKeyName:c}){let{publicKey:l,privateKey:u}=i(o);if(s&&s!==l)throw new n({publicKey:l,publicKeyExisting:s}).mispairedPrivateKey();return s||(e=r({envSrc:e,envFilepath:t,keysFilepath:a,publicKeyName:c,publicKeyValue:l}).envSrc),{envSrc:e,publicKey:l,privateKey:u}}t.exports=a})),nt=s(((e,t)=>{let n=$(),r=he(),i=qe();function a(e){let t=n(e,!1,!1,!0);for(let[e,n]of Object.entries(t))for(let t of n)if(!(r(t)||i(e)))return!1;return!0}t.exports=a})),rt=s(((e,t)=>{t.exports={opsKeypair:Oe(),opsKeypairSync:je(),localKeypair:Ge(),encryptValue:Ke(),decryptKeyValue:me(),isEncrypted:he(),isPublicKey:qe(),mutateKeysSrc:Je(),mutateKeysSrcSync:Ye(),provision:$e(),provisionSync:et(),provisionWithPrivateKey:tt(),mutateSrc:Qe(),isFullyEncrypted:nt()}})),it=s(((e,t)=>{function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}t.exports=n})),at=s(((e,t)=>{let n=$(),r=it();function i(e,t,n,i){let a=r(t),o=r(n),s=``;o===``&&(s=`$`);let c=RegExp(`^(\\s*)?(export\\s+)?`+a+`\\s*=\\s*(["'\`]?)`+o+`\\3`+s,`gm`);return e.replace(c,function(n,r=``,s=``,c=``){let l=`${t}=${c}${i}${c}`,u=e.match(RegExp(`${a}\\s*=\\s*\n\n`,`m`));if(o===``&&c===``&&u){let e=u[0].match(/\n/g).length-1;for(let t=0;t<e;t++)l+=`
|
|
37
|
+
`}return`${r}${s}${l}`})}function a(e,t,r){let a,o=``,s=n(e,!0,!0,!0);if(Object.prototype.hasOwnProperty.call(s,t)){let n=s[t],a=e,o=Array.isArray(r)?r:n.map(()=>r),c=new Map;n.forEach((e,t)=>{c.has(e)||c.set(e,o[t])});for(let[e,n]of c)a=i(a,t,e,n);return a}else o+=`${t}="${r}"`,e.endsWith(`
|
|
38
|
+
`)?o+=`
|
|
39
|
+
`:o=`
|
|
40
|
+
`+o,a=e+o;return a}t.exports=a})),ot=s(((e,t)=>{let n=A(),r=c(`path`),i=`envFile`,a=v(),{determine:o}=We(),{keyNames:s,keyValues:l,keyValuesSync:u}=Ie(),{encryptValue:d,decryptKeyValue:f,isEncrypted:p,provision:m,provisionSync:h,provisionWithPrivateKey:g}=rt(),_=at(),y=$(),b=be(),x=xe();function S(e,t){return y(e,!1,!1,!0)[t]||[]}t.exports=class{constructor(e,t,n=[],r=!0,i=null,a=!1,s=!1){this.envs=o(n,process.env),this.key=e,this.value=t,this.encrypt=r,this.envKeysFilepath=i,this.noOps=a,this.noCreate=s,this.processedEnvs=[],this.changedFilepaths=new Set,this.unchangedFilepaths=new Set,this.readableFilepaths=new Set}runSync(){for(let e of this.envs)e.type===i&&this._setEnvFileSync(e.value);return{processedEnvs:this.processedEnvs,changedFilepaths:[...this.changedFilepaths],unchangedFilepaths:[...this.unchangedFilepaths]}}async run(){for(let e of this.envs)e.type===i&&await this._setEnvFile(e.value);return{processedEnvs:this.processedEnvs,changedFilepaths:[...this.changedFilepaths],unchangedFilepaths:[...this.unchangedFilepaths]}}_setEnvFileSync(e){let t={};t.key=this.key||null,t.value=this.value||null,t.type=i;let o=r.resolve(e);t.filepath=o,t.envFilepath=e,t.changed=!1;try{let r=!1;n.existsSync(o)||(this.noCreate?x(o):n.writeFileXSync(o,``));let i=x(o),c=n.readFileXSync(o,{encoding:i});t.key&&c.trim().length===0&&(c=`${t.key}="${this.value}"\n`,r=!0),t.originalValue=y(c)[t.key]||null,r&&(t.originalValue=null);let l=!p(t.originalValue);if(this.readableFilepaths.add(e),this.encrypt){let n,r,{publicKeyName:i,privateKeyName:l}=s(o),{publicKeyValue:p,privateKeyValue:m}=u(o,{keysFilepath:this.envKeysFilepath,noOps:this.noOps});if(!m&&!p){let i=h({envSrc:c,envFilepath:e,keysFilepath:this.envKeysFilepath,noOps:this.noOps});c=i.envSrc,n=i.publicKey,r=i.privateKey,t.envKeysFilepath=i.envKeysFilepath,t.localPrivateKeyAdded=i.localPrivateKeyAdded,t.remotePrivateKeyAdded=i.remotePrivateKeyAdded}else if(m){let a=g({envSrc:c,envFilepath:e,keysFilepath:this.envKeysFilepath,privateKeyValue:m,publicKeyValue:p,publicKeyName:i});n=a.publicKey,r=a.privateKey,c=a.envSrc,t.originalValue&&=f(t.key,t.originalValue,l,r)}else p&&(n=p);t.publicKey=n,t.privateKey=r;try{t.encryptedValue=d(this.value,n)}catch{throw new a({publicKeyName:i,publicKey:n}).invalidPublicKey()}t.privateKeyName=l}let m=l&&this.encrypt,v=this.value!==t.originalValue,b=S(c,t.key).length>1;r&&!this.encrypt?(t.envSrc=c,this.changedFilepaths.add(e),t.changed=!0):m||v||b?(t.envSrc=_(c,this.key,t.encryptedValue||this.value),this.changedFilepaths.add(e),t.changed=!0):(t.envSrc=c,this.unchangedFilepaths.add(e),t.changed=!1)}catch(n){n.code===`ENOENT`?t.error=new a({envFilepath:e,filepath:o}).missingEnvFile():t.error=n}this.processedEnvs.push(t)}async _setEnvFile(e){let t={};t.key=this.key||null,t.value=this.value||null,t.type=i;let o=r.resolve(e);t.filepath=o,t.envFilepath=e,t.changed=!1;try{let r=!1;await n.exists(o)||(this.noCreate?await b(o):await n.writeFileX(o,``));let i=await b(o),c=await n.readFileX(o,{encoding:i});t.key&&c.trim().length===0&&(c=`${t.key}="${this.value}"\n`,r=!0),t.originalValue=y(c)[t.key]||null,r&&(t.originalValue=null);let u=!p(t.originalValue);if(this.readableFilepaths.add(e),this.encrypt){let n,r,{publicKeyName:i,privateKeyName:u}=s(o),{publicKeyValue:p,privateKeyValue:h}=await l(o,{keysFilepath:this.envKeysFilepath,noOps:this.noOps});if(!h&&!p){let i=await m({envSrc:c,envFilepath:e,keysFilepath:this.envKeysFilepath,noOps:this.noOps});c=i.envSrc,n=i.publicKey,r=i.privateKey,t.envKeysFilepath=i.envKeysFilepath,t.localPrivateKeyAdded=i.localPrivateKeyAdded,t.remotePrivateKeyAdded=i.remotePrivateKeyAdded}else if(h){let a=g({envSrc:c,envFilepath:e,keysFilepath:this.envKeysFilepath,privateKeyValue:h,publicKeyValue:p,publicKeyName:i});n=a.publicKey,r=a.privateKey,c=a.envSrc,t.originalValue&&=f(t.key,t.originalValue,u,r)}else p&&(n=p);t.publicKey=n,t.privateKey=r;try{t.encryptedValue=d(this.value,n)}catch{throw new a({publicKeyName:i,publicKey:n}).invalidPublicKey()}t.privateKeyName=u}let h=u&&this.encrypt,v=this.value!==t.originalValue,x=S(c,t.key).length>1;r&&!this.encrypt?(t.envSrc=c,this.changedFilepaths.add(e),t.changed=!0):h||v||x?(t.envSrc=_(c,this.key,t.encryptedValue||this.value),this.changedFilepaths.add(e),t.changed=!0):(t.envSrc=c,this.unchangedFilepaths.add(e),t.changed=!1)}catch(n){n.code===`ENOENT`?t.error=new a({envFilepath:e,filepath:o}).missingEnvFile():t.error=n}this.processedEnvs.push(t)}}})),st=s(((e,t)=>{let n=Le(),r=v(),{determine:i}=We();t.exports=class{constructor(e,t=[],n=!1,r=!1,i=null,a=!1){this.key=e,this.envs=t,this.overload=n,this.all=r,this.envKeysFilepath=i,this.noOps=a}runSync(){let e={...process.env},{processedEnvs:t}=new n(i(this.envs,e),this.overload,e,this.envKeysFilepath,this.noOps).runSync();return this._result(t,e)}async run(){let e={...process.env},{processedEnvs:t}=await new n(i(this.envs,e),this.overload,e,this.envKeysFilepath,this.noOps).run();return this._result(t,e)}_result(e,t){let n=[];for(let t of e)for(let e of t.errors)n.push(e);if(this.key){let e={},i=t[this.key];return e[this.key]=i,i===void 0&&n.push(new r({key:this.key}).missingKey()),{parsed:e,errors:n}}if(this.all)return{parsed:t,errors:n};let i={};for(let n of e)if(n.parsed)for(let e of Object.keys(n.parsed))i[e]=t[e];return{parsed:i,errors:n}}}})),ct=s(((e,t)=>{let{keyNames:n,keyValues:r,keyValuesSync:i}=Ie();t.exports=class{constructor(e=`.env`,t=null,n=!1){this.envFile=e,this.envKeysFilepath=t,this.noOps=n}runSync(){let e={},t=this._filepaths();for(let r of t){let{publicKeyName:t,privateKeyName:a}=n(r),{publicKeyValue:o,privateKeyValue:s}=i(r,{keysFilepath:this.envKeysFilepath,noOps:this.noOps});e[t]=o,e[a]=s}return e}async run(){let e={},t=this._filepaths();for(let i of t){let{publicKeyName:t,privateKeyName:a}=n(i),{publicKeyValue:o,privateKeyValue:s}=await r(i,{keysFilepath:this.envKeysFilepath,noOps:this.noOps});e[t]=o,e[a]=s}return e}_filepaths(){return Array.isArray(this.envFile)?this.envFile:[this.envFile]}}})),lt=s(((e,t)=>{let n=A(),r=c(`path`),i=v(),a=Ue(),o=at(),s=$();t.exports=class{constructor(e=`.`,t){this.directory=e,this.envFile=t||a(e),this.exampleFilename=`.env.example`,this.exampleFilepath=r.resolve(this.directory,this.exampleFilename)}run(){if(this.envFile.length<1)throw new i().missingEnvFiles();let e=new Set,t=new Set,a=this._envFilepaths(),c={},l={},u=`# ${this.exampleFilename} - generated with dotenvx\n`;for(let t of a){let a=r.resolve(this.directory,t);if(!n.existsSync(a)){let e=new i({envFilepath:t,filepath:a}).missingEnvFile();throw e.help=`? add it with [echo "HELLO=World" > ${t}] and then run [dotenvx genexample]`,e}let c=n.readFileXSync(a),l=s(c);for(let t in l)e.add(t),c=o(c,t,``);u+=`\n${c}`}if(n.existsSync(this.exampleFilepath)){u=n.readFileXSync(this.exampleFilepath);let r=s(u);for(let n of[...e])n in r?l[n]=r[n]:(u+=`${n}=''\n`,t.add(n),c[n]=``)}else for(let n of[...e])t.add(n),c[n]=``;return{envExampleFile:u,envFile:this.envFile,exampleFilepath:this.exampleFilepath,addedKeys:[...t],injected:c,preExisted:l}}_envFilepaths(){return Array.isArray(this.envFile)?this.envFile:[this.envFile]}}})),ut=s(((e,t)=>{let n=De(),{logger:r}=x();t.exports=class{constructor(){this.ops=new n}async noOps(){let e=await this.ops.status();return r.debug(`ops: ${e}`),e===`off`}noOpsSync(){let e=this.ops.statusSync();return r.debug(`ops: ${e}`),e===`off`}}})),dt=s(((e,t)=>{let n=c(`path`);function r(e){return e?n.isAbsolute(e)?n.relative(process.cwd(),e)||n.basename(e):e:`.env.keys`}t.exports=r}));s(((e,t)=>{let n=c(`path`),{setLogLevel:r,setLogName:i,setLogVersion:a,logger:o}=x(),{getColor:s,bold:l}=b(),u=k(),d=j(),f=Le(),p=ot(),m=st(),h=ct(),g=lt(),_=ut(),v=Ve(),{determine:y}=We(),S=ye(),C=A(),w=dt(),T=function(e={}){let t=process.env;e&&e.processEnv!=null&&(t=e.processEnv);let s=e.overload||e.override,c=e.ignore||[],l=e.strict,u=e.envKeysFile;e&&(r(e),i(e),a(e));let d=I(e);try{let r=v(e);e.envs||(r=y(r,t));let{processedEnvs:i,readableFilepaths:a,uniqueInjectedKeys:p}=new f(r,s,t,u,d,{noSpinner:e.noSpinner}).runSync(),m,h={};for(let t of i){t.type===`envFile`&&o.verbose(`loading env from ${t.filepath} (${n.resolve(t.filepath)})`);for(let n of t.errors||[]){if(c.includes(n.code)){o.verbose(`ignored: ${n.message}`);continue}if(l)throw n;m=n,n.code===`MISSING_ENV_FILE`&&e.convention||o.error(n.messageWithHelp)}Object.assign(h,t.injected||{}),Object.assign(h,t.preExisted||{}),o.debug(t.parsed);for(let[e,n]of Object.entries(t.injected||{}))o.verbose(`${e} set`),o.debug(`${e} set to ${n}`);for(let[e,n]of Object.entries(t.preExisted||{}))o.verbose(`${e} pre-exists (protip: use --overload to override)`),o.debug(`${e} pre-exists as ${n} (protip: use --overload to override)`)}let g=`injected env (${p.length})`;return a.length>0&&(g+=` from ${a.join(`, `)}`),o.successv(g),m?{parsed:h,error:m}:{parsed:h}}catch(e){if(l)throw e;return o.error(e.messageWithHelp),{parsed:{},error:e}}},E=function(e,t={}){let n=process.env;t&&t.processEnv!=null&&(n=t.processEnv);let r=t.privateKey||null,i=t.overload||t.override,{parsed:a,errors:s}=new S(e,r,n,i).run();for(let e of s)o.error(e.messageWithHelp);return a},D=function(e,t,n={}){let s=!0;(n.plain||n.encrypt===!1)&&(s=!1),n&&(r(n),i(n),a(n));let c=v(n),l=n.envKeysFile,u=I(n),{processedEnvs:d,changedFilepaths:f,unchangedFilepaths:m}=new p(e,t,c,s,l,u).runSync(),h=``;s&&(h=` with encryption`);for(let e of d)if(o.verbose(`setting for ${e.envFilepath}`),e.error){let t=e.error,n=t.messageWithHelp||(t.help?`${t.message}. ${t.help}`:t.message);o.warn(n)}else C.writeFileXSync(e.filepath,e.envSrc),o.verbose(`${e.key} set${h} (${e.envFilepath})`),o.debug(`${e.key} set${h} to ${e.value} (${e.envFilepath})`);let g=``,_=d.find(e=>e.localPrivateKeyAdded),y=d.find(e=>e.remotePrivateKeyAdded);if(_&&(g=` + local key (${w(_.envKeysFilepath)})`),y&&(g=` + armored key ⛨`),f.length>0)s?o.success(`◈ encrypted ${e} (${f.join(`,`)})${g}`):o.success(`◇ set ${e} (${f.join(`,`)})`);else if(s&&_){let t=_.envFilepath||f[0]||`.env`;o.success(`◈ encrypted ${e} (${t})${g}`)}else m.length>0&&o.info(`○ no change (${m})`);return{processedEnvs:d,changedFilepaths:f,unchangedFilepaths:m}},O=function(e,t={}){let n=v(t),r=I(t),i=t.ignore||[],{parsed:a,errors:s}=new m(e,n,t.overload,t.all,t.envKeysFile,r).runSync();for(let e of s||[])if(!i.includes(e.code)){if(t.strict)throw e;o.error(e.messageWithHelp)}if(e){let t=a[e];return t===void 0?void 0:t}else if(t.format===`eval`){let e=``;for(let[t,n]of Object.entries(a))e+=`${t}=${escape(n)}\n`;return e=e.trim(),e}else if(t.format===`shell`){let e=``;for(let[t,n]of Object.entries(a))e+=`${t}=${n} `;return e=e.trim(),e}else if(t.format===`colon`){let e=``;for(let[t,n]of Object.entries(a))e+=`${t}:${n} `;return e=e.trim(),e}else return a},M=function(e,t,n){return new u(e,t,n).run()},N=function(e){return new d(e).run()},P=function(e,t){return new g(e,t).run()},F=function(e,t,n=null,r=!1){let i=new h(e,n,r).runSync();return t?i[t]:i};function I(e={}){let t=new _;return e.noOps===!0||e.opsOff===!0||t.noOpsSync()}t.exports={config:T,parse:E,set:D,get:O,ls:M,doctor:N,keypair:F,genexample:P,setLogLevel:r,logger:o,getColor:s,bold:l}}))().config();const ft={ALGOLIA_APP_ID:`ALGOLIA_APP_ID`,ALGOLIA_ADMIN_API_KEY:`ALGOLIA_ADMIN_API_KEY`,ALGOLIA_INDEX_NAME:`ALGOLIA_INDEX_NAME`,DATA_DIR:`DATA_DIR`};var pt=class e{constructor(){this.envVars={},Object.values(ft).forEach(e=>{let t=process.env[e];if(t==null)throw Error(`Missing required environment variable: ${e}`);this.envVars[e]=t})}static getInstance(){return e.instance||=new e,e.instance}getConfig(e){return this.envVars[e]}},mt=class e{constructor(e,t){this.client=t(e.getConfig(`ALGOLIA_APP_ID`),e.getConfig(`ALGOLIA_ADMIN_API_KEY`)),this.indexName=e.getConfig(`ALGOLIA_INDEX_NAME`)}static getInstance(){if(!this.instance){let t=pt.getInstance();this.instance=new e(t,a)}return this.instance}getClient(){return this.client}getIndexName(){return this.indexName}};function ht(e){return t.readdirSync(e).filter(e=>e.endsWith(`.json`)).map(r=>{let i=t.readFileSync(n.join(e,r),`utf8`);return JSON.parse(i)})}var gt=class{constructor(e){this.client=e.getClient(),this.indexName=e.getIndexName()}async uploadObjects(e){if(e.length===0){console.error(`No items are included in the target JSON file. More than 1 item is necessary.`);return}let t=await this.getAllObjects();t=m(t);let n=m(e),r=this.determineOperations(t,n);if(r.update.length===0&&r.add.length===0&&r.delete.length===0){console.log(`No updates needed. All objects are up to date.`);return}if(r.update.length>0){let e=await this.client.partialUpdateObjects({indexName:this.indexName,objects:r.update,createIfNotExists:!0});console.log(`Updated ${e[0].objectIDs.length} objects`)}if(r.add.length>0){let e=await this.client.saveObjects({indexName:this.indexName,objects:r.add});console.log(`Added ${e[0].objectIDs.length} objects`)}if(r.delete.length>0){let e=r.delete.map(e=>e.objectID),t=await this.client.deleteObjects({indexName:this.indexName,objectIDs:e});console.log(`Deleted ${t[0].objectIDs.length} objects`)}}async getAllObjects(){let e=[];return await this.client.browseObjects({indexName:this.indexName,aggregator:t=>{Array.isArray(t.hits)&&t.hits.forEach(t=>{f(t)&&e.push(t)})}}),e}determineOperations(e,t){let n=new Map(e.map(e=>[e.objectID,e])),r=new Map(t.map(e=>[e.objectID,e])),i={update:[],add:[],delete:[]};for(let e of t){let t=n.get(e.objectID);t==null?i.add.push(e):o(t,e)||i.update.push(e)}for(let t of e)r.has(t.objectID)||i.delete.push(t);return i}};i(r({meta:{name:l,version:u,description:d},args:{},async run(){try{let e=pt.getInstance().getConfig(`DATA_DIR`);e=n.join(process.cwd(),e),t.existsSync(e)&&t.statSync(e).isDirectory()||(console.error(`Error: provided directory does not exist - ${e}`),process.exit(1));let r=ht(e);r.length===0&&(console.error(`Error: no .json files found in directory - ${e}`),process.exit(1));let i=r[0];Array.isArray(i)||(console.error(`The content of the provided json file is incompatible. Check the file: ${e}`),process.exit(1)),i.every(e=>f(e))||(console.error(`The content of the provided json file is incompatible. Check the file: ${e}`),process.exit(1)),await new gt(mt.getInstance()).uploadObjects(i)}catch(e){console.error(`Some errors occured: `,e),process.exit(1)}}}));export{};
|