@microsoft/cmr-cli 0.0.0-stage → 0.32.3
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/LICENSE +21 -0
- package/README.md +172 -2
- package/THIRD-PARTY-NOTICES.txt +9751 -0
- package/dist/Add-FU57YE5G.js +11 -0
- package/dist/AddConfig-CI7KNLIG.js +12 -0
- package/dist/AddConnector-WH4IU3ND.js +16 -0
- package/dist/AddDeployment-GWFCPAL5.js +11 -0
- package/dist/AddDeploymentBinding-RFLI6DKH.js +18 -0
- package/dist/AddRayfin-VRCFEOIL.js +38 -0
- package/dist/Alter-JFFT5JOA.js +11 -0
- package/dist/AuthStatus-WCZYGI5G.js +11 -0
- package/dist/AuthSwitch-XJMG7IUR.js +13 -0
- package/dist/Bin.js +12 -0
- package/dist/BuildMaafApp-7AUZHYOQ.js +11 -0
- package/dist/Clear-7B7CDIPV.js +11 -0
- package/dist/Cli-XZ4SJKBZ.js +47 -0
- package/dist/CloneMaafApp-7W246RZA.js +12 -0
- package/dist/CreateMaafApp-6MSPHUU4.js +22 -0
- package/dist/CreateMaafProject-JKMF5TH3.js +11 -0
- package/dist/DeleteMaafApp-TFGWGJO3.js +11 -0
- package/dist/DeployMaafApp-K2APWFOD.js +8 -0
- package/dist/DeployMaafProject-6WRKGIIW.js +11 -0
- package/dist/DeploymentApprovals-WTXBXCKE.js +11 -0
- package/dist/Dev-CIEWFRXR.js +15 -0
- package/dist/EnvironmentVariableAuthenticationProvider-EBRBQ5I2.js +11 -0
- package/dist/FeatureSettings-77LZQSKD.js +11 -0
- package/dist/GenerateCode-UQCHTRGP.js +13 -0
- package/dist/GetMaafBuildStatus-6ZSLIZCH.js +11 -0
- package/dist/GetMaafProjectDeployStatus-NZEMVQGJ.js +12 -0
- package/dist/GetSettings-MVVEXMJC.js +11 -0
- package/dist/InfoMaafApp-7Z6OJCHD.js +13 -0
- package/dist/InfoMaafProject-SQYB736C.js +11 -0
- package/dist/Init-PBH2IXVK.js +11 -0
- package/dist/ListConnectorActions-UERYZ2C7.js +11 -0
- package/dist/ListConnectors-2FUTJMHY.js +11 -0
- package/dist/ListDeployments-4YWCHVKF.js +11 -0
- package/dist/ListMaafApps-ZATO77G3.js +11 -0
- package/dist/ListMaafProjects-GNUXZSYL.js +11 -0
- package/dist/ListSchema-QKVHVPHB.js +8 -0
- package/dist/ListSettings-IIA5OGMP.js +12 -0
- package/dist/Login-BT6UTPCZ.js +11 -0
- package/dist/Logout-FBJE35Q5.js +11 -0
- package/dist/MockFetch-LQLQGTNT.js +13 -0
- package/dist/NoOpAuthenticationProvider-ZZK2OB27.js +11 -0
- package/dist/NodeMsalAuthenticationProvider-5TJFMHR4.js +17 -0
- package/dist/Pack-TSFHSTB5.js +8 -0
- package/dist/PackProject-T575KJQ4.js +14 -0
- package/dist/PlayMaafApp-74TQEAO5.js +8 -0
- package/dist/ProjectApprovals-5KLYEM7V.js +13 -0
- package/dist/ProjectRoleAssignments-AI2FQ2VX.js +11 -0
- package/dist/RefreshDataSource-VARFN3IV.js +11 -0
- package/dist/RefreshGitAuth-DC5NAZBJ.js +11 -0
- package/dist/Remove-MCQZVI3K.js +11 -0
- package/dist/RemoveDataSource-RRND46QZ.js +14 -0
- package/dist/RemoveDeployment-STNFNNZF.js +11 -0
- package/dist/ServicePrincipalAuthenticationProvider-7RBHTYYY.js +11 -0
- package/dist/SetSetting-CEH44OT3.js +11 -0
- package/dist/SetSetting-Q7EQNOTI.js +11 -0
- package/dist/ShareLinkCreate-ZUVHUQLH.js +11 -0
- package/dist/ShareLinkList-IEYU6NZW.js +11 -0
- package/dist/ShareLinkRevoke-22RFGOFJ.js +11 -0
- package/dist/ShareList-6UWIHPBM.js +11 -0
- package/dist/ShareMaafApp-SFNOOMOD.js +11 -0
- package/dist/TelemetrySettings-XCT73DEI.js +11 -0
- package/dist/UnshareMaafApp-TU7U3LQ3.js +11 -0
- package/dist/acorn-CYBWGE5M.js +23 -0
- package/dist/angular-Q62TJP23.js +11 -0
- package/dist/babel-AOXBHIIS.js +22 -0
- package/dist/chunk-2LDU3F6O.js +11 -0
- package/dist/chunk-2LKCCYRF.js +11 -0
- package/dist/chunk-2VJIWD7V.js +11 -0
- package/dist/chunk-3E7QQ2BR.js +11 -0
- package/dist/chunk-3YRE4IQ3.js +132 -0
- package/dist/chunk-4U53RYJJ.js +11 -0
- package/dist/chunk-4XKA5APP.js +42915 -0
- package/dist/chunk-5MHBEEMZ.js +11 -0
- package/dist/chunk-6EF722GY.js +94 -0
- package/dist/chunk-A4PVXTJS.js +13 -0
- package/dist/chunk-ADRQC63G.js +14 -0
- package/dist/chunk-ATUGCFVC.js +11 -0
- package/dist/chunk-BA52TY55.js +12 -0
- package/dist/chunk-BRRT2E75.js +38 -0
- package/dist/chunk-DGUO74I3.js +15 -0
- package/dist/chunk-DKSLWH4O.js +18 -0
- package/dist/chunk-EFY2BSWB.js +12 -0
- package/dist/chunk-FHE3OXIP.js +11 -0
- package/dist/chunk-GE3UFHZ5.js +54 -0
- package/dist/chunk-HBLO3WDD.js +13 -0
- package/dist/chunk-HOIFXUTG.js +11 -0
- package/dist/chunk-HSNRWBA6.js +11 -0
- package/dist/chunk-KKC5ZK4D.js +77 -0
- package/dist/chunk-KT2SUHGM.js +11 -0
- package/dist/chunk-NYPHWF7Q.js +32 -0
- package/dist/chunk-OL6CTXQR.js +11 -0
- package/dist/chunk-OUKOEUZA.js +12 -0
- package/dist/chunk-PEZMQ2A3.js +11 -0
- package/dist/chunk-PLFDUGBA.js +12 -0
- package/dist/chunk-PZIEJEF5.js +11 -0
- package/dist/chunk-Q3ONTUZ7.js +11 -0
- package/dist/chunk-QLK3ZVWP.js +11 -0
- package/dist/chunk-RDXQ3ZPT.js +11 -0
- package/dist/chunk-RFLXPXBN.js +11 -0
- package/dist/chunk-SIEI2EB5.js +12 -0
- package/dist/chunk-SQI4XLR7.js +11 -0
- package/dist/chunk-TMYOZDLM.js +11 -0
- package/dist/chunk-TXMTKOEJ.js +12 -0
- package/dist/chunk-TYRVM4PP.js +8 -0
- package/dist/chunk-UEZV46GZ.js +44 -0
- package/dist/chunk-UT667QSU.js +8 -0
- package/dist/chunk-UXKJNXTZ.js +11 -0
- package/dist/chunk-WTTK2GTG.js +11 -0
- package/dist/chunk-WV7D7PTW.js +12 -0
- package/dist/chunk-WWVAS3DS.js +11 -0
- package/dist/chunk-XIX2O22O.js +11 -0
- package/dist/chunk-Y5AMO72S.js +10 -0
- package/dist/chunk-YRPTITKD.js +12 -0
- package/dist/chunk-ZB6MB7GZ.js +17 -0
- package/dist/dist-7N5TXK2L.js +45 -0
- package/dist/estree-HPTPQIMZ.js +51 -0
- package/dist/flow-B6JUMONE.js +27 -0
- package/dist/glimmer-36KZ3DJ5.js +44 -0
- package/dist/graphql-E6CIFZFV.js +35 -0
- package/dist/html-BUTTPQE6.js +32 -0
- package/dist/markdown-K2C5OZHT.js +69 -0
- package/dist/meriyah-27UE2OSX.js +12 -0
- package/dist/native/arm64/dpapi.node +0 -0
- package/dist/native/ia32/dpapi.node +0 -0
- package/dist/native/x64/dpapi.node +0 -0
- package/dist/postcss-QUHZLBB7.js +68 -0
- package/dist/rayfin-pack-HOUOLOHQ.js +164 -0
- package/dist/typescript-G2G6TDZF.js +28 -0
- package/dist/yaml-W5P5CGFK.js +166 -0
- package/package.json +62 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __pathDirname(__filename);
|
|
7
|
+
import{a as o}from"./chunk-DKSLWH4O.js";import{b as I,c as h}from"./chunk-TXMTKOEJ.js";import{Ma as d,Nb as u,Ob as w,fb as j,x as c,z as p}from"./chunk-4XKA5APP.js";async function E(a,l=!0,f=u()){let e=w();if(e.projectConfig)return e.projectConfig;let t=e.appConfig;if(!t)throw new c("No managed project or app configuration was found. Run this command from a directory containing ms.project.config.json or ms.config.json.");let r=o(t.projectId),i=o(t.environmentId);if(!r){let n=o(t.appId);if(!n)throw new p("The current app does not specify an app ID.");let s=await a.getTenantIdAsync();if(!s)throw new c("Unable to determine tenant ID. Ensure you are logged in.");let g=await d({tenantId:s,environmentId:i,logger:f,actionsParams:{appName:n}});r=o(g.projectId),i=o(g.environmentId)}if(!r)throw new c("The current app is not associated with a managed project.");if(!i)throw new p("The current app does not specify an environment ID.");a.updateEnvironmentId(i);let C=await j({projectId:r,logger:f}),m=I(C,t.cloud);if(l){let n=e.fileConfig.projectConfigPath;if(!n)throw new p("Unable to determine where ms.project.config.json should be created.");h(n,m)}return m}export{E as a};
|
|
8
|
+
/*!
|
|
9
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
10
|
+
*/
|
|
11
|
+
//# sourceMappingURL=chunk-WWVAS3DS.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __pathDirname(__filename);
|
|
7
|
+
import{f as s}from"./chunk-OUKOEUZA.js";import{E as a,I as i}from"./chunk-KKC5ZK4D.js";import{spawn as c}from"node:child_process";var g={showUserCode({userCode:t,verificationUri:e,expiresIn:r}){i(""),i("First copy your one-time code:"),i(""),i(` ${t}`),i(""),i("Then visit this URL to sign in to GitHub:"),i(""),i(` ${e}`),i(""),i(`(Code expires in ${Math.round(r/60)} minutes.)`)},showWaiting(){i("Waiting for authentication...")},openVerificationUri(t){return f(t,{skip:!1})}},p=class{showUserCode(e){this._emit({phase:"github-auth-initiated",sessionId:e.sessionId,userCode:e.userCode,verificationUri:e.verificationUri,expiresIn:e.expiresIn,pollIntervalSeconds:e.pollIntervalSeconds})}showWaiting(){}showPollIteration(){this._emit({phase:"github-auth-pending"})}showComplete(e){this._emit({phase:"github-auth-complete",githubLogin:e.githubLogin,mappingExpiresAt:e.mappingExpiresAt})}_emit(e){a(e)}};function f(t,e){if(e.skip||process.stdin.isTTY===!1||s("MS_NO_BROWSER")==="1"||s("CI")==="true")return!1;let r;try{r=new URL(t)}catch{return!1}if(r.protocol!=="https:")return!1;try{let n=l(t,process.platform);if(!n)return!1;let o=c(n.file,n.args,{shell:!1,detached:!0,stdio:"ignore"});return o.on("error",()=>{}),o.unref(),!0}catch{return!1}}function l(t,e){switch(e){case"win32":return{file:"cmd.exe",args:["/c","start","",t]};case"darwin":return{file:"open",args:[t]};case"linux":return{file:"xdg-open",args:[t]};default:return}}export{g as a,p as b};
|
|
8
|
+
/*!
|
|
9
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
10
|
+
*/
|
|
11
|
+
//# sourceMappingURL=chunk-XIX2O22O.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __pathDirname(__filename);
|
|
7
|
+
/*!
|
|
8
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
9
|
+
*/
|
|
10
|
+
//# sourceMappingURL=chunk-Y5AMO72S.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __pathDirname(__filename);
|
|
7
|
+
import{a as D,c as K,d as W,f as S}from"./chunk-HSNRWBA6.js";import{b as V}from"./chunk-2LKCCYRF.js";import{a as z}from"./chunk-SQI4XLR7.js";import{l as q,m as J,n as H}from"./chunk-GE3UFHZ5.js";import{Ma as x,N as k,Nb as R,O as w,Ob as _,P as $,Pa as b,Wa as O,k as N,ka as I,pb as L,qb as B,ra as U,x as y,z as j}from"./chunk-4XKA5APP.js";import{D as F,E as T}from"./chunk-4U53RYJJ.js";import{a as C}from"./chunk-HOIFXUTG.js";import{C as P,D as G,I as A,K as v,a as E}from"./chunk-KKC5ZK4D.js";var te=64*1024,X=1e3;async function Ee(e,n){Re(e,n),await e.runVerb();let t=_();if(!t.appConfig)throw new y(`No ${E} found in the current directory. Run "${"ms"} app init" first.`);let s=await J(e),c=await e.getTenantIdAsync();if(!c)throw new y("Unable to determine tenant ID. Ensure you are logged in.");let r=await q(e),p=K(await e.getOption("access")),m=p==="edit"?W(t.appConfig):t.appConfig.repoType??"none",f=le(e.getPositionalArgs(0));if(f.length===0)throw new y("Provide at least one principal (object ID or user/group email address). Separate multiple entries with commas, spaces, or both.");let a=p!=="edit"||m!=="native",l=R(),u=l.trackScenario("MaafApp.SharePermissions",{mode:n,access:p,repoType:m,inputCount:f.length});try{let o=[],i=await ce(f,o,a);if(l.trackActivityEvent("MaafApp.SharePermissions.PrincipalResolution",{mode:n,inputCount:f.length,resolvedCount:i.length,failedCount:o.length,emailPassthrough:a}),i.length===0)throw new y(Q(o));o.length>0&&v(Q(o));let d=await(n==="share"?ie:re)({tenantId:c,environmentId:s,appName:r,access:p,refs:i,repoType:m,jsonMode:e.isJsonMode()});u.complete({resolvedCount:i.length,failedResolutionCount:o.length,scope:d.scope,role:d.role,appScopeContributorFallback:p==="edit"&&d.scope==="app",...n==="unshare"&&{revokedCount:d.revokedCount??0,revokedPrincipalCount:d.revokedPrincipalCount??0,notFoundCount:d.notFound?.length??0,skippedCount:d.skipped?.length??0}});let g=n==="share"&&p==="edit"?await ae({appInfo:d.appInfo,tenantId:c,environmentId:s,appName:r,jsonMode:e.isJsonMode()}):void 0;e.isJsonMode()?G({access:p,partialFailure:o.length>0,...d.result,...n==="unshare"&&{revokedCount:d.revokedCount??0,revokedPrincipalCount:d.revokedPrincipalCount??0,notFound:(d.notFound??[]).map(ee),skipped:(d.skipped??[]).map(ee)},...g&&{repoType:g.repoType,cloneUrl:g.cloneUrl},warnings:o}):(ye({appName:r,mode:n,access:p,inputCount:i.length,outcome:d}),pe(g))}catch(o){let i=se(o);throw u.failure(i??o),i??o}}function se(e){if(!(e instanceof N)||e.status!==400)return null;let n=e.code,t;if(e.body&&e.body.length<=te)try{let m=JSON.parse(e.body);typeof m?.error?.code=="string"&&(n=m.error.code),typeof m?.error?.message=="string"&&m.error.message.trim()&&(t=m.error.message)}catch{}let s=`${n??""} ${t??""}`.toLowerCase(),c={httpStatus:e.status,...n&&{serverErrorCode:n},...t&&{serverMessage:t}},r={httpStatus:e.status},p=t?{serverMessage:oe(t)}:void 0;return s.includes("limit")||s.includes("quota")?new y("The sharing limit for this app has been reached.",c,{errorCode:"SharingLimitExceeded",exitCode:1,telemetryDetails:r,outputDetails:p}):s.includes("policy")||s.includes("not allowed")?new j("This sharing request is blocked by an environment or tenant policy.",c,{errorCode:"SharingRequestPolicyDenied",exitCode:1,telemetryDetails:V("app_sharing",r),outputDetails:p}):new y("The sharing request was rejected.",c,{errorCode:"SharingRequestRejected",exitCode:1,telemetryDetails:r,outputDetails:p})}function oe(e){let n=[...e].map(t=>{let s=t.codePointAt(0)??0;return s<=31||s>=127&&s<=159?" ":t}).join("").trim();return n.length<=X?n:`${n.slice(0,X)}\u2026`}async function ie(e){let{tenantId:n,environmentId:t,appName:s,access:c,refs:r,repoType:p,jsonMode:m}=e;if(c==="play"||c==="test"){let u=c==="test"?$:k,o=r.map(h=>Z(h,u));return{result:await b({tenantId:n,environmentId:t,logger:R(),actionsParams:{appName:s,put:o,delete:[]}}),scope:"app",role:u}}if(p!=="native"){!m&&p==="github"&&v(D);let u=r.map(i=>Z(i,w));return{result:await b({tenantId:n,environmentId:t,logger:R(),actionsParams:{appName:s,put:u,delete:[]}}),scope:"app",role:w}}let f=await S({tenantId:n,environmentId:t,appName:s}),a=r.map(he);return{result:await L({tenantId:n,environmentId:t,logger:R(),actionsParams:{repoId:f.repositoryId,put:a,delete:[]}}),scope:"repo",role:I,appInfo:f}}async function re(e){let{tenantId:n,environmentId:t,appName:s,access:c,refs:r,repoType:p,jsonMode:m}=e,f=c!=="edit"||p!=="native",a=f?c==="test"?$:c==="play"?k:w:I,l,u=[],o;if(f){c==="edit"&&p==="github"&&(m||v(D));let i=[],h=[];o=new Map;for(let g of r)if(g.id)i.push(g.id),o.set(`id:${g.id}`,g);else if(g.email)h.push(g.email),o.set(`email:${g.email.toLowerCase()}`,g);else throw new y(`Could not resolve '${g.input}' to an AAD object ID or email.`);let d=await O({tenantId:n,environmentId:t,logger:R(),actionsParams:{appName:s,principalIds:i,principalEmails:h,roleDefinitionName:a}});l=d,u=d.notFoundEmails}else{let i=r.map(Y);o=new Map(r.map(d=>[`id:${Y(d)}`,d]));let h=await S({tenantId:n,environmentId:t,appName:s});l=await B({tenantId:n,environmentId:t,logger:R(),actionsParams:{repoId:h.repositoryId,principalIds:i}})}return{result:l.result,scope:f?"app":"repo",role:a,revokedCount:l.revokedCount,revokedPrincipalCount:l.revokedPrincipalCount,notFound:[...l.notFoundPrincipalIds.map(i=>o.get(`id:${i}`)??{id:i,input:i}),...u.map(i=>o.get(`email:${i}`)??{email:i,input:i})],skipped:l.skippedNullRoleAssignments.map(i=>o.get(`id:${i.principalObjectId}`)??o.get(`email:${i.principalObjectId}`)??{id:i.principalObjectId,input:i.principalObjectId})}}function Y(e){if(!e.id)throw new y(`Could not resolve '${e.input}' to an object ID. Unshare requires object IDs.`);return e.id}async function ae(e){let n=e.appInfo;if(!n)try{n=await x({tenantId:e.tenantId,environmentId:e.environmentId,logger:R(),actionsParams:{appName:e.appName}})}catch{e.jsonMode||v(`Share succeeded, but repository details for '${e.appName}' could not be read.`);return}return z(n)}function pe(e){e&&(e.repoType&&A(`Repo type: ${e.repoType}`),e.cloneUrl&&A(`Clone URL: ${e.cloneUrl}`))}function le(e){let n=new Set;for(let t of e)for(let s of t.split(",")){let c=s.trim();c&&n.add(c)}return[...n]}async function ce(e,n,t){let s=new Map,c=new Map,p=(await Promise.all(e.map(async a=>{let l=a.toLowerCase(),u=s.get(l);if(u)return u;if(H(a)){let o={id:a,input:a};return s.set(l,o),o}if(!me(a))return n.push({input:a,reason:"not an object ID (GUID) or a valid email address"}),null;if(t){let o={input:a,email:a};return s.set(l,o),o}try{let o=c.get(l);o||(o=U(a,R()),c.set(l,o));let i=await o;if(!i)return n.push({input:a,reason:"no user or group found in this tenant (invite as a guest in Entra ID first if external)"}),null;let h={id:i.id,input:a,type:i.type,email:a,displayName:i.displayName};return s.set(l,h),h}catch(o){return n.push({input:a,reason:ue(o)}),null}}))).filter(a=>a!==null),m=[],f=new Set;for(let a of p){let l=(a.id??a.email??a.input).toLowerCase();f.has(l)||(f.add(l),m.push(a))}return m}function Q(e){let n=e.length===1?"entry":"entries",t=e.map(s=>` - ${s.input}: ${s.reason}`);return[`Could not resolve ${e.length} ${n}:`,...t].join(`
|
|
8
|
+
`)}function ue(e){if(e instanceof N){if(e.status===403)return de(e.status);let n=fe(e.body);return n!==void 0?`Graph ${e.status}: ${n}`:e.message}return e instanceof Error?e.message:String(e)}function de(e){return`Graph ${e}: your sign-in lacks permission to look up accounts by email. Pass the object ID (GUID) instead, or have an admin grant the User.ReadBasic.All and Group.Read.All Graph permissions.`}function fe(e){if(e)try{let t=JSON.parse(e)?.error?.message;return typeof t=="string"?t:void 0}catch{return}}function me(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function Z(e,n){return{name:e.displayName??e.input,properties:{roleName:n,principal:ge(e)}}}function ge(e){return e.id?e.email?{id:e.id,email:e.email}:{id:e.id}:{email:e.email??e.input}}function he(e){let n=e.id??e.input;return{name:e.displayName??e.input,properties:{roleName:I,principal:e.type?{id:n,type:e.type}:{id:n}}}}function ee(e){return{id:e.id??e.input,label:e.displayName??e.input}}function ye(e){let{appName:n,mode:t,access:s,inputCount:c,outcome:r}=e,p=s==="play"?"play":s==="test"?"test":"edit";if(t==="share"){let u=r.result.put?.length??0;if(u===0){A("No changes were applied.");return}P(`Shared app '${n}' with ${u} ${M("principal",u)}. They can now ${p} the app.`);return}let m=r.revokedCount??0,f=r.revokedPrincipalCount??m,a=(r.skipped?.length??0)>0;if(f===0&&!a){A(`No ${p} assignments to revoke on '${n}' \u2014 none of the ${c} ${M("principal",c)} had existing access.`);return}if(f>0?P(`Revoked ${p} permissions for ${f} ${M("principal",f)} on '${n}'.`):A(`No ${p} access changes were applied on '${n}'.`),r.notFound&&r.notFound.length>0){let l=r.notFound.map(u=>u.displayName??u.input).join(", ");A(`${r.notFound.length} ${M("principal",r.notFound.length)} had no existing ${p} access (no-op): ${l}`)}if(r.skipped&&r.skipped.length>0){let l=r.skipped.map(u=>u.displayName??u.input).join(", ");A(`${r.skipped.length} ${M("principal",r.skipped.length)} had a role assignment with an unknown role definition; ${p} access was not modified for: ${l}. Investigate via the role-assignments API.`)}}function M(e,n){return n===1?e:`${e}s`}function Re(e,n){let t=n==="share"?C.app.share:C.app.unshare,s=n==="share"?F:T;e.setDescription(t.description),e.addExamples(t.examples),e.consumePositionalArgs("principal"),e.addOptions([{flags:{key:s.AppName.name},env:s.AppName.envVar,description:t.options.app,optionalInNonInteractive:!0},{flags:{key:s.Access.name},env:s.Access.envVar,default:s.Access.defaultValue,description:t.options.access,optionalInNonInteractive:!0}])}export{Ee as a};
|
|
9
|
+
/*!
|
|
10
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
11
|
+
*/
|
|
12
|
+
//# sourceMappingURL=chunk-YRPTITKD.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __pathDirname(__filename);
|
|
7
|
+
import{A as B,u as v,w as R,x as $,y as L,z as h}from"./chunk-4XKA5APP.js";import{o as _}from"./chunk-FHE3OXIP.js";import{f as D,j as F}from"./chunk-OUKOEUZA.js";import{I}from"./chunk-KKC5ZK4D.js";function C(e){try{return new URL(e).host}catch{return e}}function fe(e,t,i){t||I(`Authenticating to ${C(e)} for ${i}. A browser window may open. Sign in with the account associated with this tenant.`)}import{execFileSync as P}from"child_process";var j=[{patterns:[/403 forbidden/i,/returned error: 403/i,/remote:.*access denied/i],bucket:"auth-403",retryable:!1,errorCode:"GitAccessDenied",build:e=>`Git reached the remote but access was denied while ${e} (HTTP 403). This usually means one of:
|
|
8
|
+
- the signed-in account is in the wrong tenant, or lacks permission to this app's repo; or
|
|
9
|
+
- Git Credential Manager returned a cached credential for a different account than your current 'ms auth' sign-in (a stale or mismatched credential).
|
|
10
|
+
Confirm 'ms auth status' shows the account and tenant for this environment. If it doesn't match, clear the cached git credential for the host ('git credential-manager erase', or remove it from your OS credential store) so Git re-prompts, then re-run.`},{patterns:[/terminal prompts disabled/i,/could not read username/i,/could not read password/i],bucket:"auth-prompt-unavailable",retryable:!1,errorCode:"GitCredentialPromptUnavailable",build:e=>`Git could not obtain a credential while ${e}: there is no cached credential and the session can't prompt for one. Make sure Git Credential Manager is installed, then re-run in an interactive terminal so the browser sign-in can complete.`},{patterns:[/authentication failed/i,/invalid username or password/i],bucket:"auth-invalid-credential",retryable:!0,errorCode:"GitAuthenticationFailed",build:e=>`Git authentication failed while ${e}: the credential was missing, invalid, or expired. When the browser opens, sign in with the account for this environment's tenant; if a stale credential is cached, clear it in Git Credential Manager and re-run.`}],W=[/could not resolve host/i,/failed to connect/i,/connection timed out/i,/operation timed out after \d+ milliseconds/i,/connection refused/i,/network is unreachable/i,/temporary failure in name resolution/i,/recv failure: connection was reset/i,/connection reset by peer/i,/requested url returned error: 50[234]/i],Y=[/ssl certificate problem/i,/certificate verify failed/i,/server certificate verification failed/i,/unable to get local issuer certificate/i,/schannel:.*certificate/i,/peer certificate cannot be authenticated/i,/ssl peer certificate or ssh remote key was not ok/i,/problem with the ssl ca cert/i],X=[/could not resolve proxy/i,/failed to connect to .* proxy/i,/failed to connect to \S*proxy\S*/i,/proxy authentication required/i,/received http code 407 from proxy/i],q=[/could not create work tree dir/i,/destination path .* already exists/i,/permission denied/i,/access(?: is)? denied/i,/unable to create (?:file|directory)/i,/unable to write new index file/i,/invalid path/i,/filename too long/i,/no space left on device/i,/read-only file system/i];function J(e,t){if(typeof e!="object"||e===null)return null;let{code:i,errno:r}=e,n={action:t.action};return i==="ENOENT"?new h(`Git could not be started while ${t.action} because the executable was not found. Install Git and make sure 'git' is available on PATH, then retry.`,{...n,classifierBucket:"process-not-found"},{errorCode:"GitProcessNotFound",retryable:!1,telemetryDetails:{classifierBucket:"process-not-found"}}):i==="EACCES"?new h(`Git could not be started while ${t.action} because the executable is not permitted to run. Check the Git executable's permissions and your endpoint security policy, then retry.`,{...n,classifierBucket:"process-access-denied"},{errorCode:"GitProcessAccessDenied",retryable:!1,telemetryDetails:{classifierBucket:"process-access-denied"}}):i==="EBADARCH"||r===86||r===-86?new h(`Git could not be started while ${t.action} because the executable is incompatible with this Mac. Install a Git build for this Mac's architecture, then retry.`,{...n,classifierBucket:"process-bad-architecture"},{errorCode:"GitProcessBadArchitecture",retryable:!1,telemetryDetails:{classifierBucket:"process-bad-architecture"}}):null}function K(e){return e.replace(/(\b[a-z][a-z0-9+.-]*:\/\/)[^/\s@]+@/gi,"$1[REDACTED]@")}function b(e,t,i){let r=J(i,t);if(r)return r;let n=K(e.trimEnd());if(!n)return null;for(let o of j)if(o.patterns.some(u=>u.test(n)))return new L(o.build(t.action),{classifierBucket:o.bucket,action:t.action},{errorCode:o.errorCode,retryable:o.retryable,telemetryDetails:{classifierBucket:o.bucket}});return Y.some(o=>o.test(n))?new h(`Git could not establish a trusted TLS connection while ${t.action}. Check the system clock, certificate trust store, and any corporate TLS inspection configuration. The CLI will not disable certificate verification.`,{classifierBucket:"tls-certificate",action:t.action},{errorCode:"GitTlsCertificateError",retryable:!1,telemetryDetails:{classifierBucket:"tls-certificate"}}):X.some(o=>o.test(n))?new h(`Git could not use the configured proxy while ${t.action}. Check Git and system proxy settings, including proxy authentication, then retry.`,{classifierBucket:"proxy-configuration",action:t.action},{errorCode:"GitProxyConfigurationError",retryable:!1,telemetryDetails:{classifierBucket:"proxy-configuration"}}):q.some(o=>o.test(n))?new h(`Git could not write the local repository while ${t.action}. Check that the target directory is empty and writable, that its path is supported by Git, and that sufficient disk space is available.`,{classifierBucket:"local-filesystem",action:t.action},{errorCode:"GitFilesystemError",retryable:!1,telemetryDetails:{classifierBucket:"local-filesystem"}}):W.some(o=>o.test(n))?new B(`Git could not reach the remote while ${t.action}. Check your network connection (and proxy settings, if any) and try again.`,{classifierBucket:"network",action:t.action},{errorCode:"GitNetworkError",retryable:!0,telemetryDetails:{classifierBucket:"network"}}):null}function M(e){return e?.retryable===!0}function S(e){return e==null?"":Buffer.isBuffer(e)?e.toString():e}var Q=64*1024*1024,T=[2,31,0];function Z(){try{let t=P("git",["--version"],{stdio:["ignore","pipe","ignore"],encoding:"utf8"}).match(/git version (\d+)\.(\d+)(?:\.(\d+))?/);if(!t)return!0;let i=[Number(t[1]),Number(t[2]),Number(t[3]??0)];for(let r=0;r<T.length;r++)if(i[r]!==T[r])return i[r]>T[r];return!0}catch{return!0}}function ee(e,t){let i=t?.filter(o=>o.length>0);if(!i?.length)return{args:[...e]};if(!Z())return{args:[...i.flatMap(o=>["-c",`http.extraHeader=${o}`]),...e]};let r=Number(D("GIT_CONFIG_COUNT")??"0");if(!Number.isSafeInteger(r)||r<0)throw new Error("GIT_CONFIG_COUNT must be a non-negative integer.");let n=F();for(let[o,u]of i.entries()){let a=r+o;n[`GIT_CONFIG_KEY_${a}`]="http.extraHeader",n[`GIT_CONFIG_VALUE_${a}`]=u}return n.GIT_CONFIG_COUNT=String(r+i.length),{args:[...e],env:n}}function m(e,t={}){let{cwd:i,allowFailure:r=!1,captureStdout:n=!1,emitStderr:o=!0,classify:u,network:a=!1,httpExtraHeaders:s}=t,d=a&&!u&&!r,f=ee(e,s);try{let l=P("git",f.args,{cwd:i,stdio:["ignore",n?"pipe":"ignore",d?"inherit":"pipe"],maxBuffer:Q,env:f.env});return{success:!0,status:0,stdout:n?S(l):"",stderr:""}}catch(l){let g=l,y=S(g.stderr);if(u&&!r){let E=y||S(g.stdout)||(l instanceof Error?l.message:String(l)),G=b(E,u,l);if(G)throw G}if(o&&y&&process.stderr.write(y),!r)throw l;return{success:!1,status:typeof g.status=="number"?g.status:null,stdout:S(g.stdout),stderr:y,error:l instanceof Error?l:new Error(String(l))}}}import{execFileSync as w}from"child_process";import*as c from"fs";import*as p from"path";function U({gitUrl:e,loginAuthority:t,authResource:i,platform:r=process.platform}){let n;try{n=new URL(e)}catch(d){throw new Error(`Git credential helper setup requires a valid HTTPS remote URL: ${d instanceof Error?d.message:String(d)}`)}if(n.protocol!=="https:")throw new Error(`Git credential helper setup requires an HTTPS remote URL, got '${n.protocol}'.`);let o=n.host,u=`${t}/oauth2/v2.0`,a=`credential.https://${o}`,s=[[`${a}.oauthAuthorizeEndpoint`,`${u}/authorize?prompt=select_account`],[`${a}.oauthTokenEndpoint`,`${u}/token`],[`${a}.oauthDeviceEndpoint`,`${u}/devicecode`],[`${a}.oauthClientId`,_],[`${a}.oauthScopes`,`${i}/.default offline_access`],[`${a}.oauthRedirectUri`,"http://localhost"]];return r==="win32"&&s.push([`${a}.credentialStore`,"dpapi"]),s}var te=/^[0-9a-f]{4,39}$/i;function xe(){let e=m(["rev-parse","HEAD"],{captureStdout:!0,allowFailure:!0,emitStderr:!1});if(!e.success)return null;let t=m(["rev-parse","--abbrev-ref","HEAD"],{captureStdout:!0,allowFailure:!0,emitStderr:!1});if(!t.success)return null;let i=e.stdout.trim(),r=t.stdout.trim();return{branch:r,commitSha:i,detached:r==="HEAD"}}function Ne(e,t){if(!t||!te.test(e))return e;let i=m(["rev-parse","--verify","--end-of-options",`${e}^{commit}`],{captureStdout:!0,allowFailure:!0,emitStderr:!1}),r=i.stdout.trim();if(!i.success||!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(r))throw new $("The abbreviated --commit value could not be resolved to a unique commit in the current Git repository. Use a full commit SHA, or run this command from the repository that contains the commit.");return r}function Oe(){let e=m(["config","--get","remote.origin.url"],{captureStdout:!0,allowFailure:!0,emitStderr:!1});if(e.success)return e.stdout.trim()||void 0}var re=["https://","ssh://","git@"],ie=["-c","http.sslVersion=tlsv1.3"];function ne(e){return re.some(t=>e.startsWith(t))&&e.trim()===e&&!e.startsWith("-")&&!/[\r\n\0]/.test(e)}function O(e){return e.replace(/:\/\/[^\s/]+@/g,"://[REDACTED]@")}function Ae(e,t=process.cwd()){try{return e!==void 0&&!ne(e)?{success:!1,error:"Unsafe git remote URL."}:(A({remoteUrl:e,cwd:t}),{success:!0})}catch(i){return{success:!1,error:O(i instanceof Error?i.message:String(i))}}}function oe({directory:e,gitUrl:t,loginAuthority:i,authResource:r,emitRemoteError:n=!0}){let o=V({gitUrl:t,loginAuthority:i,authResource:r});A({remoteUrl:t,cwd:e,createDirectory:!0,initialBranch:"main",localConfig:o,updateExistingRemote:!0,emitRemoteError:n,skipInitIfRepoExists:!0})}function Ie(e,t,i,r,n=!0){let o=[...ie,"fetch","origin",...i?[i]:[]];m(o,{cwd:e,network:!0,allowFailure:!0,emitStderr:!1,httpExtraHeaders:r}).success||m(o,{cwd:e,network:!0,classify:{action:`fetching from ${C(t)}`},emitStderr:n,httpExtraHeaders:r})}function $e({directory:e,gitUrl:t,loginAuthority:i,authResource:r,onProgress:n}){let o=V({gitUrl:t,loginAuthority:i,authResource:r}),a=[...o.flatMap(([g,y])=>["-c",`${g}=${y}`]),"-c","http.sslVersion=tlsv1.3","clone","--",t],s=ce(e);n?.(`Cloning platform-managed repository into temporary folder '${s}'...`);let d=m([...a,s],{network:!0,allowFailure:!0,emitStderr:!1});if(!d.success){let g=`cloning from ${C(t)}`,y=b(d.stderr||d.stdout||d.error.message,{action:g},d.error);if(H(s,d,t),!M(y))throw y??k(g);n?.("Retrying platform-managed repository clone...");let E=m([...a,s],{network:!0,allowFailure:!0,emitStderr:!1});if(!E.success){let G=b(E.stderr||E.stdout||E.error.message,{action:g},E.error);throw H(s,E,t),G??k(g)}}n?.("Saving Git Credential Manager configuration...");let f;try{A({cwd:s,localConfig:o,skipInitIfRepoExists:!0})}catch{f="the repository-local Git configuration could not be updated"}n?.(`Moving cloned repository into '${p.resolve(e)}'...`);let l=le(s,e);return{configPersisted:f===void 0,...f?{configError:f}:{},...l?{cleanupWarning:l}:{}}}function H(e,t,i){try{c.rmSync(e,{recursive:!0,force:!0})}catch{throw se({cloneStderr:t.stderr||t.stdout||t.error.message,cloneError:t.error,gitUrl:i})}}function k(e){return new R(`Git failed while ${e}. The failure was not recognized as safely retryable, so the CLI did not retry it. Check the target directory, Git configuration, and network settings, then run the command again.`,v.GeneralError,{classifierBucket:"unclassified",action:e},{errorCode:"GitCloneUnclassified",retryable:!1,telemetryDetails:{classifierBucket:"unclassified"}})}function se({cloneStderr:e,cloneError:t,gitUrl:i}){let r=`cloning from ${C(i)}`,n=b(e,{action:r},t),o=n?.message??k(r).message;return new R(`Git clone failed, and the CLI could not remove its temporary clone storage safely. Close any process using Git files, remove the '.ms-clone-*' directory beside the target directory, and run the command again.
|
|
11
|
+
|
|
12
|
+
Original clone failure:
|
|
13
|
+
${o}`,n?.exitCode??v.GeneralError,{...n?.errorData,cleanupFailed:!0},{errorCode:"GitCloneCleanupFailed",retryable:!1,telemetryDetails:{classifierBucket:n?.telemetryDetails?.classifierBucket??"unclassified",cleanupFailed:!0}})}var ae=new Set(["EACCES","EBUSY","EEXIST","EIO","EINVAL","EISDIR","ELOOP","EMFILE","ENAMETOOLONG","ENFILE","ENOENT","ENOMEM","ENOSPC","ENOTDIR","ENOTEMPTY","ENOTSUP","EPERM","EROFS","EXDEV"]);function x(e){let t=e&&typeof e=="object"&&"code"in e?e.code:void 0;return typeof t=="string"&&ae.has(t)?t:"UNKNOWN"}function N(e){switch(e){case"EACCES":case"EPERM":case"EROFS":return"Check folder permissions and security software restrictions, and close programs using the clone files.";case"EBUSY":return"Close programs using the clone files, including editors and Git processes.";case"EEXIST":case"ENOTEMPTY":return"The destination is no longer empty. Choose an unused destination; do not overwrite existing files.";case"ENOSPC":return"Free disk space before recovering the clone.";case"ENOENT":case"ENOTDIR":return"Check that the parent folder still exists and is a directory.";case"EXDEV":return"The folders are on different filesystems. Copy the preserved clone to the destination instead of renaming it.";default:return"Check available disk space, folder permissions, and programs using the clone files."}}function ce(e){let t=p.dirname(p.resolve(e));try{return c.mkdtempSync(p.join(t,".ms-clone-"))}catch(i){let r=x(i);throw new h(`The CLI could not create temporary storage for the repository clone (create-staging: ${r}).`,{classifierBucket:"local-filesystem"},{errorCode:"GitCloneStagingFailed",retryable:!1,telemetryDetails:{classifierBucket:"local-filesystem",operation:"create-staging",systemErrorCode:r},outputDetails:{serverMessage:`Temporary storage parent: '${t}'. ${N(r)} Then run the clone command again.`}})}}function le(e,t){let i="read-target";try{if(!c.existsSync(t)){i="rename",c.renameSync(e,t);return}if(c.readdirSync(t).length>0)throw Object.assign(new Error("Target directory is no longer empty."),{code:"ENOTEMPTY"});i="read-staging";for(let r of c.readdirSync(e))i="copy",c.cpSync(p.join(e,r),p.join(t,r),{recursive:!0,force:!1,errorOnExist:!0})}catch(r){let n=x(r);throw new h(`The repository was cloned, but the CLI could not move it into the target directory (${i}: ${n}).`,{classifierBucket:"local-filesystem"},{errorCode:"GitClonePromotionFailed",retryable:!1,telemetryDetails:{classifierBucket:"local-filesystem",operation:i,systemErrorCode:n},outputDetails:{operation:i,systemErrorCode:n,stagingDirectory:e,targetDirectory:p.resolve(t),serverMessage:`The complete clone is preserved at '${e}'. Target: '${p.resolve(t)}'. ${N(n)} Inspect the target before changing it; it may contain existing or partially copied files. Move the preserved clone to an unused destination to recover without cloning again.`}})}try{c.rmSync(e,{recursive:!0,force:!0})}catch(r){let n=x(r);return`Repository cloned successfully into '${p.resolve(t)}', but temporary folder cleanup failed (cleanup: ${n}). ${N(n)} The target is ready to use. Remove only the leftover temporary folder '${e}' when it is no longer in use; do not clone again.`}}function Le(e){try{return oe(e),{success:!0}}catch(t){return{success:!1,error:O(t instanceof Error?t.message:String(t))}}}function V({gitUrl:e,loginAuthority:t,authResource:i}){try{return U({gitUrl:e,loginAuthority:t,authResource:i})}catch(r){throw new h(`Git credential helper setup failed: ${r instanceof Error?r.message:String(r)}`)}}function A({remoteUrl:e,cwd:t,createDirectory:i=!1,initialBranch:r,localConfig:n=[],updateExistingRemote:o=!1,emitRemoteError:u=!1,skipInitIfRepoExists:a=!1}){i&&c.mkdirSync(t,{recursive:!0});let s={stdio:"pipe",windowsHide:!0,cwd:t};a&&c.existsSync(p.join(t,".git"))||(w("git",["init"],s),r&&w("git",["symbolic-ref","HEAD",`refs/heads/${r}`],s));for(let[f,l]of n)w("git",["config","--local",f,l],s);if(e)try{w("git",["remote","add","origin",e],s)}catch(f){if(!o||!z(f).includes("already exists"))throw u&&process.stderr.write(O(z(f))),f;w("git",["remote","set-url","origin",e],s)}}function z(e){return typeof e=="object"&&e!==null&&"stderr"in e&&Buffer.isBuffer(e.stderr)?e.stderr.toString():""}function ue(){let e=m(["status","--porcelain"],{captureStdout:!0,allowFailure:!0,emitStderr:!1}),t=m(["rev-list","--count","origin/main..main"],{captureStdout:!0,allowFailure:!0,emitStderr:!1}),i=t.stdout.trim();return{hasUncommittedChanges:e.success?e.stdout.trim().length>0:null,isMainAheadOfOrigin:t.success&&/^\d+$/.test(i)?Number(i)>0:null}}function Be(){let e=ue(),t=[];return e.hasUncommittedChanges===!0&&t.push("There are uncommitted changes in the working tree. These will not be included in the remote build/deploy until they are committed and pushed. Run `git commit` and then `git push`."),e.isMainAheadOfOrigin===!0&&t.push("Local 'main' is ahead of 'origin/main'. These will not be included in the remote build/deploy until they are pushed. Run `git push`."),t.length>0?t.join(" "):null}export{C as a,fe as b,b as c,m as d,xe as e,Ne as f,Oe as g,Ae as h,oe as i,Ie as j,$e as k,Le as l,Be as m};
|
|
14
|
+
/*!
|
|
15
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
16
|
+
*/
|
|
17
|
+
//# sourceMappingURL=chunk-ZB6MB7GZ.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __pathDirname(__filename);
|
|
7
|
+
import{a as j}from"./chunk-UT667QSU.js";import{promises as ne}from"fs";import{pid as v}from"process";var u={EEXIST_ERROR:"EEXIST",ENOENT_ERROR:"ENOENT",EPERM_ERROR:"EPERM",DEFAULT_SERVICE_NAME:"msal-node-extensions",PERSISTENCE_TEST_DATA:"Dummy data to verify underlying persistence mechanism",LINUX_ROOT_USER_GUID:0,ENVIRONMENT:{HOME:"HOME",LOGNAME:"LOGNAME",USER:"USER",LNAME:"LNAME",USERNAME:"USERNAME",PLATFORM:"platform",LOCAL_APPLICATION_DATA:"LOCALAPPDATA"},DEFAULT_CACHE_FILE_NAME:"cache.json"},F={WINDOWS:"win32",LINUX:"linux",MACOS:"darwin"},E={INTERATION_REQUIRED_ERROR_CODE:"interaction_required",SERVER_UNAVAILABLE:"server_unavailable",UNKNOWN:"unknown_error"};var c=class s extends Error{constructor(e,t){let r=t?`${e}: ${t}`:e;super(r),Object.setPrototypeOf(this,s.prototype),this.errorCode=e,this.errorMessage=t,this.name="PersistenceError"}static createFileSystemError(e,t){return new s(e,t)}static createLibSecretError(e){return new s("GnomeKeyringError",e)}static createKeychainPersistenceError(e){return new s("KeychainError",e)}static createFilePersistenceWithDPAPIError(e){return new s("DPAPIEncryptedFileError",e)}static createCrossPlatformLockError(e){return new s("CrossPlatformLockError",e)}static createCachePersistenceError(e){return new s("CachePersistenceError",e)}static createNotSupportedError(e){return new s("NotSupportedError",e)}static createPersistenceNotVerifiedError(e){return new s("PersistenceNotVerifiedError",e)}static createPersistenceNotValidatedError(e){return new s("PersistenceNotValidatedError",e)}};var h=s=>!!s&&typeof s=="object"&&s.hasOwnProperty("code");var M=class{constructor(e,t,r){this.lockFilePath=e,this.retryNumber=r?r.retryNumber:500,this.retryDelay=r?r.retryDelay:100,this.logger=t}async lock(){for(let e=0;e<this.retryNumber;e++)try{this.logger.info(`Pid ${v} trying to acquire lock`,""),this.lockFileHandle=await ne.open(this.lockFilePath,"wx+"),this.logger.info(`Pid ${v} acquired lock`,""),await this.lockFileHandle.write(v.toString());return}catch(t){if(h(t))if(t.code===u.EEXIST_ERROR||t.code===u.EPERM_ERROR)this.logger.info(t.message,""),await this.sleep(this.retryDelay);else throw this.logger.error(`${v} was not able to acquire lock. Ran into error: ${t.message}`,""),c.createCrossPlatformLockError(t.message);else throw t}throw this.logger.error(`${v} was not able to acquire lock. Exceeded amount of retries set in the options`,""),c.createCrossPlatformLockError("Not able to acquire lock. Exceeded amount of retries set in options")}async unlock(){try{this.lockFileHandle?(await ne.unlink(this.lockFilePath),await this.lockFileHandle.close(),this.logger.info("lockfile deleted","")):this.logger.warning("lockfile handle does not exist, so lockfile could not be deleted","")}catch(e){if(h(e))if(e.code===u.ENOENT_ERROR)this.logger.info("Tried to unlock but lockfile does not exist","");else throw this.logger.error(`${v} was not able to release lock. Ran into error: ${e.message}`,""),c.createCrossPlatformLockError(e.message);else throw e}}sleep(e){return new Promise(t=>{setTimeout(t,e)})}};import{pid as X}from"process";var G=class{constructor(e,t){this.persistence=e,this.logger=e.getLogger(),this.lockFilePath=`${this.persistence.getFilePath()}.lockfile`,this.crossPlatformLock=new M(this.lockFilePath,this.logger,t),this.lastSync=0,this.currentCache=null}async beforeCacheAccess(e){if(this.logger.info("Executing before cache access",""),!await this.persistence.reloadNecessary(this.lastSync)&&this.currentCache!==null){e.cacheHasChanged&&(this.logger.verbose("Cache context has changed",""),await this.crossPlatformLock.lock());return}try{this.logger.info(`Reload necessary. Last sync time: ${this.lastSync}`,""),await this.crossPlatformLock.lock(),this.currentCache=await this.persistence.load(),this.lastSync=new Date().getTime(),this.currentCache?e.tokenCache.deserialize(this.currentCache):this.logger.info("Cache empty.",""),this.logger.info(`Last sync time updated to: ${this.lastSync}`,"")}finally{e.cacheHasChanged?this.logger.info(`Pid ${X} beforeCacheAccess did not release lock`,""):(await this.crossPlatformLock.unlock(),this.logger.info(`Pid ${X} released lock`,""))}}async afterCacheAccess(e){this.logger.info("Executing after cache access","");try{e.cacheHasChanged?(this.logger.info("Msal in-memory cache has changed. Writing changes to persistence",""),this.currentCache=e.tokenCache.serialize(),await this.persistence.save(this.currentCache)):this.logger.info("Msal in-memory cache has not changed. Did not write to persistence","")}finally{await this.crossPlatformLock.unlock(),this.logger.info(`Pid ${X} afterCacheAccess released lock`,"")}}};import{promises as N}from"fs";import{dirname as z}from"path";var P=class{async verifyPersistence(){let e=await this.createForPersistenceValidation();try{await e.save(u.PERSISTENCE_TEST_DATA);let t=await e.load();if(!t)throw c.createCachePersistenceError("Persistence check failed. Data was written but it could not be read. Possible cause: on Linux, LibSecret is installed but D-Bus isn't running because it cannot be started over SSH.");if(t!==u.PERSISTENCE_TEST_DATA)throw c.createCachePersistenceError(`Persistence check failed. Data written ${u.PERSISTENCE_TEST_DATA} is different from data read ${t}`);return await e.delete(),!0}catch(t){throw c.createCachePersistenceError(`Verifing persistence failed with the error: ${t}`)}}};var f;(function(s){s[s.Error=0]="Error",s[s.Warning=1]="Warning",s[s.Info=2]="Info",s[s.Verbose=3]="Verbose",s[s.Trace=4]="Trace"})(f||(f={}));var Ie=50,ve=500,S=new Map;function Le(s,e){S.delete(s),S.set(s,e)}function Oe(s,e){let t=Date.now(),r=S.get(s);if(r)Le(s,r);else if(r={logs:[],firstEventTime:t},S.set(s,r),S.size>Ie){let i=S.keys().next().value;i&&S.delete(i)}r.logs.push({...e,milliseconds:t-r.firstEventTime}),r.logs.length>ve&&r.logs.shift()}function Te(s){if(s.length!==6)return!1;for(let e=0;e<s.length;e++){let t=s[e];if(!(t>="a"&&t<="z"||t>="A"&&t<="Z"||t>="0"&&t<="9"))return!1}return!0}var C=class s{constructor(e,t,r){this.level=f.Info;let i=()=>{},a=e||s.createDefaultLoggerOptions();this.localCallback=a.loggerCallback||i,this.piiLoggingEnabled=a.piiLoggingEnabled||!1,this.level=typeof a.logLevel=="number"?a.logLevel:f.Info,this.packageName=t||"",this.packageVersion=r||""}static createDefaultLoggerOptions(){return{loggerCallback:()=>{},piiLoggingEnabled:!1,logLevel:f.Info}}clone(e,t){return new s({loggerCallback:this.localCallback,piiLoggingEnabled:this.piiLoggingEnabled,logLevel:this.level},e,t)}logMessage(e,t){let r=t.correlationId;if(Te(e)){let l={hash:e,level:t.logLevel,containsPii:t.containsPii||!1,milliseconds:0};Oe(r,l)}if(t.logLevel>this.level||!this.piiLoggingEnabled&&t.containsPii)return;let n=`${`[${new Date().toUTCString()}] : [${r}]`} : ${this.packageName}@${this.packageVersion} : ${f[t.logLevel]} - ${e}`;this.executeCallback(t.logLevel,n,t.containsPii||!1)}executeCallback(e,t,r){this.localCallback&&this.localCallback(e,t,r)}error(e,t){this.logMessage(e,{logLevel:f.Error,containsPii:!1,correlationId:t})}errorPii(e,t){this.logMessage(e,{logLevel:f.Error,containsPii:!0,correlationId:t})}warning(e,t){this.logMessage(e,{logLevel:f.Warning,containsPii:!1,correlationId:t})}warningPii(e,t){this.logMessage(e,{logLevel:f.Warning,containsPii:!0,correlationId:t})}info(e,t){this.logMessage(e,{logLevel:f.Info,containsPii:!1,correlationId:t})}infoPii(e,t){this.logMessage(e,{logLevel:f.Info,containsPii:!0,correlationId:t})}verbose(e,t){this.logMessage(e,{logLevel:f.Verbose,containsPii:!1,correlationId:t})}verbosePii(e,t){this.logMessage(e,{logLevel:f.Verbose,containsPii:!0,correlationId:t})}trace(e,t){this.logMessage(e,{logLevel:f.Trace,containsPii:!1,correlationId:t})}tracePii(e,t){this.logMessage(e,{logLevel:f.Trace,containsPii:!0,correlationId:t})}isPiiLoggingEnabled(){return this.piiLoggingEnabled||!1}};var p=class s extends P{constructor(e,t){super(),this.logger=new C(t||s.createDefaultLoggerOptions()),this.filePath=e}static async create(e,t){let r=new s(e,t);return await r.createCacheFile(),r}async save(e){try{await N.writeFile(this.getFilePath(),e,"utf-8")}catch(t){throw h(t)?c.createFileSystemError(t.code||E.UNKNOWN,t.message):t}}async saveBuffer(e){try{await N.writeFile(this.getFilePath(),e)}catch(t){throw h(t)?c.createFileSystemError(t.code||E.UNKNOWN,t.message):t}}async load(){try{return await N.readFile(this.getFilePath(),"utf-8")}catch(e){throw h(e)?c.createFileSystemError(e.code||E.UNKNOWN,e.message):e}}async loadBuffer(){try{return await N.readFile(this.getFilePath())}catch(e){throw h(e)?c.createFileSystemError(e.code||E.UNKNOWN,e.message):e}}async delete(){try{return await N.unlink(this.getFilePath()),!0}catch(e){if(h(e)){if(e.code===u.ENOENT_ERROR)return this.logger.warning("Cache file does not exist, so it could not be deleted",""),!1;throw c.createFileSystemError(e.code||E.UNKNOWN,e.message)}else throw e}}getFilePath(){return this.filePath}async reloadNecessary(e){return e<await this.timeLastModified()}getLogger(){return this.logger}createForPersistenceValidation(){let e=`${z(this.filePath)}/test.cache`;return s.create(e)}static createDefaultLoggerOptions(){return{loggerCallback:()=>{},piiLoggingEnabled:!1,logLevel:f.Info}}async timeLastModified(){try{return(await N.stat(this.filePath)).mtime.getTime()}catch(e){if(h(e)){if(e.code===u.ENOENT_ERROR)return this.logger.verbose("Cache file does not exist",""),0;throw c.createFileSystemError(e.code||E.UNKNOWN,e.message)}else throw e}}async createCacheFile(){await this.createFileDirectory(),await(await N.open(this.filePath,"a")).close(),this.logger.info(`File created at ${this.filePath}`,"")}async createFileDirectory(){try{await N.mkdir(z(this.filePath),{recursive:!0})}catch(e){if(h(e))if(e.code===u.EEXIST_ERROR)this.logger.info(`Directory ${z(this.filePath)} already exists`,"");else throw c.createFileSystemError(e.code||E.UNKNOWN,e.message);else throw e}}};import{createRequire as be}from"module";var U=class{constructor(e){this.errorMessage=e}protectData(){throw new Error(this.errorMessage)}unprotectData(){throw new Error(this.errorMessage)}},k;if(process.platform!=="win32")k=new U("Dpapi is not supported on this platform");else{let s=typeof j<"u"?j:be(import.meta.url);try{try{k=s(`./native/${process.arch}/dpapi.node`)}catch{k=s(`../bin/${process.arch}/dpapi`)}}catch{k=new U("Dpapi bindings unavailable")}}var T={CurrentUser:"CurrentUser",LocalMachine:"LocalMachine"};import{dirname as xe}from"path";var b=class s extends P{constructor(e,t,r){super(),this.scope=t,this.optionalEntropy=r?Buffer.from(r,"utf-8"):null,this.filePersistence=e}static async create(e,t,r,i){let a=await p.create(e,i);return new s(a,t,r)}async save(e){try{let t=k.protectData(Buffer.from(e,"utf-8"),this.optionalEntropy,this.scope.toString());await this.filePersistence.saveBuffer(t)}catch(t){throw h(t)?c.createFilePersistenceWithDPAPIError(t.message):t}}async load(){try{let e=await this.filePersistence.loadBuffer();return typeof e>"u"||!e||e.length===0?(this.filePersistence.getLogger().info("Encrypted contents loaded from file were null or empty",""),null):k.unprotectData(e,this.optionalEntropy,this.scope.toString()).toString()}catch(e){throw h(e)?c.createFilePersistenceWithDPAPIError(e.message):e}}async delete(){return this.filePersistence.delete()}async reloadNecessary(e){return this.filePersistence.reloadNecessary(e)}getFilePath(){return this.filePersistence.getFilePath()}getLogger(){return this.filePersistence.getLogger()}createForPersistenceValidation(){let e=`${xe(this.filePersistence.getFilePath())}/test.cache`;return s.create(e,T.CurrentUser)}};import Y from"@napi-rs/keyring/keytar.js";import{dirname as _e}from"path";var x=class s extends P{constructor(e,t,r){super(),this.filePersistence=e,this.serviceName=t,this.accountName=r}static async create(e,t,r,i){let a=await p.create(e,i);return new s(a,t,r)}async save(e){try{await Y.setPassword(this.serviceName,this.accountName,e)}catch(t){throw h(t)?c.createKeychainPersistenceError(t.message):t}await this.filePersistence.save("{}")}async load(){try{return await Y.getPassword(this.serviceName,this.accountName)}catch(e){throw h(e)?c.createKeychainPersistenceError(e.message):e}}async delete(){try{return await this.filePersistence.delete(),await Y.deletePassword(this.serviceName,this.accountName)}catch(e){throw h(e)?c.createKeychainPersistenceError(e.message):e}}async reloadNecessary(e){return this.filePersistence.reloadNecessary(e)}getFilePath(){return this.filePersistence.getFilePath()}getLogger(){return this.filePersistence.getLogger()}createForPersistenceValidation(){let e=`${_e(this.filePersistence.getFilePath())}/test.cache`;return s.create(e,"persistenceValidationServiceName","persistencValidationAccountName")}};import J from"@napi-rs/keyring/keytar.js";import{dirname as Ve}from"path";var _=class s extends P{constructor(e,t,r){super(),this.filePersistence=e,this.serviceName=t,this.accountName=r}static async create(e,t,r,i){let a=await p.create(e,i);return new s(a,t,r)}async save(e){try{await J.setPassword(this.serviceName,this.accountName,e)}catch(t){throw h(t)?c.createLibSecretError(t.message):t}await this.filePersistence.save("{}")}async load(){try{return await J.getPassword(this.serviceName,this.accountName)}catch(e){throw h(e)?c.createLibSecretError(e.message):e}}async delete(){try{return await this.filePersistence.delete(),await J.deletePassword(this.serviceName,this.accountName)}catch(e){throw h(e)?c.createLibSecretError(e.message):e}}async reloadNecessary(e){return this.filePersistence.reloadNecessary(e)}getFilePath(){return this.filePersistence.getFilePath()}getLogger(){return this.filePersistence.getLogger()}createForPersistenceValidation(){let e=`${Ve(this.filePersistence.getFilePath())}/test.cache`;return s.create(e,"persistenceValidationServiceName","persistencValidationAccountName")}};import ce from"path";var A=class{static get homeEnvVar(){return this.getEnvironmentVariable(u.ENVIRONMENT.HOME)}static get lognameEnvVar(){return this.getEnvironmentVariable(u.ENVIRONMENT.LOGNAME)}static get userEnvVar(){return this.getEnvironmentVariable(u.ENVIRONMENT.USER)}static get lnameEnvVar(){return this.getEnvironmentVariable(u.ENVIRONMENT.LNAME)}static get usernameEnvVar(){return this.getEnvironmentVariable(u.ENVIRONMENT.USERNAME)}static getEnvironmentVariable(e){return process.env[e]||""}static getEnvironmentPlatform(){return process.platform}static isWindowsPlatform(){return this.getEnvironmentPlatform()===F.WINDOWS}static isLinuxPlatform(){return this.getEnvironmentPlatform()===F.LINUX}static isMacPlatform(){return this.getEnvironmentPlatform()===F.MACOS}static isLinuxRootUser(){return typeof process.getuid!="function"?!1:process.getuid()===u.LINUX_ROOT_USER_GUID}static getUserRootDirectory(){return this.isWindowsPlatform()?this.getUserHomeDirOnWindows():this.getUserHomeDirOnUnix()}static getUserHomeDirOnWindows(){return this.getEnvironmentVariable(u.ENVIRONMENT.LOCAL_APPLICATION_DATA)}static getUserHomeDirOnUnix(){if(this.isWindowsPlatform())throw c.createNotSupportedError("Getting the user home directory for unix is not supported in windows");if(this.homeEnvVar)return this.homeEnvVar;let e=null;if(this.lognameEnvVar?e=this.lognameEnvVar:this.userEnvVar?e=this.userEnvVar:this.lnameEnvVar?e=this.lnameEnvVar:this.usernameEnvVar&&(e=this.usernameEnvVar),this.isMacPlatform())return e?ce.join("/Users",e):null;if(this.isLinuxPlatform())return this.isLinuxRootUser()?"/root":e?ce.join("/home",e):null;throw c.createNotSupportedError("Getting the user home directory for unix is not supported in windows")}};var Q=class{static async createPersistence(e){let t;if(A.isWindowsPlatform()){if(!e.cachePath||!e.dataProtectionScope)throw c.createPersistenceNotValidatedError("Cache path and/or data protection scope not provided for the FilePersistenceWithDataProtection cache plugin");t=await b.create(e.cachePath,T.CurrentUser,void 0,e.loggerOptions)}else if(A.isMacPlatform()){if(!e.cachePath||!e.serviceName||!e.accountName)throw c.createPersistenceNotValidatedError("Cache path, service name and/or account name not provided for the KeychainPersistence cache plugin");t=await x.create(e.cachePath,e.serviceName,e.accountName,e.loggerOptions)}else if(A.isLinuxPlatform()){if(!e.cachePath||!e.serviceName||!e.accountName)throw c.createPersistenceNotValidatedError("Cache path, service name and/or account name not provided for the LibSecretPersistence cache plugin");t=await _.create(e.cachePath,e.serviceName,e.accountName,e.loggerOptions)}else throw c.createNotSupportedError("The current environment is not supported by msal-node-extensions yet.");return await t.verifyPersistence().catch(async r=>{if(A.isLinuxPlatform()&&e.usePlaintextFileOnLinux){if(!e.cachePath)throw c.createPersistenceNotValidatedError("Cache path not provided for the FilePersistence cache plugin");if(t=await p.create(e.cachePath,e.loggerOptions),await t.verifyPersistence())return t;throw c.createPersistenceNotVerifiedError("Persistence could not be verified")}else throw r}),t}};import{msalNodeRuntime as d,ErrorStatus as y,LogLevel as O}from"@azure/msal-node-runtime";var Z="@azure/msal-node-extensions",D="5.2.2";function Fe(s){return`See https://aka.ms/msal.js.errors#${s} for details`}var m=class s extends Error{constructor(e,t,r){let i=t||(e?Fe(e):""),a=i?`${e}: ${i}`:e;super(a),Object.setPrototypeOf(this,s.prototype),this.errorCode=e||"",this.errorMessage=i||"",this.subError=r||"",this.name="AuthError"}setCorrelationId(e){this.correlationId=e}};var ee=class s extends m{constructor(e,t){super(e,t),this.name="ClientAuthError",Object.setPrototypeOf(this,s.prototype)}};function L(s,e){return new ee(s,e)}var V={LOGIN:"login",SELECT_ACCOUNT:"select_account",NONE:"none",CREATE:"create"},le="-",te=5,he=330,ue=50,ge="server-telemetry",re="|",I=",",fe="1",me="0",de="unknown_error",B={BEARER:"Bearer",POP:"pop"},Ee={NOT_APPLICABLE:"0"};var pe=",",Pe="|";function Me(s){let{skus:e,libraryName:t,libraryVersion:r,extensionName:i,extensionVersion:a}=s,o=new Map([[0,[t,r]],[2,[i,a]]]),n=[];if(e?.length){if(n=e.split(pe),n.length<4)return e}else n=Array.from({length:4},()=>Pe);return o.forEach((l,g)=>{l.length===2&&l[0]?.length&&l[1]?.length&&Ue({skuArr:n,index:g,skuName:l[0],skuVersion:l[1]})}),n.join(pe)}function Ue(s){let{skuArr:e,index:t,skuName:r,skuVersion:i}=s;t>=e.length||(e[t]=[r,i].join(Pe))}var H=class s{constructor(e,t){this.cacheOutcome=Ee.NOT_APPLICABLE,this.cacheManager=t,this.apiId=e.apiId,this.correlationId=e.correlationId,this.wrapperSKU=e.wrapperSKU||"",this.wrapperVer=e.wrapperVer||"",this.telemetryCacheKey=ge+le+e.clientId}generateCurrentRequestHeaderValue(){let e=`${this.apiId}${I}${this.cacheOutcome}`,t=[this.wrapperSKU,this.wrapperVer],r=this.getNativeBrokerErrorCode();r?.length&&t.push(`broker_error=${r}`);let i=t.join(I),a=this.getRegionDiscoveryFields(),o=[e,a].join(I);return[te,o,i].join(re)}generateLastRequestHeaderValue(){let e=this.getLastRequests(),t=s.maxErrorsToSend(e),r=e.failedRequests.slice(0,2*t).join(I),i=e.errors.slice(0,t).join(I),a=e.errors.length,o=t<a?fe:me,n=[a,o].join(I);return[te,e.cacheHits,r,i,n].join(re)}cacheFailedRequest(e){let t=this.getLastRequests();t.errors.length>=ue&&(t.failedRequests.shift(),t.failedRequests.shift(),t.errors.shift()),t.failedRequests.push(this.apiId,this.correlationId),e instanceof Error&&e&&e.toString()?e instanceof m?e.subError?t.errors.push(e.subError):e.errorCode?t.errors.push(e.errorCode):t.errors.push(e.toString()):t.errors.push(e.toString()):t.errors.push(de),this.cacheManager.setServerTelemetry(this.telemetryCacheKey,t,this.correlationId)}incrementCacheHits(){let e=this.getLastRequests();return e.cacheHits+=1,this.cacheManager.setServerTelemetry(this.telemetryCacheKey,e,this.correlationId),e.cacheHits}getLastRequests(){let e={failedRequests:[],errors:[],cacheHits:0};return this.cacheManager.getServerTelemetry(this.telemetryCacheKey,this.correlationId)||e}clearTelemetryCache(){let e=this.getLastRequests(),t=s.maxErrorsToSend(e),r=e.errors.length;if(t===r)this.cacheManager.removeItem(this.telemetryCacheKey,this.correlationId);else{let i={failedRequests:e.failedRequests.slice(t*2),errors:e.errors.slice(t),cacheHits:0};this.cacheManager.setServerTelemetry(this.telemetryCacheKey,i,this.correlationId)}}static maxErrorsToSend(e){let t,r=0,i=0,a=e.errors.length;for(t=0;t<a;t++){let o=e.failedRequests[2*t]||"",n=e.failedRequests[2*t+1]||"",l=e.errors[t]||"";if(i+=o.toString().length+n.toString().length+l.length+3,i<he)r+=1;else break}return r}getRegionDiscoveryFields(){let e=[];return e.push(this.regionUsed||""),e.push(this.regionSource||""),e.push(this.regionOutcome||""),e.join(",")}updateRegionDiscoveryMetadata(e){this.regionUsed=e.region_used,this.regionSource=e.region_source,this.regionOutcome=e.region_outcome}setCacheOutcome(e){this.cacheOutcome=e}setNativeBrokerErrorCode(e){let t=this.getLastRequests();t.nativeBrokerErrorCode=e,this.cacheManager.setServerTelemetry(this.telemetryCacheKey,t,this.correlationId)}getNativeBrokerErrorCode(){return this.getLastRequests().nativeBrokerErrorCode}clearNativeBrokerErrorCode(){let e=this.getLastRequests();delete e.nativeBrokerErrorCode,this.cacheManager.setServerTelemetry(this.telemetryCacheKey,e,this.correlationId)}static makeExtraSkuString(e){return Me(e)}};function De(s){if(s===0)return"UNTAG";let e="abcdefghijklmnopqrstuvwxyz0123456789****************************",t="*****";return t=[e[s>>24&63],e[s>>18&63],e[s>>12&63],e[s>>6&63],e[s>>0&63]].join(""),t}var $=class s extends m{constructor(e,t,r,i){let a=De(i),o=t?`${t} (Error Code: ${r}, Tag: ${a})`:`(Error Code: ${r}, Tag: ${a})`;super(e,o),this.name="PlatformBrokerError",this.statusCode=r,this.tag=a,Object.setPrototypeOf(this,s.prototype)}};var se=class s extends m{constructor(e){super(e),this.name="ClientConfigurationError",Object.setPrototypeOf(this,s.prototype)}};function ye(s){return new se(s)}var K=class s extends m{constructor(e,t,r,i,a){super(e,t,r),this.name="ServerError",this.errorNo=i,this.status=a,Object.setPrototypeOf(this,s.prototype)}};var W=class s extends m{constructor(e,t,r,i,a,o,n,l){super(e,t,r),Object.setPrototypeOf(this,s.prototype),this.timestamp=i||"",this.traceId=a||"",this.correlationId=o||"",this.claims=n||"",this.name="InteractionRequiredAuthError",this.errorNo=l}};var q="x-client-xtra-sku",we="resource";function Re(s){return s?new Date(Number(s)*1e3):new Date}var ie="no_account_found",Ne="no_network_connectivity",Ae="user_canceled",Se="platform_broker_error";var Ce="untrusted_authority";var oe=class{constructor(){let e={loggerCallback:()=>{},piiLoggingEnabled:!1};this.logger=new C(e,Z,D),this.isBrokerAvailable=!d.StartupError}setLogger(e){this.logger=new C(e,Z,D);let t=(r,i,a,o="")=>{switch(i){case O.Trace:a?this.logger.tracePii(r,o):this.logger.trace(r,o);break;case O.Debug:a?this.logger.tracePii(r,o):this.logger.trace(r,o);break;case O.Info:a?this.logger.infoPii(r,o):this.logger.info(r,o);break;case O.Warning:a?this.logger.warningPii(r,o):this.logger.warning(r,o);break;case O.Error:a?this.logger.errorPii(r,o):this.logger.error(r,o);break;case O.Fatal:a?this.logger.errorPii(r,o):this.logger.error(r,o);break;default:a?this.logger.infoPii(r,o):this.logger.info(r,o);break}};try{d.RegisterLogger(t,e.piiLoggingEnabled||!1)}catch(r){let i=this.wrapError(r);if(i)throw i}}async getAccountById(e,t){this.logger.trace("NativeBrokerPlugin - getAccountById called",t);let r=await this.readAccountById(e,t);return this.generateAccountInfo(r.account)}async getAllAccounts(e,t){return this.logger.trace("NativeBrokerPlugin - getAllAccounts called",t),new Promise((r,i)=>{let a=o=>{try{o.CheckError()}catch(l){let g=this.wrapError(l);if(g){i(g);return}}let n=[];o.accounts.forEach(l=>{n.push(this.generateAccountInfo(l))}),r(n)};try{d.DiscoverAccountsAsync(e,t,a)}catch(o){let n=this.wrapError(o);n&&i(n)}})}async acquireTokenSilent(e){this.logger.trace("NativeBrokerPlugin - acquireTokenSilent called",e.correlationId);let t=e;t.redirectUri||(t.redirectUri=this.chooseRedirectUriByPlatform(t),this.logger.info("NativeBrokerPlugin - No Redirect URI provided, using default",t.correlationId));let r=this.generateRequestParameters(t),i=await this.getAccount(t);return new Promise((a,o)=>{let n=l=>{try{l.CheckError()}catch(R){let w=this.wrapError(R);if(w){o(w);return}}let g=this.getAuthenticationResult(t,l);a(g)};try{i?d.AcquireTokenSilentlyAsync(r,t.correlationId,i,n):d.SignInSilentlyAsync(r,t.correlationId,n)}catch(l){let g=this.wrapError(l);g&&o(g)}})}async acquireTokenInteractive(e,t){this.logger.trace("NativeBrokerPlugin - acquireTokenInteractive called",e.correlationId);let r=e;r.redirectUri||(r.redirectUri=this.chooseRedirectUriByPlatform(r),this.logger.info("NativeBrokerPlugin - No Redirect URI provided, using default",r.correlationId));let i=this.generateRequestParameters(r),a=await this.getAccount(r),o=t||Buffer.from([0]);return new Promise((n,l)=>{let g=R=>{try{R.CheckError()}catch(ke){let ae=this.wrapError(ke);if(ae){l(ae);return}}let w=this.getAuthenticationResult(r,R);n(w)};try{switch(r.prompt){case V.LOGIN:case V.SELECT_ACCOUNT:case V.CREATE:this.logger.info("Calling native interop SignInInteractively API",r.correlationId);let R=r.loginHint||"";d.SignInInteractivelyAsync(o,i,r.correlationId,R,g);break;case V.NONE:a?(this.logger.info("Calling native interop AcquireTokenSilently API",r.correlationId),d.AcquireTokenSilentlyAsync(i,r.correlationId,a,g)):(this.logger.info("Calling native interop SignInSilently API",r.correlationId),d.SignInSilentlyAsync(i,r.correlationId,g));break;default:if(a)this.logger.info("Calling native interop AcquireTokenInteractively API",r.correlationId),d.AcquireTokenInteractivelyAsync(o,i,r.correlationId,a,g);else{this.logger.info("Calling native interop SignIn API",r.correlationId);let w=r.loginHint||"";d.SignInAsync(o,i,r.correlationId,w,g)}break}}catch(R){let w=this.wrapError(R);w&&l(w)}})}async signOut(e){this.logger.trace("NativeBrokerPlugin - signOut called",e.correlationId);let t=await this.getAccount(e);if(!t)throw L(ie);return new Promise((r,i)=>{let a=o=>{try{o.CheckError()}catch(n){let l=this.wrapError(n);if(l){i(l);return}}r()};try{d.SignOutSilentlyAsync(e.clientId,e.correlationId,t,a)}catch(o){let n=this.wrapError(o);n&&i(n)}})}async getAccount(e){return e.accountId?(await this.readAccountById(e.accountId,e.correlationId)).account:null}async readAccountById(e,t){return this.logger.trace("NativeBrokerPlugin - readAccountById called",t),new Promise((r,i)=>{let a=o=>{try{o.CheckError()}catch(n){let l=this.wrapError(n);if(l){i(l);return}}r(o)};try{d.ReadAccountByIdAsync(e,t,a)}catch(o){let n=this.wrapError(o);n&&i(n)}})}generateRequestParameters(e){this.logger.trace("NativeBrokerPlugin - generateRequestParameters called",e.correlationId);let t=new d.AuthParameters;try{if(t.CreateAuthParameters(e.clientId,e.authority),t.SetRedirectUri(e.redirectUri),t.SetRequestedScopes(e.scopes.join(" ")),e.claims&&t.SetDecodedClaims(e.claims),e.authenticationScheme===B.POP){if(!e.resourceRequestMethod||!e.resourceRequestUri)throw new Error("Authentication Scheme set to POP but one or more of the following parameters are missing: resourceRequestMethod, resourceRequestUri");let i=new URL(e.resourceRequestUri);t.SetPopParams(e.resourceRequestMethod,i.host,i.pathname,e.shrNonce||"")}e.resource&&t.SetAdditionalParameter(we,e.resource),e.extraParameters&&Object.entries(e.extraParameters).forEach(([i,a])=>{t.SetAdditionalParameter(i,a)});let r=e.extraParameters&&e.extraParameters[q]?.length?e.extraParameters[q]:"";t.SetAdditionalParameter(q,H.makeExtraSkuString({skus:r,extensionName:"msal.node.ext",extensionVersion:D}))}catch(r){let i=this.wrapError(r);if(i)throw i}return t}chooseRedirectUriByPlatform(e){this.logger.trace("NativeBrokerPlugin - chooseRedirectUriByPlatform called",e.correlationId);let t;switch(process.platform){case"darwin":t="msauth.com.msauth.unsignedapp://auth";break;case"win32":t=`ms-appx-web://Microsoft.AAD.BrokerPlugin/${e.clientId}`;break;default:t="https://login.microsoftonline.com/common/oauth2/nativeclient"}return t}getAuthenticationResult(e,t){this.logger.trace("NativeBrokerPlugin - getAuthenticationResult called",e.correlationId);let r=!1;try{r=!!JSON.parse(t.telemetryData).is_cache}catch{this.logger.error("NativeBrokerPlugin: getAuthenticationResult - Error parsing telemetry data. Could not determine if response came from cache.",e.correlationId)}let i;try{i=JSON.parse(t.idToken)}catch{throw new Error("Unable to parse idToken claims")}let a=this.generateAccountInfo(t.account,i),o,n;return t.isPopAuthorization?(o=t.authorizationHeader.split(" ")[1],n=B.POP):(o=t.accessToken,n=B.BEARER),{authority:e.authority,uniqueId:i.oid||i.sub||"",tenantId:i.tid||"",scopes:t.grantedScopes.split(" "),account:a,idToken:t.rawIdToken,idTokenClaims:i,accessToken:o,fromCache:r,expiresOn:Re(t.expiresOn),tokenType:n,correlationId:e.correlationId,fromPlatformBroker:!0,...e.resource&&{resource:e.resource}}}generateAccountInfo(e,t){return this.logger.trace("NativeBrokerPlugin - generateAccountInfo called",""),{homeAccountId:e.homeAccountId,environment:e.environment,tenantId:e.realm,username:e.username,localAccountId:e.localAccountId,name:e.displayName,idTokenClaims:t,nativeAccountId:e.accountId}}isMsalRuntimeError(e){return e.hasOwnProperty("errorCode")||e.hasOwnProperty("errorStatus")||e.hasOwnProperty("errorContext")||e.hasOwnProperty("errorTag")}wrapError(e){if(e&&typeof e=="object"&&this.isMsalRuntimeError(e)){let{errorCode:t,errorStatus:r,errorContext:i,errorTag:a}=e,o=new $(y[r],i,t,a),n;switch(r){case y.InteractionRequired:case y.AccountUnusable:n=new W(E.INTERATION_REQUIRED_ERROR_CODE,o.message);break;case y.NoNetwork:case y.NetworkTemporarilyUnavailable:n=L(Ne);break;case y.ServerTemporarilyUnavailable:n=new K(E.SERVER_UNAVAILABLE,o.message);break;case y.UserCanceled:n=L(Ae);break;case y.AuthorityUntrusted:n=ye(Ce);break;case y.UserSwitched:return null;case y.AccountNotFound:n=L(ie);break;default:n=L(Se)}return n.platformBrokerError=o,n}throw e}};export{T as DataProtectionScope,A as Environment,p as FilePersistence,b as FilePersistenceWithDataProtection,x as KeychainPersistence,_ as LibSecretPersistence,oe as NativeBrokerPlugin,G as PersistenceCachePlugin,Q as PersistenceCreator};
|
|
8
|
+
/*! Bundled license information:
|
|
9
|
+
|
|
10
|
+
@azure/msal-node-extensions/dist/utils/Constants.mjs:
|
|
11
|
+
@azure/msal-node-extensions/dist/error/PersistenceError.mjs:
|
|
12
|
+
@azure/msal-node-extensions/dist/utils/TypeGuards.mjs:
|
|
13
|
+
@azure/msal-node-extensions/dist/lock/CrossPlatformLock.mjs:
|
|
14
|
+
@azure/msal-node-extensions/dist/persistence/PersistenceCachePlugin.mjs:
|
|
15
|
+
@azure/msal-node-extensions/dist/persistence/BasePersistence.mjs:
|
|
16
|
+
@azure/msal-node-extensions/dist/persistence/FilePersistence.mjs:
|
|
17
|
+
@azure/msal-node-extensions/dist/Dpapi.mjs:
|
|
18
|
+
@azure/msal-node-extensions/dist/persistence/DataProtectionScope.mjs:
|
|
19
|
+
@azure/msal-node-extensions/dist/persistence/FilePersistenceWithDataProtection.mjs:
|
|
20
|
+
@azure/msal-node-extensions/dist/persistence/KeychainPersistence.mjs:
|
|
21
|
+
@azure/msal-node-extensions/dist/persistence/LibSecretPersistence.mjs:
|
|
22
|
+
@azure/msal-node-extensions/dist/utils/Environment.mjs:
|
|
23
|
+
@azure/msal-node-extensions/dist/persistence/PersistenceCreator.mjs:
|
|
24
|
+
@azure/msal-node-extensions/dist/packageMetadata.mjs:
|
|
25
|
+
@azure/msal-node-extensions/dist/broker/NativeBrokerPlugin.mjs:
|
|
26
|
+
@azure/msal-node-extensions/dist/index.mjs:
|
|
27
|
+
(*! @azure/msal-node-extensions v5.2.2 2026-05-19 *)
|
|
28
|
+
|
|
29
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/logger/Logger.mjs:
|
|
30
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/AuthError.mjs:
|
|
31
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/ClientAuthError.mjs:
|
|
32
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/utils/Constants.mjs:
|
|
33
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/telemetry/server/ServerTelemetryManager.mjs:
|
|
34
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/PlatformBrokerError.mjs:
|
|
35
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/ClientConfigurationError.mjs:
|
|
36
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/ServerError.mjs:
|
|
37
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/InteractionRequiredAuthError.mjs:
|
|
38
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/constants/AADServerParamKeys.mjs:
|
|
39
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/utils/TimeUtils.mjs:
|
|
40
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/ClientAuthErrorCodes.mjs:
|
|
41
|
+
@azure/msal-node-extensions/dist/lib/msal-common/dist/error/ClientConfigurationErrorCodes.mjs:
|
|
42
|
+
(*! @azure/msal-node-extensions v5.2.2 2026-05-19 *)
|
|
43
|
+
(*! @azure/msal-common v16.6.2 2026-05-19 *)
|
|
44
|
+
*/
|
|
45
|
+
//# sourceMappingURL=dist-7N5TXK2L.js.map
|