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.1.0-Preview.1 to 2.1.0-Preview.2

lib/es/middleware/ChaosHandler.d.ts

4

lib/es/browser/ImplicitMSALAuthenticationProvider.js

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -35,3 +35,3 @@ * @class

getAccessToken(authenticationProviderOptions) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const options = authenticationProviderOptions;

@@ -38,0 +38,0 @@ let scopes;

@@ -14,2 +14,3 @@ /**

export * from "../middleware/TelemetryHandler";
export * from "../middleware/MiddlewareFactory";
export * from "../middleware/options/AuthenticationHandlerOptions";

@@ -19,2 +20,5 @@ export * from "../middleware/options/IMiddlewareOptions";

export * from "../middleware/options/TelemetryHandlerOptions";
export * from "../middleware/options/ChaosHandlerOptions";
export * from "../middleware/options/ChaosStrategy";
export * from "../middleware/ChaosHandler";
export * from "../tasks/LargeFileUploadTask";

@@ -24,2 +28,3 @@ export * from "../tasks/OneDriveLargeFileUploadTask";

export * from "../Client";
export * from "../CustomAuthenticationProvider";
export * from "../GraphError";

@@ -26,0 +31,0 @@ export * from "../GraphRequest";

@@ -13,5 +13,9 @@ /**

export * from "../middleware/TelemetryHandler";
export * from "../middleware/MiddlewareFactory";
export * from "../middleware/options/AuthenticationHandlerOptions";
export * from "../middleware/options/RetryHandlerOptions";
export * from "../middleware/options/TelemetryHandlerOptions";
export * from "../middleware/options/ChaosHandlerOptions";
export * from "../middleware/options/ChaosStrategy";
export * from "../middleware/ChaosHandler";
export * from "../tasks/LargeFileUploadTask";

@@ -21,2 +25,3 @@ export * from "../tasks/OneDriveLargeFileUploadTask";

export * from "../Client";
export * from "../CustomAuthenticationProvider";
export * from "../GraphError";

@@ -23,0 +28,0 @@ export * from "../GraphRequest";

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

import { Options } from "./IOptions";
import { Middleware } from "./middleware/IMiddleware";
export declare class Client {

@@ -48,14 +47,2 @@ /**

* @public
* function to get the array of middlewares in use right now
* @returns An array of middlewares
*/
getMiddlewareChain(): Middleware[];
/**
* @public
* function to set the middleware chain
* @param {Middleware[]} middlewareArray - An array of middlewares
*/
setMiddlewareChain(middlewareArray: Middleware[]): void;
/**
* @public
* Entry point to make requests

@@ -62,0 +49,0 @@ * @param {string} path - The path string value

@@ -55,3 +55,3 @@ /**

else if (clientOptions.middleware !== undefined) {
httpClient = new HTTPClient(clientOptions.middleware);
httpClient = new HTTPClient(...[].concat(clientOptions.middleware));
}

@@ -99,18 +99,2 @@ else {

* @public
* function to get the array of middlewares in use right now
* @returns An array of middlewares
*/
getMiddlewareChain() {
return this.httpClient.getMiddlewareArray();
}
/**
* @public
* function to set the middleware chain
* @param {Middleware[]} middlewareArray - An array of middlewares
*/
setMiddlewareChain(middlewareArray) {
return this.httpClient.setMiddlewareArray(middlewareArray);
}
/**
* @public
* Entry point to make requests

@@ -117,0 +101,0 @@ * @param {string} path - The path string value

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -143,3 +143,3 @@ * @module BatchRequestContent

static getRequestData(request) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const requestData = {

@@ -177,3 +177,3 @@ url: "",

static getRequestBody(request) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let bodyParsed = false;

@@ -287,3 +287,3 @@ let body;

getContent() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const requests = [];

@@ -290,0 +290,0 @@ const requestBody = {

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -32,3 +32,3 @@ * @class

getAccessToken() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {

@@ -35,0 +35,0 @@ this.provider((error, accessToken) => {

@@ -17,3 +17,3 @@ /**

*/
export declare class GraphError {
export declare class GraphError extends Error {
/**

@@ -31,7 +31,2 @@ * @public

* @public
* A member holding error message
*/
message: string | null;
/**
* @public
* A member holding request-id i.e identifier of the request

@@ -57,3 +52,3 @@ */

*/
constructor(statusCode?: number);
constructor(statusCode?: number, message?: string, baseError?: Error);
}

@@ -17,3 +17,3 @@ /**

*/
export class GraphError {
export class GraphError extends Error {
/**

@@ -26,11 +26,12 @@ * @public

*/
constructor(statusCode = -1) {
constructor(statusCode = -1, message, baseError) {
super(message || (baseError && baseError.message));
this.statusCode = statusCode;
this.code = null;
this.message = null;
this.requestId = null;
this.date = new Date();
this.body = null;
this.stack = baseError ? baseError.stack : this.stack;
}
}
//# sourceMappingURL=GraphError.js.map

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -27,3 +27,3 @@ * @module GraphErrorHandler

static constructError(error, statusCode) {
const gError = new GraphError(statusCode);
const gError = new GraphError(statusCode, "", error);
if (error.name !== undefined) {

@@ -33,3 +33,2 @@ gError.code = error.name;

gError.body = error.toString();
gError.message = error.message;
gError.date = new Date();

@@ -61,5 +60,4 @@ return gError;

error = error.error;
const gError = new GraphError(statusCode);
const gError = new GraphError(statusCode, error.message);
gError.code = error.code;
gError.message = error.message;
if (error.innerError !== undefined) {

@@ -88,3 +86,3 @@ gError.requestId = error.innerError["request-id"];

static getError(error = null, statusCode = -1, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let gError;

@@ -91,0 +89,0 @@ if (error && error.error) {

@@ -37,2 +37,3 @@ /**

otherURLQueryParams: KeyValuePairObjectStringNumber;
otherURLQueryOptions: any[];
}

@@ -118,2 +119,31 @@ /**

* @private
* Parses the query parameters to set the urlComponents property of the GraphRequest object
* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query parameter
* @returns The same GraphRequest instance that is being called with
*/
private parseQueryParameter;
/**
* @private
* Parses the query parameter of string type to set the urlComponents property of the GraphRequest object
* @param {string} queryParameter - the query parameters
* returns nothing
*/
private parseQueryParamenterString;
/**
* @private
* Sets values into the urlComponents property of GraphRequest object.
* @param {string} paramKey - the query parameter key
* @param {string} paramValue - the query paramter value
* @returns nothing
*/
private setURLComponentsQueryParamater;
/**
* @private
* Check if the query parameter string has a valid key-value structure
* @param {string} queryString - the query parameter string. Example -> "name=value"
* #returns true if the query string has a valid key-value structure else false
*/
private isValidQueryKeyValuePair;
/**
* @private
* Updates the custom headers and options for a request

@@ -135,2 +165,9 @@ * @param {FetchOptions} options - The request options object

/**
* @private
* Checks if the content-type is present in the _headers property. If not present, defaults the content-type to application/json
* @param none
* @returns nothing
*/
private setHeaderContentType;
/**
* @public

@@ -146,6 +183,6 @@ * Sets the custom header for a request

* Sets the custom headers for a request
* @param {KeyValuePairObjectStringNumber} headers - The headers key value pair object
* @param {KeyValuePairObjectStringNumber | HeadersInit} headers - The request headers
* @returns The same GraphRequest instance that is being called with
*/
headers(headers: KeyValuePairObjectStringNumber): GraphRequest;
headers(headers: KeyValuePairObjectStringNumber | HeadersInit): GraphRequest;
/**

@@ -193,3 +230,3 @@ * @public

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $select query
*/

@@ -201,3 +238,3 @@ select(properties: string | string[]): GraphRequest;

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $expand query
*/

@@ -209,3 +246,3 @@ expand(properties: string | string[]): GraphRequest;

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $orderby query
*/

@@ -215,5 +252,5 @@ orderby(properties: string | string[]): GraphRequest;

* @public
* To add query string for filter OData Query param
* To add query string for filter OData Query param. The request URL accepts only one $filter Odata Query option and its value is set to the most recently passed filter query string.
* @param {string} filterStr - The filter query string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $filter query
*/

@@ -223,5 +260,5 @@ filter(filterStr: string): GraphRequest;

* @public
* To add criterion for search OData Query param
* To add criterion for search OData Query param. The request URL accepts only one $search Odata Query option and its value is set to the most recently passed search criterion string.
* @param {string} searchStr - The search criterion string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $search query criteria
*/

@@ -231,5 +268,5 @@ search(searchStr: string): GraphRequest;

* @public
* To add number for top OData Query param
* To add number for top OData Query param. The request URL accepts only one $top Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for $top query
*/

@@ -239,5 +276,5 @@ top(n: number): GraphRequest;

* @public
* To add number for skip OData Query param
* To add number for skip OData Query param. The request URL accepts only one $skip Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for the $skip query
*/

@@ -247,5 +284,5 @@ skip(n: number): GraphRequest;

* @public
* To add token string for skipToken OData Query param
* To add token string for skipToken OData Query param. The request URL accepts only one $skipToken Odata Query option and its value is set to the most recently passed token value.
* @param {string} token - The token value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the token string for $skipToken query option
*/

@@ -255,5 +292,5 @@ skipToken(token: string): GraphRequest;

* @public
* To add boolean for count OData Query param
* To add boolean for count OData Query param. The URL accepts only one $count Odata Query option and its value is set to the most recently passed boolean value.
* @param {boolean} isCount - The count boolean
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the boolean value for the $count query option
*/

@@ -265,3 +302,3 @@ count(isCount?: boolean): GraphRequest;

* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after appending the query string to the url component
*/

@@ -268,0 +305,0 @@ query(queryDictionaryOrString: string | KeyValuePairObjectStringNumber): GraphRequest;

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { GraphErrorHandler } from "./GraphErrorHandler";

@@ -71,11 +71,3 @@ import { oDataQueryNames, serializeContent, urlJoin } from "./GraphRequestUtil";

for (const queryParam of queryParams) {
const qParams = queryParam.split("=");
const key = qParams[0];
const value = qParams[1];
if (oDataQueryNames.indexOf(key) !== -1) {
this.urlComponents.oDataQueryParams[key] = value;
}
else {
this.urlComponents.otherURLQueryParams[key] = value;
}
this.parseQueryParameter(queryParam);
}

@@ -91,2 +83,3 @@ }

otherURLQueryParams: {},
otherURLQueryOptions: [],
};

@@ -156,2 +149,7 @@ this._headers = {};

}
if (urlComponents.otherURLQueryOptions.length !== 0) {
for (const str of urlComponents.otherURLQueryOptions) {
query.push(str);
}
}
return query.length > 0 ? "?" + query.join("&") : "";

@@ -161,2 +159,92 @@ }

* @private
* Parses the query parameters to set the urlComponents property of the GraphRequest object
* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query parameter
* @returns The same GraphRequest instance that is being called with
*/
parseQueryParameter(queryDictionaryOrString) {
if (typeof queryDictionaryOrString === "string") {
if (queryDictionaryOrString.charAt(0) === "?") {
queryDictionaryOrString = queryDictionaryOrString.substring(1, queryDictionaryOrString.length);
}
if (queryDictionaryOrString.indexOf("&") !== -1) {
const queryParams = queryDictionaryOrString.split("&");
for (const str of queryParams) {
this.parseQueryParamenterString(str);
}
}
else {
this.parseQueryParamenterString(queryDictionaryOrString);
}
}
else if (queryDictionaryOrString.constructor === Object) {
for (const key in queryDictionaryOrString) {
if (queryDictionaryOrString.hasOwnProperty(key)) {
this.setURLComponentsQueryParamater(key, queryDictionaryOrString[key]);
}
}
}
else {
/*Push values which are not of key-value structure.
Example-> Handle an invalid input->.query(123) and let the Graph API respond with the error in the URL*/ this.urlComponents.otherURLQueryOptions.push(queryDictionaryOrString);
}
return this;
}
/**
* @private
* Parses the query parameter of string type to set the urlComponents property of the GraphRequest object
* @param {string} queryParameter - the query parameters
* returns nothing
*/
parseQueryParamenterString(queryParameter) {
/* The query key-value pair must be split on the first equals sign to avoid errors in parsing nested query parameters.
Example-> "/me?$expand=home($select=city)" */
if (this.isValidQueryKeyValuePair(queryParameter)) {
const indexOfFirstEquals = queryParameter.indexOf("=");
const paramKey = queryParameter.substring(0, indexOfFirstEquals);
const paramValue = queryParameter.substring(indexOfFirstEquals + 1, queryParameter.length);
this.setURLComponentsQueryParamater(paramKey, paramValue);
}
else {
/* Push values which are not of key-value structure.
Example-> Handle an invalid input->.query(test), .query($select($select=name)) and let the Graph API respond with the error in the URL*/
this.urlComponents.otherURLQueryOptions.push(queryParameter);
}
}
/**
* @private
* Sets values into the urlComponents property of GraphRequest object.
* @param {string} paramKey - the query parameter key
* @param {string} paramValue - the query paramter value
* @returns nothing
*/
setURLComponentsQueryParamater(paramKey, paramValue) {
if (oDataQueryNames.indexOf(paramKey) !== -1) {
const currentValue = this.urlComponents.oDataQueryParams[paramKey];
const isValueAppendable = currentValue && (paramKey === "$expand" || paramKey === "$select" || paramKey === "$orderby");
this.urlComponents.oDataQueryParams[paramKey] = isValueAppendable ? currentValue + "," + paramValue : paramValue;
}
else {
this.urlComponents.otherURLQueryParams[paramKey] = paramValue;
}
}
/**
* @private
* Check if the query parameter string has a valid key-value structure
* @param {string} queryString - the query parameter string. Example -> "name=value"
* #returns true if the query string has a valid key-value structure else false
*/
isValidQueryKeyValuePair(queryString) {
const indexofFirstEquals = queryString.indexOf("=");
if (indexofFirstEquals === -1) {
return false;
}
const indexofOpeningParanthesis = queryString.indexOf("(");
if (indexofOpeningParanthesis !== -1 && queryString.indexOf("(") < indexofFirstEquals) {
// Example -> .query($select($expand=true));
return false;
}
return true;
}
/**
* @private
* Updates the custom headers and options for a request

@@ -192,3 +280,3 @@ * @param {FetchOptions} options - The request options object

send(request, options, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let rawResponse;

@@ -218,2 +306,22 @@ const middlewareControl = new MiddlewareControl(this._middlewareOptions);

/**
* @private
* Checks if the content-type is present in the _headers property. If not present, defaults the content-type to application/json
* @param none
* @returns nothing
*/
setHeaderContentType() {
if (!this._headers) {
this.header("Content-Type", "application/json");
return;
}
const headerKeys = Object.keys(this._headers);
for (const headerKey of headerKeys) {
if (headerKey.toLowerCase() === "content-type") {
return;
}
}
// Default the content-type to application/json in case the content-type is not present in the header
this.header("Content-Type", "application/json");
}
/**
* @public

@@ -232,3 +340,3 @@ * Sets the custom header for a request

* Sets the custom headers for a request
* @param {KeyValuePairObjectStringNumber} headers - The headers key value pair object
* @param {KeyValuePairObjectStringNumber | HeadersInit} headers - The request headers
* @returns The same GraphRequest instance that is being called with

@@ -303,3 +411,3 @@ */

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $select query
*/

@@ -320,3 +428,3 @@ /*

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $expand query
*/

@@ -331,3 +439,3 @@ expand(properties) {

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $orderby query
*/

@@ -340,5 +448,5 @@ orderby(properties) {

* @public
* To add query string for filter OData Query param
* To add query string for filter OData Query param. The request URL accepts only one $filter Odata Query option and its value is set to the most recently passed filter query string.
* @param {string} filterStr - The filter query string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $filter query
*/

@@ -351,5 +459,5 @@ filter(filterStr) {

* @public
* To add criterion for search OData Query param
* To add criterion for search OData Query param. The request URL accepts only one $search Odata Query option and its value is set to the most recently passed search criterion string.
* @param {string} searchStr - The search criterion string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $search query criteria
*/

@@ -362,5 +470,5 @@ search(searchStr) {

* @public
* To add number for top OData Query param
* To add number for top OData Query param. The request URL accepts only one $top Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for $top query
*/

@@ -373,5 +481,5 @@ top(n) {

* @public
* To add number for skip OData Query param
* To add number for skip OData Query param. The request URL accepts only one $skip Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for the $skip query
*/

@@ -384,5 +492,5 @@ skip(n) {

* @public
* To add token string for skipToken OData Query param
* To add token string for skipToken OData Query param. The request URL accepts only one $skipToken Odata Query option and its value is set to the most recently passed token value.
* @param {string} token - The token value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the token string for $skipToken query option
*/

@@ -395,5 +503,5 @@ skipToken(token) {

* @public
* To add boolean for count OData Query param
* To add boolean for count OData Query param. The URL accepts only one $count Odata Query option and its value is set to the most recently passed boolean value.
* @param {boolean} isCount - The count boolean
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the boolean value for the $count query option
*/

@@ -408,20 +516,10 @@ count(isCount = false) {

* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after appending the query string to the url component
*/
/*
* Accepts .query("displayName=xyz")
* and .select({ name: "value" })
*/
query(queryDictionaryOrString) {
const otherURLQueryParams = this.urlComponents.otherURLQueryParams;
if (typeof queryDictionaryOrString === "string") {
const querySplit = queryDictionaryOrString.split("=");
const queryKey = querySplit[0];
const queryValue = querySplit[1];
otherURLQueryParams[queryKey] = queryValue;
}
else {
for (const key in queryDictionaryOrString) {
if (queryDictionaryOrString.hasOwnProperty(key)) {
otherURLQueryParams[key] = queryDictionaryOrString[key];
}
}
}
return this;
return this.parseQueryParameter(queryDictionaryOrString);
}

@@ -436,3 +534,3 @@ /**

get(callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.buildFullUrl();

@@ -460,3 +558,3 @@ const options = {

post(content, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.buildFullUrl();

@@ -466,8 +564,12 @@ const options = {

body: serializeContent(content),
headers: typeof FormData !== "undefined" && content instanceof FormData
? {}
: {
"Content-Type": "application/json",
},
};
const className = content && content.constructor && content.constructor.name;
if (className === "FormData") {
// Content-Type headers should not be specified in case the of FormData type content
options.headers = {};
}
else {
this.setHeaderContentType();
options.headers = this._headers;
}
try {

@@ -491,3 +593,3 @@ const response = yield this.send(url, options, callback);

create(content, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -510,10 +612,8 @@ return yield this.post(content, callback);

put(content, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.buildFullUrl();
this.setHeaderContentType();
const options = {
method: RequestMethod.PUT,
body: serializeContent(content),
headers: {
"Content-Type": "application/json",
},
};

@@ -538,10 +638,8 @@ try {

patch(content, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.buildFullUrl();
this.setHeaderContentType();
const options = {
method: RequestMethod.PATCH,
body: serializeContent(content),
headers: {
"Content-Type": "application/json",
},
};

@@ -566,3 +664,3 @@ try {

update(content, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -584,3 +682,3 @@ return yield this.patch(content, callback);

delete(callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.buildFullUrl();

@@ -607,3 +705,3 @@ const options = {

del(callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -625,3 +723,3 @@ return yield this.delete(callback);

getStream(callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.buildFullUrl();

@@ -650,3 +748,3 @@ const options = {

putStream(stream, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const url = this.buildFullUrl();

@@ -653,0 +751,0 @@ const options = {

@@ -39,3 +39,3 @@ /**

export const serializeContent = (content) => {
const className = content === undefined ? undefined : content.constructor.name;
const className = content && content.constructor && content.constructor.name;
if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") {

@@ -42,0 +42,0 @@ return content;

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { ResponseType } from "./ResponseType";

@@ -94,3 +94,3 @@ /**

static convertResponse(rawResponse, responseType) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (rawResponse.status === 204) {

@@ -175,3 +175,3 @@ // NO CONTENT

static getResponse(rawResponse, responseType, callback) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -178,0 +178,0 @@ if (responseType === ResponseType.RAW) {

@@ -26,17 +26,20 @@ /**

* Creates an instance of a HTTPClient
* @param {Middleware} middleware - The first middleware of the middleware chain
* @param {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
*/
constructor(middleware: Middleware);
constructor(...middleware: Middleware[]);
/**
* @public
* To get an array of Middleware, used in middleware chain
* @returns An array of middlewares
* @private
* Processes the middleware parameter passed to set this.middleware property
* @param {...Middleware} middleware - The middleware passed
* @returns Nothing
*/
getMiddlewareArray(): Middleware[];
private setMiddleware;
/**
* @public
* To set the middleware chain
* @param {Middleware[]} middlewareArray - The array containing the middlewares
* @private
* Processes the middleware array to construct the chain
* and sets this.middleware property to the first middlware handler of the array
* @param {Middleware[]} middlewareArray - The array of middleware handlers
* @returns Nothing
*/
setMiddlewareArray(middlewareArray: Middleware[]): void;
private parseMiddleWareArray;
/**

@@ -43,0 +46,0 @@ * @public

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -18,35 +18,40 @@ * @class

* Creates an instance of a HTTPClient
* @param {Middleware} middleware - The first middleware of the middleware chain
* @param {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
*/
constructor(middleware) {
this.middleware = middleware;
constructor(...middleware) {
if (!middleware || !middleware.length) {
const error = new Error();
error.name = "InvalidMiddlewareChain";
error.message = "Please provide a default middleware chain or custom middleware chain";
throw error;
}
this.setMiddleware(...middleware);
}
/**
* @public
* To get an array of Middleware, used in middleware chain
* @returns An array of middlewares
* @private
* Processes the middleware parameter passed to set this.middleware property
* @param {...Middleware} middleware - The middleware passed
* @returns Nothing
*/
getMiddlewareArray() {
const middlewareArray = [];
let currentMiddleware = this.middleware;
while (currentMiddleware) {
middlewareArray.push(currentMiddleware);
if (typeof currentMiddleware.getNext !== "undefined") {
currentMiddleware = currentMiddleware.getNext();
}
else {
break;
}
setMiddleware(...middleware) {
if (middleware.length > 1) {
this.parseMiddleWareArray(middleware);
}
return middlewareArray;
else {
this.middleware = middleware[0];
}
}
/**
* @public
* To set the middleware chain
* @param {Middleware[]} middlewareArray - The array containing the middlewares
* @private
* Processes the middleware array to construct the chain
* and sets this.middleware property to the first middlware handler of the array
* @param {Middleware[]} middlewareArray - The array of middleware handlers
* @returns Nothing
*/
setMiddlewareArray(middlewareArray) {
for (let num = 0; num < middlewareArray.length - 1; num += 1) {
middlewareArray[num].setNext(middlewareArray[num + 1]);
}
parseMiddleWareArray(middlewareArray) {
middlewareArray.forEach((element, index) => {
if (index < middlewareArray.length - 1) {
element.setNext(middlewareArray[index + 1]);
}
});
this.middleware = middlewareArray[0];

@@ -62,3 +67,3 @@ }

sendRequest(context) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -65,0 +70,0 @@ if (typeof context.request === "string" && context.options === undefined) {

@@ -36,6 +36,6 @@ /**

* Creates a middleware chain with the given one
* @param {Middleware} middleware - The first middleware of the middleware chain
* @property {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
* @returns A HTTPClient instance
*/
static createWithMiddleware(middleware: Middleware): HTTPClient;
static createWithMiddleware(...middleware: Middleware[]): HTTPClient;
}

@@ -24,3 +24,3 @@ /**

const isNodeEnvironment = () => {
return new Function("try {return this === global;}catch(e){return false;}")(); // tslint:disable-line: function-constructor
return typeof process === "object" && typeof require === "function";
};

@@ -66,9 +66,10 @@ /**

* Creates a middleware chain with the given one
* @param {Middleware} middleware - The first middleware of the middleware chain
* @property {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
* @returns A HTTPClient instance
*/
static createWithMiddleware(middleware) {
return new HTTPClient(middleware);
static createWithMiddleware(...middleware) {
// Middleware should not empty or undefined. This is check is present in the HTTPClient constructor.
return new HTTPClient(...middleware);
}
}
//# sourceMappingURL=HTTPClientFactory.js.map

@@ -18,3 +18,3 @@ /**

* @property {FetchOptions} [fetchOptions] - The options for fetch request
* @property {Middleware} [middleware] - The first middleware of the middleware chain
* @property {Middleware| Middleware[]} [middleware] - The first middleware of the middleware chain or an array of the Middleware handlers
*/

@@ -27,3 +27,3 @@ export interface ClientOptions {

fetchOptions?: FetchOptions;
middleware?: Middleware;
middleware?: Middleware | Middleware[];
}

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -39,3 +39,3 @@ * @module ImplicitMSALAuthenticationProvider

getAccessToken(authenticationProviderOptions) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const options = authenticationProviderOptions;

@@ -42,0 +42,0 @@ let scopes;

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

export * from "./middleware/TelemetryHandler";
export * from "./middleware/MiddlewareFactory";
export * from "./middleware/options/AuthenticationHandlerOptions";

@@ -21,2 +22,5 @@ export * from "./middleware/options/IMiddlewareOptions";

export * from "./middleware/options/TelemetryHandlerOptions";
export * from "./middleware/options/ChaosHandlerOptions";
export * from "./middleware/options/ChaosStrategy";
export * from "./middleware/ChaosHandler";
export * from "./tasks/LargeFileUploadTask";

@@ -26,2 +30,3 @@ export * from "./tasks/OneDriveLargeFileUploadTask";

export * from "./Client";
export * from "./CustomAuthenticationProvider";
export * from "./GraphError";

@@ -28,0 +33,0 @@ export * from "./GraphRequest";

@@ -14,2 +14,3 @@ /**

export * from "./middleware/TelemetryHandler";
export * from "./middleware/MiddlewareFactory";
export * from "./middleware/options/AuthenticationHandlerOptions";

@@ -19,2 +20,5 @@ export * from "./middleware/options/RetryHandlerOptions";

export * from "./middleware/options/TelemetryHandlerOptions";
export * from "./middleware/options/ChaosHandlerOptions";
export * from "./middleware/options/ChaosStrategy";
export * from "./middleware/ChaosHandler";
export * from "./tasks/LargeFileUploadTask";

@@ -24,2 +28,3 @@ export * from "./tasks/OneDriveLargeFileUploadTask";

export * from "./Client";
export * from "./CustomAuthenticationProvider";
export * from "./GraphError";

@@ -26,0 +31,0 @@ export * from "./GraphRequest";

@@ -56,8 +56,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { MiddlewareControl } from "./MiddlewareControl";

@@ -36,3 +36,3 @@ import { appendRequestHeader } from "./MiddlewareUtil";

execute(context) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -72,10 +72,2 @@ let options;

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext() {
return this.nextMiddleware;
}
}

@@ -82,0 +74,0 @@ /**

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -23,3 +23,3 @@ * @class

execute(context) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -26,0 +26,0 @@ context.response = yield fetch(context.request, context.options);

@@ -16,3 +16,2 @@ /**

setNext?: (middleware: Middleware) => void;
getNext?: () => Middleware;
}

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -144,3 +144,3 @@ * @constant

*/
export const cloneRequestWithNewUrl = (newUrl, request) => __awaiter(void 0, void 0, void 0, function* () {
export const cloneRequestWithNewUrl = (newUrl, request) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const body = request.headers.get("Content-Type") ? yield request.blob() : yield Promise.resolve(undefined);

@@ -147,0 +147,0 @@ const { method, headers, referrer, referrerPolicy, mode, credentials, cache, redirect, integrity, keepalive, signal } = request;

@@ -145,8 +145,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { RequestMethod } from "../RequestMethod";

@@ -97,3 +97,3 @@ import { MiddlewareControl } from "./MiddlewareControl";

updateRequestUrl(redirectUrl, context) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
context.request = typeof context.request === "string" ? redirectUrl : yield cloneRequestWithNewUrl(redirectUrl, context.request);

@@ -128,3 +128,3 @@ });

executeWithRedirect(context, redirectCount, options) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -165,3 +165,3 @@ yield this.nextMiddleware.execute(context);

execute(context) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -188,10 +188,2 @@ const redirectCount = 0;

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext() {
return this.nextMiddleware;
}
}

@@ -198,0 +190,0 @@ /**

@@ -121,8 +121,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { RequestMethod } from "../RequestMethod";

@@ -103,3 +103,3 @@ import { MiddlewareControl } from "./MiddlewareControl";

sleep(delaySeconds) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const delayMilliseconds = delaySeconds * 1000;

@@ -129,3 +129,3 @@ return new Promise((resolve) => setTimeout(resolve, delayMilliseconds));

executeWithRetry(context, retryAttempts, options) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -157,3 +157,3 @@ yield this.nextMiddleware.execute(context);

execute(context) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -179,10 +179,2 @@ const retryAttempts = 0;

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext() {
return this.nextMiddleware;
}
}

@@ -189,0 +181,0 @@ /**

@@ -62,8 +62,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { PACKAGE_VERSION } from "../Version";

@@ -27,3 +27,3 @@ import { MiddlewareControl } from "./MiddlewareControl";

execute(context) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -61,10 +61,2 @@ let clientRequestId = getRequestHeader(context.request, context.options, TelemetryHandler.CLIENT_REQUEST_ID_HEADER);

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext() {
return this.nextMiddleware;
}
}

@@ -71,0 +63,0 @@ /**

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { Range } from "../Range";

@@ -51,3 +51,3 @@ /**

static createUploadSession(client, requestUrl, payload, headers = {}) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -131,3 +131,3 @@ const session = yield client

upload() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -166,3 +166,3 @@ while (true) {

uploadSlice(fileSlice, range, totalSize) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -189,3 +189,3 @@ return yield this.client

cancel() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -206,3 +206,3 @@ return yield this.client.api(this.uploadSession.url).delete();

getStatus() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -225,3 +225,3 @@ const response = yield this.client.api(this.uploadSession.url).get();

resume() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -228,0 +228,0 @@ yield this.getStatus();

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
import { LargeFileUploadTask } from "./LargeFileUploadTask";

@@ -49,3 +49,8 @@ import { getValidRangeSize } from "./OneDriveLargeFileUploadTaskUtil";

}
return encodeURI(`/me/drive/root:${path}${fileName}:/createUploadSession`);
// we choose to encode each component of the file path separately because when encoding full URI
// with encodeURI, special characters like # or % in the file name doesn't get encoded as desired
return `/me/drive/root:${path
.split("/")
.map((p) => encodeURIComponent(p))
.join("/")}${encodeURIComponent(fileName)}:/createUploadSession`;
}

@@ -63,3 +68,3 @@ /**

static create(client, file, options) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const name = options.fileName;

@@ -113,3 +118,3 @@ let content;

});
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const payload = {

@@ -136,3 +141,3 @@ item: {

commit(requestUrl) {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -139,0 +144,0 @@ const payload = {

@@ -10,3 +10,5 @@ /**

*/
import { FetchOptions } from "../IFetchOptions";
import { Client } from "../index";
import { MiddlewareOptions } from "../middleware/options/IMiddlewareOptions";
/**

@@ -26,2 +28,14 @@ * Signature representing PageCollection

/**
* Signature to define the request options to be sent during request.
* The values of the GraphRequestOptions properties are passed to the Graph Request object.
* @property {HeadersInit} headers - the header options for the request
* @property {MiddlewareOptions[]} middlewareoptions - The middleware options for the request
* @property {FetchOptions} options - The fetch options for the request
*/
export interface GraphRequestOptions {
headers?: HeadersInit;
middlewareOptions?: MiddlewareOptions[];
options?: FetchOptions;
}
/**
* Signature representing callback for page iterator

@@ -67,2 +81,6 @@ * @property {Function} callback - The callback function which should return boolean to continue the continue/stop the iteration.

/**
* Information to be added to the request
*/
private requestOptions;
/**
* @public

@@ -74,5 +92,6 @@ * @constructor

* @param {PageIteratorCallback} callBack - The callback function
* @param {GraphRequestOptions} requestOptions - The request options
* @returns An instance of a PageIterator
*/
constructor(client: Client, pageCollection: PageCollection, callback: PageIteratorCallback);
constructor(client: Client, pageCollection: PageCollection, callback: PageIteratorCallback, requestOptions?: GraphRequestOptions);
/**

@@ -79,0 +98,0 @@ * @private

@@ -7,3 +7,3 @@ /**

*/
import { __awaiter } from "tslib";
import * as tslib_1 from "tslib";
/**

@@ -21,5 +21,6 @@ * @class

* @param {PageIteratorCallback} callBack - The callback function
* @param {GraphRequestOptions} requestOptions - The request options
* @returns An instance of a PageIterator
*/
constructor(client, pageCollection, callback) {
constructor(client, pageCollection, callback, requestOptions) {
this.client = client;

@@ -31,2 +32,3 @@ this.collection = pageCollection.value;

this.complete = false;
this.requestOptions = requestOptions;
}

@@ -56,5 +58,17 @@ /**

fetchAndUpdateNextPageData() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.client.api(this.nextLink).get();
let graphRequest = this.client.api(this.nextLink);
if (this.requestOptions) {
if (this.requestOptions.headers) {
graphRequest = graphRequest.headers(this.requestOptions.headers);
}
if (this.requestOptions.middlewareOptions) {
graphRequest = graphRequest.middlewareOptions(this.requestOptions.middlewareOptions);
}
if (this.requestOptions.options) {
graphRequest = graphRequest.options(this.requestOptions.options);
}
}
const response = yield graphRequest.get();
this.collection = response.value;

@@ -85,3 +99,3 @@ this.nextLink = response["@odata.nextLink"];

iterate() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -115,3 +129,3 @@ let advance = this.iterationHelper();

resume() {
return __awaiter(this, void 0, void 0, function* () {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -118,0 +132,0 @@ return this.iterate();

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

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

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

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

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

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function e(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{d(r.next(e))}catch(e){s(e)}}function a(e){try{d(r.throw(e))}catch(e){s(e)}}function d(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(o,a)}d((r=r.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 n{constructor(e){if(this.requests=new Map,void 0!==e){const t=n.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 n=t.next();for(;!n.done;){const e=n.value[1];if(void 0!==e.dependsOn&&e.dependsOn.length>0)return!1;n=t.next()}return!0})(e)||(e=>{const t=e.entries();let n=t.next();const r=n.value[1];if(void 0!==r.dependsOn&&r.dependsOn.length>0)return!1;let i=n;for(n=t.next();!n.done;){const e=n.value[1];if(void 0===e.dependsOn||1!==e.dependsOn.length||e.dependsOn[0]!==i.value[1].id)return!1;i=n,n=t.next()}return!0})(e)||(e=>{const t=e.entries();let n=t.next();const r=n.value[1];let i;if(void 0===r.dependsOn||0===r.dependsOn.length)i=r.id;else{if(1!==r.dependsOn.length)return!1;{const t=r.dependsOn[0];if(t===r.id||!e.has(t))return!1;i=t}}for(n=t.next();!n.done;){const e=n.value[1];if((void 0===e.dependsOn||0===e.dependsOn.length)&&i!==e.id)return!1;if(void 0!==e.dependsOn&&0!==e.dependsOn.length){if(1===e.dependsOn.length&&(e.id===i||e.dependsOn[0]!==i))return!1;if(e.dependsOn.length>1)return!1}n=t.next()}return!0})(e)}static getRequestData(r){return e(this,void 0,void 0,(function*(){const e={url:""},i=new RegExp("^https?://");e.url=i.test(r.url)?"/"+r.url.split(/.*?\/\/.*?\//)[1]:r.url,e.method=r.method;const s={};return r.headers.forEach((e,t)=>{s[t]=e}),Object.keys(s).length&&(e.headers=s),r.method!==t.PATCH&&r.method!==t.POST&&r.method!==t.PUT||(e.body=yield n.getRequestBody(r)),e}))}static getRequestBody(t){return e(this,void 0,void 0,(function*(){let e,n=!1;try{const r=t.clone();e=yield r.json(),n=!0}catch(e){}if(!n)try{if("undefined"!=typeof Blob){const n=yield t.blob(),r=new FileReader;e=yield new Promise(e=>{r.addEventListener("load",()=>{const t=r.result,n=new RegExp("^s*data:(.+?/.+?(;.+?=.+?)*)?(;base64)?,(.*)s*$").exec(t);e(n[4])},!1),r.readAsDataURL(n)})}else if("undefined"!=typeof Buffer){e=(yield t.buffer()).toString("base64")}n=!0}catch(e){}return e}))}addRequest(e){const t=n.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),n=this.requests.entries();let r=n.next();for(;!r.done;){const t=r.value[1].dependsOn;if(void 0!==t){const n=t.indexOf(e);-1!==n&&t.splice(n,1),0===t.length&&delete r.value[1].dependsOn}r=n.next()}return t}getContent(){return e(this,void 0,void 0,(function*(){const e=[],t={requests:e},r=this.requests.entries();let i=r.next();if(i.done){const e=new Error("No requests added yet, Please add at least one request.");throw e.name="Empty Payload",e}if(!n.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(;!i.done;){const t=i.value[1],s=yield n.getRequestData(t.request);if(void 0!==s.body&&(void 0===s.headers||void 0===s.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}s.id=t.id,void 0!==t.dependsOn&&t.dependsOn.length>0&&(s.dependsOn=t.dependsOn),e.push(s),i=r.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 n=this.requests.get(e);if(void 0===n.dependsOn&&(n.dependsOn=[]),-1!==n.dependsOn.indexOf(t)){const n=new Error(`Dependency ${t} is already added for the request ${e}`);throw n.name="Duplicate Dependency",n}n.dependsOn.push(t)}else{const n=this.requests.entries();let r,i=n.next();for(;!i.done&&i.value[1].id!==e;)r=i,i=n.next();if(void 0===r){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=r.value[0];if(void 0===i.value[1].dependsOn&&(i.value[1].dependsOn=[]),-1!==i.value[1].dependsOn.indexOf(t)){const n=new Error(`Dependency ${t} is already added for the request ${e}`);throw n.name="Duplicate Dependency",n}i.value[1].dependsOn.push(t)}}}removeDependency(e,t){const n=this.requests.get(e);if(void 0===n||void 0===n.dependsOn||0===n.dependsOn.length)return!1;if(void 0!==t){const e=n.dependsOn.indexOf(t);return-1!==e&&(n.dependsOn.splice(e,1),!0)}return delete n.dependsOn,!0}}n.requestLimit=20;class r{constructor(e){this.responses=new Map,this.update(e)}createResponseObject(e){const t=e.body,n={};if(n.status=e.status,void 0!==e.statusText&&(n.statusText=e.statusText),n.headers=e.headers,void 0!==n.headers&&void 0!==n.headers["Content-Type"]&&"application/json"===n.headers["Content-Type"].split(";")[0]){const e=JSON.stringify(t);return new Response(e,n)}return new Response(t,n)}update(e){this.nextLink=e["@odata.nextLink"];const t=e.responses;for(let e=0,n=t.length;e<n;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 i{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 s=()=>{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,n)=>{let r=null;if("undefined"!=typeof Request&&e instanceof Request)r=e.headers.get(n);else if(void 0!==t&&void 0!==t.headers)if("undefined"!=typeof Headers&&t.headers instanceof Headers)r=t.headers.get(n);else if(t.headers instanceof Array){const e=t.headers;for(let t=0,i=e.length;t<i;t++)if(e[t][0]===n){r=e[t][1];break}}else void 0!==t.headers[n]&&(r=t.headers[n]);return r},a=(e,t,n,r)=>{if("undefined"!=typeof Request&&e instanceof Request)e.headers.set(n,r);else if(void 0!==t)if(void 0===t.headers)t.headers=new Headers({[n]:r});else if("undefined"!=typeof Headers&&t.headers instanceof Headers)t.headers.set(n,r);else if(t.headers instanceof Array){let e=0;const i=t.headers.length;for(;e<i;e++){const i=t.headers[e];if(i[0]===n){i[1]=r;break}}e===i&&t.headers.push([n,r])}else Object.assign(t.headers,{[n]:r})},d=(e,t,n,r)=>{"undefined"!=typeof Request&&e instanceof Request?e.headers.append(n,r):void 0!==t&&(void 0===t.headers?t.headers=new Headers({[n]:r}):"undefined"!=typeof Headers&&t.headers instanceof Headers?t.headers.append(n,r):t.headers instanceof Array?t.headers.push([n,r]):void 0===t.headers?t.headers={[n]:r}:void 0===t.headers[n]?t.headers[n]=r:t.headers[n]+=`, ${r}`)},c=(t,n)=>e(void 0,void 0,void 0,(function*(){const e=n.headers.get("Content-Type")?yield n.blob():yield Promise.resolve(void 0),{method:r,headers:i,referrer:s,referrerPolicy:o,mode:a,credentials:d,cache:c,redirect:h,integrity:l,keepalive:u,signal:p}=n;return new Request(t,{method:r,headers:i,body:e,referrer:s,referrerPolicy:o,mode:a,credentials:d,cache:c,redirect:h,integrity:l,keepalive:u,signal:p})}));class h{constructor(e,t){this.authenticationProvider=e,this.authenticationProviderOptions=t}}var l;!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"}(l||(l={}));class u{constructor(){this.featureUsage=l.NONE}static updateFeatureUsageFlag(e,t){let n;e.middlewareControl instanceof i?n=e.middlewareControl.getMiddlewareOptions(u):e.middlewareControl=new i,void 0===n&&(n=new u,e.middlewareControl.setMiddlewareOptions(u,n)),n.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,n,r;t.middlewareControl instanceof i&&(e=t.middlewareControl.getMiddlewareOptions(h)),void 0!==e&&(n=e.authenticationProvider,r=e.authenticationProviderOptions),void 0===n&&(n=this.authenticationProvider);const s=`Bearer ${yield n.getAccessToken(r)}`;return d(t.request,t.options,p.AUTHORIZATION_HEADER,s),u.updateFeatureUsageFlag(t,l.AUTHENTICATION_HANDLER_ENABLED),yield this.nextMiddleware.execute(t)}catch(e){throw e}}))}setNext(e){this.nextMiddleware=e}getNext(){return this.nextMiddleware}}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,n=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=n}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,n){const r="string"==typeof e?n.method:e.method;if(r===t.PUT||r===t.PATCH||r===t.POST){if("application/octet-stream"===o(e,n,"Content-Type"))return!1}return!0}getDelay(e,t,n){const r=()=>Number(Math.random().toFixed(3)),i=void 0!==e.headers?e.headers.get(m.RETRY_AFTER_HEADER):null;let s;return s=null!==i?Number.isNaN(Number(i))?Math.round((new Date(i).getTime()-Date.now())/1e3):Number(i):t>=2?this.getExponentialBackOffTime(t)+n+r():n+r(),Math.min(s,this.options.getMaxDelay()+r())}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 i&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor)),void 0===t&&(t=Object.assign(new y,this.options)),t}executeWithRetry(t,n,r){return e(this,void 0,void 0,(function*(){try{if(yield this.nextMiddleware.execute(t),n<r.maxRetries&&this.isRetry(t.response)&&this.isBuffered(t.request,t.options)&&r.shouldRetry(r.delay,n,t.request,t.options,t.response)){++n,a(t.request,t.options,m.RETRY_ATTEMPT_HEADER,n.toString());const e=this.getDelay(t.response,n,r.delay);return yield this.sleep(e),yield this.executeWithRetry(t,n,r)}return}catch(e){throw e}}))}execute(t){return e(this,void 0,void 0,(function*(){try{const e=0,n=this.getOptions(t);return u.updateFeatureUsageFlag(t,l.RETRY_HANDLER_ENABLED),yield this.executeWithRetry(t,e,n)}catch(e){throw e}}))}setNext(e){this.nextMiddleware=e}getNext(){return this.nextMiddleware}}m.RETRY_STATUS_CODES=[429,503,504],m.RETRY_ATTEMPT_HEADER="Retry-Attempt",m.RETRY_AFTER_HEADER="Retry-After";const E="2.1.0-Preview.1";class v{execute(t){return e(this,void 0,void 0,(function*(){try{let e=o(t.request,t.options,v.CLIENT_REQUEST_ID_HEADER);null===e&&(e=s(),a(t.request,t.options,v.CLIENT_REQUEST_ID_HEADER,e));let n,r=`${v.PRODUCT_NAME}/${E}`;if(t.middlewareControl instanceof i&&(n=t.middlewareControl.getMiddlewareOptions(u)),void 0!==n){const e=n.getFeatureUsage();r+=` (${v.FEATURE_USAGE_STRING}=${e})`}return d(t.request,t.options,v.SDK_VERSION_HEADER,r),yield this.nextMiddleware.execute(t)}catch(e){throw e}}))}setNext(e){this.nextMiddleware=e}getNext(){return this.nextMiddleware}}v.CLIENT_REQUEST_ID_HEADER="client-request-id",v.SDK_VERSION_HEADER="SdkVersion",v.PRODUCT_NAME="graph-js",v.FEATURE_USAGE_STRING="featureUsage";class w{constructor(e=-1,t=-1){this.minValue=e,this.maxValue=t}}class g{constructor(e,t,n,r={}){this.DEFAULT_FILE_SIZE=5242880,this.client=e,this.file=t,void 0===r.rangeSize&&(r.rangeSize=this.DEFAULT_FILE_SIZE),this.options=r,this.uploadSession=n,this.nextRange=new w(0,this.options.rangeSize-1)}static createUploadSession(t,n,r,i={}){return e(this,void 0,void 0,(function*(){try{const e=yield t.api(n).headers(i).post(r);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 w;const n=t.split("-"),r=parseInt(n[0],10);let i=parseInt(n[1],10);return Number.isNaN(i)&&(i=this.file.size-1),new w(r,i)}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 w(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),n=yield this.uploadSlice(t,e,this.file.size);if(void 0!==n.id)return n;this.updateTaskStatus(n)}}catch(e){throw e}}))}uploadSlice(t,n,r){return e(this,void 0,void 0,(function*(){try{return yield this.client.api(this.uploadSession.url).headers({"Content-Length":`${n.maxValue-n.minValue+1}`,"Content-Range":`bytes ${n.minValue}-${n.maxValue}/${r}`}).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 R=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};class A extends g{constructor(e,t,n,r){super(e,t,n,r)}static constructCreateSessionUrl(e,t=A.DEFAULT_UPLOAD_PATH){return e=e.trim(),""===(t=t.trim())&&(t="/"),"/"!==t[0]&&(t=`/${t}`),"/"!==t[t.length-1]&&(t=`${t}/`),encodeURI(`/me/drive/root:${t}${e}:/createUploadSession`)}static create(t,n,r){return e(this,void 0,void 0,(function*(){const e=r.fileName;let i,s;if("undefined"!=typeof Blob&&n instanceof Blob)s=(i=new File([n],e)).size;else if("undefined"!=typeof File&&n instanceof File)s=(i=n).size;else if("undefined"!=typeof Buffer&&n instanceof Buffer){const e=n;s=e.byteLength-e.byteOffset,i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}try{const n=A.constructCreateSessionUrl(r.fileName,r.path),o=yield A.createUploadSession(t,n,r.fileName),a=R(r.rangeSize);return new A(t,{name:e,content:i,size:s},o,{rangeSize:a})}catch(e){throw e}}))}static createUploadSession(t,n,r){const i=Object.create(null,{createUploadSession:{get:()=>super.createUploadSession}});return e(this,void 0,void 0,(function*(){const e={item:{"@microsoft.graph.conflictBehavior":"rename",name:r}};try{return i.createUploadSession.call(this,t,n,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}}))}}A.DEFAULT_UPLOAD_PATH="/";class T{constructor(e,t,n){this.client=e,this.collection=t.value,this.nextLink=t["@odata.nextLink"],this.deltaLink=t["@odata.deltaLink"],this.callback=n,this.complete=!1}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{const e=yield this.client.api(this.nextLink).get();this.collection=e.value,this.nextLink=e["@odata.nextLink"],this.deltaLink=e["@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}}const x="v1.0",O="https://graph.microsoft.com/";class D{constructor(e){this.provider=e}getAccessToken(){return e(this,void 0,void 0,(function*(){return new Promise((e,t)=>{this.provider((n,r)=>{r?e(r):t(n)})})}))}}class _{constructor(e=-1){this.statusCode=e,this.code=null,this.message=null,this.requestId=null,this.date=new Date,this.body=null}}class b{static constructError(e,t){const n=new _(t);return void 0!==e.name&&(n.code=e.name),n.body=e.toString(),n.message=e.message,n.date=new Date,n}static constructErrorFromResponse(e,t){e=e.error;const n=new _(t);n.code=e.code,n.message=e.message,void 0!==e.innerError&&(n.requestId=e.innerError["request-id"],n.date=new Date(e.innerError.date));try{n.body=JSON.stringify(e)}catch(e){}return n}static getError(t=null,n=-1,r){return e(this,void 0,void 0,(function*(){let e;if(e=t&&t.error?b.constructErrorFromResponse(t,n):"undefined"!=typeof Error&&t instanceof Error?b.constructError(t,n):new _(n),"function"!=typeof r)return e;r(e,null)}))}}const P=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],L=e=>{const t=e=>e.replace(/\/+$/,""),n=e=>e.replace(/^\/+/,"");return Array.prototype.slice.call(e).reduce((e,r)=>[t(e),n(r)].join("/"))},M=e=>{const t=void 0===e?void 0: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};var C,S,U,N;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}(C||(C={})),function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(S||(S={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(U||(U={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(N||(N={}));class q{static parseDocumentResponse(e,t){try{return"undefined"!=typeof DOMParser?new Promise((n,r)=>{e.text().then(e=>{try{const r=(new DOMParser).parseFromString(e,t);n(r)}catch(e){r(e)}})}):Promise.resolve(e.body)}catch(e){throw e}}static convertResponse(t,n){return e(this,void 0,void 0,(function*(){if(204===t.status)return Promise.resolve();let e;try{switch(n){case C.ARRAYBUFFER:e=yield t.arrayBuffer();break;case C.BLOB:e=yield t.blob();break;case C.DOCUMENT:e=yield q.parseDocumentResponse(t,S.TEXT_XML);break;case C.JSON:e=yield t.json();break;case C.STREAM:e=yield Promise.resolve(t.body);break;case C.TEXT:e=yield t.text();break;default:const n=t.headers.get("Content-type");if(null!==n){const r=n.split(";")[0];e=new RegExp(N.DOCUMENT).test(r)?yield q.parseDocumentResponse(t,r):new RegExp(N.IMAGE).test(r)?t.blob():r===U.TEXT_PLAIN?yield t.text():r===U.APPLICATION_JSON?yield t.json():Promise.resolve(t.body)}else e=Promise.resolve(t.body)}}catch(e){throw e}return e}))}static getResponse(t,n,r){return e(this,void 0,void 0,(function*(){try{if(n===C.RAW)return Promise.resolve(t);{const e=yield q.convertResponse(t,n);if(!t.ok)throw e;if("function"!=typeof r)return e;r(null,e)}}catch(e){throw e}}))}}class I{constructor(e,t,n){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 n=e.indexOf("/");-1!==n&&(this.urlComponents.version=e.substring(0,n),e=e.substring(n+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 n=e.substring(t+1,e.length).split("&");for(const e of n){const t=e.split("="),n=t[0],r=t[1];-1!==P.indexOf(n)?this.urlComponents.oDataQueryParams[n]=r:this.urlComponents.otherURLQueryParams[n]=r}}},this.httpClient=e,this.config=t,this.urlComponents={host:this.config.baseUrl,version:this.config.defaultVersion,oDataQueryParams:{},otherURLQueryParams:{}},this._headers={},this._options={},this._middlewareOptions=[],this.parsePath(n)}addCsvQueryParameter(e,t,n){this.urlComponents.oDataQueryParams[e]=this.urlComponents.oDataQueryParams[e]?this.urlComponents.oDataQueryParams[e]+",":"";let r=[];n.length>1&&"string"==typeof t?r=Array.prototype.slice.call(n):"string"==typeof t?r.push(t):r=r.concat(t),this.urlComponents.oDataQueryParams[e]+=r.join(",")}buildFullUrl(){const e=L([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 n in e.oDataQueryParams)e.oDataQueryParams.hasOwnProperty(n)&&t.push(n+"="+e.oDataQueryParams[n]);if(0!==Object.keys(e.otherURLQueryParams).length)for(const n in e.otherURLQueryParams)e.otherURLQueryParams.hasOwnProperty(n)&&t.push(n+"="+e.otherURLQueryParams[n]);return t.length>0?"?"+t.join("&"):""}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,n,r){return e(this,void 0,void 0,(function*(){let e;const s=new i(this._middlewareOptions);this.updateRequestOptions(n);try{return e=(yield this.httpClient.sendRequest({request:t,options:n,middlewareControl:s})).response,yield q.getResponse(e,this._responseType,r)}catch(t){let n;throw void 0!==e&&(n=e.status),yield b.getError(t,n,r)}}))}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){const t=this.urlComponents.otherURLQueryParams;if("string"==typeof e){const n=e.split("="),r=n[0],i=n[1];t[r]=i}else for(const n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return this}get(n){return e(this,void 0,void 0,(function*(){const e=this.buildFullUrl(),r={method:t.GET};try{return yield this.send(e,r,n)}catch(e){throw e}}))}post(n,r){return e(this,void 0,void 0,(function*(){const e=this.buildFullUrl(),i={method:t.POST,body:M(n),headers:"undefined"!=typeof FormData&&n instanceof FormData?{}:{"Content-Type":"application/json"}};try{return yield this.send(e,i,r)}catch(e){throw e}}))}create(t,n){return e(this,void 0,void 0,(function*(){try{return yield this.post(t,n)}catch(e){throw e}}))}put(n,r){return e(this,void 0,void 0,(function*(){const e=this.buildFullUrl(),i={method:t.PUT,body:M(n),headers:{"Content-Type":"application/json"}};try{return yield this.send(e,i,r)}catch(e){throw e}}))}patch(n,r){return e(this,void 0,void 0,(function*(){const e=this.buildFullUrl(),i={method:t.PATCH,body:M(n),headers:{"Content-Type":"application/json"}};try{return yield this.send(e,i,r)}catch(e){throw e}}))}update(t,n){return e(this,void 0,void 0,(function*(){try{return yield this.patch(t,n)}catch(e){throw e}}))}delete(n){return e(this,void 0,void 0,(function*(){const e=this.buildFullUrl(),r={method:t.DELETE};try{return yield this.send(e,r,n)}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(n){return e(this,void 0,void 0,(function*(){const e=this.buildFullUrl(),r={method:t.GET};this.responseType(C.STREAM);try{return yield this.send(e,r,n)}catch(e){throw e}}))}putStream(n,r){return e(this,void 0,void 0,(function*(){const e=this.buildFullUrl(),i={method:t.PUT,headers:{"Content-Type":"application/octet-stream"},body:n};try{return yield this.send(e,i,r)}catch(e){throw e}}))}}class F{constructor(e){this.middleware=e}getMiddlewareArray(){const e=[];let t=this.middleware;for(;t&&(e.push(t),void 0!==t.getNext);)t=t.getNext();return e}setMiddlewareArray(e){for(let t=0;t<e.length-1;t+=1)e[t].setNext(e[t+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}}))}}class H{constructor(e=H.DEFAULT_MAX_REDIRECTS,t=H.DEFAULT_SHOULD_RETRY){if(e>H.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${H.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}}H.DEFAULT_MAX_REDIRECTS=5,H.MAX_MAX_REDIRECTS=20,H.DEFAULT_SHOULD_RETRY=()=>!0;class k{constructor(e=new H){this.options=e}isRedirect(e){return-1!==k.REDIRECT_STATUS_CODES.indexOf(e.status)}hasLocationHeader(e){return e.headers.has(k.LOCATION_HEADER)}getLocationHeader(e){return e.headers.get(k.LOCATION_HEADER)}isRelativeURL(e){return-1===e.indexOf("://")}shouldDropAuthorizationHeader(e,t){const n=/^[A-Za-z].+?:\/\/.+?(?=\/|$)/,r=n.exec(e);let i,s;null!==r&&(i=r[0]);const o=n.exec(t);return null!==o&&(s=o[0]),void 0!==i&&void 0!==s&&i!==s}updateRequestUrl(t,n){return e(this,void 0,void 0,(function*(){n.request="string"==typeof n.request?t:yield c(t,n.request)}))}getOptions(e){let t;return e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(H)),void 0===t&&(t=Object.assign(new H,this.options)),t}executeWithRedirect(n,r,i){return e(this,void 0,void 0,(function*(){try{yield this.nextMiddleware.execute(n);const e=n.response;if(!(r<i.maxRedirects&&this.isRedirect(e)&&this.hasLocationHeader(e)&&i.shouldRedirect(e)))return;if(++r,e.status===k.STATUS_CODE_SEE_OTHER)n.options.method=t.GET,delete n.options.body;else{const t=this.getLocationHeader(e);!this.isRelativeURL(t)&&this.shouldDropAuthorizationHeader(e.url,t)&&a(n.request,n.options,k.AUTHORIZATION_HEADER,void 0),yield this.updateRequestUrl(t,n)}yield this.executeWithRedirect(n,r,i)}catch(e){throw e}}))}execute(t){return e(this,void 0,void 0,(function*(){try{const e=0,n=this.getOptions(t);return t.options.redirect=k.MANUAL_REDIRECT,u.updateFeatureUsageFlag(t,l.REDIRECT_HANDLER_ENABLED),yield this.executeWithRedirect(t,e,n)}catch(e){throw e}}))}setNext(e){this.nextMiddleware=e}getNext(){return this.nextMiddleware}}k.REDIRECT_STATUS_CODES=[301,302,303,307,308],k.STATUS_CODE_SEE_OTHER=303,k.LOCATION_HEADER="Location",k.AUTHORIZATION_HEADER="Authorization",k.MANUAL_REDIRECT="manual";const $=()=>new Function("try {return this === global;}catch(e){return false;}")();class X{static createWithAuthenticationProvider(e){const t=new p(e),n=new m(new y),r=new v,i=new f;if(t.setNext(n),$()){const e=new k(new H);n.setNext(e),e.setNext(r)}else n.setNext(r);return r.setNext(i),X.createWithMiddleware(t)}static createWithMiddleware(e){return new F(e)}}const B=()=>{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 Q{constructor(e){this.config={baseUrl:O,debugLogging:!1,defaultVersion:x};try{B()}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=X.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 F(e.middleware)}this.httpClient=t}static init(e){const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]="authProvider"===n?new D(e[n]):e[n]);return Q.initWithMiddleware(t)}static initWithMiddleware(e){try{return new Q(e)}catch(e){throw e}}getMiddlewareChain(){return this.httpClient.getMiddlewareArray()}setMiddlewareChain(e){return this.httpClient.setMiddlewareArray(e)}api(e){return new I(this.httpClient,this.config,e)}}class j{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 Y{constructor(e){this.scopes=e}}export{p as AuthenticationHandler,h as AuthenticationHandlerOptions,n as BatchRequestContent,r as BatchResponseContent,Q as Client,l as FeatureUsageFlag,_ as GraphError,I as GraphRequest,f as HTTPMessageHandler,j as ImplicitMSALAuthenticationProvider,g as LargeFileUploadTask,Y as MSALAuthenticationProviderOptions,A as OneDriveLargeFileUploadTask,T as PageIterator,C as ResponseType,m as RetryHandler,y as RetryHandlerOptions,v as TelemetryHandler,u 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="2.1.0-Preview.2";class v{execute(t){return e(this,void 0,void 0,function*(){try{let e=o(t.request,t.options,v.CLIENT_REQUEST_ID_HEADER);null===e&&(e=i(),a(t.request,t.options,v.CLIENT_REQUEST_ID_HEADER,e));let r,s=`${v.PRODUCT_NAME}/${E}`;if(t.middlewareControl instanceof n&&(r=t.middlewareControl.getMiddlewareOptions(l)),void 0!==r){const e=r.getFeatureUsage();s+=` (${v.FEATURE_USAGE_STRING}=${e})`}return d(t.request,t.options,v.SDK_VERSION_HEADER,s),yield this.nextMiddleware.execute(t)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}v.CLIENT_REQUEST_ID_HEADER="client-request-id",v.SDK_VERSION_HEADER="SdkVersion",v.PRODUCT_NAME="graph-js",v.FEATURE_USAGE_STRING="featureUsage";class w{constructor(e=w.DEFAULT_MAX_REDIRECTS,t=w.DEFAULT_SHOULD_RETRY){if(e>w.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${w.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}}w.DEFAULT_MAX_REDIRECTS=5,w.MAX_MAX_REDIRECTS=20,w.DEFAULT_SHOULD_RETRY=()=>!0;class g{constructor(e=new w){this.options=e}isRedirect(e){return-1!==g.REDIRECT_STATUS_CODES.indexOf(e.status)}hasLocationHeader(e){return e.headers.has(g.LOCATION_HEADER)}getLocationHeader(e){return e.headers.get(g.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(w)),void 0===t&&(t=Object.assign(new w,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===g.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)&&a(r.request,r.options,g.AUTHORIZATION_HEADER,void 0),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=g.MANUAL_REDIRECT,l.updateFeatureUsageFlag(t,u.REDIRECT_HANDLER_ENABLED),yield this.executeWithRedirect(t,e,r)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}g.REDIRECT_STATUS_CODES=[301,302,303,307,308],g.STATUS_CODE_SEE_OTHER=303,g.LOCATION_HEADER="Location",g.AUTHORIZATION_HEADER="Authorization",g.MANUAL_REDIRECT="manual";const R=()=>"object"==typeof process&&"function"==typeof require;class A{static getDefaultMiddlewareChain(e){const t=[],r=new p(e),s=new m(new y),n=new v,i=new f;if(t.push(r),t.push(s),R()){const e=new g(new w);t.push(e)}return t.push(n),t.push(i),t}}var T;!function(e){e[e.MANUAL=0]="MANUAL",e[e.RANDOM=1]="RANDOM"}(T||(T={}));class O{constructor(e=T.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 x={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]},D={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 P{constructor(e=new O,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:D[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=x[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===T.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(O)),void 0===t&&(t=Object.assign(new O,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 C{constructor(e=-1,t=-1){this.minValue=e,this.maxValue=t}}class M{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 C(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 C;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 C(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 C(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 _=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};class L extends M{constructor(e,t,r,s){super(e,t,r,s)}static constructCreateSessionUrl(e,t=L.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=L.constructCreateSessionUrl(s.fileName,s.path),o=yield L.createUploadSession(t,r,s.fileName),a=_(s.rangeSize);return new L(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}})}}L.DEFAULT_UPLOAD_PATH="/";class b{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}}const S="v1.0",U="https://graph.microsoft.com/";class N{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 q extends Error{constructor(e=-1,t,r){super(t||r&&r.message),this.statusCode=e,this.code=null,this.requestId=null,this.date=new Date,this.body=null,this.stack=r?r.stack:this.stack}}class I{static constructError(e,t){const r=new q(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 q(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?I.constructErrorFromResponse(t,r):"undefined"!=typeof Error&&t instanceof Error?I.constructError(t,r):new q(r),"function"!=typeof s)return e;s(e,null)})}}const H=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],F=e=>{const t=e=>e.replace(/\/+$/,""),r=e=>e.replace(/^\/+/,"");return Array.prototype.slice.call(e).reduce((e,s)=>[t(e),r(s)].join("/"))},k=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};var $,Q,B,X;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}($||($={})),function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(Q||(Q={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(B||(B={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(X||(X={}));class j{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 $.ARRAYBUFFER:e=yield t.arrayBuffer();break;case $.BLOB:e=yield t.blob();break;case $.DOCUMENT:e=yield j.parseDocumentResponse(t,Q.TEXT_XML);break;case $.JSON:e=yield t.json();break;case $.STREAM:e=yield Promise.resolve(t.body);break;case $.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(X.DOCUMENT).test(r)?yield j.parseDocumentResponse(t,r):new RegExp(X.IMAGE).test(r)?t.blob():r===B.TEXT_PLAIN?yield t.text():r===B.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===$.RAW)return Promise.resolve(t);{const e=yield j.convertResponse(t,r);if(!t.ok)throw e;if("function"!=typeof s)return e;s(null,e)}}catch(e){throw e}})}}class Y{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=F([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,e.length)),-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]);else this.urlComponents.otherURLQueryOptions.push(e);return this}parseQueryParamenterString(e){if(this.isValidQueryKeyValuePair(e)){const t=e.indexOf("="),r=e.substring(0,t),s=e.substring(t+1,e.length);this.setURLComponentsQueryParamater(r,s)}else this.urlComponents.otherURLQueryOptions.push(e)}setURLComponentsQueryParamater(e,t){if(-1!==H.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 j.getResponse(e,this._responseType,s)}catch(t){let r;throw void 0!==e&&(r=e.status),yield I.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:k(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:k(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:k(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($.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 V{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 z=()=>"object"==typeof process&&"function"==typeof require;class W{static createWithAuthenticationProvider(e){const t=new p(e),r=new m(new y),s=new v,n=new f;if(t.setNext(r),z()){const e=new g(new w);r.setNext(e),e.setNext(s)}else r.setNext(s);return s.setNext(n),W.createWithMiddleware(t)}static createWithMiddleware(...e){return new V(...e)}}const G=()=>{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 J{constructor(e){this.config={baseUrl:U,debugLogging:!1,defaultVersion:S};try{G()}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=W.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 V(...[].concat(e.middleware))}this.httpClient=t}static init(e){const t={};for(const r in e)e.hasOwnProperty(r)&&(t[r]="authProvider"===r?new N(e[r]):e[r]);return J.initWithMiddleware(t)}static initWithMiddleware(e){try{return new J(e)}catch(e){throw e}}api(e){return new Y(this.httpClient,this.config,e)}}class Z{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 K{constructor(e){this.scopes=e}}export{p as AuthenticationHandler,h as AuthenticationHandlerOptions,r as BatchRequestContent,s as BatchResponseContent,P as ChaosHandler,O as ChaosHandlerOptions,T as ChaosStrategy,J as Client,N as CustomAuthenticationProvider,u as FeatureUsageFlag,q as GraphError,Y as GraphRequest,f as HTTPMessageHandler,Z as ImplicitMSALAuthenticationProvider,M as LargeFileUploadTask,K as MSALAuthenticationProviderOptions,A as MiddlewareFactory,L as OneDriveLargeFileUploadTask,b as PageIterator,$ as ResponseType,m as RetryHandler,y as RetryHandlerOptions,v as TelemetryHandler,l as TelemetryHandlerOptions};

@@ -14,2 +14,3 @@ /**

export * from "../middleware/TelemetryHandler";
export * from "../middleware/MiddlewareFactory";
export * from "../middleware/options/AuthenticationHandlerOptions";

@@ -19,2 +20,5 @@ export * from "../middleware/options/IMiddlewareOptions";

export * from "../middleware/options/TelemetryHandlerOptions";
export * from "../middleware/options/ChaosHandlerOptions";
export * from "../middleware/options/ChaosStrategy";
export * from "../middleware/ChaosHandler";
export * from "../tasks/LargeFileUploadTask";

@@ -24,2 +28,3 @@ export * from "../tasks/OneDriveLargeFileUploadTask";

export * from "../Client";
export * from "../CustomAuthenticationProvider";
export * from "../GraphError";

@@ -26,0 +31,0 @@ export * from "../GraphRequest";

@@ -16,5 +16,9 @@ "use strict";

tslib_1.__exportStar(require("../middleware/TelemetryHandler"), exports);
tslib_1.__exportStar(require("../middleware/MiddlewareFactory"), exports);
tslib_1.__exportStar(require("../middleware/options/AuthenticationHandlerOptions"), exports);
tslib_1.__exportStar(require("../middleware/options/RetryHandlerOptions"), exports);
tslib_1.__exportStar(require("../middleware/options/TelemetryHandlerOptions"), exports);
tslib_1.__exportStar(require("../middleware/options/ChaosHandlerOptions"), exports);
tslib_1.__exportStar(require("../middleware/options/ChaosStrategy"), exports);
tslib_1.__exportStar(require("../middleware/ChaosHandler"), exports);
tslib_1.__exportStar(require("../tasks/LargeFileUploadTask"), exports);

@@ -24,2 +28,3 @@ tslib_1.__exportStar(require("../tasks/OneDriveLargeFileUploadTask"), exports);

tslib_1.__exportStar(require("../Client"), exports);
tslib_1.__exportStar(require("../CustomAuthenticationProvider"), exports);
tslib_1.__exportStar(require("../GraphError"), exports);

@@ -26,0 +31,0 @@ tslib_1.__exportStar(require("../GraphRequest"), exports);

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

import { Options } from "./IOptions";
import { Middleware } from "./middleware/IMiddleware";
export declare class Client {

@@ -48,14 +47,2 @@ /**

* @public
* function to get the array of middlewares in use right now
* @returns An array of middlewares
*/
getMiddlewareChain(): Middleware[];
/**
* @public
* function to set the middleware chain
* @param {Middleware[]} middlewareArray - An array of middlewares
*/
setMiddlewareChain(middlewareArray: Middleware[]): void;
/**
* @public
* Entry point to make requests

@@ -62,0 +49,0 @@ * @param {string} path - The path string value

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

else if (clientOptions.middleware !== undefined) {
httpClient = new HTTPClient_1.HTTPClient(clientOptions.middleware);
httpClient = new (HTTPClient_1.HTTPClient.bind.apply(HTTPClient_1.HTTPClient, [void 0].concat([].concat(clientOptions.middleware))))();
}

@@ -101,18 +101,2 @@ else {

* @public
* function to get the array of middlewares in use right now
* @returns An array of middlewares
*/
Client.prototype.getMiddlewareChain = function () {
return this.httpClient.getMiddlewareArray();
};
/**
* @public
* function to set the middleware chain
* @param {Middleware[]} middlewareArray - An array of middlewares
*/
Client.prototype.setMiddlewareChain = function (middlewareArray) {
return this.httpClient.setMiddlewareArray(middlewareArray);
};
/**
* @public
* Entry point to make requests

@@ -119,0 +103,0 @@ * @param {string} path - The path string value

@@ -17,3 +17,3 @@ /**

*/
export declare class GraphError {
export declare class GraphError extends Error {
/**

@@ -31,7 +31,2 @@ * @public

* @public
* A member holding error message
*/
message: string | null;
/**
* @public
* A member holding request-id i.e identifier of the request

@@ -57,3 +52,3 @@ */

*/
constructor(statusCode?: number);
constructor(statusCode?: number, message?: string, baseError?: Error);
}

@@ -9,2 +9,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/**

@@ -20,3 +21,4 @@ * @module GraphError

*/
var GraphError = /** @class */ (function () {
var GraphError = /** @class */ (function (_super) {
tslib_1.__extends(GraphError, _super);
/**

@@ -29,14 +31,16 @@ * @public

*/
function GraphError(statusCode) {
function GraphError(statusCode, message, baseError) {
if (statusCode === void 0) { statusCode = -1; }
this.statusCode = statusCode;
this.code = null;
this.message = null;
this.requestId = null;
this.date = new Date();
this.body = null;
var _this = _super.call(this, message || (baseError && baseError.message)) || this;
_this.statusCode = statusCode;
_this.code = null;
_this.requestId = null;
_this.date = new Date();
_this.body = null;
_this.stack = baseError ? baseError.stack : _this.stack;
return _this;
}
return GraphError;
}());
}(Error));
exports.GraphError = GraphError;
//# sourceMappingURL=GraphError.js.map

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

GraphErrorHandler.constructError = function (error, statusCode) {
var gError = new GraphError_1.GraphError(statusCode);
var gError = new GraphError_1.GraphError(statusCode, "", error);
if (error.name !== undefined) {

@@ -36,3 +36,2 @@ gError.code = error.name;

gError.body = error.toString();
gError.message = error.message;
gError.date = new Date();

@@ -64,5 +63,4 @@ return gError;

error = error.error;
var gError = new GraphError_1.GraphError(statusCode);
var gError = new GraphError_1.GraphError(statusCode, error.message);
gError.code = error.code;
gError.message = error.message;
if (error.innerError !== undefined) {

@@ -69,0 +67,0 @@ gError.requestId = error.innerError["request-id"];

@@ -37,2 +37,3 @@ /**

otherURLQueryParams: KeyValuePairObjectStringNumber;
otherURLQueryOptions: any[];
}

@@ -118,2 +119,31 @@ /**

* @private
* Parses the query parameters to set the urlComponents property of the GraphRequest object
* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query parameter
* @returns The same GraphRequest instance that is being called with
*/
private parseQueryParameter;
/**
* @private
* Parses the query parameter of string type to set the urlComponents property of the GraphRequest object
* @param {string} queryParameter - the query parameters
* returns nothing
*/
private parseQueryParamenterString;
/**
* @private
* Sets values into the urlComponents property of GraphRequest object.
* @param {string} paramKey - the query parameter key
* @param {string} paramValue - the query paramter value
* @returns nothing
*/
private setURLComponentsQueryParamater;
/**
* @private
* Check if the query parameter string has a valid key-value structure
* @param {string} queryString - the query parameter string. Example -> "name=value"
* #returns true if the query string has a valid key-value structure else false
*/
private isValidQueryKeyValuePair;
/**
* @private
* Updates the custom headers and options for a request

@@ -135,2 +165,9 @@ * @param {FetchOptions} options - The request options object

/**
* @private
* Checks if the content-type is present in the _headers property. If not present, defaults the content-type to application/json
* @param none
* @returns nothing
*/
private setHeaderContentType;
/**
* @public

@@ -146,6 +183,6 @@ * Sets the custom header for a request

* Sets the custom headers for a request
* @param {KeyValuePairObjectStringNumber} headers - The headers key value pair object
* @param {KeyValuePairObjectStringNumber | HeadersInit} headers - The request headers
* @returns The same GraphRequest instance that is being called with
*/
headers(headers: KeyValuePairObjectStringNumber): GraphRequest;
headers(headers: KeyValuePairObjectStringNumber | HeadersInit): GraphRequest;
/**

@@ -193,3 +230,3 @@ * @public

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $select query
*/

@@ -201,3 +238,3 @@ select(properties: string | string[]): GraphRequest;

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $expand query
*/

@@ -209,3 +246,3 @@ expand(properties: string | string[]): GraphRequest;

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $orderby query
*/

@@ -215,5 +252,5 @@ orderby(properties: string | string[]): GraphRequest;

* @public
* To add query string for filter OData Query param
* To add query string for filter OData Query param. The request URL accepts only one $filter Odata Query option and its value is set to the most recently passed filter query string.
* @param {string} filterStr - The filter query string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $filter query
*/

@@ -223,5 +260,5 @@ filter(filterStr: string): GraphRequest;

* @public
* To add criterion for search OData Query param
* To add criterion for search OData Query param. The request URL accepts only one $search Odata Query option and its value is set to the most recently passed search criterion string.
* @param {string} searchStr - The search criterion string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $search query criteria
*/

@@ -231,5 +268,5 @@ search(searchStr: string): GraphRequest;

* @public
* To add number for top OData Query param
* To add number for top OData Query param. The request URL accepts only one $top Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for $top query
*/

@@ -239,5 +276,5 @@ top(n: number): GraphRequest;

* @public
* To add number for skip OData Query param
* To add number for skip OData Query param. The request URL accepts only one $skip Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for the $skip query
*/

@@ -247,5 +284,5 @@ skip(n: number): GraphRequest;

* @public
* To add token string for skipToken OData Query param
* To add token string for skipToken OData Query param. The request URL accepts only one $skipToken Odata Query option and its value is set to the most recently passed token value.
* @param {string} token - The token value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the token string for $skipToken query option
*/

@@ -255,5 +292,5 @@ skipToken(token: string): GraphRequest;

* @public
* To add boolean for count OData Query param
* To add boolean for count OData Query param. The URL accepts only one $count Odata Query option and its value is set to the most recently passed boolean value.
* @param {boolean} isCount - The count boolean
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the boolean value for the $count query option
*/

@@ -265,3 +302,3 @@ count(isCount?: boolean): GraphRequest;

* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after appending the query string to the url component
*/

@@ -268,0 +305,0 @@ query(queryDictionaryOrString: string | KeyValuePairObjectStringNumber): GraphRequest;

@@ -74,11 +74,3 @@ "use strict";

var queryParam = queryParams_1[_i];
var qParams = queryParam.split("=");
var key = qParams[0];
var value = qParams[1];
if (GraphRequestUtil_1.oDataQueryNames.indexOf(key) !== -1) {
_this.urlComponents.oDataQueryParams[key] = value;
}
else {
_this.urlComponents.otherURLQueryParams[key] = value;
}
_this.parseQueryParameter(queryParam);
}

@@ -94,2 +86,3 @@ }

otherURLQueryParams: {},
otherURLQueryOptions: [],
};

@@ -159,2 +152,8 @@ this._headers = {};

}
if (urlComponents.otherURLQueryOptions.length !== 0) {
for (var _i = 0, _a = urlComponents.otherURLQueryOptions; _i < _a.length; _i++) {
var str = _a[_i];
query.push(str);
}
}
return query.length > 0 ? "?" + query.join("&") : "";

@@ -164,2 +163,93 @@ };

* @private
* Parses the query parameters to set the urlComponents property of the GraphRequest object
* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query parameter
* @returns The same GraphRequest instance that is being called with
*/
GraphRequest.prototype.parseQueryParameter = function (queryDictionaryOrString) {
if (typeof queryDictionaryOrString === "string") {
if (queryDictionaryOrString.charAt(0) === "?") {
queryDictionaryOrString = queryDictionaryOrString.substring(1, queryDictionaryOrString.length);
}
if (queryDictionaryOrString.indexOf("&") !== -1) {
var queryParams = queryDictionaryOrString.split("&");
for (var _i = 0, queryParams_2 = queryParams; _i < queryParams_2.length; _i++) {
var str = queryParams_2[_i];
this.parseQueryParamenterString(str);
}
}
else {
this.parseQueryParamenterString(queryDictionaryOrString);
}
}
else if (queryDictionaryOrString.constructor === Object) {
for (var key in queryDictionaryOrString) {
if (queryDictionaryOrString.hasOwnProperty(key)) {
this.setURLComponentsQueryParamater(key, queryDictionaryOrString[key]);
}
}
}
else {
/*Push values which are not of key-value structure.
Example-> Handle an invalid input->.query(123) and let the Graph API respond with the error in the URL*/ this.urlComponents.otherURLQueryOptions.push(queryDictionaryOrString);
}
return this;
};
/**
* @private
* Parses the query parameter of string type to set the urlComponents property of the GraphRequest object
* @param {string} queryParameter - the query parameters
* returns nothing
*/
GraphRequest.prototype.parseQueryParamenterString = function (queryParameter) {
/* The query key-value pair must be split on the first equals sign to avoid errors in parsing nested query parameters.
Example-> "/me?$expand=home($select=city)" */
if (this.isValidQueryKeyValuePair(queryParameter)) {
var indexOfFirstEquals = queryParameter.indexOf("=");
var paramKey = queryParameter.substring(0, indexOfFirstEquals);
var paramValue = queryParameter.substring(indexOfFirstEquals + 1, queryParameter.length);
this.setURLComponentsQueryParamater(paramKey, paramValue);
}
else {
/* Push values which are not of key-value structure.
Example-> Handle an invalid input->.query(test), .query($select($select=name)) and let the Graph API respond with the error in the URL*/
this.urlComponents.otherURLQueryOptions.push(queryParameter);
}
};
/**
* @private
* Sets values into the urlComponents property of GraphRequest object.
* @param {string} paramKey - the query parameter key
* @param {string} paramValue - the query paramter value
* @returns nothing
*/
GraphRequest.prototype.setURLComponentsQueryParamater = function (paramKey, paramValue) {
if (GraphRequestUtil_1.oDataQueryNames.indexOf(paramKey) !== -1) {
var currentValue = this.urlComponents.oDataQueryParams[paramKey];
var isValueAppendable = currentValue && (paramKey === "$expand" || paramKey === "$select" || paramKey === "$orderby");
this.urlComponents.oDataQueryParams[paramKey] = isValueAppendable ? currentValue + "," + paramValue : paramValue;
}
else {
this.urlComponents.otherURLQueryParams[paramKey] = paramValue;
}
};
/**
* @private
* Check if the query parameter string has a valid key-value structure
* @param {string} queryString - the query parameter string. Example -> "name=value"
* #returns true if the query string has a valid key-value structure else false
*/
GraphRequest.prototype.isValidQueryKeyValuePair = function (queryString) {
var indexofFirstEquals = queryString.indexOf("=");
if (indexofFirstEquals === -1) {
return false;
}
var indexofOpeningParanthesis = queryString.indexOf("(");
if (indexofOpeningParanthesis !== -1 && queryString.indexOf("(") < indexofFirstEquals) {
// Example -> .query($select($expand=true));
return false;
}
return true;
};
/**
* @private
* Updates the custom headers and options for a request

@@ -233,2 +323,23 @@ * @param {FetchOptions} options - The request options object

/**
* @private
* Checks if the content-type is present in the _headers property. If not present, defaults the content-type to application/json
* @param none
* @returns nothing
*/
GraphRequest.prototype.setHeaderContentType = function () {
if (!this._headers) {
this.header("Content-Type", "application/json");
return;
}
var headerKeys = Object.keys(this._headers);
for (var _i = 0, headerKeys_1 = headerKeys; _i < headerKeys_1.length; _i++) {
var headerKey = headerKeys_1[_i];
if (headerKey.toLowerCase() === "content-type") {
return;
}
}
// Default the content-type to application/json in case the content-type is not present in the header
this.header("Content-Type", "application/json");
};
/**
* @public

@@ -247,3 +358,3 @@ * Sets the custom header for a request

* Sets the custom headers for a request
* @param {KeyValuePairObjectStringNumber} headers - The headers key value pair object
* @param {KeyValuePairObjectStringNumber | HeadersInit} headers - The request headers
* @returns The same GraphRequest instance that is being called with

@@ -318,3 +429,3 @@ */

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $select query
*/

@@ -335,3 +446,3 @@ /*

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $expand query
*/

@@ -346,3 +457,3 @@ GraphRequest.prototype.expand = function (properties) {

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $orderby query
*/

@@ -355,5 +466,5 @@ GraphRequest.prototype.orderby = function (properties) {

* @public
* To add query string for filter OData Query param
* To add query string for filter OData Query param. The request URL accepts only one $filter Odata Query option and its value is set to the most recently passed filter query string.
* @param {string} filterStr - The filter query string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $filter query
*/

@@ -366,5 +477,5 @@ GraphRequest.prototype.filter = function (filterStr) {

* @public
* To add criterion for search OData Query param
* To add criterion for search OData Query param. The request URL accepts only one $search Odata Query option and its value is set to the most recently passed search criterion string.
* @param {string} searchStr - The search criterion string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $search query criteria
*/

@@ -377,5 +488,5 @@ GraphRequest.prototype.search = function (searchStr) {

* @public
* To add number for top OData Query param
* To add number for top OData Query param. The request URL accepts only one $top Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for $top query
*/

@@ -388,5 +499,5 @@ GraphRequest.prototype.top = function (n) {

* @public
* To add number for skip OData Query param
* To add number for skip OData Query param. The request URL accepts only one $skip Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for the $skip query
*/

@@ -399,5 +510,5 @@ GraphRequest.prototype.skip = function (n) {

* @public
* To add token string for skipToken OData Query param
* To add token string for skipToken OData Query param. The request URL accepts only one $skipToken Odata Query option and its value is set to the most recently passed token value.
* @param {string} token - The token value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the token string for $skipToken query option
*/

@@ -410,5 +521,5 @@ GraphRequest.prototype.skipToken = function (token) {

* @public
* To add boolean for count OData Query param
* To add boolean for count OData Query param. The URL accepts only one $count Odata Query option and its value is set to the most recently passed boolean value.
* @param {boolean} isCount - The count boolean
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the boolean value for the $count query option
*/

@@ -424,20 +535,10 @@ GraphRequest.prototype.count = function (isCount) {

* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after appending the query string to the url component
*/
/*
* Accepts .query("displayName=xyz")
* and .select({ name: "value" })
*/
GraphRequest.prototype.query = function (queryDictionaryOrString) {
var otherURLQueryParams = this.urlComponents.otherURLQueryParams;
if (typeof queryDictionaryOrString === "string") {
var querySplit = queryDictionaryOrString.split("=");
var queryKey = querySplit[0];
var queryValue = querySplit[1];
otherURLQueryParams[queryKey] = queryValue;
}
else {
for (var key in queryDictionaryOrString) {
if (queryDictionaryOrString.hasOwnProperty(key)) {
otherURLQueryParams[key] = queryDictionaryOrString[key];
}
}
}
return this;
return this.parseQueryParameter(queryDictionaryOrString);
};

@@ -486,3 +587,3 @@ /**

return tslib_1.__awaiter(this, void 0, void 0, function () {
var url, options, response, error_3;
var url, options, className, response, error_3;
return tslib_1.__generator(this, function (_a) {

@@ -495,8 +596,12 @@ switch (_a.label) {

body: GraphRequestUtil_1.serializeContent(content),
headers: typeof FormData !== "undefined" && content instanceof FormData
? {}
: {
"Content-Type": "application/json",
},
};
className = content && content.constructor && content.constructor.name;
if (className === "FormData") {
// Content-Type headers should not be specified in case the of FormData type content
options.headers = {};
}
else {
this.setHeaderContentType();
options.headers = this._headers;
}
_a.label = 1;

@@ -557,8 +662,6 @@ case 1:

url = this.buildFullUrl();
this.setHeaderContentType();
options = {
method: RequestMethod_1.RequestMethod.PUT,
body: GraphRequestUtil_1.serializeContent(content),
headers: {
"Content-Type": "application/json",
},
};

@@ -595,8 +698,6 @@ _a.label = 1;

url = this.buildFullUrl();
this.setHeaderContentType();
options = {
method: RequestMethod_1.RequestMethod.PATCH,
body: GraphRequestUtil_1.serializeContent(content),
headers: {
"Content-Type": "application/json",
},
};

@@ -603,0 +704,0 @@ _a.label = 1;

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

exports.serializeContent = function (content) {
var className = content === undefined ? undefined : content.constructor.name;
var className = content && content.constructor && content.constructor.name;
if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") {

@@ -44,0 +44,0 @@ return content;

@@ -26,17 +26,20 @@ /**

* Creates an instance of a HTTPClient
* @param {Middleware} middleware - The first middleware of the middleware chain
* @param {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
*/
constructor(middleware: Middleware);
constructor(...middleware: Middleware[]);
/**
* @public
* To get an array of Middleware, used in middleware chain
* @returns An array of middlewares
* @private
* Processes the middleware parameter passed to set this.middleware property
* @param {...Middleware} middleware - The middleware passed
* @returns Nothing
*/
getMiddlewareArray(): Middleware[];
private setMiddleware;
/**
* @public
* To set the middleware chain
* @param {Middleware[]} middlewareArray - The array containing the middlewares
* @private
* Processes the middleware array to construct the chain
* and sets this.middleware property to the first middlware handler of the array
* @param {Middleware[]} middlewareArray - The array of middleware handlers
* @returns Nothing
*/
setMiddlewareArray(middlewareArray: Middleware[]): void;
private parseMiddleWareArray;
/**

@@ -43,0 +46,0 @@ * @public

@@ -19,35 +19,48 @@ "use strict";

* Creates an instance of a HTTPClient
* @param {Middleware} middleware - The first middleware of the middleware chain
* @param {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
*/
function HTTPClient(middleware) {
this.middleware = middleware;
function HTTPClient() {
var middleware = [];
for (var _i = 0; _i < arguments.length; _i++) {
middleware[_i] = arguments[_i];
}
if (!middleware || !middleware.length) {
var error = new Error();
error.name = "InvalidMiddlewareChain";
error.message = "Please provide a default middleware chain or custom middleware chain";
throw error;
}
this.setMiddleware.apply(this, middleware);
}
/**
* @public
* To get an array of Middleware, used in middleware chain
* @returns An array of middlewares
* @private
* Processes the middleware parameter passed to set this.middleware property
* @param {...Middleware} middleware - The middleware passed
* @returns Nothing
*/
HTTPClient.prototype.getMiddlewareArray = function () {
var middlewareArray = [];
var currentMiddleware = this.middleware;
while (currentMiddleware) {
middlewareArray.push(currentMiddleware);
if (typeof currentMiddleware.getNext !== "undefined") {
currentMiddleware = currentMiddleware.getNext();
}
else {
break;
}
HTTPClient.prototype.setMiddleware = function () {
var middleware = [];
for (var _i = 0; _i < arguments.length; _i++) {
middleware[_i] = arguments[_i];
}
return middlewareArray;
if (middleware.length > 1) {
this.parseMiddleWareArray(middleware);
}
else {
this.middleware = middleware[0];
}
};
/**
* @public
* To set the middleware chain
* @param {Middleware[]} middlewareArray - The array containing the middlewares
* @private
* Processes the middleware array to construct the chain
* and sets this.middleware property to the first middlware handler of the array
* @param {Middleware[]} middlewareArray - The array of middleware handlers
* @returns Nothing
*/
HTTPClient.prototype.setMiddlewareArray = function (middlewareArray) {
for (var num = 0; num < middlewareArray.length - 1; num += 1) {
middlewareArray[num].setNext(middlewareArray[num + 1]);
}
HTTPClient.prototype.parseMiddleWareArray = function (middlewareArray) {
middlewareArray.forEach(function (element, index) {
if (index < middlewareArray.length - 1) {
element.setNext(middlewareArray[index + 1]);
}
});
this.middleware = middlewareArray[0];

@@ -54,0 +67,0 @@ };

@@ -36,6 +36,6 @@ /**

* Creates a middleware chain with the given one
* @param {Middleware} middleware - The first middleware of the middleware chain
* @property {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
* @returns A HTTPClient instance
*/
static createWithMiddleware(middleware: Middleware): HTTPClient;
static createWithMiddleware(...middleware: Middleware[]): HTTPClient;
}

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

var isNodeEnvironment = function () {
return new Function("try {return this === global;}catch(e){return false;}")(); // tslint:disable-line: function-constructor
return typeof process === "object" && typeof require === "function";
};

@@ -70,7 +70,12 @@ /**

* Creates a middleware chain with the given one
* @param {Middleware} middleware - The first middleware of the middleware chain
* @property {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
* @returns A HTTPClient instance
*/
HTTPClientFactory.createWithMiddleware = function (middleware) {
return new HTTPClient_1.HTTPClient(middleware);
HTTPClientFactory.createWithMiddleware = function () {
var middleware = [];
for (var _i = 0; _i < arguments.length; _i++) {
middleware[_i] = arguments[_i];
}
// Middleware should not empty or undefined. This is check is present in the HTTPClient constructor.
return new (HTTPClient_1.HTTPClient.bind.apply(HTTPClient_1.HTTPClient, [void 0].concat(middleware)))();
};

@@ -77,0 +82,0 @@ return HTTPClientFactory;

@@ -18,3 +18,3 @@ /**

* @property {FetchOptions} [fetchOptions] - The options for fetch request
* @property {Middleware} [middleware] - The first middleware of the middleware chain
* @property {Middleware| Middleware[]} [middleware] - The first middleware of the middleware chain or an array of the Middleware handlers
*/

@@ -27,3 +27,3 @@ export interface ClientOptions {

fetchOptions?: FetchOptions;
middleware?: Middleware;
middleware?: Middleware | Middleware[];
}

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

export * from "./middleware/TelemetryHandler";
export * from "./middleware/MiddlewareFactory";
export * from "./middleware/options/AuthenticationHandlerOptions";

@@ -21,2 +22,5 @@ export * from "./middleware/options/IMiddlewareOptions";

export * from "./middleware/options/TelemetryHandlerOptions";
export * from "./middleware/options/ChaosHandlerOptions";
export * from "./middleware/options/ChaosStrategy";
export * from "./middleware/ChaosHandler";
export * from "./tasks/LargeFileUploadTask";

@@ -26,2 +30,3 @@ export * from "./tasks/OneDriveLargeFileUploadTask";

export * from "./Client";
export * from "./CustomAuthenticationProvider";
export * from "./GraphError";

@@ -28,0 +33,0 @@ export * from "./GraphRequest";

@@ -17,2 +17,3 @@ "use strict";

tslib_1.__exportStar(require("./middleware/TelemetryHandler"), exports);
tslib_1.__exportStar(require("./middleware/MiddlewareFactory"), exports);
tslib_1.__exportStar(require("./middleware/options/AuthenticationHandlerOptions"), exports);

@@ -22,2 +23,5 @@ tslib_1.__exportStar(require("./middleware/options/RetryHandlerOptions"), exports);

tslib_1.__exportStar(require("./middleware/options/TelemetryHandlerOptions"), exports);
tslib_1.__exportStar(require("./middleware/options/ChaosHandlerOptions"), exports);
tslib_1.__exportStar(require("./middleware/options/ChaosStrategy"), exports);
tslib_1.__exportStar(require("./middleware/ChaosHandler"), exports);
tslib_1.__exportStar(require("./tasks/LargeFileUploadTask"), exports);

@@ -27,2 +31,3 @@ tslib_1.__exportStar(require("./tasks/OneDriveLargeFileUploadTask"), exports);

tslib_1.__exportStar(require("./Client"), exports);
tslib_1.__exportStar(require("./CustomAuthenticationProvider"), exports);
tslib_1.__exportStar(require("./GraphError"), exports);

@@ -29,0 +34,0 @@ tslib_1.__exportStar(require("./GraphRequest"), exports);

@@ -56,8 +56,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -82,10 +82,2 @@ "use strict";

/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
AuthenticationHandler.prototype.getNext = function () {
return this.nextMiddleware;
};
/**
* @private

@@ -92,0 +84,0 @@ * A member representing the authorization header name

@@ -16,3 +16,2 @@ /**

setNext?: (middleware: Middleware) => void;
getNext?: () => Middleware;
}

@@ -8,2 +8,3 @@ "use strict";

*/
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -148,3 +149,3 @@ var tslib_1 = require("tslib");

*/
exports.cloneRequestWithNewUrl = function (newUrl, request) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
exports.cloneRequestWithNewUrl = function (newUrl, request) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var body, _a, method, headers, referrer, referrerPolicy, mode, credentials, cache, redirect, integrity, keepalive, signal;

@@ -151,0 +152,0 @@ return tslib_1.__generator(this, function (_b) {

@@ -145,8 +145,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -222,10 +222,2 @@ "use strict";

/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
RedirectHandler.prototype.getNext = function () {
return this.nextMiddleware;
};
/**
* @private

@@ -232,0 +224,0 @@ * @static

@@ -121,8 +121,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -198,10 +198,2 @@ "use strict";

/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
RetryHandler.prototype.getNext = function () {
return this.nextMiddleware;
};
/**
* @private

@@ -208,0 +200,0 @@ * @static

@@ -62,8 +62,2 @@ /**

setNext(next: Middleware): void;
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
getNext(): Middleware;
}

@@ -71,10 +71,2 @@ "use strict";

/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
TelemetryHandler.prototype.getNext = function () {
return this.nextMiddleware;
};
/**
* @private

@@ -81,0 +73,0 @@ * @static

@@ -52,3 +52,8 @@ "use strict";

}
return encodeURI("/me/drive/root:" + path + fileName + ":/createUploadSession");
// we choose to encode each component of the file path separately because when encoding full URI
// with encodeURI, special characters like # or % in the file name doesn't get encoded as desired
return "/me/drive/root:" + path
.split("/")
.map(function (p) { return encodeURIComponent(p); })
.join("/") + encodeURIComponent(fileName) + ":/createUploadSession";
};

@@ -55,0 +60,0 @@ /**

@@ -10,3 +10,5 @@ /**

*/
import { FetchOptions } from "../IFetchOptions";
import { Client } from "../index";
import { MiddlewareOptions } from "../middleware/options/IMiddlewareOptions";
/**

@@ -26,2 +28,14 @@ * Signature representing PageCollection

/**
* Signature to define the request options to be sent during request.
* The values of the GraphRequestOptions properties are passed to the Graph Request object.
* @property {HeadersInit} headers - the header options for the request
* @property {MiddlewareOptions[]} middlewareoptions - The middleware options for the request
* @property {FetchOptions} options - The fetch options for the request
*/
export interface GraphRequestOptions {
headers?: HeadersInit;
middlewareOptions?: MiddlewareOptions[];
options?: FetchOptions;
}
/**
* Signature representing callback for page iterator

@@ -67,2 +81,6 @@ * @property {Function} callback - The callback function which should return boolean to continue the continue/stop the iteration.

/**
* Information to be added to the request
*/
private requestOptions;
/**
* @public

@@ -74,5 +92,6 @@ * @constructor

* @param {PageIteratorCallback} callBack - The callback function
* @param {GraphRequestOptions} requestOptions - The request options
* @returns An instance of a PageIterator
*/
constructor(client: Client, pageCollection: PageCollection, callback: PageIteratorCallback);
constructor(client: Client, pageCollection: PageCollection, callback: PageIteratorCallback, requestOptions?: GraphRequestOptions);
/**

@@ -79,0 +98,0 @@ * @private

@@ -22,5 +22,6 @@ "use strict";

* @param {PageIteratorCallback} callBack - The callback function
* @param {GraphRequestOptions} requestOptions - The request options
* @returns An instance of a PageIterator
*/
function PageIterator(client, pageCollection, callback) {
function PageIterator(client, pageCollection, callback, requestOptions) {
this.client = client;

@@ -32,2 +33,3 @@ this.collection = pageCollection.value;

this.complete = false;
this.requestOptions = requestOptions;
}

@@ -58,3 +60,3 @@ /**

return tslib_1.__awaiter(this, void 0, void 0, function () {
var response, error_1;
var graphRequest, response, error_1;
return tslib_1.__generator(this, function (_a) {

@@ -64,3 +66,15 @@ switch (_a.label) {

_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.client.api(this.nextLink).get()];
graphRequest = this.client.api(this.nextLink);
if (this.requestOptions) {
if (this.requestOptions.headers) {
graphRequest = graphRequest.headers(this.requestOptions.headers);
}
if (this.requestOptions.middlewareOptions) {
graphRequest = graphRequest.middlewareOptions(this.requestOptions.middlewareOptions);
}
if (this.requestOptions.options) {
graphRequest = graphRequest.options(this.requestOptions.options);
}
}
return [4 /*yield*/, graphRequest.get()];
case 1:

@@ -67,0 +81,0 @@ response = _a.sent();

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

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

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

*/
exports.PACKAGE_VERSION = "2.1.0-Preview.1";
exports.PACKAGE_VERSION = "2.1.0-Preview.2";
//# sourceMappingURL=Version.js.map
{
"name": "@microsoft/microsoft-graph-client",
"version": "2.1.0-Preview.1",
"version": "2.1.0-Preview.2",
"description": "Microsoft Graph Client Library",
"license": "MIT",
"main": "lib/src/index.js",

@@ -6,0 +7,0 @@ "module": "lib/es/index.js",

@@ -99,3 +99,4 @@ # Microsoft Graph JavaScript Client Library

import { ImplicitMSALAuthenticationProvider } from "./node_modules/@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
import { MSALAuthenticationProviderOptions } from '@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions';

@@ -114,3 +115,3 @@ // An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options

const msalApplication = new UserAgentApplication(msalConfig);
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
const options = new MSALAuthenticationProviderOptions(graphScopes);
const authProvider = new ImplicitMSALAuthenticationProvider(msalApplication, options);

@@ -117,0 +118,0 @@ ```

@@ -16,3 +16,3 @@ /**

export * from "../middleware/TelemetryHandler";
export * from "../middleware/MiddlewareFactory";
export * from "../middleware/options/AuthenticationHandlerOptions";

@@ -22,2 +22,5 @@ export * from "../middleware/options/IMiddlewareOptions";

export * from "../middleware/options/TelemetryHandlerOptions";
export * from "../middleware/options/ChaosHandlerOptions";
export * from "../middleware/options/ChaosStrategy";
export * from "../middleware/ChaosHandler";

@@ -29,2 +32,3 @@ export * from "../tasks/LargeFileUploadTask";

export * from "../Client";
export * from "../CustomAuthenticationProvider";
export * from "../GraphError";

@@ -31,0 +35,0 @@ export * from "../GraphRequest";

@@ -19,3 +19,2 @@ /**

import { Options } from "./IOptions";
import { Middleware } from "./middleware/IMiddleware";
import { validatePolyFilling } from "./ValidatePolyFilling";

@@ -98,3 +97,3 @@

} else if (clientOptions.middleware !== undefined) {
httpClient = new HTTPClient(clientOptions.middleware);
httpClient = new HTTPClient(...[].concat(clientOptions.middleware));
} else {

@@ -111,20 +110,2 @@ const error = new Error();

* @public
* function to get the array of middlewares in use right now
* @returns An array of middlewares
*/
public getMiddlewareChain() {
return this.httpClient.getMiddlewareArray();
}
/**
* @public
* function to set the middleware chain
* @param {Middleware[]} middlewareArray - An array of middlewares
*/
public setMiddlewareChain(middlewareArray: Middleware[]) {
return this.httpClient.setMiddlewareArray(middlewareArray);
}
/**
* @public
* Entry point to make requests

@@ -131,0 +112,0 @@ * @param {string} path - The path string value

@@ -20,3 +20,3 @@ /**

export class GraphError {
export class GraphError extends Error {
/**

@@ -36,8 +36,2 @@ * @public

* @public
* A member holding error message
*/
public message: string | null;
/**
* @public
* A member holding request-id i.e identifier of the request

@@ -66,10 +60,11 @@ */

*/
public constructor(statusCode: number = -1) {
public constructor(statusCode: number = -1, message?: string, baseError?: Error) {
super(message || (baseError && baseError.message));
this.statusCode = statusCode;
this.code = null;
this.message = null;
this.requestId = null;
this.date = new Date();
this.body = null;
this.stack = baseError ? baseError.stack : this.stack;
}
}

@@ -30,3 +30,3 @@ /**

private static constructError(error: Error, statusCode?: number): GraphError {
const gError = new GraphError(statusCode);
const gError = new GraphError(statusCode, "", error);
if (error.name !== undefined) {

@@ -36,3 +36,2 @@ gError.code = error.name;

gError.body = error.toString();
gError.message = error.message;
gError.date = new Date();

@@ -65,5 +64,4 @@ return gError;

error = error.error;
const gError = new GraphError(statusCode);
const gError = new GraphError(statusCode, error.message);
gError.code = error.code;
gError.message = error.message;
if (error.innerError !== undefined) {

@@ -70,0 +68,0 @@ gError.requestId = error.innerError["request-id"];

@@ -25,3 +25,2 @@ /**

import { ResponseType } from "./ResponseType";
/**

@@ -53,2 +52,3 @@ * @interface

otherURLQueryParams: KeyValuePairObjectStringNumber;
otherURLQueryOptions: any[];
}

@@ -84,5 +84,3 @@

*/
private _headers: {
[key: string]: string;
};
private _headers: HeadersInit;

@@ -124,2 +122,3 @@ /**

otherURLQueryParams: {},
otherURLQueryOptions: [],
};

@@ -177,10 +176,3 @@ this._headers = {};

for (const queryParam of queryParams) {
const qParams = queryParam.split("=");
const key = qParams[0];
const value = qParams[1];
if (oDataQueryNames.indexOf(key) !== -1) {
this.urlComponents.oDataQueryParams[key] = value;
} else {
this.urlComponents.otherURLQueryParams[key] = value;
}
this.parseQueryParameter(queryParam);
}

@@ -252,2 +244,8 @@ }

}
if (urlComponents.otherURLQueryOptions.length !== 0) {
for (const str of urlComponents.otherURLQueryOptions) {
query.push(str);
}
}
return query.length > 0 ? "?" + query.join("&") : "";

@@ -258,2 +256,92 @@ }

* @private
* Parses the query parameters to set the urlComponents property of the GraphRequest object
* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query parameter
* @returns The same GraphRequest instance that is being called with
*/
private parseQueryParameter(queryDictionaryOrString: string | KeyValuePairObjectStringNumber): GraphRequest {
if (typeof queryDictionaryOrString === "string") {
if (queryDictionaryOrString.charAt(0) === "?") {
queryDictionaryOrString = queryDictionaryOrString.substring(1, queryDictionaryOrString.length);
}
if (queryDictionaryOrString.indexOf("&") !== -1) {
const queryParams = queryDictionaryOrString.split("&");
for (const str of queryParams) {
this.parseQueryParamenterString(str);
}
} else {
this.parseQueryParamenterString(queryDictionaryOrString);
}
} else if (queryDictionaryOrString.constructor === Object) {
for (const key in queryDictionaryOrString) {
if (queryDictionaryOrString.hasOwnProperty(key)) {
this.setURLComponentsQueryParamater(key, queryDictionaryOrString[key]);
}
}
} else {
/*Push values which are not of key-value structure.
Example-> Handle an invalid input->.query(123) and let the Graph API respond with the error in the URL*/ this.urlComponents.otherURLQueryOptions.push(queryDictionaryOrString);
}
return this;
}
/**
* @private
* Parses the query parameter of string type to set the urlComponents property of the GraphRequest object
* @param {string} queryParameter - the query parameters
* returns nothing
*/
private parseQueryParamenterString(queryParameter: string): void {
/* The query key-value pair must be split on the first equals sign to avoid errors in parsing nested query parameters.
Example-> "/me?$expand=home($select=city)" */
if (this.isValidQueryKeyValuePair(queryParameter)) {
const indexOfFirstEquals = queryParameter.indexOf("=");
const paramKey = queryParameter.substring(0, indexOfFirstEquals);
const paramValue = queryParameter.substring(indexOfFirstEquals + 1, queryParameter.length);
this.setURLComponentsQueryParamater(paramKey, paramValue);
} else {
/* Push values which are not of key-value structure.
Example-> Handle an invalid input->.query(test), .query($select($select=name)) and let the Graph API respond with the error in the URL*/
this.urlComponents.otherURLQueryOptions.push(queryParameter);
}
}
/**
* @private
* Sets values into the urlComponents property of GraphRequest object.
* @param {string} paramKey - the query parameter key
* @param {string} paramValue - the query paramter value
* @returns nothing
*/
private setURLComponentsQueryParamater(paramKey: string, paramValue: string | number): void {
if (oDataQueryNames.indexOf(paramKey) !== -1) {
const currentValue = this.urlComponents.oDataQueryParams[paramKey];
const isValueAppendable = currentValue && (paramKey === "$expand" || paramKey === "$select" || paramKey === "$orderby");
this.urlComponents.oDataQueryParams[paramKey] = isValueAppendable ? currentValue + "," + paramValue : paramValue;
} else {
this.urlComponents.otherURLQueryParams[paramKey] = paramValue;
}
}
/**
* @private
* Check if the query parameter string has a valid key-value structure
* @param {string} queryString - the query parameter string. Example -> "name=value"
* #returns true if the query string has a valid key-value structure else false
*/
private isValidQueryKeyValuePair(queryString: string): boolean {
const indexofFirstEquals = queryString.indexOf("=");
if (indexofFirstEquals === -1) {
return false;
}
const indexofOpeningParanthesis = queryString.indexOf("(");
if (indexofOpeningParanthesis !== -1 && queryString.indexOf("(") < indexofFirstEquals) {
// Example -> .query($select($expand=true));
return false;
}
return true;
}
/**
* @private
* Updates the custom headers and options for a request

@@ -313,2 +401,23 @@ * @param {FetchOptions} options - The request options object

/**
* @private
* Checks if the content-type is present in the _headers property. If not present, defaults the content-type to application/json
* @param none
* @returns nothing
*/
private setHeaderContentType(): void {
if (!this._headers) {
this.header("Content-Type", "application/json");
return;
}
const headerKeys = Object.keys(this._headers);
for (const headerKey of headerKeys) {
if (headerKey.toLowerCase() === "content-type") {
return;
}
}
// Default the content-type to application/json in case the content-type is not present in the header
this.header("Content-Type", "application/json");
}
/**
* @public

@@ -328,6 +437,6 @@ * Sets the custom header for a request

* Sets the custom headers for a request
* @param {KeyValuePairObjectStringNumber} headers - The headers key value pair object
* @param {KeyValuePairObjectStringNumber | HeadersInit} headers - The request headers
* @returns The same GraphRequest instance that is being called with
*/
public headers(headers: KeyValuePairObjectStringNumber): GraphRequest {
public headers(headers: KeyValuePairObjectStringNumber | HeadersInit): GraphRequest {
for (const key in headers) {

@@ -405,3 +514,3 @@ if (headers.hasOwnProperty(key)) {

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $select query
*/

@@ -423,3 +532,3 @@ /*

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $expand query
*/

@@ -435,3 +544,3 @@ public expand(properties: string | string[]): GraphRequest {

* @param {string|string[]} properties - The Properties value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the properties for $orderby query
*/

@@ -445,5 +554,5 @@ public orderby(properties: string | string[]): GraphRequest {

* @public
* To add query string for filter OData Query param
* To add query string for filter OData Query param. The request URL accepts only one $filter Odata Query option and its value is set to the most recently passed filter query string.
* @param {string} filterStr - The filter query string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $filter query
*/

@@ -457,5 +566,5 @@ public filter(filterStr: string): GraphRequest {

* @public
* To add criterion for search OData Query param
* To add criterion for search OData Query param. The request URL accepts only one $search Odata Query option and its value is set to the most recently passed search criterion string.
* @param {string} searchStr - The search criterion string
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the $search query criteria
*/

@@ -469,5 +578,5 @@ public search(searchStr: string): GraphRequest {

* @public
* To add number for top OData Query param
* To add number for top OData Query param. The request URL accepts only one $top Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for $top query
*/

@@ -481,5 +590,5 @@ public top(n: number): GraphRequest {

* @public
* To add number for skip OData Query param
* To add number for skip OData Query param. The request URL accepts only one $skip Odata Query option and its value is set to the most recently passed number value.
* @param {number} n - The number value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the number for the $skip query
*/

@@ -493,5 +602,5 @@ public skip(n: number): GraphRequest {

* @public
* To add token string for skipToken OData Query param
* To add token string for skipToken OData Query param. The request URL accepts only one $skipToken Odata Query option and its value is set to the most recently passed token value.
* @param {string} token - The token value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the token string for $skipToken query option
*/

@@ -505,5 +614,5 @@ public skipToken(token: string): GraphRequest {

* @public
* To add boolean for count OData Query param
* To add boolean for count OData Query param. The URL accepts only one $count Odata Query option and its value is set to the most recently passed boolean value.
* @param {boolean} isCount - The count boolean
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after adding the boolean value for the $count query option
*/

@@ -519,19 +628,10 @@ public count(isCount: boolean = false): GraphRequest {

* @param {string|KeyValuePairObjectStringNumber} queryDictionaryOrString - The query value
* @returns The same GraphRequest instance that is being called with
* @returns The same GraphRequest instance that is being called with, after appending the query string to the url component
*/
/*
* Accepts .query("displayName=xyz")
* and .select({ name: "value" })
*/
public query(queryDictionaryOrString: string | KeyValuePairObjectStringNumber): GraphRequest {
const otherURLQueryParams = this.urlComponents.otherURLQueryParams;
if (typeof queryDictionaryOrString === "string") {
const querySplit = queryDictionaryOrString.split("=");
const queryKey = querySplit[0];
const queryValue = querySplit[1];
otherURLQueryParams[queryKey] = queryValue;
} else {
for (const key in queryDictionaryOrString) {
if (queryDictionaryOrString.hasOwnProperty(key)) {
otherURLQueryParams[key] = queryDictionaryOrString[key];
}
}
}
return this;
return this.parseQueryParameter(queryDictionaryOrString);
}

@@ -572,9 +672,11 @@

body: serializeContent(content),
headers:
typeof FormData !== "undefined" && content instanceof FormData
? {}
: {
"Content-Type": "application/json",
},
};
const className: string = content && content.constructor && content.constructor.name;
if (className === "FormData") {
// Content-Type headers should not be specified in case the of FormData type content
options.headers = {};
} else {
this.setHeaderContentType();
options.headers = this._headers;
}
try {

@@ -614,8 +716,6 @@ const response = await this.send(url, options, callback);

const url = this.buildFullUrl();
this.setHeaderContentType();
const options: FetchOptions = {
method: RequestMethod.PUT,
body: serializeContent(content),
headers: {
"Content-Type": "application/json",
},
};

@@ -640,8 +740,6 @@ try {

const url = this.buildFullUrl();
this.setHeaderContentType();
const options: FetchOptions = {
method: RequestMethod.PATCH,
body: serializeContent(content),
headers: {
"Content-Type": "application/json",
},
};

@@ -648,0 +746,0 @@ try {

@@ -44,3 +44,3 @@ /**

export const serializeContent = (content: any): any => {
const className: string = content === undefined ? undefined : content.constructor.name;
const className: string = content && content.constructor && content.constructor.name;
if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") {

@@ -47,0 +47,0 @@ return content;

@@ -30,36 +30,41 @@ /**

* Creates an instance of a HTTPClient
* @param {Middleware} middleware - The first middleware of the middleware chain
* @param {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
*/
public constructor(middleware: Middleware) {
this.middleware = middleware;
public constructor(...middleware: Middleware[]) {
if (!middleware || !middleware.length) {
const error = new Error();
error.name = "InvalidMiddlewareChain";
error.message = "Please provide a default middleware chain or custom middleware chain";
throw error;
}
this.setMiddleware(...middleware);
}
/**
* @public
* To get an array of Middleware, used in middleware chain
* @returns An array of middlewares
* @private
* Processes the middleware parameter passed to set this.middleware property
* @param {...Middleware} middleware - The middleware passed
* @returns Nothing
*/
public getMiddlewareArray(): Middleware[] {
const middlewareArray: Middleware[] = [];
let currentMiddleware = this.middleware;
while (currentMiddleware) {
middlewareArray.push(currentMiddleware);
if (typeof currentMiddleware.getNext !== "undefined") {
currentMiddleware = currentMiddleware.getNext();
} else {
break;
}
private setMiddleware(...middleware: Middleware[]): void {
if (middleware.length > 1) {
this.parseMiddleWareArray(middleware);
} else {
this.middleware = middleware[0];
}
return middlewareArray;
}
/**
* @public
* To set the middleware chain
* @param {Middleware[]} middlewareArray - The array containing the middlewares
* @private
* Processes the middleware array to construct the chain
* and sets this.middleware property to the first middlware handler of the array
* @param {Middleware[]} middlewareArray - The array of middleware handlers
* @returns Nothing
*/
public setMiddlewareArray(middlewareArray: Middleware[]) {
for (let num = 0; num < middlewareArray.length - 1; num += 1) {
middlewareArray[num].setNext(middlewareArray[num + 1]);
}
private parseMiddleWareArray(middlewareArray: Middleware[]) {
middlewareArray.forEach((element, index) => {
if (index < middlewareArray.length - 1) {
element.setNext(middlewareArray[index + 1]);
}
});
this.middleware = middlewareArray[0];

@@ -66,0 +71,0 @@ }

@@ -29,3 +29,3 @@ /**

const isNodeEnvironment = (): boolean => {
return new Function("try {return this === global;}catch(e){return false;}")(); // tslint:disable-line: function-constructor
return typeof process === "object" && typeof require === "function";
};

@@ -73,8 +73,9 @@

* Creates a middleware chain with the given one
* @param {Middleware} middleware - The first middleware of the middleware chain
* @property {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
* @returns A HTTPClient instance
*/
public static createWithMiddleware(middleware: Middleware): HTTPClient {
return new HTTPClient(middleware);
public static createWithMiddleware(...middleware: Middleware[]): HTTPClient {
// Middleware should not empty or undefined. This is check is present in the HTTPClient constructor.
return new HTTPClient(...middleware);
}
}

@@ -20,3 +20,3 @@ /**

* @property {FetchOptions} [fetchOptions] - The options for fetch request
* @property {Middleware} [middleware] - The first middleware of the middleware chain
* @property {Middleware| Middleware[]} [middleware] - The first middleware of the middleware chain or an array of the Middleware handlers
*/

@@ -29,3 +29,3 @@ export interface ClientOptions {

fetchOptions?: FetchOptions;
middleware?: Middleware;
middleware?: Middleware | Middleware[];
}

@@ -17,3 +17,3 @@ /**

export * from "./middleware/TelemetryHandler";
export * from "./middleware/MiddlewareFactory";
export * from "./middleware/options/AuthenticationHandlerOptions";

@@ -24,2 +24,5 @@ export * from "./middleware/options/IMiddlewareOptions";

export * from "./middleware/options/TelemetryHandlerOptions";
export * from "./middleware/options/ChaosHandlerOptions";
export * from "./middleware/options/ChaosStrategy";
export * from "./middleware/ChaosHandler";

@@ -31,2 +34,3 @@ export * from "./tasks/LargeFileUploadTask";

export * from "./Client";
export * from "./CustomAuthenticationProvider";
export * from "./GraphError";

@@ -33,0 +37,0 @@ export * from "./GraphRequest";

@@ -97,11 +97,2 @@ /**

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
public getNext(): Middleware {
return this.nextMiddleware;
}
}

@@ -18,3 +18,2 @@ /**

setNext?: (middleware: Middleware) => void;
getNext?: () => Middleware;
}

@@ -246,11 +246,2 @@ /**

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
public getNext(): Middleware {
return this.nextMiddleware;
}
}

@@ -219,11 +219,2 @@ /**

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
public getNext(): Middleware {
return this.nextMiddleware;
}
}

@@ -99,11 +99,2 @@ /**

}
/**
* @public
* To get the next middleware in the chain
* @returns next Middleware instance
*/
public getNext(): Middleware {
return this.nextMiddleware;
}
}

@@ -62,3 +62,8 @@ /**

}
return encodeURI(`/me/drive/root:${path}${fileName}:/createUploadSession`);
// we choose to encode each component of the file path separately because when encoding full URI
// with encodeURI, special characters like # or % in the file name doesn't get encoded as desired
return `/me/drive/root:${path
.split("/")
.map((p) => encodeURIComponent(p))
.join("/")}${encodeURIComponent(fileName)}:/createUploadSession`;
}

@@ -65,0 +70,0 @@

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

import { FetchOptions } from "../IFetchOptions";
import { Client } from "../index";
import { MiddlewareOptions } from "../middleware/options/IMiddlewareOptions";
import { ResponseType } from "../ResponseType";

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

/**
* Signature to define the request options to be sent during request.
* The values of the GraphRequestOptions properties are passed to the Graph Request object.
* @property {HeadersInit} headers - the header options for the request
* @property {MiddlewareOptions[]} middlewareoptions - The middleware options for the request
* @property {FetchOptions} options - The fetch options for the request
*/
export interface GraphRequestOptions {
headers?: HeadersInit;
middlewareOptions?: MiddlewareOptions[];
options?: FetchOptions;
}
/**
* Signature representing callback for page iterator

@@ -79,2 +95,7 @@ * @property {Function} callback - The callback function which should return boolean to continue the continue/stop the iteration.

/**
* Information to be added to the request
*/
private requestOptions: GraphRequestOptions;
/**
* @public

@@ -86,5 +107,6 @@ * @constructor

* @param {PageIteratorCallback} callBack - The callback function
* @param {GraphRequestOptions} requestOptions - The request options
* @returns An instance of a PageIterator
*/
public constructor(client: Client, pageCollection: PageCollection, callback: PageIteratorCallback) {
public constructor(client: Client, pageCollection: PageCollection, callback: PageIteratorCallback, requestOptions?: GraphRequestOptions) {
this.client = client;

@@ -96,2 +118,3 @@ this.collection = pageCollection.value;

this.complete = false;
this.requestOptions = requestOptions;
}

@@ -124,3 +147,16 @@

try {
const response: PageCollection = await this.client.api(this.nextLink).get();
let graphRequest = this.client.api(this.nextLink);
if (this.requestOptions) {
if (this.requestOptions.headers) {
graphRequest = graphRequest.headers(this.requestOptions.headers);
}
if (this.requestOptions.middlewareOptions) {
graphRequest = graphRequest.middlewareOptions(this.requestOptions.middlewareOptions);
}
if (this.requestOptions.options) {
graphRequest = graphRequest.options(this.requestOptions.options);
}
}
const response: PageCollection = await graphRequest.get();
this.collection = response.value;

@@ -127,0 +163,0 @@ this.nextLink = response["@odata.nextLink"];

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

export const PACKAGE_VERSION = "2.1.0-Preview.1";
export const PACKAGE_VERSION = "2.1.0-Preview.2";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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