diff --git a/.gitignore b/.gitignore index 19939848..7edecbc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ -################################################################################ -# This .gitignore file was automatically created by Microsoft(R) Visual Studio. -################################################################################ - +.DS_Store +npm-debug.log +/typings/ /.vs/config /node_modules +/coverage/ /obj/Debug /web.Release.config /web.Debug.config -/web.config diff --git a/config.json b/config.json deleted file mode 100644 index 01234c97..00000000 --- a/config.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "build": { - "version": "0.4.1", - "filename": "kurve.js", - "minFilename": "kurve.min", - "declarationFilename": ".d.ts", - "outputDirectory": "./dist", - "srcOutputDirectory": "./dist", - "srcCompiledJavaScriptFile": "./dist/kurve.js" - }, - "core": { - "typescript": [ - "./promises.ts", - "./KurveIdentity.ts", - "./KurveGraph.ts", - "./promises.d.ts", - "./KurveIdentity.d.ts", - "./KurveGraph.d.ts" - ] - } -} \ No newline at end of file diff --git a/dist/kurve.d.ts b/dist/kurve.d.ts new file mode 100644 index 00000000..952b606c --- /dev/null +++ b/dist/kurve.d.ts @@ -0,0 +1,469 @@ +declare module 'kurve/src/identity' { + import { Promise, PromiseCallback } from 'kurve/src/promises'; + export enum OAuthVersion { + v1 = 1, + v2 = 2, + } + export class Error { + status: number; + statusText: string; + text: string; + other: any; + } + export interface TokenStorage { + add(key: string, token: any): any; + remove(key: string): any; + getAll(): any[]; + clear(): any; + } + export class IdToken { + Token: string; + IssuerIdentifier: string; + SubjectIdentifier: string; + Audience: string; + Expiry: Date; + UPN: string; + TenantId: string; + FamilyName: string; + GivenName: string; + Name: string; + PreferredUsername: string; + FullToken: any; + } + export interface IdentitySettings { + clientId: string; + tokenProcessingUri: string; + version: OAuthVersion; + tokenStorage?: TokenStorage; + } + export class Identity { + clientId: string; + private state; + private version; + private nonce; + private idToken; + private loginCallback; + private getTokenCallback; + private tokenProcessorUrl; + private tokenCache; + private refreshTimer; + private policy; + constructor(identitySettings: IdentitySettings); + checkForIdentityRedirect(): boolean; + private decodeIdToken(idToken); + private decodeAccessToken(accessToken, resource?, scopes?); + getIdToken(): any; + isLoggedIn(): boolean; + private renewIdToken(); + getCurrentOauthVersion(): OAuthVersion; + getAccessTokenAsync(resource: string): Promise; + getAccessToken(resource: string, callback: PromiseCallback): void; + getAccessTokenForScopesAsync(scopes: string[], promptForConsent?: boolean): Promise; + getAccessTokenForScopes(scopes: string[], promptForConsent: boolean, callback: (token: string, error: Error) => void): void; + loginAsync(loginSettings?: { + scopes?: string[]; + policy?: string; + tenant?: string; + }): Promise; + login(callback: (error: Error) => void, loginSettings?: { + scopes?: string[]; + policy?: string; + tenant?: string; + }): void; + loginNoWindowAsync(toUrl?: string): Promise; + loginNoWindow(callback: (error: Error) => void, toUrl?: string): void; + logOut(): void; + private base64Decode(encodedString); + private generateNonce(); + } + +} +declare module 'kurve/src/promises' { + export interface PromiseCallback { + (T: any, Error: any): void; + } + export class Deferred { + private _dispatcher; + constructor(); + constructor(dispatcher: (closure: () => void) => void); + private DispatchDeferred(closure); + then(successCB: any, errorCB: any): any; + resolve(value?: T): Deferred; + resolve(value?: Promise): Deferred; + private _resolve(value); + reject(error?: E): Deferred; + private _reject(error?); + promise: Promise; + private _stack; + private _state; + private _value; + private _error; + } + export class Promise implements Promise { + private _deferred; + constructor(_deferred: Deferred); + then(successCallback?: (result: T) => R, errorCallback?: (error: E) => R): Promise; + fail(errorCallback?: (error: E) => R): Promise; + } + +} +declare module 'kurve/src/graph' { + import { Promise, PromiseCallback } from 'kurve/src/promises'; + import { Identity, Error } from 'kurve/src/identity'; + export module Scopes { + class General { + static OpenId: string; + static OfflineAccess: string; + } + class User { + static Read: string; + static ReadWrite: string; + static ReadBasicAll: string; + static ReadAll: string; + static ReadWriteAll: string; + } + class Contacts { + static Read: string; + static ReadWrite: string; + } + class Directory { + static ReadAll: string; + static ReadWriteAll: string; + static AccessAsUserAll: string; + } + class Group { + static ReadAll: string; + static ReadWriteAll: string; + static AccessAsUserAll: string; + } + class Mail { + static Read: string; + static ReadWrite: string; + static Send: string; + } + class Calendars { + static Read: string; + static ReadWrite: string; + } + class Files { + static Read: string; + static ReadAll: string; + static ReadWrite: string; + static ReadWriteAppFolder: string; + static ReadWriteSelected: string; + } + class Tasks { + static ReadWrite: string; + } + class People { + static Read: string; + static ReadWrite: string; + } + class Notes { + static Create: string; + static ReadWriteCreatedByApp: string; + static Read: string; + static ReadAll: string; + static ReadWriteAll: string; + } + } + export class DataModelWrapper { + protected graph: Graph; + protected _data: T; + constructor(graph: Graph, _data: T); + data: T; + } + export class DataModelListWrapper extends DataModelWrapper { + nextLink: NextLink; + } + export class ProfilePhotoDataModel { + id: string; + height: Number; + width: Number; + } + export class ProfilePhoto extends DataModelWrapper { + } + export class UserDataModel { + businessPhones: string; + displayName: string; + givenName: string; + jobTitle: string; + mail: string; + mobilePhone: string; + officeLocation: string; + preferredLanguage: string; + surname: string; + userPrincipalName: string; + id: string; + } + export enum EventsEndpoint { + events = 0, + calendarView = 1, + } + export class User extends DataModelWrapper { + events(callback: PromiseCallback, odataQuery?: string): void; + eventsAsync(odataQuery?: string): Promise; + memberOf(callback: PromiseCallback, Error: any, odataQuery?: string): void; + memberOfAsync(odataQuery?: string): Promise; + messages(callback: PromiseCallback, odataQuery?: string): void; + messagesAsync(odataQuery?: string): Promise; + manager(callback: PromiseCallback, odataQuery?: string): void; + managerAsync(odataQuery?: string): Promise; + profilePhoto(callback: PromiseCallback, odataQuery?: string): void; + profilePhotoAsync(odataQuery?: string): Promise; + profilePhotoValue(callback: PromiseCallback, odataQuery?: string): void; + profilePhotoValueAsync(odataQuery?: string): Promise; + calendarView(callback: PromiseCallback, odataQuery?: string): void; + calendarViewAsync(odataQuery?: string): Promise; + mailFolders(callback: PromiseCallback, odataQuery?: string): void; + mailFoldersAsync(odataQuery?: string): Promise; + message(messageId: string, callback: PromiseCallback, odataQuery?: string): void; + messageAsync(messageId: string, odataQuery?: string): Promise; + event(eventId: string, callback: PromiseCallback, odataQuery?: string): void; + eventAsync(eventId: string, odataQuery?: string): Promise; + messageAttachment(messageId: string, attachmentId: string, callback: PromiseCallback, odataQuery?: string): void; + messageAttachmentAsync(messageId: string, attachmentId: string, odataQuery?: string): Promise; + } + export interface NextLink { + (callback?: PromiseCallback): Promise; + } + export class Users extends DataModelListWrapper { + } + export interface ItemBody { + contentType: string; + content: string; + } + export interface EmailAddress { + name: string; + address: string; + } + export interface Recipient { + emailAddress: EmailAddress; + } + export class MessageDataModel { + attachments: AttachmentDataModel[]; + bccRecipients: Recipient[]; + body: ItemBody; + bodyPreview: string; + categories: string[]; + ccRecipients: Recipient[]; + changeKey: string; + conversationId: string; + createdDateTime: string; + from: Recipient; + graph: any; + hasAttachments: boolean; + id: string; + importance: string; + isDeliveryReceiptRequested: boolean; + isDraft: boolean; + isRead: boolean; + isReadReceiptRequested: boolean; + lastModifiedDateTime: string; + parentFolderId: string; + receivedDateTime: string; + replyTo: Recipient[]; + sender: Recipient; + sentDateTime: string; + subject: string; + toRecipients: Recipient[]; + webLink: string; + } + export class Message extends DataModelWrapper { + } + export class Messages extends DataModelListWrapper { + } + export interface Attendee { + status: ResponseStatus; + type: string; + emailAddress: EmailAddress; + } + export interface DateTimeTimeZone { + dateTime: string; + timeZone: string; + } + export interface PatternedRecurrence { + } + export interface ResponseStatus { + response: string; + time: string; + } + export interface Location { + displayName: string; + address: any; + } + export class EventDataModel { + attendees: Attendee[]; + body: ItemBody; + bodyPreview: string; + categories: string[]; + changeKey: string; + createdDateTime: string; + end: DateTimeTimeZone; + hasAttachments: boolean; + iCalUId: string; + id: string; + IDBCursor: string; + importance: string; + isAllDay: boolean; + isCancelled: boolean; + isOrganizer: boolean; + isReminderOn: boolean; + lastModifiedDateTime: string; + location: Location; + organizer: Recipient; + originalEndTimeZone: string; + originalStartTimeZone: string; + recurrence: PatternedRecurrence; + reminderMinutesBeforeStart: number; + responseRequested: boolean; + responseStatus: ResponseStatus; + sensitivity: string; + seriesMasterId: string; + showAs: string; + start: DateTimeTimeZone; + subject: string; + type: string; + webLink: string; + } + export class Event extends DataModelWrapper { + } + export class Events extends DataModelListWrapper { + protected graph: Graph; + protected endpoint: EventsEndpoint; + protected _data: Event[]; + constructor(graph: Graph, endpoint: EventsEndpoint, _data: Event[]); + } + export class Contact { + } + export class GroupDataModel { + id: string; + description: string; + displayName: string; + groupTypes: string[]; + mail: string; + mailEnabled: Boolean; + mailNickname: string; + onPremisesLastSyncDateTime: Date; + onPremisesSecurityIdentifier: string; + onPremisesSyncEnabled: Boolean; + proxyAddresses: string[]; + securityEnabled: Boolean; + visibility: string; + } + export class Group extends DataModelWrapper { + } + export class Groups extends DataModelListWrapper { + } + export class MailFolderDataModel { + id: string; + displayName: string; + childFolderCount: number; + unreadItemCount: number; + totalItemCount: number; + } + export class MailFolder extends DataModelWrapper { + } + export class MailFolders extends DataModelListWrapper { + } + export enum AttachmentType { + fileAttachment = 0, + itemAttachment = 1, + referenceAttachment = 2, + } + export class AttachmentDataModel { + contentId: string; + id: string; + isInline: boolean; + lastModifiedDateTime: Date; + name: string; + size: number; + contentBytes: string; + contentLocation: string; + contentType: string; + } + export class Attachment extends DataModelWrapper { + getType(): AttachmentType; + } + export class Attachments extends DataModelListWrapper { + } + export class Graph { + private req; + private accessToken; + private KurveIdentity; + private defaultResourceID; + private baseUrl; + constructor(identityInfo: { + identity: Identity; + }); + constructor(identityInfo: { + defaultAccessToken: string; + }); + private scopesForV2(scopes); + meAsync(odataQuery?: string): Promise; + me(callback: PromiseCallback, odataQuery?: string): void; + userAsync(userId: string, odataQuery?: string, basicProfileOnly?: boolean): Promise; + user(userId: string, callback: PromiseCallback, odataQuery?: string, basicProfileOnly?: boolean): void; + usersAsync(odataQuery?: string, basicProfileOnly?: boolean): Promise; + users(callback: PromiseCallback, odataQuery?: string, basicProfileOnly?: boolean): void; + groupAsync(groupId: string, odataQuery?: string): Promise; + group(groupId: string, callback: PromiseCallback, odataQuery?: string): void; + groupsAsync(odataQuery?: string): Promise; + groups(callback: PromiseCallback, odataQuery?: string): void; + messageForUserAsync(userPrincipalName: string, messageId: string, odataQuery?: string): Promise; + messageForUser(userPrincipalName: string, messageId: string, callback: PromiseCallback, odataQuery?: string): void; + messagesForUserAsync(userPrincipalName: string, odataQuery?: string): Promise; + messagesForUser(userPrincipalName: string, callback: PromiseCallback, odataQuery?: string): void; + mailFoldersForUserAsync(userPrincipalName: string, odataQuery?: string): Promise; + mailFoldersForUser(userPrincipalName: string, callback: PromiseCallback, odataQuery?: string): void; + eventForUserAsync(userPrincipalName: string, eventId: string, odataQuery?: string): Promise; + eventForUser(userPrincipalName: string, eventId: string, callback: PromiseCallback, odataQuery?: string): void; + eventsForUserAsync(userPrincipalName: string, endpoint: EventsEndpoint, odataQuery?: string): Promise; + eventsForUser(userPrincipalName: string, endpoint: EventsEndpoint, callback: (messages: Events, error: Error) => void, odataQuery?: string): void; + memberOfForUserAsync(userPrincipalName: string, odataQuery?: string): Promise; + memberOfForUser(userPrincipalName: string, callback: PromiseCallback, odataQuery?: string): void; + managerForUserAsync(userPrincipalName: string, odataQuery?: string): Promise; + managerForUser(userPrincipalName: string, callback: PromiseCallback, odataQuery?: string): void; + directReportsForUserAsync(userPrincipalName: string, odataQuery?: string): Promise; + directReportsForUser(userPrincipalName: string, callback: PromiseCallback, odataQuery?: string): void; + profilePhotoForUserAsync(userPrincipalName: string, odataQuery?: string): Promise; + profilePhotoForUser(userPrincipalName: string, callback: PromiseCallback, odataQuery?: string): void; + profilePhotoValueForUserAsync(userPrincipalName: string, odataQuery?: string): Promise; + profilePhotoValueForUser(userPrincipalName: string, callback: PromiseCallback, odataQuery?: string): void; + messageAttachmentsForUserAsync(userPrincipalName: string, messageId: string, odataQuery?: string): Promise; + messageAttachmentsForUser(userPrincipalName: string, messageId: string, callback: PromiseCallback, odataQuery?: string): void; + messageAttachmentForUserAsync(userPrincipalName: string, messageId: string, attachmentId: string, odataQuery?: string): Promise; + messageAttachmentForUser(userPrincipalName: string, messageId: string, attachmentId: string, callback: PromiseCallback, odataQuery?: string): void; + getAsync(url: string): Promise; + get(url: string, callback: PromiseCallback, responseType?: string, scopes?: string[]): void; + private generateError(xhr); + private getUsers(urlString, callback, scopes?, basicProfileOnly?); + private getUser(urlString, callback, scopes?); + private addAccessTokenAndSend(xhr, callback, scopes?); + private getMessage(urlString, messageId, callback, scopes?); + private getMessages(urlString, callback, scopes?); + private getEvent(urlString, EventId, callback, scopes?); + private getEvents(urlString, endpoint, callback, scopes?); + private getGroups(urlString, callback, scopes?); + private getGroup(urlString, callback, scopes?); + private getPhoto(urlString, callback, scopes?); + private getPhotoValue(urlString, callback, scopes?); + private getMailFolders(urlString, callback, scopes?); + private getMessageAttachments(urlString, callback, scopes?); + private getMessageAttachment(urlString, callback, scopes?); + private buildUrl(root, path, odataQuery?); + private buildMeUrl(path?, odataQuery?); + private buildUsersUrl(path?, odataQuery?); + private buildGroupsUrl(path?, odataQuery?); + } + +} +declare module 'kurve/src/kurve' { + import { Graph } from 'kurve/src/graph'; + import { Identity } from 'kurve/src/identity'; var _default: { + Graph: typeof Graph; + Identity: typeof Identity; + }; + export = _default; + +} diff --git a/dist/kurve.js b/dist/kurve.js new file mode 100644 index 00000000..884f200d --- /dev/null +++ b/dist/kurve.js @@ -0,0 +1,1704 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["Kurve"] = factory(); + else + root["Kurve"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var graph_1 = __webpack_require__(1); + var identity_1 = __webpack_require__(3); + module.exports = { + Graph: graph_1.Graph, + Identity: identity_1.Identity + }; + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var promises_1 = __webpack_require__(2); + var identity_1 = __webpack_require__(3); + var Scopes; + (function (Scopes) { + var Util = (function () { + function Util() { + } + Util.rootUrl = "https://graph.microsoft.com/"; + return Util; + }()); + var General = (function () { + function General() { + } + General.OpenId = "openid"; + General.OfflineAccess = "offline_access"; + return General; + }()); + Scopes.General = General; + var User = (function () { + function User() { + } + User.Read = Util.rootUrl + "User.Read"; + User.ReadWrite = Util.rootUrl + "User.ReadWrite"; + User.ReadBasicAll = Util.rootUrl + "User.ReadBasic.All"; + User.ReadAll = Util.rootUrl + "User.Read.All"; + User.ReadWriteAll = Util.rootUrl + "User.ReadWrite.All"; + return User; + }()); + Scopes.User = User; + var Contacts = (function () { + function Contacts() { + } + Contacts.Read = Util.rootUrl + "Contacts.Read"; + Contacts.ReadWrite = Util.rootUrl + "Contacts.ReadWrite"; + return Contacts; + }()); + Scopes.Contacts = Contacts; + var Directory = (function () { + function Directory() { + } + Directory.ReadAll = Util.rootUrl + "Directory.Read.All"; + Directory.ReadWriteAll = Util.rootUrl + "Directory.ReadWrite.All"; + Directory.AccessAsUserAll = Util.rootUrl + "Directory.AccessAsUser.All"; + return Directory; + }()); + Scopes.Directory = Directory; + var Group = (function () { + function Group() { + } + Group.ReadAll = Util.rootUrl + "Group.Read.All"; + Group.ReadWriteAll = Util.rootUrl + "Group.ReadWrite.All"; + Group.AccessAsUserAll = Util.rootUrl + "Directory.AccessAsUser.All"; + return Group; + }()); + Scopes.Group = Group; + var Mail = (function () { + function Mail() { + } + Mail.Read = Util.rootUrl + "Mail.Read"; + Mail.ReadWrite = Util.rootUrl + "Mail.ReadWrite"; + Mail.Send = Util.rootUrl + "Mail.Send"; + return Mail; + }()); + Scopes.Mail = Mail; + var Calendars = (function () { + function Calendars() { + } + Calendars.Read = Util.rootUrl + "Calendars.Read"; + Calendars.ReadWrite = Util.rootUrl + "Calendars.ReadWrite"; + return Calendars; + }()); + Scopes.Calendars = Calendars; + var Files = (function () { + function Files() { + } + Files.Read = Util.rootUrl + "Files.Read"; + Files.ReadAll = Util.rootUrl + "Files.Read.All"; + Files.ReadWrite = Util.rootUrl + "Files.ReadWrite"; + Files.ReadWriteAppFolder = Util.rootUrl + "Files.ReadWrite.AppFolder"; + Files.ReadWriteSelected = Util.rootUrl + "Files.ReadWrite.Selected"; + return Files; + }()); + Scopes.Files = Files; + var Tasks = (function () { + function Tasks() { + } + Tasks.ReadWrite = Util.rootUrl + "Tasks.ReadWrite"; + return Tasks; + }()); + Scopes.Tasks = Tasks; + var People = (function () { + function People() { + } + People.Read = Util.rootUrl + "People.Read"; + People.ReadWrite = Util.rootUrl + "People.ReadWrite"; + return People; + }()); + Scopes.People = People; + var Notes = (function () { + function Notes() { + } + Notes.Create = Util.rootUrl + "Notes.Create"; + Notes.ReadWriteCreatedByApp = Util.rootUrl + "Notes.ReadWrite.CreatedByApp"; + Notes.Read = Util.rootUrl + "Notes.Read"; + Notes.ReadAll = Util.rootUrl + "Notes.Read.All"; + Notes.ReadWriteAll = Util.rootUrl + "Notes.ReadWrite.All"; + return Notes; + }()); + Scopes.Notes = Notes; + })(Scopes = exports.Scopes || (exports.Scopes = {})); + var DataModelWrapper = (function () { + function DataModelWrapper(graph, _data) { + this.graph = graph; + this._data = _data; + } + Object.defineProperty(DataModelWrapper.prototype, "data", { + get: function () { return this._data; }, + enumerable: true, + configurable: true + }); + return DataModelWrapper; + }()); + exports.DataModelWrapper = DataModelWrapper; + var DataModelListWrapper = (function (_super) { + __extends(DataModelListWrapper, _super); + function DataModelListWrapper() { + _super.apply(this, arguments); + } + return DataModelListWrapper; + }(DataModelWrapper)); + exports.DataModelListWrapper = DataModelListWrapper; + var ProfilePhotoDataModel = (function () { + function ProfilePhotoDataModel() { + } + return ProfilePhotoDataModel; + }()); + exports.ProfilePhotoDataModel = ProfilePhotoDataModel; + var ProfilePhoto = (function (_super) { + __extends(ProfilePhoto, _super); + function ProfilePhoto() { + _super.apply(this, arguments); + } + return ProfilePhoto; + }(DataModelWrapper)); + exports.ProfilePhoto = ProfilePhoto; + var UserDataModel = (function () { + function UserDataModel() { + } + return UserDataModel; + }()); + exports.UserDataModel = UserDataModel; + (function (EventsEndpoint) { + EventsEndpoint[EventsEndpoint["events"] = 0] = "events"; + EventsEndpoint[EventsEndpoint["calendarView"] = 1] = "calendarView"; + })(exports.EventsEndpoint || (exports.EventsEndpoint = {})); + var EventsEndpoint = exports.EventsEndpoint; + var User = (function (_super) { + __extends(User, _super); + function User() { + _super.apply(this, arguments); + } + User.prototype.events = function (callback, odataQuery) { + this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.events, callback, odataQuery); + }; + User.prototype.eventsAsync = function (odataQuery) { + return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.events, odataQuery); + }; + User.prototype.memberOf = function (callback, Error, odataQuery) { + this.graph.memberOfForUser(this._data.userPrincipalName, callback, odataQuery); + }; + User.prototype.memberOfAsync = function (odataQuery) { + return this.graph.memberOfForUserAsync(this._data.userPrincipalName, odataQuery); + }; + User.prototype.messages = function (callback, odataQuery) { + this.graph.messagesForUser(this._data.userPrincipalName, callback, odataQuery); + }; + User.prototype.messagesAsync = function (odataQuery) { + return this.graph.messagesForUserAsync(this._data.userPrincipalName, odataQuery); + }; + User.prototype.manager = function (callback, odataQuery) { + this.graph.managerForUser(this._data.userPrincipalName, callback, odataQuery); + }; + User.prototype.managerAsync = function (odataQuery) { + return this.graph.managerForUserAsync(this._data.userPrincipalName, odataQuery); + }; + User.prototype.profilePhoto = function (callback, odataQuery) { + this.graph.profilePhotoForUser(this._data.userPrincipalName, callback, odataQuery); + }; + User.prototype.profilePhotoAsync = function (odataQuery) { + return this.graph.profilePhotoForUserAsync(this._data.userPrincipalName, odataQuery); + }; + User.prototype.profilePhotoValue = function (callback, odataQuery) { + this.graph.profilePhotoValueForUser(this._data.userPrincipalName, callback, odataQuery); + }; + User.prototype.profilePhotoValueAsync = function (odataQuery) { + return this.graph.profilePhotoValueForUserAsync(this._data.userPrincipalName, odataQuery); + }; + User.prototype.calendarView = function (callback, odataQuery) { + this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.calendarView, callback, odataQuery); + }; + User.prototype.calendarViewAsync = function (odataQuery) { + return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.calendarView, odataQuery); + }; + User.prototype.mailFolders = function (callback, odataQuery) { + this.graph.mailFoldersForUser(this._data.userPrincipalName, callback, odataQuery); + }; + User.prototype.mailFoldersAsync = function (odataQuery) { + return this.graph.mailFoldersForUserAsync(this._data.userPrincipalName, odataQuery); + }; + User.prototype.message = function (messageId, callback, odataQuery) { + this.graph.messageForUser(this._data.userPrincipalName, messageId, callback, odataQuery); + }; + User.prototype.messageAsync = function (messageId, odataQuery) { + return this.graph.messageForUserAsync(this._data.userPrincipalName, messageId, odataQuery); + }; + User.prototype.event = function (eventId, callback, odataQuery) { + this.graph.eventForUser(this._data.userPrincipalName, eventId, callback, odataQuery); + }; + User.prototype.eventAsync = function (eventId, odataQuery) { + return this.graph.eventForUserAsync(this._data.userPrincipalName, eventId, odataQuery); + }; + User.prototype.messageAttachment = function (messageId, attachmentId, callback, odataQuery) { + this.graph.messageAttachmentForUser(this._data.userPrincipalName, messageId, attachmentId, callback, odataQuery); + }; + User.prototype.messageAttachmentAsync = function (messageId, attachmentId, odataQuery) { + return this.graph.messageAttachmentForUserAsync(this._data.userPrincipalName, messageId, attachmentId, odataQuery); + }; + return User; + }(DataModelWrapper)); + exports.User = User; + var Users = (function (_super) { + __extends(Users, _super); + function Users() { + _super.apply(this, arguments); + } + return Users; + }(DataModelListWrapper)); + exports.Users = Users; + var MessageDataModel = (function () { + function MessageDataModel() { + } + return MessageDataModel; + }()); + exports.MessageDataModel = MessageDataModel; + var Message = (function (_super) { + __extends(Message, _super); + function Message() { + _super.apply(this, arguments); + } + return Message; + }(DataModelWrapper)); + exports.Message = Message; + var Messages = (function (_super) { + __extends(Messages, _super); + function Messages() { + _super.apply(this, arguments); + } + return Messages; + }(DataModelListWrapper)); + exports.Messages = Messages; + var EventDataModel = (function () { + function EventDataModel() { + } + return EventDataModel; + }()); + exports.EventDataModel = EventDataModel; + var Event = (function (_super) { + __extends(Event, _super); + function Event() { + _super.apply(this, arguments); + } + return Event; + }(DataModelWrapper)); + exports.Event = Event; + var Events = (function (_super) { + __extends(Events, _super); + function Events(graph, endpoint, _data) { + _super.call(this, graph, _data); + this.graph = graph; + this.endpoint = endpoint; + this._data = _data; + } + return Events; + }(DataModelListWrapper)); + exports.Events = Events; + var Contact = (function () { + function Contact() { + } + return Contact; + }()); + exports.Contact = Contact; + var GroupDataModel = (function () { + function GroupDataModel() { + } + return GroupDataModel; + }()); + exports.GroupDataModel = GroupDataModel; + var Group = (function (_super) { + __extends(Group, _super); + function Group() { + _super.apply(this, arguments); + } + return Group; + }(DataModelWrapper)); + exports.Group = Group; + var Groups = (function (_super) { + __extends(Groups, _super); + function Groups() { + _super.apply(this, arguments); + } + return Groups; + }(DataModelListWrapper)); + exports.Groups = Groups; + var MailFolderDataModel = (function () { + function MailFolderDataModel() { + } + return MailFolderDataModel; + }()); + exports.MailFolderDataModel = MailFolderDataModel; + var MailFolder = (function (_super) { + __extends(MailFolder, _super); + function MailFolder() { + _super.apply(this, arguments); + } + return MailFolder; + }(DataModelWrapper)); + exports.MailFolder = MailFolder; + var MailFolders = (function (_super) { + __extends(MailFolders, _super); + function MailFolders() { + _super.apply(this, arguments); + } + return MailFolders; + }(DataModelListWrapper)); + exports.MailFolders = MailFolders; + (function (AttachmentType) { + AttachmentType[AttachmentType["fileAttachment"] = 0] = "fileAttachment"; + AttachmentType[AttachmentType["itemAttachment"] = 1] = "itemAttachment"; + AttachmentType[AttachmentType["referenceAttachment"] = 2] = "referenceAttachment"; + })(exports.AttachmentType || (exports.AttachmentType = {})); + var AttachmentType = exports.AttachmentType; + var AttachmentDataModel = (function () { + function AttachmentDataModel() { + } + return AttachmentDataModel; + }()); + exports.AttachmentDataModel = AttachmentDataModel; + var Attachment = (function (_super) { + __extends(Attachment, _super); + function Attachment() { + _super.apply(this, arguments); + } + Attachment.prototype.getType = function () { + switch (this._data['@odata.type']) { + case "#microsoft.graph.fileAttachment": + return AttachmentType.fileAttachment; + case "#microsoft.graph.itemAttachment": + return AttachmentType.itemAttachment; + case "#microsoft.graph.referenceAttachment": + return AttachmentType.referenceAttachment; + } + }; + return Attachment; + }(DataModelWrapper)); + exports.Attachment = Attachment; + var Attachments = (function (_super) { + __extends(Attachments, _super); + function Attachments() { + _super.apply(this, arguments); + } + return Attachments; + }(DataModelListWrapper)); + exports.Attachments = Attachments; + var Graph = (function () { + function Graph(identityInfo) { + this.req = null; + this.accessToken = null; + this.KurveIdentity = null; + this.defaultResourceID = "https://graph.microsoft.com"; + this.baseUrl = "https://graph.microsoft.com/v1.0/"; + if (identityInfo.defaultAccessToken) { + this.accessToken = identityInfo.defaultAccessToken; + } + else { + this.KurveIdentity = identityInfo.identity; + } + } + Graph.prototype.scopesForV2 = function (scopes) { + if (!this.KurveIdentity) + return null; + if (this.KurveIdentity.getCurrentOauthVersion() === identity_1.OAuthVersion.v1) + return null; + else + return scopes; + }; + Graph.prototype.meAsync = function (odataQuery) { + var d = new promises_1.Deferred(); + this.me(function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery); + return d.promise; + }; + Graph.prototype.me = function (callback, odataQuery) { + var scopes = [Scopes.User.Read]; + var urlString = this.buildMeUrl("", odataQuery); + this.getUser(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.userAsync = function (userId, odataQuery, basicProfileOnly) { + if (basicProfileOnly === void 0) { basicProfileOnly = true; } + var d = new promises_1.Deferred(); + this.user(userId, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery, basicProfileOnly); + return d.promise; + }; + Graph.prototype.user = function (userId, callback, odataQuery, basicProfileOnly) { + if (basicProfileOnly === void 0) { basicProfileOnly = true; } + var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll]; + var urlString = this.buildUsersUrl(userId, odataQuery); + this.getUser(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.usersAsync = function (odataQuery, basicProfileOnly) { + if (basicProfileOnly === void 0) { basicProfileOnly = true; } + var d = new promises_1.Deferred(); + this.users(function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery, basicProfileOnly); + return d.promise; + }; + Graph.prototype.users = function (callback, odataQuery, basicProfileOnly) { + if (basicProfileOnly === void 0) { basicProfileOnly = true; } + var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll]; + var urlString = this.buildUsersUrl("", odataQuery); + this.getUsers(urlString, callback, this.scopesForV2(scopes), basicProfileOnly); + }; + Graph.prototype.groupAsync = function (groupId, odataQuery) { + var d = new promises_1.Deferred(); + this.group(groupId, function (group, error) { return error ? d.reject(error) : d.resolve(group); }, odataQuery); + return d.promise; + }; + Graph.prototype.group = function (groupId, callback, odataQuery) { + var scopes = [Scopes.Group.ReadAll]; + var urlString = this.buildGroupsUrl(groupId, odataQuery); + this.getGroup(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.groupsAsync = function (odataQuery) { + var d = new promises_1.Deferred(); + this.groups(function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery); + return d.promise; + }; + Graph.prototype.groups = function (callback, odataQuery) { + var scopes = [Scopes.Group.ReadAll]; + var urlString = this.buildGroupsUrl("", odataQuery); + this.getGroups(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.messageForUserAsync = function (userPrincipalName, messageId, odataQuery) { + var d = new promises_1.Deferred(); + this.messageForUser(userPrincipalName, messageId, function (message, error) { return error ? d.reject(error) : d.resolve(message); }, odataQuery); + return d.promise; + }; + Graph.prototype.messageForUser = function (userPrincipalName, messageId, callback, odataQuery) { + var scopes = [Scopes.Mail.Read]; + var urlString = this.buildUsersUrl(userPrincipalName + "/messages/" + messageId, odataQuery); + this.getMessage(urlString, messageId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes)); + }; + Graph.prototype.messagesForUserAsync = function (userPrincipalName, odataQuery) { + var d = new promises_1.Deferred(); + this.messagesForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery); + return d.promise; + }; + Graph.prototype.messagesForUser = function (userPrincipalName, callback, odataQuery) { + var scopes = [Scopes.Mail.Read]; + var urlString = this.buildUsersUrl(userPrincipalName + "/messages", odataQuery); + this.getMessages(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes)); + }; + Graph.prototype.mailFoldersForUserAsync = function (userPrincipalName, odataQuery) { + var d = new promises_1.Deferred(); + this.mailFoldersForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery); + return d.promise; + }; + Graph.prototype.mailFoldersForUser = function (userPrincipalName, callback, odataQuery) { + var scopes = [Scopes.Mail.Read]; + var urlString = this.buildUsersUrl(userPrincipalName + "/mailFolders", odataQuery); + this.getMailFolders(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes)); + }; + Graph.prototype.eventForUserAsync = function (userPrincipalName, eventId, odataQuery) { + var d = new promises_1.Deferred(); + this.eventForUser(userPrincipalName, eventId, function (event, error) { return error ? d.reject(error) : d.resolve(event); }, odataQuery); + return d.promise; + }; + Graph.prototype.eventForUser = function (userPrincipalName, eventId, callback, odataQuery) { + var scopes = [Scopes.Calendars.Read]; + var urlString = this.buildUsersUrl(userPrincipalName + "/events/" + eventId, odataQuery); + this.getEvent(urlString, eventId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes)); + }; + Graph.prototype.eventsForUserAsync = function (userPrincipalName, endpoint, odataQuery) { + var d = new promises_1.Deferred(); + this.eventsForUser(userPrincipalName, endpoint, function (events, error) { return error ? d.reject(error) : d.resolve(events); }, odataQuery); + return d.promise; + }; + Graph.prototype.eventsForUser = function (userPrincipalName, endpoint, callback, odataQuery) { + var scopes = [Scopes.Calendars.Read]; + var urlString = this.buildUsersUrl(userPrincipalName + "/" + EventsEndpoint[endpoint], odataQuery); + this.getEvents(urlString, endpoint, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes)); + }; + Graph.prototype.memberOfForUserAsync = function (userPrincipalName, odataQuery) { + var d = new promises_1.Deferred(); + this.memberOfForUser(userPrincipalName, function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery); + return d.promise; + }; + Graph.prototype.memberOfForUser = function (userPrincipalName, callback, odataQuery) { + var scopes = [Scopes.Group.ReadAll]; + var urlString = this.buildUsersUrl(userPrincipalName + "/memberOf", odataQuery); + this.getGroups(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.managerForUserAsync = function (userPrincipalName, odataQuery) { + var d = new promises_1.Deferred(); + this.managerForUser(userPrincipalName, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery); + return d.promise; + }; + Graph.prototype.managerForUser = function (userPrincipalName, callback, odataQuery) { + var scopes = [Scopes.Directory.ReadAll]; + var urlString = this.buildUsersUrl(userPrincipalName + "/manager", odataQuery); + this.getUser(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.directReportsForUserAsync = function (userPrincipalName, odataQuery) { + var d = new promises_1.Deferred(); + this.directReportsForUser(userPrincipalName, function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery); + return d.promise; + }; + Graph.prototype.directReportsForUser = function (userPrincipalName, callback, odataQuery) { + var scopes = [Scopes.Directory.ReadAll]; + var urlString = this.buildUsersUrl(userPrincipalName + "/directReports", odataQuery); + this.getUsers(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.profilePhotoForUserAsync = function (userPrincipalName, odataQuery) { + var d = new promises_1.Deferred(); + this.profilePhotoForUser(userPrincipalName, function (profilePhoto, error) { return error ? d.reject(error) : d.resolve(profilePhoto); }, odataQuery); + return d.promise; + }; + Graph.prototype.profilePhotoForUser = function (userPrincipalName, callback, odataQuery) { + var scopes = [Scopes.User.ReadBasicAll]; + var urlString = this.buildUsersUrl(userPrincipalName + "/photo", odataQuery); + this.getPhoto(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.profilePhotoValueForUserAsync = function (userPrincipalName, odataQuery) { + var d = new promises_1.Deferred(); + this.profilePhotoValueForUser(userPrincipalName, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery); + return d.promise; + }; + Graph.prototype.profilePhotoValueForUser = function (userPrincipalName, callback, odataQuery) { + var scopes = [Scopes.User.ReadBasicAll]; + var urlString = this.buildUsersUrl(userPrincipalName + "/photo/$value", odataQuery); + this.getPhotoValue(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.messageAttachmentsForUserAsync = function (userPrincipalName, messageId, odataQuery) { + var d = new promises_1.Deferred(); + this.messageAttachmentsForUser(userPrincipalName, messageId, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery); + return d.promise; + }; + Graph.prototype.messageAttachmentsForUser = function (userPrincipalName, messageId, callback, odataQuery) { + var scopes = [Scopes.Mail.Read]; + var urlString = this.buildUsersUrl(userPrincipalName + "/messages/" + messageId + "/attachments", odataQuery); + this.getMessageAttachments(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.messageAttachmentForUserAsync = function (userPrincipalName, messageId, attachmentId, odataQuery) { + var d = new promises_1.Deferred(); + this.messageAttachmentForUser(userPrincipalName, messageId, attachmentId, function (attachment, error) { return error ? d.reject(error) : d.resolve(attachment); }, odataQuery); + return d.promise; + }; + Graph.prototype.messageAttachmentForUser = function (userPrincipalName, messageId, attachmentId, callback, odataQuery) { + var scopes = [Scopes.Mail.Read]; + var urlString = this.buildUsersUrl(userPrincipalName + "/messages/" + messageId + "/attachments/" + attachmentId, odataQuery); + this.getMessageAttachment(urlString, callback, this.scopesForV2(scopes)); + }; + Graph.prototype.getAsync = function (url) { + var d = new promises_1.Deferred(); + this.get(url, function (response, error) { return error ? d.reject(error) : d.resolve(response); }); + return d.promise; + }; + Graph.prototype.get = function (url, callback, responseType, scopes) { + var _this = this; + var xhr = new XMLHttpRequest(); + if (responseType) + xhr.responseType = responseType; + xhr.onreadystatechange = function () { + if (xhr.readyState === 4) + if (xhr.status === 200) + callback(responseType ? xhr.response : xhr.responseText, null); + else + callback(null, _this.generateError(xhr)); + }; + xhr.open("GET", url); + this.addAccessTokenAndSend(xhr, function (addTokenError) { + if (addTokenError) { + callback(null, addTokenError); + } + }, scopes); + }; + Graph.prototype.generateError = function (xhr) { + var response = new identity_1.Error(); + response.status = xhr.status; + response.statusText = xhr.statusText; + if (xhr.responseType === '' || xhr.responseType === 'text') + response.text = xhr.responseText; + else + response.other = xhr.response; + return response; + }; + Graph.prototype.getUsers = function (urlString, callback, scopes, basicProfileOnly) { + var _this = this; + if (basicProfileOnly === void 0) { basicProfileOnly = true; } + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var usersODATA = JSON.parse(result); + if (usersODATA.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = usersODATA.error; + callback(null, errorODATA); + return; + } + var resultsArray = (usersODATA.value ? usersODATA.value : [usersODATA]); + var users = new Users(_this, resultsArray.map(function (o) { return new User(_this, o); })); + var nextLink = usersODATA['@odata.nextLink']; + if (nextLink) { + users.nextLink = function (callback) { + var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll]; + var d = new promises_1.Deferred(); + _this.getUsers(nextLink, function (result, error) { + if (callback) + callback(result, error); + else + error ? d.reject(error) : d.resolve(result); + }, _this.scopesForV2(scopes), basicProfileOnly); + return d.promise; + }; + } + callback(users, null); + }, null, scopes); + }; + Graph.prototype.getUser = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var userODATA = JSON.parse(result); + if (userODATA.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = userODATA.error; + callback(null, errorODATA); + return; + } + var user = new User(_this, userODATA); + callback(user, null); + }, null, scopes); + }; + Graph.prototype.addAccessTokenAndSend = function (xhr, callback, scopes) { + if (this.accessToken) { + xhr.setRequestHeader('Authorization', 'Bearer ' + this.accessToken); + xhr.send(); + } + else { + if (scopes) { + this.KurveIdentity.getAccessTokenForScopes(scopes, false, (function (token, error) { + if (error) + callback(error); + else { + xhr.setRequestHeader('Authorization', 'Bearer ' + token); + xhr.send(); + callback(null); + } + })); + } + else { + this.KurveIdentity.getAccessToken(this.defaultResourceID, (function (token, error) { + if (error) + callback(error); + else { + xhr.setRequestHeader('Authorization', 'Bearer ' + token); + xhr.send(); + callback(null); + } + })); + } + } + }; + Graph.prototype.getMessage = function (urlString, messageId, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var ODATA = JSON.parse(result); + if (ODATA.error) { + var ODATAError = new identity_1.Error(); + ODATAError.other = ODATA.error; + callback(null, ODATAError); + return; + } + var message = new Message(_this, ODATA); + callback(message, null); + }, null, scopes); + }; + Graph.prototype.getMessages = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var messagesODATA = JSON.parse(result); + if (messagesODATA.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = messagesODATA.error; + callback(null, errorODATA); + return; + } + var resultsArray = (messagesODATA.value ? messagesODATA.value : [messagesODATA]); + var messages = new Messages(_this, resultsArray.map(function (o) { return new Message(_this, o); })); + var nextLink = messagesODATA['@odata.nextLink']; + if (nextLink) { + messages.nextLink = function (callback) { + var scopes = [Scopes.Mail.Read]; + var d = new promises_1.Deferred(); + _this.getMessages(nextLink, function (messages, error) { + if (callback) + callback(messages, error); + else + error ? d.reject(error) : d.resolve(messages); + }, _this.scopesForV2(scopes)); + return d.promise; + }; + } + callback(messages, null); + }, null, scopes); + }; + Graph.prototype.getEvent = function (urlString, EventId, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var ODATA = JSON.parse(result); + if (ODATA.error) { + var ODATAError = new identity_1.Error(); + ODATAError.other = ODATA.error; + callback(null, ODATAError); + return; + } + var event = new Event(_this, ODATA); + callback(event, null); + }, null, scopes); + }; + Graph.prototype.getEvents = function (urlString, endpoint, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var odata = JSON.parse(result); + if (odata.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = odata.error; + callback(null, errorODATA); + return; + } + var resultsArray = (odata.value ? odata.value : [odata]); + var events = new Events(_this, endpoint, resultsArray.map(function (o) { return new Event(_this, o); })); + var nextLink = odata['@odata.nextLink']; + if (nextLink) { + events.nextLink = function (callback) { + var scopes = [Scopes.Mail.Read]; + var d = new promises_1.Deferred(); + _this.getEvents(nextLink, endpoint, function (result, error) { + if (callback) + callback(result, error); + else + error ? d.reject(error) : d.resolve(result); + }, _this.scopesForV2(scopes)); + return d.promise; + }; + } + callback(events, null); + }, null, scopes); + }; + Graph.prototype.getGroups = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var groupsODATA = JSON.parse(result); + if (groupsODATA.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = groupsODATA.error; + callback(null, errorODATA); + return; + } + var resultsArray = (groupsODATA.value ? groupsODATA.value : [groupsODATA]); + var groups = new Groups(_this, resultsArray.map(function (o) { return new Group(_this, o); })); + var nextLink = groupsODATA['@odata.nextLink']; + if (nextLink) { + groups.nextLink = function (callback) { + var scopes = [Scopes.Group.ReadAll]; + var d = new promises_1.Deferred(); + _this.getGroups(nextLink, function (result, error) { + if (callback) + callback(result, error); + else + error ? d.reject(error) : d.resolve(result); + }, _this.scopesForV2(scopes)); + return d.promise; + }; + } + callback(groups, null); + }, null, scopes); + }; + Graph.prototype.getGroup = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var ODATA = JSON.parse(result); + if (ODATA.error) { + var ODATAError = new identity_1.Error(); + ODATAError.other = ODATA.error; + callback(null, ODATAError); + return; + } + var group = new Group(_this, ODATA); + callback(group, null); + }, null, scopes); + }; + Graph.prototype.getPhoto = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var ODATA = JSON.parse(result); + if (ODATA.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = ODATA.error; + callback(null, errorODATA); + return; + } + var photo = new ProfilePhoto(_this, ODATA); + callback(photo, null); + }, null, scopes); + }; + Graph.prototype.getPhotoValue = function (urlString, callback, scopes) { + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + callback(result, null); + }, "blob", scopes); + }; + Graph.prototype.getMailFolders = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var odata = JSON.parse(result); + if (odata.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = odata.error; + callback(null, errorODATA); + } + var resultsArray = (odata.value ? odata.value : [odata]); + var mailFolders = new MailFolders(_this, resultsArray.map(function (o) { return new MailFolder(_this, o); })); + var nextLink = odata['@odata.nextLink']; + if (nextLink) { + mailFolders.nextLink = function (callback) { + var scopes = [Scopes.User.ReadAll]; + var d = new promises_1.Deferred(); + _this.getMailFolders(nextLink, function (result, error) { + if (callback) + callback(result, error); + else + error ? d.reject(error) : d.resolve(result); + }, _this.scopesForV2(scopes)); + return d.promise; + }; + } + callback(mailFolders, null); + }, null, scopes); + }; + Graph.prototype.getMessageAttachments = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var attachmentsODATA = JSON.parse(result); + if (attachmentsODATA.error) { + var errorODATA = new identity_1.Error(); + errorODATA.other = attachmentsODATA.error; + callback(null, errorODATA); + return; + } + var resultsArray = (attachmentsODATA.value ? attachmentsODATA.value : [attachmentsODATA]); + var attachments = new Attachments(_this, resultsArray.map(function (o) { return new Attachment(_this, o); })); + var nextLink = attachmentsODATA['@odata.nextLink']; + if (nextLink) { + attachments.nextLink = function (callback) { + var scopes = [Scopes.Mail.Read]; + var d = new promises_1.Deferred(); + _this.getMessageAttachments(nextLink, function (attachments, error) { + if (callback) + callback(attachments, error); + else + error ? d.reject(error) : d.resolve(attachments); + }, _this.scopesForV2(scopes)); + return d.promise; + }; + } + callback(attachments, null); + }, null, scopes); + }; + Graph.prototype.getMessageAttachment = function (urlString, callback, scopes) { + var _this = this; + this.get(urlString, function (result, errorGet) { + if (errorGet) { + callback(null, errorGet); + return; + } + var ODATA = JSON.parse(result); + if (ODATA.error) { + var ODATAError = new identity_1.Error(); + ODATAError.other = ODATA.error; + callback(null, ODATAError); + return; + } + var attachment = new Attachment(_this, ODATA); + callback(attachment, null); + }, null, scopes); + }; + Graph.prototype.buildUrl = function (root, path, odataQuery) { + return this.baseUrl + root + path + (odataQuery ? "?" + odataQuery : ""); + }; + Graph.prototype.buildMeUrl = function (path, odataQuery) { + if (path === void 0) { path = ""; } + return this.buildUrl("me/", path, odataQuery); + }; + Graph.prototype.buildUsersUrl = function (path, odataQuery) { + if (path === void 0) { path = ""; } + return this.buildUrl("users/", path, odataQuery); + }; + Graph.prototype.buildGroupsUrl = function (path, odataQuery) { + if (path === void 0) { path = ""; } + return this.buildUrl("groups/", path, odataQuery); + }; + return Graph; + }()); + exports.Graph = Graph; + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + function DispatchDeferred(closure) { + setTimeout(closure, 0); + } + var PromiseState; + (function (PromiseState) { + PromiseState[PromiseState["Pending"] = 0] = "Pending"; + PromiseState[PromiseState["ResolutionInProgress"] = 1] = "ResolutionInProgress"; + PromiseState[PromiseState["Resolved"] = 2] = "Resolved"; + PromiseState[PromiseState["Rejected"] = 3] = "Rejected"; + })(PromiseState || (PromiseState = {})); + var Client = (function () { + function Client(_dispatcher, _successCB, _errorCB) { + this._dispatcher = _dispatcher; + this._successCB = _successCB; + this._errorCB = _errorCB; + this.result = new Deferred(_dispatcher); + } + Client.prototype.resolve = function (value, defer) { + var _this = this; + if (typeof (this._successCB) !== 'function') { + this.result.resolve(value); + return; + } + if (defer) { + this._dispatcher(function () { return _this._dispatchCallback(_this._successCB, value); }); + } + else { + this._dispatchCallback(this._successCB, value); + } + }; + Client.prototype.reject = function (error, defer) { + var _this = this; + if (typeof (this._errorCB) !== 'function') { + this.result.reject(error); + return; + } + if (defer) { + this._dispatcher(function () { return _this._dispatchCallback(_this._errorCB, error); }); + } + else { + this._dispatchCallback(this._errorCB, error); + } + }; + Client.prototype._dispatchCallback = function (callback, arg) { + var result, then, type; + try { + result = callback(arg); + this.result.resolve(result); + } + catch (err) { + this.result.reject(err); + return; + } + }; + return Client; + }()); + var Deferred = (function () { + function Deferred(dispatcher) { + this._stack = []; + this._state = PromiseState.Pending; + if (dispatcher) + this._dispatcher = dispatcher; + else + this._dispatcher = DispatchDeferred; + this.promise = new Promise(this); + } + Deferred.prototype.DispatchDeferred = function (closure) { + setTimeout(closure, 0); + }; + Deferred.prototype.then = function (successCB, errorCB) { + if (typeof (successCB) !== 'function' && typeof (errorCB) !== 'function') { + return this.promise; + } + var client = new Client(this._dispatcher, successCB, errorCB); + switch (this._state) { + case PromiseState.Pending: + case PromiseState.ResolutionInProgress: + this._stack.push(client); + break; + case PromiseState.Resolved: + client.resolve(this._value, true); + break; + case PromiseState.Rejected: + client.reject(this._error, true); + break; + } + return client.result.promise; + }; + Deferred.prototype.resolve = function (value) { + if (this._state !== PromiseState.Pending) { + return this; + } + return this._resolve(value); + }; + Deferred.prototype._resolve = function (value) { + var _this = this; + var type = typeof (value), then, pending = true; + try { + if (value !== null && + (type === 'object' || type === 'function') && + typeof (then = value.then) === 'function') { + if (value === this.promise) { + throw new TypeError('recursive resolution'); + } + this._state = PromiseState.ResolutionInProgress; + then.call(value, function (result) { + if (pending) { + pending = false; + _this._resolve(result); + } + }, function (error) { + if (pending) { + pending = false; + _this._reject(error); + } + }); + } + else { + this._state = PromiseState.ResolutionInProgress; + this._dispatcher(function () { + _this._state = PromiseState.Resolved; + _this._value = value; + var i, stackSize = _this._stack.length; + for (i = 0; i < stackSize; i++) { + _this._stack[i].resolve(value, false); + } + _this._stack.splice(0, stackSize); + }); + } + } + catch (err) { + if (pending) { + this._reject(err); + } + } + return this; + }; + Deferred.prototype.reject = function (error) { + if (this._state !== PromiseState.Pending) { + return this; + } + return this._reject(error); + }; + Deferred.prototype._reject = function (error) { + var _this = this; + this._state = PromiseState.ResolutionInProgress; + this._dispatcher(function () { + _this._state = PromiseState.Rejected; + _this._error = error; + var stackSize = _this._stack.length, i = 0; + for (i = 0; i < stackSize; i++) { + _this._stack[i].reject(error, false); + } + _this._stack.splice(0, stackSize); + }); + return this; + }; + return Deferred; + }()); + exports.Deferred = Deferred; + var Promise = (function () { + function Promise(_deferred) { + this._deferred = _deferred; + } + Promise.prototype.then = function (successCallback, errorCallback) { + return this._deferred.then(successCallback, errorCallback); + }; + Promise.prototype.fail = function (errorCallback) { + return this._deferred.then(undefined, errorCallback); + }; + return Promise; + }()); + exports.Promise = Promise; + + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var promises_1 = __webpack_require__(2); + (function (OAuthVersion) { + OAuthVersion[OAuthVersion["v1"] = 1] = "v1"; + OAuthVersion[OAuthVersion["v2"] = 2] = "v2"; + })(exports.OAuthVersion || (exports.OAuthVersion = {})); + var OAuthVersion = exports.OAuthVersion; + var Error = (function () { + function Error() { + } + return Error; + }()); + exports.Error = Error; + var CachedToken = (function () { + function CachedToken(id, scopes, resource, token, expiry) { + this.id = id; + this.scopes = scopes; + this.resource = resource; + this.token = token; + this.expiry = expiry; + } + ; + Object.defineProperty(CachedToken.prototype, "isExpired", { + get: function () { + return this.expiry <= new Date(new Date().getTime() + 60000); + }, + enumerable: true, + configurable: true + }); + CachedToken.prototype.hasScopes = function (requiredScopes) { + var _this = this; + if (!this.scopes) { + return false; + } + return requiredScopes.every(function (requiredScope) { + return _this.scopes.some(function (actualScope) { return requiredScope === actualScope; }); + }); + }; + return CachedToken; + }()); + var TokenCache = (function () { + function TokenCache(tokenStorage) { + var _this = this; + this.tokenStorage = tokenStorage; + this.cachedTokens = {}; + if (tokenStorage) { + tokenStorage.getAll().forEach(function (_a) { + var id = _a.id, scopes = _a.scopes, resource = _a.resource, token = _a.token, expiry = _a.expiry; + var cachedToken = new CachedToken(id, scopes, resource, token, new Date(expiry)); + if (cachedToken.isExpired) { + _this.tokenStorage.remove(cachedToken.id); + } + else { + _this.cachedTokens[cachedToken.id] = cachedToken; + } + }); + } + } + TokenCache.prototype.add = function (token) { + this.cachedTokens[token.id] = token; + this.tokenStorage && this.tokenStorage.add(token.id, token); + }; + TokenCache.prototype.getForResource = function (resource) { + var cachedToken = this.cachedTokens[resource]; + if (cachedToken && cachedToken.isExpired) { + this.remove(resource); + return null; + } + return cachedToken; + }; + TokenCache.prototype.getForScopes = function (scopes) { + for (var key in this.cachedTokens) { + var cachedToken = this.cachedTokens[key]; + if (cachedToken.hasScopes(scopes)) { + if (cachedToken.isExpired) { + this.remove(key); + } + else { + return cachedToken; + } + } + } + return null; + }; + TokenCache.prototype.clear = function () { + this.cachedTokens = {}; + this.tokenStorage && this.tokenStorage.clear(); + }; + TokenCache.prototype.remove = function (key) { + this.tokenStorage && this.tokenStorage.remove(key); + delete this.cachedTokens[key]; + }; + return TokenCache; + }()); + var IdToken = (function () { + function IdToken() { + } + return IdToken; + }()); + exports.IdToken = IdToken; + var Identity = (function () { + function Identity(identitySettings) { + var _this = this; + this.policy = ""; + this.clientId = identitySettings.clientId; + this.tokenProcessorUrl = identitySettings.tokenProcessingUri; + if (identitySettings.version) + this.version = identitySettings.version; + else + this.version = OAuthVersion.v1; + this.tokenCache = new TokenCache(identitySettings.tokenStorage); + window.addEventListener("message", function (event) { + if (event.data.type === "id_token") { + if (event.data.error) { + var e = new Error(); + e.text = event.data.error; + _this.loginCallback(e); + } + else { + if (_this.state !== event.data.state) { + var error = new Error(); + error.statusText = "Invalid state"; + _this.loginCallback(error); + } + else { + _this.decodeIdToken(event.data.token); + _this.loginCallback(null); + } + } + } + else if (event.data.type === "access_token") { + if (event.data.error) { + var e = new Error(); + e.text = event.data.error; + _this.getTokenCallback(null, e); + } + else { + var token = event.data.token; + var iframe = document.getElementById("tokenIFrame"); + iframe.parentNode.removeChild(iframe); + if (event.data.state !== _this.state) { + var error = new Error(); + error.statusText = "Invalid state"; + _this.getTokenCallback(null, error); + } + else { + _this.getTokenCallback(token, null); + } + } + } + }); + } + Identity.prototype.checkForIdentityRedirect = function () { + function token(s) { + var start = window.location.href.indexOf(s); + if (start < 0) + return null; + var end = window.location.href.indexOf("&", start + s.length); + return window.location.href.substring(start, ((end > 0) ? end : window.location.href.length)); + } + function parseQueryString(str) { + var queryString = str || window.location.search || ''; + var keyValPairs = []; + var params = {}; + queryString = queryString.replace(/.*?\?/, ""); + if (queryString.length) { + keyValPairs = queryString.split('&'); + for (var pairNum in keyValPairs) { + var key = keyValPairs[pairNum].split('=')[0]; + if (!key.length) + continue; + if (typeof params[key] === 'undefined') + params[key] = []; + params[key].push(keyValPairs[pairNum].split('=')[1]); + } + } + return params; + } + var params = parseQueryString(window.location.href); + var idToken = token("#id_token="); + var accessToken = token("#access_token"); + if (idToken) { + if (true) { + this.decodeIdToken(idToken); + this.loginCallback && this.loginCallback(null); + } + else { + var error = new Error(); + error.statusText = "Invalid state"; + this.loginCallback && this.loginCallback(error); + } + return true; + } + else if (accessToken) { + throw "Should not get here. This should be handled via the iframe approach."; + } + return false; + }; + Identity.prototype.decodeIdToken = function (idToken) { + var _this = this; + var decodedToken = this.base64Decode(idToken.substring(idToken.indexOf('.') + 1, idToken.lastIndexOf('.'))); + var decodedTokenJSON = JSON.parse(decodedToken); + var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000); + this.idToken = new IdToken(); + this.idToken.FullToken = decodedTokenJSON; + this.idToken.Token = idToken; + this.idToken.Expiry = expiryDate; + this.idToken.UPN = decodedTokenJSON.upn; + this.idToken.TenantId = decodedTokenJSON.tid; + this.idToken.FamilyName = decodedTokenJSON.family_name; + this.idToken.GivenName = decodedTokenJSON.given_name; + this.idToken.Name = decodedTokenJSON.name; + this.idToken.PreferredUsername = decodedTokenJSON.preferred_username; + var expiration = expiryDate.getTime() - new Date().getTime() - 300000; + this.refreshTimer = setTimeout((function () { + _this.renewIdToken(); + }), expiration); + }; + Identity.prototype.decodeAccessToken = function (accessToken, resource, scopes) { + var decodedToken = this.base64Decode(accessToken.substring(accessToken.indexOf('.') + 1, accessToken.lastIndexOf('.'))); + var decodedTokenJSON = JSON.parse(decodedToken); + var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000); + var key = resource || scopes.join(" "); + var token = new CachedToken(key, scopes, resource, accessToken, expiryDate); + this.tokenCache.add(token); + }; + Identity.prototype.getIdToken = function () { + return this.idToken; + }; + Identity.prototype.isLoggedIn = function () { + if (!this.idToken) + return false; + return (this.idToken.Expiry > new Date()); + }; + Identity.prototype.renewIdToken = function () { + clearTimeout(this.refreshTimer); + this.login(function () { }); + }; + Identity.prototype.getCurrentOauthVersion = function () { + return this.version; + }; + Identity.prototype.getAccessTokenAsync = function (resource) { + var d = new promises_1.Deferred(); + this.getAccessToken(resource, (function (token, error) { + if (error) { + d.reject(error); + } + else { + d.resolve(token); + } + })); + return d.promise; + }; + Identity.prototype.getAccessToken = function (resource, callback) { + var _this = this; + if (this.version !== OAuthVersion.v1) { + var e = new Error(); + e.statusText = "Currently this identity class is using v2 OAuth mode. You need to use getAccessTokenForScopes() method"; + callback(null, e); + return; + } + var token = this.tokenCache.getForResource(resource); + if (token) { + return callback(token.token, null); + } + this.getTokenCallback = (function (token, error) { + if (error) { + callback(null, error); + } + else { + _this.decodeAccessToken(token, resource); + callback(token, null); + } + }); + this.nonce = "token" + this.generateNonce(); + this.state = "token" + this.generateNonce(); + var iframe = document.createElement('iframe'); + iframe.style.display = "none"; + iframe.id = "tokenIFrame"; + iframe.src = this.tokenProcessorUrl + "?clientId=" + encodeURIComponent(this.clientId) + + "&resource=" + encodeURIComponent(resource) + + "&redirectUri=" + encodeURIComponent(this.tokenProcessorUrl) + + "&state=" + encodeURIComponent(this.state) + + "&version=" + encodeURIComponent(this.version.toString()) + + "&nonce=" + encodeURIComponent(this.nonce) + + "&op=token"; + document.body.appendChild(iframe); + }; + Identity.prototype.getAccessTokenForScopesAsync = function (scopes, promptForConsent) { + if (promptForConsent === void 0) { promptForConsent = false; } + var d = new promises_1.Deferred(); + this.getAccessTokenForScopes(scopes, promptForConsent, function (token, error) { + if (error) { + d.reject(error); + } + else { + d.resolve(token); + } + }); + return d.promise; + }; + Identity.prototype.getAccessTokenForScopes = function (scopes, promptForConsent, callback) { + var _this = this; + if (promptForConsent === void 0) { promptForConsent = false; } + if (this.version !== OAuthVersion.v2) { + var e = new Error(); + e.statusText = "Dynamic scopes require v2 mode. Currently this identity class is using v1"; + callback(null, e); + return; + } + var token = this.tokenCache.getForScopes(scopes); + if (token) { + return callback(token.token, null); + } + this.getTokenCallback = (function (token, error) { + if (error) { + if (promptForConsent || !error.text) { + callback(null, error); + } + else if (error.text.indexOf("AADSTS65001") >= 0) { + _this.getAccessTokenForScopes(scopes, true, _this.getTokenCallback); + } + else { + callback(null, error); + } + } + else { + _this.decodeAccessToken(token, null, scopes); + callback(token, null); + } + }); + this.nonce = "token" + this.generateNonce(); + this.state = "token" + this.generateNonce(); + if (!promptForConsent) { + var iframe = document.createElement('iframe'); + iframe.style.display = "none"; + iframe.id = "tokenIFrame"; + iframe.src = this.tokenProcessorUrl + "?clientId=" + encodeURIComponent(this.clientId) + + "&scopes=" + encodeURIComponent(scopes.join(" ")) + + "&redirectUri=" + encodeURIComponent(this.tokenProcessorUrl) + + "&version=" + encodeURIComponent(this.version.toString()) + + "&state=" + encodeURIComponent(this.state) + + "&nonce=" + encodeURIComponent(this.nonce) + + "&login_hint=" + encodeURIComponent(this.idToken.PreferredUsername) + + "&domain_hint=" + encodeURIComponent(this.idToken.TenantId === "9188040d-6c67-4c5b-b112-36a304b66dad" ? "consumers" : "organizations") + + "&op=token"; + document.body.appendChild(iframe); + } + else { + window.open(this.tokenProcessorUrl + "?clientId=" + encodeURIComponent(this.clientId) + + "&scopes=" + encodeURIComponent(scopes.join(" ")) + + "&redirectUri=" + encodeURIComponent(this.tokenProcessorUrl) + + "&version=" + encodeURIComponent(this.version.toString()) + + "&state=" + encodeURIComponent(this.state) + + "&nonce=" + encodeURIComponent(this.nonce) + + "&op=token", "_blank"); + } + }; + Identity.prototype.loginAsync = function (loginSettings) { + var d = new promises_1.Deferred(); + this.login(function (error) { + if (error) { + d.reject(error); + } + else { + d.resolve(null); + } + }, loginSettings); + return d.promise; + }; + Identity.prototype.login = function (callback, loginSettings) { + this.loginCallback = callback; + if (!loginSettings) + loginSettings = {}; + if (loginSettings.policy) + this.policy = loginSettings.policy; + if (loginSettings.scopes && this.version === OAuthVersion.v1) { + var e = new Error(); + e.text = "Scopes can only be used with OAuth v2."; + callback(e); + return; + } + if (loginSettings.policy && !loginSettings.tenant) { + var e = new Error(); + e.text = "In order to use policy (AAD B2C) a tenant must be specified as well."; + callback(e); + return; + } + this.state = "login" + this.generateNonce(); + this.nonce = "login" + this.generateNonce(); + var loginURL = this.tokenProcessorUrl + "?clientId=" + encodeURIComponent(this.clientId) + + "&redirectUri=" + encodeURIComponent(this.tokenProcessorUrl) + + "&state=" + encodeURIComponent(this.state) + + "&nonce=" + encodeURIComponent(this.nonce) + + "&version=" + encodeURIComponent(this.version.toString()) + + "&op=login" + + "&p=" + encodeURIComponent(this.policy); + if (loginSettings.tenant) { + loginURL += "&tenant=" + encodeURIComponent(loginSettings.tenant); + } + if (this.version === OAuthVersion.v2) { + if (!loginSettings.scopes) + loginSettings.scopes = []; + if (loginSettings.scopes.indexOf("profile") < 0) + loginSettings.scopes.push("profile"); + if (loginSettings.scopes.indexOf("openid") < 0) + loginSettings.scopes.push("openid"); + loginURL += "&scopes=" + encodeURIComponent(loginSettings.scopes.join(" ")); + } + window.open(loginURL, "_blank"); + }; + Identity.prototype.loginNoWindowAsync = function (toUrl) { + var d = new promises_1.Deferred(); + this.loginNoWindow(function (error) { + if (error) { + d.reject(error); + } + else { + d.resolve(null); + } + }, toUrl); + return d.promise; + }; + Identity.prototype.loginNoWindow = function (callback, toUrl) { + this.loginCallback = callback; + this.state = "clientId=" + this.clientId + "&" + "tokenProcessorUrl=" + this.tokenProcessorUrl; + this.nonce = this.generateNonce(); + var redirected = this.checkForIdentityRedirect(); + if (!redirected) { + var redirectUri = (toUrl) ? toUrl : window.location.href.split("#")[0]; + var url = "https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token" + + "&client_id=" + encodeURIComponent(this.clientId) + + "&redirect_uri=" + encodeURIComponent(redirectUri) + + "&state=" + encodeURIComponent(this.state) + + "&nonce=" + encodeURIComponent(this.nonce); + window.location.href = url; + } + }; + Identity.prototype.logOut = function () { + this.tokenCache.clear(); + var url = "https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=" + encodeURI(window.location.href); + window.location.href = url; + }; + Identity.prototype.base64Decode = function (encodedString) { + var e = {}, i, b = 0, c, x, l = 0, a, r = '', w = String.fromCharCode, L = encodedString.length; + var A = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + for (i = 0; i < 64; i++) { + e[A.charAt(i)] = i; + } + for (x = 0; x < L; x++) { + c = e[encodedString.charAt(x)]; + b = (b << 6) + c; + l += 6; + while (l >= 8) { + ((a = (b >>> (l -= 8)) & 0xff) || (x < (L - 2))) && (r += w(a)); + } + } + return r; + }; + Identity.prototype.generateNonce = function () { + var text = ""; + var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + for (var i = 0; i < 32; i++) { + text += chars.charAt(Math.floor(Math.random() * chars.length)); + } + return text; + }; + return Identity; + }()); + exports.Identity = Identity; + + +/***/ } +/******/ ]) +}); +; +//# sourceMappingURL=kurve.js.map \ No newline at end of file diff --git a/dist/kurve.js.map b/dist/kurve.js.map new file mode 100644 index 00000000..b8920c56 --- /dev/null +++ b/dist/kurve.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 9c41019a5f8fde3e37b8","webpack:///./src/kurve.ts","webpack:///./src/graph.ts","webpack:///./src/promises.ts","webpack:///./src/identity.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACNA;AACA;AACA;AACA,oBAAmB,sBAAsB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA,EAAC,iDAAiD;AAClD;AACA;AACA;AACA;AACA;AACA;AACA,2BAA0B,mBAAmB,EAAE;AAC/C;AACA;AACA,MAAK;AACL;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA,EAAC,wDAAwD;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,EAAC,wDAAwD;AACzD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAwC,kDAAkD,EAAE;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA0C,yBAAyB;AACnE;AACA,mDAAkD,kDAAkD,EAAE;AACtG;AACA;AACA;AACA,2CAA0C,yBAAyB;AACnE;AACA;AACA;AACA;AACA;AACA,2CAA0C,yBAAyB;AACnE;AACA,6CAA4C,mDAAmD,EAAE;AACjG;AACA;AACA;AACA,2CAA0C,yBAAyB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA,sDAAqD,mDAAmD,EAAE;AAC1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA8C,oDAAoD,EAAE;AACpG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sFAAqF,qDAAqD,EAAE;AAC5I;AACA;AACA;AACA;AACA;AACA,yEAAwE,gCAAgC,EAAE;AAC1G;AACA;AACA;AACA,6EAA4E,sDAAsD,EAAE;AACpI;AACA;AACA;AACA;AACA;AACA,+DAA8D,gCAAgC,EAAE;AAChG;AACA;AACA;AACA,gFAA+E,sDAAsD,EAAE;AACvI;AACA;AACA;AACA;AACA;AACA,kEAAiE,gCAAgC,EAAE;AACnG;AACA;AACA;AACA,gFAA+E,mDAAmD,EAAE;AACpI;AACA;AACA;AACA;AACA;AACA,qEAAoE,gCAAgC,EAAE;AACtG;AACA;AACA;AACA,mFAAkF,oDAAoD,EAAE;AACxI;AACA;AACA;AACA;AACA;AACA,uEAAsE,gCAAgC,EAAE;AACxG;AACA;AACA;AACA,2EAA0E,oDAAoD,EAAE;AAChI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wEAAuE,kDAAkD,EAAE;AAC3H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+EAA8E,mDAAmD,EAAE;AACnI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qFAAoF,0DAA0D,EAAE;AAChJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oFAAmF,oDAAoD,EAAE;AACzI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gGAA+F,oDAAoD,EAAE;AACrJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iHAAgH,wDAAwD,EAAE;AAC1K;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAkD,sDAAsD,EAAE;AAC1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA0C,yBAAyB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE,2BAA2B,EAAE;AACrG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+EAA8E,8BAA8B,EAAE;AAC9G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qFAAoF,4BAA4B,EAAE;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2EAA0E,4BAA4B,EAAE;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qFAAoF,iCAAiC,EAAE;AACvH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qFAAoF,iCAAiC,EAAE;AACvH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,+BAA8B,WAAW;AACzC;AACA;AACA;AACA,+BAA8B,WAAW;AACzC;AACA;AACA;AACA,+BAA8B,WAAW;AACzC;AACA;AACA;AACA,EAAC;AACD;;;;;;;AC38BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC,oCAAoC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA0C,yDAAyD,EAAE;AACrG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA0C,uDAAuD,EAAE;AACnG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAA+B,eAAe;AAC9C;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAuB,eAAe;AACtC;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;;;;;;;AC7KA;AACA;AACA;AACA;AACA;AACA,EAAC,oDAAoD;AACrD;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,8DAA6D,sCAAsC,EAAE;AACrG,UAAS;AACT;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAgC,EAAE;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA0C,0BAA0B;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA,2CAA0C,0BAA0B;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAkB;AAClB;AACA,oBAAmB,QAAQ;AAC3B;AACA;AACA,oBAAmB,OAAO;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAuB,QAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA,EAAC;AACD","file":"dist/kurve.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Kurve\"] = factory();\n\telse\n\t\troot[\"Kurve\"] = factory();\n})(this, function() {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 9c41019a5f8fde3e37b8\n **/","\"use strict\";\nvar graph_1 = require(\"./graph\");\nvar identity_1 = require(\"./identity\");\nmodule.exports = {\n Graph: graph_1.Graph,\n Identity: identity_1.Identity\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/kurve.ts\n ** module id = 0\n ** module chunks = 0\n **/","\"use strict\";\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar promises_1 = require(\"./promises\");\nvar identity_1 = require(\"./identity\");\nvar Scopes;\n(function (Scopes) {\n var Util = (function () {\n function Util() {\n }\n Util.rootUrl = \"https://graph.microsoft.com/\";\n return Util;\n }());\n var General = (function () {\n function General() {\n }\n General.OpenId = \"openid\";\n General.OfflineAccess = \"offline_access\";\n return General;\n }());\n Scopes.General = General;\n var User = (function () {\n function User() {\n }\n User.Read = Util.rootUrl + \"User.Read\";\n User.ReadWrite = Util.rootUrl + \"User.ReadWrite\";\n User.ReadBasicAll = Util.rootUrl + \"User.ReadBasic.All\";\n User.ReadAll = Util.rootUrl + \"User.Read.All\";\n User.ReadWriteAll = Util.rootUrl + \"User.ReadWrite.All\";\n return User;\n }());\n Scopes.User = User;\n var Contacts = (function () {\n function Contacts() {\n }\n Contacts.Read = Util.rootUrl + \"Contacts.Read\";\n Contacts.ReadWrite = Util.rootUrl + \"Contacts.ReadWrite\";\n return Contacts;\n }());\n Scopes.Contacts = Contacts;\n var Directory = (function () {\n function Directory() {\n }\n Directory.ReadAll = Util.rootUrl + \"Directory.Read.All\";\n Directory.ReadWriteAll = Util.rootUrl + \"Directory.ReadWrite.All\";\n Directory.AccessAsUserAll = Util.rootUrl + \"Directory.AccessAsUser.All\";\n return Directory;\n }());\n Scopes.Directory = Directory;\n var Group = (function () {\n function Group() {\n }\n Group.ReadAll = Util.rootUrl + \"Group.Read.All\";\n Group.ReadWriteAll = Util.rootUrl + \"Group.ReadWrite.All\";\n Group.AccessAsUserAll = Util.rootUrl + \"Directory.AccessAsUser.All\";\n return Group;\n }());\n Scopes.Group = Group;\n var Mail = (function () {\n function Mail() {\n }\n Mail.Read = Util.rootUrl + \"Mail.Read\";\n Mail.ReadWrite = Util.rootUrl + \"Mail.ReadWrite\";\n Mail.Send = Util.rootUrl + \"Mail.Send\";\n return Mail;\n }());\n Scopes.Mail = Mail;\n var Calendars = (function () {\n function Calendars() {\n }\n Calendars.Read = Util.rootUrl + \"Calendars.Read\";\n Calendars.ReadWrite = Util.rootUrl + \"Calendars.ReadWrite\";\n return Calendars;\n }());\n Scopes.Calendars = Calendars;\n var Files = (function () {\n function Files() {\n }\n Files.Read = Util.rootUrl + \"Files.Read\";\n Files.ReadAll = Util.rootUrl + \"Files.Read.All\";\n Files.ReadWrite = Util.rootUrl + \"Files.ReadWrite\";\n Files.ReadWriteAppFolder = Util.rootUrl + \"Files.ReadWrite.AppFolder\";\n Files.ReadWriteSelected = Util.rootUrl + \"Files.ReadWrite.Selected\";\n return Files;\n }());\n Scopes.Files = Files;\n var Tasks = (function () {\n function Tasks() {\n }\n Tasks.ReadWrite = Util.rootUrl + \"Tasks.ReadWrite\";\n return Tasks;\n }());\n Scopes.Tasks = Tasks;\n var People = (function () {\n function People() {\n }\n People.Read = Util.rootUrl + \"People.Read\";\n People.ReadWrite = Util.rootUrl + \"People.ReadWrite\";\n return People;\n }());\n Scopes.People = People;\n var Notes = (function () {\n function Notes() {\n }\n Notes.Create = Util.rootUrl + \"Notes.Create\";\n Notes.ReadWriteCreatedByApp = Util.rootUrl + \"Notes.ReadWrite.CreatedByApp\";\n Notes.Read = Util.rootUrl + \"Notes.Read\";\n Notes.ReadAll = Util.rootUrl + \"Notes.Read.All\";\n Notes.ReadWriteAll = Util.rootUrl + \"Notes.ReadWrite.All\";\n return Notes;\n }());\n Scopes.Notes = Notes;\n})(Scopes = exports.Scopes || (exports.Scopes = {}));\nvar DataModelWrapper = (function () {\n function DataModelWrapper(graph, _data) {\n this.graph = graph;\n this._data = _data;\n }\n Object.defineProperty(DataModelWrapper.prototype, \"data\", {\n get: function () { return this._data; },\n enumerable: true,\n configurable: true\n });\n return DataModelWrapper;\n}());\nexports.DataModelWrapper = DataModelWrapper;\nvar DataModelListWrapper = (function (_super) {\n __extends(DataModelListWrapper, _super);\n function DataModelListWrapper() {\n _super.apply(this, arguments);\n }\n return DataModelListWrapper;\n}(DataModelWrapper));\nexports.DataModelListWrapper = DataModelListWrapper;\nvar ProfilePhotoDataModel = (function () {\n function ProfilePhotoDataModel() {\n }\n return ProfilePhotoDataModel;\n}());\nexports.ProfilePhotoDataModel = ProfilePhotoDataModel;\nvar ProfilePhoto = (function (_super) {\n __extends(ProfilePhoto, _super);\n function ProfilePhoto() {\n _super.apply(this, arguments);\n }\n return ProfilePhoto;\n}(DataModelWrapper));\nexports.ProfilePhoto = ProfilePhoto;\nvar UserDataModel = (function () {\n function UserDataModel() {\n }\n return UserDataModel;\n}());\nexports.UserDataModel = UserDataModel;\n(function (EventsEndpoint) {\n EventsEndpoint[EventsEndpoint[\"events\"] = 0] = \"events\";\n EventsEndpoint[EventsEndpoint[\"calendarView\"] = 1] = \"calendarView\";\n})(exports.EventsEndpoint || (exports.EventsEndpoint = {}));\nvar EventsEndpoint = exports.EventsEndpoint;\nvar User = (function (_super) {\n __extends(User, _super);\n function User() {\n _super.apply(this, arguments);\n }\n User.prototype.events = function (callback, odataQuery) {\n this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.events, callback, odataQuery);\n };\n User.prototype.eventsAsync = function (odataQuery) {\n return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.events, odataQuery);\n };\n User.prototype.memberOf = function (callback, Error, odataQuery) {\n this.graph.memberOfForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.memberOfAsync = function (odataQuery) {\n return this.graph.memberOfForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.messages = function (callback, odataQuery) {\n this.graph.messagesForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.messagesAsync = function (odataQuery) {\n return this.graph.messagesForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.manager = function (callback, odataQuery) {\n this.graph.managerForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.managerAsync = function (odataQuery) {\n return this.graph.managerForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.profilePhoto = function (callback, odataQuery) {\n this.graph.profilePhotoForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.profilePhotoAsync = function (odataQuery) {\n return this.graph.profilePhotoForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.profilePhotoValue = function (callback, odataQuery) {\n this.graph.profilePhotoValueForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.profilePhotoValueAsync = function (odataQuery) {\n return this.graph.profilePhotoValueForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.calendarView = function (callback, odataQuery) {\n this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.calendarView, callback, odataQuery);\n };\n User.prototype.calendarViewAsync = function (odataQuery) {\n return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.calendarView, odataQuery);\n };\n User.prototype.mailFolders = function (callback, odataQuery) {\n this.graph.mailFoldersForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.mailFoldersAsync = function (odataQuery) {\n return this.graph.mailFoldersForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.message = function (messageId, callback, odataQuery) {\n this.graph.messageForUser(this._data.userPrincipalName, messageId, callback, odataQuery);\n };\n User.prototype.messageAsync = function (messageId, odataQuery) {\n return this.graph.messageForUserAsync(this._data.userPrincipalName, messageId, odataQuery);\n };\n User.prototype.event = function (eventId, callback, odataQuery) {\n this.graph.eventForUser(this._data.userPrincipalName, eventId, callback, odataQuery);\n };\n User.prototype.eventAsync = function (eventId, odataQuery) {\n return this.graph.eventForUserAsync(this._data.userPrincipalName, eventId, odataQuery);\n };\n User.prototype.messageAttachment = function (messageId, attachmentId, callback, odataQuery) {\n this.graph.messageAttachmentForUser(this._data.userPrincipalName, messageId, attachmentId, callback, odataQuery);\n };\n User.prototype.messageAttachmentAsync = function (messageId, attachmentId, odataQuery) {\n return this.graph.messageAttachmentForUserAsync(this._data.userPrincipalName, messageId, attachmentId, odataQuery);\n };\n return User;\n}(DataModelWrapper));\nexports.User = User;\nvar Users = (function (_super) {\n __extends(Users, _super);\n function Users() {\n _super.apply(this, arguments);\n }\n return Users;\n}(DataModelListWrapper));\nexports.Users = Users;\nvar MessageDataModel = (function () {\n function MessageDataModel() {\n }\n return MessageDataModel;\n}());\nexports.MessageDataModel = MessageDataModel;\nvar Message = (function (_super) {\n __extends(Message, _super);\n function Message() {\n _super.apply(this, arguments);\n }\n return Message;\n}(DataModelWrapper));\nexports.Message = Message;\nvar Messages = (function (_super) {\n __extends(Messages, _super);\n function Messages() {\n _super.apply(this, arguments);\n }\n return Messages;\n}(DataModelListWrapper));\nexports.Messages = Messages;\nvar EventDataModel = (function () {\n function EventDataModel() {\n }\n return EventDataModel;\n}());\nexports.EventDataModel = EventDataModel;\nvar Event = (function (_super) {\n __extends(Event, _super);\n function Event() {\n _super.apply(this, arguments);\n }\n return Event;\n}(DataModelWrapper));\nexports.Event = Event;\nvar Events = (function (_super) {\n __extends(Events, _super);\n function Events(graph, endpoint, _data) {\n _super.call(this, graph, _data);\n this.graph = graph;\n this.endpoint = endpoint;\n this._data = _data;\n }\n return Events;\n}(DataModelListWrapper));\nexports.Events = Events;\nvar Contact = (function () {\n function Contact() {\n }\n return Contact;\n}());\nexports.Contact = Contact;\nvar GroupDataModel = (function () {\n function GroupDataModel() {\n }\n return GroupDataModel;\n}());\nexports.GroupDataModel = GroupDataModel;\nvar Group = (function (_super) {\n __extends(Group, _super);\n function Group() {\n _super.apply(this, arguments);\n }\n return Group;\n}(DataModelWrapper));\nexports.Group = Group;\nvar Groups = (function (_super) {\n __extends(Groups, _super);\n function Groups() {\n _super.apply(this, arguments);\n }\n return Groups;\n}(DataModelListWrapper));\nexports.Groups = Groups;\nvar MailFolderDataModel = (function () {\n function MailFolderDataModel() {\n }\n return MailFolderDataModel;\n}());\nexports.MailFolderDataModel = MailFolderDataModel;\nvar MailFolder = (function (_super) {\n __extends(MailFolder, _super);\n function MailFolder() {\n _super.apply(this, arguments);\n }\n return MailFolder;\n}(DataModelWrapper));\nexports.MailFolder = MailFolder;\nvar MailFolders = (function (_super) {\n __extends(MailFolders, _super);\n function MailFolders() {\n _super.apply(this, arguments);\n }\n return MailFolders;\n}(DataModelListWrapper));\nexports.MailFolders = MailFolders;\n(function (AttachmentType) {\n AttachmentType[AttachmentType[\"fileAttachment\"] = 0] = \"fileAttachment\";\n AttachmentType[AttachmentType[\"itemAttachment\"] = 1] = \"itemAttachment\";\n AttachmentType[AttachmentType[\"referenceAttachment\"] = 2] = \"referenceAttachment\";\n})(exports.AttachmentType || (exports.AttachmentType = {}));\nvar AttachmentType = exports.AttachmentType;\nvar AttachmentDataModel = (function () {\n function AttachmentDataModel() {\n }\n return AttachmentDataModel;\n}());\nexports.AttachmentDataModel = AttachmentDataModel;\nvar Attachment = (function (_super) {\n __extends(Attachment, _super);\n function Attachment() {\n _super.apply(this, arguments);\n }\n Attachment.prototype.getType = function () {\n switch (this._data['@odata.type']) {\n case \"#microsoft.graph.fileAttachment\":\n return AttachmentType.fileAttachment;\n case \"#microsoft.graph.itemAttachment\":\n return AttachmentType.itemAttachment;\n case \"#microsoft.graph.referenceAttachment\":\n return AttachmentType.referenceAttachment;\n }\n };\n return Attachment;\n}(DataModelWrapper));\nexports.Attachment = Attachment;\nvar Attachments = (function (_super) {\n __extends(Attachments, _super);\n function Attachments() {\n _super.apply(this, arguments);\n }\n return Attachments;\n}(DataModelListWrapper));\nexports.Attachments = Attachments;\nvar Graph = (function () {\n function Graph(identityInfo) {\n this.req = null;\n this.accessToken = null;\n this.KurveIdentity = null;\n this.defaultResourceID = \"https://graph.microsoft.com\";\n this.baseUrl = \"https://graph.microsoft.com/v1.0/\";\n if (identityInfo.defaultAccessToken) {\n this.accessToken = identityInfo.defaultAccessToken;\n }\n else {\n this.KurveIdentity = identityInfo.identity;\n }\n }\n Graph.prototype.scopesForV2 = function (scopes) {\n if (!this.KurveIdentity)\n return null;\n if (this.KurveIdentity.getCurrentOauthVersion() === identity_1.OAuthVersion.v1)\n return null;\n else\n return scopes;\n };\n Graph.prototype.meAsync = function (odataQuery) {\n var d = new promises_1.Deferred();\n this.me(function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.me = function (callback, odataQuery) {\n var scopes = [Scopes.User.Read];\n var urlString = this.buildMeUrl(\"\", odataQuery);\n this.getUser(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.userAsync = function (userId, odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var d = new promises_1.Deferred();\n this.user(userId, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery, basicProfileOnly);\n return d.promise;\n };\n Graph.prototype.user = function (userId, callback, odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n var urlString = this.buildUsersUrl(userId, odataQuery);\n this.getUser(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.usersAsync = function (odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var d = new promises_1.Deferred();\n this.users(function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery, basicProfileOnly);\n return d.promise;\n };\n Graph.prototype.users = function (callback, odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n var urlString = this.buildUsersUrl(\"\", odataQuery);\n this.getUsers(urlString, callback, this.scopesForV2(scopes), basicProfileOnly);\n };\n Graph.prototype.groupAsync = function (groupId, odataQuery) {\n var d = new promises_1.Deferred();\n this.group(groupId, function (group, error) { return error ? d.reject(error) : d.resolve(group); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.group = function (groupId, callback, odataQuery) {\n var scopes = [Scopes.Group.ReadAll];\n var urlString = this.buildGroupsUrl(groupId, odataQuery);\n this.getGroup(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.groupsAsync = function (odataQuery) {\n var d = new promises_1.Deferred();\n this.groups(function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.groups = function (callback, odataQuery) {\n var scopes = [Scopes.Group.ReadAll];\n var urlString = this.buildGroupsUrl(\"\", odataQuery);\n this.getGroups(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.messageForUserAsync = function (userPrincipalName, messageId, odataQuery) {\n var d = new promises_1.Deferred();\n this.messageForUser(userPrincipalName, messageId, function (message, error) { return error ? d.reject(error) : d.resolve(message); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messageForUser = function (userPrincipalName, messageId, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId, odataQuery);\n this.getMessage(urlString, messageId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.messagesForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.messagesForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messagesForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages\", odataQuery);\n this.getMessages(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.mailFoldersForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.mailFoldersForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.mailFoldersForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/mailFolders\", odataQuery);\n this.getMailFolders(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.eventForUserAsync = function (userPrincipalName, eventId, odataQuery) {\n var d = new promises_1.Deferred();\n this.eventForUser(userPrincipalName, eventId, function (event, error) { return error ? d.reject(error) : d.resolve(event); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.eventForUser = function (userPrincipalName, eventId, callback, odataQuery) {\n var scopes = [Scopes.Calendars.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/events/\" + eventId, odataQuery);\n this.getEvent(urlString, eventId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.eventsForUserAsync = function (userPrincipalName, endpoint, odataQuery) {\n var d = new promises_1.Deferred();\n this.eventsForUser(userPrincipalName, endpoint, function (events, error) { return error ? d.reject(error) : d.resolve(events); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.eventsForUser = function (userPrincipalName, endpoint, callback, odataQuery) {\n var scopes = [Scopes.Calendars.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/\" + EventsEndpoint[endpoint], odataQuery);\n this.getEvents(urlString, endpoint, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.memberOfForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.memberOfForUser(userPrincipalName, function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.memberOfForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Group.ReadAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/memberOf\", odataQuery);\n this.getGroups(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.managerForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.managerForUser(userPrincipalName, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.managerForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Directory.ReadAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/manager\", odataQuery);\n this.getUser(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.directReportsForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.directReportsForUser(userPrincipalName, function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.directReportsForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Directory.ReadAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/directReports\", odataQuery);\n this.getUsers(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.profilePhotoForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.profilePhotoForUser(userPrincipalName, function (profilePhoto, error) { return error ? d.reject(error) : d.resolve(profilePhoto); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.profilePhotoForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.User.ReadBasicAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/photo\", odataQuery);\n this.getPhoto(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.profilePhotoValueForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.profilePhotoValueForUser(userPrincipalName, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.profilePhotoValueForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.User.ReadBasicAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/photo/$value\", odataQuery);\n this.getPhotoValue(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.messageAttachmentsForUserAsync = function (userPrincipalName, messageId, odataQuery) {\n var d = new promises_1.Deferred();\n this.messageAttachmentsForUser(userPrincipalName, messageId, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messageAttachmentsForUser = function (userPrincipalName, messageId, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId + \"/attachments\", odataQuery);\n this.getMessageAttachments(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.messageAttachmentForUserAsync = function (userPrincipalName, messageId, attachmentId, odataQuery) {\n var d = new promises_1.Deferred();\n this.messageAttachmentForUser(userPrincipalName, messageId, attachmentId, function (attachment, error) { return error ? d.reject(error) : d.resolve(attachment); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messageAttachmentForUser = function (userPrincipalName, messageId, attachmentId, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId + \"/attachments/\" + attachmentId, odataQuery);\n this.getMessageAttachment(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.getAsync = function (url) {\n var d = new promises_1.Deferred();\n this.get(url, function (response, error) { return error ? d.reject(error) : d.resolve(response); });\n return d.promise;\n };\n Graph.prototype.get = function (url, callback, responseType, scopes) {\n var _this = this;\n var xhr = new XMLHttpRequest();\n if (responseType)\n xhr.responseType = responseType;\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4)\n if (xhr.status === 200)\n callback(responseType ? xhr.response : xhr.responseText, null);\n else\n callback(null, _this.generateError(xhr));\n };\n xhr.open(\"GET\", url);\n this.addAccessTokenAndSend(xhr, function (addTokenError) {\n if (addTokenError) {\n callback(null, addTokenError);\n }\n }, scopes);\n };\n Graph.prototype.generateError = function (xhr) {\n var response = new identity_1.Error();\n response.status = xhr.status;\n response.statusText = xhr.statusText;\n if (xhr.responseType === '' || xhr.responseType === 'text')\n response.text = xhr.responseText;\n else\n response.other = xhr.response;\n return response;\n };\n Graph.prototype.getUsers = function (urlString, callback, scopes, basicProfileOnly) {\n var _this = this;\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var usersODATA = JSON.parse(result);\n if (usersODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = usersODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (usersODATA.value ? usersODATA.value : [usersODATA]);\n var users = new Users(_this, resultsArray.map(function (o) { return new User(_this, o); }));\n var nextLink = usersODATA['@odata.nextLink'];\n if (nextLink) {\n users.nextLink = function (callback) {\n var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n var d = new promises_1.Deferred();\n _this.getUsers(nextLink, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes), basicProfileOnly);\n return d.promise;\n };\n }\n callback(users, null);\n }, null, scopes);\n };\n Graph.prototype.getUser = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var userODATA = JSON.parse(result);\n if (userODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = userODATA.error;\n callback(null, errorODATA);\n return;\n }\n var user = new User(_this, userODATA);\n callback(user, null);\n }, null, scopes);\n };\n Graph.prototype.addAccessTokenAndSend = function (xhr, callback, scopes) {\n if (this.accessToken) {\n xhr.setRequestHeader('Authorization', 'Bearer ' + this.accessToken);\n xhr.send();\n }\n else {\n if (scopes) {\n this.KurveIdentity.getAccessTokenForScopes(scopes, false, (function (token, error) {\n if (error)\n callback(error);\n else {\n xhr.setRequestHeader('Authorization', 'Bearer ' + token);\n xhr.send();\n callback(null);\n }\n }));\n }\n else {\n this.KurveIdentity.getAccessToken(this.defaultResourceID, (function (token, error) {\n if (error)\n callback(error);\n else {\n xhr.setRequestHeader('Authorization', 'Bearer ' + token);\n xhr.send();\n callback(null);\n }\n }));\n }\n }\n };\n Graph.prototype.getMessage = function (urlString, messageId, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var message = new Message(_this, ODATA);\n callback(message, null);\n }, null, scopes);\n };\n Graph.prototype.getMessages = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var messagesODATA = JSON.parse(result);\n if (messagesODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = messagesODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (messagesODATA.value ? messagesODATA.value : [messagesODATA]);\n var messages = new Messages(_this, resultsArray.map(function (o) { return new Message(_this, o); }));\n var nextLink = messagesODATA['@odata.nextLink'];\n if (nextLink) {\n messages.nextLink = function (callback) {\n var scopes = [Scopes.Mail.Read];\n var d = new promises_1.Deferred();\n _this.getMessages(nextLink, function (messages, error) {\n if (callback)\n callback(messages, error);\n else\n error ? d.reject(error) : d.resolve(messages);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(messages, null);\n }, null, scopes);\n };\n Graph.prototype.getEvent = function (urlString, EventId, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var event = new Event(_this, ODATA);\n callback(event, null);\n }, null, scopes);\n };\n Graph.prototype.getEvents = function (urlString, endpoint, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var odata = JSON.parse(result);\n if (odata.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = odata.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (odata.value ? odata.value : [odata]);\n var events = new Events(_this, endpoint, resultsArray.map(function (o) { return new Event(_this, o); }));\n var nextLink = odata['@odata.nextLink'];\n if (nextLink) {\n events.nextLink = function (callback) {\n var scopes = [Scopes.Mail.Read];\n var d = new promises_1.Deferred();\n _this.getEvents(nextLink, endpoint, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(events, null);\n }, null, scopes);\n };\n Graph.prototype.getGroups = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var groupsODATA = JSON.parse(result);\n if (groupsODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = groupsODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (groupsODATA.value ? groupsODATA.value : [groupsODATA]);\n var groups = new Groups(_this, resultsArray.map(function (o) { return new Group(_this, o); }));\n var nextLink = groupsODATA['@odata.nextLink'];\n if (nextLink) {\n groups.nextLink = function (callback) {\n var scopes = [Scopes.Group.ReadAll];\n var d = new promises_1.Deferred();\n _this.getGroups(nextLink, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(groups, null);\n }, null, scopes);\n };\n Graph.prototype.getGroup = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var group = new Group(_this, ODATA);\n callback(group, null);\n }, null, scopes);\n };\n Graph.prototype.getPhoto = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = ODATA.error;\n callback(null, errorODATA);\n return;\n }\n var photo = new ProfilePhoto(_this, ODATA);\n callback(photo, null);\n }, null, scopes);\n };\n Graph.prototype.getPhotoValue = function (urlString, callback, scopes) {\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n callback(result, null);\n }, \"blob\", scopes);\n };\n Graph.prototype.getMailFolders = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var odata = JSON.parse(result);\n if (odata.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = odata.error;\n callback(null, errorODATA);\n }\n var resultsArray = (odata.value ? odata.value : [odata]);\n var mailFolders = new MailFolders(_this, resultsArray.map(function (o) { return new MailFolder(_this, o); }));\n var nextLink = odata['@odata.nextLink'];\n if (nextLink) {\n mailFolders.nextLink = function (callback) {\n var scopes = [Scopes.User.ReadAll];\n var d = new promises_1.Deferred();\n _this.getMailFolders(nextLink, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(mailFolders, null);\n }, null, scopes);\n };\n Graph.prototype.getMessageAttachments = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var attachmentsODATA = JSON.parse(result);\n if (attachmentsODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = attachmentsODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (attachmentsODATA.value ? attachmentsODATA.value : [attachmentsODATA]);\n var attachments = new Attachments(_this, resultsArray.map(function (o) { return new Attachment(_this, o); }));\n var nextLink = attachmentsODATA['@odata.nextLink'];\n if (nextLink) {\n attachments.nextLink = function (callback) {\n var scopes = [Scopes.Mail.Read];\n var d = new promises_1.Deferred();\n _this.getMessageAttachments(nextLink, function (attachments, error) {\n if (callback)\n callback(attachments, error);\n else\n error ? d.reject(error) : d.resolve(attachments);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(attachments, null);\n }, null, scopes);\n };\n Graph.prototype.getMessageAttachment = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var attachment = new Attachment(_this, ODATA);\n callback(attachment, null);\n }, null, scopes);\n };\n Graph.prototype.buildUrl = function (root, path, odataQuery) {\n return this.baseUrl + root + path + (odataQuery ? \"?\" + odataQuery : \"\");\n };\n Graph.prototype.buildMeUrl = function (path, odataQuery) {\n if (path === void 0) { path = \"\"; }\n return this.buildUrl(\"me/\", path, odataQuery);\n };\n Graph.prototype.buildUsersUrl = function (path, odataQuery) {\n if (path === void 0) { path = \"\"; }\n return this.buildUrl(\"users/\", path, odataQuery);\n };\n Graph.prototype.buildGroupsUrl = function (path, odataQuery) {\n if (path === void 0) { path = \"\"; }\n return this.buildUrl(\"groups/\", path, odataQuery);\n };\n return Graph;\n}());\nexports.Graph = Graph;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/graph.ts\n ** module id = 1\n ** module chunks = 0\n **/","\"use strict\";\nfunction DispatchDeferred(closure) {\n setTimeout(closure, 0);\n}\nvar PromiseState;\n(function (PromiseState) {\n PromiseState[PromiseState[\"Pending\"] = 0] = \"Pending\";\n PromiseState[PromiseState[\"ResolutionInProgress\"] = 1] = \"ResolutionInProgress\";\n PromiseState[PromiseState[\"Resolved\"] = 2] = \"Resolved\";\n PromiseState[PromiseState[\"Rejected\"] = 3] = \"Rejected\";\n})(PromiseState || (PromiseState = {}));\nvar Client = (function () {\n function Client(_dispatcher, _successCB, _errorCB) {\n this._dispatcher = _dispatcher;\n this._successCB = _successCB;\n this._errorCB = _errorCB;\n this.result = new Deferred(_dispatcher);\n }\n Client.prototype.resolve = function (value, defer) {\n var _this = this;\n if (typeof (this._successCB) !== 'function') {\n this.result.resolve(value);\n return;\n }\n if (defer) {\n this._dispatcher(function () { return _this._dispatchCallback(_this._successCB, value); });\n }\n else {\n this._dispatchCallback(this._successCB, value);\n }\n };\n Client.prototype.reject = function (error, defer) {\n var _this = this;\n if (typeof (this._errorCB) !== 'function') {\n this.result.reject(error);\n return;\n }\n if (defer) {\n this._dispatcher(function () { return _this._dispatchCallback(_this._errorCB, error); });\n }\n else {\n this._dispatchCallback(this._errorCB, error);\n }\n };\n Client.prototype._dispatchCallback = function (callback, arg) {\n var result, then, type;\n try {\n result = callback(arg);\n this.result.resolve(result);\n }\n catch (err) {\n this.result.reject(err);\n return;\n }\n };\n return Client;\n}());\nvar Deferred = (function () {\n function Deferred(dispatcher) {\n this._stack = [];\n this._state = PromiseState.Pending;\n if (dispatcher)\n this._dispatcher = dispatcher;\n else\n this._dispatcher = DispatchDeferred;\n this.promise = new Promise(this);\n }\n Deferred.prototype.DispatchDeferred = function (closure) {\n setTimeout(closure, 0);\n };\n Deferred.prototype.then = function (successCB, errorCB) {\n if (typeof (successCB) !== 'function' && typeof (errorCB) !== 'function') {\n return this.promise;\n }\n var client = new Client(this._dispatcher, successCB, errorCB);\n switch (this._state) {\n case PromiseState.Pending:\n case PromiseState.ResolutionInProgress:\n this._stack.push(client);\n break;\n case PromiseState.Resolved:\n client.resolve(this._value, true);\n break;\n case PromiseState.Rejected:\n client.reject(this._error, true);\n break;\n }\n return client.result.promise;\n };\n Deferred.prototype.resolve = function (value) {\n if (this._state !== PromiseState.Pending) {\n return this;\n }\n return this._resolve(value);\n };\n Deferred.prototype._resolve = function (value) {\n var _this = this;\n var type = typeof (value), then, pending = true;\n try {\n if (value !== null &&\n (type === 'object' || type === 'function') &&\n typeof (then = value.then) === 'function') {\n if (value === this.promise) {\n throw new TypeError('recursive resolution');\n }\n this._state = PromiseState.ResolutionInProgress;\n then.call(value, function (result) {\n if (pending) {\n pending = false;\n _this._resolve(result);\n }\n }, function (error) {\n if (pending) {\n pending = false;\n _this._reject(error);\n }\n });\n }\n else {\n this._state = PromiseState.ResolutionInProgress;\n this._dispatcher(function () {\n _this._state = PromiseState.Resolved;\n _this._value = value;\n var i, stackSize = _this._stack.length;\n for (i = 0; i < stackSize; i++) {\n _this._stack[i].resolve(value, false);\n }\n _this._stack.splice(0, stackSize);\n });\n }\n }\n catch (err) {\n if (pending) {\n this._reject(err);\n }\n }\n return this;\n };\n Deferred.prototype.reject = function (error) {\n if (this._state !== PromiseState.Pending) {\n return this;\n }\n return this._reject(error);\n };\n Deferred.prototype._reject = function (error) {\n var _this = this;\n this._state = PromiseState.ResolutionInProgress;\n this._dispatcher(function () {\n _this._state = PromiseState.Rejected;\n _this._error = error;\n var stackSize = _this._stack.length, i = 0;\n for (i = 0; i < stackSize; i++) {\n _this._stack[i].reject(error, false);\n }\n _this._stack.splice(0, stackSize);\n });\n return this;\n };\n return Deferred;\n}());\nexports.Deferred = Deferred;\nvar Promise = (function () {\n function Promise(_deferred) {\n this._deferred = _deferred;\n }\n Promise.prototype.then = function (successCallback, errorCallback) {\n return this._deferred.then(successCallback, errorCallback);\n };\n Promise.prototype.fail = function (errorCallback) {\n return this._deferred.then(undefined, errorCallback);\n };\n return Promise;\n}());\nexports.Promise = Promise;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/promises.ts\n ** module id = 2\n ** module chunks = 0\n **/","\"use strict\";\nvar promises_1 = require(\"./promises\");\n(function (OAuthVersion) {\n OAuthVersion[OAuthVersion[\"v1\"] = 1] = \"v1\";\n OAuthVersion[OAuthVersion[\"v2\"] = 2] = \"v2\";\n})(exports.OAuthVersion || (exports.OAuthVersion = {}));\nvar OAuthVersion = exports.OAuthVersion;\nvar Error = (function () {\n function Error() {\n }\n return Error;\n}());\nexports.Error = Error;\nvar CachedToken = (function () {\n function CachedToken(id, scopes, resource, token, expiry) {\n this.id = id;\n this.scopes = scopes;\n this.resource = resource;\n this.token = token;\n this.expiry = expiry;\n }\n ;\n Object.defineProperty(CachedToken.prototype, \"isExpired\", {\n get: function () {\n return this.expiry <= new Date(new Date().getTime() + 60000);\n },\n enumerable: true,\n configurable: true\n });\n CachedToken.prototype.hasScopes = function (requiredScopes) {\n var _this = this;\n if (!this.scopes) {\n return false;\n }\n return requiredScopes.every(function (requiredScope) {\n return _this.scopes.some(function (actualScope) { return requiredScope === actualScope; });\n });\n };\n return CachedToken;\n}());\nvar TokenCache = (function () {\n function TokenCache(tokenStorage) {\n var _this = this;\n this.tokenStorage = tokenStorage;\n this.cachedTokens = {};\n if (tokenStorage) {\n tokenStorage.getAll().forEach(function (_a) {\n var id = _a.id, scopes = _a.scopes, resource = _a.resource, token = _a.token, expiry = _a.expiry;\n var cachedToken = new CachedToken(id, scopes, resource, token, new Date(expiry));\n if (cachedToken.isExpired) {\n _this.tokenStorage.remove(cachedToken.id);\n }\n else {\n _this.cachedTokens[cachedToken.id] = cachedToken;\n }\n });\n }\n }\n TokenCache.prototype.add = function (token) {\n this.cachedTokens[token.id] = token;\n this.tokenStorage && this.tokenStorage.add(token.id, token);\n };\n TokenCache.prototype.getForResource = function (resource) {\n var cachedToken = this.cachedTokens[resource];\n if (cachedToken && cachedToken.isExpired) {\n this.remove(resource);\n return null;\n }\n return cachedToken;\n };\n TokenCache.prototype.getForScopes = function (scopes) {\n for (var key in this.cachedTokens) {\n var cachedToken = this.cachedTokens[key];\n if (cachedToken.hasScopes(scopes)) {\n if (cachedToken.isExpired) {\n this.remove(key);\n }\n else {\n return cachedToken;\n }\n }\n }\n return null;\n };\n TokenCache.prototype.clear = function () {\n this.cachedTokens = {};\n this.tokenStorage && this.tokenStorage.clear();\n };\n TokenCache.prototype.remove = function (key) {\n this.tokenStorage && this.tokenStorage.remove(key);\n delete this.cachedTokens[key];\n };\n return TokenCache;\n}());\nvar IdToken = (function () {\n function IdToken() {\n }\n return IdToken;\n}());\nexports.IdToken = IdToken;\nvar Identity = (function () {\n function Identity(identitySettings) {\n var _this = this;\n this.policy = \"\";\n this.clientId = identitySettings.clientId;\n this.tokenProcessorUrl = identitySettings.tokenProcessingUri;\n if (identitySettings.version)\n this.version = identitySettings.version;\n else\n this.version = OAuthVersion.v1;\n this.tokenCache = new TokenCache(identitySettings.tokenStorage);\n window.addEventListener(\"message\", function (event) {\n if (event.data.type === \"id_token\") {\n if (event.data.error) {\n var e = new Error();\n e.text = event.data.error;\n _this.loginCallback(e);\n }\n else {\n if (_this.state !== event.data.state) {\n var error = new Error();\n error.statusText = \"Invalid state\";\n _this.loginCallback(error);\n }\n else {\n _this.decodeIdToken(event.data.token);\n _this.loginCallback(null);\n }\n }\n }\n else if (event.data.type === \"access_token\") {\n if (event.data.error) {\n var e = new Error();\n e.text = event.data.error;\n _this.getTokenCallback(null, e);\n }\n else {\n var token = event.data.token;\n var iframe = document.getElementById(\"tokenIFrame\");\n iframe.parentNode.removeChild(iframe);\n if (event.data.state !== _this.state) {\n var error = new Error();\n error.statusText = \"Invalid state\";\n _this.getTokenCallback(null, error);\n }\n else {\n _this.getTokenCallback(token, null);\n }\n }\n }\n });\n }\n Identity.prototype.checkForIdentityRedirect = function () {\n function token(s) {\n var start = window.location.href.indexOf(s);\n if (start < 0)\n return null;\n var end = window.location.href.indexOf(\"&\", start + s.length);\n return window.location.href.substring(start, ((end > 0) ? end : window.location.href.length));\n }\n function parseQueryString(str) {\n var queryString = str || window.location.search || '';\n var keyValPairs = [];\n var params = {};\n queryString = queryString.replace(/.*?\\?/, \"\");\n if (queryString.length) {\n keyValPairs = queryString.split('&');\n for (var pairNum in keyValPairs) {\n var key = keyValPairs[pairNum].split('=')[0];\n if (!key.length)\n continue;\n if (typeof params[key] === 'undefined')\n params[key] = [];\n params[key].push(keyValPairs[pairNum].split('=')[1]);\n }\n }\n return params;\n }\n var params = parseQueryString(window.location.href);\n var idToken = token(\"#id_token=\");\n var accessToken = token(\"#access_token\");\n if (idToken) {\n if (true || this.state === params[\"state\"][0]) {\n this.decodeIdToken(idToken);\n this.loginCallback && this.loginCallback(null);\n }\n else {\n var error = new Error();\n error.statusText = \"Invalid state\";\n this.loginCallback && this.loginCallback(error);\n }\n return true;\n }\n else if (accessToken) {\n throw \"Should not get here. This should be handled via the iframe approach.\";\n }\n return false;\n };\n Identity.prototype.decodeIdToken = function (idToken) {\n var _this = this;\n var decodedToken = this.base64Decode(idToken.substring(idToken.indexOf('.') + 1, idToken.lastIndexOf('.')));\n var decodedTokenJSON = JSON.parse(decodedToken);\n var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000);\n this.idToken = new IdToken();\n this.idToken.FullToken = decodedTokenJSON;\n this.idToken.Token = idToken;\n this.idToken.Expiry = expiryDate;\n this.idToken.UPN = decodedTokenJSON.upn;\n this.idToken.TenantId = decodedTokenJSON.tid;\n this.idToken.FamilyName = decodedTokenJSON.family_name;\n this.idToken.GivenName = decodedTokenJSON.given_name;\n this.idToken.Name = decodedTokenJSON.name;\n this.idToken.PreferredUsername = decodedTokenJSON.preferred_username;\n var expiration = expiryDate.getTime() - new Date().getTime() - 300000;\n this.refreshTimer = setTimeout((function () {\n _this.renewIdToken();\n }), expiration);\n };\n Identity.prototype.decodeAccessToken = function (accessToken, resource, scopes) {\n var decodedToken = this.base64Decode(accessToken.substring(accessToken.indexOf('.') + 1, accessToken.lastIndexOf('.')));\n var decodedTokenJSON = JSON.parse(decodedToken);\n var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000);\n var key = resource || scopes.join(\" \");\n var token = new CachedToken(key, scopes, resource, accessToken, expiryDate);\n this.tokenCache.add(token);\n };\n Identity.prototype.getIdToken = function () {\n return this.idToken;\n };\n Identity.prototype.isLoggedIn = function () {\n if (!this.idToken)\n return false;\n return (this.idToken.Expiry > new Date());\n };\n Identity.prototype.renewIdToken = function () {\n clearTimeout(this.refreshTimer);\n this.login(function () { });\n };\n Identity.prototype.getCurrentOauthVersion = function () {\n return this.version;\n };\n Identity.prototype.getAccessTokenAsync = function (resource) {\n var d = new promises_1.Deferred();\n this.getAccessToken(resource, (function (token, error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(token);\n }\n }));\n return d.promise;\n };\n Identity.prototype.getAccessToken = function (resource, callback) {\n var _this = this;\n if (this.version !== OAuthVersion.v1) {\n var e = new Error();\n e.statusText = \"Currently this identity class is using v2 OAuth mode. You need to use getAccessTokenForScopes() method\";\n callback(null, e);\n return;\n }\n var token = this.tokenCache.getForResource(resource);\n if (token) {\n return callback(token.token, null);\n }\n this.getTokenCallback = (function (token, error) {\n if (error) {\n callback(null, error);\n }\n else {\n _this.decodeAccessToken(token, resource);\n callback(token, null);\n }\n });\n this.nonce = \"token\" + this.generateNonce();\n this.state = \"token\" + this.generateNonce();\n var iframe = document.createElement('iframe');\n iframe.style.display = \"none\";\n iframe.id = \"tokenIFrame\";\n iframe.src = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&resource=\" + encodeURIComponent(resource) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&op=token\";\n document.body.appendChild(iframe);\n };\n Identity.prototype.getAccessTokenForScopesAsync = function (scopes, promptForConsent) {\n if (promptForConsent === void 0) { promptForConsent = false; }\n var d = new promises_1.Deferred();\n this.getAccessTokenForScopes(scopes, promptForConsent, function (token, error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(token);\n }\n });\n return d.promise;\n };\n Identity.prototype.getAccessTokenForScopes = function (scopes, promptForConsent, callback) {\n var _this = this;\n if (promptForConsent === void 0) { promptForConsent = false; }\n if (this.version !== OAuthVersion.v2) {\n var e = new Error();\n e.statusText = \"Dynamic scopes require v2 mode. Currently this identity class is using v1\";\n callback(null, e);\n return;\n }\n var token = this.tokenCache.getForScopes(scopes);\n if (token) {\n return callback(token.token, null);\n }\n this.getTokenCallback = (function (token, error) {\n if (error) {\n if (promptForConsent || !error.text) {\n callback(null, error);\n }\n else if (error.text.indexOf(\"AADSTS65001\") >= 0) {\n _this.getAccessTokenForScopes(scopes, true, _this.getTokenCallback);\n }\n else {\n callback(null, error);\n }\n }\n else {\n _this.decodeAccessToken(token, null, scopes);\n callback(token, null);\n }\n });\n this.nonce = \"token\" + this.generateNonce();\n this.state = \"token\" + this.generateNonce();\n if (!promptForConsent) {\n var iframe = document.createElement('iframe');\n iframe.style.display = \"none\";\n iframe.id = \"tokenIFrame\";\n iframe.src = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&scopes=\" + encodeURIComponent(scopes.join(\" \")) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&login_hint=\" + encodeURIComponent(this.idToken.PreferredUsername) +\n \"&domain_hint=\" + encodeURIComponent(this.idToken.TenantId === \"9188040d-6c67-4c5b-b112-36a304b66dad\" ? \"consumers\" : \"organizations\") +\n \"&op=token\";\n document.body.appendChild(iframe);\n }\n else {\n window.open(this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&scopes=\" + encodeURIComponent(scopes.join(\" \")) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&op=token\", \"_blank\");\n }\n };\n Identity.prototype.loginAsync = function (loginSettings) {\n var d = new promises_1.Deferred();\n this.login(function (error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(null);\n }\n }, loginSettings);\n return d.promise;\n };\n Identity.prototype.login = function (callback, loginSettings) {\n this.loginCallback = callback;\n if (!loginSettings)\n loginSettings = {};\n if (loginSettings.policy)\n this.policy = loginSettings.policy;\n if (loginSettings.scopes && this.version === OAuthVersion.v1) {\n var e = new Error();\n e.text = \"Scopes can only be used with OAuth v2.\";\n callback(e);\n return;\n }\n if (loginSettings.policy && !loginSettings.tenant) {\n var e = new Error();\n e.text = \"In order to use policy (AAD B2C) a tenant must be specified as well.\";\n callback(e);\n return;\n }\n this.state = \"login\" + this.generateNonce();\n this.nonce = \"login\" + this.generateNonce();\n var loginURL = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&op=login\" +\n \"&p=\" + encodeURIComponent(this.policy);\n if (loginSettings.tenant) {\n loginURL += \"&tenant=\" + encodeURIComponent(loginSettings.tenant);\n }\n if (this.version === OAuthVersion.v2) {\n if (!loginSettings.scopes)\n loginSettings.scopes = [];\n if (loginSettings.scopes.indexOf(\"profile\") < 0)\n loginSettings.scopes.push(\"profile\");\n if (loginSettings.scopes.indexOf(\"openid\") < 0)\n loginSettings.scopes.push(\"openid\");\n loginURL += \"&scopes=\" + encodeURIComponent(loginSettings.scopes.join(\" \"));\n }\n window.open(loginURL, \"_blank\");\n };\n Identity.prototype.loginNoWindowAsync = function (toUrl) {\n var d = new promises_1.Deferred();\n this.loginNoWindow(function (error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(null);\n }\n }, toUrl);\n return d.promise;\n };\n Identity.prototype.loginNoWindow = function (callback, toUrl) {\n this.loginCallback = callback;\n this.state = \"clientId=\" + this.clientId + \"&\" + \"tokenProcessorUrl=\" + this.tokenProcessorUrl;\n this.nonce = this.generateNonce();\n var redirected = this.checkForIdentityRedirect();\n if (!redirected) {\n var redirectUri = (toUrl) ? toUrl : window.location.href.split(\"#\")[0];\n var url = \"https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token\" +\n \"&client_id=\" + encodeURIComponent(this.clientId) +\n \"&redirect_uri=\" + encodeURIComponent(redirectUri) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce);\n window.location.href = url;\n }\n };\n Identity.prototype.logOut = function () {\n this.tokenCache.clear();\n var url = \"https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=\" + encodeURI(window.location.href);\n window.location.href = url;\n };\n Identity.prototype.base64Decode = function (encodedString) {\n var e = {}, i, b = 0, c, x, l = 0, a, r = '', w = String.fromCharCode, L = encodedString.length;\n var A = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n for (i = 0; i < 64; i++) {\n e[A.charAt(i)] = i;\n }\n for (x = 0; x < L; x++) {\n c = e[encodedString.charAt(x)];\n b = (b << 6) + c;\n l += 6;\n while (l >= 8) {\n ((a = (b >>> (l -= 8)) & 0xff) || (x < (L - 2))) && (r += w(a));\n }\n }\n return r;\n };\n Identity.prototype.generateNonce = function () {\n var text = \"\";\n var chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n for (var i = 0; i < 32; i++) {\n text += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return text;\n };\n return Identity;\n}());\nexports.Identity = Identity;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/identity.ts\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/kurve.min.js b/dist/kurve.min.js new file mode 100644 index 00000000..ce013676 --- /dev/null +++ b/dist/kurve.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Kurve=t():e.Kurve=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";var n=r(1),o=r(3);e.exports={Graph:n.Graph,Identity:o.Identity}},function(e,t,r){"use strict";var n,o=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},s=r(2),i=r(3);!function(e){var t=function(){function e(){}return e.rootUrl="https://graph.microsoft.com/",e}(),r=function(){function e(){}return e.OpenId="openid",e.OfflineAccess="offline_access",e}();e.General=r;var n=function(){function e(){}return e.Read=t.rootUrl+"User.Read",e.ReadWrite=t.rootUrl+"User.ReadWrite",e.ReadBasicAll=t.rootUrl+"User.ReadBasic.All",e.ReadAll=t.rootUrl+"User.Read.All",e.ReadWriteAll=t.rootUrl+"User.ReadWrite.All",e}();e.User=n;var o=function(){function e(){}return e.Read=t.rootUrl+"Contacts.Read",e.ReadWrite=t.rootUrl+"Contacts.ReadWrite",e}();e.Contacts=o;var s=function(){function e(){}return e.ReadAll=t.rootUrl+"Directory.Read.All",e.ReadWriteAll=t.rootUrl+"Directory.ReadWrite.All",e.AccessAsUserAll=t.rootUrl+"Directory.AccessAsUser.All",e}();e.Directory=s;var i=function(){function e(){}return e.ReadAll=t.rootUrl+"Group.Read.All",e.ReadWriteAll=t.rootUrl+"Group.ReadWrite.All",e.AccessAsUserAll=t.rootUrl+"Directory.AccessAsUser.All",e}();e.Group=i;var a=function(){function e(){}return e.Read=t.rootUrl+"Mail.Read",e.ReadWrite=t.rootUrl+"Mail.ReadWrite",e.Send=t.rootUrl+"Mail.Send",e}();e.Mail=a;var c=function(){function e(){}return e.Read=t.rootUrl+"Calendars.Read",e.ReadWrite=t.rootUrl+"Calendars.ReadWrite",e}();e.Calendars=c;var u=function(){function e(){}return e.Read=t.rootUrl+"Files.Read",e.ReadAll=t.rootUrl+"Files.Read.All",e.ReadWrite=t.rootUrl+"Files.ReadWrite",e.ReadWriteAppFolder=t.rootUrl+"Files.ReadWrite.AppFolder",e.ReadWriteSelected=t.rootUrl+"Files.ReadWrite.Selected",e}();e.Files=u;var l=function(){function e(){}return e.ReadWrite=t.rootUrl+"Tasks.ReadWrite",e}();e.Tasks=l;var p=function(){function e(){}return e.Read=t.rootUrl+"People.Read",e.ReadWrite=t.rootUrl+"People.ReadWrite",e}();e.People=p;var h=function(){function e(){}return e.Create=t.rootUrl+"Notes.Create",e.ReadWriteCreatedByApp=t.rootUrl+"Notes.ReadWrite.CreatedByApp",e.Read=t.rootUrl+"Notes.Read",e.ReadAll=t.rootUrl+"Notes.Read.All",e.ReadWriteAll=t.rootUrl+"Notes.ReadWrite.All",e}();e.Notes=h}(n=t.Scopes||(t.Scopes={}));var a=function(){function e(e,t){this.graph=e,this._data=t}return Object.defineProperty(e.prototype,"data",{get:function(){return this._data},enumerable:!0,configurable:!0}),e}();t.DataModelWrapper=a;var c=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(a);t.DataModelListWrapper=c;var u=function(){function e(){}return e}();t.ProfilePhotoDataModel=u;var l=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(a);t.ProfilePhoto=l;var p=function(){function e(){}return e}();t.UserDataModel=p,function(e){e[e.events=0]="events",e[e.calendarView=1]="calendarView"}(t.EventsEndpoint||(t.EventsEndpoint={}));var h=t.EventsEndpoint,d=function(e){function t(){e.apply(this,arguments)}return o(t,e),t.prototype.events=function(e,t){this.graph.eventsForUser(this._data.userPrincipalName,h.events,e,t)},t.prototype.eventsAsync=function(e){return this.graph.eventsForUserAsync(this._data.userPrincipalName,h.events,e)},t.prototype.memberOf=function(e,t,r){this.graph.memberOfForUser(this._data.userPrincipalName,e,r)},t.prototype.memberOfAsync=function(e){return this.graph.memberOfForUserAsync(this._data.userPrincipalName,e)},t.prototype.messages=function(e,t){this.graph.messagesForUser(this._data.userPrincipalName,e,t)},t.prototype.messagesAsync=function(e){return this.graph.messagesForUserAsync(this._data.userPrincipalName,e)},t.prototype.manager=function(e,t){this.graph.managerForUser(this._data.userPrincipalName,e,t)},t.prototype.managerAsync=function(e){return this.graph.managerForUserAsync(this._data.userPrincipalName,e)},t.prototype.profilePhoto=function(e,t){this.graph.profilePhotoForUser(this._data.userPrincipalName,e,t)},t.prototype.profilePhotoAsync=function(e){return this.graph.profilePhotoForUserAsync(this._data.userPrincipalName,e)},t.prototype.profilePhotoValue=function(e,t){this.graph.profilePhotoValueForUser(this._data.userPrincipalName,e,t)},t.prototype.profilePhotoValueAsync=function(e){return this.graph.profilePhotoValueForUserAsync(this._data.userPrincipalName,e)},t.prototype.calendarView=function(e,t){this.graph.eventsForUser(this._data.userPrincipalName,h.calendarView,e,t)},t.prototype.calendarViewAsync=function(e){return this.graph.eventsForUserAsync(this._data.userPrincipalName,h.calendarView,e)},t.prototype.mailFolders=function(e,t){this.graph.mailFoldersForUser(this._data.userPrincipalName,e,t)},t.prototype.mailFoldersAsync=function(e){return this.graph.mailFoldersForUserAsync(this._data.userPrincipalName,e)},t.prototype.message=function(e,t,r){this.graph.messageForUser(this._data.userPrincipalName,e,t,r)},t.prototype.messageAsync=function(e,t){return this.graph.messageForUserAsync(this._data.userPrincipalName,e,t)},t.prototype.event=function(e,t,r){this.graph.eventForUser(this._data.userPrincipalName,e,t,r)},t.prototype.eventAsync=function(e,t){return this.graph.eventForUserAsync(this._data.userPrincipalName,e,t)},t.prototype.messageAttachment=function(e,t,r,n){this.graph.messageAttachmentForUser(this._data.userPrincipalName,e,t,r,n)},t.prototype.messageAttachmentAsync=function(e,t,r){return this.graph.messageAttachmentForUserAsync(this._data.userPrincipalName,e,t,r)},t}(a);t.User=d;var f=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(c);t.Users=f;var v=function(){function e(){}return e}();t.MessageDataModel=v;var m=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(a);t.Message=m;var y=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(c);t.Messages=y;var g=function(){function e(){}return e}();t.EventDataModel=g;var U=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(a);t.Event=U;var A=function(e){function t(t,r,n){e.call(this,t,n),this.graph=t,this.endpoint=r,this._data=n}return o(t,e),t}(c);t.Events=A;var k=function(){function e(){}return e}();t.Contact=k;var R=function(){function e(){}return e}();t.GroupDataModel=R;var w=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(a);t.Group=w;var F=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(c);t.Groups=F;var _=function(){function e(){}return e}();t.MailFolderDataModel=_;var T=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(a);t.MailFolder=T;var C=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(c);t.MailFolders=C,function(e){e[e.fileAttachment=0]="fileAttachment",e[e.itemAttachment=1]="itemAttachment",e[e.referenceAttachment=2]="referenceAttachment"}(t.AttachmentType||(t.AttachmentType={}));var I=t.AttachmentType,b=function(){function e(){}return e}();t.AttachmentDataModel=b;var P=function(e){function t(){e.apply(this,arguments)}return o(t,e),t.prototype.getType=function(){switch(this._data["@odata.type"]){case"#microsoft.graph.fileAttachment":return I.fileAttachment;case"#microsoft.graph.itemAttachment":return I.itemAttachment;case"#microsoft.graph.referenceAttachment":return I.referenceAttachment}},t}(a);t.Attachment=P;var D=function(e){function t(){e.apply(this,arguments)}return o(t,e),t}(c);t.Attachments=D;var x=function(){function e(e){this.req=null,this.accessToken=null,this.KurveIdentity=null,this.defaultResourceID="https://graph.microsoft.com",this.baseUrl="https://graph.microsoft.com/v1.0/",e.defaultAccessToken?this.accessToken=e.defaultAccessToken:this.KurveIdentity=e.identity}return e.prototype.scopesForV2=function(e){return this.KurveIdentity?this.KurveIdentity.getCurrentOauthVersion()===i.OAuthVersion.v1?null:e:null},e.prototype.meAsync=function(e){var t=new s.Deferred;return this.me(function(e,r){return r?t.reject(r):t.resolve(e)},e),t.promise},e.prototype.me=function(e,t){var r=[n.User.Read],o=this.buildMeUrl("",t);this.getUser(o,e,this.scopesForV2(r))},e.prototype.userAsync=function(e,t,r){void 0===r&&(r=!0);var n=new s.Deferred;return this.user(e,function(e,t){return t?n.reject(t):n.resolve(e)},t,r),n.promise},e.prototype.user=function(e,t,r,o){void 0===o&&(o=!0);var s=o?[n.User.ReadBasicAll]:[n.User.ReadAll],i=this.buildUsersUrl(e,r);this.getUser(i,t,this.scopesForV2(s))},e.prototype.usersAsync=function(e,t){void 0===t&&(t=!0);var r=new s.Deferred;return this.users(function(e,t){return t?r.reject(t):r.resolve(e)},e,t),r.promise},e.prototype.users=function(e,t,r){void 0===r&&(r=!0);var o=r?[n.User.ReadBasicAll]:[n.User.ReadAll],s=this.buildUsersUrl("",t);this.getUsers(s,e,this.scopesForV2(o),r)},e.prototype.groupAsync=function(e,t){var r=new s.Deferred;return this.group(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.group=function(e,t,r){var o=[n.Group.ReadAll],s=this.buildGroupsUrl(e,r);this.getGroup(s,t,this.scopesForV2(o))},e.prototype.groupsAsync=function(e){var t=new s.Deferred;return this.groups(function(e,r){return r?t.reject(r):t.resolve(e)},e),t.promise},e.prototype.groups=function(e,t){var r=[n.Group.ReadAll],o=this.buildGroupsUrl("",t);this.getGroups(o,e,this.scopesForV2(r))},e.prototype.messageForUserAsync=function(e,t,r){var n=new s.Deferred;return this.messageForUser(e,t,function(e,t){return t?n.reject(t):n.resolve(e)},r),n.promise},e.prototype.messageForUser=function(e,t,r,o){var s=[n.Mail.Read],i=this.buildUsersUrl(e+"/messages/"+t,o);this.getMessage(i,t,function(e,t){return r(e,t)},this.scopesForV2(s))},e.prototype.messagesForUserAsync=function(e,t){var r=new s.Deferred;return this.messagesForUser(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.messagesForUser=function(e,t,r){var o=[n.Mail.Read],s=this.buildUsersUrl(e+"/messages",r);this.getMessages(s,function(e,r){return t(e,r)},this.scopesForV2(o))},e.prototype.mailFoldersForUserAsync=function(e,t){var r=new s.Deferred;return this.mailFoldersForUser(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.mailFoldersForUser=function(e,t,r){var o=[n.Mail.Read],s=this.buildUsersUrl(e+"/mailFolders",r);this.getMailFolders(s,function(e,r){return t(e,r)},this.scopesForV2(o))},e.prototype.eventForUserAsync=function(e,t,r){var n=new s.Deferred;return this.eventForUser(e,t,function(e,t){return t?n.reject(t):n.resolve(e)},r),n.promise},e.prototype.eventForUser=function(e,t,r,o){var s=[n.Calendars.Read],i=this.buildUsersUrl(e+"/events/"+t,o);this.getEvent(i,t,function(e,t){return r(e,t)},this.scopesForV2(s))},e.prototype.eventsForUserAsync=function(e,t,r){var n=new s.Deferred;return this.eventsForUser(e,t,function(e,t){return t?n.reject(t):n.resolve(e)},r),n.promise},e.prototype.eventsForUser=function(e,t,r,o){var s=[n.Calendars.Read],i=this.buildUsersUrl(e+"/"+h[t],o);this.getEvents(i,t,function(e,t){return r(e,t)},this.scopesForV2(s))},e.prototype.memberOfForUserAsync=function(e,t){var r=new s.Deferred;return this.memberOfForUser(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.memberOfForUser=function(e,t,r){var o=[n.Group.ReadAll],s=this.buildUsersUrl(e+"/memberOf",r);this.getGroups(s,t,this.scopesForV2(o))},e.prototype.managerForUserAsync=function(e,t){var r=new s.Deferred;return this.managerForUser(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.managerForUser=function(e,t,r){var o=[n.Directory.ReadAll],s=this.buildUsersUrl(e+"/manager",r);this.getUser(s,t,this.scopesForV2(o))},e.prototype.directReportsForUserAsync=function(e,t){var r=new s.Deferred;return this.directReportsForUser(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.directReportsForUser=function(e,t,r){var o=[n.Directory.ReadAll],s=this.buildUsersUrl(e+"/directReports",r);this.getUsers(s,t,this.scopesForV2(o))},e.prototype.profilePhotoForUserAsync=function(e,t){var r=new s.Deferred;return this.profilePhotoForUser(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.profilePhotoForUser=function(e,t,r){var o=[n.User.ReadBasicAll],s=this.buildUsersUrl(e+"/photo",r);this.getPhoto(s,t,this.scopesForV2(o))},e.prototype.profilePhotoValueForUserAsync=function(e,t){var r=new s.Deferred;return this.profilePhotoValueForUser(e,function(e,t){return t?r.reject(t):r.resolve(e)},t),r.promise},e.prototype.profilePhotoValueForUser=function(e,t,r){var o=[n.User.ReadBasicAll],s=this.buildUsersUrl(e+"/photo/$value",r);this.getPhotoValue(s,t,this.scopesForV2(o))},e.prototype.messageAttachmentsForUserAsync=function(e,t,r){var n=new s.Deferred;return this.messageAttachmentsForUser(e,t,function(e,t){return t?n.reject(t):n.resolve(e)},r),n.promise},e.prototype.messageAttachmentsForUser=function(e,t,r,o){var s=[n.Mail.Read],i=this.buildUsersUrl(e+"/messages/"+t+"/attachments",o);this.getMessageAttachments(i,r,this.scopesForV2(s))},e.prototype.messageAttachmentForUserAsync=function(e,t,r,n){var o=new s.Deferred;return this.messageAttachmentForUser(e,t,r,function(e,t){return t?o.reject(t):o.resolve(e)},n),o.promise},e.prototype.messageAttachmentForUser=function(e,t,r,o,s){var i=[n.Mail.Read],a=this.buildUsersUrl(e+"/messages/"+t+"/attachments/"+r,s);this.getMessageAttachment(a,o,this.scopesForV2(i))},e.prototype.getAsync=function(e){var t=new s.Deferred;return this.get(e,function(e,r){return r?t.reject(r):t.resolve(e)}),t.promise},e.prototype.get=function(e,t,r,n){var o=this,s=new XMLHttpRequest;r&&(s.responseType=r),s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(r?s.response:s.responseText,null):t(null,o.generateError(s)))},s.open("GET",e),this.addAccessTokenAndSend(s,function(e){e&&t(null,e)},n)},e.prototype.generateError=function(e){var t=new i.Error;return t.status=e.status,t.statusText=e.statusText,""===e.responseType||"text"===e.responseType?t.text=e.responseText:t.other=e.response,t},e.prototype.getUsers=function(e,t,r,o){var a=this;void 0===o&&(o=!0),this.get(e,function(e,r){if(r)return void t(null,r);var c=JSON.parse(e);if(c.error){var u=new i.Error;return u.other=c.error,void t(null,u)}var l=c.value?c.value:[c],p=new f(a,l.map(function(e){return new d(a,e)})),h=c["@odata.nextLink"];h&&(p.nextLink=function(e){var t=o?[n.User.ReadBasicAll]:[n.User.ReadAll],r=new s.Deferred;return a.getUsers(h,function(t,n){e?e(t,n):n?r.reject(n):r.resolve(t)},a.scopesForV2(t),o),r.promise}),t(p,null)},null,r)},e.prototype.getUser=function(e,t,r){var n=this;this.get(e,function(e,r){if(r)return void t(null,r);var o=JSON.parse(e);if(o.error){var s=new i.Error;return s.other=o.error,void t(null,s)}var a=new d(n,o);t(a,null)},null,r)},e.prototype.addAccessTokenAndSend=function(e,t,r){this.accessToken?(e.setRequestHeader("Authorization","Bearer "+this.accessToken),e.send()):r?this.KurveIdentity.getAccessTokenForScopes(r,!1,function(r,n){n?t(n):(e.setRequestHeader("Authorization","Bearer "+r),e.send(),t(null))}):this.KurveIdentity.getAccessToken(this.defaultResourceID,function(r,n){n?t(n):(e.setRequestHeader("Authorization","Bearer "+r),e.send(),t(null))})},e.prototype.getMessage=function(e,t,r,n){var o=this;this.get(e,function(e,t){if(t)return void r(null,t);var n=JSON.parse(e);if(n.error){var s=new i.Error;return s.other=n.error,void r(null,s)}var a=new m(o,n);r(a,null)},null,n)},e.prototype.getMessages=function(e,t,r){var o=this;this.get(e,function(e,r){if(r)return void t(null,r);var a=JSON.parse(e);if(a.error){var c=new i.Error;return c.other=a.error,void t(null,c)}var u=a.value?a.value:[a],l=new y(o,u.map(function(e){return new m(o,e)})),p=a["@odata.nextLink"];p&&(l.nextLink=function(e){var t=[n.Mail.Read],r=new s.Deferred;return o.getMessages(p,function(t,n){e?e(t,n):n?r.reject(n):r.resolve(t)},o.scopesForV2(t)),r.promise}),t(l,null)},null,r)},e.prototype.getEvent=function(e,t,r,n){var o=this;this.get(e,function(e,t){if(t)return void r(null,t);var n=JSON.parse(e);if(n.error){var s=new i.Error;return s.other=n.error,void r(null,s)}var a=new U(o,n);r(a,null)},null,n)},e.prototype.getEvents=function(e,t,r,o){var a=this;this.get(e,function(e,o){if(o)return void r(null,o);var c=JSON.parse(e);if(c.error){var u=new i.Error;return u.other=c.error,void r(null,u)}var l=c.value?c.value:[c],p=new A(a,t,l.map(function(e){return new U(a,e)})),h=c["@odata.nextLink"];h&&(p.nextLink=function(e){var r=[n.Mail.Read],o=new s.Deferred;return a.getEvents(h,t,function(t,r){e?e(t,r):r?o.reject(r):o.resolve(t)},a.scopesForV2(r)),o.promise}),r(p,null)},null,o)},e.prototype.getGroups=function(e,t,r){var o=this;this.get(e,function(e,r){if(r)return void t(null,r);var a=JSON.parse(e);if(a.error){var c=new i.Error;return c.other=a.error,void t(null,c)}var u=a.value?a.value:[a],l=new F(o,u.map(function(e){return new w(o,e)})),p=a["@odata.nextLink"];p&&(l.nextLink=function(e){var t=[n.Group.ReadAll],r=new s.Deferred;return o.getGroups(p,function(t,n){e?e(t,n):n?r.reject(n):r.resolve(t)},o.scopesForV2(t)),r.promise}),t(l,null)},null,r)},e.prototype.getGroup=function(e,t,r){var n=this;this.get(e,function(e,r){if(r)return void t(null,r);var o=JSON.parse(e);if(o.error){var s=new i.Error;return s.other=o.error,void t(null,s)}var a=new w(n,o);t(a,null)},null,r)},e.prototype.getPhoto=function(e,t,r){var n=this;this.get(e,function(e,r){if(r)return void t(null,r);var o=JSON.parse(e);if(o.error){var s=new i.Error;return s.other=o.error,void t(null,s)}var a=new l(n,o);t(a,null)},null,r)},e.prototype.getPhotoValue=function(e,t,r){this.get(e,function(e,r){return r?void t(null,r):void t(e,null)},"blob",r)},e.prototype.getMailFolders=function(e,t,r){var o=this;this.get(e,function(e,r){if(r)return void t(null,r);var a=JSON.parse(e);if(a.error){var c=new i.Error;c.other=a.error,t(null,c)}var u=a.value?a.value:[a],l=new C(o,u.map(function(e){return new T(o,e)})),p=a["@odata.nextLink"];p&&(l.nextLink=function(e){var t=[n.User.ReadAll],r=new s.Deferred;return o.getMailFolders(p,function(t,n){e?e(t,n):n?r.reject(n):r.resolve(t)},o.scopesForV2(t)),r.promise}),t(l,null)},null,r)},e.prototype.getMessageAttachments=function(e,t,r){var o=this;this.get(e,function(e,r){if(r)return void t(null,r);var a=JSON.parse(e);if(a.error){var c=new i.Error;return c.other=a.error,void t(null,c)}var u=a.value?a.value:[a],l=new D(o,u.map(function(e){return new P(o,e)})),p=a["@odata.nextLink"];p&&(l.nextLink=function(e){var t=[n.Mail.Read],r=new s.Deferred;return o.getMessageAttachments(p,function(t,n){e?e(t,n):n?r.reject(n):r.resolve(t)},o.scopesForV2(t)),r.promise}),t(l,null)},null,r)},e.prototype.getMessageAttachment=function(e,t,r){var n=this;this.get(e,function(e,r){if(r)return void t(null,r);var o=JSON.parse(e);if(o.error){var s=new i.Error;return s.other=o.error,void t(null,s)}var a=new P(n,o);t(a,null)},null,r)},e.prototype.buildUrl=function(e,t,r){return this.baseUrl+e+t+(r?"?"+r:"")},e.prototype.buildMeUrl=function(e,t){return void 0===e&&(e=""),this.buildUrl("me/",e,t)},e.prototype.buildUsersUrl=function(e,t){return void 0===e&&(e=""),this.buildUrl("users/",e,t)},e.prototype.buildGroupsUrl=function(e,t){return void 0===e&&(e=""),this.buildUrl("groups/",e,t)},e}();t.Graph=x},function(e,t){"use strict";function r(e){setTimeout(e,0)}var n;!function(e){e[e.Pending=0]="Pending",e[e.ResolutionInProgress=1]="ResolutionInProgress",e[e.Resolved=2]="Resolved",e[e.Rejected=3]="Rejected"}(n||(n={}));var o=function(){function e(e,t,r){this._dispatcher=e,this._successCB=t,this._errorCB=r,this.result=new s(e)}return e.prototype.resolve=function(e,t){var r=this;return"function"!=typeof this._successCB?void this.result.resolve(e):void(t?this._dispatcher(function(){return r._dispatchCallback(r._successCB,e)}):this._dispatchCallback(this._successCB,e))},e.prototype.reject=function(e,t){var r=this;return"function"!=typeof this._errorCB?void this.result.reject(e):void(t?this._dispatcher(function(){return r._dispatchCallback(r._errorCB,e)}):this._dispatchCallback(this._errorCB,e))},e.prototype._dispatchCallback=function(e,t){var r;try{r=e(t),this.result.resolve(r)}catch(n){return void this.result.reject(n)}},e}(),s=function(){function e(e){this._stack=[],this._state=n.Pending,e?this._dispatcher=e:this._dispatcher=r,this.promise=new i(this)}return e.prototype.DispatchDeferred=function(e){setTimeout(e,0)},e.prototype.then=function(e,t){if("function"!=typeof e&&"function"!=typeof t)return this.promise;var r=new o(this._dispatcher,e,t);switch(this._state){case n.Pending:case n.ResolutionInProgress:this._stack.push(r);break;case n.Resolved:r.resolve(this._value,!0);break;case n.Rejected:r.reject(this._error,!0)}return r.result.promise},e.prototype.resolve=function(e){return this._state!==n.Pending?this:this._resolve(e)},e.prototype._resolve=function(e){var t,r=this,o=typeof e,s=!0;try{if(null===e||"object"!==o&&"function"!==o||"function"!=typeof(t=e.then))this._state=n.ResolutionInProgress,this._dispatcher(function(){r._state=n.Resolved,r._value=e;var t,o=r._stack.length;for(t=0;o>t;t++)r._stack[t].resolve(e,!1);r._stack.splice(0,o)});else{if(e===this.promise)throw new TypeError("recursive resolution");this._state=n.ResolutionInProgress,t.call(e,function(e){s&&(s=!1,r._resolve(e))},function(e){s&&(s=!1,r._reject(e))})}}catch(i){s&&this._reject(i)}return this},e.prototype.reject=function(e){return this._state!==n.Pending?this:this._reject(e)},e.prototype._reject=function(e){var t=this;return this._state=n.ResolutionInProgress,this._dispatcher(function(){t._state=n.Rejected,t._error=e;var r=t._stack.length,o=0;for(o=0;r>o;o++)t._stack[o].reject(e,!1);t._stack.splice(0,r)}),this},e}();t.Deferred=s;var i=function(){function e(e){this._deferred=e}return e.prototype.then=function(e,t){return this._deferred.then(e,t)},e.prototype.fail=function(e){return this._deferred.then(void 0,e)},e}();t.Promise=i},function(e,t,r){"use strict";var n=r(2);!function(e){e[e.v1=1]="v1",e[e.v2=2]="v2"}(t.OAuthVersion||(t.OAuthVersion={}));var o=t.OAuthVersion,s=function(){function e(){}return e}();t.Error=s;var i=function(){function e(e,t,r,n,o){this.id=e,this.scopes=t,this.resource=r,this.token=n,this.expiry=o}return Object.defineProperty(e.prototype,"isExpired",{get:function(){return this.expiry<=new Date((new Date).getTime()+6e4)},enumerable:!0,configurable:!0}),e.prototype.hasScopes=function(e){var t=this;return this.scopes?e.every(function(e){return t.scopes.some(function(t){return e===t})}):!1},e}(),a=function(){function e(e){var t=this;this.tokenStorage=e,this.cachedTokens={},e&&e.getAll().forEach(function(e){var r=e.id,n=e.scopes,o=e.resource,s=e.token,a=e.expiry,c=new i(r,n,o,s,new Date(a));c.isExpired?t.tokenStorage.remove(c.id):t.cachedTokens[c.id]=c})}return e.prototype.add=function(e){this.cachedTokens[e.id]=e,this.tokenStorage&&this.tokenStorage.add(e.id,e)},e.prototype.getForResource=function(e){var t=this.cachedTokens[e];return t&&t.isExpired?(this.remove(e),null):t},e.prototype.getForScopes=function(e){for(var t in this.cachedTokens){var r=this.cachedTokens[t];if(r.hasScopes(e)){if(!r.isExpired)return r;this.remove(t)}}return null},e.prototype.clear=function(){this.cachedTokens={},this.tokenStorage&&this.tokenStorage.clear()},e.prototype.remove=function(e){this.tokenStorage&&this.tokenStorage.remove(e),delete this.cachedTokens[e]},e}(),c=function(){function e(){}return e}();t.IdToken=c;var u=function(){function e(e){var t=this;this.policy="",this.clientId=e.clientId,this.tokenProcessorUrl=e.tokenProcessingUri,e.version?this.version=e.version:this.version=o.v1,this.tokenCache=new a(e.tokenStorage),window.addEventListener("message",function(e){if("id_token"===e.data.type)if(e.data.error){var r=new s;r.text=e.data.error,t.loginCallback(r)}else if(t.state!==e.data.state){var n=new s;n.statusText="Invalid state",t.loginCallback(n)}else t.decodeIdToken(e.data.token),t.loginCallback(null);else if("access_token"===e.data.type)if(e.data.error){var r=new s;r.text=e.data.error,t.getTokenCallback(null,r)}else{var o=e.data.token,i=document.getElementById("tokenIFrame");if(i.parentNode.removeChild(i),e.data.state!==t.state){var n=new s;n.statusText="Invalid state",t.getTokenCallback(null,n)}else t.getTokenCallback(o,null)}})}return e.prototype.checkForIdentityRedirect=function(){function e(e){var t=window.location.href.indexOf(e);if(0>t)return null;var r=window.location.href.indexOf("&",t+e.length);return window.location.href.substring(t,r>0?r:window.location.href.length)}function t(e){var t=e||window.location.search||"",r=[],n={};if(t=t.replace(/.*?\?/,""),t.length){r=t.split("&");for(var o in r){var s=r[o].split("=")[0];s.length&&("undefined"==typeof n[s]&&(n[s]=[]),n[s].push(r[o].split("=")[1]))}}return n}var r=(t(window.location.href),e("#id_token=")),n=e("#access_token");if(r){return this.decodeIdToken(r),this.loginCallback&&this.loginCallback(null),!0}if(n)throw"Should not get here. This should be handled via the iframe approach.";return!1},e.prototype.decodeIdToken=function(e){var t=this,r=this.base64Decode(e.substring(e.indexOf(".")+1,e.lastIndexOf("."))),n=JSON.parse(r),o=new Date(new Date("01/01/1970 0:0 UTC").getTime()+1e3*parseInt(n.exp));this.idToken=new c,this.idToken.FullToken=n,this.idToken.Token=e,this.idToken.Expiry=o,this.idToken.UPN=n.upn,this.idToken.TenantId=n.tid,this.idToken.FamilyName=n.family_name,this.idToken.GivenName=n.given_name,this.idToken.Name=n.name,this.idToken.PreferredUsername=n.preferred_username;var s=o.getTime()-(new Date).getTime()-3e5;this.refreshTimer=setTimeout(function(){t.renewIdToken()},s)},e.prototype.decodeAccessToken=function(e,t,r){var n=this.base64Decode(e.substring(e.indexOf(".")+1,e.lastIndexOf("."))),o=JSON.parse(n),s=new Date(new Date("01/01/1970 0:0 UTC").getTime()+1e3*parseInt(o.exp)),a=t||r.join(" "),c=new i(a,r,t,e,s);this.tokenCache.add(c)},e.prototype.getIdToken=function(){return this.idToken},e.prototype.isLoggedIn=function(){return this.idToken?this.idToken.Expiry>new Date:!1},e.prototype.renewIdToken=function(){clearTimeout(this.refreshTimer),this.login(function(){})},e.prototype.getCurrentOauthVersion=function(){return this.version},e.prototype.getAccessTokenAsync=function(e){var t=new n.Deferred;return this.getAccessToken(e,function(e,r){r?t.reject(r):t.resolve(e)}),t.promise},e.prototype.getAccessToken=function(e,t){var r=this;if(this.version!==o.v1){var n=new s;return n.statusText="Currently this identity class is using v2 OAuth mode. You need to use getAccessTokenForScopes() method",void t(null,n)}var i=this.tokenCache.getForResource(e);if(i)return t(i.token,null);this.getTokenCallback=function(n,o){o?t(null,o):(r.decodeAccessToken(n,e),t(n,null))},this.nonce="token"+this.generateNonce(),this.state="token"+this.generateNonce();var a=document.createElement("iframe");a.style.display="none",a.id="tokenIFrame",a.src=this.tokenProcessorUrl+"?clientId="+encodeURIComponent(this.clientId)+"&resource="+encodeURIComponent(e)+"&redirectUri="+encodeURIComponent(this.tokenProcessorUrl)+"&state="+encodeURIComponent(this.state)+"&version="+encodeURIComponent(this.version.toString())+"&nonce="+encodeURIComponent(this.nonce)+"&op=token",document.body.appendChild(a)},e.prototype.getAccessTokenForScopesAsync=function(e,t){void 0===t&&(t=!1);var r=new n.Deferred;return this.getAccessTokenForScopes(e,t,function(e,t){t?r.reject(t):r.resolve(e)}),r.promise},e.prototype.getAccessTokenForScopes=function(e,t,r){var n=this;if(void 0===t&&(t=!1),this.version!==o.v2){var i=new s;return i.statusText="Dynamic scopes require v2 mode. Currently this identity class is using v1",void r(null,i)}var a=this.tokenCache.getForScopes(e);if(a)return r(a.token,null);if(this.getTokenCallback=function(o,s){s?t||!s.text?r(null,s):s.text.indexOf("AADSTS65001")>=0?n.getAccessTokenForScopes(e,!0,n.getTokenCallback):r(null,s):(n.decodeAccessToken(o,null,e),r(o,null))},this.nonce="token"+this.generateNonce(),this.state="token"+this.generateNonce(),t)window.open(this.tokenProcessorUrl+"?clientId="+encodeURIComponent(this.clientId)+"&scopes="+encodeURIComponent(e.join(" "))+"&redirectUri="+encodeURIComponent(this.tokenProcessorUrl)+"&version="+encodeURIComponent(this.version.toString())+"&state="+encodeURIComponent(this.state)+"&nonce="+encodeURIComponent(this.nonce)+"&op=token","_blank");else{var c=document.createElement("iframe");c.style.display="none",c.id="tokenIFrame",c.src=this.tokenProcessorUrl+"?clientId="+encodeURIComponent(this.clientId)+"&scopes="+encodeURIComponent(e.join(" "))+"&redirectUri="+encodeURIComponent(this.tokenProcessorUrl)+"&version="+encodeURIComponent(this.version.toString())+"&state="+encodeURIComponent(this.state)+"&nonce="+encodeURIComponent(this.nonce)+"&login_hint="+encodeURIComponent(this.idToken.PreferredUsername)+"&domain_hint="+encodeURIComponent("9188040d-6c67-4c5b-b112-36a304b66dad"===this.idToken.TenantId?"consumers":"organizations")+"&op=token",document.body.appendChild(c)}},e.prototype.loginAsync=function(e){var t=new n.Deferred;return this.login(function(e){e?t.reject(e):t.resolve(null)},e),t.promise},e.prototype.login=function(e,t){if(this.loginCallback=e,t||(t={}),t.policy&&(this.policy=t.policy),t.scopes&&this.version===o.v1){var r=new s;return r.text="Scopes can only be used with OAuth v2.",void e(r)}if(t.policy&&!t.tenant){var r=new s;return r.text="In order to use policy (AAD B2C) a tenant must be specified as well.",void e(r)}this.state="login"+this.generateNonce(),this.nonce="login"+this.generateNonce();var n=this.tokenProcessorUrl+"?clientId="+encodeURIComponent(this.clientId)+"&redirectUri="+encodeURIComponent(this.tokenProcessorUrl)+"&state="+encodeURIComponent(this.state)+"&nonce="+encodeURIComponent(this.nonce)+"&version="+encodeURIComponent(this.version.toString())+"&op=login&p="+encodeURIComponent(this.policy);t.tenant&&(n+="&tenant="+encodeURIComponent(t.tenant)),this.version===o.v2&&(t.scopes||(t.scopes=[]),t.scopes.indexOf("profile")<0&&t.scopes.push("profile"),t.scopes.indexOf("openid")<0&&t.scopes.push("openid"),n+="&scopes="+encodeURIComponent(t.scopes.join(" "))),window.open(n,"_blank")},e.prototype.loginNoWindowAsync=function(e){var t=new n.Deferred;return this.loginNoWindow(function(e){e?t.reject(e):t.resolve(null)},e),t.promise},e.prototype.loginNoWindow=function(e,t){this.loginCallback=e,this.state="clientId="+this.clientId+"&tokenProcessorUrl="+this.tokenProcessorUrl,this.nonce=this.generateNonce();var r=this.checkForIdentityRedirect();if(!r){var n=t?t:window.location.href.split("#")[0],o="https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token&client_id="+encodeURIComponent(this.clientId)+"&redirect_uri="+encodeURIComponent(n)+"&state="+encodeURIComponent(this.state)+"&nonce="+encodeURIComponent(this.nonce);window.location.href=o}},e.prototype.logOut=function(){this.tokenCache.clear();var e="https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri="+encodeURI(window.location.href);window.location.href=e},e.prototype.base64Decode=function(e){var t,r,n,o,s={},i=0,a=0,c="",u=String.fromCharCode,l=e.length,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(t=0;64>t;t++)s[p.charAt(t)]=t;for(n=0;l>n;n++)for(r=s[e.charAt(n)],i=(i<<6)+r,a+=6;a>=8;)((o=i>>>(a-=8)&255)||l-2>n)&&(c+=u(o));return c},e.prototype.generateNonce=function(){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=0;32>r;r++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},e}();t.Identity=u}])}); +//# sourceMappingURL=kurve.min.js.map \ No newline at end of file diff --git a/dist/kurve.min.js.map b/dist/kurve.min.js.map new file mode 100644 index 00000000..e2356a6b --- /dev/null +++ b/dist/kurve.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///dist/kurve.min.js","webpack:///webpack/bootstrap ea984da496e148599765","webpack:///./src/kurve.ts","webpack:///./src/graph.ts","webpack:///./src/promises.ts","webpack:///./src/identity.ts"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","graph_1","identity_1","Graph","Identity","Scopes","__extends","d","b","__","constructor","hasOwnProperty","prototype","Object","create","promises_1","Util","rootUrl","General","OpenId","OfflineAccess","User","Read","ReadWrite","ReadBasicAll","ReadAll","ReadWriteAll","Contacts","Directory","AccessAsUserAll","Group","Mail","Send","Calendars","Files","ReadWriteAppFolder","ReadWriteSelected","Tasks","People","Notes","Create","ReadWriteCreatedByApp","DataModelWrapper","graph","_data","defineProperty","get","enumerable","configurable","DataModelListWrapper","_super","apply","arguments","ProfilePhotoDataModel","ProfilePhoto","UserDataModel","EventsEndpoint","events","callback","odataQuery","eventsForUser","userPrincipalName","eventsAsync","eventsForUserAsync","memberOf","Error","memberOfForUser","memberOfAsync","memberOfForUserAsync","messages","messagesForUser","messagesAsync","messagesForUserAsync","manager","managerForUser","managerAsync","managerForUserAsync","profilePhoto","profilePhotoForUser","profilePhotoAsync","profilePhotoForUserAsync","profilePhotoValue","profilePhotoValueForUser","profilePhotoValueAsync","profilePhotoValueForUserAsync","calendarView","calendarViewAsync","mailFolders","mailFoldersForUser","mailFoldersAsync","mailFoldersForUserAsync","message","messageId","messageForUser","messageAsync","messageForUserAsync","event","eventId","eventForUser","eventAsync","eventForUserAsync","messageAttachment","attachmentId","messageAttachmentForUser","messageAttachmentAsync","messageAttachmentForUserAsync","Users","MessageDataModel","Message","Messages","EventDataModel","Event","Events","endpoint","Contact","GroupDataModel","Groups","MailFolderDataModel","MailFolder","MailFolders","AttachmentType","AttachmentDataModel","Attachment","getType","fileAttachment","itemAttachment","referenceAttachment","Attachments","identityInfo","req","accessToken","KurveIdentity","defaultResourceID","baseUrl","defaultAccessToken","identity","scopesForV2","scopes","getCurrentOauthVersion","OAuthVersion","v1","meAsync","Deferred","me","user","error","reject","resolve","promise","urlString","buildMeUrl","getUser","userAsync","userId","basicProfileOnly","buildUsersUrl","usersAsync","users","getUsers","groupAsync","groupId","group","buildGroupsUrl","getGroup","groupsAsync","groups","getGroups","getMessage","result","getMessages","getMailFolders","getEvent","getEvents","directReportsForUserAsync","directReportsForUser","getPhoto","getPhotoValue","messageAttachmentsForUserAsync","messageAttachmentsForUser","getMessageAttachments","attachment","getMessageAttachment","getAsync","url","response","responseType","_this","xhr","XMLHttpRequest","onreadystatechange","readyState","status","responseText","generateError","open","addAccessTokenAndSend","addTokenError","statusText","text","other","errorGet","usersODATA","JSON","parse","errorODATA","resultsArray","value","map","o","nextLink","userODATA","setRequestHeader","send","getAccessTokenForScopes","token","getAccessToken","ODATA","ODATAError","messagesODATA","EventId","odata","groupsODATA","photo","attachmentsODATA","attachments","buildUrl","path","DispatchDeferred","closure","setTimeout","PromiseState","Client","_dispatcher","_successCB","_errorCB","defer","_dispatchCallback","arg","err","dispatcher","_stack","_state","Pending","Promise","then","successCB","errorCB","client","ResolutionInProgress","push","Resolved","_value","Rejected","_error","_resolve","type","pending","i","stackSize","length","splice","TypeError","_reject","_deferred","successCallback","errorCallback","fail","undefined","CachedToken","resource","expiry","Date","getTime","hasScopes","requiredScopes","every","requiredScope","some","actualScope","TokenCache","tokenStorage","cachedTokens","getAll","forEach","_a","cachedToken","isExpired","remove","add","getForResource","getForScopes","key","clear","IdToken","identitySettings","policy","clientId","tokenProcessorUrl","tokenProcessingUri","version","tokenCache","window","addEventListener","data","e","loginCallback","state","decodeIdToken","getTokenCallback","iframe","document","getElementById","parentNode","removeChild","checkForIdentityRedirect","s","start","location","href","indexOf","end","substring","parseQueryString","str","queryString","search","keyValPairs","params","replace","split","pairNum","idToken","decodedToken","base64Decode","lastIndexOf","decodedTokenJSON","expiryDate","parseInt","exp","FullToken","Token","Expiry","UPN","upn","TenantId","tid","FamilyName","family_name","GivenName","given_name","Name","name","PreferredUsername","preferred_username","expiration","refreshTimer","renewIdToken","decodeAccessToken","join","getIdToken","isLoggedIn","clearTimeout","login","getAccessTokenAsync","nonce","generateNonce","createElement","style","display","src","encodeURIComponent","toString","body","appendChild","getAccessTokenForScopesAsync","promptForConsent","v2","loginAsync","loginSettings","tenant","loginURL","loginNoWindowAsync","toUrl","loginNoWindow","redirected","redirectUri","logOut","encodeURI","encodedString","x","a","l","r","w","String","fromCharCode","L","A","charAt","chars","Math","floor","random"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,MAAAD,IAEAD,EAAA,MAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAA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C,GAAA,EAAAH,EAAAjF,OAAAgB,SAAAC,KAAAW,MAAA,QACAlJ,EAAA,8FACA2L,mBAAA5X,KAAAkT,UACA,iBAAA0E,mBAAAe,GACA,UAAAf,mBAAA5X,KAAA4T,OACA,UAAAgE,mBAAA5X,KAAAsX,MACA/D,QAAAgB,SAAAC,KAAAvI,IAGAnL,EAAAQ,UAAAsX,OAAA,WACA5Y,KAAAsT,WAAAR,OACA,IAAA7G,GAAA,mFAAA4M,UAAAtF,OAAAgB,SAAAC,KACAjB,QAAAgB,SAAAC,KAAAvI,GAEAnL,EAAAQ,UAAAiU,aAAA,SAAAuD,GACA,GAAkBnI,GAAAlQ,EAAAsY,EAAAC,EAAlBtF,KAAkBxS,EAAA,EAAA+X,EAAA,EAAAC,EAAA,GAAAC,EAAAC,OAAAC,aAAAC,EAAAR,EAAAjI,OAClB0I,EAAA,kEACA,KAAA5I,EAAA,EAAmB,GAAAA,EAAQA,IAC3B+C,EAAA6F,EAAAC,OAAA7I,KAEA,KAAAoI,EAAA,EAAmBO,EAAAP,EAAOA,IAI1B,IAHAtY,EAAAiT,EAAAoF,EAAAU,OAAAT,IACA7X,MAAA,GAAAT,EACAwY,GAAA,EACAA,GAAA,KACAD,EAAA9X,KAAA+X,GAAA,SAAAK,EAAA,EAAAP,KAAAG,GAAAC,EAAAH,GAGA,OAAAE,IAEApY,EAAAQ,UAAAiW,cAAA,WAGA,OAFAvK,GAAA,GACAyM,EAAA,iEACA9I,EAAA,EAAuB,GAAAA,EAAQA,IAC/B3D,GAAAyM,EAAAD,OAAAE,KAAAC,MAAAD,KAAAE,SAAAH,EAAA5I,QAEA,OAAA7D,IAEAlM,IAEAlB,GAAAkB","file":"dist/kurve.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Kurve\"] = factory();\n\telse\n\t\troot[\"Kurve\"] = factory();\n})(this, function() {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Kurve\"] = factory();\n\telse\n\t\troot[\"Kurve\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\tvar graph_1 = __webpack_require__(1);\n\tvar identity_1 = __webpack_require__(3);\n\tmodule.exports = {\n\t Graph: graph_1.Graph,\n\t Identity: identity_1.Identity\n\t};\n\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\tvar __extends = (this && this.__extends) || function (d, b) {\n\t for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n\t function __() { this.constructor = d; }\n\t d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n\t};\n\tvar promises_1 = __webpack_require__(2);\n\tvar identity_1 = __webpack_require__(3);\n\tvar Scopes;\n\t(function (Scopes) {\n\t var Util = (function () {\n\t function Util() {\n\t }\n\t Util.rootUrl = \"https://graph.microsoft.com/\";\n\t return Util;\n\t }());\n\t var General = (function () {\n\t function General() {\n\t }\n\t General.OpenId = \"openid\";\n\t General.OfflineAccess = \"offline_access\";\n\t return General;\n\t }());\n\t Scopes.General = General;\n\t var User = (function () {\n\t function User() {\n\t }\n\t User.Read = Util.rootUrl + \"User.Read\";\n\t User.ReadWrite = Util.rootUrl + \"User.ReadWrite\";\n\t User.ReadBasicAll = Util.rootUrl + \"User.ReadBasic.All\";\n\t User.ReadAll = Util.rootUrl + \"User.Read.All\";\n\t User.ReadWriteAll = Util.rootUrl + \"User.ReadWrite.All\";\n\t return User;\n\t }());\n\t Scopes.User = User;\n\t var Contacts = (function () {\n\t function Contacts() {\n\t }\n\t Contacts.Read = Util.rootUrl + \"Contacts.Read\";\n\t Contacts.ReadWrite = Util.rootUrl + \"Contacts.ReadWrite\";\n\t return Contacts;\n\t }());\n\t Scopes.Contacts = Contacts;\n\t var Directory = (function () {\n\t function Directory() {\n\t }\n\t Directory.ReadAll = Util.rootUrl + \"Directory.Read.All\";\n\t Directory.ReadWriteAll = Util.rootUrl + \"Directory.ReadWrite.All\";\n\t Directory.AccessAsUserAll = Util.rootUrl + \"Directory.AccessAsUser.All\";\n\t return Directory;\n\t }());\n\t Scopes.Directory = Directory;\n\t var Group = (function () {\n\t function Group() {\n\t }\n\t Group.ReadAll = Util.rootUrl + \"Group.Read.All\";\n\t Group.ReadWriteAll = Util.rootUrl + \"Group.ReadWrite.All\";\n\t Group.AccessAsUserAll = Util.rootUrl + \"Directory.AccessAsUser.All\";\n\t return Group;\n\t }());\n\t Scopes.Group = Group;\n\t var Mail = (function () {\n\t function Mail() {\n\t }\n\t Mail.Read = Util.rootUrl + \"Mail.Read\";\n\t Mail.ReadWrite = Util.rootUrl + \"Mail.ReadWrite\";\n\t Mail.Send = Util.rootUrl + \"Mail.Send\";\n\t return Mail;\n\t }());\n\t Scopes.Mail = Mail;\n\t var Calendars = (function () {\n\t function Calendars() {\n\t }\n\t Calendars.Read = Util.rootUrl + \"Calendars.Read\";\n\t Calendars.ReadWrite = Util.rootUrl + \"Calendars.ReadWrite\";\n\t return Calendars;\n\t }());\n\t Scopes.Calendars = Calendars;\n\t var Files = (function () {\n\t function Files() {\n\t }\n\t Files.Read = Util.rootUrl + \"Files.Read\";\n\t Files.ReadAll = Util.rootUrl + \"Files.Read.All\";\n\t Files.ReadWrite = Util.rootUrl + \"Files.ReadWrite\";\n\t Files.ReadWriteAppFolder = Util.rootUrl + \"Files.ReadWrite.AppFolder\";\n\t Files.ReadWriteSelected = Util.rootUrl + \"Files.ReadWrite.Selected\";\n\t return Files;\n\t }());\n\t Scopes.Files = Files;\n\t var Tasks = (function () {\n\t function Tasks() {\n\t }\n\t Tasks.ReadWrite = Util.rootUrl + \"Tasks.ReadWrite\";\n\t return Tasks;\n\t }());\n\t Scopes.Tasks = Tasks;\n\t var People = (function () {\n\t function People() {\n\t }\n\t People.Read = Util.rootUrl + \"People.Read\";\n\t People.ReadWrite = Util.rootUrl + \"People.ReadWrite\";\n\t return People;\n\t }());\n\t Scopes.People = People;\n\t var Notes = (function () {\n\t function Notes() {\n\t }\n\t Notes.Create = Util.rootUrl + \"Notes.Create\";\n\t Notes.ReadWriteCreatedByApp = Util.rootUrl + \"Notes.ReadWrite.CreatedByApp\";\n\t Notes.Read = Util.rootUrl + \"Notes.Read\";\n\t Notes.ReadAll = Util.rootUrl + \"Notes.Read.All\";\n\t Notes.ReadWriteAll = Util.rootUrl + \"Notes.ReadWrite.All\";\n\t return Notes;\n\t }());\n\t Scopes.Notes = Notes;\n\t})(Scopes = exports.Scopes || (exports.Scopes = {}));\n\tvar DataModelWrapper = (function () {\n\t function DataModelWrapper(graph, _data) {\n\t this.graph = graph;\n\t this._data = _data;\n\t }\n\t Object.defineProperty(DataModelWrapper.prototype, \"data\", {\n\t get: function () { return this._data; },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t return DataModelWrapper;\n\t}());\n\texports.DataModelWrapper = DataModelWrapper;\n\tvar DataModelListWrapper = (function (_super) {\n\t __extends(DataModelListWrapper, _super);\n\t function DataModelListWrapper() {\n\t _super.apply(this, arguments);\n\t }\n\t return DataModelListWrapper;\n\t}(DataModelWrapper));\n\texports.DataModelListWrapper = DataModelListWrapper;\n\tvar ProfilePhotoDataModel = (function () {\n\t function ProfilePhotoDataModel() {\n\t }\n\t return ProfilePhotoDataModel;\n\t}());\n\texports.ProfilePhotoDataModel = ProfilePhotoDataModel;\n\tvar ProfilePhoto = (function (_super) {\n\t __extends(ProfilePhoto, _super);\n\t function ProfilePhoto() {\n\t _super.apply(this, arguments);\n\t }\n\t return ProfilePhoto;\n\t}(DataModelWrapper));\n\texports.ProfilePhoto = ProfilePhoto;\n\tvar UserDataModel = (function () {\n\t function UserDataModel() {\n\t }\n\t return UserDataModel;\n\t}());\n\texports.UserDataModel = UserDataModel;\n\t(function (EventsEndpoint) {\n\t EventsEndpoint[EventsEndpoint[\"events\"] = 0] = \"events\";\n\t EventsEndpoint[EventsEndpoint[\"calendarView\"] = 1] = \"calendarView\";\n\t})(exports.EventsEndpoint || (exports.EventsEndpoint = {}));\n\tvar EventsEndpoint = exports.EventsEndpoint;\n\tvar User = (function (_super) {\n\t __extends(User, _super);\n\t function User() {\n\t _super.apply(this, arguments);\n\t }\n\t User.prototype.events = function (callback, odataQuery) {\n\t this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.events, callback, odataQuery);\n\t };\n\t User.prototype.eventsAsync = function (odataQuery) {\n\t return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.events, odataQuery);\n\t };\n\t User.prototype.memberOf = function (callback, Error, odataQuery) {\n\t this.graph.memberOfForUser(this._data.userPrincipalName, callback, odataQuery);\n\t };\n\t User.prototype.memberOfAsync = function (odataQuery) {\n\t return this.graph.memberOfForUserAsync(this._data.userPrincipalName, odataQuery);\n\t };\n\t User.prototype.messages = function (callback, odataQuery) {\n\t this.graph.messagesForUser(this._data.userPrincipalName, callback, odataQuery);\n\t };\n\t User.prototype.messagesAsync = function (odataQuery) {\n\t return this.graph.messagesForUserAsync(this._data.userPrincipalName, odataQuery);\n\t };\n\t User.prototype.manager = function (callback, odataQuery) {\n\t this.graph.managerForUser(this._data.userPrincipalName, callback, odataQuery);\n\t };\n\t User.prototype.managerAsync = function (odataQuery) {\n\t return this.graph.managerForUserAsync(this._data.userPrincipalName, odataQuery);\n\t };\n\t User.prototype.profilePhoto = function (callback, odataQuery) {\n\t this.graph.profilePhotoForUser(this._data.userPrincipalName, callback, odataQuery);\n\t };\n\t User.prototype.profilePhotoAsync = function (odataQuery) {\n\t return this.graph.profilePhotoForUserAsync(this._data.userPrincipalName, odataQuery);\n\t };\n\t User.prototype.profilePhotoValue = function (callback, odataQuery) {\n\t this.graph.profilePhotoValueForUser(this._data.userPrincipalName, callback, odataQuery);\n\t };\n\t User.prototype.profilePhotoValueAsync = function (odataQuery) {\n\t return this.graph.profilePhotoValueForUserAsync(this._data.userPrincipalName, odataQuery);\n\t };\n\t User.prototype.calendarView = function (callback, odataQuery) {\n\t this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.calendarView, callback, odataQuery);\n\t };\n\t User.prototype.calendarViewAsync = function (odataQuery) {\n\t return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.calendarView, odataQuery);\n\t };\n\t User.prototype.mailFolders = function (callback, odataQuery) {\n\t this.graph.mailFoldersForUser(this._data.userPrincipalName, callback, odataQuery);\n\t };\n\t User.prototype.mailFoldersAsync = function (odataQuery) {\n\t return this.graph.mailFoldersForUserAsync(this._data.userPrincipalName, odataQuery);\n\t };\n\t User.prototype.message = function (messageId, callback, odataQuery) {\n\t this.graph.messageForUser(this._data.userPrincipalName, messageId, callback, odataQuery);\n\t };\n\t User.prototype.messageAsync = function (messageId, odataQuery) {\n\t return this.graph.messageForUserAsync(this._data.userPrincipalName, messageId, odataQuery);\n\t };\n\t User.prototype.event = function (eventId, callback, odataQuery) {\n\t this.graph.eventForUser(this._data.userPrincipalName, eventId, callback, odataQuery);\n\t };\n\t User.prototype.eventAsync = function (eventId, odataQuery) {\n\t return this.graph.eventForUserAsync(this._data.userPrincipalName, eventId, odataQuery);\n\t };\n\t User.prototype.messageAttachment = function (messageId, attachmentId, callback, odataQuery) {\n\t this.graph.messageAttachmentForUser(this._data.userPrincipalName, messageId, attachmentId, callback, odataQuery);\n\t };\n\t User.prototype.messageAttachmentAsync = function (messageId, attachmentId, odataQuery) {\n\t return this.graph.messageAttachmentForUserAsync(this._data.userPrincipalName, messageId, attachmentId, odataQuery);\n\t };\n\t return User;\n\t}(DataModelWrapper));\n\texports.User = User;\n\tvar Users = (function (_super) {\n\t __extends(Users, _super);\n\t function Users() {\n\t _super.apply(this, arguments);\n\t }\n\t return Users;\n\t}(DataModelListWrapper));\n\texports.Users = Users;\n\tvar MessageDataModel = (function () {\n\t function MessageDataModel() {\n\t }\n\t return MessageDataModel;\n\t}());\n\texports.MessageDataModel = MessageDataModel;\n\tvar Message = (function (_super) {\n\t __extends(Message, _super);\n\t function Message() {\n\t _super.apply(this, arguments);\n\t }\n\t return Message;\n\t}(DataModelWrapper));\n\texports.Message = Message;\n\tvar Messages = (function (_super) {\n\t __extends(Messages, _super);\n\t function Messages() {\n\t _super.apply(this, arguments);\n\t }\n\t return Messages;\n\t}(DataModelListWrapper));\n\texports.Messages = Messages;\n\tvar EventDataModel = (function () {\n\t function EventDataModel() {\n\t }\n\t return EventDataModel;\n\t}());\n\texports.EventDataModel = EventDataModel;\n\tvar Event = (function (_super) {\n\t __extends(Event, _super);\n\t function Event() {\n\t _super.apply(this, arguments);\n\t }\n\t return Event;\n\t}(DataModelWrapper));\n\texports.Event = Event;\n\tvar Events = (function (_super) {\n\t __extends(Events, _super);\n\t function Events(graph, endpoint, _data) {\n\t _super.call(this, graph, _data);\n\t this.graph = graph;\n\t this.endpoint = endpoint;\n\t this._data = _data;\n\t }\n\t return Events;\n\t}(DataModelListWrapper));\n\texports.Events = Events;\n\tvar Contact = (function () {\n\t function Contact() {\n\t }\n\t return Contact;\n\t}());\n\texports.Contact = Contact;\n\tvar GroupDataModel = (function () {\n\t function GroupDataModel() {\n\t }\n\t return GroupDataModel;\n\t}());\n\texports.GroupDataModel = GroupDataModel;\n\tvar Group = (function (_super) {\n\t __extends(Group, _super);\n\t function Group() {\n\t _super.apply(this, arguments);\n\t }\n\t return Group;\n\t}(DataModelWrapper));\n\texports.Group = Group;\n\tvar Groups = (function (_super) {\n\t __extends(Groups, _super);\n\t function Groups() {\n\t _super.apply(this, arguments);\n\t }\n\t return Groups;\n\t}(DataModelListWrapper));\n\texports.Groups = Groups;\n\tvar MailFolderDataModel = (function () {\n\t function MailFolderDataModel() {\n\t }\n\t return MailFolderDataModel;\n\t}());\n\texports.MailFolderDataModel = MailFolderDataModel;\n\tvar MailFolder = (function (_super) {\n\t __extends(MailFolder, _super);\n\t function MailFolder() {\n\t _super.apply(this, arguments);\n\t }\n\t return MailFolder;\n\t}(DataModelWrapper));\n\texports.MailFolder = MailFolder;\n\tvar MailFolders = (function (_super) {\n\t __extends(MailFolders, _super);\n\t function MailFolders() {\n\t _super.apply(this, arguments);\n\t }\n\t return MailFolders;\n\t}(DataModelListWrapper));\n\texports.MailFolders = MailFolders;\n\t(function (AttachmentType) {\n\t AttachmentType[AttachmentType[\"fileAttachment\"] = 0] = \"fileAttachment\";\n\t AttachmentType[AttachmentType[\"itemAttachment\"] = 1] = \"itemAttachment\";\n\t AttachmentType[AttachmentType[\"referenceAttachment\"] = 2] = \"referenceAttachment\";\n\t})(exports.AttachmentType || (exports.AttachmentType = {}));\n\tvar AttachmentType = exports.AttachmentType;\n\tvar AttachmentDataModel = (function () {\n\t function AttachmentDataModel() {\n\t }\n\t return AttachmentDataModel;\n\t}());\n\texports.AttachmentDataModel = AttachmentDataModel;\n\tvar Attachment = (function (_super) {\n\t __extends(Attachment, _super);\n\t function Attachment() {\n\t _super.apply(this, arguments);\n\t }\n\t Attachment.prototype.getType = function () {\n\t switch (this._data['@odata.type']) {\n\t case \"#microsoft.graph.fileAttachment\":\n\t return AttachmentType.fileAttachment;\n\t case \"#microsoft.graph.itemAttachment\":\n\t return AttachmentType.itemAttachment;\n\t case \"#microsoft.graph.referenceAttachment\":\n\t return AttachmentType.referenceAttachment;\n\t }\n\t };\n\t return Attachment;\n\t}(DataModelWrapper));\n\texports.Attachment = Attachment;\n\tvar Attachments = (function (_super) {\n\t __extends(Attachments, _super);\n\t function Attachments() {\n\t _super.apply(this, arguments);\n\t }\n\t return Attachments;\n\t}(DataModelListWrapper));\n\texports.Attachments = Attachments;\n\tvar Graph = (function () {\n\t function Graph(identityInfo) {\n\t this.req = null;\n\t this.accessToken = null;\n\t this.KurveIdentity = null;\n\t this.defaultResourceID = \"https://graph.microsoft.com\";\n\t this.baseUrl = \"https://graph.microsoft.com/v1.0/\";\n\t if (identityInfo.defaultAccessToken) {\n\t this.accessToken = identityInfo.defaultAccessToken;\n\t }\n\t else {\n\t this.KurveIdentity = identityInfo.identity;\n\t }\n\t }\n\t Graph.prototype.scopesForV2 = function (scopes) {\n\t if (!this.KurveIdentity)\n\t return null;\n\t if (this.KurveIdentity.getCurrentOauthVersion() === identity_1.OAuthVersion.v1)\n\t return null;\n\t else\n\t return scopes;\n\t };\n\t Graph.prototype.meAsync = function (odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.me(function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.me = function (callback, odataQuery) {\n\t var scopes = [Scopes.User.Read];\n\t var urlString = this.buildMeUrl(\"\", odataQuery);\n\t this.getUser(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.userAsync = function (userId, odataQuery, basicProfileOnly) {\n\t if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n\t var d = new promises_1.Deferred();\n\t this.user(userId, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery, basicProfileOnly);\n\t return d.promise;\n\t };\n\t Graph.prototype.user = function (userId, callback, odataQuery, basicProfileOnly) {\n\t if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n\t var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n\t var urlString = this.buildUsersUrl(userId, odataQuery);\n\t this.getUser(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.usersAsync = function (odataQuery, basicProfileOnly) {\n\t if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n\t var d = new promises_1.Deferred();\n\t this.users(function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery, basicProfileOnly);\n\t return d.promise;\n\t };\n\t Graph.prototype.users = function (callback, odataQuery, basicProfileOnly) {\n\t if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n\t var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n\t var urlString = this.buildUsersUrl(\"\", odataQuery);\n\t this.getUsers(urlString, callback, this.scopesForV2(scopes), basicProfileOnly);\n\t };\n\t Graph.prototype.groupAsync = function (groupId, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.group(groupId, function (group, error) { return error ? d.reject(error) : d.resolve(group); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.group = function (groupId, callback, odataQuery) {\n\t var scopes = [Scopes.Group.ReadAll];\n\t var urlString = this.buildGroupsUrl(groupId, odataQuery);\n\t this.getGroup(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.groupsAsync = function (odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.groups(function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.groups = function (callback, odataQuery) {\n\t var scopes = [Scopes.Group.ReadAll];\n\t var urlString = this.buildGroupsUrl(\"\", odataQuery);\n\t this.getGroups(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.messageForUserAsync = function (userPrincipalName, messageId, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.messageForUser(userPrincipalName, messageId, function (message, error) { return error ? d.reject(error) : d.resolve(message); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.messageForUser = function (userPrincipalName, messageId, callback, odataQuery) {\n\t var scopes = [Scopes.Mail.Read];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId, odataQuery);\n\t this.getMessage(urlString, messageId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.messagesForUserAsync = function (userPrincipalName, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.messagesForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.messagesForUser = function (userPrincipalName, callback, odataQuery) {\n\t var scopes = [Scopes.Mail.Read];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/messages\", odataQuery);\n\t this.getMessages(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.mailFoldersForUserAsync = function (userPrincipalName, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.mailFoldersForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.mailFoldersForUser = function (userPrincipalName, callback, odataQuery) {\n\t var scopes = [Scopes.Mail.Read];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/mailFolders\", odataQuery);\n\t this.getMailFolders(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.eventForUserAsync = function (userPrincipalName, eventId, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.eventForUser(userPrincipalName, eventId, function (event, error) { return error ? d.reject(error) : d.resolve(event); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.eventForUser = function (userPrincipalName, eventId, callback, odataQuery) {\n\t var scopes = [Scopes.Calendars.Read];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/events/\" + eventId, odataQuery);\n\t this.getEvent(urlString, eventId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.eventsForUserAsync = function (userPrincipalName, endpoint, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.eventsForUser(userPrincipalName, endpoint, function (events, error) { return error ? d.reject(error) : d.resolve(events); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.eventsForUser = function (userPrincipalName, endpoint, callback, odataQuery) {\n\t var scopes = [Scopes.Calendars.Read];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/\" + EventsEndpoint[endpoint], odataQuery);\n\t this.getEvents(urlString, endpoint, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.memberOfForUserAsync = function (userPrincipalName, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.memberOfForUser(userPrincipalName, function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.memberOfForUser = function (userPrincipalName, callback, odataQuery) {\n\t var scopes = [Scopes.Group.ReadAll];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/memberOf\", odataQuery);\n\t this.getGroups(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.managerForUserAsync = function (userPrincipalName, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.managerForUser(userPrincipalName, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.managerForUser = function (userPrincipalName, callback, odataQuery) {\n\t var scopes = [Scopes.Directory.ReadAll];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/manager\", odataQuery);\n\t this.getUser(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.directReportsForUserAsync = function (userPrincipalName, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.directReportsForUser(userPrincipalName, function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.directReportsForUser = function (userPrincipalName, callback, odataQuery) {\n\t var scopes = [Scopes.Directory.ReadAll];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/directReports\", odataQuery);\n\t this.getUsers(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.profilePhotoForUserAsync = function (userPrincipalName, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.profilePhotoForUser(userPrincipalName, function (profilePhoto, error) { return error ? d.reject(error) : d.resolve(profilePhoto); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.profilePhotoForUser = function (userPrincipalName, callback, odataQuery) {\n\t var scopes = [Scopes.User.ReadBasicAll];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/photo\", odataQuery);\n\t this.getPhoto(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.profilePhotoValueForUserAsync = function (userPrincipalName, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.profilePhotoValueForUser(userPrincipalName, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.profilePhotoValueForUser = function (userPrincipalName, callback, odataQuery) {\n\t var scopes = [Scopes.User.ReadBasicAll];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/photo/$value\", odataQuery);\n\t this.getPhotoValue(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.messageAttachmentsForUserAsync = function (userPrincipalName, messageId, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.messageAttachmentsForUser(userPrincipalName, messageId, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.messageAttachmentsForUser = function (userPrincipalName, messageId, callback, odataQuery) {\n\t var scopes = [Scopes.Mail.Read];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId + \"/attachments\", odataQuery);\n\t this.getMessageAttachments(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.messageAttachmentForUserAsync = function (userPrincipalName, messageId, attachmentId, odataQuery) {\n\t var d = new promises_1.Deferred();\n\t this.messageAttachmentForUser(userPrincipalName, messageId, attachmentId, function (attachment, error) { return error ? d.reject(error) : d.resolve(attachment); }, odataQuery);\n\t return d.promise;\n\t };\n\t Graph.prototype.messageAttachmentForUser = function (userPrincipalName, messageId, attachmentId, callback, odataQuery) {\n\t var scopes = [Scopes.Mail.Read];\n\t var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId + \"/attachments/\" + attachmentId, odataQuery);\n\t this.getMessageAttachment(urlString, callback, this.scopesForV2(scopes));\n\t };\n\t Graph.prototype.getAsync = function (url) {\n\t var d = new promises_1.Deferred();\n\t this.get(url, function (response, error) { return error ? d.reject(error) : d.resolve(response); });\n\t return d.promise;\n\t };\n\t Graph.prototype.get = function (url, callback, responseType, scopes) {\n\t var _this = this;\n\t var xhr = new XMLHttpRequest();\n\t if (responseType)\n\t xhr.responseType = responseType;\n\t xhr.onreadystatechange = function () {\n\t if (xhr.readyState === 4)\n\t if (xhr.status === 200)\n\t callback(responseType ? xhr.response : xhr.responseText, null);\n\t else\n\t callback(null, _this.generateError(xhr));\n\t };\n\t xhr.open(\"GET\", url);\n\t this.addAccessTokenAndSend(xhr, function (addTokenError) {\n\t if (addTokenError) {\n\t callback(null, addTokenError);\n\t }\n\t }, scopes);\n\t };\n\t Graph.prototype.generateError = function (xhr) {\n\t var response = new identity_1.Error();\n\t response.status = xhr.status;\n\t response.statusText = xhr.statusText;\n\t if (xhr.responseType === '' || xhr.responseType === 'text')\n\t response.text = xhr.responseText;\n\t else\n\t response.other = xhr.response;\n\t return response;\n\t };\n\t Graph.prototype.getUsers = function (urlString, callback, scopes, basicProfileOnly) {\n\t var _this = this;\n\t if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var usersODATA = JSON.parse(result);\n\t if (usersODATA.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = usersODATA.error;\n\t callback(null, errorODATA);\n\t return;\n\t }\n\t var resultsArray = (usersODATA.value ? usersODATA.value : [usersODATA]);\n\t var users = new Users(_this, resultsArray.map(function (o) { return new User(_this, o); }));\n\t var nextLink = usersODATA['@odata.nextLink'];\n\t if (nextLink) {\n\t users.nextLink = function (callback) {\n\t var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n\t var d = new promises_1.Deferred();\n\t _this.getUsers(nextLink, function (result, error) {\n\t if (callback)\n\t callback(result, error);\n\t else\n\t error ? d.reject(error) : d.resolve(result);\n\t }, _this.scopesForV2(scopes), basicProfileOnly);\n\t return d.promise;\n\t };\n\t }\n\t callback(users, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getUser = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var userODATA = JSON.parse(result);\n\t if (userODATA.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = userODATA.error;\n\t callback(null, errorODATA);\n\t return;\n\t }\n\t var user = new User(_this, userODATA);\n\t callback(user, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.addAccessTokenAndSend = function (xhr, callback, scopes) {\n\t if (this.accessToken) {\n\t xhr.setRequestHeader('Authorization', 'Bearer ' + this.accessToken);\n\t xhr.send();\n\t }\n\t else {\n\t if (scopes) {\n\t this.KurveIdentity.getAccessTokenForScopes(scopes, false, (function (token, error) {\n\t if (error)\n\t callback(error);\n\t else {\n\t xhr.setRequestHeader('Authorization', 'Bearer ' + token);\n\t xhr.send();\n\t callback(null);\n\t }\n\t }));\n\t }\n\t else {\n\t this.KurveIdentity.getAccessToken(this.defaultResourceID, (function (token, error) {\n\t if (error)\n\t callback(error);\n\t else {\n\t xhr.setRequestHeader('Authorization', 'Bearer ' + token);\n\t xhr.send();\n\t callback(null);\n\t }\n\t }));\n\t }\n\t }\n\t };\n\t Graph.prototype.getMessage = function (urlString, messageId, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var ODATA = JSON.parse(result);\n\t if (ODATA.error) {\n\t var ODATAError = new identity_1.Error();\n\t ODATAError.other = ODATA.error;\n\t callback(null, ODATAError);\n\t return;\n\t }\n\t var message = new Message(_this, ODATA);\n\t callback(message, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getMessages = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var messagesODATA = JSON.parse(result);\n\t if (messagesODATA.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = messagesODATA.error;\n\t callback(null, errorODATA);\n\t return;\n\t }\n\t var resultsArray = (messagesODATA.value ? messagesODATA.value : [messagesODATA]);\n\t var messages = new Messages(_this, resultsArray.map(function (o) { return new Message(_this, o); }));\n\t var nextLink = messagesODATA['@odata.nextLink'];\n\t if (nextLink) {\n\t messages.nextLink = function (callback) {\n\t var scopes = [Scopes.Mail.Read];\n\t var d = new promises_1.Deferred();\n\t _this.getMessages(nextLink, function (messages, error) {\n\t if (callback)\n\t callback(messages, error);\n\t else\n\t error ? d.reject(error) : d.resolve(messages);\n\t }, _this.scopesForV2(scopes));\n\t return d.promise;\n\t };\n\t }\n\t callback(messages, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getEvent = function (urlString, EventId, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var ODATA = JSON.parse(result);\n\t if (ODATA.error) {\n\t var ODATAError = new identity_1.Error();\n\t ODATAError.other = ODATA.error;\n\t callback(null, ODATAError);\n\t return;\n\t }\n\t var event = new Event(_this, ODATA);\n\t callback(event, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getEvents = function (urlString, endpoint, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var odata = JSON.parse(result);\n\t if (odata.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = odata.error;\n\t callback(null, errorODATA);\n\t return;\n\t }\n\t var resultsArray = (odata.value ? odata.value : [odata]);\n\t var events = new Events(_this, endpoint, resultsArray.map(function (o) { return new Event(_this, o); }));\n\t var nextLink = odata['@odata.nextLink'];\n\t if (nextLink) {\n\t events.nextLink = function (callback) {\n\t var scopes = [Scopes.Mail.Read];\n\t var d = new promises_1.Deferred();\n\t _this.getEvents(nextLink, endpoint, function (result, error) {\n\t if (callback)\n\t callback(result, error);\n\t else\n\t error ? d.reject(error) : d.resolve(result);\n\t }, _this.scopesForV2(scopes));\n\t return d.promise;\n\t };\n\t }\n\t callback(events, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getGroups = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var groupsODATA = JSON.parse(result);\n\t if (groupsODATA.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = groupsODATA.error;\n\t callback(null, errorODATA);\n\t return;\n\t }\n\t var resultsArray = (groupsODATA.value ? groupsODATA.value : [groupsODATA]);\n\t var groups = new Groups(_this, resultsArray.map(function (o) { return new Group(_this, o); }));\n\t var nextLink = groupsODATA['@odata.nextLink'];\n\t if (nextLink) {\n\t groups.nextLink = function (callback) {\n\t var scopes = [Scopes.Group.ReadAll];\n\t var d = new promises_1.Deferred();\n\t _this.getGroups(nextLink, function (result, error) {\n\t if (callback)\n\t callback(result, error);\n\t else\n\t error ? d.reject(error) : d.resolve(result);\n\t }, _this.scopesForV2(scopes));\n\t return d.promise;\n\t };\n\t }\n\t callback(groups, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getGroup = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var ODATA = JSON.parse(result);\n\t if (ODATA.error) {\n\t var ODATAError = new identity_1.Error();\n\t ODATAError.other = ODATA.error;\n\t callback(null, ODATAError);\n\t return;\n\t }\n\t var group = new Group(_this, ODATA);\n\t callback(group, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getPhoto = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var ODATA = JSON.parse(result);\n\t if (ODATA.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = ODATA.error;\n\t callback(null, errorODATA);\n\t return;\n\t }\n\t var photo = new ProfilePhoto(_this, ODATA);\n\t callback(photo, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getPhotoValue = function (urlString, callback, scopes) {\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t callback(result, null);\n\t }, \"blob\", scopes);\n\t };\n\t Graph.prototype.getMailFolders = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var odata = JSON.parse(result);\n\t if (odata.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = odata.error;\n\t callback(null, errorODATA);\n\t }\n\t var resultsArray = (odata.value ? odata.value : [odata]);\n\t var mailFolders = new MailFolders(_this, resultsArray.map(function (o) { return new MailFolder(_this, o); }));\n\t var nextLink = odata['@odata.nextLink'];\n\t if (nextLink) {\n\t mailFolders.nextLink = function (callback) {\n\t var scopes = [Scopes.User.ReadAll];\n\t var d = new promises_1.Deferred();\n\t _this.getMailFolders(nextLink, function (result, error) {\n\t if (callback)\n\t callback(result, error);\n\t else\n\t error ? d.reject(error) : d.resolve(result);\n\t }, _this.scopesForV2(scopes));\n\t return d.promise;\n\t };\n\t }\n\t callback(mailFolders, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getMessageAttachments = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var attachmentsODATA = JSON.parse(result);\n\t if (attachmentsODATA.error) {\n\t var errorODATA = new identity_1.Error();\n\t errorODATA.other = attachmentsODATA.error;\n\t callback(null, errorODATA);\n\t return;\n\t }\n\t var resultsArray = (attachmentsODATA.value ? attachmentsODATA.value : [attachmentsODATA]);\n\t var attachments = new Attachments(_this, resultsArray.map(function (o) { return new Attachment(_this, o); }));\n\t var nextLink = attachmentsODATA['@odata.nextLink'];\n\t if (nextLink) {\n\t attachments.nextLink = function (callback) {\n\t var scopes = [Scopes.Mail.Read];\n\t var d = new promises_1.Deferred();\n\t _this.getMessageAttachments(nextLink, function (attachments, error) {\n\t if (callback)\n\t callback(attachments, error);\n\t else\n\t error ? d.reject(error) : d.resolve(attachments);\n\t }, _this.scopesForV2(scopes));\n\t return d.promise;\n\t };\n\t }\n\t callback(attachments, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.getMessageAttachment = function (urlString, callback, scopes) {\n\t var _this = this;\n\t this.get(urlString, function (result, errorGet) {\n\t if (errorGet) {\n\t callback(null, errorGet);\n\t return;\n\t }\n\t var ODATA = JSON.parse(result);\n\t if (ODATA.error) {\n\t var ODATAError = new identity_1.Error();\n\t ODATAError.other = ODATA.error;\n\t callback(null, ODATAError);\n\t return;\n\t }\n\t var attachment = new Attachment(_this, ODATA);\n\t callback(attachment, null);\n\t }, null, scopes);\n\t };\n\t Graph.prototype.buildUrl = function (root, path, odataQuery) {\n\t return this.baseUrl + root + path + (odataQuery ? \"?\" + odataQuery : \"\");\n\t };\n\t Graph.prototype.buildMeUrl = function (path, odataQuery) {\n\t if (path === void 0) { path = \"\"; }\n\t return this.buildUrl(\"me/\", path, odataQuery);\n\t };\n\t Graph.prototype.buildUsersUrl = function (path, odataQuery) {\n\t if (path === void 0) { path = \"\"; }\n\t return this.buildUrl(\"users/\", path, odataQuery);\n\t };\n\t Graph.prototype.buildGroupsUrl = function (path, odataQuery) {\n\t if (path === void 0) { path = \"\"; }\n\t return this.buildUrl(\"groups/\", path, odataQuery);\n\t };\n\t return Graph;\n\t}());\n\texports.Graph = Graph;\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports) {\n\n\t\"use strict\";\n\tfunction DispatchDeferred(closure) {\n\t setTimeout(closure, 0);\n\t}\n\tvar PromiseState;\n\t(function (PromiseState) {\n\t PromiseState[PromiseState[\"Pending\"] = 0] = \"Pending\";\n\t PromiseState[PromiseState[\"ResolutionInProgress\"] = 1] = \"ResolutionInProgress\";\n\t PromiseState[PromiseState[\"Resolved\"] = 2] = \"Resolved\";\n\t PromiseState[PromiseState[\"Rejected\"] = 3] = \"Rejected\";\n\t})(PromiseState || (PromiseState = {}));\n\tvar Client = (function () {\n\t function Client(_dispatcher, _successCB, _errorCB) {\n\t this._dispatcher = _dispatcher;\n\t this._successCB = _successCB;\n\t this._errorCB = _errorCB;\n\t this.result = new Deferred(_dispatcher);\n\t }\n\t Client.prototype.resolve = function (value, defer) {\n\t var _this = this;\n\t if (typeof (this._successCB) !== 'function') {\n\t this.result.resolve(value);\n\t return;\n\t }\n\t if (defer) {\n\t this._dispatcher(function () { return _this._dispatchCallback(_this._successCB, value); });\n\t }\n\t else {\n\t this._dispatchCallback(this._successCB, value);\n\t }\n\t };\n\t Client.prototype.reject = function (error, defer) {\n\t var _this = this;\n\t if (typeof (this._errorCB) !== 'function') {\n\t this.result.reject(error);\n\t return;\n\t }\n\t if (defer) {\n\t this._dispatcher(function () { return _this._dispatchCallback(_this._errorCB, error); });\n\t }\n\t else {\n\t this._dispatchCallback(this._errorCB, error);\n\t }\n\t };\n\t Client.prototype._dispatchCallback = function (callback, arg) {\n\t var result, then, type;\n\t try {\n\t result = callback(arg);\n\t this.result.resolve(result);\n\t }\n\t catch (err) {\n\t this.result.reject(err);\n\t return;\n\t }\n\t };\n\t return Client;\n\t}());\n\tvar Deferred = (function () {\n\t function Deferred(dispatcher) {\n\t this._stack = [];\n\t this._state = PromiseState.Pending;\n\t if (dispatcher)\n\t this._dispatcher = dispatcher;\n\t else\n\t this._dispatcher = DispatchDeferred;\n\t this.promise = new Promise(this);\n\t }\n\t Deferred.prototype.DispatchDeferred = function (closure) {\n\t setTimeout(closure, 0);\n\t };\n\t Deferred.prototype.then = function (successCB, errorCB) {\n\t if (typeof (successCB) !== 'function' && typeof (errorCB) !== 'function') {\n\t return this.promise;\n\t }\n\t var client = new Client(this._dispatcher, successCB, errorCB);\n\t switch (this._state) {\n\t case PromiseState.Pending:\n\t case PromiseState.ResolutionInProgress:\n\t this._stack.push(client);\n\t break;\n\t case PromiseState.Resolved:\n\t client.resolve(this._value, true);\n\t break;\n\t case PromiseState.Rejected:\n\t client.reject(this._error, true);\n\t break;\n\t }\n\t return client.result.promise;\n\t };\n\t Deferred.prototype.resolve = function (value) {\n\t if (this._state !== PromiseState.Pending) {\n\t return this;\n\t }\n\t return this._resolve(value);\n\t };\n\t Deferred.prototype._resolve = function (value) {\n\t var _this = this;\n\t var type = typeof (value), then, pending = true;\n\t try {\n\t if (value !== null &&\n\t (type === 'object' || type === 'function') &&\n\t typeof (then = value.then) === 'function') {\n\t if (value === this.promise) {\n\t throw new TypeError('recursive resolution');\n\t }\n\t this._state = PromiseState.ResolutionInProgress;\n\t then.call(value, function (result) {\n\t if (pending) {\n\t pending = false;\n\t _this._resolve(result);\n\t }\n\t }, function (error) {\n\t if (pending) {\n\t pending = false;\n\t _this._reject(error);\n\t }\n\t });\n\t }\n\t else {\n\t this._state = PromiseState.ResolutionInProgress;\n\t this._dispatcher(function () {\n\t _this._state = PromiseState.Resolved;\n\t _this._value = value;\n\t var i, stackSize = _this._stack.length;\n\t for (i = 0; i < stackSize; i++) {\n\t _this._stack[i].resolve(value, false);\n\t }\n\t _this._stack.splice(0, stackSize);\n\t });\n\t }\n\t }\n\t catch (err) {\n\t if (pending) {\n\t this._reject(err);\n\t }\n\t }\n\t return this;\n\t };\n\t Deferred.prototype.reject = function (error) {\n\t if (this._state !== PromiseState.Pending) {\n\t return this;\n\t }\n\t return this._reject(error);\n\t };\n\t Deferred.prototype._reject = function (error) {\n\t var _this = this;\n\t this._state = PromiseState.ResolutionInProgress;\n\t this._dispatcher(function () {\n\t _this._state = PromiseState.Rejected;\n\t _this._error = error;\n\t var stackSize = _this._stack.length, i = 0;\n\t for (i = 0; i < stackSize; i++) {\n\t _this._stack[i].reject(error, false);\n\t }\n\t _this._stack.splice(0, stackSize);\n\t });\n\t return this;\n\t };\n\t return Deferred;\n\t}());\n\texports.Deferred = Deferred;\n\tvar Promise = (function () {\n\t function Promise(_deferred) {\n\t this._deferred = _deferred;\n\t }\n\t Promise.prototype.then = function (successCallback, errorCallback) {\n\t return this._deferred.then(successCallback, errorCallback);\n\t };\n\t Promise.prototype.fail = function (errorCallback) {\n\t return this._deferred.then(undefined, errorCallback);\n\t };\n\t return Promise;\n\t}());\n\texports.Promise = Promise;\n\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\tvar promises_1 = __webpack_require__(2);\n\t(function (OAuthVersion) {\n\t OAuthVersion[OAuthVersion[\"v1\"] = 1] = \"v1\";\n\t OAuthVersion[OAuthVersion[\"v2\"] = 2] = \"v2\";\n\t})(exports.OAuthVersion || (exports.OAuthVersion = {}));\n\tvar OAuthVersion = exports.OAuthVersion;\n\tvar Error = (function () {\n\t function Error() {\n\t }\n\t return Error;\n\t}());\n\texports.Error = Error;\n\tvar CachedToken = (function () {\n\t function CachedToken(id, scopes, resource, token, expiry) {\n\t this.id = id;\n\t this.scopes = scopes;\n\t this.resource = resource;\n\t this.token = token;\n\t this.expiry = expiry;\n\t }\n\t ;\n\t Object.defineProperty(CachedToken.prototype, \"isExpired\", {\n\t get: function () {\n\t return this.expiry <= new Date(new Date().getTime() + 60000);\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t CachedToken.prototype.hasScopes = function (requiredScopes) {\n\t var _this = this;\n\t if (!this.scopes) {\n\t return false;\n\t }\n\t return requiredScopes.every(function (requiredScope) {\n\t return _this.scopes.some(function (actualScope) { return requiredScope === actualScope; });\n\t });\n\t };\n\t return CachedToken;\n\t}());\n\tvar TokenCache = (function () {\n\t function TokenCache(tokenStorage) {\n\t var _this = this;\n\t this.tokenStorage = tokenStorage;\n\t this.cachedTokens = {};\n\t if (tokenStorage) {\n\t tokenStorage.getAll().forEach(function (_a) {\n\t var id = _a.id, scopes = _a.scopes, resource = _a.resource, token = _a.token, expiry = _a.expiry;\n\t var cachedToken = new CachedToken(id, scopes, resource, token, new Date(expiry));\n\t if (cachedToken.isExpired) {\n\t _this.tokenStorage.remove(cachedToken.id);\n\t }\n\t else {\n\t _this.cachedTokens[cachedToken.id] = cachedToken;\n\t }\n\t });\n\t }\n\t }\n\t TokenCache.prototype.add = function (token) {\n\t this.cachedTokens[token.id] = token;\n\t this.tokenStorage && this.tokenStorage.add(token.id, token);\n\t };\n\t TokenCache.prototype.getForResource = function (resource) {\n\t var cachedToken = this.cachedTokens[resource];\n\t if (cachedToken && cachedToken.isExpired) {\n\t this.remove(resource);\n\t return null;\n\t }\n\t return cachedToken;\n\t };\n\t TokenCache.prototype.getForScopes = function (scopes) {\n\t for (var key in this.cachedTokens) {\n\t var cachedToken = this.cachedTokens[key];\n\t if (cachedToken.hasScopes(scopes)) {\n\t if (cachedToken.isExpired) {\n\t this.remove(key);\n\t }\n\t else {\n\t return cachedToken;\n\t }\n\t }\n\t }\n\t return null;\n\t };\n\t TokenCache.prototype.clear = function () {\n\t this.cachedTokens = {};\n\t this.tokenStorage && this.tokenStorage.clear();\n\t };\n\t TokenCache.prototype.remove = function (key) {\n\t this.tokenStorage && this.tokenStorage.remove(key);\n\t delete this.cachedTokens[key];\n\t };\n\t return TokenCache;\n\t}());\n\tvar IdToken = (function () {\n\t function IdToken() {\n\t }\n\t return IdToken;\n\t}());\n\texports.IdToken = IdToken;\n\tvar Identity = (function () {\n\t function Identity(identitySettings) {\n\t var _this = this;\n\t this.policy = \"\";\n\t this.clientId = identitySettings.clientId;\n\t this.tokenProcessorUrl = identitySettings.tokenProcessingUri;\n\t if (identitySettings.version)\n\t this.version = identitySettings.version;\n\t else\n\t this.version = OAuthVersion.v1;\n\t this.tokenCache = new TokenCache(identitySettings.tokenStorage);\n\t window.addEventListener(\"message\", function (event) {\n\t if (event.data.type === \"id_token\") {\n\t if (event.data.error) {\n\t var e = new Error();\n\t e.text = event.data.error;\n\t _this.loginCallback(e);\n\t }\n\t else {\n\t if (_this.state !== event.data.state) {\n\t var error = new Error();\n\t error.statusText = \"Invalid state\";\n\t _this.loginCallback(error);\n\t }\n\t else {\n\t _this.decodeIdToken(event.data.token);\n\t _this.loginCallback(null);\n\t }\n\t }\n\t }\n\t else if (event.data.type === \"access_token\") {\n\t if (event.data.error) {\n\t var e = new Error();\n\t e.text = event.data.error;\n\t _this.getTokenCallback(null, e);\n\t }\n\t else {\n\t var token = event.data.token;\n\t var iframe = document.getElementById(\"tokenIFrame\");\n\t iframe.parentNode.removeChild(iframe);\n\t if (event.data.state !== _this.state) {\n\t var error = new Error();\n\t error.statusText = \"Invalid state\";\n\t _this.getTokenCallback(null, error);\n\t }\n\t else {\n\t _this.getTokenCallback(token, null);\n\t }\n\t }\n\t }\n\t });\n\t }\n\t Identity.prototype.checkForIdentityRedirect = function () {\n\t function token(s) {\n\t var start = window.location.href.indexOf(s);\n\t if (start < 0)\n\t return null;\n\t var end = window.location.href.indexOf(\"&\", start + s.length);\n\t return window.location.href.substring(start, ((end > 0) ? end : window.location.href.length));\n\t }\n\t function parseQueryString(str) {\n\t var queryString = str || window.location.search || '';\n\t var keyValPairs = [];\n\t var params = {};\n\t queryString = queryString.replace(/.*?\\?/, \"\");\n\t if (queryString.length) {\n\t keyValPairs = queryString.split('&');\n\t for (var pairNum in keyValPairs) {\n\t var key = keyValPairs[pairNum].split('=')[0];\n\t if (!key.length)\n\t continue;\n\t if (typeof params[key] === 'undefined')\n\t params[key] = [];\n\t params[key].push(keyValPairs[pairNum].split('=')[1]);\n\t }\n\t }\n\t return params;\n\t }\n\t var params = parseQueryString(window.location.href);\n\t var idToken = token(\"#id_token=\");\n\t var accessToken = token(\"#access_token\");\n\t if (idToken) {\n\t if (true) {\n\t this.decodeIdToken(idToken);\n\t this.loginCallback && this.loginCallback(null);\n\t }\n\t else {\n\t var error = new Error();\n\t error.statusText = \"Invalid state\";\n\t this.loginCallback && this.loginCallback(error);\n\t }\n\t return true;\n\t }\n\t else if (accessToken) {\n\t throw \"Should not get here. This should be handled via the iframe approach.\";\n\t }\n\t return false;\n\t };\n\t Identity.prototype.decodeIdToken = function (idToken) {\n\t var _this = this;\n\t var decodedToken = this.base64Decode(idToken.substring(idToken.indexOf('.') + 1, idToken.lastIndexOf('.')));\n\t var decodedTokenJSON = JSON.parse(decodedToken);\n\t var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000);\n\t this.idToken = new IdToken();\n\t this.idToken.FullToken = decodedTokenJSON;\n\t this.idToken.Token = idToken;\n\t this.idToken.Expiry = expiryDate;\n\t this.idToken.UPN = decodedTokenJSON.upn;\n\t this.idToken.TenantId = decodedTokenJSON.tid;\n\t this.idToken.FamilyName = decodedTokenJSON.family_name;\n\t this.idToken.GivenName = decodedTokenJSON.given_name;\n\t this.idToken.Name = decodedTokenJSON.name;\n\t this.idToken.PreferredUsername = decodedTokenJSON.preferred_username;\n\t var expiration = expiryDate.getTime() - new Date().getTime() - 300000;\n\t this.refreshTimer = setTimeout((function () {\n\t _this.renewIdToken();\n\t }), expiration);\n\t };\n\t Identity.prototype.decodeAccessToken = function (accessToken, resource, scopes) {\n\t var decodedToken = this.base64Decode(accessToken.substring(accessToken.indexOf('.') + 1, accessToken.lastIndexOf('.')));\n\t var decodedTokenJSON = JSON.parse(decodedToken);\n\t var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000);\n\t var key = resource || scopes.join(\" \");\n\t var token = new CachedToken(key, scopes, resource, accessToken, expiryDate);\n\t this.tokenCache.add(token);\n\t };\n\t Identity.prototype.getIdToken = function () {\n\t return this.idToken;\n\t };\n\t Identity.prototype.isLoggedIn = function () {\n\t if (!this.idToken)\n\t return false;\n\t return (this.idToken.Expiry > new Date());\n\t };\n\t Identity.prototype.renewIdToken = function () {\n\t clearTimeout(this.refreshTimer);\n\t this.login(function () { });\n\t };\n\t Identity.prototype.getCurrentOauthVersion = function () {\n\t return this.version;\n\t };\n\t Identity.prototype.getAccessTokenAsync = function (resource) {\n\t var d = new promises_1.Deferred();\n\t this.getAccessToken(resource, (function (token, error) {\n\t if (error) {\n\t d.reject(error);\n\t }\n\t else {\n\t d.resolve(token);\n\t }\n\t }));\n\t return d.promise;\n\t };\n\t Identity.prototype.getAccessToken = function (resource, callback) {\n\t var _this = this;\n\t if (this.version !== OAuthVersion.v1) {\n\t var e = new Error();\n\t e.statusText = \"Currently this identity class is using v2 OAuth mode. You need to use getAccessTokenForScopes() method\";\n\t callback(null, e);\n\t return;\n\t }\n\t var token = this.tokenCache.getForResource(resource);\n\t if (token) {\n\t return callback(token.token, null);\n\t }\n\t this.getTokenCallback = (function (token, error) {\n\t if (error) {\n\t callback(null, error);\n\t }\n\t else {\n\t _this.decodeAccessToken(token, resource);\n\t callback(token, null);\n\t }\n\t });\n\t this.nonce = \"token\" + this.generateNonce();\n\t this.state = \"token\" + this.generateNonce();\n\t var iframe = document.createElement('iframe');\n\t iframe.style.display = \"none\";\n\t iframe.id = \"tokenIFrame\";\n\t iframe.src = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n\t \"&resource=\" + encodeURIComponent(resource) +\n\t \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n\t \"&state=\" + encodeURIComponent(this.state) +\n\t \"&version=\" + encodeURIComponent(this.version.toString()) +\n\t \"&nonce=\" + encodeURIComponent(this.nonce) +\n\t \"&op=token\";\n\t document.body.appendChild(iframe);\n\t };\n\t Identity.prototype.getAccessTokenForScopesAsync = function (scopes, promptForConsent) {\n\t if (promptForConsent === void 0) { promptForConsent = false; }\n\t var d = new promises_1.Deferred();\n\t this.getAccessTokenForScopes(scopes, promptForConsent, function (token, error) {\n\t if (error) {\n\t d.reject(error);\n\t }\n\t else {\n\t d.resolve(token);\n\t }\n\t });\n\t return d.promise;\n\t };\n\t Identity.prototype.getAccessTokenForScopes = function (scopes, promptForConsent, callback) {\n\t var _this = this;\n\t if (promptForConsent === void 0) { promptForConsent = false; }\n\t if (this.version !== OAuthVersion.v2) {\n\t var e = new Error();\n\t e.statusText = \"Dynamic scopes require v2 mode. Currently this identity class is using v1\";\n\t callback(null, e);\n\t return;\n\t }\n\t var token = this.tokenCache.getForScopes(scopes);\n\t if (token) {\n\t return callback(token.token, null);\n\t }\n\t this.getTokenCallback = (function (token, error) {\n\t if (error) {\n\t if (promptForConsent || !error.text) {\n\t callback(null, error);\n\t }\n\t else if (error.text.indexOf(\"AADSTS65001\") >= 0) {\n\t _this.getAccessTokenForScopes(scopes, true, _this.getTokenCallback);\n\t }\n\t else {\n\t callback(null, error);\n\t }\n\t }\n\t else {\n\t _this.decodeAccessToken(token, null, scopes);\n\t callback(token, null);\n\t }\n\t });\n\t this.nonce = \"token\" + this.generateNonce();\n\t this.state = \"token\" + this.generateNonce();\n\t if (!promptForConsent) {\n\t var iframe = document.createElement('iframe');\n\t iframe.style.display = \"none\";\n\t iframe.id = \"tokenIFrame\";\n\t iframe.src = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n\t \"&scopes=\" + encodeURIComponent(scopes.join(\" \")) +\n\t \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n\t \"&version=\" + encodeURIComponent(this.version.toString()) +\n\t \"&state=\" + encodeURIComponent(this.state) +\n\t \"&nonce=\" + encodeURIComponent(this.nonce) +\n\t \"&login_hint=\" + encodeURIComponent(this.idToken.PreferredUsername) +\n\t \"&domain_hint=\" + encodeURIComponent(this.idToken.TenantId === \"9188040d-6c67-4c5b-b112-36a304b66dad\" ? \"consumers\" : \"organizations\") +\n\t \"&op=token\";\n\t document.body.appendChild(iframe);\n\t }\n\t else {\n\t window.open(this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n\t \"&scopes=\" + encodeURIComponent(scopes.join(\" \")) +\n\t \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n\t \"&version=\" + encodeURIComponent(this.version.toString()) +\n\t \"&state=\" + encodeURIComponent(this.state) +\n\t \"&nonce=\" + encodeURIComponent(this.nonce) +\n\t \"&op=token\", \"_blank\");\n\t }\n\t };\n\t Identity.prototype.loginAsync = function (loginSettings) {\n\t var d = new promises_1.Deferred();\n\t this.login(function (error) {\n\t if (error) {\n\t d.reject(error);\n\t }\n\t else {\n\t d.resolve(null);\n\t }\n\t }, loginSettings);\n\t return d.promise;\n\t };\n\t Identity.prototype.login = function (callback, loginSettings) {\n\t this.loginCallback = callback;\n\t if (!loginSettings)\n\t loginSettings = {};\n\t if (loginSettings.policy)\n\t this.policy = loginSettings.policy;\n\t if (loginSettings.scopes && this.version === OAuthVersion.v1) {\n\t var e = new Error();\n\t e.text = \"Scopes can only be used with OAuth v2.\";\n\t callback(e);\n\t return;\n\t }\n\t if (loginSettings.policy && !loginSettings.tenant) {\n\t var e = new Error();\n\t e.text = \"In order to use policy (AAD B2C) a tenant must be specified as well.\";\n\t callback(e);\n\t return;\n\t }\n\t this.state = \"login\" + this.generateNonce();\n\t this.nonce = \"login\" + this.generateNonce();\n\t var loginURL = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n\t \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n\t \"&state=\" + encodeURIComponent(this.state) +\n\t \"&nonce=\" + encodeURIComponent(this.nonce) +\n\t \"&version=\" + encodeURIComponent(this.version.toString()) +\n\t \"&op=login\" +\n\t \"&p=\" + encodeURIComponent(this.policy);\n\t if (loginSettings.tenant) {\n\t loginURL += \"&tenant=\" + encodeURIComponent(loginSettings.tenant);\n\t }\n\t if (this.version === OAuthVersion.v2) {\n\t if (!loginSettings.scopes)\n\t loginSettings.scopes = [];\n\t if (loginSettings.scopes.indexOf(\"profile\") < 0)\n\t loginSettings.scopes.push(\"profile\");\n\t if (loginSettings.scopes.indexOf(\"openid\") < 0)\n\t loginSettings.scopes.push(\"openid\");\n\t loginURL += \"&scopes=\" + encodeURIComponent(loginSettings.scopes.join(\" \"));\n\t }\n\t window.open(loginURL, \"_blank\");\n\t };\n\t Identity.prototype.loginNoWindowAsync = function (toUrl) {\n\t var d = new promises_1.Deferred();\n\t this.loginNoWindow(function (error) {\n\t if (error) {\n\t d.reject(error);\n\t }\n\t else {\n\t d.resolve(null);\n\t }\n\t }, toUrl);\n\t return d.promise;\n\t };\n\t Identity.prototype.loginNoWindow = function (callback, toUrl) {\n\t this.loginCallback = callback;\n\t this.state = \"clientId=\" + this.clientId + \"&\" + \"tokenProcessorUrl=\" + this.tokenProcessorUrl;\n\t this.nonce = this.generateNonce();\n\t var redirected = this.checkForIdentityRedirect();\n\t if (!redirected) {\n\t var redirectUri = (toUrl) ? toUrl : window.location.href.split(\"#\")[0];\n\t var url = \"https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token\" +\n\t \"&client_id=\" + encodeURIComponent(this.clientId) +\n\t \"&redirect_uri=\" + encodeURIComponent(redirectUri) +\n\t \"&state=\" + encodeURIComponent(this.state) +\n\t \"&nonce=\" + encodeURIComponent(this.nonce);\n\t window.location.href = url;\n\t }\n\t };\n\t Identity.prototype.logOut = function () {\n\t this.tokenCache.clear();\n\t var url = \"https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=\" + encodeURI(window.location.href);\n\t window.location.href = url;\n\t };\n\t Identity.prototype.base64Decode = function (encodedString) {\n\t var e = {}, i, b = 0, c, x, l = 0, a, r = '', w = String.fromCharCode, L = encodedString.length;\n\t var A = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\t for (i = 0; i < 64; i++) {\n\t e[A.charAt(i)] = i;\n\t }\n\t for (x = 0; x < L; x++) {\n\t c = e[encodedString.charAt(x)];\n\t b = (b << 6) + c;\n\t l += 6;\n\t while (l >= 8) {\n\t ((a = (b >>> (l -= 8)) & 0xff) || (x < (L - 2))) && (r += w(a));\n\t }\n\t }\n\t return r;\n\t };\n\t Identity.prototype.generateNonce = function () {\n\t var text = \"\";\n\t var chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\t for (var i = 0; i < 32; i++) {\n\t text += chars.charAt(Math.floor(Math.random() * chars.length));\n\t }\n\t return text;\n\t };\n\t return Identity;\n\t}());\n\texports.Identity = Identity;\n\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** dist/kurve.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap ea984da496e148599765\n **/","\"use strict\";\nvar graph_1 = require(\"./graph\");\nvar identity_1 = require(\"./identity\");\nmodule.exports = {\n Graph: graph_1.Graph,\n Identity: identity_1.Identity\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/kurve.ts\n ** module id = 0\n ** module chunks = 0\n **/","\"use strict\";\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar promises_1 = require(\"./promises\");\nvar identity_1 = require(\"./identity\");\nvar Scopes;\n(function (Scopes) {\n var Util = (function () {\n function Util() {\n }\n Util.rootUrl = \"https://graph.microsoft.com/\";\n return Util;\n }());\n var General = (function () {\n function General() {\n }\n General.OpenId = \"openid\";\n General.OfflineAccess = \"offline_access\";\n return General;\n }());\n Scopes.General = General;\n var User = (function () {\n function User() {\n }\n User.Read = Util.rootUrl + \"User.Read\";\n User.ReadWrite = Util.rootUrl + \"User.ReadWrite\";\n User.ReadBasicAll = Util.rootUrl + \"User.ReadBasic.All\";\n User.ReadAll = Util.rootUrl + \"User.Read.All\";\n User.ReadWriteAll = Util.rootUrl + \"User.ReadWrite.All\";\n return User;\n }());\n Scopes.User = User;\n var Contacts = (function () {\n function Contacts() {\n }\n Contacts.Read = Util.rootUrl + \"Contacts.Read\";\n Contacts.ReadWrite = Util.rootUrl + \"Contacts.ReadWrite\";\n return Contacts;\n }());\n Scopes.Contacts = Contacts;\n var Directory = (function () {\n function Directory() {\n }\n Directory.ReadAll = Util.rootUrl + \"Directory.Read.All\";\n Directory.ReadWriteAll = Util.rootUrl + \"Directory.ReadWrite.All\";\n Directory.AccessAsUserAll = Util.rootUrl + \"Directory.AccessAsUser.All\";\n return Directory;\n }());\n Scopes.Directory = Directory;\n var Group = (function () {\n function Group() {\n }\n Group.ReadAll = Util.rootUrl + \"Group.Read.All\";\n Group.ReadWriteAll = Util.rootUrl + \"Group.ReadWrite.All\";\n Group.AccessAsUserAll = Util.rootUrl + \"Directory.AccessAsUser.All\";\n return Group;\n }());\n Scopes.Group = Group;\n var Mail = (function () {\n function Mail() {\n }\n Mail.Read = Util.rootUrl + \"Mail.Read\";\n Mail.ReadWrite = Util.rootUrl + \"Mail.ReadWrite\";\n Mail.Send = Util.rootUrl + \"Mail.Send\";\n return Mail;\n }());\n Scopes.Mail = Mail;\n var Calendars = (function () {\n function Calendars() {\n }\n Calendars.Read = Util.rootUrl + \"Calendars.Read\";\n Calendars.ReadWrite = Util.rootUrl + \"Calendars.ReadWrite\";\n return Calendars;\n }());\n Scopes.Calendars = Calendars;\n var Files = (function () {\n function Files() {\n }\n Files.Read = Util.rootUrl + \"Files.Read\";\n Files.ReadAll = Util.rootUrl + \"Files.Read.All\";\n Files.ReadWrite = Util.rootUrl + \"Files.ReadWrite\";\n Files.ReadWriteAppFolder = Util.rootUrl + \"Files.ReadWrite.AppFolder\";\n Files.ReadWriteSelected = Util.rootUrl + \"Files.ReadWrite.Selected\";\n return Files;\n }());\n Scopes.Files = Files;\n var Tasks = (function () {\n function Tasks() {\n }\n Tasks.ReadWrite = Util.rootUrl + \"Tasks.ReadWrite\";\n return Tasks;\n }());\n Scopes.Tasks = Tasks;\n var People = (function () {\n function People() {\n }\n People.Read = Util.rootUrl + \"People.Read\";\n People.ReadWrite = Util.rootUrl + \"People.ReadWrite\";\n return People;\n }());\n Scopes.People = People;\n var Notes = (function () {\n function Notes() {\n }\n Notes.Create = Util.rootUrl + \"Notes.Create\";\n Notes.ReadWriteCreatedByApp = Util.rootUrl + \"Notes.ReadWrite.CreatedByApp\";\n Notes.Read = Util.rootUrl + \"Notes.Read\";\n Notes.ReadAll = Util.rootUrl + \"Notes.Read.All\";\n Notes.ReadWriteAll = Util.rootUrl + \"Notes.ReadWrite.All\";\n return Notes;\n }());\n Scopes.Notes = Notes;\n})(Scopes = exports.Scopes || (exports.Scopes = {}));\nvar DataModelWrapper = (function () {\n function DataModelWrapper(graph, _data) {\n this.graph = graph;\n this._data = _data;\n }\n Object.defineProperty(DataModelWrapper.prototype, \"data\", {\n get: function () { return this._data; },\n enumerable: true,\n configurable: true\n });\n return DataModelWrapper;\n}());\nexports.DataModelWrapper = DataModelWrapper;\nvar DataModelListWrapper = (function (_super) {\n __extends(DataModelListWrapper, _super);\n function DataModelListWrapper() {\n _super.apply(this, arguments);\n }\n return DataModelListWrapper;\n}(DataModelWrapper));\nexports.DataModelListWrapper = DataModelListWrapper;\nvar ProfilePhotoDataModel = (function () {\n function ProfilePhotoDataModel() {\n }\n return ProfilePhotoDataModel;\n}());\nexports.ProfilePhotoDataModel = ProfilePhotoDataModel;\nvar ProfilePhoto = (function (_super) {\n __extends(ProfilePhoto, _super);\n function ProfilePhoto() {\n _super.apply(this, arguments);\n }\n return ProfilePhoto;\n}(DataModelWrapper));\nexports.ProfilePhoto = ProfilePhoto;\nvar UserDataModel = (function () {\n function UserDataModel() {\n }\n return UserDataModel;\n}());\nexports.UserDataModel = UserDataModel;\n(function (EventsEndpoint) {\n EventsEndpoint[EventsEndpoint[\"events\"] = 0] = \"events\";\n EventsEndpoint[EventsEndpoint[\"calendarView\"] = 1] = \"calendarView\";\n})(exports.EventsEndpoint || (exports.EventsEndpoint = {}));\nvar EventsEndpoint = exports.EventsEndpoint;\nvar User = (function (_super) {\n __extends(User, _super);\n function User() {\n _super.apply(this, arguments);\n }\n User.prototype.events = function (callback, odataQuery) {\n this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.events, callback, odataQuery);\n };\n User.prototype.eventsAsync = function (odataQuery) {\n return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.events, odataQuery);\n };\n User.prototype.memberOf = function (callback, Error, odataQuery) {\n this.graph.memberOfForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.memberOfAsync = function (odataQuery) {\n return this.graph.memberOfForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.messages = function (callback, odataQuery) {\n this.graph.messagesForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.messagesAsync = function (odataQuery) {\n return this.graph.messagesForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.manager = function (callback, odataQuery) {\n this.graph.managerForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.managerAsync = function (odataQuery) {\n return this.graph.managerForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.profilePhoto = function (callback, odataQuery) {\n this.graph.profilePhotoForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.profilePhotoAsync = function (odataQuery) {\n return this.graph.profilePhotoForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.profilePhotoValue = function (callback, odataQuery) {\n this.graph.profilePhotoValueForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.profilePhotoValueAsync = function (odataQuery) {\n return this.graph.profilePhotoValueForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.calendarView = function (callback, odataQuery) {\n this.graph.eventsForUser(this._data.userPrincipalName, EventsEndpoint.calendarView, callback, odataQuery);\n };\n User.prototype.calendarViewAsync = function (odataQuery) {\n return this.graph.eventsForUserAsync(this._data.userPrincipalName, EventsEndpoint.calendarView, odataQuery);\n };\n User.prototype.mailFolders = function (callback, odataQuery) {\n this.graph.mailFoldersForUser(this._data.userPrincipalName, callback, odataQuery);\n };\n User.prototype.mailFoldersAsync = function (odataQuery) {\n return this.graph.mailFoldersForUserAsync(this._data.userPrincipalName, odataQuery);\n };\n User.prototype.message = function (messageId, callback, odataQuery) {\n this.graph.messageForUser(this._data.userPrincipalName, messageId, callback, odataQuery);\n };\n User.prototype.messageAsync = function (messageId, odataQuery) {\n return this.graph.messageForUserAsync(this._data.userPrincipalName, messageId, odataQuery);\n };\n User.prototype.event = function (eventId, callback, odataQuery) {\n this.graph.eventForUser(this._data.userPrincipalName, eventId, callback, odataQuery);\n };\n User.prototype.eventAsync = function (eventId, odataQuery) {\n return this.graph.eventForUserAsync(this._data.userPrincipalName, eventId, odataQuery);\n };\n User.prototype.messageAttachment = function (messageId, attachmentId, callback, odataQuery) {\n this.graph.messageAttachmentForUser(this._data.userPrincipalName, messageId, attachmentId, callback, odataQuery);\n };\n User.prototype.messageAttachmentAsync = function (messageId, attachmentId, odataQuery) {\n return this.graph.messageAttachmentForUserAsync(this._data.userPrincipalName, messageId, attachmentId, odataQuery);\n };\n return User;\n}(DataModelWrapper));\nexports.User = User;\nvar Users = (function (_super) {\n __extends(Users, _super);\n function Users() {\n _super.apply(this, arguments);\n }\n return Users;\n}(DataModelListWrapper));\nexports.Users = Users;\nvar MessageDataModel = (function () {\n function MessageDataModel() {\n }\n return MessageDataModel;\n}());\nexports.MessageDataModel = MessageDataModel;\nvar Message = (function (_super) {\n __extends(Message, _super);\n function Message() {\n _super.apply(this, arguments);\n }\n return Message;\n}(DataModelWrapper));\nexports.Message = Message;\nvar Messages = (function (_super) {\n __extends(Messages, _super);\n function Messages() {\n _super.apply(this, arguments);\n }\n return Messages;\n}(DataModelListWrapper));\nexports.Messages = Messages;\nvar EventDataModel = (function () {\n function EventDataModel() {\n }\n return EventDataModel;\n}());\nexports.EventDataModel = EventDataModel;\nvar Event = (function (_super) {\n __extends(Event, _super);\n function Event() {\n _super.apply(this, arguments);\n }\n return Event;\n}(DataModelWrapper));\nexports.Event = Event;\nvar Events = (function (_super) {\n __extends(Events, _super);\n function Events(graph, endpoint, _data) {\n _super.call(this, graph, _data);\n this.graph = graph;\n this.endpoint = endpoint;\n this._data = _data;\n }\n return Events;\n}(DataModelListWrapper));\nexports.Events = Events;\nvar Contact = (function () {\n function Contact() {\n }\n return Contact;\n}());\nexports.Contact = Contact;\nvar GroupDataModel = (function () {\n function GroupDataModel() {\n }\n return GroupDataModel;\n}());\nexports.GroupDataModel = GroupDataModel;\nvar Group = (function (_super) {\n __extends(Group, _super);\n function Group() {\n _super.apply(this, arguments);\n }\n return Group;\n}(DataModelWrapper));\nexports.Group = Group;\nvar Groups = (function (_super) {\n __extends(Groups, _super);\n function Groups() {\n _super.apply(this, arguments);\n }\n return Groups;\n}(DataModelListWrapper));\nexports.Groups = Groups;\nvar MailFolderDataModel = (function () {\n function MailFolderDataModel() {\n }\n return MailFolderDataModel;\n}());\nexports.MailFolderDataModel = MailFolderDataModel;\nvar MailFolder = (function (_super) {\n __extends(MailFolder, _super);\n function MailFolder() {\n _super.apply(this, arguments);\n }\n return MailFolder;\n}(DataModelWrapper));\nexports.MailFolder = MailFolder;\nvar MailFolders = (function (_super) {\n __extends(MailFolders, _super);\n function MailFolders() {\n _super.apply(this, arguments);\n }\n return MailFolders;\n}(DataModelListWrapper));\nexports.MailFolders = MailFolders;\n(function (AttachmentType) {\n AttachmentType[AttachmentType[\"fileAttachment\"] = 0] = \"fileAttachment\";\n AttachmentType[AttachmentType[\"itemAttachment\"] = 1] = \"itemAttachment\";\n AttachmentType[AttachmentType[\"referenceAttachment\"] = 2] = \"referenceAttachment\";\n})(exports.AttachmentType || (exports.AttachmentType = {}));\nvar AttachmentType = exports.AttachmentType;\nvar AttachmentDataModel = (function () {\n function AttachmentDataModel() {\n }\n return AttachmentDataModel;\n}());\nexports.AttachmentDataModel = AttachmentDataModel;\nvar Attachment = (function (_super) {\n __extends(Attachment, _super);\n function Attachment() {\n _super.apply(this, arguments);\n }\n Attachment.prototype.getType = function () {\n switch (this._data['@odata.type']) {\n case \"#microsoft.graph.fileAttachment\":\n return AttachmentType.fileAttachment;\n case \"#microsoft.graph.itemAttachment\":\n return AttachmentType.itemAttachment;\n case \"#microsoft.graph.referenceAttachment\":\n return AttachmentType.referenceAttachment;\n }\n };\n return Attachment;\n}(DataModelWrapper));\nexports.Attachment = Attachment;\nvar Attachments = (function (_super) {\n __extends(Attachments, _super);\n function Attachments() {\n _super.apply(this, arguments);\n }\n return Attachments;\n}(DataModelListWrapper));\nexports.Attachments = Attachments;\nvar Graph = (function () {\n function Graph(identityInfo) {\n this.req = null;\n this.accessToken = null;\n this.KurveIdentity = null;\n this.defaultResourceID = \"https://graph.microsoft.com\";\n this.baseUrl = \"https://graph.microsoft.com/v1.0/\";\n if (identityInfo.defaultAccessToken) {\n this.accessToken = identityInfo.defaultAccessToken;\n }\n else {\n this.KurveIdentity = identityInfo.identity;\n }\n }\n Graph.prototype.scopesForV2 = function (scopes) {\n if (!this.KurveIdentity)\n return null;\n if (this.KurveIdentity.getCurrentOauthVersion() === identity_1.OAuthVersion.v1)\n return null;\n else\n return scopes;\n };\n Graph.prototype.meAsync = function (odataQuery) {\n var d = new promises_1.Deferred();\n this.me(function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.me = function (callback, odataQuery) {\n var scopes = [Scopes.User.Read];\n var urlString = this.buildMeUrl(\"\", odataQuery);\n this.getUser(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.userAsync = function (userId, odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var d = new promises_1.Deferred();\n this.user(userId, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery, basicProfileOnly);\n return d.promise;\n };\n Graph.prototype.user = function (userId, callback, odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n var urlString = this.buildUsersUrl(userId, odataQuery);\n this.getUser(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.usersAsync = function (odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var d = new promises_1.Deferred();\n this.users(function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery, basicProfileOnly);\n return d.promise;\n };\n Graph.prototype.users = function (callback, odataQuery, basicProfileOnly) {\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n var urlString = this.buildUsersUrl(\"\", odataQuery);\n this.getUsers(urlString, callback, this.scopesForV2(scopes), basicProfileOnly);\n };\n Graph.prototype.groupAsync = function (groupId, odataQuery) {\n var d = new promises_1.Deferred();\n this.group(groupId, function (group, error) { return error ? d.reject(error) : d.resolve(group); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.group = function (groupId, callback, odataQuery) {\n var scopes = [Scopes.Group.ReadAll];\n var urlString = this.buildGroupsUrl(groupId, odataQuery);\n this.getGroup(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.groupsAsync = function (odataQuery) {\n var d = new promises_1.Deferred();\n this.groups(function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.groups = function (callback, odataQuery) {\n var scopes = [Scopes.Group.ReadAll];\n var urlString = this.buildGroupsUrl(\"\", odataQuery);\n this.getGroups(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.messageForUserAsync = function (userPrincipalName, messageId, odataQuery) {\n var d = new promises_1.Deferred();\n this.messageForUser(userPrincipalName, messageId, function (message, error) { return error ? d.reject(error) : d.resolve(message); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messageForUser = function (userPrincipalName, messageId, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId, odataQuery);\n this.getMessage(urlString, messageId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.messagesForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.messagesForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messagesForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages\", odataQuery);\n this.getMessages(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.mailFoldersForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.mailFoldersForUser(userPrincipalName, function (messages, error) { return error ? d.reject(error) : d.resolve(messages); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.mailFoldersForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/mailFolders\", odataQuery);\n this.getMailFolders(urlString, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.eventForUserAsync = function (userPrincipalName, eventId, odataQuery) {\n var d = new promises_1.Deferred();\n this.eventForUser(userPrincipalName, eventId, function (event, error) { return error ? d.reject(error) : d.resolve(event); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.eventForUser = function (userPrincipalName, eventId, callback, odataQuery) {\n var scopes = [Scopes.Calendars.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/events/\" + eventId, odataQuery);\n this.getEvent(urlString, eventId, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.eventsForUserAsync = function (userPrincipalName, endpoint, odataQuery) {\n var d = new promises_1.Deferred();\n this.eventsForUser(userPrincipalName, endpoint, function (events, error) { return error ? d.reject(error) : d.resolve(events); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.eventsForUser = function (userPrincipalName, endpoint, callback, odataQuery) {\n var scopes = [Scopes.Calendars.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/\" + EventsEndpoint[endpoint], odataQuery);\n this.getEvents(urlString, endpoint, function (result, error) { return callback(result, error); }, this.scopesForV2(scopes));\n };\n Graph.prototype.memberOfForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.memberOfForUser(userPrincipalName, function (groups, error) { return error ? d.reject(error) : d.resolve(groups); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.memberOfForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Group.ReadAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/memberOf\", odataQuery);\n this.getGroups(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.managerForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.managerForUser(userPrincipalName, function (user, error) { return error ? d.reject(error) : d.resolve(user); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.managerForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Directory.ReadAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/manager\", odataQuery);\n this.getUser(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.directReportsForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.directReportsForUser(userPrincipalName, function (users, error) { return error ? d.reject(error) : d.resolve(users); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.directReportsForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.Directory.ReadAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/directReports\", odataQuery);\n this.getUsers(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.profilePhotoForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.profilePhotoForUser(userPrincipalName, function (profilePhoto, error) { return error ? d.reject(error) : d.resolve(profilePhoto); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.profilePhotoForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.User.ReadBasicAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/photo\", odataQuery);\n this.getPhoto(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.profilePhotoValueForUserAsync = function (userPrincipalName, odataQuery) {\n var d = new promises_1.Deferred();\n this.profilePhotoValueForUser(userPrincipalName, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.profilePhotoValueForUser = function (userPrincipalName, callback, odataQuery) {\n var scopes = [Scopes.User.ReadBasicAll];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/photo/$value\", odataQuery);\n this.getPhotoValue(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.messageAttachmentsForUserAsync = function (userPrincipalName, messageId, odataQuery) {\n var d = new promises_1.Deferred();\n this.messageAttachmentsForUser(userPrincipalName, messageId, function (result, error) { return error ? d.reject(error) : d.resolve(result); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messageAttachmentsForUser = function (userPrincipalName, messageId, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId + \"/attachments\", odataQuery);\n this.getMessageAttachments(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.messageAttachmentForUserAsync = function (userPrincipalName, messageId, attachmentId, odataQuery) {\n var d = new promises_1.Deferred();\n this.messageAttachmentForUser(userPrincipalName, messageId, attachmentId, function (attachment, error) { return error ? d.reject(error) : d.resolve(attachment); }, odataQuery);\n return d.promise;\n };\n Graph.prototype.messageAttachmentForUser = function (userPrincipalName, messageId, attachmentId, callback, odataQuery) {\n var scopes = [Scopes.Mail.Read];\n var urlString = this.buildUsersUrl(userPrincipalName + \"/messages/\" + messageId + \"/attachments/\" + attachmentId, odataQuery);\n this.getMessageAttachment(urlString, callback, this.scopesForV2(scopes));\n };\n Graph.prototype.getAsync = function (url) {\n var d = new promises_1.Deferred();\n this.get(url, function (response, error) { return error ? d.reject(error) : d.resolve(response); });\n return d.promise;\n };\n Graph.prototype.get = function (url, callback, responseType, scopes) {\n var _this = this;\n var xhr = new XMLHttpRequest();\n if (responseType)\n xhr.responseType = responseType;\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4)\n if (xhr.status === 200)\n callback(responseType ? xhr.response : xhr.responseText, null);\n else\n callback(null, _this.generateError(xhr));\n };\n xhr.open(\"GET\", url);\n this.addAccessTokenAndSend(xhr, function (addTokenError) {\n if (addTokenError) {\n callback(null, addTokenError);\n }\n }, scopes);\n };\n Graph.prototype.generateError = function (xhr) {\n var response = new identity_1.Error();\n response.status = xhr.status;\n response.statusText = xhr.statusText;\n if (xhr.responseType === '' || xhr.responseType === 'text')\n response.text = xhr.responseText;\n else\n response.other = xhr.response;\n return response;\n };\n Graph.prototype.getUsers = function (urlString, callback, scopes, basicProfileOnly) {\n var _this = this;\n if (basicProfileOnly === void 0) { basicProfileOnly = true; }\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var usersODATA = JSON.parse(result);\n if (usersODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = usersODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (usersODATA.value ? usersODATA.value : [usersODATA]);\n var users = new Users(_this, resultsArray.map(function (o) { return new User(_this, o); }));\n var nextLink = usersODATA['@odata.nextLink'];\n if (nextLink) {\n users.nextLink = function (callback) {\n var scopes = basicProfileOnly ? [Scopes.User.ReadBasicAll] : [Scopes.User.ReadAll];\n var d = new promises_1.Deferred();\n _this.getUsers(nextLink, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes), basicProfileOnly);\n return d.promise;\n };\n }\n callback(users, null);\n }, null, scopes);\n };\n Graph.prototype.getUser = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var userODATA = JSON.parse(result);\n if (userODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = userODATA.error;\n callback(null, errorODATA);\n return;\n }\n var user = new User(_this, userODATA);\n callback(user, null);\n }, null, scopes);\n };\n Graph.prototype.addAccessTokenAndSend = function (xhr, callback, scopes) {\n if (this.accessToken) {\n xhr.setRequestHeader('Authorization', 'Bearer ' + this.accessToken);\n xhr.send();\n }\n else {\n if (scopes) {\n this.KurveIdentity.getAccessTokenForScopes(scopes, false, (function (token, error) {\n if (error)\n callback(error);\n else {\n xhr.setRequestHeader('Authorization', 'Bearer ' + token);\n xhr.send();\n callback(null);\n }\n }));\n }\n else {\n this.KurveIdentity.getAccessToken(this.defaultResourceID, (function (token, error) {\n if (error)\n callback(error);\n else {\n xhr.setRequestHeader('Authorization', 'Bearer ' + token);\n xhr.send();\n callback(null);\n }\n }));\n }\n }\n };\n Graph.prototype.getMessage = function (urlString, messageId, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var message = new Message(_this, ODATA);\n callback(message, null);\n }, null, scopes);\n };\n Graph.prototype.getMessages = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var messagesODATA = JSON.parse(result);\n if (messagesODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = messagesODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (messagesODATA.value ? messagesODATA.value : [messagesODATA]);\n var messages = new Messages(_this, resultsArray.map(function (o) { return new Message(_this, o); }));\n var nextLink = messagesODATA['@odata.nextLink'];\n if (nextLink) {\n messages.nextLink = function (callback) {\n var scopes = [Scopes.Mail.Read];\n var d = new promises_1.Deferred();\n _this.getMessages(nextLink, function (messages, error) {\n if (callback)\n callback(messages, error);\n else\n error ? d.reject(error) : d.resolve(messages);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(messages, null);\n }, null, scopes);\n };\n Graph.prototype.getEvent = function (urlString, EventId, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var event = new Event(_this, ODATA);\n callback(event, null);\n }, null, scopes);\n };\n Graph.prototype.getEvents = function (urlString, endpoint, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var odata = JSON.parse(result);\n if (odata.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = odata.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (odata.value ? odata.value : [odata]);\n var events = new Events(_this, endpoint, resultsArray.map(function (o) { return new Event(_this, o); }));\n var nextLink = odata['@odata.nextLink'];\n if (nextLink) {\n events.nextLink = function (callback) {\n var scopes = [Scopes.Mail.Read];\n var d = new promises_1.Deferred();\n _this.getEvents(nextLink, endpoint, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(events, null);\n }, null, scopes);\n };\n Graph.prototype.getGroups = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var groupsODATA = JSON.parse(result);\n if (groupsODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = groupsODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (groupsODATA.value ? groupsODATA.value : [groupsODATA]);\n var groups = new Groups(_this, resultsArray.map(function (o) { return new Group(_this, o); }));\n var nextLink = groupsODATA['@odata.nextLink'];\n if (nextLink) {\n groups.nextLink = function (callback) {\n var scopes = [Scopes.Group.ReadAll];\n var d = new promises_1.Deferred();\n _this.getGroups(nextLink, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(groups, null);\n }, null, scopes);\n };\n Graph.prototype.getGroup = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var group = new Group(_this, ODATA);\n callback(group, null);\n }, null, scopes);\n };\n Graph.prototype.getPhoto = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = ODATA.error;\n callback(null, errorODATA);\n return;\n }\n var photo = new ProfilePhoto(_this, ODATA);\n callback(photo, null);\n }, null, scopes);\n };\n Graph.prototype.getPhotoValue = function (urlString, callback, scopes) {\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n callback(result, null);\n }, \"blob\", scopes);\n };\n Graph.prototype.getMailFolders = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var odata = JSON.parse(result);\n if (odata.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = odata.error;\n callback(null, errorODATA);\n }\n var resultsArray = (odata.value ? odata.value : [odata]);\n var mailFolders = new MailFolders(_this, resultsArray.map(function (o) { return new MailFolder(_this, o); }));\n var nextLink = odata['@odata.nextLink'];\n if (nextLink) {\n mailFolders.nextLink = function (callback) {\n var scopes = [Scopes.User.ReadAll];\n var d = new promises_1.Deferred();\n _this.getMailFolders(nextLink, function (result, error) {\n if (callback)\n callback(result, error);\n else\n error ? d.reject(error) : d.resolve(result);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(mailFolders, null);\n }, null, scopes);\n };\n Graph.prototype.getMessageAttachments = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var attachmentsODATA = JSON.parse(result);\n if (attachmentsODATA.error) {\n var errorODATA = new identity_1.Error();\n errorODATA.other = attachmentsODATA.error;\n callback(null, errorODATA);\n return;\n }\n var resultsArray = (attachmentsODATA.value ? attachmentsODATA.value : [attachmentsODATA]);\n var attachments = new Attachments(_this, resultsArray.map(function (o) { return new Attachment(_this, o); }));\n var nextLink = attachmentsODATA['@odata.nextLink'];\n if (nextLink) {\n attachments.nextLink = function (callback) {\n var scopes = [Scopes.Mail.Read];\n var d = new promises_1.Deferred();\n _this.getMessageAttachments(nextLink, function (attachments, error) {\n if (callback)\n callback(attachments, error);\n else\n error ? d.reject(error) : d.resolve(attachments);\n }, _this.scopesForV2(scopes));\n return d.promise;\n };\n }\n callback(attachments, null);\n }, null, scopes);\n };\n Graph.prototype.getMessageAttachment = function (urlString, callback, scopes) {\n var _this = this;\n this.get(urlString, function (result, errorGet) {\n if (errorGet) {\n callback(null, errorGet);\n return;\n }\n var ODATA = JSON.parse(result);\n if (ODATA.error) {\n var ODATAError = new identity_1.Error();\n ODATAError.other = ODATA.error;\n callback(null, ODATAError);\n return;\n }\n var attachment = new Attachment(_this, ODATA);\n callback(attachment, null);\n }, null, scopes);\n };\n Graph.prototype.buildUrl = function (root, path, odataQuery) {\n return this.baseUrl + root + path + (odataQuery ? \"?\" + odataQuery : \"\");\n };\n Graph.prototype.buildMeUrl = function (path, odataQuery) {\n if (path === void 0) { path = \"\"; }\n return this.buildUrl(\"me/\", path, odataQuery);\n };\n Graph.prototype.buildUsersUrl = function (path, odataQuery) {\n if (path === void 0) { path = \"\"; }\n return this.buildUrl(\"users/\", path, odataQuery);\n };\n Graph.prototype.buildGroupsUrl = function (path, odataQuery) {\n if (path === void 0) { path = \"\"; }\n return this.buildUrl(\"groups/\", path, odataQuery);\n };\n return Graph;\n}());\nexports.Graph = Graph;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/graph.ts\n ** module id = 1\n ** module chunks = 0\n **/","\"use strict\";\nfunction DispatchDeferred(closure) {\n setTimeout(closure, 0);\n}\nvar PromiseState;\n(function (PromiseState) {\n PromiseState[PromiseState[\"Pending\"] = 0] = \"Pending\";\n PromiseState[PromiseState[\"ResolutionInProgress\"] = 1] = \"ResolutionInProgress\";\n PromiseState[PromiseState[\"Resolved\"] = 2] = \"Resolved\";\n PromiseState[PromiseState[\"Rejected\"] = 3] = \"Rejected\";\n})(PromiseState || (PromiseState = {}));\nvar Client = (function () {\n function Client(_dispatcher, _successCB, _errorCB) {\n this._dispatcher = _dispatcher;\n this._successCB = _successCB;\n this._errorCB = _errorCB;\n this.result = new Deferred(_dispatcher);\n }\n Client.prototype.resolve = function (value, defer) {\n var _this = this;\n if (typeof (this._successCB) !== 'function') {\n this.result.resolve(value);\n return;\n }\n if (defer) {\n this._dispatcher(function () { return _this._dispatchCallback(_this._successCB, value); });\n }\n else {\n this._dispatchCallback(this._successCB, value);\n }\n };\n Client.prototype.reject = function (error, defer) {\n var _this = this;\n if (typeof (this._errorCB) !== 'function') {\n this.result.reject(error);\n return;\n }\n if (defer) {\n this._dispatcher(function () { return _this._dispatchCallback(_this._errorCB, error); });\n }\n else {\n this._dispatchCallback(this._errorCB, error);\n }\n };\n Client.prototype._dispatchCallback = function (callback, arg) {\n var result, then, type;\n try {\n result = callback(arg);\n this.result.resolve(result);\n }\n catch (err) {\n this.result.reject(err);\n return;\n }\n };\n return Client;\n}());\nvar Deferred = (function () {\n function Deferred(dispatcher) {\n this._stack = [];\n this._state = PromiseState.Pending;\n if (dispatcher)\n this._dispatcher = dispatcher;\n else\n this._dispatcher = DispatchDeferred;\n this.promise = new Promise(this);\n }\n Deferred.prototype.DispatchDeferred = function (closure) {\n setTimeout(closure, 0);\n };\n Deferred.prototype.then = function (successCB, errorCB) {\n if (typeof (successCB) !== 'function' && typeof (errorCB) !== 'function') {\n return this.promise;\n }\n var client = new Client(this._dispatcher, successCB, errorCB);\n switch (this._state) {\n case PromiseState.Pending:\n case PromiseState.ResolutionInProgress:\n this._stack.push(client);\n break;\n case PromiseState.Resolved:\n client.resolve(this._value, true);\n break;\n case PromiseState.Rejected:\n client.reject(this._error, true);\n break;\n }\n return client.result.promise;\n };\n Deferred.prototype.resolve = function (value) {\n if (this._state !== PromiseState.Pending) {\n return this;\n }\n return this._resolve(value);\n };\n Deferred.prototype._resolve = function (value) {\n var _this = this;\n var type = typeof (value), then, pending = true;\n try {\n if (value !== null &&\n (type === 'object' || type === 'function') &&\n typeof (then = value.then) === 'function') {\n if (value === this.promise) {\n throw new TypeError('recursive resolution');\n }\n this._state = PromiseState.ResolutionInProgress;\n then.call(value, function (result) {\n if (pending) {\n pending = false;\n _this._resolve(result);\n }\n }, function (error) {\n if (pending) {\n pending = false;\n _this._reject(error);\n }\n });\n }\n else {\n this._state = PromiseState.ResolutionInProgress;\n this._dispatcher(function () {\n _this._state = PromiseState.Resolved;\n _this._value = value;\n var i, stackSize = _this._stack.length;\n for (i = 0; i < stackSize; i++) {\n _this._stack[i].resolve(value, false);\n }\n _this._stack.splice(0, stackSize);\n });\n }\n }\n catch (err) {\n if (pending) {\n this._reject(err);\n }\n }\n return this;\n };\n Deferred.prototype.reject = function (error) {\n if (this._state !== PromiseState.Pending) {\n return this;\n }\n return this._reject(error);\n };\n Deferred.prototype._reject = function (error) {\n var _this = this;\n this._state = PromiseState.ResolutionInProgress;\n this._dispatcher(function () {\n _this._state = PromiseState.Rejected;\n _this._error = error;\n var stackSize = _this._stack.length, i = 0;\n for (i = 0; i < stackSize; i++) {\n _this._stack[i].reject(error, false);\n }\n _this._stack.splice(0, stackSize);\n });\n return this;\n };\n return Deferred;\n}());\nexports.Deferred = Deferred;\nvar Promise = (function () {\n function Promise(_deferred) {\n this._deferred = _deferred;\n }\n Promise.prototype.then = function (successCallback, errorCallback) {\n return this._deferred.then(successCallback, errorCallback);\n };\n Promise.prototype.fail = function (errorCallback) {\n return this._deferred.then(undefined, errorCallback);\n };\n return Promise;\n}());\nexports.Promise = Promise;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/promises.ts\n ** module id = 2\n ** module chunks = 0\n **/","\"use strict\";\nvar promises_1 = require(\"./promises\");\n(function (OAuthVersion) {\n OAuthVersion[OAuthVersion[\"v1\"] = 1] = \"v1\";\n OAuthVersion[OAuthVersion[\"v2\"] = 2] = \"v2\";\n})(exports.OAuthVersion || (exports.OAuthVersion = {}));\nvar OAuthVersion = exports.OAuthVersion;\nvar Error = (function () {\n function Error() {\n }\n return Error;\n}());\nexports.Error = Error;\nvar CachedToken = (function () {\n function CachedToken(id, scopes, resource, token, expiry) {\n this.id = id;\n this.scopes = scopes;\n this.resource = resource;\n this.token = token;\n this.expiry = expiry;\n }\n ;\n Object.defineProperty(CachedToken.prototype, \"isExpired\", {\n get: function () {\n return this.expiry <= new Date(new Date().getTime() + 60000);\n },\n enumerable: true,\n configurable: true\n });\n CachedToken.prototype.hasScopes = function (requiredScopes) {\n var _this = this;\n if (!this.scopes) {\n return false;\n }\n return requiredScopes.every(function (requiredScope) {\n return _this.scopes.some(function (actualScope) { return requiredScope === actualScope; });\n });\n };\n return CachedToken;\n}());\nvar TokenCache = (function () {\n function TokenCache(tokenStorage) {\n var _this = this;\n this.tokenStorage = tokenStorage;\n this.cachedTokens = {};\n if (tokenStorage) {\n tokenStorage.getAll().forEach(function (_a) {\n var id = _a.id, scopes = _a.scopes, resource = _a.resource, token = _a.token, expiry = _a.expiry;\n var cachedToken = new CachedToken(id, scopes, resource, token, new Date(expiry));\n if (cachedToken.isExpired) {\n _this.tokenStorage.remove(cachedToken.id);\n }\n else {\n _this.cachedTokens[cachedToken.id] = cachedToken;\n }\n });\n }\n }\n TokenCache.prototype.add = function (token) {\n this.cachedTokens[token.id] = token;\n this.tokenStorage && this.tokenStorage.add(token.id, token);\n };\n TokenCache.prototype.getForResource = function (resource) {\n var cachedToken = this.cachedTokens[resource];\n if (cachedToken && cachedToken.isExpired) {\n this.remove(resource);\n return null;\n }\n return cachedToken;\n };\n TokenCache.prototype.getForScopes = function (scopes) {\n for (var key in this.cachedTokens) {\n var cachedToken = this.cachedTokens[key];\n if (cachedToken.hasScopes(scopes)) {\n if (cachedToken.isExpired) {\n this.remove(key);\n }\n else {\n return cachedToken;\n }\n }\n }\n return null;\n };\n TokenCache.prototype.clear = function () {\n this.cachedTokens = {};\n this.tokenStorage && this.tokenStorage.clear();\n };\n TokenCache.prototype.remove = function (key) {\n this.tokenStorage && this.tokenStorage.remove(key);\n delete this.cachedTokens[key];\n };\n return TokenCache;\n}());\nvar IdToken = (function () {\n function IdToken() {\n }\n return IdToken;\n}());\nexports.IdToken = IdToken;\nvar Identity = (function () {\n function Identity(identitySettings) {\n var _this = this;\n this.policy = \"\";\n this.clientId = identitySettings.clientId;\n this.tokenProcessorUrl = identitySettings.tokenProcessingUri;\n if (identitySettings.version)\n this.version = identitySettings.version;\n else\n this.version = OAuthVersion.v1;\n this.tokenCache = new TokenCache(identitySettings.tokenStorage);\n window.addEventListener(\"message\", function (event) {\n if (event.data.type === \"id_token\") {\n if (event.data.error) {\n var e = new Error();\n e.text = event.data.error;\n _this.loginCallback(e);\n }\n else {\n if (_this.state !== event.data.state) {\n var error = new Error();\n error.statusText = \"Invalid state\";\n _this.loginCallback(error);\n }\n else {\n _this.decodeIdToken(event.data.token);\n _this.loginCallback(null);\n }\n }\n }\n else if (event.data.type === \"access_token\") {\n if (event.data.error) {\n var e = new Error();\n e.text = event.data.error;\n _this.getTokenCallback(null, e);\n }\n else {\n var token = event.data.token;\n var iframe = document.getElementById(\"tokenIFrame\");\n iframe.parentNode.removeChild(iframe);\n if (event.data.state !== _this.state) {\n var error = new Error();\n error.statusText = \"Invalid state\";\n _this.getTokenCallback(null, error);\n }\n else {\n _this.getTokenCallback(token, null);\n }\n }\n }\n });\n }\n Identity.prototype.checkForIdentityRedirect = function () {\n function token(s) {\n var start = window.location.href.indexOf(s);\n if (start < 0)\n return null;\n var end = window.location.href.indexOf(\"&\", start + s.length);\n return window.location.href.substring(start, ((end > 0) ? end : window.location.href.length));\n }\n function parseQueryString(str) {\n var queryString = str || window.location.search || '';\n var keyValPairs = [];\n var params = {};\n queryString = queryString.replace(/.*?\\?/, \"\");\n if (queryString.length) {\n keyValPairs = queryString.split('&');\n for (var pairNum in keyValPairs) {\n var key = keyValPairs[pairNum].split('=')[0];\n if (!key.length)\n continue;\n if (typeof params[key] === 'undefined')\n params[key] = [];\n params[key].push(keyValPairs[pairNum].split('=')[1]);\n }\n }\n return params;\n }\n var params = parseQueryString(window.location.href);\n var idToken = token(\"#id_token=\");\n var accessToken = token(\"#access_token\");\n if (idToken) {\n if (true || this.state === params[\"state\"][0]) {\n this.decodeIdToken(idToken);\n this.loginCallback && this.loginCallback(null);\n }\n else {\n var error = new Error();\n error.statusText = \"Invalid state\";\n this.loginCallback && this.loginCallback(error);\n }\n return true;\n }\n else if (accessToken) {\n throw \"Should not get here. This should be handled via the iframe approach.\";\n }\n return false;\n };\n Identity.prototype.decodeIdToken = function (idToken) {\n var _this = this;\n var decodedToken = this.base64Decode(idToken.substring(idToken.indexOf('.') + 1, idToken.lastIndexOf('.')));\n var decodedTokenJSON = JSON.parse(decodedToken);\n var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000);\n this.idToken = new IdToken();\n this.idToken.FullToken = decodedTokenJSON;\n this.idToken.Token = idToken;\n this.idToken.Expiry = expiryDate;\n this.idToken.UPN = decodedTokenJSON.upn;\n this.idToken.TenantId = decodedTokenJSON.tid;\n this.idToken.FamilyName = decodedTokenJSON.family_name;\n this.idToken.GivenName = decodedTokenJSON.given_name;\n this.idToken.Name = decodedTokenJSON.name;\n this.idToken.PreferredUsername = decodedTokenJSON.preferred_username;\n var expiration = expiryDate.getTime() - new Date().getTime() - 300000;\n this.refreshTimer = setTimeout((function () {\n _this.renewIdToken();\n }), expiration);\n };\n Identity.prototype.decodeAccessToken = function (accessToken, resource, scopes) {\n var decodedToken = this.base64Decode(accessToken.substring(accessToken.indexOf('.') + 1, accessToken.lastIndexOf('.')));\n var decodedTokenJSON = JSON.parse(decodedToken);\n var expiryDate = new Date(new Date('01/01/1970 0:0 UTC').getTime() + parseInt(decodedTokenJSON.exp) * 1000);\n var key = resource || scopes.join(\" \");\n var token = new CachedToken(key, scopes, resource, accessToken, expiryDate);\n this.tokenCache.add(token);\n };\n Identity.prototype.getIdToken = function () {\n return this.idToken;\n };\n Identity.prototype.isLoggedIn = function () {\n if (!this.idToken)\n return false;\n return (this.idToken.Expiry > new Date());\n };\n Identity.prototype.renewIdToken = function () {\n clearTimeout(this.refreshTimer);\n this.login(function () { });\n };\n Identity.prototype.getCurrentOauthVersion = function () {\n return this.version;\n };\n Identity.prototype.getAccessTokenAsync = function (resource) {\n var d = new promises_1.Deferred();\n this.getAccessToken(resource, (function (token, error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(token);\n }\n }));\n return d.promise;\n };\n Identity.prototype.getAccessToken = function (resource, callback) {\n var _this = this;\n if (this.version !== OAuthVersion.v1) {\n var e = new Error();\n e.statusText = \"Currently this identity class is using v2 OAuth mode. You need to use getAccessTokenForScopes() method\";\n callback(null, e);\n return;\n }\n var token = this.tokenCache.getForResource(resource);\n if (token) {\n return callback(token.token, null);\n }\n this.getTokenCallback = (function (token, error) {\n if (error) {\n callback(null, error);\n }\n else {\n _this.decodeAccessToken(token, resource);\n callback(token, null);\n }\n });\n this.nonce = \"token\" + this.generateNonce();\n this.state = \"token\" + this.generateNonce();\n var iframe = document.createElement('iframe');\n iframe.style.display = \"none\";\n iframe.id = \"tokenIFrame\";\n iframe.src = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&resource=\" + encodeURIComponent(resource) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&op=token\";\n document.body.appendChild(iframe);\n };\n Identity.prototype.getAccessTokenForScopesAsync = function (scopes, promptForConsent) {\n if (promptForConsent === void 0) { promptForConsent = false; }\n var d = new promises_1.Deferred();\n this.getAccessTokenForScopes(scopes, promptForConsent, function (token, error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(token);\n }\n });\n return d.promise;\n };\n Identity.prototype.getAccessTokenForScopes = function (scopes, promptForConsent, callback) {\n var _this = this;\n if (promptForConsent === void 0) { promptForConsent = false; }\n if (this.version !== OAuthVersion.v2) {\n var e = new Error();\n e.statusText = \"Dynamic scopes require v2 mode. Currently this identity class is using v1\";\n callback(null, e);\n return;\n }\n var token = this.tokenCache.getForScopes(scopes);\n if (token) {\n return callback(token.token, null);\n }\n this.getTokenCallback = (function (token, error) {\n if (error) {\n if (promptForConsent || !error.text) {\n callback(null, error);\n }\n else if (error.text.indexOf(\"AADSTS65001\") >= 0) {\n _this.getAccessTokenForScopes(scopes, true, _this.getTokenCallback);\n }\n else {\n callback(null, error);\n }\n }\n else {\n _this.decodeAccessToken(token, null, scopes);\n callback(token, null);\n }\n });\n this.nonce = \"token\" + this.generateNonce();\n this.state = \"token\" + this.generateNonce();\n if (!promptForConsent) {\n var iframe = document.createElement('iframe');\n iframe.style.display = \"none\";\n iframe.id = \"tokenIFrame\";\n iframe.src = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&scopes=\" + encodeURIComponent(scopes.join(\" \")) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&login_hint=\" + encodeURIComponent(this.idToken.PreferredUsername) +\n \"&domain_hint=\" + encodeURIComponent(this.idToken.TenantId === \"9188040d-6c67-4c5b-b112-36a304b66dad\" ? \"consumers\" : \"organizations\") +\n \"&op=token\";\n document.body.appendChild(iframe);\n }\n else {\n window.open(this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&scopes=\" + encodeURIComponent(scopes.join(\" \")) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&op=token\", \"_blank\");\n }\n };\n Identity.prototype.loginAsync = function (loginSettings) {\n var d = new promises_1.Deferred();\n this.login(function (error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(null);\n }\n }, loginSettings);\n return d.promise;\n };\n Identity.prototype.login = function (callback, loginSettings) {\n this.loginCallback = callback;\n if (!loginSettings)\n loginSettings = {};\n if (loginSettings.policy)\n this.policy = loginSettings.policy;\n if (loginSettings.scopes && this.version === OAuthVersion.v1) {\n var e = new Error();\n e.text = \"Scopes can only be used with OAuth v2.\";\n callback(e);\n return;\n }\n if (loginSettings.policy && !loginSettings.tenant) {\n var e = new Error();\n e.text = \"In order to use policy (AAD B2C) a tenant must be specified as well.\";\n callback(e);\n return;\n }\n this.state = \"login\" + this.generateNonce();\n this.nonce = \"login\" + this.generateNonce();\n var loginURL = this.tokenProcessorUrl + \"?clientId=\" + encodeURIComponent(this.clientId) +\n \"&redirectUri=\" + encodeURIComponent(this.tokenProcessorUrl) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce) +\n \"&version=\" + encodeURIComponent(this.version.toString()) +\n \"&op=login\" +\n \"&p=\" + encodeURIComponent(this.policy);\n if (loginSettings.tenant) {\n loginURL += \"&tenant=\" + encodeURIComponent(loginSettings.tenant);\n }\n if (this.version === OAuthVersion.v2) {\n if (!loginSettings.scopes)\n loginSettings.scopes = [];\n if (loginSettings.scopes.indexOf(\"profile\") < 0)\n loginSettings.scopes.push(\"profile\");\n if (loginSettings.scopes.indexOf(\"openid\") < 0)\n loginSettings.scopes.push(\"openid\");\n loginURL += \"&scopes=\" + encodeURIComponent(loginSettings.scopes.join(\" \"));\n }\n window.open(loginURL, \"_blank\");\n };\n Identity.prototype.loginNoWindowAsync = function (toUrl) {\n var d = new promises_1.Deferred();\n this.loginNoWindow(function (error) {\n if (error) {\n d.reject(error);\n }\n else {\n d.resolve(null);\n }\n }, toUrl);\n return d.promise;\n };\n Identity.prototype.loginNoWindow = function (callback, toUrl) {\n this.loginCallback = callback;\n this.state = \"clientId=\" + this.clientId + \"&\" + \"tokenProcessorUrl=\" + this.tokenProcessorUrl;\n this.nonce = this.generateNonce();\n var redirected = this.checkForIdentityRedirect();\n if (!redirected) {\n var redirectUri = (toUrl) ? toUrl : window.location.href.split(\"#\")[0];\n var url = \"https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token\" +\n \"&client_id=\" + encodeURIComponent(this.clientId) +\n \"&redirect_uri=\" + encodeURIComponent(redirectUri) +\n \"&state=\" + encodeURIComponent(this.state) +\n \"&nonce=\" + encodeURIComponent(this.nonce);\n window.location.href = url;\n }\n };\n Identity.prototype.logOut = function () {\n this.tokenCache.clear();\n var url = \"https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=\" + encodeURI(window.location.href);\n window.location.href = url;\n };\n Identity.prototype.base64Decode = function (encodedString) {\n var e = {}, i, b = 0, c, x, l = 0, a, r = '', w = String.fromCharCode, L = encodedString.length;\n var A = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n for (i = 0; i < 64; i++) {\n e[A.charAt(i)] = i;\n }\n for (x = 0; x < L; x++) {\n c = e[encodedString.charAt(x)];\n b = (b << 6) + c;\n l += 6;\n while (l >= 8) {\n ((a = (b >>> (l -= 8)) & 0xff) || (x < (L - 2))) && (r += w(a));\n }\n }\n return r;\n };\n Identity.prototype.generateNonce = function () {\n var text = \"\";\n var chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n for (var i = 0; i < 32; i++) {\n text += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return text;\n };\n return Identity;\n}());\nexports.Identity = Identity;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/identity.ts\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/login.html b/dist/login.html new file mode 100644 index 00000000..24de9a9f --- /dev/null +++ b/dist/login.html @@ -0,0 +1,224 @@ + + + + Active Directory Helper + + + + + + + + +
+ + + + + diff --git a/gulp-addModuleExports.js b/gulp-addModuleExports.js deleted file mode 100644 index c21dff78..00000000 --- a/gulp-addModuleExports.js +++ /dev/null @@ -1,45 +0,0 @@ -var gutil = require('gulp-util'); -var through = require('through2'); - - -module.exports = function (varName) { - return through.obj(function (file, enc, cb) { - - - var moduleExportsAddition = - '\nif (((typeof window != "undefined" && window.module) || (typeof module != "undefined")) && typeof module.exports != "undefined") {\n' + - ' module.exports = ' + varName + ';\n' + - '};\n'; - - var extendsAddition = - 'var __extends = (this && this.__extends) || function (d, b) {\n' + - 'for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n' + - 'function __() { this.constructor = d; }\n' + - '__.prototype = b.prototype;\n' + - 'd.prototype = new __();\n' + - '};\n'; - - - if (file.isNull()) { - cb(null, file); - return; - } - - - if (file.isStream()) { - //streams not supported, no need for now. - return; - } - - - try { - file.contents = new Buffer(extendsAddition.concat(String(file.contents)).concat(moduleExportsAddition)); - this.push(file); - - - } catch (err) { - this.emit('error', new gutil.PluginError('gulp-add-module-exports', err, {fileName: file.path})); - } - cb(); - }); - }; diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index a7f60903..00000000 --- a/gulpfile.js +++ /dev/null @@ -1,89 +0,0 @@ -var gulp = require("gulp"); -var uglify = require("gulp-uglify"); -var typescript = require("gulp-typescript"); -var sourcemaps = require("gulp-sourcemaps"); -var merge2 = require("merge2"); -var concat = require("gulp-concat"); -var rename = require("gulp-rename"); -var changed = require('gulp-changed'); -var runSequence = require('run-sequence'); -var replace = require("gulp-replace"); -var config = require("./config.json"); -var addModuleExports = require("./gulp-addModuleExports"); -/* -Compiles all typescript files and creating a declaration file. -*/ -gulp.task('default', ['typescript-compile'], function () { - gulp.src(config.build.srcOutputDirectory + '-' + config.build.version + '/kurve-' + config.build.version + '.js') - .pipe(addModuleExports("Kurve")) - .pipe(gulp.dest(config.build.outputDirectory + '-' + config.build.version + '/')) - .pipe(rename(config.build.minFilename + '-' + config.build.version + '.js')) - .pipe(uglify()) - .pipe(gulp.dest(config.build.outputDirectory + '-' + config.build.version + '/')); -}); - - -gulp.task('typescript-sourcemaps',['move-html'], function () { - var tsResult = gulp.src(config.core.typescript) - .pipe(sourcemaps.init()) // sourcemaps init. currently redundant directory def, waiting for this - https://github.com/floridoo/gulp-sourcemaps/issues/111 - .pipe(typescript({ - noExternalResolve: true, - target: 'ES5', - declarationFiles: true, - typescript: require('typescript'), - out: 'kurve-' + config.build.version + '.js' - })); - return tsResult.js - .pipe(sourcemaps.write("./")) // sourcemaps are written. - .pipe(gulp.dest(config.build.srcOutputDirectory + '-' + config.build.version + '/')); - -}); - -gulp.task('typescript-compile',["typescript-sourcemaps"], function() { - var tsResult = gulp.src(config.core.typescript) - .pipe(typescript({ - noExternalResolve: true, - target: 'ES5', - declarationFiles: true, - typescript: require('typescript'), - out: 'kurve-' + config.build.version + '.js' - })); - return merge2([ - tsResult.dts - .pipe(concat('kurve-' + config.build.version + config.build.declarationFilename)) - .pipe(gulp.dest(config.build.outputDirectory + '-' + config.build.version + '/')), - tsResult.js - .pipe(gulp.dest(config.build.srcOutputDirectory + '-' + config.build.version + '/')) - ]); - }); - -gulp.task('app-compile', ["typescript-compile"], function () { - return gulp - .src(['./Examples/OAuthV1/app.ts', - './Examples/OAuthV2/app.ts', - './Examples/NoWindow/noLoginWindow.ts', - './dist-' + config.build.version + '/kurve-' + config.build.version + '.d.ts'], - { base: '.' }) - .pipe(typescript({ - noExternalResolve: true, - target: 'ES5', - outDir: './', - typescript: require('typescript') - })) - .pipe(gulp.dest('./')); -}); - -/** - * Watch task, will call the default task if a js file is updated. - */ -gulp.task('watch', function () { - gulp.watch(config.core.typescript, ['default']); -}); - -gulp.task('move-html', function () { - var result = gulp.src(['login.html']) - .pipe(gulp.dest('./dist-' + config.build.version)); - return result; -}); - - diff --git a/package.json b/package.json index 3891fa9e..5651ea20 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,32 @@ { - "name": "kurveJS", - "version": "0.4.1", - "description": "Kurve JS library", - "main": "", - "license": "MIT", - "devDependencies": { - "gulp": "^3.9.0", - "gulp-changed": "~1.2.1", - "gulp-clean-ts-extends": "~0.1.1", - "gulp-concat": "~2.5.2", - "gulp-rename": "~1.2.2", - "gulp-replace": "~0.5.3", - "gulp-sourcemaps": "~1.5.2", - "gulp-typescript": "~2.9.0", - "gulp-uglify": "~1.2.0", - "gulp-util": "~3.0.4", - "gulp-webserver": "^0.9.1", - "merge2": "~0.3.5", - "run-sequence": "~1.1.0", - "through2": "~0.6.5", - "typescript": "~1.6.2" - } + "name": "kurve-js", + "version": "0.5.0", + "description": "Kurve JS library", + "license": "MIT", + "main": "./dist/kurve.js", + "typings": "./dist/kurve.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/MicrosoftDX/kurvejs" + }, + "devDependencies": { + "chai": "3.5.0", + "dts-generator": "1.7.0", + "mocha": "2.4.5", + "sinon": "1.17.3", + "ts-loader": "0.8.1", + "ts-node": "0.7.0", + "tsify": "0.14.1", + "typescript": "1.8.9", + "webpack": "1.12.14" + }, + "scripts": { + "test": "mocha --require ts-node/register test/**/*.ts", + "build:cleanup": "rm -rf ./dist ", + "build:dts": "./node_modules/dts-generator/bin/dts-generator --name kurve --project ./ --out dist/kurve.d.ts", + "build:bundle": "webpack", + "build:bundle-min": "MINIFIED=true webpack", + "build:copy-index": "cp ./login.html ./dist/login.html", + "build": "npm run build:cleanup && npm run build:dts && npm run build:bundle && npm run build:bundle-min && npm run build:copy-index" + } } diff --git a/KurveGraph.ts b/src/graph.ts similarity index 99% rename from KurveGraph.ts rename to src/graph.ts index e83b7dd3..28b5e785 100755 --- a/KurveGraph.ts +++ b/src/graph.ts @@ -1,5 +1,8 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. -module Kurve { + +import { Deferred, Promise, PromiseCallback } from "./promises"; +import { Identity, OAuthVersion, Error } from "./identity"; + export module Scopes { class Util { static rootUrl = "https://graph.microsoft.com/"; @@ -162,7 +165,7 @@ module Kurve { public mailFoldersAsync(odataQuery?: string): Promise { return this.graph.mailFoldersForUserAsync(this._data.userPrincipalName, odataQuery); } - + public message(messageId: string, callback: PromiseCallback, odataQuery?: string) { this.graph.messageForUser(this._data.userPrincipalName, messageId, callback, odataQuery); } @@ -170,7 +173,7 @@ module Kurve { public messageAsync(messageId: string, odataQuery?: string): Promise { return this.graph.messageForUserAsync(this._data.userPrincipalName, messageId, odataQuery); } - + public event(eventId: string, callback: PromiseCallback, odataQuery?: string) { this.graph.eventForUser(this._data.userPrincipalName, eventId, callback, odataQuery); } @@ -178,8 +181,8 @@ module Kurve { public eventAsync(eventId: string, odataQuery?: string): Promise { return this.graph.eventForUserAsync(this._data.userPrincipalName, eventId, odataQuery); } - - + + public messageAttachment(messageId: string, attachmentId: string, callback: PromiseCallback, odataQuery?: string) { this.graph.messageAttachmentForUser(this._data.userPrincipalName, messageId, attachmentId, callback, odataQuery); } @@ -308,7 +311,7 @@ module Kurve { export class Event extends DataModelWrapper{ } - + export class Events extends DataModelListWrapper{ constructor(protected graph: Graph, protected endpoint: EventsEndpoint, protected _data: Event[]) { super(graph, _data); @@ -517,7 +520,7 @@ module Kurve { } // Events For User - + public eventForUserAsync(userPrincipalName: string, eventId: string, odataQuery?: string): Promise { var d = new Deferred(); this.eventForUser(userPrincipalName, eventId, (event, error) => error ? d.reject(error) : d.resolve(event), odataQuery); @@ -956,7 +959,7 @@ module Kurve { callback(result, null); }, "blob",scopes); } - + private getMailFolders(urlString, callback: PromiseCallback, scopes?: string[]): void { this.get(urlString, (result: string, errorGet: Error) => { if (errorGet) { @@ -1059,7 +1062,6 @@ module Kurve { return this.buildUrl("groups/", path, odataQuery); } } -} //********************************************************* // diff --git a/KurveIdentity.ts b/src/identity.ts similarity index 99% rename from KurveIdentity.ts rename to src/identity.ts index 8c785cd7..0dfb81f1 100644 --- a/KurveIdentity.ts +++ b/src/identity.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. -module Kurve { + +import { Deferred, Promise, PromiseCallback } from "./promises"; export enum OAuthVersion { v1=1, @@ -558,7 +559,6 @@ module Kurve { return text; } } -} //********************************************************* diff --git a/src/kurve.ts b/src/kurve.ts new file mode 100644 index 00000000..34d09bb7 --- /dev/null +++ b/src/kurve.ts @@ -0,0 +1,7 @@ +import { Graph } from "./graph"; +import { Identity } from "./identity"; + +export = { + Graph, + Identity +}; diff --git a/promises.ts b/src/promises.ts similarity index 94% rename from promises.ts rename to src/promises.ts index 1129bc87..defffc18 100644 --- a/promises.ts +++ b/src/promises.ts @@ -1,7 +1,7 @@ // Adapted from the original source: https://github.com/DirtyHairy/typescript-deferred // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. -module Kurve { +import { Error } from "./identity"; function DispatchDeferred(closure: () => void) { setTimeout(closure, 0); @@ -229,39 +229,38 @@ module Kurve { return this._deferred.then(undefined, errorCallback); } } -} -//********************************************************* -// +//********************************************************* +// //Kurve js, https://github.com/microsoftdx/kurvejs -// -//Copyright (c) Microsoft Corporation -//All rights reserved. -// -// MIT License: -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// ""Software""), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: +// +//Copyright (c) Microsoft Corporation +//All rights reserved. +// +// MIT License: +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// ""Software""), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -//********************************************************* +// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//********************************************************* diff --git a/test/graph.spec.ts b/test/graph.spec.ts new file mode 100644 index 00000000..d9abd391 --- /dev/null +++ b/test/graph.spec.ts @@ -0,0 +1,28 @@ +/// +import { expect } from "chai"; +import { mock } from "sinon"; +import { Graph } from "../src/graph"; + +describe("Graph", () => { + + describe("meAsync", () => { + + it("should get /me url", (done) => { + var graph = new Graph({ + defaultAccessToken: "access_token" + }); + + var mockedGet = mock(graph); + + mockedGet.expects("get") + .withArgs("https://graph.microsoft.com/v1.0/me/") + .yields(JSON.stringify({ displayName: "John" }), null); + + graph.meAsync().then((user) => { + expect(user.data.displayName).to.be.equal("John"); + mockedGet.verify(); + done(); + }); + }); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 95b15068..92c9ab92 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,21 +2,13 @@ "compilerOptions": { "removeComments": true, "preserveConstEnums": true, - "target": "es5", - "sourceMap": true + "module": "commonjs", + "target": "es5" }, - "exclude": [ - "dist", - "node_modules", - "wwwroot", - "dist-0.1.0", - "dist-0.2.0", - "dist-0.3.0", - "dist-0.3.1", - "dist-0.3.5", - "dist-0.3.6", - "dist-0.3.7", - "dist-0.4.0", - "dist-0.4.1" + "files": [ + "src/kurve.ts", + "src/graph.ts", + "src/identity.ts", + "src/promises.ts" ] } diff --git a/typings.json b/typings.json new file mode 100644 index 00000000..81416081 --- /dev/null +++ b/typings.json @@ -0,0 +1,12 @@ +{ + "name": "kurveJS", + "version": false, + "dependencies": {}, + "devDependencies": {}, + "ambientDevDependencies": {}, + "ambientDependencies": { + "chai": "registry:dt/chai#3.4.0+20160317120654", + "mocha": "registry:dt/mocha#2.2.5+20160317120654", + "sinon": "registry:dt/sinon#1.16.0+20160317120654" + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..5a8b8340 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,21 @@ +var webpack = require('webpack'); +var minified = process.env.MINIFIED === 'true'; + +module.exports = { + entry: './src/kurve.ts', + output: { + library: "Kurve", + libraryTarget: "umd", + filename: minified ? 'dist/kurve.min.js' : 'dist/kurve.js' + }, + devtool: 'source-map', + plugins: minified ? [ new webpack.optimize.UglifyJsPlugin({minimize: true}) ] : [], + resolve: { + extensions: ['', '.webpack.js', '.web.js', '.ts'] + }, + module: { + loaders: [ + { loader: 'ts-loader' } + ] + } +}