msal
Version:
Microsoft Authentication Library for js
1,283 lines (1,259 loc) • 329 kB
JavaScript
/*! msal v1.4.4 2020-11-11 */
'use strict';
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("Msal", [], factory);
else if(typeof exports === 'object')
exports["Msal"] = factory();
else
root["Msal"] = factory();
})(window, 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] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = 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;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 28);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
Object.defineProperty(exports, "__esModule", { value: true });
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
exports.__extends = __extends;
exports.__assign = function () {
exports.__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return exports.__assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
exports.__rest = __rest;
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
exports.__decorate = __decorate;
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); };
}
exports.__param = __param;
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
}
exports.__metadata = __metadata;
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try {
step(generator.next(value));
}
catch (e) {
reject(e);
} }
function rejected(value) { try {
step(generator["throw"](value));
}
catch (e) {
reject(e);
} }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
exports.__awaiter = __awaiter;
function __generator(thisArg, body) {
var _ = { label: 0, sent: function () { if (t[0] & 1)
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f)
throw new TypeError("Generator is already executing.");
while (_)
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
return t;
if (y = 0, t)
op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
}
catch (e) {
op = [6, e];
y = 0;
}
finally {
f = t = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
}
exports.__generator = __generator;
function __exportStar(m, exports) {
for (var p in m)
if (!exports.hasOwnProperty(p))
exports[p] = m[p];
}
exports.__exportStar = __exportStar;
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m)
return m.call(o);
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
exports.__values = __values;
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
exports.__read = __read;
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
exports.__spread = __spread;
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
exports.__spreadArrays = __spreadArrays;
;
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
exports.__await = __await;
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n])
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try {
step(g[n](v));
}
catch (e) {
settle(q[0][3], e);
} }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length)
resume(q[0][0], q[0][1]); }
}
exports.__asyncGenerator = __asyncGenerator;
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
exports.__asyncDelegator = __asyncDelegator;
function __asyncValues(o) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
}
exports.__asyncValues = __asyncValues;
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", { value: raw });
}
else {
cooked.raw = raw;
}
return cooked;
}
exports.__makeTemplateObject = __makeTemplateObject;
;
function __importStar(mod) {
if (mod && mod.__esModule)
return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (Object.hasOwnProperty.call(mod, k))
result[k] = mod[k];
result.default = mod;
return result;
}
exports.__importStar = __importStar;
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
exports.__importDefault = __importDefault;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @hidden
* Constants
*/
var Constants = /** @class */ (function () {
function Constants() {
}
Object.defineProperty(Constants, "libraryName", {
get: function () { return "Msal.js"; } // used in telemetry sdkName
,
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "claims", {
get: function () { return "claims"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "clientId", {
get: function () { return "clientId"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "adalIdToken", {
get: function () { return "adal.idtoken"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "cachePrefix", {
get: function () { return "msal"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "scopes", {
get: function () { return "scopes"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "no_account", {
get: function () { return "NO_ACCOUNT"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "upn", {
get: function () { return "upn"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "domain_hint", {
get: function () { return "domain_hint"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "prompt_select_account", {
get: function () { return "&prompt=select_account"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "prompt_none", {
get: function () { return "&prompt=none"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "prompt", {
get: function () { return "prompt"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "response_mode_fragment", {
get: function () { return "&response_mode=fragment"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "resourceDelimiter", {
get: function () { return "|"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "cacheDelimiter", {
get: function () { return "."; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "popUpWidth", {
get: function () { return this._popUpWidth; },
set: function (width) {
this._popUpWidth = width;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "popUpHeight", {
get: function () { return this._popUpHeight; },
set: function (height) {
this._popUpHeight = height;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "login", {
get: function () { return "LOGIN"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "renewToken", {
get: function () { return "RENEW_TOKEN"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "unknown", {
get: function () { return "UNKNOWN"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "ADFS", {
get: function () { return "adfs"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "homeAccountIdentifier", {
get: function () { return "homeAccountIdentifier"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "common", {
get: function () { return "common"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "openidScope", {
get: function () { return "openid"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "profileScope", {
get: function () { return "profile"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "oidcScopes", {
get: function () { return [this.openidScope, this.profileScope]; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "interactionTypeRedirect", {
get: function () { return "redirectInteraction"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "interactionTypePopup", {
get: function () { return "popupInteraction"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "interactionTypeSilent", {
get: function () { return "silentInteraction"; },
enumerable: true,
configurable: true
});
Object.defineProperty(Constants, "inProgress", {
get: function () { return "inProgress"; },
enumerable: true,
configurable: true
});
Constants._popUpWidth = 483;
Constants._popUpHeight = 600;
return Constants;
}());
exports.Constants = Constants;
/**
* Keys in the hashParams
*/
var ServerHashParamKeys;
(function (ServerHashParamKeys) {
ServerHashParamKeys["SCOPE"] = "scope";
ServerHashParamKeys["STATE"] = "state";
ServerHashParamKeys["ERROR"] = "error";
ServerHashParamKeys["ERROR_DESCRIPTION"] = "error_description";
ServerHashParamKeys["ACCESS_TOKEN"] = "access_token";
ServerHashParamKeys["ID_TOKEN"] = "id_token";
ServerHashParamKeys["EXPIRES_IN"] = "expires_in";
ServerHashParamKeys["SESSION_STATE"] = "session_state";
ServerHashParamKeys["CLIENT_INFO"] = "client_info";
})(ServerHashParamKeys = exports.ServerHashParamKeys || (exports.ServerHashParamKeys = {}));
/**
* @hidden
* @ignore
* response_type from OpenIDConnect
* References: https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html & https://tools.ietf.org/html/rfc6749#section-4.2.1
*
*/
exports.ResponseTypes = {
id_token: "id_token",
token: "token",
id_token_token: "id_token token"
};
/**
* @hidden
* CacheKeys for MSAL
*/
var TemporaryCacheKeys;
(function (TemporaryCacheKeys) {
TemporaryCacheKeys["AUTHORITY"] = "authority";
TemporaryCacheKeys["ACQUIRE_TOKEN_ACCOUNT"] = "acquireTokenAccount";
TemporaryCacheKeys["SESSION_STATE"] = "session.state";
TemporaryCacheKeys["STATE_LOGIN"] = "state.login";
TemporaryCacheKeys["STATE_ACQ_TOKEN"] = "state.acquireToken";
TemporaryCacheKeys["STATE_RENEW"] = "state.renew";
TemporaryCacheKeys["NONCE_IDTOKEN"] = "nonce.idtoken";
TemporaryCacheKeys["LOGIN_REQUEST"] = "login.request";
TemporaryCacheKeys["RENEW_STATUS"] = "token.renew.status";
TemporaryCacheKeys["URL_HASH"] = "urlHash";
TemporaryCacheKeys["INTERACTION_STATUS"] = "interaction_status";
TemporaryCacheKeys["REDIRECT_REQUEST"] = "redirect_request";
})(TemporaryCacheKeys = exports.TemporaryCacheKeys || (exports.TemporaryCacheKeys = {}));
var PersistentCacheKeys;
(function (PersistentCacheKeys) {
PersistentCacheKeys["IDTOKEN"] = "idtoken";
PersistentCacheKeys["CLIENT_INFO"] = "client.info";
})(PersistentCacheKeys = exports.PersistentCacheKeys || (exports.PersistentCacheKeys = {}));
var ErrorCacheKeys;
(function (ErrorCacheKeys) {
ErrorCacheKeys["LOGIN_ERROR"] = "login.error";
ErrorCacheKeys["ERROR"] = "error";
ErrorCacheKeys["ERROR_DESC"] = "error.description";
})(ErrorCacheKeys = exports.ErrorCacheKeys || (exports.ErrorCacheKeys = {}));
exports.DEFAULT_AUTHORITY = "https://login.microsoftonline.com/common/";
exports.AAD_INSTANCE_DISCOVERY_ENDPOINT = exports.DEFAULT_AUTHORITY + "/discovery/instance?api-version=1.1&authorization_endpoint=";
exports.WELL_KNOWN_SUFFIX = ".well-known/openid-configuration";
/**
* @hidden
* SSO Types - generated to populate hints
*/
var SSOTypes;
(function (SSOTypes) {
SSOTypes["ACCOUNT"] = "account";
SSOTypes["SID"] = "sid";
SSOTypes["LOGIN_HINT"] = "login_hint";
SSOTypes["ORGANIZATIONS"] = "organizations";
SSOTypes["ID_TOKEN"] = "id_token";
SSOTypes["ACCOUNT_ID"] = "accountIdentifier";
SSOTypes["HOMEACCOUNT_ID"] = "homeAccountIdentifier";
})(SSOTypes = exports.SSOTypes || (exports.SSOTypes = {}));
/**
* @hidden
*/
exports.BlacklistedEQParams = [
SSOTypes.SID,
SSOTypes.LOGIN_HINT
];
exports.NetworkRequestType = {
GET: "GET",
POST: "POST"
};
/**
* we considered making this "enum" in the request instead of string, however it looks like the allowed list of
* prompt values kept changing over past couple of years. There are some undocumented prompt values for some
* internal partners too, hence the choice of generic "string" type instead of the "enum"
* @hidden
*/
exports.PromptState = {
LOGIN: "login",
SELECT_ACCOUNT: "select_account",
CONSENT: "consent",
NONE: "none"
};
/**
* Frame name prefixes for the hidden iframe created in silent frames
*/
exports.FramePrefix = {
ID_TOKEN_FRAME: "msalIdTokenFrame",
TOKEN_FRAME: "msalRenewFrame"
};
/**
* MSAL JS Library Version
*/
function libraryVersion() {
return "1.4.4";
}
exports.libraryVersion = libraryVersion;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @hidden
*/
var StringUtils = /** @class */ (function () {
function StringUtils() {
}
/**
* Check if a string is empty
*
* @param str
*/
StringUtils.isEmpty = function (str) {
return (typeof str === "undefined" || !str || 0 === str.length);
};
/**
* Check if a string's value is a valid JSON object
*
* @param str
*/
StringUtils.validateAndParseJsonCacheKey = function (str) {
try {
var parsedKey = JSON.parse(str);
/**
* There are edge cases in which JSON.parse will successfully parse a non-valid JSON object
* (e.g. JSON.parse will parse an escaped string into an unescaped string), so adding a type check
* of the parsed value is necessary in order to be certain that the string represents a valid JSON object.
*
*/
return (parsedKey && typeof parsedKey === "object") ? parsedKey : null;
}
catch (error) {
return null;
}
};
return StringUtils;
}());
exports.StringUtils = StringUtils;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @hidden
*/
var CryptoUtils = /** @class */ (function () {
function CryptoUtils() {
}
/**
* Creates a new random GUID
* @returns string (GUID)
*/
CryptoUtils.createNewGuid = function () {
/*
* RFC4122: The version 4 UUID is meant for generating UUIDs from truly-random or
* pseudo-random numbers.
* The algorithm is as follows:
* Set the two most significant bits (bits 6 and 7) of the
* clock_seq_hi_and_reserved to zero and one, respectively.
* Set the four most significant bits (bits 12 through 15) of the
* time_hi_and_version field to the 4-bit version number from
* Section 4.1.3. Version4
* Set all the other bits to randomly (or pseudo-randomly) chosen
* values.
* UUID = time-low "-" time-mid "-"time-high-and-version "-"clock-seq-reserved and low(2hexOctet)"-" node
* time-low = 4hexOctet
* time-mid = 2hexOctet
* time-high-and-version = 2hexOctet
* clock-seq-and-reserved = hexOctet:
* clock-seq-low = hexOctet
* node = 6hexOctet
* Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
* y could be 1000, 1001, 1010, 1011 since most significant two bits needs to be 10
* y values are 8, 9, A, B
*/
var cryptoObj = window.crypto; // for IE 11
if (cryptoObj && cryptoObj.getRandomValues) {
var buffer = new Uint8Array(16);
cryptoObj.getRandomValues(buffer);
// buffer[6] and buffer[7] represents the time_hi_and_version field. We will set the four most significant bits (4 through 7) of buffer[6] to represent decimal number 4 (UUID version number).
buffer[6] |= 0x40; // buffer[6] | 01000000 will set the 6 bit to 1.
buffer[6] &= 0x4f; // buffer[6] & 01001111 will set the 4, 5, and 7 bit to 0 such that bits 4-7 == 0100 = "4".
// buffer[8] represents the clock_seq_hi_and_reserved field. We will set the two most significant bits (6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively.
buffer[8] |= 0x80; // buffer[8] | 10000000 will set the 7 bit to 1.
buffer[8] &= 0xbf; // buffer[8] & 10111111 will set the 6 bit to 0.
return CryptoUtils.decimalToHex(buffer[0]) + CryptoUtils.decimalToHex(buffer[1])
+ CryptoUtils.decimalToHex(buffer[2]) + CryptoUtils.decimalToHex(buffer[3])
+ "-" + CryptoUtils.decimalToHex(buffer[4]) + CryptoUtils.decimalToHex(buffer[5])
+ "-" + CryptoUtils.decimalToHex(buffer[6]) + CryptoUtils.decimalToHex(buffer[7])
+ "-" + CryptoUtils.decimalToHex(buffer[8]) + CryptoUtils.decimalToHex(buffer[9])
+ "-" + CryptoUtils.decimalToHex(buffer[10]) + CryptoUtils.decimalToHex(buffer[11])
+ CryptoUtils.decimalToHex(buffer[12]) + CryptoUtils.decimalToHex(buffer[13])
+ CryptoUtils.decimalToHex(buffer[14]) + CryptoUtils.decimalToHex(buffer[15]);
}
else {
var guidHolder = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
var hex = "0123456789abcdef";
var r = 0;
var guidResponse = "";
for (var i = 0; i < 36; i++) {
if (guidHolder[i] !== "-" && guidHolder[i] !== "4") {
// each x and y needs to be random
r = Math.random() * 16 | 0;
}
if (guidHolder[i] === "x") {
guidResponse += hex[r];
}
else if (guidHolder[i] === "y") {
// clock-seq-and-reserved first hex is filtered and remaining hex values are random
r &= 0x3; // bit and with 0011 to set pos 2 to zero ?0??
r |= 0x8; // set pos 3 to 1 as 1???
guidResponse += hex[r];
}
else {
guidResponse += guidHolder[i];
}
}
return guidResponse;
}
};
/**
* verifies if a string is GUID
* @param guid
*/
CryptoUtils.isGuid = function (guid) {
var regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
return regexGuid.test(guid);
};
/**
* Decimal to Hex
*
* @param num
*/
CryptoUtils.decimalToHex = function (num) {
var hex = num.toString(16);
while (hex.length < 2) {
hex = "0" + hex;
}
return hex;
};
// See: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_4_%E2%80%93_escaping_the_string_before_encoding_it
/**
* encoding string to base64 - platform specific check
*
* @param input
*/
CryptoUtils.base64Encode = function (input) {
return btoa(encodeURIComponent(input).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
return String.fromCharCode(Number("0x" + p1));
}));
};
/**
* Decodes a base64 encoded string.
*
* @param input
*/
CryptoUtils.base64Decode = function (input) {
var encodedString = input.replace(/-/g, "+").replace(/_/g, "/");
switch (encodedString.length % 4) {
case 0:
break;
case 2:
encodedString += "==";
break;
case 3:
encodedString += "=";
break;
default:
throw new Error("Invalid base64 string");
}
return decodeURIComponent(atob(encodedString).split("").map(function (c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
}).join(""));
};
/**
* deserialize a string
*
* @param query
*/
CryptoUtils.deserialize = function (query) {
var match; // Regex for replacing addition symbol with a space
var pl = /\+/g;
var search = /([^&=]+)=([^&]*)/g;
var decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); };
var obj = {};
match = search.exec(query);
while (match) {
obj[decode(match[1])] = decode(match[2]);
match = search.exec(query);
}
return obj;
};
return CryptoUtils;
}());
exports.CryptoUtils = CryptoUtils;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Constants_1 = __webpack_require__(1);
var ScopeSet_1 = __webpack_require__(7);
var StringUtils_1 = __webpack_require__(2);
var CryptoUtils_1 = __webpack_require__(3);
/**
* @hidden
*/
var UrlUtils = /** @class */ (function () {
function UrlUtils() {
}
/**
* generates the URL with QueryString Parameters
* @param scopes
*/
UrlUtils.createNavigateUrl = function (serverRequestParams) {
var str = this.createNavigationUrlString(serverRequestParams);
var authEndpoint = serverRequestParams.authorityInstance.AuthorizationEndpoint;
// if the endpoint already has queryparams, lets add to it, otherwise add the first one
if (authEndpoint.indexOf("?") < 0) {
authEndpoint += "?";
}
else {
authEndpoint += "&";
}
var requestUrl = "" + authEndpoint + str.join("&");
return requestUrl;
};
/**
* Generate the array of all QueryStringParams to be sent to the server
* @param scopes
*/
UrlUtils.createNavigationUrlString = function (serverRequestParams) {
var scopes = ScopeSet_1.ScopeSet.appendDefaultScopes(serverRequestParams.scopes);
var str = [];
str.push("response_type=" + serverRequestParams.responseType);
str.push("scope=" + encodeURIComponent(ScopeSet_1.ScopeSet.parseScope(scopes)));
str.push("client_id=" + encodeURIComponent(serverRequestParams.clientId));
str.push("redirect_uri=" + encodeURIComponent(serverRequestParams.redirectUri));
str.push("state=" + encodeURIComponent(serverRequestParams.state));
str.push("nonce=" + encodeURIComponent(serverRequestParams.nonce));
str.push("client_info=1");
str.push("x-client-SKU=" + serverRequestParams.xClientSku);
str.push("x-client-Ver=" + serverRequestParams.xClientVer);
if (serverRequestParams.promptValue) {
str.push("prompt=" + encodeURIComponent(serverRequestParams.promptValue));
}
if (serverRequestParams.claimsValue) {
str.push("claims=" + encodeURIComponent(serverRequestParams.claimsValue));
}
if (serverRequestParams.queryParameters) {
str.push(serverRequestParams.queryParameters);
}
if (serverRequestParams.extraQueryParameters) {
str.push(serverRequestParams.extraQueryParameters);
}
str.push("client-request-id=" + encodeURIComponent(serverRequestParams.correlationId));
return str;
};
/**
* Returns current window URL as redirect uri
*/
UrlUtils.getCurrentUrl = function () {
return window.location.href.split("?")[0].split("#")[0];
};
/**
* Returns given URL with query string removed
*/
UrlUtils.removeHashFromUrl = function (url) {
return url.split("#")[0];
};
/**
* Given a url like https://a:b/common/d?e=f#g, and a tenantId, returns https://a:b/tenantId/d
* @param href The url
* @param tenantId The tenant id to replace
*/
UrlUtils.replaceTenantPath = function (url, tenantId) {
var lowerCaseUrl = url.toLowerCase();
var urlObject = this.GetUrlComponents(lowerCaseUrl);
var pathArray = urlObject.PathSegments;
if (tenantId && (pathArray.length !== 0 && (pathArray[0] === Constants_1.Constants.common || pathArray[0] === Constants_1.SSOTypes.ORGANIZATIONS))) {
pathArray[0] = tenantId;
}
return this.constructAuthorityUriFromObject(urlObject, pathArray);
};
UrlUtils.constructAuthorityUriFromObject = function (urlObject, pathArray) {
return this.CanonicalizeUri(urlObject.Protocol + "//" + urlObject.HostNameAndPort + "/" + pathArray.join("/"));
};
/**
* Checks if an authority is common (ex. https://a:b/common/)
* @param url The url
* @returns true if authority is common and false otherwise
*/
UrlUtils.isCommonAuthority = function (url) {
var authority = this.CanonicalizeUri(url);
var pathArray = this.GetUrlComponents(authority).PathSegments;
return (pathArray.length !== 0 && pathArray[0] === Constants_1.Constants.common);
};
/**
* Checks if an authority is for organizations (ex. https://a:b/organizations/)
* @param url The url
* @returns true if authority is for and false otherwise
*/
UrlUtils.isOrganizationsAuthority = function (url) {
var authority = this.CanonicalizeUri(url);
var pathArray = this.GetUrlComponents(authority).PathSegments;
return (pathArray.length !== 0 && pathArray[0] === Constants_1.SSOTypes.ORGANIZATIONS);
};
/**
* Parses out the components from a url string.
* @returns An object with the various components. Please cache this value insted of calling this multiple times on the same url.
*/
UrlUtils.GetUrlComponents = function (url) {
if (!url) {
throw "Url required";
}
// https://gist.github.com/curtisz/11139b2cfcaef4a261e0
var regEx = RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
var match = url.match(regEx);
if (!match || match.length < 6) {
throw "Valid url required";
}
var urlComponents = {
Protocol: match[1],
HostNameAndPort: match[4],
AbsolutePath: match[5]
};
var pathSegments = urlComponents.AbsolutePath.split("/");
pathSegments = pathSegments.filter(function (val) { return val && val.length > 0; }); // remove empty elements
urlComponents.PathSegments = pathSegments;
if (match[6]) {
urlComponents.Search = match[6];
}
if (match[8]) {
urlComponents.Hash = match[8];
}
return urlComponents;
};
/**
* Given a url or path, append a trailing slash if one doesnt exist
*
* @param url
*/
UrlUtils.CanonicalizeUri = function (url) {
if (url) {
url = url.toLowerCase();
}
if (url && !UrlUtils.endsWith(url, "/")) {
url += "/";
}
return url;
};
/**
* Checks to see if the url ends with the suffix
* Required because we are compiling for es5 instead of es6
* @param url
* @param str
*/
// TODO: Rename this, not clear what it is supposed to do
UrlUtils.endsWith = function (url, suffix) {
if (!url || !suffix) {
return false;
}
return url.indexOf(suffix, url.length - suffix.length) !== -1;
};
/**
* Utils function to remove the login_hint and domain_hint from the i/p extraQueryParameters
* @param url
* @param name
*/
UrlUtils.urlRemoveQueryStringParameter = function (url, name) {
if (StringUtils_1.StringUtils.isEmpty(url)) {
return url;
}
var regex = new RegExp("(\\&" + name + "=)[^\&]+");
url = url.replace(regex, "");
// name=value&
regex = new RegExp("(" + name + "=)[^\&]+&");
url = url.replace(regex, "");
// name=value
regex = new RegExp("(" + name + "=)[^\&]+");
url = url.replace(regex, "");
return url;
};
/**
* @hidden
* @ignore
*
* Returns the anchor part(#) of the URL
*/
UrlUtils.getHashFromUrl = function (urlStringOrFragment) {
var hashIndex1 = urlStringOrFragment.indexOf("#");
var hashIndex2 = urlStringOrFragment.indexOf("#/");
if (hashIndex2 > -1) {
return urlStringOrFragment.substring(hashIndex2 + 2);
}
else if (hashIndex1 > -1) {
return urlStringOrFragment.substring(hashIndex1 + 1);
}
return urlStringOrFragment;
};
/**
* @hidden
* Check if the url contains a hash with known properties
* @ignore
*/
UrlUtils.urlContainsHash = function (urlString) {
var parameters = UrlUtils.deserializeHash(urlString);
return (parameters.hasOwnProperty(Constants_1.ServerHashParamKeys.ERROR_DESCRIPTION) ||
parameters.hasOwnProperty(Constants_1.ServerHashParamKeys.ERROR) ||
parameters.hasOwnProperty(Constants_1.ServerHashParamKeys.ACCESS_TOKEN) ||
parameters.hasOwnProperty(Constants_1.ServerHashParamKeys.ID_TOKEN));
};
/**
* @hidden
* Returns deserialized portion of URL hash
* @ignore
*/
UrlUtils.deserializeHash = function (urlFragment) {
var hash = UrlUtils.getHashFromUrl(urlFragment);
return CryptoUtils_1.CryptoUtils.deserialize(hash);
};
/**
* @ignore
* @param {string} URI
* @returns {string} host from the URI
*
* extract URI from the host
*/
UrlUtils.getHostFromUri = function (uri) {
// remove http:// or https:// from uri
var extractedUri = String(uri).replace(/^(https?:)\/\//, "");
extractedUri = extractedUri.split("/")[0];
return extractedUri;
};
return UrlUtils;
}());
exports.UrlUtils = UrlUtils;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = __webpack_require__(0);
var ClientAuthError_1 = __webpack_require__(6);
exports.ClientConfigurationErrorMessage = {
configurationNotSet: {
code: "no_config_set",
desc: "Configuration has not been set. Please call the UserAgentApplication constructor with a valid Configuration object."
},
storageNotSupported: {
code: "storage_not_supported",
desc: "The value for the cacheLocation is not supported."
},
noRedirectCallbacksSet: {
code: "no_redirect_callbacks",
desc: "No redirect callbacks have been set. Please call handleRedirectCallback() with the appropriate function arguments before continuing. " +
"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
},
invalidCallbackObject: {
code: "invalid_callback_object",
desc: "The object passed for the callback was invalid. " +
"More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."
},
scopesRequired: {
code: "scopes_required",
desc: "Scopes are required to obtain an access token."
},
emptyScopes: {
code: "empty_input_scopes_error",
desc: "Scopes cannot be passed as empty array."
},
nonArrayScopes: {
code: "nonarray_input_scopes_error",
desc: "Scopes cannot be passed as non-array."
},
invalidPrompt: {
code: "invalid_prompt_value",
desc: "Supported prompt values are 'login', 'select_account', 'consent' and 'none'",
},
invalidAuthorityType: {
code: "invalid_authority_type",
desc: "The given authority is not a valid type of authority supported by MSAL. Please see here for valid authorities: <insert URL here>."
},
authorityUriInsecure: {
code: "authority_uri_insecure",
desc: "Authority URIs must use https."
},
authorityUriInvalidPath: {
code: "authority_uri_invalid_path",
desc: "Given authority URI is invalid."
},
unsupportedAuthorityValidation: {
code: "unsupported_authority_validation",
desc: "The authority validation is not supported for this authority type."
},
untrustedAuthority: {
code: "untrusted_authority",
desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter or set validateAuthority=false."
},
b2cAuthorityUriInvalidPath: {
code: "b2c_authority_uri_invalid_path",
desc: "The given URI for the B2C authority is invalid."
},
b2cKnownAuthoritiesNotSet: {
code: "b2c_known_authorities_not_set",
desc: "Must set known authorities when validateAuthority is set to True and using B2C"
},
claimsRequestParsingError: {
code: "claims_request_parsing_error",
desc: "Could not parse the given claims request object."
},
emptyRequestError: {
code: "empty_request_error",
desc: "Request object is required."
},
invalidCorrelationIdError: {
code: "invalid_guid_sent_as_correlationId",
desc: "Please set the correlationId as a valid guid"
},
telemetryConfigError: {
code: "telemetry_config_error",
desc: "Telemetry config is not configured with required values"
},
ssoSilentError: {
code: "sso_silent_error",
desc: "request must contain either sid or login_hint"
},
invalidAuthorityMetadataError: {
code: "authority_metadata_error",
desc: "Invalid authorityMetadata. Must be a JSON object containing authorization_endpoint, end_session_endpoint, and issuer fields."
}
};
/**
* Error thrown when there is an error in configuration of the .js library.
*/
var ClientConfigurationError = /** @class */ (function (_super) {
tslib_1.__extends(ClientConfigurationError, _super);
function ClientConfigurationError(errorCode, errorMessage) {
var _this = _super.call(this, errorCode, errorMessage) || this;
_this.name = "ClientConfigurationError";
Object.setPrototypeOf(_this, ClientConfigurationError.prototype);
return _this;
}
ClientConfigurationError.createNoSetConfigurationError = function () {
return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.configurationNotSet.code, "" + exports.ClientConfigurationErrorMessage.configurationNotSet.desc);
};
ClientConfigurationError.createStorageNotSupportedError = function (givenCacheLocation) {
return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.storageNotSupported.code, exports.ClientConfigurationErrorMessage.storageNotSupported.desc + " Given location: " + givenCacheLocation);
};
ClientConfigurationError.createRedirectCallbacksNotSetError = function () {
return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.noRedirectCallbacksSet.code, exports.ClientConfigurationErrorMessage.noRedirectCallbacksSet.desc);
};
ClientConfigurationError.createInvalidCallbackObjectError = function (callbackObject) {
return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.invalidCallbackObject.code, exports.ClientConfigurationErrorMessage.invalidCallbackObject.desc + " Given value for callback function: " + callbackObject);
};
ClientConfigurationError.createEmptyScopesArrayError = function (scopesValue) {
return new ClientConfigurationError(exports.ClientConfigurationErrorMessage.emptyScopes.code, exports.ClientConfigurationErrorMessage.emptyScopes.desc + " Given value: " + scopesValue + ".");
};
ClientConfigurationError.createScopesNonArrayError