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 1.7.0 to 2.0.0-Preview.1

lib/es/browser/ImplicitMSALAuthenticationProvider.d.ts

2

lib/es/browser/index.d.ts

@@ -33,4 +33,4 @@ /**

export * from "../IOptions";
export * from "./MSALAuthenticationProvider";
export * from "./ImplicitMSALAuthenticationProvider";
export * from "../MSALAuthenticationProviderOptions";
export * from "../ResponseType";

@@ -22,5 +22,5 @@ /**

export * from "../GraphRequest";
export * from "./MSALAuthenticationProvider";
export * from "./ImplicitMSALAuthenticationProvider";
export * from "../MSALAuthenticationProviderOptions";
export * from "../ResponseType";
//# sourceMappingURL=index.js.map

@@ -20,8 +20,1 @@ /**

export declare const GRAPH_BASE_URL = "https://graph.microsoft.com/";
/**
* @constant
* A package version
* @NOTE: This should be kept up to date with the version used in package.json.
* If you are changing this please ensure you are also changing it in package.json.
*/
export declare const PACKAGE_VERSION = "1.7.0";

@@ -20,9 +20,2 @@ /**

export const GRAPH_BASE_URL = "https://graph.microsoft.com/";
/**
* @constant
* A package version
* @NOTE: This should be kept up to date with the version used in package.json.
* If you are changing this please ensure you are also changing it in package.json.
*/
export const PACKAGE_VERSION = "1.7.0";
//# sourceMappingURL=Constants.js.map

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
/**

@@ -150,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 = {

@@ -184,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;

@@ -294,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 = [];

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

@@ -21,7 +21,7 @@ /**

* @property {KeyValuePairObject[]} responses - An array of key value pair representing response object for every request
* @property {string} [@nextLink] - The nextLink value to get next set of responses in case of asynchronous batch requests
* @property {string} [@odata.nextLink] - The nextLink value to get next set of responses in case of asynchronous batch requests
*/
interface BatchResponseBody {
responses: KeyValuePairObject[];
"@nextLink"?: string;
"@odata.nextLink"?: string;
}

@@ -28,0 +28,0 @@ /**

@@ -46,3 +46,3 @@ /**

update(response) {
this.nextLink = response["@nextLink"];
this.nextLink = response["@odata.nextLink"];
const responses = response.responses;

@@ -49,0 +49,0 @@ for (let i = 0, l = responses.length; i < l; i++) {

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
/**

@@ -39,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) => {

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

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
/**

@@ -92,3 +85,3 @@ * @module GraphErrorHandler

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;

@@ -95,0 +88,0 @@ if (error && error.error) {

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
import { GraphErrorHandler } from "./GraphErrorHandler";

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

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

@@ -427,3 +420,3 @@ const middlewareControl = new MiddlewareControl(this._middlewareOptions);

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

@@ -451,3 +444,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();

@@ -481,3 +474,3 @@ const options = {

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

@@ -500,3 +493,3 @@ 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();

@@ -507,3 +500,3 @@ const options = {

headers: {
"Content-Type": "application/octet-stream",
"Content-Type": "application/json",
},

@@ -529,3 +522,3 @@ };

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();

@@ -557,3 +550,3 @@ const options = {

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

@@ -575,3 +568,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();

@@ -598,3 +591,3 @@ const options = {

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

@@ -616,3 +609,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();

@@ -641,3 +634,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();

@@ -644,0 +637,0 @@ const options = {

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
import { ResponseType } from "./ResponseType";

@@ -101,5 +94,4 @@ /**

static convertResponse(rawResponse, responseType) {
return __awaiter(this, void 0, void 0, function* () {
const clonedRawResponse = rawResponse.clone();
if (clonedRawResponse.status === 204) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (rawResponse.status === 204) {
// NO CONTENT

@@ -112,37 +104,37 @@ return Promise.resolve();

case ResponseType.ARRAYBUFFER:
responseValue = yield clonedRawResponse.arrayBuffer();
responseValue = yield rawResponse.arrayBuffer();
break;
case ResponseType.BLOB:
responseValue = yield clonedRawResponse.blob();
responseValue = yield rawResponse.blob();
break;
case ResponseType.DOCUMENT:
responseValue = yield GraphResponseHandler.parseDocumentResponse(clonedRawResponse, DocumentType.TEXT_XML);
responseValue = yield GraphResponseHandler.parseDocumentResponse(rawResponse, DocumentType.TEXT_XML);
break;
case ResponseType.JSON:
responseValue = yield clonedRawResponse.json();
responseValue = yield rawResponse.json();
break;
case ResponseType.STREAM:
responseValue = yield Promise.resolve(clonedRawResponse.body);
responseValue = yield Promise.resolve(rawResponse.body);
break;
case ResponseType.TEXT:
responseValue = yield clonedRawResponse.text();
responseValue = yield rawResponse.text();
break;
default:
const contentType = clonedRawResponse.headers.get("Content-type");
const contentType = rawResponse.headers.get("Content-type");
if (contentType !== null) {
const mimeType = contentType.split(";")[0];
if (new RegExp(ContentTypeRegexStr.DOCUMENT).test(mimeType)) {
responseValue = yield GraphResponseHandler.parseDocumentResponse(clonedRawResponse, mimeType);
responseValue = yield GraphResponseHandler.parseDocumentResponse(rawResponse, mimeType);
}
else if (new RegExp(ContentTypeRegexStr.IMAGE).test(mimeType)) {
responseValue = clonedRawResponse.blob();
responseValue = rawResponse.blob();
}
else if (mimeType === ContentType.TEXT_PLAIN) {
responseValue = yield clonedRawResponse.text();
responseValue = yield rawResponse.text();
}
else if (mimeType === ContentType.APPLICATION_JSON) {
responseValue = yield clonedRawResponse.json();
responseValue = yield rawResponse.json();
}
else {
responseValue = Promise.resolve(clonedRawResponse.body);
responseValue = Promise.resolve(rawResponse.body);
}

@@ -162,3 +154,3 @@ }

*/
responseValue = Promise.resolve(clonedRawResponse.body);
responseValue = Promise.resolve(rawResponse.body);
}

@@ -185,3 +177,3 @@ break;

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

@@ -196,3 +188,3 @@ if (responseType === ResponseType.RAW) {

if (typeof callback === "function") {
callback(null, response, rawResponse);
callback(null, response);
}

@@ -199,0 +191,0 @@ else {

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
/**

@@ -38,3 +31,3 @@ * @class

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

@@ -41,0 +34,0 @@ if (!(context.request instanceof Request) && context.options === undefined) {

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

*/
import "./PolyFill";
export * from "./content/BatchRequestContent";

@@ -10,0 +9,0 @@ export * from "./content/BatchResponseContent";

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

*/
import "./PolyFill";
export * from "./content/BatchRequestContent";

@@ -10,0 +9,0 @@ export * from "./content/BatchResponseContent";

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
import { MiddlewareControl } from "./MiddlewareControl";
import { setRequestHeader } from "./MiddlewareUtil";
import { appendRequestHeader } from "./MiddlewareUtil";
import { AuthenticationHandlerOptions } from "./options/AuthenticationHandlerOptions";

@@ -43,3 +36,3 @@ import { FeatureUsageFlag, TelemetryHandlerOptions } from "./options/TelemetryHandlerOptions";

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

@@ -61,3 +54,3 @@ let options;

const bearerKey = `Bearer ${token}`;
setRequestHeader(context.request, context.options, AuthenticationHandler.AUTHORIZATION_HEADER, bearerKey);
appendRequestHeader(context.request, context.options, AuthenticationHandler.AUTHORIZATION_HEADER, bearerKey);
TelemetryHandlerOptions.updateFeatureUsageFlag(context, FeatureUsageFlag.AUTHENTICATION_HANDLER_ENABLED);

@@ -64,0 +57,0 @@ return yield this.nextMiddleware.execute(context);

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
/**

@@ -30,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 {

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

@@ -38,2 +38,12 @@ /**

* @constant
* To append the header value to the given request
* @param {RequestInfo} request - The request object or the url string
* @param {FetchOptions|undefined} options - The request options object
* @param {string} key - The header key string
* @param {string } value - The header value string
* @returns Nothing
*/
export declare const appendRequestHeader: (request: RequestInfo, options: FetchOptions, key: string, value: string) => void;
/**
* @constant
* To clone the request with the new url

@@ -40,0 +50,0 @@ * @param {string} url - The new url string

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
/**

@@ -78,5 +71,5 @@ * @constant

if (options.headers === undefined) {
options.headers = {
options.headers = new Headers({
[key]: value,
};
});
}

@@ -88,3 +81,14 @@ else {

else if (options.headers instanceof Array) {
options.headers.push([key, value]);
let i = 0;
const l = options.headers.length;
for (; i < l; i++) {
const header = options.headers[i];
if (header[0] === key) {
header[1] = value;
break;
}
}
if (i === l) {
options.headers.push([key, value]);
}
}

@@ -99,2 +103,40 @@ else {

* @constant
* To append the header value to the given request
* @param {RequestInfo} request - The request object or the url string
* @param {FetchOptions|undefined} options - The request options object
* @param {string} key - The header key string
* @param {string } value - The header value string
* @returns Nothing
*/
export const appendRequestHeader = (request, options, key, value) => {
if (request instanceof Request) {
request.headers.append(key, value);
}
else if (typeof options !== "undefined") {
if (options.headers === undefined) {
options.headers = new Headers({
[key]: value,
});
}
else {
if (options.headers instanceof Headers) {
options.headers.append(key, value);
}
else if (options.headers instanceof Array) {
options.headers.push([key, value]);
}
else if (options.headers === undefined) {
options.headers = { [key]: value };
}
else if (options.headers[key] === undefined) {
options.headers[key] = value;
}
else {
options.headers[key] += `, ${value}`;
}
}
}
};
/**
* @constant
* To clone the request with the new url

@@ -105,3 +147,3 @@ * @param {string} url - The new url string

*/
export const cloneRequestWithNewUrl = (newUrl, request) => __awaiter(this, 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);

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

@@ -27,2 +27,7 @@ /**

}
if (maxRedirects < 0) {
const error = new Error(`MaxRedirects should not be negative`);
error.name = "MinExpectationNotMet";
throw error;
}
this.maxRedirects = maxRedirects;

@@ -29,0 +34,0 @@ this.shouldRedirect = shouldRedirect;

@@ -38,2 +38,17 @@ /**

}
else if (delay < 0 && maxRetries < 0) {
const error = new Error(`Delay and MaxRetries should not be negative`);
error.name = "MinExpectationNotMet";
throw error;
}
else if (delay < 0) {
const error = new Error(`Delay should not be negative`);
error.name = "MinExpectationNotMet";
throw error;
}
else if (maxRetries < 0) {
const error = new Error(`MaxRetries should not be negative`);
error.name = "MinExpectationNotMet";
throw error;
}
this.delay = Math.min(delay, RetryHandlerOptions.MAX_DELAY);

@@ -40,0 +55,0 @@ this.maxRetries = Math.min(maxRetries, RetryHandlerOptions.MAX_MAX_RETRIES);

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
import { RequestMethod } from "../RequestMethod";

@@ -104,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 = context.request instanceof Request ? yield cloneRequestWithNewUrl(redirectUrl, context.request) : redirectUrl;

@@ -135,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 {

@@ -172,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 {

@@ -175,0 +168,0 @@ const redirectCount = 0;

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
import { RequestMethod } from "../RequestMethod";

@@ -110,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;

@@ -136,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 {

@@ -164,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 {

@@ -167,0 +160,0 @@ const retryAttempts = 0;

@@ -7,2 +7,5 @@ /**

*/
/**
* @module TelemetryHandler
*/
import { Context } from "../IContext";

@@ -9,0 +12,0 @@ import { Middleware } from "./IMiddleware";

@@ -7,16 +7,6 @@ /**

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* @module TelemetryHandler
*/
import { PACKAGE_VERSION } from "../Constants";
import * as tslib_1 from "tslib";
import { PACKAGE_VERSION } from "../Version";
import { MiddlewareControl } from "./MiddlewareControl";
import { generateUUID, getRequestHeader, setRequestHeader } from "./MiddlewareUtil";
import { appendRequestHeader, generateUUID, getRequestHeader, setRequestHeader } from "./MiddlewareUtil";
import { TelemetryHandlerOptions } from "./options/TelemetryHandlerOptions";

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

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

@@ -54,3 +44,3 @@ let clientRequestId = getRequestHeader(context.request, context.options, TelemetryHandler.CLIENT_REQUEST_ID_HEADER);

}
setRequestHeader(context.request, context.options, TelemetryHandler.SDK_VERSION_HEADER, sdkVersionValue);
appendRequestHeader(context.request, context.options, TelemetryHandler.SDK_VERSION_HEADER, sdkVersionValue);
return yield this.nextMiddleware.execute(context);

@@ -57,0 +47,0 @@ }

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
import { Range } from "../Range";

@@ -58,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 {

@@ -138,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 {

@@ -173,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 {

@@ -196,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 {

@@ -213,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 {

@@ -232,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 {

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

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
import { LargeFileUploadTask } from "./LargeFileUploadTask";

@@ -69,3 +62,3 @@ import { getValidRangeSize } from "./OneDriveLargeFileUploadTaskUtil";

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;

@@ -121,3 +114,3 @@ let content;

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

@@ -144,3 +137,3 @@ item: {

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

@@ -147,0 +140,0 @@ const payload = {

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

* @property {any[]} value - The collection value
* @property {string} [@odata.nextLink] - The nextLine value
* @property {string} [@odata.nextLink] - The nextLink value
* @property {string} [@odata.deltaLink] - The deltaLink value
* @property {any} Additional - Any number of additional properties (This is to accept the any additional data returned by in the response to the nextLink request)

@@ -17,0 +18,0 @@ */

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

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as tslib_1 from "tslib";
/**

@@ -61,3 +54,3 @@ * @class

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

@@ -90,3 +83,3 @@ const response = yield this.client.api(this.nextLink).get();

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

@@ -120,3 +113,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 {

@@ -123,0 +116,0 @@ return this.iterate();

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

var e;!function(e){e.GET="GET",e.PATCH="PATCH",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}(e||(e={}));var t=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};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 t(this,void 0,void 0,function*(){const t={url:""},i=new RegExp("^https?://");t.url=i.test(r.url)?"/"+r.url.split(/.*?\/\/.*?\//)[1]:r.url,t.method=r.method;const o={};return r.headers.forEach((e,t)=>{o[t]=e}),Object.keys(o).length&&(t.headers=o),r.method!==e.PATCH&&r.method!==e.POST&&r.method!==e.PUT||(t.body=yield n.getRequestBody(r)),t})}static getRequestBody(e){return t(this,void 0,void 0,function*(){let t,n=!1;try{const r=e.clone();t=yield r.json(),n=!0}catch(e){}if(!n)try{if("undefined"!=typeof Blob){const n=yield e.blob(),r=new FileReader;t=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){t=(yield e.buffer()).toString("base64")}n=!0}catch(e){}return t})}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 t(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],o=yield n.getRequestData(t.request);if(void 0!==o.body&&(void 0===o.headers||void 0===o.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}o.id=t.id,void 0!==t.dependsOn&&t.dependsOn.length>0&&(o.dependsOn=t.dependsOn),e.push(o),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={};return n.status=e.status,void 0!==e.statusText&&(n.statusText=e.statusText),n.headers=e.headers,new Response(t,n)}update(e){this.nextLink=e["@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.name;this.middlewareOptions.set(e,t)}}getMiddlewareOptions(e){return this.middlewareOptions.get(e)}setMiddlewareOptions(e,t){this.middlewareOptions.set(e,t)}}var o=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};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},a=(e,t,n)=>{let r=null;if(e instanceof Request)r=e.headers.get(n);else if(void 0!==t&&void 0!==t.headers)if(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},c=(e,t,n,r)=>{e instanceof Request?e.headers.set(n,r):void 0!==t&&(void 0===t.headers?t.headers={[n]:r}:t.headers instanceof Headers?t.headers.set(n,r):t.headers instanceof Array?t.headers.push([n,r]):Object.assign(t.headers,{[n]:r}))},d=(e,t)=>o(void 0,void 0,void 0,function*(){const n=t.headers.get("Content-Type")?yield t.blob():yield Promise.resolve(void 0),{method:r,headers:i,referrer:o,referrerPolicy:s,mode:a,credentials:c,cache:d,redirect:u,integrity:h,keepalive:l,signal:p}=t;return new Request(e,{method:r,headers:i,body:n,referrer:o,referrerPolicy:s,mode:a,credentials:c,cache:d,redirect:u,integrity:h,keepalive:l,signal:p})});class u{constructor(e,t){this.authenticationProvider=e,this.authenticationProviderOptions=t}}var h;!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"}(h||(h={}));class l{constructor(){this.featureUsage=h.NONE}static updateFeatureUsageFlag(e,t){let n;e.middlewareControl instanceof i?n=e.middlewareControl.getMiddlewareOptions(l.name):e.middlewareControl=new i,void 0===n&&(n=new l,e.middlewareControl.setMiddlewareOptions(l.name,n)),n.setFeatureUsage(t)}setFeatureUsage(e){this.featureUsage=this.featureUsage|e}getFeatureUsage(){return this.featureUsage.toString(16)}}var p=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class f{constructor(e){this.authenticationProvider=e}execute(e){return p(this,void 0,void 0,function*(){try{let t,n,r;e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(u.name)),void 0!==t&&(n=t.authenticationProvider,r=t.authenticationProviderOptions),void 0===n&&(n=this.authenticationProvider);const o=`Bearer ${yield n.getAccessToken(r)}`;return c(e.request,e.options,f.AUTHORIZATION_HEADER,o),l.updateFeatureUsageFlag(e,h.AUTHENTICATION_HANDLER_ENABLED),yield this.nextMiddleware.execute(e)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}f.AUTHORIZATION_HEADER="Authorization";var y=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class m{execute(e){return y(this,void 0,void 0,function*(){try{return void(e.response=yield fetch(e.request,e.options))}catch(e){throw e}})}}class v{constructor(e=v.DEFAULT_DELAY,t=v.DEFAULT_MAX_RETRIES,n=v.DEFAULT_SHOULD_RETRY){if(e>v.MAX_DELAY&&t>v.MAX_MAX_RETRIES){const e=new Error(`Delay and MaxRetries should not be more than ${v.MAX_DELAY} and ${v.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e>v.MAX_DELAY){const e=new Error(`Delay should not be more than ${v.MAX_DELAY}`);throw e.name="MaxLimitExceeded",e}if(t>v.MAX_MAX_RETRIES){const e=new Error(`MaxRetries should not be more than ${v.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}this.delay=Math.min(e,v.MAX_DELAY),this.maxRetries=Math.min(t,v.MAX_MAX_RETRIES),this.shouldRetry=n}getMaxDelay(){return v.MAX_DELAY}}v.DEFAULT_DELAY=3,v.DEFAULT_MAX_RETRIES=3,v.MAX_DELAY=180,v.MAX_MAX_RETRIES=10,v.DEFAULT_SHOULD_RETRY=(()=>!0);var E=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class w{constructor(e=new v){this.options=e}isRetry(e){return-1!==w.RETRY_STATUS_CODES.indexOf(e.status)}isBuffered(t,n){const r=t instanceof Request?t.method:n.method;if(r===e.PUT||r===e.PATCH||r===e.POST){if("application/octet-stream"===a(t,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(w.RETRY_AFTER_HEADER):null;let o;return o=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(o,this.options.getMaxDelay()+r())}getExponentialBackOffTime(e){return Math.round(.5*(Math.pow(2,e)-1))}sleep(e){return E(this,void 0,void 0,function*(){const t=1e3*e;return new Promise(e=>setTimeout(e,t))})}getOptions(e){let t;return e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new v,this.options)),t}executeWithRetry(e,t,n){return E(this,void 0,void 0,function*(){try{if(yield this.nextMiddleware.execute(e),t<n.maxRetries&&this.isRetry(e.response)&&this.isBuffered(e.request,e.options)&&n.shouldRetry(n.delay,t,e.request,e.options,e.response)){++t,c(e.request,e.options,w.RETRY_ATTEMPT_HEADER,t.toString());const r=this.getDelay(e.response,t,n.delay);return yield this.sleep(r),yield this.executeWithRetry(e,t,n)}return}catch(e){throw e}})}execute(e){return E(this,void 0,void 0,function*(){try{const t=0,n=this.getOptions(e);return l.updateFeatureUsageFlag(e,h.RETRY_HANDLER_ENABLED),yield this.executeWithRetry(e,t,n)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}w.RETRY_STATUS_CODES=[429,503,504],w.RETRY_ATTEMPT_HEADER="Retry-Attempt",w.RETRY_AFTER_HEADER="Retry-After";const g="v1.0",R="https://graph.microsoft.com/",A="1.7.0";var T=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class x{execute(e){return T(this,void 0,void 0,function*(){try{let t=a(e.request,e.options,x.CLIENT_REQUEST_ID_HEADER);null===t&&(t=s(),c(e.request,e.options,x.CLIENT_REQUEST_ID_HEADER,t));let n,r=`${x.PRODUCT_NAME}/${A}`;if(e.middlewareControl instanceof i&&(n=e.middlewareControl.getMiddlewareOptions(l.name)),void 0!==n){const e=n.getFeatureUsage();r+=` (${x.FEATURE_USAGE_STRING}=${e})`}return c(e.request,e.options,x.SDK_VERSION_HEADER,r),yield this.nextMiddleware.execute(e)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}x.CLIENT_REQUEST_ID_HEADER="client-request-id",x.SDK_VERSION_HEADER="SdkVersion",x.PRODUCT_NAME="graph-js",x.FEATURE_USAGE_STRING="featureUsage";class O{constructor(e=-1,t=-1){this.minValue=e,this.maxValue=t}}var D=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class _{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 O(0,this.options.rangeSize-1)}static createUploadSession(e,t,n,r={}){return D(this,void 0,void 0,function*(){try{const i=yield e.api(t).headers(r).post(n);return{url:i.uploadUrl,expiry:new Date(i.expirationDateTime)}}catch(e){throw e}})}parseRange(e){const t=e[0];if(void 0===t||""===t)return new O;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 O(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 O(e,t)}sliceFile(e){return this.file.content.slice(e.minValue,e.maxValue+1)}upload(){return D(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(e,t,n){return D(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).headers({"Content-Length":`${t.maxValue-t.minValue+1}`,"Content-Range":`bytes ${t.minValue}-${t.maxValue}/${n}`}).put(e)}catch(e){throw e}})}cancel(){return D(this,void 0,void 0,function*(){try{return yield this.client.api(this.uploadSession.url).delete()}catch(e){throw e}})}getStatus(){return D(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 D(this,void 0,void 0,function*(){try{return yield this.getStatus(),yield this.upload()}catch(e){throw e}})}}const P=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};var L=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class b extends _{constructor(e,t,n,r){super(e,t,n,r)}static constructCreateSessionUrl(e,t=b.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(e,t,n){return L(this,void 0,void 0,function*(){const r=n.fileName;let i,o;switch(t.constructor.name){case"Blob":o=(i=new File([t],r)).size;break;case"File":o=(i=t).size;break;case"Buffer":const e=t;o=e.byteLength-e.byteOffset,i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}try{const t=b.constructCreateSessionUrl(n.fileName,n.path),s=yield b.createUploadSession(e,t,n.fileName),a=P(n.rangeSize);return new b(e,{name:r,content:i,size:o},s,{rangeSize:a})}catch(e){throw e}})}static createUploadSession(e,t,n){const r=Object.create(null,{createUploadSession:{get:()=>super.createUploadSession}});return L(this,void 0,void 0,function*(){const i={item:{"@microsoft.graph.conflictBehavior":"rename",name:n}};try{return r.createUploadSession.call(this,e,t,i)}catch(e){throw e}})}commit(e){return L(this,void 0,void 0,function*(){try{const t={name:this.file.name,"@microsoft.graph.conflictBehavior":"rename","@microsoft.graph.sourceUrl":this.uploadSession.url};return yield this.client.api(e).put(t)}catch(e){throw e}})}}b.DEFAULT_UPLOAD_PATH="/";var S=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class U{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 S(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 S(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 S(this,void 0,void 0,function*(){try{return this.iterate()}catch(e){throw e}})}isComplete(){return this.complete}}var C=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class M{constructor(e){this.provider=e}getAccessToken(){return C(this,void 0,void 0,function*(){return new Promise((e,t)=>{this.provider((n,r)=>{r?e(r):t(n)})})})}}class N{constructor(e=-1){this.statusCode=e,this.code=null,this.message=null,this.requestId=null,this.date=new Date,this.body=null}}var q=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class I{static constructError(e,t){const n=new N(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 N(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(e=null,t=-1,n){return q(this,void 0,void 0,function*(){let r;if(r=e&&e.error?I.constructErrorFromResponse(e,t):e&&"Error"===e.constructor.name?I.constructError(e,t):new N(t),"function"!=typeof n)return r;n(r,null)})}}const F=["$select","$expand","$orderby","$filter","$top","$skip","$skipToken","$count"],k=e=>{const t=e=>e.replace(/\/+$/,""),n=e=>e.replace(/^\/+/,"");return Array.prototype.slice.call(e).reduce((e,r)=>[t(e),n(r)].join("/"))},H=e=>{const t=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 $;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}($||($={}));var X,B,Q,j=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};!function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(X||(X={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(B||(B={})),function(e){e.DOCUMENT="^(text\\/(html|xml))|(application\\/(xml|xhtml\\+xml))$",e.IMAGE="^image\\/.+"}(Q||(Q={}));class Y{static parseDocumentResponse(e,t){try{return"undefined"!=typeof DOMParser?new Promise((n,r)=>{e.text().then(e=>{try{const i=(new DOMParser).parseFromString(e,t);n(i)}catch(e){r(e)}})}):Promise.resolve(e.body)}catch(e){throw e}}static convertResponse(e,t){return j(this,void 0,void 0,function*(){const n=e.clone();if(204===n.status)return Promise.resolve();let r;try{switch(t){case $.ARRAYBUFFER:r=yield n.arrayBuffer();break;case $.BLOB:r=yield n.blob();break;case $.DOCUMENT:r=yield Y.parseDocumentResponse(n,X.TEXT_XML);break;case $.JSON:r=yield n.json();break;case $.STREAM:r=yield Promise.resolve(n.body);break;case $.TEXT:r=yield n.text();break;default:const e=n.headers.get("Content-type");if(null!==e){const t=e.split(";")[0];r=new RegExp(Q.DOCUMENT).test(t)?yield Y.parseDocumentResponse(n,t):new RegExp(Q.IMAGE).test(t)?n.blob():t===B.TEXT_PLAIN?yield n.text():t===B.APPLICATION_JSON?yield n.json():Promise.resolve(n.body)}else r=Promise.resolve(n.body)}}catch(e){throw e}return r})}static getResponse(e,t,n){return j(this,void 0,void 0,function*(){try{if(t===$.RAW)return Promise.resolve(e);{const r=yield Y.convertResponse(e,t);if(!e.ok)throw r;if("function"!=typeof n)return r;n(null,r,e)}}catch(e){throw e}})}}var z=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class V{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!==F.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=k([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(e,t,n){return z(this,void 0,void 0,function*(){let r;const o=new i(this._middlewareOptions);this.updateRequestOptions(t);try{return r=(yield this.httpClient.sendRequest({request:e,options:t,middlewareControl:o})).response,yield Y.getResponse(r,this._responseType,n)}catch(e){let t;throw void 0!==r&&(t=r.status),yield I.getError(e,t,n)}})}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){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(t){return z(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.GET};try{return yield this.send(n,r,t)}catch(e){throw e}})}post(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.POST,body:H(t),headers:void 0!==t.constructor&&"FormData"===t.constructor.name?{}:{"Content-Type":"application/json"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}create(e,t){return z(this,void 0,void 0,function*(){try{return yield this.post(e,t)}catch(e){throw e}})}put(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PUT,body:H(t),headers:{"Content-Type":"application/octet-stream"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}patch(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PATCH,body:H(t),headers:{"Content-Type":"application/json"}};try{return yield this.send(r,i,n)}catch(e){throw e}})}update(e,t){return z(this,void 0,void 0,function*(){try{return yield this.patch(e,t)}catch(e){throw e}})}delete(t){return z(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.DELETE};try{return yield this.send(n,r,t)}catch(e){throw e}})}del(e){return z(this,void 0,void 0,function*(){try{return yield this.delete(e)}catch(e){throw e}})}getStream(t){return z(this,void 0,void 0,function*(){const n=this.buildFullUrl(),r={method:e.GET};this.responseType($.STREAM);try{return yield this.send(n,r,t)}catch(e){throw e}})}putStream(t,n){return z(this,void 0,void 0,function*(){const r=this.buildFullUrl(),i={method:e.PUT,headers:{"Content-Type":"application/octet-stream"},body:t};try{return yield this.send(r,i,n)}catch(e){throw e}})}}var W=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class G{constructor(e){this.middleware=e}sendRequest(e){return W(this,void 0,void 0,function*(){try{if(!(e.request instanceof Request)&&void 0===e.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(e),e}catch(e){throw e}})}}class Z{constructor(e=Z.DEFAULT_MAX_REDIRECTS,t=Z.DEFAULT_SHOULD_RETRY){if(e>Z.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${Z.MAX_MAX_REDIRECTS}`);throw e.name="MaxLimitExceeded",e}this.maxRedirects=e,this.shouldRedirect=t}}Z.DEFAULT_MAX_REDIRECTS=5,Z.MAX_MAX_REDIRECTS=20,Z.DEFAULT_SHOULD_RETRY=(()=>!0);var J=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class K{constructor(e=new Z){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,o;null!==r&&(i=r[0]);const s=n.exec(t);return null!==s&&(o=s[0]),void 0!==i&&void 0!==o&&i!==o}updateRequestUrl(e,t){return J(this,void 0,void 0,function*(){t.request=t.request instanceof Request?yield d(e,t.request):e})}getOptions(e){let t;return e.middlewareControl instanceof i&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new Z,this.options)),t}executeWithRedirect(t,n,r){return J(this,void 0,void 0,function*(){try{yield this.nextMiddleware.execute(t);const i=t.response;if(!(n<r.maxRedirects&&this.isRedirect(i)&&this.hasLocationHeader(i)&&r.shouldRedirect(i)))return;if(++n,i.status===K.STATUS_CODE_SEE_OTHER)t.options.method=e.GET,delete t.options.body;else{const e=this.getLocationHeader(i);!this.isRelativeURL(e)&&this.shouldDropAuthorizationHeader(i.url,e)&&c(t.request,t.options,K.AUTHORIZATION_HEADER,void 0),yield this.updateRequestUrl(e,t)}yield this.executeWithRedirect(t,n,r)}catch(e){throw e}})}execute(e){return J(this,void 0,void 0,function*(){try{const t=0,n=this.getOptions(e);return e.options.redirect=K.MANUAL_REDIRECT,l.updateFeatureUsageFlag(e,h.REDIRECT_HANDLER_ENABLED),yield this.executeWithRedirect(e,t,n)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}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 ee=()=>new Function("try {return this === global;}catch(e){return false;}")();class te{static createWithAuthenticationProvider(e){const t=new f(e),n=new w(new v),r=new x,i=new m;if(t.setNext(n),ee()){const e=new K(new Z);n.setNext(e),e.setNext(r)}else n.setNext(r);return r.setNext(i),te.createWithMiddleware(t)}static createWithMiddleware(e){return new G(e)}}const ne=()=>{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 re{constructor(e){this.config={baseUrl:R,debugLogging:!1,defaultVersion:g};try{ne()}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=te.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 G(e.middleware)}this.httpClient=t}static init(e){const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]="authProvider"===n?new M(e[n]):e[n]);return re.initWithMiddleware(t)}static initWithMiddleware(e){try{return new re(e)}catch(e){throw e}}api(e){return new V(this.httpClient,this.config,e)}}var ie=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})};class oe{constructor(e,t,n){this.scopes=t,this.userAgentApplication="string"==typeof e?new Msal.UserAgentApplication(e,void 0,(e,t,n,r)=>{},n):e}getAccessToken(e){return ie(this,void 0,void 0,function*(){let t;if(void 0!==e&&(t=e.scopes),void 0!==t&&0!==t.length||(t=this.scopes),0===t.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes cannot be empty, Please provide a scope",e}try{return yield this.userAgentApplication.acquireTokenSilent(t)}catch(e){try{yield this.userAgentApplication.loginPopup(t);try{return yield this.userAgentApplication.acquireTokenSilent(t)}catch(e){return yield this.userAgentApplication.acquireTokenPopup(t)}}catch(e){throw new Error(e)}}})}addScopes(e){if(0===e.length){const e=new Error;throw e.name="EmptyScopes",e.message="Scopes array cannot be empty",e}this.scopes=Array.from(new Set(this.scopes.concat(e)))}clearScopes(){this.scopes=[]}}class se{constructor(e){this.scopes=e}}export{f as AuthenticationHandler,u as AuthenticationHandlerOptions,n as BatchRequestContent,r as BatchResponseContent,re as Client,h as FeatureUsageFlag,N as GraphError,V as GraphRequest,m as HTTPMessageHandler,_ as LargeFileUploadTask,oe as MSALAuthenticationProvider,se as MSALAuthenticationProviderOptions,b as OneDriveLargeFileUploadTask,U as PageIterator,$ as ResponseType,w as RetryHandler,v as RetryHandlerOptions,x as TelemetryHandler,l as TelemetryHandlerOptions};
function e(e,t,n,r){return new(n||(n=Promise))(function(s,i){function o(e){try{d(r.next(e))}catch(e){i(e)}}function a(e){try{d(r.throw(e))}catch(e){i(e)}}function d(e){e.done?s(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 s=n;for(n=t.next();!n.done;){const e=n.value[1];if(void 0===e.dependsOn||1!==e.dependsOn.length||e.dependsOn[0]!==s.value[1].id)return!1;s=n,n=t.next()}return!0})(e)||(e=>{const t=e.entries();let n=t.next();const r=n.value[1];let s;if(void 0===r.dependsOn||0===r.dependsOn.length)s=r.id;else{if(1!==r.dependsOn.length)return!1;{const t=r.dependsOn[0];if(t===r.id||!e.has(t))return!1;s=t}}for(n=t.next();!n.done;){const e=n.value[1];if((void 0===e.dependsOn||0===e.dependsOn.length)&&s!==e.id)return!1;if(void 0!==e.dependsOn&&0!==e.dependsOn.length){if(1===e.dependsOn.length&&(e.id===s||e.dependsOn[0]!==s))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:""},s=new RegExp("^https?://");e.url=s.test(r.url)?"/"+r.url.split(/.*?\/\/.*?\//)[1]:r.url,e.method=r.method;const i={};return r.headers.forEach((e,t)=>{i[t]=e}),Object.keys(i).length&&(e.headers=i),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 s=r.next();if(s.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(;!s.done;){const t=s.value[1],i=yield n.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),s=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,s=n.next();for(;!s.done&&s.value[1].id!==e;)r=s,s=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===s.value[1].dependsOn&&(s.value[1].dependsOn=[]),-1!==s.value[1].dependsOn.indexOf(t)){const n=new Error(`Dependency ${t} is already added for the request ${e}`);throw n.name="Duplicate Dependency",n}s.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={};return n.status=e.status,void 0!==e.statusText&&(n.statusText=e.statusText),n.headers=e.headers,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 s{constructor(e=[]){this.middlewareOptions=new Map;for(const t of e){const e=t.constructor.name;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,n)=>{let r=null;if(e instanceof Request)r=e.headers.get(n);else if(void 0!==t&&void 0!==t.headers)if(t.headers instanceof Headers)r=t.headers.get(n);else if(t.headers instanceof Array){const e=t.headers;for(let t=0,s=e.length;t<s;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(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(t.headers instanceof Headers)t.headers.set(n,r);else if(t.headers instanceof Array){let e=0;const s=t.headers.length;for(;e<s;e++){const s=t.headers[e];if(s[0]===n){s[1]=r;break}}e===s&&t.headers.push([n,r])}else Object.assign(t.headers,{[n]:r})},d=(e,t,n,r)=>{e instanceof Request?e.headers.append(n,r):void 0!==t&&(void 0===t.headers?t.headers=new Headers({[n]:r}):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:s,referrer:i,referrerPolicy:o,mode:a,credentials:d,cache:c,redirect:h,integrity:l,keepalive:u,signal:p}=n;return new Request(t,{method:r,headers:s,body:e,referrer:i,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 s?n=e.middlewareControl.getMiddlewareOptions(u.name):e.middlewareControl=new s,void 0===n&&(n=new u,e.middlewareControl.setMiddlewareOptions(u.name,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 s&&(e=t.middlewareControl.getMiddlewareOptions(h.name)),void 0!==e&&(n=e.authenticationProvider,r=e.authenticationProviderOptions),void 0===n&&(n=this.authenticationProvider);const i=`Bearer ${yield n.getAccessToken(r)}`;return d(t.request,t.options,p.AUTHORIZATION_HEADER,i),u.updateFeatureUsageFlag(t,l.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 m{constructor(e=m.DEFAULT_DELAY,t=m.DEFAULT_MAX_RETRIES,n=m.DEFAULT_SHOULD_RETRY){if(e>m.MAX_DELAY&&t>m.MAX_MAX_RETRIES){const e=new Error(`Delay and MaxRetries should not be more than ${m.MAX_DELAY} and ${m.MAX_MAX_RETRIES}`);throw e.name="MaxLimitExceeded",e}if(e>m.MAX_DELAY){const e=new Error(`Delay should not be more than ${m.MAX_DELAY}`);throw e.name="MaxLimitExceeded",e}if(t>m.MAX_MAX_RETRIES){const e=new Error(`MaxRetries should not be more than ${m.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,m.MAX_DELAY),this.maxRetries=Math.min(t,m.MAX_MAX_RETRIES),this.shouldRetry=n}getMaxDelay(){return m.MAX_DELAY}}m.DEFAULT_DELAY=3,m.DEFAULT_MAX_RETRIES=3,m.MAX_DELAY=180,m.MAX_MAX_RETRIES=10,m.DEFAULT_SHOULD_RETRY=(()=>!0);class y{constructor(e=new m){this.options=e}isRetry(e){return-1!==y.RETRY_STATUS_CODES.indexOf(e.status)}isBuffered(e,n){const r=e instanceof Request?e.method:n.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)),s=void 0!==e.headers?e.headers.get(y.RETRY_AFTER_HEADER):null;let i;return i=null!==s?Number.isNaN(Number(s))?Math.round((new Date(s).getTime()-Date.now())/1e3):Number(s):t>=2?this.getExponentialBackOffTime(t)+n+r():n+r(),Math.min(i,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 s&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new m,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,y.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}}y.RETRY_STATUS_CODES=[429,503,504],y.RETRY_ATTEMPT_HEADER="Retry-Attempt",y.RETRY_AFTER_HEADER="Retry-After";const E="2.0.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=i(),a(t.request,t.options,v.CLIENT_REQUEST_ID_HEADER,e));let n,r=`${v.PRODUCT_NAME}/${E}`;if(t.middlewareControl instanceof s&&(n=t.middlewareControl.getMiddlewareOptions(u.name)),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}}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 R{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,s={}){return e(this,void 0,void 0,function*(){try{const e=yield t.api(n).headers(s).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 s=parseInt(n[1],10);return Number.isNaN(s)&&(s=this.file.size-1),new w(r,s)}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 g=(e=5242880)=>{return e>62914560&&(e=62914560),(e=>(e>327680&&(e=320*Math.floor(e/327680)*1024),e))(e)};class A extends R{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 s,i;switch(n.constructor.name){case"Blob":i=(s=new File([n],e)).size;break;case"File":i=(s=n).size;break;case"Buffer":const t=n;i=t.byteLength-t.byteOffset,s=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}try{const n=A.constructCreateSessionUrl(r.fileName,r.path),o=yield A.createUploadSession(t,n,r.fileName),a=g(r.rangeSize);return new A(t,{name:e,content:s,size:i},o,{rangeSize:a})}catch(e){throw e}})}static createUploadSession(t,n,r){const s=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 s.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 O="v1.0",D="https://graph.microsoft.com/";class x{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):t&&"Error"===t.constructor.name?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("/"))},U=e=>{const t=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 S,C,M,N;!function(e){e.ARRAYBUFFER="arraybuffer",e.BLOB="blob",e.DOCUMENT="document",e.JSON="json",e.RAW="raw",e.STREAM="stream",e.TEXT="text"}(S||(S={})),function(e){e.TEXT_HTML="text/html",e.TEXT_XML="text/xml",e.APPLICATION_XML="application/xml",e.APPLICATION_XHTML="application/xhtml+xml"}(C||(C={})),function(e){e.TEXT_PLAIN="text/plain",e.APPLICATION_JSON="application/json"}(M||(M={})),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 s=(new DOMParser).parseFromString(e,t);n(s)}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 S.ARRAYBUFFER:e=yield t.arrayBuffer();break;case S.BLOB:e=yield t.blob();break;case S.DOCUMENT:e=yield q.parseDocumentResponse(t,C.TEXT_XML);break;case S.JSON:e=yield t.json();break;case S.STREAM:e=yield Promise.resolve(t.body);break;case S.TEXT:e=yield t.text();break;default:const r=t.headers.get("Content-type");if(null!==r){const n=r.split(";")[0];e=new RegExp(N.DOCUMENT).test(n)?yield q.parseDocumentResponse(t,n):new RegExp(N.IMAGE).test(n)?t.blob():n===M.TEXT_PLAIN?yield t.text():n===M.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===S.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 i=new s(this._middlewareOptions);this.updateRequestOptions(n);try{return e=(yield this.httpClient.sendRequest({request:t,options:n,middlewareControl:i})).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){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],s=n[1];t[r]=s}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(),s={method:t.POST,body:U(n),headers:void 0!==n.constructor&&"FormData"===n.constructor.name?{}:{"Content-Type":"application/json"}};try{return yield this.send(e,s,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(),s={method:t.PUT,body:U(n),headers:{"Content-Type":"application/json"}};try{return yield this.send(e,s,r)}catch(e){throw e}})}patch(n,r){return e(this,void 0,void 0,function*(){const e=this.buildFullUrl(),s={method:t.PATCH,body:U(n),headers:{"Content-Type":"application/json"}};try{return yield this.send(e,s,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(S.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(),s={method:t.PUT,headers:{"Content-Type":"application/octet-stream"},body:n};try{return yield this.send(e,s,r)}catch(e){throw e}})}}class F{constructor(e){this.middleware=e}sendRequest(t){return e(this,void 0,void 0,function*(){try{if(!(t.request instanceof 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 k{constructor(e=k.DEFAULT_MAX_REDIRECTS,t=k.DEFAULT_SHOULD_RETRY){if(e>k.MAX_MAX_REDIRECTS){const e=new Error(`MaxRedirects should not be more than ${k.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}}k.DEFAULT_MAX_REDIRECTS=5,k.MAX_MAX_REDIRECTS=20,k.DEFAULT_SHOULD_RETRY=(()=>!0);class H{constructor(e=new k){this.options=e}isRedirect(e){return-1!==H.REDIRECT_STATUS_CODES.indexOf(e.status)}hasLocationHeader(e){return e.headers.has(H.LOCATION_HEADER)}getLocationHeader(e){return e.headers.get(H.LOCATION_HEADER)}isRelativeURL(e){return-1===e.indexOf("://")}shouldDropAuthorizationHeader(e,t){const n=/^[A-Za-z].+?:\/\/.+?(?=\/|$)/,r=n.exec(e);let s,i;null!==r&&(s=r[0]);const o=n.exec(t);return null!==o&&(i=o[0]),void 0!==s&&void 0!==i&&s!==i}updateRequestUrl(t,n){return e(this,void 0,void 0,function*(){n.request=n.request instanceof Request?yield c(t,n.request):t})}getOptions(e){let t;return e.middlewareControl instanceof s&&(t=e.middlewareControl.getMiddlewareOptions(this.options.constructor.name)),void 0===t&&(t=Object.assign(new k,this.options)),t}executeWithRedirect(n,r,s){return e(this,void 0,void 0,function*(){try{yield this.nextMiddleware.execute(n);const e=n.response;if(!(r<s.maxRedirects&&this.isRedirect(e)&&this.hasLocationHeader(e)&&s.shouldRedirect(e)))return;if(++r,e.status===H.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,H.AUTHORIZATION_HEADER,void 0),yield this.updateRequestUrl(t,n)}yield this.executeWithRedirect(n,r,s)}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=H.MANUAL_REDIRECT,u.updateFeatureUsageFlag(t,l.REDIRECT_HANDLER_ENABLED),yield this.executeWithRedirect(t,e,n)}catch(e){throw e}})}setNext(e){this.nextMiddleware=e}}H.REDIRECT_STATUS_CODES=[301,302,303,307,308],H.STATUS_CODE_SEE_OTHER=303,H.LOCATION_HEADER="Location",H.AUTHORIZATION_HEADER="Authorization",H.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 y(new m),r=new v,s=new f;if(t.setNext(n),$()){const e=new H(new k);n.setNext(e),e.setNext(r)}else n.setNext(r);return r.setNext(s),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:D,debugLogging:!1,defaultVersion:O};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 x(e[n]):e[n]);return Q.initWithMiddleware(t)}static initWithMiddleware(e){try{return new Q(e)}catch(e){throw 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)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,R as LargeFileUploadTask,Y as MSALAuthenticationProviderOptions,A as OneDriveLargeFileUploadTask,T as PageIterator,S as ResponseType,y as RetryHandler,m as RetryHandlerOptions,v as TelemetryHandler,u as TelemetryHandlerOptions};

@@ -33,4 +33,4 @@ /**

export * from "../IOptions";
export * from "./MSALAuthenticationProvider";
export * from "./ImplicitMSALAuthenticationProvider";
export * from "../MSALAuthenticationProviderOptions";
export * from "../ResponseType";

@@ -25,5 +25,5 @@ "use strict";

tslib_1.__exportStar(require("../GraphRequest"), exports);
tslib_1.__exportStar(require("./MSALAuthenticationProvider"), exports);
tslib_1.__exportStar(require("./ImplicitMSALAuthenticationProvider"), exports);
tslib_1.__exportStar(require("../MSALAuthenticationProviderOptions"), exports);
tslib_1.__exportStar(require("../ResponseType"), exports);
//# sourceMappingURL=index.js.map

@@ -20,8 +20,1 @@ /**

export declare const GRAPH_BASE_URL = "https://graph.microsoft.com/";
/**
* @constant
* A package version
* @NOTE: This should be kept up to date with the version used in package.json.
* If you are changing this please ensure you are also changing it in package.json.
*/
export declare const PACKAGE_VERSION = "1.7.0";

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

exports.GRAPH_BASE_URL = "https://graph.microsoft.com/";
/**
* @constant
* A package version
* @NOTE: This should be kept up to date with the version used in package.json.
* If you are changing this please ensure you are also changing it in package.json.
*/
exports.PACKAGE_VERSION = "1.7.0";
//# sourceMappingURL=Constants.js.map

@@ -21,7 +21,7 @@ /**

* @property {KeyValuePairObject[]} responses - An array of key value pair representing response object for every request
* @property {string} [@nextLink] - The nextLink value to get next set of responses in case of asynchronous batch requests
* @property {string} [@odata.nextLink] - The nextLink value to get next set of responses in case of asynchronous batch requests
*/
interface BatchResponseBody {
responses: KeyValuePairObject[];
"@nextLink"?: string;
"@odata.nextLink"?: string;
}

@@ -28,0 +28,0 @@ /**

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

BatchResponseContent.prototype.update = function (response) {
this.nextLink = response["@nextLink"];
this.nextLink = response["@odata.nextLink"];
var responses = response.responses;

@@ -52,0 +52,0 @@ for (var i = 0, l = responses.length; i < l; i++) {

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

headers: {
"Content-Type": "application/octet-stream",
"Content-Type": "application/json",
},

@@ -545,0 +545,0 @@ };

@@ -98,8 +98,7 @@ "use strict";

return tslib_1.__awaiter(this, void 0, void 0, function () {
var clonedRawResponse, responseValue, _a, contentType, mimeType, error_1;
var responseValue, _a, contentType, mimeType, error_1;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
clonedRawResponse = rawResponse.clone();
if (clonedRawResponse.status === 204) {
if (rawResponse.status === 204) {
// NO CONTENT

@@ -121,23 +120,23 @@ return [2 /*return*/, Promise.resolve()];

return [3 /*break*/, 14];
case 2: return [4 /*yield*/, clonedRawResponse.arrayBuffer()];
case 2: return [4 /*yield*/, rawResponse.arrayBuffer()];
case 3:
responseValue = _b.sent();
return [3 /*break*/, 25];
case 4: return [4 /*yield*/, clonedRawResponse.blob()];
case 4: return [4 /*yield*/, rawResponse.blob()];
case 5:
responseValue = _b.sent();
return [3 /*break*/, 25];
case 6: return [4 /*yield*/, GraphResponseHandler.parseDocumentResponse(clonedRawResponse, DocumentType.TEXT_XML)];
case 6: return [4 /*yield*/, GraphResponseHandler.parseDocumentResponse(rawResponse, DocumentType.TEXT_XML)];
case 7:
responseValue = _b.sent();
return [3 /*break*/, 25];
case 8: return [4 /*yield*/, clonedRawResponse.json()];
case 8: return [4 /*yield*/, rawResponse.json()];
case 9:
responseValue = _b.sent();
return [3 /*break*/, 25];
case 10: return [4 /*yield*/, Promise.resolve(clonedRawResponse.body)];
case 10: return [4 /*yield*/, Promise.resolve(rawResponse.body)];
case 11:
responseValue = _b.sent();
return [3 /*break*/, 25];
case 12: return [4 /*yield*/, clonedRawResponse.text()];
case 12: return [4 /*yield*/, rawResponse.text()];
case 13:

@@ -147,7 +146,7 @@ responseValue = _b.sent();

case 14:
contentType = clonedRawResponse.headers.get("Content-type");
contentType = rawResponse.headers.get("Content-type");
if (!(contentType !== null)) return [3 /*break*/, 23];
mimeType = contentType.split(";")[0];
if (!new RegExp(ContentTypeRegexStr.DOCUMENT).test(mimeType)) return [3 /*break*/, 16];
return [4 /*yield*/, GraphResponseHandler.parseDocumentResponse(clonedRawResponse, mimeType)];
return [4 /*yield*/, GraphResponseHandler.parseDocumentResponse(rawResponse, mimeType)];
case 15:

@@ -158,7 +157,7 @@ responseValue = _b.sent();

if (!new RegExp(ContentTypeRegexStr.IMAGE).test(mimeType)) return [3 /*break*/, 17];
responseValue = clonedRawResponse.blob();
responseValue = rawResponse.blob();
return [3 /*break*/, 22];
case 17:
if (!(mimeType === ContentType.TEXT_PLAIN)) return [3 /*break*/, 19];
return [4 /*yield*/, clonedRawResponse.text()];
return [4 /*yield*/, rawResponse.text()];
case 18:

@@ -169,3 +168,3 @@ responseValue = _b.sent();

if (!(mimeType === ContentType.APPLICATION_JSON)) return [3 /*break*/, 21];
return [4 /*yield*/, clonedRawResponse.json()];
return [4 /*yield*/, rawResponse.json()];
case 20:

@@ -175,3 +174,3 @@ responseValue = _b.sent();

case 21:
responseValue = Promise.resolve(clonedRawResponse.body);
responseValue = Promise.resolve(rawResponse.body);
_b.label = 22;

@@ -191,3 +190,3 @@ case 22: return [3 /*break*/, 24];

*/
responseValue = Promise.resolve(clonedRawResponse.body);
responseValue = Promise.resolve(rawResponse.body);
_b.label = 24;

@@ -229,3 +228,3 @@ case 24: return [3 /*break*/, 25];

if (typeof callback === "function") {
callback(null, response, rawResponse);
callback(null, response);
}

@@ -232,0 +231,0 @@ else {

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

*/
import "./PolyFill";
export * from "./content/BatchRequestContent";

@@ -10,0 +9,0 @@ export * from "./content/BatchResponseContent";

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

var tslib_1 = require("tslib");
require("./PolyFill");
tslib_1.__exportStar(require("./content/BatchRequestContent"), exports);

@@ -13,0 +12,0 @@ tslib_1.__exportStar(require("./content/BatchResponseContent"), exports);

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

bearerKey = "Bearer " + token;
MiddlewareUtil_1.setRequestHeader(context.request, context.options, AuthenticationHandler.AUTHORIZATION_HEADER, bearerKey);
MiddlewareUtil_1.appendRequestHeader(context.request, context.options, AuthenticationHandler.AUTHORIZATION_HEADER, bearerKey);
TelemetryHandlerOptions_1.TelemetryHandlerOptions.updateFeatureUsageFlag(context, TelemetryHandlerOptions_1.FeatureUsageFlag.AUTHENTICATION_HANDLER_ENABLED);

@@ -63,0 +63,0 @@ return [4 /*yield*/, this.nextMiddleware.execute(context)];

@@ -38,2 +38,12 @@ /**

* @constant
* To append the header value to the given request
* @param {RequestInfo} request - The request object or the url string
* @param {FetchOptions|undefined} options - The request options object
* @param {string} key - The header key string
* @param {string } value - The header value string
* @returns Nothing
*/
export declare const appendRequestHeader: (request: RequestInfo, options: FetchOptions, key: string, value: string) => void;
/**
* @constant
* To clone the request with the new url

@@ -40,0 +50,0 @@ * @param {string} url - The new url string

@@ -74,5 +74,5 @@ "use strict";

if (options.headers === undefined) {
options.headers = (_a = {},
options.headers = new Headers((_a = {},
_a[key] = value,
_a);
_a));
}

@@ -84,3 +84,14 @@ else {

else if (options.headers instanceof Array) {
options.headers.push([key, value]);
var i = 0;
var l = options.headers.length;
for (; i < l; i++) {
var header = options.headers[i];
if (header[0] === key) {
header[1] = value;
break;
}
}
if (i === l) {
options.headers.push([key, value]);
}
}

@@ -95,2 +106,41 @@ else {

* @constant
* To append the header value to the given request
* @param {RequestInfo} request - The request object or the url string
* @param {FetchOptions|undefined} options - The request options object
* @param {string} key - The header key string
* @param {string } value - The header value string
* @returns Nothing
*/
exports.appendRequestHeader = function (request, options, key, value) {
var _a, _b;
if (request instanceof Request) {
request.headers.append(key, value);
}
else if (typeof options !== "undefined") {
if (options.headers === undefined) {
options.headers = new Headers((_a = {},
_a[key] = value,
_a));
}
else {
if (options.headers instanceof Headers) {
options.headers.append(key, value);
}
else if (options.headers instanceof Array) {
options.headers.push([key, value]);
}
else if (options.headers === undefined) {
options.headers = (_b = {}, _b[key] = value, _b);
}
else if (options.headers[key] === undefined) {
options.headers[key] = value;
}
else {
options.headers[key] += ", " + value;
}
}
}
};
/**
* @constant
* To clone the request with the new url

@@ -97,0 +147,0 @@ * @param {string} url - The new url string

@@ -31,2 +31,7 @@ "use strict";

}
if (maxRedirects < 0) {
var error = new Error("MaxRedirects should not be negative");
error.name = "MinExpectationNotMet";
throw error;
}
this.maxRedirects = maxRedirects;

@@ -33,0 +38,0 @@ this.shouldRedirect = shouldRedirect;

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

}
else if (delay < 0 && maxRetries < 0) {
var error = new Error("Delay and MaxRetries should not be negative");
error.name = "MinExpectationNotMet";
throw error;
}
else if (delay < 0) {
var error = new Error("Delay should not be negative");
error.name = "MinExpectationNotMet";
throw error;
}
else if (maxRetries < 0) {
var error = new Error("MaxRetries should not be negative");
error.name = "MinExpectationNotMet";
throw error;
}
this.delay = Math.min(delay, RetryHandlerOptions.MAX_DELAY);

@@ -45,0 +60,0 @@ this.maxRetries = Math.min(maxRetries, RetryHandlerOptions.MAX_MAX_RETRIES);

@@ -7,2 +7,5 @@ /**

*/
/**
* @module TelemetryHandler
*/
import { Context } from "../IContext";

@@ -9,0 +12,0 @@ import { Middleware } from "./IMiddleware";

@@ -10,6 +10,3 @@ "use strict";

var tslib_1 = require("tslib");
/**
* @module TelemetryHandler
*/
var Constants_1 = require("../Constants");
var Version_1 = require("../Version");
var MiddlewareControl_1 = require("./MiddlewareControl");

@@ -45,3 +42,3 @@ var MiddlewareUtil_1 = require("./MiddlewareUtil");

}
sdkVersionValue = TelemetryHandler.PRODUCT_NAME + "/" + Constants_1.PACKAGE_VERSION;
sdkVersionValue = TelemetryHandler.PRODUCT_NAME + "/" + Version_1.PACKAGE_VERSION;
options = void 0;

@@ -55,3 +52,3 @@ if (context.middlewareControl instanceof MiddlewareControl_1.MiddlewareControl) {

}
MiddlewareUtil_1.setRequestHeader(context.request, context.options, TelemetryHandler.SDK_VERSION_HEADER, sdkVersionValue);
MiddlewareUtil_1.appendRequestHeader(context.request, context.options, TelemetryHandler.SDK_VERSION_HEADER, sdkVersionValue);
return [4 /*yield*/, this.nextMiddleware.execute(context)];

@@ -58,0 +55,0 @@ case 1: return [2 /*return*/, _a.sent()];

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

* @property {any[]} value - The collection value
* @property {string} [@odata.nextLink] - The nextLine value
* @property {string} [@odata.nextLink] - The nextLink value
* @property {string} [@odata.deltaLink] - The deltaLink value
* @property {any} Additional - Any number of additional properties (This is to accept the any additional data returned by in the response to the nextLink request)

@@ -17,0 +18,0 @@ */

{
"name": "@microsoft/microsoft-graph-client",
"//": "NOTE: The version here should match exactly the exported const PACKAGE_VERSION in Constants.ts. If you change it here, also change it there.",
"version": "1.7.0",
"version": "2.0.0-Preview.1",
"description": "Microsoft Graph Client Library",

@@ -14,30 +13,35 @@ "main": "lib/src/index.js",

"dependencies": {
"es6-promise": "^4.2.6",
"isomorphic-fetch": "^2.2.1",
"@babel/runtime": "^7.4.4",
"tslib": "^1.9.3"
},
"devDependencies": {
"@types/isomorphic-fetch": "0.0.35",
"@babel/core": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@types/mocha": "^5.2.6",
"@types/node": "^11.13.4",
"browserify": "^16.2.3",
"@types/node": "^11.13.9",
"chai": "^4.2.0",
"husky": "^1.3.1",
"gulp": "^4.0.2",
"husky": "^2.2.0",
"isomorphic-fetch": "^2.2.1",
"lint-staged": "^8.1.5",
"mocha": "^6.1.3",
"msal": "^0.2.4",
"mocha": "^6.1.4",
"msal": "^1.0.0",
"prettier": "^1.17.0",
"rollup": "^1.10.0",
"rollup": "^1.10.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-terser": "^4.0.4",
"tslint": "^5.15.0",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.4.3",
"typescript": "^3.4.5",
"uglify-es": "^3.3.9"
},
"scripts": {
"web:js": "node browserify-with-dependencies.js > lib/graph-js-sdk-web.js && uglifyjs ./lib/graph-js-sdk-web.js --output ./lib/graph-js-sdk-web.js",
"core:js": "node browserify.js > lib/graph-js-sdk-core.js && uglifyjs ./lib/graph-js-sdk-core.js --output ./lib/graph-js-sdk-core.js",
"setVersion": "gulp setVersion",
"build:es": "tsc --p tsconfig-es.json",
"build:cjs": "tsc --p tsconfig-cjs.json",
"build": "npm run build:cjs && npm run build:es && rollup -c && npm run web:js && npm run core:js",
"pre-build": "npm run setVersion",
"build": "npm run pre-build && npm run build:cjs && npm run build:es && rollup -c",
"test": "npm run build:cjs && mocha lib/spec/content && mocha lib/spec/core && mocha lib/spec/middleware && mocha lib/spec/tasks",

@@ -44,0 +48,0 @@ "test:content": "tsc --p spec/tsconfig.json && mocha spec/content",

@@ -19,5 +19,6 @@ # Microsoft Graph JavaScript Client Library

import `@microsoft/microsoft-graph-client` into your module.
import `@microsoft/microsoft-graph-client` into your module and also you will need polyfills for fetch like [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch).
```typescript
import "isomorphic-fetch";
import { Client } from "@microsoft/microsoft-graph-client";

@@ -28,12 +29,19 @@ ```

Include `lib/graph-js-sdk-web.js` in your page.
Include [graph-js-sdk.js](https://cdn.jsdelivr.net/npm/@microsoft/microsoft-graph-client/lib/graph-js-sdk.js) in your HTML page.
```HTML
<script type="text/javascript" src="graph-js-sdk-web.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@microsoft/microsoft-graph-client/lib/graph-js-sdk.js"></script>
```
Incase if your application ships with [es6-promise](https://www.npmjs.com/package/es6-promise) and [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch) just use `lib/graph-js-sdk-core.js`
In case your browser doesn't have support for [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) [[support](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility)] or [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) [[support](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Browser_compatibility)], you need to use polyfills like [github/fetch](https://github.com/github/fetch) for fetch and [es6-promise](https://github.com/stefanpenner/es6-promise) for promise.
```HTML
<script type="text/javascript" src="graph-js-sdk-core.js"></script>
<!-- polyfilling promise -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js"></script>
<!-- polyfilling fetch -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/whatwg-fetch/dist/fetch.umd.min.js"></script>
<!-- depending on your browser you might wanna include babel polyfill -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.4.4/dist/polyfill.min.js"></script>
```

@@ -52,7 +60,7 @@

The Microsoft Graph JavaScript Client Library has an adapter implementation ([MSALAuthenticationProvider](src/MSALAuthenticationProvider.ts)) for [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core) (Microsoft Authentication Library) which takes care of getting the `accessToken`. MSAL library does not ship with this library, user has to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
The Microsoft Graph JavaScript Client Library has an adapter implementation ([ImplicitMSALAuthenticationProvider](src/ImplicitMSALAuthenticationProvider.ts)) for [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core) (Microsoft Authentication Library) which takes care of getting the `accessToken`. MSAL library does not ship with this library, user has to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
> **Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
> **Important Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Learn how you can create a [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
#### Creating an instance of MSALAuthenticationProvider in browser environment
#### Creating an instance of ImplicitMSALAuthenticationProvider in browser environment

@@ -66,16 +74,20 @@ Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.

```typescript
const clientId = "your_client_id"; // Client Id of the registered application
const callback = (errorDesc, token, error, tokenType) => {};
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
const options = {
redirectUri: "Your redirect URI",
// Configuration options for MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL.js-1.0.0-api-release#configuration-options
const msalConfig = {
auth: {
clientId: "your_client_id"; // Client Id of the registered application
redirectUri: "your_redirect_uri",
},
};
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
const userAgentApplication = new Msal.UserAgentApplication(clientId, undefined, callback, options);
const authProvider = new MicrosoftGraph.MSALAuthenticationProvider(userAgentApplication, graphScopes);
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
const msalApplication = new Msal.UserAgentApplication(msalConfig);
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(msalApplication, options);
```
#### Creating an instance of MSALAuthenticationProvider in node environment
#### Creating an instance of ImplicitMSALAuthenticationProvider in node environment

@@ -91,15 +103,18 @@ Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.

import { MSALAuthenticationProvider } from "./node_modules/@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProvider";
import { ImplicitMSALAuthenticationProvider } from "./node_modules/@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
const clientId = "your_client_id"; // Client Id of the registered application
const callback = (errorDesc, token, error, tokenType) => {};
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
const options = {
redirectUri: "Your redirect URI",
const msalConfig = {
auth: {
clientId: "your_client_id", // Client Id of the registered application
redirectUri: "your_redirect_uri",
},
};
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
const userAgentApplication = new UserAgentApplication(clientId, undefined, callback, options);
const authProvider = new MSALAuthenticationProvider(userAgentApplication, scopes);
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
const msalApplication = new UserAgentApplication(msalConfig);
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
const authProvider = new ImplicitMSALAuthenticationProvider(msalApplication, options);
```

@@ -201,4 +216,4 @@

- [Microsoft Graph TypeScript types](https://github.com/microsoftgraph/msgraph-typescript-typings/)
- [Angular.js sample using the JavaScript client library](https://github.com/microsoftgraph/angular-connect-sample)
- [Node.js sample using the JavaScript client library](https://github.com/microsoftgraph/nodejs-connect-sample)
- [Build Angular single-page apps with Microsoft Graph](https://github.com/microsoftgraph/msgraph-training-angularspa)
- [Build Node.js Express apps with Microsoft Graph](https://github.com/microsoftgraph/msgraph-training-nodeexpressapp)
- [Office Dev Center](http://dev.office.com/)

@@ -205,0 +220,0 @@

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

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

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