azureauth
Version:
node-azure auth wrapps the AzureAuth CLI wrapper for performing AAD Authentication
8 lines (7 loc) • 28.9 kB
JavaScript
var an=Object.create;var Ce=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty;var h=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var l=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ln=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of un(t))!fn.call(e,o)&&o!==n&&Ce(e,o,{get:()=>t[o],enumerable:!(r=cn(t,o))||r.enumerable});return e};var k=(e,t,n)=>(n=e!=null?an(dn(e)):{},ln(t||!e||!e.__esModule?Ce(n,"default",{value:e,enumerable:!0}):n,e));var Re=l((Qr,$e)=>{$e.exports=Oe;Oe.sync=mn;var Ae=h("fs");function pn(e,t){var n=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!n||(n=n.split(";"),n.indexOf("")!==-1))return!0;for(var r=0;r<n.length;r++){var o=n[r].toLowerCase();if(o&&e.substr(-o.length).toLowerCase()===o)return!0}return!1}function Ge(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:pn(t,n)}function Oe(e,t,n){Ae.stat(e,function(r,o){n(r,r?!1:Ge(o,e,t))})}function mn(e,t){return Ge(Ae.statSync(e),e,t)}});var Be=l((Zr,ke)=>{ke.exports=je;je.sync=hn;var Ne=h("fs");function je(e,t,n){Ne.stat(e,function(r,o){n(r,r?!1:Le(o,t))})}function hn(e,t){return Le(Ne.statSync(e),t)}function Le(e,t){return e.isFile()&&gn(e,t)}function gn(e,t){var n=e.mode,r=e.uid,o=e.gid,i=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),s=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),d=a|c,g=n&u||n&c&&o===s||n&a&&r===i||n&d&&i===0;return g}});var Me=l((eo,Fe)=>{var Jr=h("fs"),B;process.platform==="win32"||global.TESTING_WINDOWS?B=Re():B=Be();Fe.exports=Y;Y.sync=yn;function Y(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,o){Y(e,t||{},function(i,s){i?o(i):r(s)})})}B(e,t||{},function(r,o){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,o=!1),n(r,o)})}function yn(e,t){try{return B.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}});var We=l((to,He)=>{var T=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ue=h("path"),Sn=T?";":":",_e=Me(),qe=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),De=(e,t)=>{let n=t.colon||Sn,r=e.match(/\//)||T&&e.match(/\\/)?[""]:[...T?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],o=T?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=T?o.split(n):[""];return T&&e.indexOf(".")!==-1&&i[0]!==""&&i.unshift(""),{pathEnv:r,pathExt:i,pathExtExe:o}},ze=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});let{pathEnv:r,pathExt:o,pathExtExe:i}=De(e,t),s=[],a=u=>new Promise((d,g)=>{if(u===r.length)return t.all&&s.length?d(s):g(qe(e));let m=r[u],S=/^".*"$/.test(m)?m.slice(1,-1):m,y=Ue.join(S,e),x=!S&&/^\.[\\\/]/.test(e)?e.slice(0,2)+y:y;d(c(x,u,0))}),c=(u,d,g)=>new Promise((m,S)=>{if(g===o.length)return m(a(d+1));let y=o[g];_e(u+y,{pathExt:i},(x,E)=>{if(!x&&E)if(t.all)s.push(u+y);else return m(u+y);return m(c(u,d,g+1))})});return n?a(0).then(u=>n(null,u),n):a(0)},xn=(e,t)=>{t=t||{};let{pathEnv:n,pathExt:r,pathExtExe:o}=De(e,t),i=[];for(let s=0;s<n.length;s++){let a=n[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Ue.join(c,e),d=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+u:u;for(let g=0;g<r.length;g++){let m=d+r[g];try{if(_e.sync(m,{pathExt:o}))if(t.all)i.push(m);else return m}catch{}}}if(t.all&&i.length)return i;if(t.nothrow)return null;throw qe(e)};He.exports=ze;ze.sync=xn});var Xe=l((no,Q)=>{"use strict";var Ke=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};Q.exports=Ke;Q.exports.default=Ke});var Ze=l((ro,Qe)=>{"use strict";var Ve=h("path"),bn=We(),wn=Xe();function Ye(e,t){let n=e.options.env||process.env,r=process.cwd(),o=e.options.cwd!=null,i=o&&process.chdir!==void 0&&!process.chdir.disabled;if(i)try{process.chdir(e.options.cwd)}catch{}let s;try{s=bn.sync(e.command,{path:n[wn({env:n})],pathExt:t?Ve.delimiter:void 0})}catch{}finally{i&&process.chdir(r)}return s&&(s=Ve.resolve(o?e.options.cwd:"",s)),s}function En(e){return Ye(e)||Ye(e,!0)}Qe.exports=En});var Je=l((oo,J)=>{"use strict";var Z=/([()\][%!^"`<>&|;, *?])/g;function Tn(e){return e=e.replace(Z,"^$1"),e}function vn(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Z,"^$1"),t&&(e=e.replace(Z,"^$1")),e}J.exports.command=Tn;J.exports.argument=vn});var tt=l((io,et)=>{"use strict";et.exports=/^#!(.*)/});var rt=l((so,nt)=>{"use strict";var In=tt();nt.exports=(e="")=>{let t=e.match(In);if(!t)return null;let[n,r]=t[0].replace(/#! ?/,"").split(" "),o=n.split("/").pop();return o==="env"?r:r?`${o} ${r}`:o}});var it=l((ao,ot)=>{"use strict";var ee=h("fs"),Pn=rt();function Cn(e){let n=Buffer.alloc(150),r;try{r=ee.openSync(e,"r"),ee.readSync(r,n,0,150,0),ee.closeSync(r)}catch{}return Pn(n.toString())}ot.exports=Cn});var ut=l((co,ct)=>{"use strict";var An=h("path"),st=Ze(),at=Je(),Gn=it(),On=process.platform==="win32",$n=/\.(?:com|exe)$/i,Rn=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Nn(e){e.file=st(e);let t=e.file&&Gn(e.file);return t?(e.args.unshift(e.file),e.command=t,st(e)):e.file}function jn(e){if(!On)return e;let t=Nn(e),n=!$n.test(t);if(e.options.forceShell||n){let r=Rn.test(t);e.command=An.normalize(e.command),e.command=at.command(e.command),e.args=e.args.map(i=>at.argument(i,r));let o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Ln(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:jn(r)}ct.exports=Ln});var lt=l((uo,ft)=>{"use strict";var te=process.platform==="win32";function ne(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function kn(e,t){if(!te)return;let n=e.emit;e.emit=function(r,o){if(r==="exit"){let i=dt(o,t,"spawn");if(i)return n.call(e,"error",i)}return n.apply(e,arguments)}}function dt(e,t){return te&&e===1&&!t.file?ne(t.original,"spawn"):null}function Bn(e,t){return te&&e===1&&!t.file?ne(t.original,"spawnSync"):null}ft.exports={hookChildProcess:kn,verifyENOENT:dt,verifyENOENTSync:Bn,notFoundError:ne}});var ht=l((fo,v)=>{"use strict";var pt=h("child_process"),re=ut(),oe=lt();function mt(e,t,n){let r=re(e,t,n),o=pt.spawn(r.command,r.args,r.options);return oe.hookChildProcess(o,r),o}function Fn(e,t,n){let r=re(e,t,n),o=pt.spawnSync(r.command,r.args,r.options);return o.error=o.error||oe.verifyENOENTSync(o.status,r),o}v.exports=mt;v.exports.spawn=mt;v.exports.sync=Fn;v.exports._parse=re;v.exports._enoent=oe});var Pt=l((ko,q)=>{q.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&q.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&q.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var $t=l((Bo,C)=>{var f=global.process,b=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};b(f)?(Ct=h("assert"),I=Pt(),At=/^win/i.test(f.platform),O=h("events"),typeof O!="function"&&(O=O.EventEmitter),f.__signal_exit_emitter__?p=f.__signal_exit_emitter__:(p=f.__signal_exit_emitter__=new O,p.count=0,p.emitted={}),p.infinite||(p.setMaxListeners(1/0),p.infinite=!0),C.exports=function(e,t){if(!b(global.process))return function(){};Ct.equal(typeof e,"function","a callback must be provided for exit handler"),P===!1&&ce();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){p.removeListener(n,e),p.listeners("exit").length===0&&p.listeners("afterexit").length===0&&D()};return p.on(n,e),r},D=function(){!P||!b(global.process)||(P=!1,I.forEach(function(t){try{f.removeListener(t,z[t])}catch{}}),f.emit=H,f.reallyExit=ue,p.count-=1)},C.exports.unload=D,w=function(t,n,r){p.emitted[t]||(p.emitted[t]=!0,p.emit(t,n,r))},z={},I.forEach(function(e){z[e]=function(){if(b(global.process)){var n=f.listeners(e);n.length===p.count&&(D(),w("exit",null,e),w("afterexit",null,e),At&&e==="SIGHUP"&&(e="SIGINT"),f.kill(f.pid,e))}}}),C.exports.signals=function(){return I},P=!1,ce=function(){P||!b(global.process)||(P=!0,p.count+=1,I=I.filter(function(t){try{return f.on(t,z[t]),!0}catch{return!1}}),f.emit=Ot,f.reallyExit=Gt)},C.exports.load=ce,ue=f.reallyExit,Gt=function(t){b(global.process)&&(f.exitCode=t||0,w("exit",f.exitCode,null),w("afterexit",f.exitCode,null),ue.call(f,f.exitCode))},H=f.emit,Ot=function(t,n){if(t==="exit"&&b(global.process)){n!==void 0&&(f.exitCode=n);var r=H.apply(this,arguments);return w("exit",f.exitCode,null),w("afterexit",f.exitCode,null),r}else return H.apply(this,arguments)}):C.exports=function(){return function(){}};var Ct,I,At,O,p,D,w,z,P,ce,ue,Gt,H,Ot});var Ut=l((Ho,Mt)=>{"use strict";var{PassThrough:yr}=h("stream");Mt.exports=e=>{e={...e};let{array:t}=e,{encoding:n}=e,r=n==="buffer",o=!1;t?o=!(n||r):n=n||"utf8",r&&(n=null);let i=new yr({objectMode:o});n&&i.setEncoding(n);let s=0,a=[];return i.on("data",c=>{a.push(c),o?s=a.length:s+=c.length}),i.getBufferedValue=()=>t?a:r?Buffer.concat(a,s):a.join(""),i.getBufferedLength=()=>s,i}});var _t=l((Wo,$)=>{"use strict";var{constants:Sr}=h("buffer"),xr=h("stream"),{promisify:br}=h("util"),wr=Ut(),Er=br(xr.pipeline),K=class extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};async function le(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};let{maxBuffer:n}=t,r=wr(t);return await new Promise((o,i)=>{let s=a=>{a&&r.getBufferedLength()<=Sr.MAX_LENGTH&&(a.bufferedData=r.getBufferedValue()),i(a)};(async()=>{try{await Er(e,r),o()}catch(a){s(a)}})(),r.on("data",()=>{r.getBufferedLength()>n&&s(new K)})}),r.getBufferedValue()}$.exports=le;$.exports.buffer=(e,t)=>le(e,{...t,encoding:"buffer"});$.exports.array=(e,t)=>le(e,{...t,array:!0});$.exports.MaxBufferError=K});var Dt=l((Ko,qt)=>{"use strict";var{PassThrough:Tr}=h("stream");qt.exports=function(){var e=[],t=new Tr({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(n),t;function n(i){return Array.isArray(i)?(i.forEach(n),this):(e.push(i),i.once("end",o.bind(null,i)),i.once("error",t.emit.bind(t,"error")),i.pipe(t,{end:!1}),this)}function r(){return e.length==0}function o(i){e=e.filter(function(s){return s!==i}),!e.length&&t.readable&&t.end()}}});var nn=k(ht(),1);import{Buffer as Ur}from"node:buffer";import _r from"node:path";import we from"node:child_process";import V from"node:process";function ie(e){let t=typeof e=="string"?`
`:10,n=typeof e=="string"?"\r":13;return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}import M from"node:process";import A from"node:path";import{fileURLToPath as gt}from"node:url";function F(e={}){let{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}var Mn=({cwd:e=M.cwd(),path:t=M.env[F()],preferLocal:n=!0,execPath:r=M.execPath,addExecPath:o=!0}={})=>{let i=e instanceof URL?gt(e):e,s=A.resolve(i),a=[];return n&&Un(a,s),o&&_n(a,r,s),[...a,t].join(A.delimiter)},Un=(e,t)=>{let n;for(;n!==t;)e.push(A.join(t,"node_modules/.bin")),n=t,t=A.resolve(t,"..")},_n=(e,t,n)=>{let r=t instanceof URL?gt(t):t;e.push(A.resolve(n,r,".."))},yt=({env:e=M.env,...t}={})=>{e={...e};let n=F({env:e});return t.path=e[n],e[n]=Mn(t),e};var qn=(e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;let o=Object.getOwnPropertyDescriptor(e,n),i=Object.getOwnPropertyDescriptor(t,n);!Dn(o,i)&&r||Object.defineProperty(e,n,i)},Dn=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},zn=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},Hn=(e,t)=>`/* Wrapped ${e}*/
${t}`,Wn=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Kn=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Xn=(e,t,n)=>{let r=n===""?"":`with ${n.trim()}() `,o=Hn.bind(null,r,t.toString());Object.defineProperty(o,"name",Kn),Object.defineProperty(e,"toString",{...Wn,value:o})};function se(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let o of Reflect.ownKeys(t))qn(e,t,o,n);return zn(e,t),Xn(e,t,r),e}var U=new WeakMap,St=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0,o=e.displayName||e.name||"<anonymous>",i=function(...s){if(U.set(i,++r),r===1)n=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return n};return se(i,e),U.set(i,r),i};St.callCount=e=>{if(!U.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return U.get(e)};var xt=St;import or from"node:process";import{constants as Zn}from"node:os";var bt=()=>{let e=Et-wt+1;return Array.from({length:e},Vn)},Vn=(e,t)=>({name:`SIGRT${t+1}`,number:wt+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),wt=34,Et=64;import{constants as Yn}from"node:os";var Tt=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var ae=()=>{let e=bt();return[...Tt,...e].map(Qn)},Qn=({name:e,number:t,description:n,action:r,forced:o=!1,standard:i})=>{let{signals:{[e]:s}}=Yn,a=s!==void 0;return{name:e,number:a?s:t,description:n,supported:a,action:r,forced:o,standard:i}};var Jn=()=>{let e=ae();return Object.fromEntries(e.map(er))},er=({name:e,number:t,description:n,supported:r,action:o,forced:i,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:o,forced:i,standard:s}],vt=Jn(),tr=()=>{let e=ae(),t=65,n=Array.from({length:t},(r,o)=>nr(o,e));return Object.assign({},...n)},nr=(e,t)=>{let n=rr(e,t);if(n===void 0)return{};let{name:r,description:o,supported:i,action:s,forced:a,standard:c}=n;return{[e]:{name:r,number:e,description:o,supported:i,action:s,forced:a,standard:c}}},rr=(e,t)=>{let n=t.find(({name:r})=>Zn.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)},Oo=tr();var ir=({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:o,exitCode:i,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${o})`:i!==void 0?`failed with exit code ${i}`:"failed",G=({stdout:e,stderr:t,all:n,error:r,signal:o,exitCode:i,command:s,escapedCommand:a,timedOut:c,isCanceled:u,killed:d,parsed:{options:{timeout:g,cwd:m=or.cwd()}}})=>{i=i===null?void 0:i,o=o===null?void 0:o;let S=o===void 0?void 0:vt[o].description,y=r&&r.code,E=`Command ${ir({timedOut:c,timeout:g,errorCode:y,signal:o,signalDescription:S,exitCode:i,isCanceled:u})}: ${s}`,N=Object.prototype.toString.call(r)==="[object Error]",j=N?`${E}
${r.message}`:E,L=[j,t,e].filter(Boolean).join(`
`);return N?(r.originalMessage=r.message,r.message=L):r=new Error(L),r.shortMessage=j,r.command=s,r.escapedCommand=a,r.exitCode=i,r.signal=o,r.signalDescription=S,r.stdout=e,r.stderr=t,r.cwd=m,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!c,r.isCanceled=u,r.killed=d&&!c,r};var _=["stdin","stdout","stderr"],sr=e=>_.some(t=>e[t]!==void 0),It=e=>{if(!e)return;let{stdio:t}=e;if(t===void 0)return _.map(r=>e[r]);if(sr(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${_.map(r=>`\`${r}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);let n=Math.max(t.length,_.length);return Array.from({length:n},(r,o)=>t[o])};var Rt=k($t(),1);import ar from"node:os";var cr=1e3*5,Nt=(e,t="SIGTERM",n={})=>{let r=e(t);return ur(e,t,n,r),r},ur=(e,t,n,r)=>{if(!dr(t,n,r))return;let o=lr(n),i=setTimeout(()=>{e("SIGKILL")},o);i.unref&&i.unref()},dr=(e,{forceKillAfterTimeout:t},n)=>fr(e)&&t!==!1&&n,fr=e=>e===ar.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",lr=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return cr;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},jt=(e,t)=>{e.kill()&&(t.isCanceled=!0)},pr=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Lt=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let o,i=new Promise((a,c)=>{o=setTimeout(()=>{pr(e,n,c)},t)}),s=r.finally(()=>{clearTimeout(o)});return Promise.race([i,s])},kt=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Bt=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;let o=(0,Rt.default)(()=>{e.kill()});return r.finally(()=>{o()})};import{createWriteStream as mr}from"node:fs";import{ChildProcess as hr}from"node:child_process";function W(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function de(e){return W(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}var gr=e=>e instanceof hr&&typeof e.then=="function",fe=(e,t,n)=>{if(typeof n=="string")return e[t].pipe(mr(n)),e;if(de(n))return e[t].pipe(n),e;if(!gr(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!de(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},Ft=e=>{e.stdout!==null&&(e.pipeStdout=fe.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=fe.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=fe.bind(void 0,e,"all"))};import{createReadStream as vr,readFileSync as Ir}from"node:fs";var he=k(_t(),1),zt=k(Dt(),1),Ht=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},Pr=({input:e,inputFile:t})=>typeof t!="string"?e:(Ht(e),Ir(t)),Wt=e=>{let t=Pr(e);if(W(t))throw new TypeError("The `input` option cannot be a stream in sync mode");return t},Cr=({input:e,inputFile:t})=>typeof t!="string"?e:(Ht(e),vr(t)),Kt=(e,t)=>{let n=Cr(t);n!==void 0&&(W(n)?n.pipe(e.stdin):e.stdin.end(n))},Xt=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;let n=(0,zt.default)();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},pe=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},me=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t?(0,he.default)(e,{encoding:t,maxBuffer:r}):he.default.buffer(e,{maxBuffer:r})},Vt=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:o,maxBuffer:i},s)=>{let a=me(e,{encoding:r,buffer:o,maxBuffer:i}),c=me(t,{encoding:r,buffer:o,maxBuffer:i}),u=me(n,{encoding:r,buffer:o,maxBuffer:i*2});try{return await Promise.all([s,a,c,u])}catch(d){return Promise.all([{error:d,signal:d.signal,timedOut:d.timedOut},pe(e,a),pe(t,c),pe(n,u)])}};var Ar=(async()=>{})().constructor.prototype,Gr=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Ar,e)]),ge=(e,t)=>{for(let[n,r]of Gr){let o=typeof t=="function"?(...i)=>Reflect.apply(r.value,t(),i):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:o})}},Yt=e=>new Promise((t,n)=>{e.on("exit",(r,o)=>{t({exitCode:r,signal:o})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})});import{Buffer as Or}from"node:buffer";import{ChildProcess as $r}from"node:child_process";var Jt=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],Rr=/^[\w.-]+$/,Nr=/"/g,jr=e=>typeof e!="string"||Rr.test(e)?e:`"${e.replace(Nr,'\\"')}"`,ye=(e,t)=>Jt(e,t).join(" "),Se=(e,t)=>Jt(e,t).map(n=>jr(n)).join(" "),Lr=/ +/g;var Qt=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(t==="object"&&e!==null&&!(e instanceof $r)&&"stdout"in e){let n=typeof e.stdout;if(n==="string")return e.stdout;if(Or.isBuffer(e.stdout))return e.stdout.toString();throw new TypeError(`Unexpected "${n}" stdout in template expression`)}throw new TypeError(`Unexpected "${t}" in template expression`)},Zt=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e[e.length-1]}${t[0]}`,...t.slice(1)],kr=({templates:e,expressions:t,tokens:n,index:r,template:o})=>{let i=o??e.raw[r],s=i.split(Lr).filter(Boolean),a=Zt(n,s,i.startsWith(" "));if(r===t.length)return a;let c=t[r],u=Array.isArray(c)?c.map(d=>Qt(d)):[Qt(c)];return Zt(a,u,i.endsWith(" "))},xe=(e,t)=>{let n=[];for(let[r,o]of e.entries())n=kr({templates:e,expressions:t,tokens:n,index:r,template:o});return n};import{debuglog as Br}from"node:util";import Fr from"node:process";var en=Br("execa").enabled,X=(e,t)=>String(e).padStart(t,"0"),Mr=()=>{let e=new Date;return`${X(e.getHours(),2)}:${X(e.getMinutes(),2)}:${X(e.getSeconds(),2)}.${X(e.getMilliseconds(),3)}`},be=(e,{verbose:t})=>{t&&Fr.stderr.write(`[${Mr()}] ${e}
`)};var qr=1e3*1e3*100,Dr=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:o})=>{let i=t?{...V.env,...e}:e;return n?yt({env:i,cwd:r,execPath:o}):i},rn=(e,t,n={})=>{let r=nn.default._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:qr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||V.cwd(),execPath:V.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:en,...n},n.env=Dr(n),n.stdio=It(n),V.platform==="win32"&&_r.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},R=(e,t,n)=>typeof t!="string"&&!Ur.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?ie(t):t;function Ee(e,t,n){let r=rn(e,t,n),o=ye(e,t),i=Se(e,t);be(i,r.options),kt(r.options);let s;try{s=we.spawn(r.file,r.args,r.options)}catch(S){let y=new we.ChildProcess,x=Promise.reject(G({error:S,stdout:"",stderr:"",all:"",command:o,escapedCommand:i,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return ge(y,x),y}let a=Yt(s),c=Lt(s,r.options,a),u=Bt(s,r.options,c),d={isCanceled:!1};s.kill=Nt.bind(null,s.kill.bind(s)),s.cancel=jt.bind(null,s,d);let m=xt(async()=>{let[{error:S,exitCode:y,signal:x,timedOut:E},N,j,L]=await Vt(s,r.options,u),Te=R(r.options,N),ve=R(r.options,j),Ie=R(r.options,L);if(S||y!==0||x!==null){let Pe=G({error:S,exitCode:y,signal:x,stdout:Te,stderr:ve,all:Ie,command:o,escapedCommand:i,parsed:r,timedOut:E,isCanceled:d.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:s.killed});if(!r.options.reject)return Pe;throw Pe}return{command:o,escapedCommand:i,exitCode:0,stdout:Te,stderr:ve,all:Ie,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Kt(s,r.options),s.all=Xt(s,r.options),Ft(s),ge(s,m),s}function zr(e,t,n){let r=rn(e,t,n),o=ye(e,t),i=Se(e,t);be(i,r.options);let s=Wt(r.options),a;try{a=we.spawnSync(r.file,r.args,{...r.options,input:s})}catch(d){throw G({error:d,stdout:"",stderr:"",all:"",command:o,escapedCommand:i,parsed:r,timedOut:!1,isCanceled:!1,killed:!1})}let c=R(r.options,a.stdout,a.error),u=R(r.options,a.stderr,a.error);if(a.error||a.status!==0||a.signal!==null){let d=G({stdout:c,stderr:u,error:a.error,signal:a.signal,exitCode:a.status,command:o,escapedCommand:i,parsed:r,timedOut:a.error&&a.error.code==="ETIMEDOUT",isCanceled:!1,killed:a.signal!==null});if(!r.options.reject)return d;throw d}return{command:o,escapedCommand:i,exitCode:0,stdout:c,stderr:u,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}var Hr=({input:e,inputFile:t,stdio:n})=>e===void 0&&t===void 0&&n===void 0?{stdin:"inherit"}:{},tn=(e={})=>({preferLocal:!0,...Hr(e),...e});function on(e){function t(n,...r){if(!Array.isArray(n))return on({...e,...n});let[o,...i]=xe(n,r);return Ee(o,i,tn(e))}return t.sync=(n,...r)=>{if(!Array.isArray(n))throw new TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[o,...i]=xe(n,r);return zr(o,i,tn(e))},t}var wi=on();import Wr from"node:path";import Kr from"node:process";var sn=()=>{let e=Wr.join(__dirname,"..","bin","azureauth","azureauth");return Kr.platform==="win32"&&(e=e+".exe"),e};var Xr=e=>{let t=["ado","pat",`--prompt-hint "${e.promptHint}"`,`--organization "${e.organization}"`,`--display-name "${e.displayName}"`,...e.scope.map(n=>`--scope ${n}`)];return e.output?t.push(`--output ${e.output}`):t.push("--output json"),e.mode&&t.push(`--mode "${e.mode}"`),e.domain&&t.push(`--domain "${e.domain}"`),e.timeout&&t.push(`--timeout ${e.timeout}`),t},Vr=async e=>{let t=Xr(e);try{let n=await Ee(sn(),t);return e.output==="json"?JSON.parse(n.stdout):n.stdout}catch(n){throw new Error("Failed to get Ado Pat: "+n.message)}};export{Vr as adoPat};
//# sourceMappingURL=index.js.map