@stacksjs/dnsx
Version:
A command-line & library DNS client. Like dig & dog, but for TypeScript.
2 lines (1 loc) • 6.88 kB
JavaScript
import{b as he,c as de,d as pe,e as ge,f as me,g as ve,h as be,i as Ae,j as ye,k as xe,l as we,m as Ce,n as je,o as Oe,p as ke,r as Pe}from"../chunk-e3sexww2.js";var{create:N,defineProperty:O,getOwnPropertyDescriptor:z,getOwnPropertyNames:_,getPrototypeOf:I}=Object,L=Object.prototype.hasOwnProperty,R=(c,f)=>()=>(f||c((f={exports:{}}).exports,f),f.exports),V=(c,f,l,p)=>{if(f&&typeof f=="object"||typeof f=="function")for(let g of _(f))!L.call(c,g)&&g!==l&&O(c,g,{get:()=>f[g],enumerable:!(p=z(f,g))||p.enumerable});return c},$=(c,f,l)=>(l=c!=null?N(I(c)):{},V(f||!c||!c.__esModule?O(l,"default",{value:c,enumerable:!0}):l,c)),B=R((c,f)=>{function l(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function p(e,r){for(var t="",a=0,i=-1,n=0,s,o=0;o<=e.length;++o){if(o<e.length)s=e.charCodeAt(o);else{if(s===47)break;s=47}if(s===47){if(!(i===o-1||n===1))if(i!==o-1&&n===2){if(t.length<2||a!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var m=t.lastIndexOf("/");if(m!==t.length-1){m===-1?(t="",a=0):(t=t.slice(0,m),a=t.length-1-t.lastIndexOf("/")),i=o,n=0;continue}}else if(t.length===2||t.length===1){t="",a=0,i=o,n=0;continue}}r&&(t.length>0?t+="/..":t="..",a=2)}else t.length>0?t+="/"+e.slice(i+1,o):t=e.slice(i+1,o),a=o-i-1;i=o,n=0}else s===46&&n!==-1?++n:n=-1}return t}function g(e,r){var t=r.dir||r.root,a=r.base||(r.name||"")+(r.ext||"");return t?t===r.root?t+a:t+e+a:a}var d={resolve:function(){for(var e="",r=!1,t,a=arguments.length-1;a>=-1&&!r;a--){var i;a>=0?i=arguments[a]:(t===void 0&&(t=process.cwd()),i=t),l(i),i.length!==0&&(e=i+"/"+e,r=i.charCodeAt(0)===47)}return e=p(e,!r),r?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(l(e),e.length===0)return".";var r=e.charCodeAt(0)===47,t=e.charCodeAt(e.length-1)===47;return e=p(e,!r),e.length===0&&!r&&(e="."),e.length>0&&t&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return l(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,r=0;r<arguments.length;++r){var t=arguments[r];l(t),t.length>0&&(e===void 0?e=t:e+="/"+t)}return e===void 0?".":d.normalize(e)},relative:function(e,r){if(l(e),l(r),e===r||(e=d.resolve(e),r=d.resolve(r),e===r))return"";for(var t=1;t<e.length&&e.charCodeAt(t)===47;++t);for(var a=e.length,i=a-t,n=1;n<r.length&&r.charCodeAt(n)===47;++n);for(var s=r.length,o=s-n,m=i<o?i:o,v=-1,u=0;u<=m;++u){if(u===m){if(o>m){if(r.charCodeAt(n+u)===47)return r.slice(n+u+1);if(u===0)return r.slice(n+u)}else i>m&&(e.charCodeAt(t+u)===47?v=u:u===0&&(v=0));break}var w=e.charCodeAt(t+u),E=r.charCodeAt(n+u);if(w!==E)break;w===47&&(v=u)}var y="";for(u=t+v+1;u<=a;++u)(u===a||e.charCodeAt(u)===47)&&(y.length===0?y+="..":y+="/..");return y.length>0?y+r.slice(n+v):(n+=v,r.charCodeAt(n)===47&&++n,r.slice(n))},_makeLong:function(e){return e},dirname:function(e){if(l(e),e.length===0)return".";for(var r=e.charCodeAt(0),t=r===47,a=-1,i=!0,n=e.length-1;n>=1;--n)if(r=e.charCodeAt(n),r===47){if(!i){a=n;break}}else i=!1;return a===-1?t?"/":".":t&&a===1?"//":e.slice(0,a)},basename:function(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');l(e);var t=0,a=-1,i=!0,n;if(r!==void 0&&r.length>0&&r.length<=e.length){if(r.length===e.length&&r===e)return"";var s=r.length-1,o=-1;for(n=e.length-1;n>=0;--n){var m=e.charCodeAt(n);if(m===47){if(!i){t=n+1;break}}else o===-1&&(i=!1,o=n+1),s>=0&&(m===r.charCodeAt(s)?--s===-1&&(a=n):(s=-1,a=o))}return t===a?a=o:a===-1&&(a=e.length),e.slice(t,a)}else{for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===47){if(!i){t=n+1;break}}else a===-1&&(i=!1,a=n+1);return a===-1?"":e.slice(t,a)}},extname:function(e){l(e);for(var r=-1,t=0,a=-1,i=!0,n=0,s=e.length-1;s>=0;--s){var o=e.charCodeAt(s);if(o===47){if(!i){t=s+1;break}continue}a===-1&&(i=!1,a=s+1),o===46?r===-1?r=s:n!==1&&(n=1):r!==-1&&(n=-1)}return r===-1||a===-1||n===0||n===1&&r===a-1&&r===t+1?"":e.slice(r,a)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return g("/",e)},parse:function(e){l(e);var r={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return r;var t=e.charCodeAt(0),a=t===47,i;a?(r.root="/",i=1):i=0;for(var n=-1,s=0,o=-1,m=!0,v=e.length-1,u=0;v>=i;--v){if(t=e.charCodeAt(v),t===47){if(!m){s=v+1;break}continue}o===-1&&(m=!1,o=v+1),t===46?n===-1?n=v:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||o===-1||u===0||u===1&&n===o-1&&n===s+1?o!==-1&&(s===0&&a?r.base=r.name=e.slice(1,o):r.base=r.name=e.slice(s,o)):(s===0&&a?(r.name=e.slice(1,n),r.base=e.slice(1,o)):(r.name=e.slice(s,n),r.base=e.slice(s,o)),r.ext=e.slice(n,o)),s>0?r.dir=e.slice(0,s-1):a&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};d.posix=d,f.exports=d}),k=$(B()),h=k,D=k,C=function(c){return c},P=function(){throw new Error("Not implemented")};h.parse??=P;D.parse??=P;var A={resolve:h.resolve.bind(h),normalize:h.normalize.bind(h),isAbsolute:h.isAbsolute.bind(h),join:h.join.bind(h),relative:h.relative.bind(h),toNamespacedPath:C,dirname:h.dirname.bind(h),basename:h.basename.bind(h),extname:h.extname.bind(h),format:h.format.bind(h),parse:h.parse.bind(h),sep:"/",delimiter:":",win32:void 0,posix:void 0,_makeLong:C},j={sep:"\\",delimiter:";",win32:void 0,...A,posix:A};A.win32=j.win32=j;A.posix=A;var{resolve:F,normalize:J,isAbsolute:M,join:S,relative:q,toNamespacedPath:K,dirname:Q,basename:U,extname:W,format:X,parse:Y,sep:Z,delimiter:ee}=A;function x(c,f){if(Array.isArray(f)&&!Array.isArray(c))return f;if(Array.isArray(f)&&Array.isArray(c))return f.map((p,g)=>{let d=c[g];if(b(p)&&b(d))return x(d,p);return p});if(!b(f)||!b(c))return f;let l={...c};for(let p in f)if(Object.prototype.hasOwnProperty.call(f,p)){let g=f[p],d=l[p];if(g===null||g===void 0)l[p]=g;else if(b(g)&&b(d))l[p]=x(d,g);else l[p]=g}return l}function b(c){return Boolean(c&&typeof c==="object"&&!Array.isArray(c))}async function T({name:c,cwd:f,defaultConfig:l,endpoint:p,headers:g={Accept:"application/json","Content-Type":"application/json"}}){if(typeof window==="undefined"){let d=F(f||"../../../",`${c}.config`);try{let e=await import(d),r=e.default||e;return x(l,r)}catch(e){return l}}if(!p)return console.warn("An API endpoint is required to load the client config."),l;try{let d=await fetch(p,{method:"GET",headers:g});if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);let e=await d.json();return x(l,e)}catch(d){return console.error("Failed to load client config:",d),l}}var G={verbose:!0},H=await T({name:"dnsx",defaultConfig:G});export{Ce as parseResponse,ve as parseProtocolTweaks,Pe as formatOutput,be as debugLog,Oe as createTransport,H as config,we as buildQuery,me as WireError,je as TransportType,he as RecordType,de as QClass,pe as EDNSMode,ge as DnsResponseCode,Ae as DnsFlags,ye as DnsEncoder,xe as DnsDecoder,ke as DnsClient};