Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/microsoft-graph-client

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/microsoft-graph-client - npm Package Compare versions

Comparing version 2.2.0-Preview.1 to 2.2.0

2

lib/es/Version.d.ts

@@ -10,2 +10,2 @@ /**

*/
export declare const PACKAGE_VERSION = "2.2.0-Preview.1";
export declare const PACKAGE_VERSION = "2.2.0";

@@ -12,3 +12,3 @@ /**

*/
export const PACKAGE_VERSION = "2.2.0-Preview.1";
export const PACKAGE_VERSION = "2.2.0";
//# sourceMappingURL=Version.js.map

@@ -1,1 +0,1 @@

function e(e,t,r,s){return new(r||(r=Promise))(function(n,i){function o(e){try{d(s.next(e))}catch(e){i(e)}}function a(e){try{d(s.throw(e))}catch(e){i(e)}}function d(e){e.done?n(e.value):new r(function(t){t(e.value)}).then(o,a)}d((s=s.apply(e,t||[])).next())})}var t;!function(e){e.GET="GET",e.PATCH="PATCH",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(t||(t={}));class r{constructor(e){if(this.requests=new Map,void 0!==e){const t=r.requestLimit;if(e.length>t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}for(const t of e)this.addRequest(t)}}static validateDependencies(e){if(0===e.size){const e=new Error("Empty requests map, Please provide at least one request.");throw e.name="Empty Requests Error",e}return(e=>{const t=e.entries();let r=t.next();for(;!r.done;){const e=r.value[1];if(void 0!==e.dependsOn&&e.dependsOn.length>0)return!1;r=t.next()}return!0})(e)||(e=>{const t=e.entries();let r=t.next();const s=r.value[1];if(void 0!==s.dependsOn&&s.dependsOn.length>0)return!1;let n=r;for(r=t.next();!r.done;){const e=r.value[1];if(void 0===e.dependsOn||1!==e.dependsOn.length||e.dependsOn[0]!==n.value[1].id)return!1;n=r,r=t.next()}return!0})(e)||(e=>{const t=e.entries();let r=t.next();const s=r.value[1];let n;if(void 0===s.dependsOn||0===s.dependsOn.length)n=s.id;else{if(1!==s.dependsOn.length)return!1;{const t=s.dependsOn[0];if(t===s.id||!e.has(t))return!1;n=t}}for(r=t.next();!r.done;){const e=r.value[1];if((void 0===e.dependsOn||0===e.dependsOn.length)&&n!==e.id)return!1;if(void 0!==e.dependsOn&&0!==e.dependsOn.length){if(1===e.dependsOn.length&&(e.id===n||e.dependsOn[0]!==n))return!1;if(e.dependsOn.length>1)return!1}r=t.next()}return!0})(e)}static getRequestData(s){return e(this,void 0,void 0,function*(){const e={url:""},n=new RegExp("^https?://");e.url=n.test(s.url)?"/"+s.url.split(/.*?\/\/.*?\//)[1]:s.url,e.method=s.method;const i={};return s.headers.forEach((e,t)=>{i[t]=e}),Object.keys(i).length&&(e.headers=i),s.method!==t.PATCH&&s.method!==t.POST&&s.method!==t.PUT||(e.body=yield r.getRequestBody(s)),e})}static getRequestBody(t){return e(this,void 0,void 0,function*(){let e,r=!1;try{const s=t.clone();e=yield s.json(),r=!0}catch(e){}if(!r)try{if("undefined"!=typeof Blob){const r=yield t.blob(),s=new FileReader;e=yield new Promise(e=>{s.addEventListener("load",()=>{const t=s.result,r=new RegExp("^s*data:(.+?/.+?(;.+?=.+?)*)?(;base64)?,(.*)s*$").exec(t);e(r[4])},!1),s.readAsDataURL(r)})}else if("undefined"!=typeof Buffer){e=(yield t.buffer()).toString("base64")}r=!0}catch(e){}return e})}addRequest(e){const t=r.requestLimit;if(""===e.id){const e=new Error("Id for a request is empty, Please provide an unique id");throw e.name="Empty Id For Request",e}if(this.requests.size===t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}if(this.requests.has(e.id)){const t=new Error(`Adding request with duplicate id ${e.id}, Make the id of the requests unique`);throw t.name="Duplicate RequestId Error",t}return this.requests.set(e.id,e),e.id}removeRequest(e){const t=this.requests.delete(e),r=this.requests.entries();let s=r.next();for(;!s.done;){const t=s.value[1].dependsOn;if(void 0!==t){const r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&delete s.value[1].dependsOn}s=r.next()}return t}getContent(){return e(this,void 0,void 0,function*(){const e=[],t={requests:e},s=this.requests.entries();let n=s.next();if(n.done){const e=new Error("No requests added yet, Please add at least one request.");throw e.name="Empty Payload",e}if(!r.validateDependencies(this.requests)){const e=new Error("Invalid dependency found, Dependency should be:\n1. Parallel - no individual request states a dependency in the dependsOn property.\n2. Serial - all individual requests depend on the previous individual request.\n3. Same - all individual requests that state a dependency in the dependsOn property, state the same dependency.");throw e.name="Invalid Dependency",e}for(;!n.done;){const t=n.value[1],i=yield r.getRequestData(t.request);if(void 0!==i.body&&(void 0===i.headers||void 0===i.headers["content-type"])){const e=new Error(`Content-type header is not mentioned for request #${t.id}, For request having body, Content-type header should be mentioned`);throw e.name="Invalid Content-type header",e}i.id=t.id,void 0!==t.dependsOn&&t.dependsOn.length>0&&(i.dependsOn=t.dependsOn),e.push(i),n=s.next()}return t.requests=e,t})}addDependency(e,t){if(!this.requests.has(e)){const t=new Error(`Dependent ${e} does not exists, Please check the id`);throw t.name="Invalid Dependent",t}if(void 0!==t&&!this.requests.has(t)){const e=new Error(`Dependency ${t} does not exists, Please check the id`);throw e.name="Invalid Dependency",e}if(void 0!==t){const r=this.requests.get(e);if(void 0===r.dependsOn&&(r.dependsOn=[]),-1!==r.dependsOn.indexOf(t)){const r=new Error(`Dependency ${t} is already added for the request ${e}`);throw r.name="Duplicate Dependency",r}r.dependsOn.push(t)}else{const r=this.requests.entries();let s,n=r.next();for(;!n.done&&n.value[1].id!==e;)s=n,n=r.next();if(void 0===s){const e=new Error(`Can't add dependency ${t}, There is only a dependent request in the batch`);throw e.name="Invalid Dependency Addition",e}{const t=s.value[0];if(void 0===n.value[1].dependsOn&&(n.value[1].dependsOn=[]),-1!==n.value[1].dependsOn.indexOf(t)){const r=new Error(`Dependency ${t} is already added for the request ${e}`);throw r.name="Duplicate Dependency",r}n.value[1].dependsOn.push(t)}}}removeDependency(e,t){const r=this.requests.get(e);if(void 0===r||void 0===r.dependsOn||0===r.dependsOn.length)return!1;if(void 0!==t){const e=r.dependsOn.indexOf(t);return-1!==e&&(r.dependsOn.splice(e,1),!0)}return delete r.dependsOn,!0}}r.requestLimit=20;class s{constructor(e){this.responses=new Map,this.update(e)}createResponseObject(e){const t=e.body,r={};if(r.status=e.status,void 0!==e.statusText&&(r.statusText=e.statusText),r.headers=e.headers,void 0!==r.headers&&void 0!==r.headers["Content-Type"]&&"application/json"===r.headers["Content-Type"].split(";")[0]){const e=JSON.stringify(t);return new Response(e,r)}return new Response(t,r)}update(e){this.nextLink=e["@odata.nextLink"];const t=e.responses;for(let e=0,r=t.length;e<r;e++)this.responses.set(t[e].id,this.createResponseObject(t[e]))}getResponseById(e){return this.responses.get(e)}getResponses(){return this.responses}*getResponsesIterator(){const e=this.responses.entries();let t=e.next();for(;!t.done;)yield t.value,t=e.next()}}class n{constructor(e=[]){this.middlewareOptions=new Map;for(const t of e){const e=t.constructor;this.middlewareOptions.set(e,t)}}getMiddlewareOptions(e){return this.middlewareOptions.get(e)}setMiddlewareOptions(e,t){this.middlewareOptions.set(e,t)}}const i=()=>{let e="";for(let t=0;t<32;t++)8!==t&&12!==t&&16!==t&&20!==t||(e+="-"),e+=Math.floor(16*Math.random()).toString(16);return e},o=(e,t,r)=>{let s=null;if("undefined"!=typeof Request&&e instanceof Request)s=e.headers.get(r);else if(void 0!==t&&void 0!==t.headers)if("undefined"!=typeof Headers&&t.headers instanceof Headers)s=t.headers.get(r);else if(t.headers instanceof Array){const e=t.headers;for(let t=0,n=e.length;t<n;t++)if(e[t][0]===r){s=e[t][1];break}}else void 0!==t.headers[r]&&(s=t.headers[r]);return s},a=(e,t,r,s)=>{if("undefined"!=typeof Request&&e instanceof Request)e.headers.set(r,s);else if(void 0!==t)if(void 0===t.headers)t.headers=new Headers({[r]:s});else if("undefined"!=typeof Headers&&t.headers instanceof Headers)t.headers.set(r,s);else if(t.headers instanceof Array){let e=0;const n=t.headers.length;for(;e<n;e++){const n=t.headers[e];if(n[0]===r){n[1]=s;break}}e===n&&t.headers.push([r,s])}else Object.assign(t.headers,{[r]:s})},d=(e,t,r,s)=>{"undefined"!=typeof Request&&e instanceof Request?e.headers.append(r,s):void 0!==t&&(void 0===t.headers?t.headers=new Headers({[r]:s}):"undefined"!=typeof Headers&&t.headers instanceof Headers?t.headers.append(r,s):t.headers instanceof Array?t.headers.push([r,s]):void 0===t.headers?t.headers={[r]:s}:void 0===t.headers[r]?t.headers[r]=s:t.headers[r]+=`, ${s}`)},c=(t,r)=>e(void 0,void 0,void 0,function*(){const e=r.headers.get("Content-Type")?yield r.blob():yield Promise.resolve(void 0),{method:s,headers:n,referrer:i,referrerPolicy:o,mode:a,credentials:d,cache:c,redirect:h,integrity:u,keepalive:l,signal:p}=r;return new Request(t,{method:s,headers:n,body:e,referrer:i,referrerPolicy:o,mode:a,credentials:d,cache:c,redirect:h,integrity:u,keepalive:l,signal:p})});class h{constructor(e,t){this.authenticationProvider=e,this.authenticationProviderOptions=t}}var u;!function(e){e[e.NONE=0]="NONE",e[e.REDIRECT_HANDLER_ENABLED=1]="REDIRECT_HANDLER_ENABLED",e[e.RETRY_HANDLER_ENABLED=2]="RETRY_HANDLER_ENABLED",e[e.AUTHENTICATION_HANDLER_ENABLED=4]="AUTHENTICATION_HANDLER_ENABLED"}(u||(u={}));class l{constructor(){this.featureUsage=u.NONE}static updateFeatureUsageFlag(e,t){let r;e.middlewareControl instanceof n?r=e.middlewareControl.getMiddlewareOptions(l):e.middlewareControl=new n,void 0===r&&(r=new l,e.middlewareControl.setMiddlewareOptions(l,r)),r.setFeatureUsage(t)}setFeatureUsage(e){this.featureUsage=this.featureUsage|e}getFeatureUsage(){return this.featureUsage.toString(16)}}class p{constructor(e){this.authenticationProvider=e}execute(t){return e(this,void 0,void 0,function*(){try{let e,r,s;t.middlewareControl instanceof n&&(e=t.middlewareControl.getMiddlewareOptions(h)),void 0!==e&&(r=e.authenticationProvider,s=e.authenticationProviderOptions),void 0===r&&(r=this.authenticationProvider);const i=`Bearer ${yield r.getAccessToken(s)}`;return d(t.request,t.options,p.AUTHORIZATION_HEADER,i),l.updateFeatureUsageFlag(t,u.AUTHENTICATION_HANDLER_ENABLED),yield this.nextMiddleware.execute(t)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}p.AUTHORIZATION_HEADER="Authorization";class f{execute(t){return e(this,void 0,void 0,function*(){try{return void(t.response=yield fetch(t.request,t.options))}catch(e){throw e}})}}class y{constructor(e=y.DEFAULT_DELAY,t=y.DEFAULT_MAX_RETRIES,r=y.DEFAULT_SHOULD_RETRY){if(e>y.MAX_DELAY&&t>y.MAX_MAX_RETRIES){const e=new Error(`Delay and MaxRetries should not be more than ${y.MAX_DELAY} and ${y.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e>y.MAX_DELAY){const e=new Error(`Delay should not be more than ${y.MAX_DELAY}`);throw e.name="MaxLimitExceeded",e}if(t>y.MAX_MAX_RETRIES){const e=new Error(`MaxRetries should not be more than ${y.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e<0&&t<0){const e=new Error("Delay and MaxRetries should not be negative");throw e.name="MinExpectationNotMet",e}if(e<0){const e=new Error("Delay should not be negative");throw e.name="MinExpectationNotMet",e}if(t<0){const e=new Error("MaxRetries should not be negative");throw e.name="MinExpectationNotMet",e}this.delay=Math.min(e,y.MAX_DELAY),this.maxRetries=Math.min(t,y.MAX_MAX_RETRIES),this.shouldRetry=r}getMaxDelay(){return y.MAX_DELAY}}y.DEFAULT_DELAY=3,y.DEFAULT_MAX_RETRIES=3,y.MAX_DELAY=180,y.MAX_MAX_RETRIES=10,y.DEFAULT_SHOULD_RETRY=()=>!0;class m{constructor(e=new y){this.options=e}isRetry(e){return-1!==m.RETRY_STATUS_CODES.indexOf(e.status)}isBuffered(e,r){const s="string"==typeof e?r.method:e.method;if(s===t.PUT||s===t.PATCH||s===t.POST){if("application/octet-stream"===o(e,r,"Content-Type"))return!1}return!0}getDelay(e,t,r){const s=()=>Number(Math.random().toFixed(3)),n=void 0!==e.headers?e.headers.get(m.RETRY_AFTER_HEADER):null;let i;return i=null!==n?Number.isNaN(Number(n))?Math.round((new Date(n).getTime()-Date.now())/1e3):Number(n):t>=2?this.getExponentialBackOffTime(t)+r+s():r+s(),Math.min(i,this.options.getMaxDelay()+s())}getExponentialBackOffTime(e){return Math.round(.5*(Math.pow(2,e)-1))}sleep(t){return e(this,void 0,void 0,function*(){const e=1e3*t;return new Promise(t=>setTimeout(t,e))})}getOptions(e){let t;return e.middlewareControl instanceof n&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor)),void 0===t&&(t=Object.assign(new y,this.options)),t}executeWithRetry(t,r,s){return e(this,void 0,void 0,function*(){try{if(yield this.nextMiddleware.execute(t),r<s.maxRetries&&this.isRetry(t.response)&&this.isBuffered(t.request,t.options)&&s.shouldRetry(s.delay,r,t.request,t.options,t.response)){++r,a(t.request,t.options,m.RETRY_ATTEMPT_HEADER,r.toString());const e=this.getDelay(t.response,r,s.delay);return yield this.sleep(e),yield this.executeWithRetry(t,r,s)}return}catch(e){throw e}})}execute(t){return e(this,void 0,void 0,function*(){try{const e=0,r=this.getOptions(t);return l.updateFeatureUsageFlag(t,u.RETRY_HANDLER_ENABLED),yield this.executeWithRetry(t,e,r)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}m.RETRY_STATUS_CODES=[429,503,504],m.RETRY_ATTEMPT_HEADER="Retry-Attempt",m.RETRY_AFTER_HEADER="Retry-After";const E="v1.0",g="https://graph.microsoft.com/",w=new Set(["graph.microsoft.com","graph.microsoft.us","dod-graph.microsoft.us","graph.microsoft.de","microsoftgraph.chinacloudapi.cn"]),v=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],R=e=>{const t=e=>e.replace(/\/+$/,""),r=e=>e.replace(/^\/+/,"");return Array.prototype.slice.call(e).reduce((e,s)=>[t(e),r(s)].join("/"))},A=e=>{const t=e&&e.constructor&&e.constructor.name;if("Buffer"===t||"Blob"===t||"File"===t||"FormData"===t||"string"==typeof e)return e;if("ArrayBuffer"===t)e=Buffer.from(e);else if("Int8Array"===t||"Int16Array"===t||"Int32Array"===t||"Uint8Array"===t||"Uint16Array"===t||"Uint32Array"===t||"Uint8ClampedArray"===t||"Float32Array"===t||"Float64Array"===t||"DataView"===t)e=Buffer.from(e.buffer);else try{e=JSON.stringify(e)}catch(e){throw new Error("Unable to stringify the content")}return e},T=e=>{if(-1!==(e=e.toLowerCase()).indexOf("https://")){const t=(e=e.replace("https://","")).indexOf(":"),r=e.indexOf("/");let s="";if(-1!==r)return-1!==t&&t<r?(s=e.substring(0,t),w.has(s)):(s=e.substring(0,r),w.has(s))}return!1},O="2.2.0-Preview.1";class x{execute(t){return e(this,void 0,void 0,function*(){try{const e="string"==typeof t.request?t.request:t.request.url;if(T(e)){let e=o(t.request,t.options,x.CLIENT_REQUEST_ID_HEADER);e||(e=i(),a(t.request,t.options,x.CLIENT_REQUEST_ID_HEADER,e));let r,s=`${x.PRODUCT_NAME}/${O}`;if(t.middlewareControl instanceof n&&(r=t.middlewareControl.getMiddlewareOptions(l)),r){const e=r.getFeatureUsage();s+=` (${x.FEATURE_USAGE_STRING}=${e})`}d(t.request,t.options,x.SDK_VERSION_HEADER,s)}else delete t.options.headers[x.CLIENT_REQUEST_ID_HEADER],delete t.options.headers[x.SDK_VERSION_HEADER];return yield this.nextMiddleware.execute(t)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}x.CLIENT_REQUEST_ID_HEADER="client-request-id",x.SDK_VERSION_HEADER="SdkVersion",x.PRODUCT_NAME="graph-js",x.FEATURE_USAGE_STRING="featureUsage";class D{constructor(e=D.DEFAULT_MAX_REDIRECTS,t=D.DEFAULT_SHOULD_RETRY){if(e>D.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${D.MAX_MAX_REDIRECTS}`);throw e.name="MaxLimitExceeded",e}if(e<0){const e=new Error("MaxRedirects should not be negative");throw e.name="MinExpectationNotMet",e}this.maxRedirects=e,this.shouldRedirect=t}}D.DEFAULT_MAX_REDIRECTS=5,D.MAX_MAX_REDIRECTS=20,D.DEFAULT_SHOULD_RETRY=()=>!0;class P{constructor(e=new D){this.options=e}isRedirect(e){return-1!==P.REDIRECT_STATUS_CODES.indexOf(e.status)}hasLocationHeader(e){return e.headers.has(P.LOCATION_HEADER)}getLocationHeader(e){return e.headers.get(P.LOCATION_HEADER)}isRelativeURL(e){return-1===e.indexOf("://")}shouldDropAuthorizationHeader(e,t){const r=/^[A-Za-z].+?:\/\/.+?(?=\/|$)/,s=r.exec(e);let n,i;null!==s&&(n=s[0]);const o=r.exec(t);return null!==o&&(i=o[0]),void 0!==n&&void 0!==i&&n!==i}updateRequestUrl(t,r){return e(this,void 0,void 0,function*(){r.request="string"==typeof r.request?t:yield c(t,r.request)})}getOptions(e){let t;return e.middlewareControl instanceof n&&(t=e.middlewareControl.getMiddlewareOptions(D)),void 0===t&&(t=Object.assign(new D,this.options)),t}executeWithRedirect(r,s,n){return e(this,void 0,void 0,function*(){try{yield this.nextMiddleware.execute(r);const e=r.response;if(!(s<n.maxRedirects&&this.isRedirect(e)&&this.hasLocationHeader(e)&&n.shouldRedirect(e)))return;if(++s,e.status===P.STATUS_CODE_SEE_OTHER)r.options.method=t.GET,delete r.options.body;else{const t=this.getLocationHeader(e);!this.isRelativeURL(t)&&this.shouldDropAuthorizationHeader(e.url,t)&&delete r.options.headers[P.AUTHORIZATION_HEADER],yield this.updateRequestUrl(t,r)}yield this.executeWithRedirect(r,s,n)}catch(e){throw e}})}execute(t){return e(this,void 0,void 0,function*(){try{const e=0,r=this.getOptions(t);return t.options.redirect=P.MANUAL_REDIRECT,l.updateFeatureUsageFlag(t,u.REDIRECT_HANDLER_ENABLED),yield this.executeWithRedirect(t,e,r)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}P.REDIRECT_STATUS_CODES=[301,302,303,307,308],P.STATUS_CODE_SEE_OTHER=303,P.LOCATION_HEADER="Location",P.AUTHORIZATION_HEADER="Authorization",P.MANUAL_REDIRECT="manual";const C=()=>"object"==typeof process&&"function"==typeof require;class _{static getDefaultMiddlewareChain(e){const t=[],r=new p(e),s=new m(new y),n=new x,i=new f;if(t.push(r),t.push(s),C()){const e=new P(new D);t.push(e)}return t.push(n),t.push(i),t}}var M;!function(e){e[e.MANUAL=0]="MANUAL",e[e.RANDOM=1]="RANDOM"}(M||(M={}));class L{constructor(e=M.RANDOM,t="Some error Happened",r,s,n){if(this.chaosStrategy=e,this.statusCode=r,this.statusMessage=t,this.chaosPercentage=void 0!==s?s:10,this.responseBody=n,this.chaosPercentage>100)throw new Error("Error Pecentage can not be more than 100")}}const b={GET:[429,500,502,503,504],POST:[429,500,502,503,504,507],PUT:[429,500,502,503,504,507],PATCH:[429,500,502,503,504],DELETE:[429,500,502,503,504,507]},S={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};class U{constructor(e=new L,t){this.options=e,this.manualMap=t}createResponseHeaders(e,t,r){const s=new Headers;return s.append("Cache-Control","no-store"),s.append("request-id",t),s.append("client-request-id",t),s.append("x-ms-ags-diagnostic",""),s.append("Date",r),s.append("Strict-Transport-Security",""),429===e&&s.append("retry-after","300"),s}createResponseBody(e,t,r,s,n){if(n)return n;let i;if(e>=400){i={error:{code:S[e],message:t,innerError:{"request-id":r,date:s}}}}else i={};return i}createResponse(e,t){try{let r,s,n,o;const a=t.request;n=i(),o=new Date,s=this.createResponseHeaders(e.statusCode,n,o.toString()),r=this.createResponseBody(e.statusCode,e.statusMessage,n,o.toString(),e.responseBody);const d={url:a,status:e.statusCode,statusText:e.statusMessage,headers:s};t.response=new Response(r,d)}catch(e){throw e}}sendRequest(t,r){return e(this,void 0,void 0,function*(){try{this.setStatusCode(t,r.request,r.options.method),t.statusCode?this.createResponse(t,r):yield this.nextMiddleware.execute(r)}catch(e){throw e}})}getRandomStatusCode(e){try{const t=b[e];return t[Math.floor(Math.random()*t.length)]}catch(e){throw e}}getRelativeURL(e){const t=/https?:\/\/graph\.microsoft\.com\/[^/]+(.+?)(\?|$)/;let r;return null!==t.exec(e)&&(r=t.exec(e)[1]),r}setStatusCode(e,t,r){try{if(e.chaosStrategy===M.MANUAL){if(void 0===e.statusCode){const s=this.getRelativeURL(t);void 0!==this.manualMap.get(s)?void 0!==this.manualMap.get(s).get(r)&&(e.statusCode=this.manualMap.get(s).get(r)):this.manualMap.forEach((t,n)=>{new RegExp(n+"$").test(s)&&void 0!==this.manualMap.get(n).get(r)&&(e.statusCode=this.manualMap.get(n).get(r))})}}else Math.floor(100*Math.random())<e.chaosPercentage&&(e.statusCode=this.getRandomStatusCode(r))}catch(e){throw e}}getOptions(e){let t;return e.middlewareControl instanceof n&&(t=e.middlewareControl.getMiddlewareOptions(L)),void 0===t&&(t=Object.assign(new L,this.options)),t}execute(t){return e(this,void 0,void 0,function*(){try{const e=this.getOptions(t);return yield this.sendRequest(e,t)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}class N{constructor(e=-1,t=-1){this.minValue=e,this.maxValue=t}}class q{constructor(e,t,r,s={}){this.DEFAULT_FILE_SIZE=5242880,this.client=e,this.file=t,void 0===s.rangeSize&&(s.rangeSize=this.DEFAULT_FILE_SIZE),this.options=s,this.uploadSession=r,this.nextRange=new N(0,this.options.rangeSize-1)}static createUploadSession(t,r,s,n={}){return e(this,void 0,void 0,function*(){try{const e=yield t.api(r).headers(n).post(s);return{url:e.uploadUrl,expiry:new Date(e.expirationDateTime)}}catch(e){throw e}})}parseRange(e){const t=e[0];if(void 0===t||""===t)return new N;const r=t.split("-"),s=parseInt(r[0],10);let n=parseInt(r[1],10);return Number.isNaN(n)&&(n=this.file.size-1),new N(s,n)}updateTaskStatus(e){this.uploadSession.expiry=new Date(e.expirationDateTime),this.nextRange=this.parseRange(e.nextExpectedRanges)}getNextRange(){if(-1===this.nextRange.minValue)return this.nextRange;const e=this.nextRange.minValue;let t=e+this.options.rangeSize-1;return t>=this.file.size&&(t=this.file.size-1),new N(e,t)}sliceFile(e){return this.file.content.slice(e.minValue,e.maxValue+1)}upload(){return e(this,void 0,void 0,function*(){try{for(;;){const e=this.getNextRange();if(-1===e.maxValue){const e=new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file");throw e.name="Invalid Session",e}const t=this.sliceFile(e),r=yield this.uploadSlice(t,e,this.file.size);if(void 0!==r.id)return r;this.updateTaskStatus(r)}}catch(e){throw e}})}uploadSlice(t,r,s){return e(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).headers({"Content-Length":`${r.maxValue-r.minValue+1}`,"Content-Range":`bytes ${r.minValue}-${r.maxValue}/${s}`}).put(t)}catch(e){throw e}})}cancel(){return e(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).delete()}catch(e){throw e}})}getStatus(){return e(this,void 0,void 0,function*(){try{const e=yield this.client.api(this.uploadSession.url).get();return this.updateTaskStatus(e),e}catch(e){throw e}})}resume(){return e(this,void 0,void 0,function*(){try{return yield this.getStatus(),yield this.upload()}catch(e){throw e}})}}const I=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};class H extends q{constructor(e,t,r,s){super(e,t,r,s)}static constructCreateSessionUrl(e,t=H.DEFAULT_UPLOAD_PATH){return e=e.trim(),""===(t=t.trim())&&(t="/"),"/"!==t[0]&&(t=`/${t}`),"/"!==t[t.length-1]&&(t=`${t}/`),`/me/drive/root:${t.split("/").map(e=>encodeURIComponent(e)).join("/")}${encodeURIComponent(e)}:/createUploadSession`}static create(t,r,s){return e(this,void 0,void 0,function*(){const e=s.fileName;let n,i;if("undefined"!=typeof Blob&&r instanceof Blob)i=(n=new File([r],e)).size;else if("undefined"!=typeof File&&r instanceof File)i=(n=r).size;else if("undefined"!=typeof Buffer&&r instanceof Buffer){const e=r;i=e.byteLength-e.byteOffset,n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}try{const r=H.constructCreateSessionUrl(s.fileName,s.path),o=yield H.createUploadSession(t,r,s.fileName),a=I(s.rangeSize);return new H(t,{name:e,content:n,size:i},o,{rangeSize:a})}catch(e){throw e}})}static createUploadSession(t,r,s){const n=Object.create(null,{createUploadSession:{get:()=>super.createUploadSession}});return e(this,void 0,void 0,function*(){const e={item:{"@microsoft.graph.conflictBehavior":"rename",name:s}};try{return n.createUploadSession.call(this,t,r,e)}catch(e){throw e}})}commit(t){return e(this,void 0,void 0,function*(){try{const e={name:this.file.name,"@microsoft.graph.conflictBehavior":"rename","@microsoft.graph.sourceUrl":this.uploadSession.url};return yield this.client.api(t).put(e)}catch(e){throw e}})}}H.DEFAULT_UPLOAD_PATH="/";class F{constructor(e,t,r,s){this.client=e,this.collection=t.value,this.nextLink=t["@odata.nextLink"],this.deltaLink=t["@odata.deltaLink"],this.callback=r,this.complete=!1,this.requestOptions=s}iterationHelper(){if(void 0===this.collection)return!1;let e=!0;for(;e&&0!==this.collection.length;){const t=this.collection.shift();e=this.callback(t)}return e}fetchAndUpdateNextPageData(){return e(this,void 0,void 0,function*(){try{let e=this.client.api(this.nextLink);this.requestOptions&&(this.requestOptions.headers&&(e=e.headers(this.requestOptions.headers)),this.requestOptions.middlewareOptions&&(e=e.middlewareOptions(this.requestOptions.middlewareOptions)),this.requestOptions.options&&(e=e.options(this.requestOptions.options)));const t=yield e.get();this.collection=t.value,this.nextLink=t["@odata.nextLink"],this.deltaLink=t["@odata.deltaLink"]}catch(e){throw e}})}getDeltaLink(){return this.deltaLink}iterate(){return e(this,void 0,void 0,function*(){try{let e=this.iterationHelper();for(;e;)void 0!==this.nextLink?(yield this.fetchAndUpdateNextPageData(),e=this.iterationHelper()):e=!1;void 0===this.nextLink&&0===this.collection.length&&(this.complete=!0)}catch(e){throw e}})}resume(){return e(this,void 0,void 0,function*(){try{return this.iterate()}catch(e){throw e}})}isComplete(){return this.complete}}class k{constructor(e){this.provider=e}getAccessToken(){return e(this,void 0,void 0,function*(){return new Promise((e,t)=>{this.provider((r,s)=>{s?e(s):t(r)})})})}}class $ extends Error{constructor(e=-1,t,r){super(t||r&&r.message),Object.setPrototypeOf(this,$.prototype),this.statusCode=e,this.code=null,this.requestId=null,this.date=new Date,this.body=null,this.stack=r?r.stack:this.stack}}class Q{static constructError(e,t){const r=new $(t,"",e);return void 0!==e.name&&(r.code=e.name),r.body=e.toString(),r.date=new Date,r}static constructErrorFromResponse(e,t){e=e.error;const r=new $(t,e.message);r.code=e.code,void 0!==e.innerError&&(r.requestId=e.innerError["request-id"],r.date=new Date(e.innerError.date));try{r.body=JSON.stringify(e)}catch(e){}return r}static getError(t=null,r=-1,s){return e(this,void 0,void 0,function*(){let e;if(e=t&&t.error?Q.constructErrorFromResponse(t,r):"undefined"!=typeof Error&&t instanceof Error?Q.constructError(t,r):new $(r),"function"!=typeof s)return e;s(e,null)})}}var B,X,j,V;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}(B||(B={})),function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(X||(X={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(j||(j={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(V||(V={}));class Y{static parseDocumentResponse(e,t){try{return"undefined"!=typeof DOMParser?new Promise((r,s)=>{e.text().then(e=>{try{const n=(new DOMParser).parseFromString(e,t);r(n)}catch(e){s(e)}})}):Promise.resolve(e.body)}catch(e){throw e}}static convertResponse(t,r){return e(this,void 0,void 0,function*(){if(204===t.status)return Promise.resolve();let e;try{switch(r){case B.ARRAYBUFFER:e=yield t.arrayBuffer();break;case B.BLOB:e=yield t.blob();break;case B.DOCUMENT:e=yield Y.parseDocumentResponse(t,X.TEXT_XML);break;case B.JSON:e=yield t.json();break;case B.STREAM:e=yield Promise.resolve(t.body);break;case B.TEXT:e=yield t.text();break;default:const s=t.headers.get("Content-type");if(null!==s){const r=s.split(";")[0];e=new RegExp(V.DOCUMENT).test(r)?yield Y.parseDocumentResponse(t,r):new RegExp(V.IMAGE).test(r)?t.blob():r===j.TEXT_PLAIN?yield t.text():r===j.APPLICATION_JSON?yield t.json():Promise.resolve(t.body)}else e=Promise.resolve(t.body)}}catch(e){throw e}return e})}static getResponse(t,r,s){return e(this,void 0,void 0,function*(){try{if(r===B.RAW)return Promise.resolve(t);{const e=yield Y.convertResponse(t,r);if(!t.ok)throw e;if("function"!=typeof s)return e;s(null,e)}}catch(e){throw e}})}}class z{constructor(e,t,r){this.parsePath=e=>{if(-1!==e.indexOf("https://")){const t=(e=e.replace("https://","")).indexOf("/");-1!==t&&(this.urlComponents.host="https://"+e.substring(0,t),e=e.substring(t+1,e.length));const r=e.indexOf("/");-1!==r&&(this.urlComponents.version=e.substring(0,r),e=e.substring(r+1,e.length))}"/"===e.charAt(0)&&(e=e.substr(1));const t=e.indexOf("?");if(-1===t)this.urlComponents.path=e;else{this.urlComponents.path=e.substr(0,t);const r=e.substring(t+1,e.length).split("&");for(const e of r)this.parseQueryParameter(e)}},this.httpClient=e,this.config=t,this.urlComponents={host:this.config.baseUrl,version:this.config.defaultVersion,oDataQueryParams:{},otherURLQueryParams:{},otherURLQueryOptions:[]},this._headers={},this._options={},this._middlewareOptions=[],this.parsePath(r)}addCsvQueryParameter(e,t,r){this.urlComponents.oDataQueryParams[e]=this.urlComponents.oDataQueryParams[e]?this.urlComponents.oDataQueryParams[e]+",":"";let s=[];r.length>1&&"string"==typeof t?s=Array.prototype.slice.call(r):"string"==typeof t?s.push(t):s=s.concat(t),this.urlComponents.oDataQueryParams[e]+=s.join(",")}buildFullUrl(){const e=R([this.urlComponents.host,this.urlComponents.version,this.urlComponents.path])+this.createQueryString();return this.config.debugLogging&&console.log(e),e}createQueryString(){const e=this.urlComponents,t=[];if(0!==Object.keys(e.oDataQueryParams).length)for(const r in e.oDataQueryParams)e.oDataQueryParams.hasOwnProperty(r)&&t.push(r+"="+e.oDataQueryParams[r]);if(0!==Object.keys(e.otherURLQueryParams).length)for(const r in e.otherURLQueryParams)e.otherURLQueryParams.hasOwnProperty(r)&&t.push(r+"="+e.otherURLQueryParams[r]);if(0!==e.otherURLQueryOptions.length)for(const r of e.otherURLQueryOptions)t.push(r);return t.length>0?"?"+t.join("&"):""}parseQueryParameter(e){if("string"==typeof e)if("?"===e.charAt(0)&&(e=e.substring(1)),-1!==e.indexOf("&")){const t=e.split("&");for(const e of t)this.parseQueryParamenterString(e)}else this.parseQueryParamenterString(e);else if(e.constructor===Object)for(const t in e)e.hasOwnProperty(t)&&this.setURLComponentsQueryParamater(t,e[t]);return this}parseQueryParamenterString(e){if(this.isValidQueryKeyValuePair(e)){const t=e.indexOf("="),r=e.substring(0,t),s=e.substring(t+1);this.setURLComponentsQueryParamater(r,s)}else this.urlComponents.otherURLQueryOptions.push(e)}setURLComponentsQueryParamater(e,t){if(-1!==v.indexOf(e)){const r=this.urlComponents.oDataQueryParams[e],s=r&&("$expand"===e||"$select"===e||"$orderby"===e);this.urlComponents.oDataQueryParams[e]=s?r+","+t:t}else this.urlComponents.otherURLQueryParams[e]=t}isValidQueryKeyValuePair(e){const t=e.indexOf("=");return-1!==t&&!(-1!==e.indexOf("(")&&e.indexOf("(")<t)}updateRequestOptions(e){const t=Object.assign({},e.headers);if(void 0!==this.config.fetchOptions){const t=Object.assign({},this.config.fetchOptions);Object.assign(e,t),void 0!==typeof this.config.fetchOptions.headers&&(e.headers=Object.assign({},this.config.fetchOptions.headers))}Object.assign(e,this._options),void 0!==e.headers&&Object.assign(t,e.headers),Object.assign(t,this._headers),e.headers=t}send(t,r,s){return e(this,void 0,void 0,function*(){let e;const i=new n(this._middlewareOptions);this.updateRequestOptions(r);try{return e=(yield this.httpClient.sendRequest({request:t,options:r,middlewareControl:i})).response,yield Y.getResponse(e,this._responseType,s)}catch(t){let r;throw void 0!==e&&(r=e.status),yield Q.getError(t,r,s)}})}setHeaderContentType(){if(!this._headers)return void this.header("Content-Type","application/json");const e=Object.keys(this._headers);for(const t of e)if("content-type"===t.toLowerCase())return;this.header("Content-Type","application/json")}header(e,t){return this._headers[e]=t,this}headers(e){for(const t in e)e.hasOwnProperty(t)&&(this._headers[t]=e[t]);return this}option(e,t){return this._options[e]=t,this}options(e){for(const t in e)e.hasOwnProperty(t)&&(this._options[t]=e[t]);return this}middlewareOptions(e){return this._middlewareOptions=e,this}version(e){return this.urlComponents.version=e,this}responseType(e){return this._responseType=e,this}select(e){return this.addCsvQueryParameter("$select",e,arguments),this}expand(e){return this.addCsvQueryParameter("$expand",e,arguments),this}orderby(e){return this.addCsvQueryParameter("$orderby",e,arguments),this}filter(e){return this.urlComponents.oDataQueryParams.$filter=e,this}search(e){return this.urlComponents.oDataQueryParams.$search=e,this}top(e){return this.urlComponents.oDataQueryParams.$top=e,this}skip(e){return this.urlComponents.oDataQueryParams.$skip=e,this}skipToken(e){return this.urlComponents.oDataQueryParams.$skipToken=e,this}count(e=!1){return this.urlComponents.oDataQueryParams.$count=e.toString(),this}query(e){return this.parseQueryParameter(e)}get(r){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),s={method:t.GET};try{return yield this.send(e,s,r)}catch(e){throw e}})}post(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),n={method:t.POST,body:A(r)};"FormData"===(r&&r.constructor&&r.constructor.name)?n.headers={}:(this.setHeaderContentType(),n.headers=this._headers);try{return yield this.send(e,n,s)}catch(e){throw e}})}create(t,r){return e(this,void 0,void 0,function*(){try{return yield this.post(t,r)}catch(e){throw e}})}put(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl();this.setHeaderContentType();const n={method:t.PUT,body:A(r)};try{return yield this.send(e,n,s)}catch(e){throw e}})}patch(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl();this.setHeaderContentType();const n={method:t.PATCH,body:A(r)};try{return yield this.send(e,n,s)}catch(e){throw e}})}update(t,r){return e(this,void 0,void 0,function*(){try{return yield this.patch(t,r)}catch(e){throw e}})}delete(r){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),s={method:t.DELETE};try{return yield this.send(e,s,r)}catch(e){throw e}})}del(t){return e(this,void 0,void 0,function*(){try{return yield this.delete(t)}catch(e){throw e}})}getStream(r){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),s={method:t.GET};this.responseType(B.STREAM);try{return yield this.send(e,s,r)}catch(e){throw e}})}putStream(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),n={method:t.PUT,headers:{"Content-Type":"application/octet-stream"},body:r};try{return yield this.send(e,n,s)}catch(e){throw e}})}}class W{constructor(...e){if(!e||!e.length){const e=new Error;throw e.name="InvalidMiddlewareChain",e.message="Please provide a default middleware chain or custom middleware chain",e}this.setMiddleware(...e)}setMiddleware(...e){e.length>1?this.parseMiddleWareArray(e):this.middleware=e[0]}parseMiddleWareArray(e){e.forEach((t,r)=>{r<e.length-1&&t.setNext(e[r+1])}),this.middleware=e[0]}sendRequest(t){return e(this,void 0,void 0,function*(){try{if("string"==typeof t.request&&void 0===t.options){const e=new Error;throw e.name="InvalidRequestOptions",e.message="Unable to execute the middleware, Please provide valid options for a request",e}return yield this.middleware.execute(t),t}catch(e){throw e}})}}const G=()=>"object"==typeof process&&"function"==typeof require;class J{static createWithAuthenticationProvider(e){const t=new p(e),r=new m(new y),s=new x,n=new f;if(t.setNext(r),G()){const e=new P(new D);r.setNext(e),e.setNext(s)}else r.setNext(s);return s.setNext(n),J.createWithMiddleware(t)}static createWithMiddleware(...e){return new W(...e)}}const Z=()=>{if("undefined"==typeof Promise&&"undefined"==typeof fetch){const e=new Error("Library cannot function without Promise and fetch. So, please provide polyfill for them.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof Promise){const e=new Error("Library cannot function without Promise. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof fetch){const e=new Error("Library cannot function without fetch. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}return!0};class K{constructor(e){this.config={baseUrl:g,debugLogging:!1,defaultVersion:E};try{Z()}catch(e){throw e}for(const t in e)e.hasOwnProperty(t)&&(this.config[t]=e[t]);let t;if(void 0!==e.authProvider&&void 0!==e.middleware){const e=new Error;throw e.name="AmbiguityInInitialization",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain not both",e}if(void 0!==e.authProvider)t=J.createWithAuthenticationProvider(e.authProvider);else{if(void 0===e.middleware){const e=new Error;throw e.name="InvalidMiddlewareChain",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain",e}t=new W(...[].concat(e.middleware))}this.httpClient=t}static init(e){const t={};for(const r in e)e.hasOwnProperty(r)&&(t[r]="authProvider"===r?new k(e[r]):e[r]);return K.initWithMiddleware(t)}static initWithMiddleware(e){try{return new K(e)}catch(e){throw e}}api(e){return new z(this.httpClient,this.config,e)}}class ee{constructor(e,t){this.options=t,this.msalApplication=e}getAccessToken(t){return e(this,void 0,void 0,function*(){let e;if(void 0!==t&&(e=t.scopes),void 0!==e&&0!==e.length||(e=this.options.scopes),0===e.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes cannot be empty, Please provide a scopes",e}if(this.msalApplication.getAccount()){const t={scopes:e};try{return(yield this.msalApplication.acquireTokenSilent(t)).accessToken}catch(e){if("InteractionRequiredAuthError"!==e.name)throw e;try{return(yield this.msalApplication.acquireTokenPopup(t)).accessToken}catch(e){throw e}}}else try{const t={scopes:e};return yield this.msalApplication.loginPopup(t),(yield this.msalApplication.acquireTokenSilent(t)).accessToken}catch(e){throw e}})}}class te{constructor(e){this.scopes=e}}export{p as AuthenticationHandler,h as AuthenticationHandlerOptions,r as BatchRequestContent,s as BatchResponseContent,U as ChaosHandler,L as ChaosHandlerOptions,M as ChaosStrategy,K as Client,k as CustomAuthenticationProvider,u as FeatureUsageFlag,$ as GraphError,z as GraphRequest,f as HTTPMessageHandler,ee as ImplicitMSALAuthenticationProvider,q as LargeFileUploadTask,te as MSALAuthenticationProviderOptions,_ as MiddlewareFactory,H as OneDriveLargeFileUploadTask,F as PageIterator,B as ResponseType,m as RetryHandler,y as RetryHandlerOptions,x as TelemetryHandler,l as TelemetryHandlerOptions};
function e(e,t,r,s){return new(r||(r=Promise))(function(n,i){function o(e){try{d(s.next(e))}catch(e){i(e)}}function a(e){try{d(s.throw(e))}catch(e){i(e)}}function d(e){e.done?n(e.value):new r(function(t){t(e.value)}).then(o,a)}d((s=s.apply(e,t||[])).next())})}var t;!function(e){e.GET="GET",e.PATCH="PATCH",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(t||(t={}));class r{constructor(e){if(this.requests=new Map,void 0!==e){const t=r.requestLimit;if(e.length>t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}for(const t of e)this.addRequest(t)}}static validateDependencies(e){if(0===e.size){const e=new Error("Empty requests map, Please provide at least one request.");throw e.name="Empty Requests Error",e}return(e=>{const t=e.entries();let r=t.next();for(;!r.done;){const e=r.value[1];if(void 0!==e.dependsOn&&e.dependsOn.length>0)return!1;r=t.next()}return!0})(e)||(e=>{const t=e.entries();let r=t.next();const s=r.value[1];if(void 0!==s.dependsOn&&s.dependsOn.length>0)return!1;let n=r;for(r=t.next();!r.done;){const e=r.value[1];if(void 0===e.dependsOn||1!==e.dependsOn.length||e.dependsOn[0]!==n.value[1].id)return!1;n=r,r=t.next()}return!0})(e)||(e=>{const t=e.entries();let r=t.next();const s=r.value[1];let n;if(void 0===s.dependsOn||0===s.dependsOn.length)n=s.id;else{if(1!==s.dependsOn.length)return!1;{const t=s.dependsOn[0];if(t===s.id||!e.has(t))return!1;n=t}}for(r=t.next();!r.done;){const e=r.value[1];if((void 0===e.dependsOn||0===e.dependsOn.length)&&n!==e.id)return!1;if(void 0!==e.dependsOn&&0!==e.dependsOn.length){if(1===e.dependsOn.length&&(e.id===n||e.dependsOn[0]!==n))return!1;if(e.dependsOn.length>1)return!1}r=t.next()}return!0})(e)}static getRequestData(s){return e(this,void 0,void 0,function*(){const e={url:""},n=new RegExp("^https?://");e.url=n.test(s.url)?"/"+s.url.split(/.*?\/\/.*?\//)[1]:s.url,e.method=s.method;const i={};return s.headers.forEach((e,t)=>{i[t]=e}),Object.keys(i).length&&(e.headers=i),s.method!==t.PATCH&&s.method!==t.POST&&s.method!==t.PUT||(e.body=yield r.getRequestBody(s)),e})}static getRequestBody(t){return e(this,void 0,void 0,function*(){let e,r=!1;try{const s=t.clone();e=yield s.json(),r=!0}catch(e){}if(!r)try{if("undefined"!=typeof Blob){const r=yield t.blob(),s=new FileReader;e=yield new Promise(e=>{s.addEventListener("load",()=>{const t=s.result,r=new RegExp("^s*data:(.+?/.+?(;.+?=.+?)*)?(;base64)?,(.*)s*$").exec(t);e(r[4])},!1),s.readAsDataURL(r)})}else if("undefined"!=typeof Buffer){e=(yield t.buffer()).toString("base64")}r=!0}catch(e){}return e})}addRequest(e){const t=r.requestLimit;if(""===e.id){const e=new Error("Id for a request is empty, Please provide an unique id");throw e.name="Empty Id For Request",e}if(this.requests.size===t){const e=new Error(`Maximum requests limit exceeded, Max allowed number of requests are ${t}`);throw e.name="Limit Exceeded Error",e}if(this.requests.has(e.id)){const t=new Error(`Adding request with duplicate id ${e.id}, Make the id of the requests unique`);throw t.name="Duplicate RequestId Error",t}return this.requests.set(e.id,e),e.id}removeRequest(e){const t=this.requests.delete(e),r=this.requests.entries();let s=r.next();for(;!s.done;){const t=s.value[1].dependsOn;if(void 0!==t){const r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&delete s.value[1].dependsOn}s=r.next()}return t}getContent(){return e(this,void 0,void 0,function*(){const e=[],t={requests:e},s=this.requests.entries();let n=s.next();if(n.done){const e=new Error("No requests added yet, Please add at least one request.");throw e.name="Empty Payload",e}if(!r.validateDependencies(this.requests)){const e=new Error("Invalid dependency found, Dependency should be:\n1. Parallel - no individual request states a dependency in the dependsOn property.\n2. Serial - all individual requests depend on the previous individual request.\n3. Same - all individual requests that state a dependency in the dependsOn property, state the same dependency.");throw e.name="Invalid Dependency",e}for(;!n.done;){const t=n.value[1],i=yield r.getRequestData(t.request);if(void 0!==i.body&&(void 0===i.headers||void 0===i.headers["content-type"])){const e=new Error(`Content-type header is not mentioned for request #${t.id}, For request having body, Content-type header should be mentioned`);throw e.name="Invalid Content-type header",e}i.id=t.id,void 0!==t.dependsOn&&t.dependsOn.length>0&&(i.dependsOn=t.dependsOn),e.push(i),n=s.next()}return t.requests=e,t})}addDependency(e,t){if(!this.requests.has(e)){const t=new Error(`Dependent ${e} does not exists, Please check the id`);throw t.name="Invalid Dependent",t}if(void 0!==t&&!this.requests.has(t)){const e=new Error(`Dependency ${t} does not exists, Please check the id`);throw e.name="Invalid Dependency",e}if(void 0!==t){const r=this.requests.get(e);if(void 0===r.dependsOn&&(r.dependsOn=[]),-1!==r.dependsOn.indexOf(t)){const r=new Error(`Dependency ${t} is already added for the request ${e}`);throw r.name="Duplicate Dependency",r}r.dependsOn.push(t)}else{const r=this.requests.entries();let s,n=r.next();for(;!n.done&&n.value[1].id!==e;)s=n,n=r.next();if(void 0===s){const e=new Error(`Can't add dependency ${t}, There is only a dependent request in the batch`);throw e.name="Invalid Dependency Addition",e}{const t=s.value[0];if(void 0===n.value[1].dependsOn&&(n.value[1].dependsOn=[]),-1!==n.value[1].dependsOn.indexOf(t)){const r=new Error(`Dependency ${t} is already added for the request ${e}`);throw r.name="Duplicate Dependency",r}n.value[1].dependsOn.push(t)}}}removeDependency(e,t){const r=this.requests.get(e);if(void 0===r||void 0===r.dependsOn||0===r.dependsOn.length)return!1;if(void 0!==t){const e=r.dependsOn.indexOf(t);return-1!==e&&(r.dependsOn.splice(e,1),!0)}return delete r.dependsOn,!0}}r.requestLimit=20;class s{constructor(e){this.responses=new Map,this.update(e)}createResponseObject(e){const t=e.body,r={};if(r.status=e.status,void 0!==e.statusText&&(r.statusText=e.statusText),r.headers=e.headers,void 0!==r.headers&&void 0!==r.headers["Content-Type"]&&"application/json"===r.headers["Content-Type"].split(";")[0]){const e=JSON.stringify(t);return new Response(e,r)}return new Response(t,r)}update(e){this.nextLink=e["@odata.nextLink"];const t=e.responses;for(let e=0,r=t.length;e<r;e++)this.responses.set(t[e].id,this.createResponseObject(t[e]))}getResponseById(e){return this.responses.get(e)}getResponses(){return this.responses}*getResponsesIterator(){const e=this.responses.entries();let t=e.next();for(;!t.done;)yield t.value,t=e.next()}}class n{constructor(e=[]){this.middlewareOptions=new Map;for(const t of e){const e=t.constructor;this.middlewareOptions.set(e,t)}}getMiddlewareOptions(e){return this.middlewareOptions.get(e)}setMiddlewareOptions(e,t){this.middlewareOptions.set(e,t)}}const i=()=>{let e="";for(let t=0;t<32;t++)8!==t&&12!==t&&16!==t&&20!==t||(e+="-"),e+=Math.floor(16*Math.random()).toString(16);return e},o=(e,t,r)=>{let s=null;if("undefined"!=typeof Request&&e instanceof Request)s=e.headers.get(r);else if(void 0!==t&&void 0!==t.headers)if("undefined"!=typeof Headers&&t.headers instanceof Headers)s=t.headers.get(r);else if(t.headers instanceof Array){const e=t.headers;for(let t=0,n=e.length;t<n;t++)if(e[t][0]===r){s=e[t][1];break}}else void 0!==t.headers[r]&&(s=t.headers[r]);return s},a=(e,t,r,s)=>{if("undefined"!=typeof Request&&e instanceof Request)e.headers.set(r,s);else if(void 0!==t)if(void 0===t.headers)t.headers=new Headers({[r]:s});else if("undefined"!=typeof Headers&&t.headers instanceof Headers)t.headers.set(r,s);else if(t.headers instanceof Array){let e=0;const n=t.headers.length;for(;e<n;e++){const n=t.headers[e];if(n[0]===r){n[1]=s;break}}e===n&&t.headers.push([r,s])}else Object.assign(t.headers,{[r]:s})},d=(e,t,r,s)=>{"undefined"!=typeof Request&&e instanceof Request?e.headers.append(r,s):void 0!==t&&(void 0===t.headers?t.headers=new Headers({[r]:s}):"undefined"!=typeof Headers&&t.headers instanceof Headers?t.headers.append(r,s):t.headers instanceof Array?t.headers.push([r,s]):void 0===t.headers?t.headers={[r]:s}:void 0===t.headers[r]?t.headers[r]=s:t.headers[r]+=`, ${s}`)},c=(t,r)=>e(void 0,void 0,void 0,function*(){const e=r.headers.get("Content-Type")?yield r.blob():yield Promise.resolve(void 0),{method:s,headers:n,referrer:i,referrerPolicy:o,mode:a,credentials:d,cache:c,redirect:h,integrity:u,keepalive:l,signal:p}=r;return new Request(t,{method:s,headers:n,body:e,referrer:i,referrerPolicy:o,mode:a,credentials:d,cache:c,redirect:h,integrity:u,keepalive:l,signal:p})});class h{constructor(e,t){this.authenticationProvider=e,this.authenticationProviderOptions=t}}var u;!function(e){e[e.NONE=0]="NONE",e[e.REDIRECT_HANDLER_ENABLED=1]="REDIRECT_HANDLER_ENABLED",e[e.RETRY_HANDLER_ENABLED=2]="RETRY_HANDLER_ENABLED",e[e.AUTHENTICATION_HANDLER_ENABLED=4]="AUTHENTICATION_HANDLER_ENABLED"}(u||(u={}));class l{constructor(){this.featureUsage=u.NONE}static updateFeatureUsageFlag(e,t){let r;e.middlewareControl instanceof n?r=e.middlewareControl.getMiddlewareOptions(l):e.middlewareControl=new n,void 0===r&&(r=new l,e.middlewareControl.setMiddlewareOptions(l,r)),r.setFeatureUsage(t)}setFeatureUsage(e){this.featureUsage=this.featureUsage|e}getFeatureUsage(){return this.featureUsage.toString(16)}}class p{constructor(e){this.authenticationProvider=e}execute(t){return e(this,void 0,void 0,function*(){try{let e,r,s;t.middlewareControl instanceof n&&(e=t.middlewareControl.getMiddlewareOptions(h)),void 0!==e&&(r=e.authenticationProvider,s=e.authenticationProviderOptions),void 0===r&&(r=this.authenticationProvider);const i=`Bearer ${yield r.getAccessToken(s)}`;return d(t.request,t.options,p.AUTHORIZATION_HEADER,i),l.updateFeatureUsageFlag(t,u.AUTHENTICATION_HANDLER_ENABLED),yield this.nextMiddleware.execute(t)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}p.AUTHORIZATION_HEADER="Authorization";class f{execute(t){return e(this,void 0,void 0,function*(){try{return void(t.response=yield fetch(t.request,t.options))}catch(e){throw e}})}}class y{constructor(e=y.DEFAULT_DELAY,t=y.DEFAULT_MAX_RETRIES,r=y.DEFAULT_SHOULD_RETRY){if(e>y.MAX_DELAY&&t>y.MAX_MAX_RETRIES){const e=new Error(`Delay and MaxRetries should not be more than ${y.MAX_DELAY} and ${y.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e>y.MAX_DELAY){const e=new Error(`Delay should not be more than ${y.MAX_DELAY}`);throw e.name="MaxLimitExceeded",e}if(t>y.MAX_MAX_RETRIES){const e=new Error(`MaxRetries should not be more than ${y.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e<0&&t<0){const e=new Error("Delay and MaxRetries should not be negative");throw e.name="MinExpectationNotMet",e}if(e<0){const e=new Error("Delay should not be negative");throw e.name="MinExpectationNotMet",e}if(t<0){const e=new Error("MaxRetries should not be negative");throw e.name="MinExpectationNotMet",e}this.delay=Math.min(e,y.MAX_DELAY),this.maxRetries=Math.min(t,y.MAX_MAX_RETRIES),this.shouldRetry=r}getMaxDelay(){return y.MAX_DELAY}}y.DEFAULT_DELAY=3,y.DEFAULT_MAX_RETRIES=3,y.MAX_DELAY=180,y.MAX_MAX_RETRIES=10,y.DEFAULT_SHOULD_RETRY=()=>!0;class m{constructor(e=new y){this.options=e}isRetry(e){return-1!==m.RETRY_STATUS_CODES.indexOf(e.status)}isBuffered(e,r){const s="string"==typeof e?r.method:e.method;if(s===t.PUT||s===t.PATCH||s===t.POST){if("application/octet-stream"===o(e,r,"Content-Type"))return!1}return!0}getDelay(e,t,r){const s=()=>Number(Math.random().toFixed(3)),n=void 0!==e.headers?e.headers.get(m.RETRY_AFTER_HEADER):null;let i;return i=null!==n?Number.isNaN(Number(n))?Math.round((new Date(n).getTime()-Date.now())/1e3):Number(n):t>=2?this.getExponentialBackOffTime(t)+r+s():r+s(),Math.min(i,this.options.getMaxDelay()+s())}getExponentialBackOffTime(e){return Math.round(.5*(Math.pow(2,e)-1))}sleep(t){return e(this,void 0,void 0,function*(){const e=1e3*t;return new Promise(t=>setTimeout(t,e))})}getOptions(e){let t;return e.middlewareControl instanceof n&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor)),void 0===t&&(t=Object.assign(new y,this.options)),t}executeWithRetry(t,r,s){return e(this,void 0,void 0,function*(){try{if(yield this.nextMiddleware.execute(t),r<s.maxRetries&&this.isRetry(t.response)&&this.isBuffered(t.request,t.options)&&s.shouldRetry(s.delay,r,t.request,t.options,t.response)){++r,a(t.request,t.options,m.RETRY_ATTEMPT_HEADER,r.toString());const e=this.getDelay(t.response,r,s.delay);return yield this.sleep(e),yield this.executeWithRetry(t,r,s)}return}catch(e){throw e}})}execute(t){return e(this,void 0,void 0,function*(){try{const e=0,r=this.getOptions(t);return l.updateFeatureUsageFlag(t,u.RETRY_HANDLER_ENABLED),yield this.executeWithRetry(t,e,r)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}m.RETRY_STATUS_CODES=[429,503,504],m.RETRY_ATTEMPT_HEADER="Retry-Attempt",m.RETRY_AFTER_HEADER="Retry-After";const E="v1.0",g="https://graph.microsoft.com/",w=new Set(["graph.microsoft.com","graph.microsoft.us","dod-graph.microsoft.us","graph.microsoft.de","microsoftgraph.chinacloudapi.cn"]),v=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],R=e=>{const t=e=>e.replace(/\/+$/,""),r=e=>e.replace(/^\/+/,"");return Array.prototype.slice.call(e).reduce((e,s)=>[t(e),r(s)].join("/"))},A=e=>{const t=e&&e.constructor&&e.constructor.name;if("Buffer"===t||"Blob"===t||"File"===t||"FormData"===t||"string"==typeof e)return e;if("ArrayBuffer"===t)e=Buffer.from(e);else if("Int8Array"===t||"Int16Array"===t||"Int32Array"===t||"Uint8Array"===t||"Uint16Array"===t||"Uint32Array"===t||"Uint8ClampedArray"===t||"Float32Array"===t||"Float64Array"===t||"DataView"===t)e=Buffer.from(e.buffer);else try{e=JSON.stringify(e)}catch(e){throw new Error("Unable to stringify the content")}return e},T=e=>{if(-1!==(e=e.toLowerCase()).indexOf("https://")){const t=(e=e.replace("https://","")).indexOf(":"),r=e.indexOf("/");let s="";if(-1!==r)return-1!==t&&t<r?(s=e.substring(0,t),w.has(s)):(s=e.substring(0,r),w.has(s))}return!1},O="2.2.0";class x{execute(t){return e(this,void 0,void 0,function*(){try{const e="string"==typeof t.request?t.request:t.request.url;if(T(e)){let e=o(t.request,t.options,x.CLIENT_REQUEST_ID_HEADER);e||(e=i(),a(t.request,t.options,x.CLIENT_REQUEST_ID_HEADER,e));let r,s=`${x.PRODUCT_NAME}/${O}`;if(t.middlewareControl instanceof n&&(r=t.middlewareControl.getMiddlewareOptions(l)),r){const e=r.getFeatureUsage();s+=` (${x.FEATURE_USAGE_STRING}=${e})`}d(t.request,t.options,x.SDK_VERSION_HEADER,s)}else delete t.options.headers[x.CLIENT_REQUEST_ID_HEADER],delete t.options.headers[x.SDK_VERSION_HEADER];return yield this.nextMiddleware.execute(t)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}x.CLIENT_REQUEST_ID_HEADER="client-request-id",x.SDK_VERSION_HEADER="SdkVersion",x.PRODUCT_NAME="graph-js",x.FEATURE_USAGE_STRING="featureUsage";class D{constructor(e=D.DEFAULT_MAX_REDIRECTS,t=D.DEFAULT_SHOULD_RETRY){if(e>D.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${D.MAX_MAX_REDIRECTS}`);throw e.name="MaxLimitExceeded",e}if(e<0){const e=new Error("MaxRedirects should not be negative");throw e.name="MinExpectationNotMet",e}this.maxRedirects=e,this.shouldRedirect=t}}D.DEFAULT_MAX_REDIRECTS=5,D.MAX_MAX_REDIRECTS=20,D.DEFAULT_SHOULD_RETRY=()=>!0;class P{constructor(e=new D){this.options=e}isRedirect(e){return-1!==P.REDIRECT_STATUS_CODES.indexOf(e.status)}hasLocationHeader(e){return e.headers.has(P.LOCATION_HEADER)}getLocationHeader(e){return e.headers.get(P.LOCATION_HEADER)}isRelativeURL(e){return-1===e.indexOf("://")}shouldDropAuthorizationHeader(e,t){const r=/^[A-Za-z].+?:\/\/.+?(?=\/|$)/,s=r.exec(e);let n,i;null!==s&&(n=s[0]);const o=r.exec(t);return null!==o&&(i=o[0]),void 0!==n&&void 0!==i&&n!==i}updateRequestUrl(t,r){return e(this,void 0,void 0,function*(){r.request="string"==typeof r.request?t:yield c(t,r.request)})}getOptions(e){let t;return e.middlewareControl instanceof n&&(t=e.middlewareControl.getMiddlewareOptions(D)),void 0===t&&(t=Object.assign(new D,this.options)),t}executeWithRedirect(r,s,n){return e(this,void 0,void 0,function*(){try{yield this.nextMiddleware.execute(r);const e=r.response;if(!(s<n.maxRedirects&&this.isRedirect(e)&&this.hasLocationHeader(e)&&n.shouldRedirect(e)))return;if(++s,e.status===P.STATUS_CODE_SEE_OTHER)r.options.method=t.GET,delete r.options.body;else{const t=this.getLocationHeader(e);!this.isRelativeURL(t)&&this.shouldDropAuthorizationHeader(e.url,t)&&delete r.options.headers[P.AUTHORIZATION_HEADER],yield this.updateRequestUrl(t,r)}yield this.executeWithRedirect(r,s,n)}catch(e){throw e}})}execute(t){return e(this,void 0,void 0,function*(){try{const e=0,r=this.getOptions(t);return t.options.redirect=P.MANUAL_REDIRECT,l.updateFeatureUsageFlag(t,u.REDIRECT_HANDLER_ENABLED),yield this.executeWithRedirect(t,e,r)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}P.REDIRECT_STATUS_CODES=[301,302,303,307,308],P.STATUS_CODE_SEE_OTHER=303,P.LOCATION_HEADER="Location",P.AUTHORIZATION_HEADER="Authorization",P.MANUAL_REDIRECT="manual";const C=()=>"object"==typeof process&&"function"==typeof require;class _{static getDefaultMiddlewareChain(e){const t=[],r=new p(e),s=new m(new y),n=new x,i=new f;if(t.push(r),t.push(s),C()){const e=new P(new D);t.push(e)}return t.push(n),t.push(i),t}}var M;!function(e){e[e.MANUAL=0]="MANUAL",e[e.RANDOM=1]="RANDOM"}(M||(M={}));class L{constructor(e=M.RANDOM,t="Some error Happened",r,s,n){if(this.chaosStrategy=e,this.statusCode=r,this.statusMessage=t,this.chaosPercentage=void 0!==s?s:10,this.responseBody=n,this.chaosPercentage>100)throw new Error("Error Pecentage can not be more than 100")}}const b={GET:[429,500,502,503,504],POST:[429,500,502,503,504,507],PUT:[429,500,502,503,504,507],PATCH:[429,500,502,503,504],DELETE:[429,500,502,503,504,507]},S={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};class U{constructor(e=new L,t){this.options=e,this.manualMap=t}createResponseHeaders(e,t,r){const s=new Headers;return s.append("Cache-Control","no-store"),s.append("request-id",t),s.append("client-request-id",t),s.append("x-ms-ags-diagnostic",""),s.append("Date",r),s.append("Strict-Transport-Security",""),429===e&&s.append("retry-after","300"),s}createResponseBody(e,t,r,s,n){if(n)return n;let i;if(e>=400){i={error:{code:S[e],message:t,innerError:{"request-id":r,date:s}}}}else i={};return i}createResponse(e,t){try{let r,s,n,o;const a=t.request;n=i(),o=new Date,s=this.createResponseHeaders(e.statusCode,n,o.toString()),r=this.createResponseBody(e.statusCode,e.statusMessage,n,o.toString(),e.responseBody);const d={url:a,status:e.statusCode,statusText:e.statusMessage,headers:s};t.response=new Response(r,d)}catch(e){throw e}}sendRequest(t,r){return e(this,void 0,void 0,function*(){try{this.setStatusCode(t,r.request,r.options.method),t.statusCode?this.createResponse(t,r):yield this.nextMiddleware.execute(r)}catch(e){throw e}})}getRandomStatusCode(e){try{const t=b[e];return t[Math.floor(Math.random()*t.length)]}catch(e){throw e}}getRelativeURL(e){const t=/https?:\/\/graph\.microsoft\.com\/[^/]+(.+?)(\?|$)/;let r;return null!==t.exec(e)&&(r=t.exec(e)[1]),r}setStatusCode(e,t,r){try{if(e.chaosStrategy===M.MANUAL){if(void 0===e.statusCode){const s=this.getRelativeURL(t);void 0!==this.manualMap.get(s)?void 0!==this.manualMap.get(s).get(r)&&(e.statusCode=this.manualMap.get(s).get(r)):this.manualMap.forEach((t,n)=>{new RegExp(n+"$").test(s)&&void 0!==this.manualMap.get(n).get(r)&&(e.statusCode=this.manualMap.get(n).get(r))})}}else Math.floor(100*Math.random())<e.chaosPercentage&&(e.statusCode=this.getRandomStatusCode(r))}catch(e){throw e}}getOptions(e){let t;return e.middlewareControl instanceof n&&(t=e.middlewareControl.getMiddlewareOptions(L)),void 0===t&&(t=Object.assign(new L,this.options)),t}execute(t){return e(this,void 0,void 0,function*(){try{const e=this.getOptions(t);return yield this.sendRequest(e,t)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}class N{constructor(e=-1,t=-1){this.minValue=e,this.maxValue=t}}class q{constructor(e,t,r,s={}){this.DEFAULT_FILE_SIZE=5242880,this.client=e,this.file=t,void 0===s.rangeSize&&(s.rangeSize=this.DEFAULT_FILE_SIZE),this.options=s,this.uploadSession=r,this.nextRange=new N(0,this.options.rangeSize-1)}static createUploadSession(t,r,s,n={}){return e(this,void 0,void 0,function*(){try{const e=yield t.api(r).headers(n).post(s);return{url:e.uploadUrl,expiry:new Date(e.expirationDateTime)}}catch(e){throw e}})}parseRange(e){const t=e[0];if(void 0===t||""===t)return new N;const r=t.split("-"),s=parseInt(r[0],10);let n=parseInt(r[1],10);return Number.isNaN(n)&&(n=this.file.size-1),new N(s,n)}updateTaskStatus(e){this.uploadSession.expiry=new Date(e.expirationDateTime),this.nextRange=this.parseRange(e.nextExpectedRanges)}getNextRange(){if(-1===this.nextRange.minValue)return this.nextRange;const e=this.nextRange.minValue;let t=e+this.options.rangeSize-1;return t>=this.file.size&&(t=this.file.size-1),new N(e,t)}sliceFile(e){return this.file.content.slice(e.minValue,e.maxValue+1)}upload(){return e(this,void 0,void 0,function*(){try{for(;;){const e=this.getNextRange();if(-1===e.maxValue){const e=new Error("Task with which you are trying to upload is already completed, Please check for your uploaded file");throw e.name="Invalid Session",e}const t=this.sliceFile(e),r=yield this.uploadSlice(t,e,this.file.size);if(void 0!==r.id)return r;this.updateTaskStatus(r)}}catch(e){throw e}})}uploadSlice(t,r,s){return e(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).headers({"Content-Length":`${r.maxValue-r.minValue+1}`,"Content-Range":`bytes ${r.minValue}-${r.maxValue}/${s}`}).put(t)}catch(e){throw e}})}cancel(){return e(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).delete()}catch(e){throw e}})}getStatus(){return e(this,void 0,void 0,function*(){try{const e=yield this.client.api(this.uploadSession.url).get();return this.updateTaskStatus(e),e}catch(e){throw e}})}resume(){return e(this,void 0,void 0,function*(){try{return yield this.getStatus(),yield this.upload()}catch(e){throw e}})}}const I=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};class H extends q{constructor(e,t,r,s){super(e,t,r,s)}static constructCreateSessionUrl(e,t=H.DEFAULT_UPLOAD_PATH){return e=e.trim(),""===(t=t.trim())&&(t="/"),"/"!==t[0]&&(t=`/${t}`),"/"!==t[t.length-1]&&(t=`${t}/`),`/me/drive/root:${t.split("/").map(e=>encodeURIComponent(e)).join("/")}${encodeURIComponent(e)}:/createUploadSession`}static create(t,r,s){return e(this,void 0,void 0,function*(){const e=s.fileName;let n,i;if("undefined"!=typeof Blob&&r instanceof Blob)i=(n=new File([r],e)).size;else if("undefined"!=typeof File&&r instanceof File)i=(n=r).size;else if("undefined"!=typeof Buffer&&r instanceof Buffer){const e=r;i=e.byteLength-e.byteOffset,n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}try{const r=H.constructCreateSessionUrl(s.fileName,s.path),o=yield H.createUploadSession(t,r,s.fileName),a=I(s.rangeSize);return new H(t,{name:e,content:n,size:i},o,{rangeSize:a})}catch(e){throw e}})}static createUploadSession(t,r,s){const n=Object.create(null,{createUploadSession:{get:()=>super.createUploadSession}});return e(this,void 0,void 0,function*(){const e={item:{"@microsoft.graph.conflictBehavior":"rename",name:s}};try{return n.createUploadSession.call(this,t,r,e)}catch(e){throw e}})}commit(t){return e(this,void 0,void 0,function*(){try{const e={name:this.file.name,"@microsoft.graph.conflictBehavior":"rename","@microsoft.graph.sourceUrl":this.uploadSession.url};return yield this.client.api(t).put(e)}catch(e){throw e}})}}H.DEFAULT_UPLOAD_PATH="/";class F{constructor(e,t,r,s){this.client=e,this.collection=t.value,this.nextLink=t["@odata.nextLink"],this.deltaLink=t["@odata.deltaLink"],this.callback=r,this.complete=!1,this.requestOptions=s}iterationHelper(){if(void 0===this.collection)return!1;let e=!0;for(;e&&0!==this.collection.length;){const t=this.collection.shift();e=this.callback(t)}return e}fetchAndUpdateNextPageData(){return e(this,void 0,void 0,function*(){try{let e=this.client.api(this.nextLink);this.requestOptions&&(this.requestOptions.headers&&(e=e.headers(this.requestOptions.headers)),this.requestOptions.middlewareOptions&&(e=e.middlewareOptions(this.requestOptions.middlewareOptions)),this.requestOptions.options&&(e=e.options(this.requestOptions.options)));const t=yield e.get();this.collection=t.value,this.nextLink=t["@odata.nextLink"],this.deltaLink=t["@odata.deltaLink"]}catch(e){throw e}})}getDeltaLink(){return this.deltaLink}iterate(){return e(this,void 0,void 0,function*(){try{let e=this.iterationHelper();for(;e;)void 0!==this.nextLink?(yield this.fetchAndUpdateNextPageData(),e=this.iterationHelper()):e=!1;void 0===this.nextLink&&0===this.collection.length&&(this.complete=!0)}catch(e){throw e}})}resume(){return e(this,void 0,void 0,function*(){try{return this.iterate()}catch(e){throw e}})}isComplete(){return this.complete}}class k{constructor(e){this.provider=e}getAccessToken(){return e(this,void 0,void 0,function*(){return new Promise((e,t)=>{this.provider((r,s)=>{s?e(s):t(r)})})})}}class $ extends Error{constructor(e=-1,t,r){super(t||r&&r.message),Object.setPrototypeOf(this,$.prototype),this.statusCode=e,this.code=null,this.requestId=null,this.date=new Date,this.body=null,this.stack=r?r.stack:this.stack}}class Q{static constructError(e,t){const r=new $(t,"",e);return void 0!==e.name&&(r.code=e.name),r.body=e.toString(),r.date=new Date,r}static constructErrorFromResponse(e,t){e=e.error;const r=new $(t,e.message);r.code=e.code,void 0!==e.innerError&&(r.requestId=e.innerError["request-id"],r.date=new Date(e.innerError.date));try{r.body=JSON.stringify(e)}catch(e){}return r}static getError(t=null,r=-1,s){return e(this,void 0,void 0,function*(){let e;if(e=t&&t.error?Q.constructErrorFromResponse(t,r):"undefined"!=typeof Error&&t instanceof Error?Q.constructError(t,r):new $(r),"function"!=typeof s)return e;s(e,null)})}}var B,X,j,V;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}(B||(B={})),function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(X||(X={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(j||(j={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(V||(V={}));class Y{static parseDocumentResponse(e,t){try{return"undefined"!=typeof DOMParser?new Promise((r,s)=>{e.text().then(e=>{try{const n=(new DOMParser).parseFromString(e,t);r(n)}catch(e){s(e)}})}):Promise.resolve(e.body)}catch(e){throw e}}static convertResponse(t,r){return e(this,void 0,void 0,function*(){if(204===t.status)return Promise.resolve();let e;try{switch(r){case B.ARRAYBUFFER:e=yield t.arrayBuffer();break;case B.BLOB:e=yield t.blob();break;case B.DOCUMENT:e=yield Y.parseDocumentResponse(t,X.TEXT_XML);break;case B.JSON:e=yield t.json();break;case B.STREAM:e=yield Promise.resolve(t.body);break;case B.TEXT:e=yield t.text();break;default:const s=t.headers.get("Content-type");if(null!==s){const r=s.split(";")[0];e=new RegExp(V.DOCUMENT).test(r)?yield Y.parseDocumentResponse(t,r):new RegExp(V.IMAGE).test(r)?t.blob():r===j.TEXT_PLAIN?yield t.text():r===j.APPLICATION_JSON?yield t.json():Promise.resolve(t.body)}else e=Promise.resolve(t.body)}}catch(e){throw e}return e})}static getResponse(t,r,s){return e(this,void 0,void 0,function*(){try{if(r===B.RAW)return Promise.resolve(t);{const e=yield Y.convertResponse(t,r);if(!t.ok)throw e;if("function"!=typeof s)return e;s(null,e)}}catch(e){throw e}})}}class z{constructor(e,t,r){this.parsePath=e=>{if(-1!==e.indexOf("https://")){const t=(e=e.replace("https://","")).indexOf("/");-1!==t&&(this.urlComponents.host="https://"+e.substring(0,t),e=e.substring(t+1,e.length));const r=e.indexOf("/");-1!==r&&(this.urlComponents.version=e.substring(0,r),e=e.substring(r+1,e.length))}"/"===e.charAt(0)&&(e=e.substr(1));const t=e.indexOf("?");if(-1===t)this.urlComponents.path=e;else{this.urlComponents.path=e.substr(0,t);const r=e.substring(t+1,e.length).split("&");for(const e of r)this.parseQueryParameter(e)}},this.httpClient=e,this.config=t,this.urlComponents={host:this.config.baseUrl,version:this.config.defaultVersion,oDataQueryParams:{},otherURLQueryParams:{},otherURLQueryOptions:[]},this._headers={},this._options={},this._middlewareOptions=[],this.parsePath(r)}addCsvQueryParameter(e,t,r){this.urlComponents.oDataQueryParams[e]=this.urlComponents.oDataQueryParams[e]?this.urlComponents.oDataQueryParams[e]+",":"";let s=[];r.length>1&&"string"==typeof t?s=Array.prototype.slice.call(r):"string"==typeof t?s.push(t):s=s.concat(t),this.urlComponents.oDataQueryParams[e]+=s.join(",")}buildFullUrl(){const e=R([this.urlComponents.host,this.urlComponents.version,this.urlComponents.path])+this.createQueryString();return this.config.debugLogging&&console.log(e),e}createQueryString(){const e=this.urlComponents,t=[];if(0!==Object.keys(e.oDataQueryParams).length)for(const r in e.oDataQueryParams)e.oDataQueryParams.hasOwnProperty(r)&&t.push(r+"="+e.oDataQueryParams[r]);if(0!==Object.keys(e.otherURLQueryParams).length)for(const r in e.otherURLQueryParams)e.otherURLQueryParams.hasOwnProperty(r)&&t.push(r+"="+e.otherURLQueryParams[r]);if(0!==e.otherURLQueryOptions.length)for(const r of e.otherURLQueryOptions)t.push(r);return t.length>0?"?"+t.join("&"):""}parseQueryParameter(e){if("string"==typeof e)if("?"===e.charAt(0)&&(e=e.substring(1)),-1!==e.indexOf("&")){const t=e.split("&");for(const e of t)this.parseQueryParamenterString(e)}else this.parseQueryParamenterString(e);else if(e.constructor===Object)for(const t in e)e.hasOwnProperty(t)&&this.setURLComponentsQueryParamater(t,e[t]);return this}parseQueryParamenterString(e){if(this.isValidQueryKeyValuePair(e)){const t=e.indexOf("="),r=e.substring(0,t),s=e.substring(t+1);this.setURLComponentsQueryParamater(r,s)}else this.urlComponents.otherURLQueryOptions.push(e)}setURLComponentsQueryParamater(e,t){if(-1!==v.indexOf(e)){const r=this.urlComponents.oDataQueryParams[e],s=r&&("$expand"===e||"$select"===e||"$orderby"===e);this.urlComponents.oDataQueryParams[e]=s?r+","+t:t}else this.urlComponents.otherURLQueryParams[e]=t}isValidQueryKeyValuePair(e){const t=e.indexOf("=");return-1!==t&&!(-1!==e.indexOf("(")&&e.indexOf("(")<t)}updateRequestOptions(e){const t=Object.assign({},e.headers);if(void 0!==this.config.fetchOptions){const t=Object.assign({},this.config.fetchOptions);Object.assign(e,t),void 0!==typeof this.config.fetchOptions.headers&&(e.headers=Object.assign({},this.config.fetchOptions.headers))}Object.assign(e,this._options),void 0!==e.headers&&Object.assign(t,e.headers),Object.assign(t,this._headers),e.headers=t}send(t,r,s){return e(this,void 0,void 0,function*(){let e;const i=new n(this._middlewareOptions);this.updateRequestOptions(r);try{return e=(yield this.httpClient.sendRequest({request:t,options:r,middlewareControl:i})).response,yield Y.getResponse(e,this._responseType,s)}catch(t){let r;throw void 0!==e&&(r=e.status),yield Q.getError(t,r,s)}})}setHeaderContentType(){if(!this._headers)return void this.header("Content-Type","application/json");const e=Object.keys(this._headers);for(const t of e)if("content-type"===t.toLowerCase())return;this.header("Content-Type","application/json")}header(e,t){return this._headers[e]=t,this}headers(e){for(const t in e)e.hasOwnProperty(t)&&(this._headers[t]=e[t]);return this}option(e,t){return this._options[e]=t,this}options(e){for(const t in e)e.hasOwnProperty(t)&&(this._options[t]=e[t]);return this}middlewareOptions(e){return this._middlewareOptions=e,this}version(e){return this.urlComponents.version=e,this}responseType(e){return this._responseType=e,this}select(e){return this.addCsvQueryParameter("$select",e,arguments),this}expand(e){return this.addCsvQueryParameter("$expand",e,arguments),this}orderby(e){return this.addCsvQueryParameter("$orderby",e,arguments),this}filter(e){return this.urlComponents.oDataQueryParams.$filter=e,this}search(e){return this.urlComponents.oDataQueryParams.$search=e,this}top(e){return this.urlComponents.oDataQueryParams.$top=e,this}skip(e){return this.urlComponents.oDataQueryParams.$skip=e,this}skipToken(e){return this.urlComponents.oDataQueryParams.$skipToken=e,this}count(e=!1){return this.urlComponents.oDataQueryParams.$count=e.toString(),this}query(e){return this.parseQueryParameter(e)}get(r){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),s={method:t.GET};try{return yield this.send(e,s,r)}catch(e){throw e}})}post(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),n={method:t.POST,body:A(r)};"FormData"===(r&&r.constructor&&r.constructor.name)?n.headers={}:(this.setHeaderContentType(),n.headers=this._headers);try{return yield this.send(e,n,s)}catch(e){throw e}})}create(t,r){return e(this,void 0,void 0,function*(){try{return yield this.post(t,r)}catch(e){throw e}})}put(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl();this.setHeaderContentType();const n={method:t.PUT,body:A(r)};try{return yield this.send(e,n,s)}catch(e){throw e}})}patch(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl();this.setHeaderContentType();const n={method:t.PATCH,body:A(r)};try{return yield this.send(e,n,s)}catch(e){throw e}})}update(t,r){return e(this,void 0,void 0,function*(){try{return yield this.patch(t,r)}catch(e){throw e}})}delete(r){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),s={method:t.DELETE};try{return yield this.send(e,s,r)}catch(e){throw e}})}del(t){return e(this,void 0,void 0,function*(){try{return yield this.delete(t)}catch(e){throw e}})}getStream(r){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),s={method:t.GET};this.responseType(B.STREAM);try{return yield this.send(e,s,r)}catch(e){throw e}})}putStream(r,s){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),n={method:t.PUT,headers:{"Content-Type":"application/octet-stream"},body:r};try{return yield this.send(e,n,s)}catch(e){throw e}})}}class W{constructor(...e){if(!e||!e.length){const e=new Error;throw e.name="InvalidMiddlewareChain",e.message="Please provide a default middleware chain or custom middleware chain",e}this.setMiddleware(...e)}setMiddleware(...e){e.length>1?this.parseMiddleWareArray(e):this.middleware=e[0]}parseMiddleWareArray(e){e.forEach((t,r)=>{r<e.length-1&&t.setNext(e[r+1])}),this.middleware=e[0]}sendRequest(t){return e(this,void 0,void 0,function*(){try{if("string"==typeof t.request&&void 0===t.options){const e=new Error;throw e.name="InvalidRequestOptions",e.message="Unable to execute the middleware, Please provide valid options for a request",e}return yield this.middleware.execute(t),t}catch(e){throw e}})}}const G=()=>"object"==typeof process&&"function"==typeof require;class J{static createWithAuthenticationProvider(e){const t=new p(e),r=new m(new y),s=new x,n=new f;if(t.setNext(r),G()){const e=new P(new D);r.setNext(e),e.setNext(s)}else r.setNext(s);return s.setNext(n),J.createWithMiddleware(t)}static createWithMiddleware(...e){return new W(...e)}}const Z=()=>{if("undefined"==typeof Promise&&"undefined"==typeof fetch){const e=new Error("Library cannot function without Promise and fetch. So, please provide polyfill for them.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof Promise){const e=new Error("Library cannot function without Promise. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}if("undefined"==typeof fetch){const e=new Error("Library cannot function without fetch. So, please provide polyfill for it.");throw e.name="PolyFillNotAvailable",e}return!0};class K{constructor(e){this.config={baseUrl:g,debugLogging:!1,defaultVersion:E};try{Z()}catch(e){throw e}for(const t in e)e.hasOwnProperty(t)&&(this.config[t]=e[t]);let t;if(void 0!==e.authProvider&&void 0!==e.middleware){const e=new Error;throw e.name="AmbiguityInInitialization",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain not both",e}if(void 0!==e.authProvider)t=J.createWithAuthenticationProvider(e.authProvider);else{if(void 0===e.middleware){const e=new Error;throw e.name="InvalidMiddlewareChain",e.message="Unable to Create Client, Please provide either authentication provider for default middleware chain or custom middleware chain",e}t=new W(...[].concat(e.middleware))}this.httpClient=t}static init(e){const t={};for(const r in e)e.hasOwnProperty(r)&&(t[r]="authProvider"===r?new k(e[r]):e[r]);return K.initWithMiddleware(t)}static initWithMiddleware(e){try{return new K(e)}catch(e){throw e}}api(e){return new z(this.httpClient,this.config,e)}}class ee{constructor(e,t){this.options=t,this.msalApplication=e}getAccessToken(t){return e(this,void 0,void 0,function*(){let e;if(void 0!==t&&(e=t.scopes),void 0!==e&&0!==e.length||(e=this.options.scopes),0===e.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes cannot be empty, Please provide a scopes",e}if(this.msalApplication.getAccount()){const t={scopes:e};try{return(yield this.msalApplication.acquireTokenSilent(t)).accessToken}catch(e){if("InteractionRequiredAuthError"!==e.name)throw e;try{return(yield this.msalApplication.acquireTokenPopup(t)).accessToken}catch(e){throw e}}}else try{const t={scopes:e};return yield this.msalApplication.loginPopup(t),(yield this.msalApplication.acquireTokenSilent(t)).accessToken}catch(e){throw e}})}}class te{constructor(e){this.scopes=e}}export{p as AuthenticationHandler,h as AuthenticationHandlerOptions,r as BatchRequestContent,s as BatchResponseContent,U as ChaosHandler,L as ChaosHandlerOptions,M as ChaosStrategy,K as Client,k as CustomAuthenticationProvider,u as FeatureUsageFlag,$ as GraphError,z as GraphRequest,f as HTTPMessageHandler,ee as ImplicitMSALAuthenticationProvider,q as LargeFileUploadTask,te as MSALAuthenticationProviderOptions,_ as MiddlewareFactory,H as OneDriveLargeFileUploadTask,F as PageIterator,B as ResponseType,m as RetryHandler,y as RetryHandlerOptions,x as TelemetryHandler,l as TelemetryHandlerOptions};

@@ -10,2 +10,2 @@ /**

*/
export declare const PACKAGE_VERSION = "2.2.0-Preview.1";
export declare const PACKAGE_VERSION = "2.2.0";

@@ -14,3 +14,3 @@ "use strict";

*/
exports.PACKAGE_VERSION = "2.2.0-Preview.1";
exports.PACKAGE_VERSION = "2.2.0";
//# sourceMappingURL=Version.js.map
{
"name": "@microsoft/microsoft-graph-client",
"version": "2.2.0-Preview.1",
"version": "2.2.0",
"description": "Microsoft Graph Client Library",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -15,2 +15,2 @@ /**

export const PACKAGE_VERSION = "2.2.0-Preview.1";
export const PACKAGE_VERSION = "2.2.0";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc