@pnp/common
Advanced tools
Comparing version 1.0.3 to 1.0.4-0
/** | ||
@license | ||
* @pnp/common v1.0.3 - pnp - provides shared functionality across all pnp libraries | ||
* @pnp/common v1.0.4-0 - pnp - provides shared functionality across all pnp libraries | ||
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE) | ||
* Copyright (c) 2018 Microsoft | ||
* docs: http://officedev.github.io/PnP-JS-Core | ||
* docs: https://pnp.github.io/pnp/ | ||
* source: https://github.com/pnp/pnp | ||
* bugs: https://github.com/pnp/pnp/issues | ||
*/ | ||
import { __extends } from 'tslib'; | ||
import { inject } from 'adal-angular'; | ||
import { Logger } from '@pnp/logging'; | ||
import { __extends } from 'tslib'; | ||
/** | ||
* Reads a blob as text | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsText(blob) { | ||
return readBlobAs(blob, "string"); | ||
} | ||
/** | ||
* Reads a blob into an array buffer | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsArrayBuffer(blob) { | ||
return readBlobAs(blob, "buffer"); | ||
} | ||
/** | ||
* Generic method to read blob's content | ||
* | ||
* @param blob The data to read | ||
* @param mode The read mode | ||
*/ | ||
function readBlobAs(blob, mode) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
var reader = new FileReader(); | ||
reader.onload = function (e) { | ||
resolve(e.target.result); | ||
}; | ||
switch (mode) { | ||
case "string": | ||
reader.readAsText(blob); | ||
break; | ||
case "buffer": | ||
reader.readAsArrayBuffer(blob); | ||
break; | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
} | ||
/** | ||
* Generic dictionary | ||
*/ | ||
var Dictionary = /** @class */ (function () { | ||
/** | ||
* Creates a new instance of the Dictionary<T> class | ||
* | ||
* @constructor | ||
*/ | ||
function Dictionary(keys, values) { | ||
if (keys === void 0) { keys = []; } | ||
if (values === void 0) { values = []; } | ||
this.keys = keys; | ||
this.values = values; | ||
} | ||
/** | ||
* Gets a value from the collection using the specified key | ||
* | ||
* @param key The key whose value we want to return, returns null if the key does not exist | ||
*/ | ||
Dictionary.prototype.get = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
return this.values[index]; | ||
}; | ||
/** | ||
* Adds the supplied key and value to the dictionary | ||
* | ||
* @param key The key to add | ||
* @param o The value to add | ||
*/ | ||
Dictionary.prototype.add = function (key, o) { | ||
var index = this.keys.indexOf(key); | ||
if (index > -1) { | ||
if (o === null) { | ||
this.remove(key); | ||
} | ||
else { | ||
this.values[index] = o; | ||
} | ||
} | ||
else { | ||
if (o !== null) { | ||
this.keys.push(key); | ||
this.values.push(o); | ||
} | ||
} | ||
}; | ||
/** | ||
* Merges the supplied typed hash into this dictionary instance. Existing values are updated and new ones are created as appropriate. | ||
*/ | ||
Dictionary.prototype.merge = function (source) { | ||
var _this = this; | ||
if ("getKeys" in source) { | ||
var sourceAsDictionary_1 = source; | ||
sourceAsDictionary_1.getKeys().map(function (key) { | ||
_this.add(key, sourceAsDictionary_1.get(key)); | ||
}); | ||
} | ||
else { | ||
var sourceAsHash = source; | ||
for (var key in sourceAsHash) { | ||
if (sourceAsHash.hasOwnProperty(key)) { | ||
this.add(key, sourceAsHash[key]); | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Removes a value from the dictionary | ||
* | ||
* @param key The key of the key/value pair to remove. Returns null if the key was not found. | ||
*/ | ||
Dictionary.prototype.remove = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
var val = this.values[index]; | ||
this.keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
return val; | ||
}; | ||
/** | ||
* Returns all the keys currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getKeys = function () { | ||
return this.keys; | ||
}; | ||
/** | ||
* Returns all the values currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getValues = function () { | ||
return this.values; | ||
}; | ||
/** | ||
* Clears the current dictionary | ||
*/ | ||
Dictionary.prototype.clear = function () { | ||
this.keys = []; | ||
this.values = []; | ||
}; | ||
Object.defineProperty(Dictionary.prototype, "count", { | ||
/** | ||
* Gets a count of the items currently in the dictionary | ||
*/ | ||
get: function () { | ||
return this.keys.length; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Dictionary; | ||
}()); | ||
function deprecated(deprecationVersion, message) { | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: "(" + deprecationVersion + ") " + message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
function beta(message) { | ||
if (message === void 0) { message = "This feature is flagged as beta and is subject to change."; } | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
var UrlException = /** @class */ (function (_super) { | ||
__extends(UrlException, _super); | ||
function UrlException(msg) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.name = "UrlException"; | ||
Logger.log({ data: {}, level: 3 /* Error */, message: "[" + _this.name + "]::" + _this.message }); | ||
return _this; | ||
} | ||
return UrlException; | ||
}(Error)); | ||
function setup(config) { | ||
RuntimeConfig.extend(config); | ||
} | ||
var RuntimeConfigImpl = /** @class */ (function () { | ||
function RuntimeConfigImpl() { | ||
this._v = new Dictionary(); | ||
// setup defaults | ||
this._v.add("defaultCachingStore", "session"); | ||
this._v.add("defaultCachingTimeoutSeconds", 60); | ||
this._v.add("globalCacheDisable", false); | ||
this._v.add("enableCacheExpiration", false); | ||
this._v.add("cacheExpirationIntervalMilliseconds", 750); | ||
this._v.add("spfxContext", null); | ||
} | ||
/** | ||
* | ||
* @param config The set of properties to add to the globa configuration instance | ||
*/ | ||
RuntimeConfigImpl.prototype.extend = function (config) { | ||
var _this = this; | ||
Object.keys(config).forEach(function (key) { | ||
_this._v.add(key, config[key]); | ||
}); | ||
}; | ||
RuntimeConfigImpl.prototype.get = function (key) { | ||
return this._v.get(key); | ||
}; | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingStore", { | ||
get: function () { | ||
return this.get("defaultCachingStore"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingTimeoutSeconds", { | ||
get: function () { | ||
return this.get("defaultCachingTimeoutSeconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "globalCacheDisable", { | ||
get: function () { | ||
return this.get("globalCacheDisable"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "enableCacheExpiration", { | ||
get: function () { | ||
return this.get("enableCacheExpiration"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "cacheExpirationIntervalMilliseconds", { | ||
get: function () { | ||
return this.get("cacheExpirationIntervalMilliseconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "spfxContext", { | ||
get: function () { | ||
return this.get("spfxContext"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return RuntimeConfigImpl; | ||
}()); | ||
var _runtimeConfig = new RuntimeConfigImpl(); | ||
var RuntimeConfig = _runtimeConfig; | ||
/** | ||
* Gets a callback function which will maintain context across async calls. | ||
@@ -586,2 +297,12 @@ * Allows for the calling pattern getCtxCallback(thisobj, method, methodarg1, methodarg2, ...) | ||
} | ||
Object.defineProperty(BearerTokenFetchClient.prototype, "token", { | ||
get: function () { | ||
return this._token; | ||
}, | ||
set: function (token) { | ||
this._token = token; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
BearerTokenFetchClient.prototype.fetch = function (url, options) { | ||
@@ -599,2 +320,446 @@ if (options === void 0) { options = {}; } | ||
/** | ||
* Azure AD Client for use in the browser | ||
*/ | ||
var AdalClient = /** @class */ (function (_super) { | ||
__extends(AdalClient, _super); | ||
/** | ||
* Creates a new instance of AdalClient | ||
* @param clientId Azure App Id | ||
* @param tenant Office 365 tenant (Ex: {tenant}.onmicrosoft.com) | ||
* @param redirectUri The redirect url used to authenticate the | ||
*/ | ||
function AdalClient(clientId, tenant, redirectUri) { | ||
var _this = _super.call(this, null) || this; | ||
_this.clientId = clientId; | ||
_this.tenant = tenant; | ||
_this.redirectUri = redirectUri; | ||
return _this; | ||
} | ||
/** | ||
* Creates a new AdalClient using the values of the supplied SPFx context | ||
* | ||
* @param spfxContext Current SPFx context | ||
* @param clientId Optional client id to use instead of the built-in SPFx id | ||
* @description Using this method and the default clientId requires that the features described in | ||
* this article https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient are activated in the tenant. If not you can | ||
* creat your own app, grant permissions and use that clientId here along with the SPFx context | ||
*/ | ||
AdalClient.fromSPFxContext = function (spfxContext, cliendId) { | ||
if (cliendId === void 0) { cliendId = "c58637bb-e2e1-4312-8a00-04b5ffcd3403"; } | ||
// this "magic" client id is the one to which permissions are granted behind the scenes | ||
// this redirectUrl is the page as used by spfx | ||
return new AdalClient(cliendId, spfxContext.pageContext.aadInfo.tenantId.toString(), combinePaths(window.location.origin, "/_forms/spfxsinglesignon.aspx")); | ||
}; | ||
/** | ||
* Conducts the fetch opertation against the AAD secured resource | ||
* | ||
* @param url Absolute URL for the request | ||
* @param options Any fetch options passed to the underlying fetch implementation | ||
*/ | ||
AdalClient.prototype.fetch = function (url, options) { | ||
var _this = this; | ||
if (!isUrlAbsolute(url)) { | ||
throw new Error("You must supply absolute urls to AdalClient.fetch."); | ||
} | ||
// the url we are calling is the resource | ||
return this.getToken(this.getResource(url)).then(function (token) { | ||
_this.token = token; | ||
return _super.prototype.fetch.call(_this, url, options); | ||
}); | ||
}; | ||
/** | ||
* Gets a token based on the current user | ||
* | ||
* @param resource The resource for which we are requesting a token | ||
*/ | ||
AdalClient.prototype.getToken = function (resource) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.ensureAuthContext().then(function (_) { return _this.login(); }).then(function (_) { | ||
AdalClient._authContext.acquireToken(resource, function (message, token) { | ||
if (message) { | ||
return reject(new Error(message)); | ||
} | ||
resolve(token); | ||
}); | ||
}).catch(reject); | ||
}); | ||
}; | ||
/** | ||
* Ensures we have created and setup the adal AuthenticationContext instance | ||
*/ | ||
AdalClient.prototype.ensureAuthContext = function () { | ||
var _this = this; | ||
return new Promise(function (resolve) { | ||
if (AdalClient._authContext === null) { | ||
AdalClient._authContext = inject({ | ||
clientId: _this.clientId, | ||
displayCall: function (url) { | ||
if (_this._displayCallback) { | ||
_this._displayCallback(url); | ||
} | ||
}, | ||
navigateToLoginRequestUrl: false, | ||
redirectUri: _this.redirectUri, | ||
tenant: _this.tenant, | ||
}); | ||
} | ||
resolve(); | ||
}); | ||
}; | ||
/** | ||
* Ensures the current user is logged in | ||
*/ | ||
AdalClient.prototype.login = function () { | ||
var _this = this; | ||
if (this._loginPromise) { | ||
return this._loginPromise; | ||
} | ||
this._loginPromise = new Promise(function (resolve, reject) { | ||
if (AdalClient._authContext.getCachedUser()) { | ||
return resolve(); | ||
} | ||
_this._displayCallback = function (url) { | ||
var popupWindow = window.open(url, "login", "width=483, height=600"); | ||
if (!popupWindow) { | ||
return reject(new Error("Could not open pop-up window for auth. Likely pop-ups are blocked by the browser.")); | ||
} | ||
if (popupWindow && popupWindow.focus) { | ||
popupWindow.focus(); | ||
} | ||
var pollTimer = window.setInterval(function () { | ||
if (!popupWindow || popupWindow.closed || popupWindow.closed === undefined) { | ||
window.clearInterval(pollTimer); | ||
} | ||
try { | ||
if (popupWindow.document.URL.indexOf(_this.redirectUri) !== -1) { | ||
window.clearInterval(pollTimer); | ||
AdalClient._authContext.handleWindowCallback(popupWindow.location.hash); | ||
popupWindow.close(); | ||
resolve(); | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}, 30); | ||
}; | ||
// this triggers the login process | ||
_this.ensureAuthContext().then(function (_) { | ||
AdalClient._authContext._loginInProgress = false; | ||
AdalClient._authContext.login(); | ||
_this._displayCallback = null; | ||
}); | ||
}); | ||
return this._loginPromise; | ||
}; | ||
/** | ||
* Parses out the root of the request url to use as the resource when getting the token | ||
* | ||
* After: https://gist.github.com/jlong/2428561 | ||
* @param url The url to parse | ||
*/ | ||
AdalClient.prototype.getResource = function (url) { | ||
var parser = document.createElement("a"); | ||
parser.href = url; | ||
return parser.protocol + "//" + parser.hostname; | ||
}; | ||
/** | ||
* Our auth context | ||
*/ | ||
AdalClient._authContext = null; | ||
return AdalClient; | ||
}(BearerTokenFetchClient)); | ||
/** | ||
* Reads a blob as text | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsText(blob) { | ||
return readBlobAs(blob, "string"); | ||
} | ||
/** | ||
* Reads a blob into an array buffer | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsArrayBuffer(blob) { | ||
return readBlobAs(blob, "buffer"); | ||
} | ||
/** | ||
* Generic method to read blob's content | ||
* | ||
* @param blob The data to read | ||
* @param mode The read mode | ||
*/ | ||
function readBlobAs(blob, mode) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
var reader = new FileReader(); | ||
reader.onload = function (e) { | ||
resolve(e.target.result); | ||
}; | ||
switch (mode) { | ||
case "string": | ||
reader.readAsText(blob); | ||
break; | ||
case "buffer": | ||
reader.readAsArrayBuffer(blob); | ||
break; | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
} | ||
/** | ||
* Generic dictionary | ||
*/ | ||
var Dictionary = /** @class */ (function () { | ||
/** | ||
* Creates a new instance of the Dictionary<T> class | ||
* | ||
* @constructor | ||
*/ | ||
function Dictionary(keys, values) { | ||
if (keys === void 0) { keys = []; } | ||
if (values === void 0) { values = []; } | ||
this.keys = keys; | ||
this.values = values; | ||
} | ||
/** | ||
* Gets a value from the collection using the specified key | ||
* | ||
* @param key The key whose value we want to return, returns null if the key does not exist | ||
*/ | ||
Dictionary.prototype.get = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
return this.values[index]; | ||
}; | ||
/** | ||
* Adds the supplied key and value to the dictionary | ||
* | ||
* @param key The key to add | ||
* @param o The value to add | ||
*/ | ||
Dictionary.prototype.add = function (key, o) { | ||
var index = this.keys.indexOf(key); | ||
if (index > -1) { | ||
if (o === null) { | ||
this.remove(key); | ||
} | ||
else { | ||
this.values[index] = o; | ||
} | ||
} | ||
else { | ||
if (o !== null) { | ||
this.keys.push(key); | ||
this.values.push(o); | ||
} | ||
} | ||
}; | ||
/** | ||
* Merges the supplied typed hash into this dictionary instance. Existing values are updated and new ones are created as appropriate. | ||
*/ | ||
Dictionary.prototype.merge = function (source) { | ||
var _this = this; | ||
if ("getKeys" in source) { | ||
var sourceAsDictionary_1 = source; | ||
sourceAsDictionary_1.getKeys().map(function (key) { | ||
_this.add(key, sourceAsDictionary_1.get(key)); | ||
}); | ||
} | ||
else { | ||
var sourceAsHash = source; | ||
for (var key in sourceAsHash) { | ||
if (sourceAsHash.hasOwnProperty(key)) { | ||
this.add(key, sourceAsHash[key]); | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Removes a value from the dictionary | ||
* | ||
* @param key The key of the key/value pair to remove. Returns null if the key was not found. | ||
*/ | ||
Dictionary.prototype.remove = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
var val = this.values[index]; | ||
this.keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
return val; | ||
}; | ||
/** | ||
* Returns all the keys currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getKeys = function () { | ||
return this.keys; | ||
}; | ||
/** | ||
* Returns all the values currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getValues = function () { | ||
return this.values; | ||
}; | ||
/** | ||
* Clears the current dictionary | ||
*/ | ||
Dictionary.prototype.clear = function () { | ||
this.keys = []; | ||
this.values = []; | ||
}; | ||
Object.defineProperty(Dictionary.prototype, "count", { | ||
/** | ||
* Gets a count of the items currently in the dictionary | ||
*/ | ||
get: function () { | ||
return this.keys.length; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Dictionary; | ||
}()); | ||
function deprecated(deprecationVersion, message) { | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: "(" + deprecationVersion + ") " + message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
function beta(message) { | ||
if (message === void 0) { message = "This feature is flagged as beta and is subject to change."; } | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
var UrlException = /** @class */ (function (_super) { | ||
__extends(UrlException, _super); | ||
function UrlException(msg) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.name = "UrlException"; | ||
Logger.log({ data: {}, level: 3 /* Error */, message: "[" + _this.name + "]::" + _this.message }); | ||
return _this; | ||
} | ||
return UrlException; | ||
}(Error)); | ||
function setup(config) { | ||
RuntimeConfig.extend(config); | ||
} | ||
var RuntimeConfigImpl = /** @class */ (function () { | ||
function RuntimeConfigImpl() { | ||
this._v = new Dictionary(); | ||
// setup defaults | ||
this._v.add("defaultCachingStore", "session"); | ||
this._v.add("defaultCachingTimeoutSeconds", 60); | ||
this._v.add("globalCacheDisable", false); | ||
this._v.add("enableCacheExpiration", false); | ||
this._v.add("cacheExpirationIntervalMilliseconds", 750); | ||
this._v.add("spfxContext", null); | ||
} | ||
/** | ||
* | ||
* @param config The set of properties to add to the globa configuration instance | ||
*/ | ||
RuntimeConfigImpl.prototype.extend = function (config) { | ||
var _this = this; | ||
Object.keys(config).forEach(function (key) { | ||
_this._v.add(key, config[key]); | ||
}); | ||
}; | ||
RuntimeConfigImpl.prototype.get = function (key) { | ||
return this._v.get(key); | ||
}; | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingStore", { | ||
get: function () { | ||
return this.get("defaultCachingStore"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingTimeoutSeconds", { | ||
get: function () { | ||
return this.get("defaultCachingTimeoutSeconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "globalCacheDisable", { | ||
get: function () { | ||
return this.get("globalCacheDisable"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "enableCacheExpiration", { | ||
get: function () { | ||
return this.get("enableCacheExpiration"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "cacheExpirationIntervalMilliseconds", { | ||
get: function () { | ||
return this.get("cacheExpirationIntervalMilliseconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "spfxContext", { | ||
get: function () { | ||
return this.get("spfxContext"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return RuntimeConfigImpl; | ||
}()); | ||
var _runtimeConfig = new RuntimeConfigImpl(); | ||
var RuntimeConfig = _runtimeConfig; | ||
/** | ||
* A wrapper class to provide a consistent interface to browser based storage | ||
@@ -842,3 +1007,3 @@ * | ||
export { readBlobAsText, readBlobAsArrayBuffer, Dictionary, deprecated, beta, UrlException, setup, RuntimeConfigImpl, RuntimeConfig, mergeHeaders, mergeOptions, FetchClient, BearerTokenFetchClient, PnPClientStorageWrapper, PnPClientStorage, getCtxCallback, dateAdd, combinePaths, getRandomString, getGUID, isFunc, objectDefinedNotNull, isArray, extend, isUrlAbsolute, stringIsNullOrEmpty, Util }; | ||
export { AdalClient, readBlobAsText, readBlobAsArrayBuffer, Dictionary, deprecated, beta, UrlException, setup, RuntimeConfigImpl, RuntimeConfig, mergeHeaders, mergeOptions, FetchClient, BearerTokenFetchClient, PnPClientStorageWrapper, PnPClientStorage, getCtxCallback, dateAdd, combinePaths, getRandomString, getGUID, isFunc, objectDefinedNotNull, isArray, extend, isUrlAbsolute, stringIsNullOrEmpty, Util }; | ||
//# sourceMappingURL=common.es5.js.map |
/** | ||
@license | ||
* @pnp/common v1.0.3 - pnp - provides shared functionality across all pnp libraries | ||
* @pnp/common v1.0.4-0 - pnp - provides shared functionality across all pnp libraries | ||
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE) | ||
* Copyright (c) 2018 Microsoft | ||
* docs: http://officedev.github.io/PnP-JS-Core | ||
* docs: https://pnp.github.io/pnp/ | ||
* source: https://github.com/pnp/pnp | ||
* bugs: https://github.com/pnp/pnp/issues | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.pnp=t():e.pnp=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r=function(){function e(e,t){void 0===e&&(e=[]),void 0===t&&(t=[]),this.keys=e,this.values=t}return e.prototype.get=function(e){var t=this.keys.indexOf(e);return t<0?null:this.values[t]},e.prototype.add=function(e,t){var n=this.keys.indexOf(e);n>-1?null===t?this.remove(e):this.values[n]=t:null!==t&&(this.keys.push(e),this.values.push(t))},e.prototype.merge=function(e){var t=this;if("getKeys"in e){var n=e;n.getKeys().map(function(e){t.add(e,n.get(e))})}else{var r=e;for(var o in r)r.hasOwnProperty(o)&&this.add(o,r[o])}},e.prototype.remove=function(e){var t=this.keys.indexOf(e);if(t<0)return null;var n=this.values[t];return this.keys.splice(t,1),this.values.splice(t,1),n},e.prototype.getKeys=function(){return this.keys},e.prototype.getValues=function(){return this.values},e.prototype.clear=function(){this.keys=[],this.values=[]},Object.defineProperty(e.prototype,"count",{get:function(){return this.keys.length},enumerable:!0,configurable:!0}),e}()},function(e,t,n){"use strict";n.d(t,"a",function(){return r});/** | ||
@license | ||
* @pnp/logging v1.0.3 - pnp - light-weight, subscribable logging framework | ||
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE) | ||
* Copyright (c) 2018 Microsoft | ||
* docs: http://officedev.github.io/PnP-JS-Core | ||
* source: https://github.com/pnp/pnp | ||
* bugs: https://github.com/pnp/pnp/issues | ||
*/ | ||
var r=function(){function e(){}return Object.defineProperty(e,"activeLogLevel",{get:function(){return e.instance.activeLogLevel},set:function(t){e.instance.activeLogLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return void 0!==e._instance&&null!==e._instance||(e._instance=new o),e._instance},enumerable:!0,configurable:!0}),e.subscribe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.map(function(t){return e.instance.subscribe(t)})},e.clearSubscribers=function(){return e.instance.clearSubscribers()},Object.defineProperty(e,"count",{get:function(){return e.instance.count},enumerable:!0,configurable:!0}),e.write=function(t,n){void 0===n&&(n=0),e.instance.log({level:n,message:t})},e.writeJSON=function(t,n){void 0===n&&(n=0),e.instance.log({level:n,message:JSON.stringify(t)})},e.log=function(t){e.instance.log(t)},e.error=function(t){e.instance.log({data:t,level:3,message:t.message})},e}(),o=function(){function e(e,t){void 0===e&&(e=2),void 0===t&&(t=[]),this.activeLogLevel=e,this.subscribers=t}return e.prototype.subscribe=function(e){this.subscribers.push(e)},e.prototype.clearSubscribers=function(){var e=this.subscribers.slice(0);return this.subscribers.length=0,e},Object.defineProperty(e.prototype,"count",{get:function(){return this.subscribers.length},enumerable:!0,configurable:!0}),e.prototype.write=function(e,t){void 0===t&&(t=0),this.log({level:t,message:e})},e.prototype.log=function(e){void 0!==e&&this.activeLogLevel<=e.level&&this.subscribers.map(function(t){return t.log(e)})},e}();(function(){function e(){}e.prototype.log=function(e){var t=this.format(e);switch(e.level){case 0:case 1:console.log(t);break;case 2:console.warn(t);break;case 3:console.error(t)}},e.prototype.format=function(e){var t=[];return t.push("Message: "+e.message),void 0!==e.data&&t.push(" Data: "+JSON.stringify(e.data)),t.join("")}})(),function(){function e(e){this.method=e}e.prototype.log=function(e){this.method(e)}}()},function(e,t,n){"use strict";function r(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return function(){t.apply(e,n)}}function o(e,t,n){var r=new Date(e);switch(t.toLowerCase()){case"year":r.setFullYear(r.getFullYear()+n);break;case"quarter":r.setMonth(r.getMonth()+3*n);break;case"month":r.setMonth(r.getMonth()+n);break;case"week":r.setDate(r.getDate()+7*n);break;case"day":r.setDate(r.getDate()+n);break;case"hour":r.setTime(r.getTime()+36e5*n);break;case"minute":r.setTime(r.getTime()+6e4*n);break;case"second":r.setTime(r.getTime()+1e3*n);break;default:r=void 0}return r}function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter(function(e){return!h.stringIsNullOrEmpty(e)}).map(function(e){return e.replace(/^[\\|\/]/,"").replace(/[\\|\/]$/,"")}).join("/").replace(/\\/g,"/")}function u(e){for(var t=new Array(e),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=0;r<e;r++)t[r]=n.charAt(Math.floor(Math.random()*n.length));return t.join("")}function c(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)})}function a(e){return"function"==typeof e}function s(e){return void 0!==e&&null!==e}function f(e){return Array.isArray?Array.isArray(e):e&&"number"==typeof e.length&&e.constructor===Array}function l(e,t,n){if(void 0===n&&(n=!1),!h.objectDefinedNotNull(t))return e;var r=n?function(e,t){return!(t in e)}:function(){return!0};return Object.getOwnPropertyNames(t).filter(function(t){return r(e,t)}).reduce(function(e,n){return e[n]=t[n],e},e)}function d(e){return/^https?:\/\/|^\/\//i.test(e)}function p(e){return void 0===e||null===e||e.length<1}t.e=r,t.c=o,t.b=i,t.g=u,t.f=c,t.i=a,t.k=s,t.h=f,t.d=l,t.j=d,t.l=p,n.d(t,"a",function(){return h});var h=function(){function e(){}return e.getCtxCallback=r,e.dateAdd=o,e.combinePaths=i,e.getRandomString=u,e.getGUID=c,e.isFunc=a,e.objectDefinedNotNull=s,e.isArray=f,e.extend=l,e.isUrlAbsolute=d,e.stringIsNullOrEmpty=p,e}()},function(e,t,n){"use strict";function r(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}t.a=r;/*! ***************************************************************************** | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.pnp=t():e.pnp=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){"use strict";function i(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return function(){t.apply(e,n)}}function r(e,t,n){var i=new Date(e);switch(t.toLowerCase()){case"year":i.setFullYear(i.getFullYear()+n);break;case"quarter":i.setMonth(i.getMonth()+3*n);break;case"month":i.setMonth(i.getMonth()+n);break;case"week":i.setDate(i.getDate()+7*n);break;case"day":i.setDate(i.getDate()+n);break;case"hour":i.setTime(i.getTime()+36e5*n);break;case"minute":i.setTime(i.getTime()+6e4*n);break;case"second":i.setTime(i.getTime()+1e3*n);break;default:i=void 0}return i}function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter(function(e){return!f.stringIsNullOrEmpty(e)}).map(function(e){return e.replace(/^[\\|\/]/,"").replace(/[\\|\/]$/,"")}).join("/").replace(/\\/g,"/")}function s(e){for(var t=new Array(e),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;i<e;i++)t[i]=n.charAt(Math.floor(Math.random()*n.length));return t.join("")}function a(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)})}function c(e){return"function"==typeof e}function u(e){return void 0!==e&&null!==e}function l(e){return Array.isArray?Array.isArray(e):e&&"number"==typeof e.length&&e.constructor===Array}function h(e,t,n){if(void 0===n&&(n=!1),!f.objectDefinedNotNull(t))return e;var i=n?function(e,t){return!(t in e)}:function(){return!0};return Object.getOwnPropertyNames(t).filter(function(t){return i(e,t)}).reduce(function(e,n){return e[n]=t[n],e},e)}function d(e){return/^https?:\/\/|^\/\//i.test(e)}function p(e){return void 0===e||null===e||e.length<1}t.e=i,t.c=r,t.b=o,t.g=s,t.f=a,t.i=c,t.k=u,t.h=l,t.d=h,t.j=d,t.l=p,n.d(t,"a",function(){return f});var f=function(){function e(){}return e.getCtxCallback=i,e.dateAdd=r,e.combinePaths=o,e.getRandomString=s,e.getGUID=a,e.isFunc=c,e.objectDefinedNotNull=u,e.isArray=l,e.extend=h,e.isUrlAbsolute=d,e.stringIsNullOrEmpty=p,e}()},function(e,t,n){"use strict";function i(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}t.a=i;/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
@@ -33,3 +24,14 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
***************************************************************************** */ | ||
var o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};Object.assign},function(e,t,n){"use strict";function r(e){c.extend(e)}t.c=r,n.d(t,"b",function(){return i}),n.d(t,"a",function(){return c});var o=n(0),i=function(){function e(){this._v=new o.a,this._v.add("defaultCachingStore","session"),this._v.add("defaultCachingTimeoutSeconds",60),this._v.add("globalCacheDisable",!1),this._v.add("enableCacheExpiration",!1),this._v.add("cacheExpirationIntervalMilliseconds",750),this._v.add("spfxContext",null)}return e.prototype.extend=function(e){var t=this;Object.keys(e).forEach(function(n){t._v.add(n,e[n])})},e.prototype.get=function(e){return this._v.get(e)},Object.defineProperty(e.prototype,"defaultCachingStore",{get:function(){return this.get("defaultCachingStore")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultCachingTimeoutSeconds",{get:function(){return this.get("defaultCachingTimeoutSeconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalCacheDisable",{get:function(){return this.get("globalCacheDisable")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableCacheExpiration",{get:function(){return this.get("enableCacheExpiration")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cacheExpirationIntervalMilliseconds",{get:function(){return this.get("cacheExpirationIntervalMilliseconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spfxContext",{get:function(){return this.get("spfxContext")},enumerable:!0,configurable:!0}),e}(),u=new i,c=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6);n.d(t,"readBlobAsText",function(){return r.y}),n.d(t,"readBlobAsArrayBuffer",function(){return r.x}),n.d(t,"Dictionary",function(){return r.b}),n.d(t,"deprecated",function(){return r.m}),n.d(t,"beta",function(){return r.j}),n.d(t,"UrlException",function(){return r.h}),n.d(t,"setup",function(){return r.z}),n.d(t,"RuntimeConfigImpl",function(){return r.g}),n.d(t,"RuntimeConfig",function(){return r.f}),n.d(t,"mergeHeaders",function(){return r.u}),n.d(t,"mergeOptions",function(){return r.v}),n.d(t,"FetchClient",function(){return r.c}),n.d(t,"BearerTokenFetchClient",function(){return r.a}),n.d(t,"PnPClientStorageWrapper",function(){return r.e}),n.d(t,"PnPClientStorage",function(){return r.d}),n.d(t,"getCtxCallback",function(){return r.o}),n.d(t,"dateAdd",function(){return r.l}),n.d(t,"combinePaths",function(){return r.k}),n.d(t,"getRandomString",function(){return r.q}),n.d(t,"getGUID",function(){return r.p}),n.d(t,"isFunc",function(){return r.s}),n.d(t,"objectDefinedNotNull",function(){return r.w}),n.d(t,"isArray",function(){return r.r}),n.d(t,"extend",function(){return r.n}),n.d(t,"isUrlAbsolute",function(){return r.t}),n.d(t,"stringIsNullOrEmpty",function(){return r.A}),n.d(t,"Util",function(){return r.i})},function(e,t,n){"use strict";var r=n(7);n.d(t,"x",function(){return r.a}),n.d(t,"y",function(){return r.b});var o=n(0);n.d(t,"b",function(){return o.a});var i=n(8);n.d(t,"j",function(){return i.a}),n.d(t,"m",function(){return i.b});var u=n(9);n.d(t,"h",function(){return u.a});var c=n(4);n.d(t,"f",function(){return c.a}),n.d(t,"g",function(){return c.b}),n.d(t,"z",function(){return c.c});var a=n(10);n.d(t,"a",function(){return a.a}),n.d(t,"c",function(){return a.b}),n.d(t,"u",function(){return a.c}),n.d(t,"v",function(){return a.d});var s=n(12);n.d(t,"d",function(){return s.a}),n.d(t,"e",function(){return s.b});var f=n(2);n.d(t,"i",function(){return f.a}),n.d(t,"k",function(){return f.b}),n.d(t,"l",function(){return f.c}),n.d(t,"n",function(){return f.d}),n.d(t,"o",function(){return f.e}),n.d(t,"p",function(){return f.f}),n.d(t,"q",function(){return f.g}),n.d(t,"r",function(){return f.h}),n.d(t,"s",function(){return f.i}),n.d(t,"t",function(){return f.j}),n.d(t,"w",function(){return f.k}),n.d(t,"A",function(){return f.l})},function(e,t,n){"use strict";function r(e){return i(e,"string")}function o(e){return i(e,"buffer")}function i(e,t){return new Promise(function(n,r){try{var o=new FileReader;switch(o.onload=function(e){n(e.target.result)},t){case"string":o.readAsText(e);break;case"buffer":o.readAsArrayBuffer(e)}}catch(e){r(e)}})}t.b=r,t.a=o},function(e,t,n){"use strict";function r(e,t){return function(n,r,o){var u=o.value;o.value=function(){for(var c=[],a=0;a<arguments.length;a++)c[a]=arguments[a];return i.a.log({data:{descriptor:o,propertyKey:r,target:n},level:2,message:"("+e+") "+t}),u.apply(this,c)}}}function o(e){return void 0===e&&(e="This feature is flagged as beta and is subject to change."),function(t,n,r){var o=r.value;r.value=function(){for(var u=[],c=0;c<arguments.length;c++)u[c]=arguments[c];return i.a.log({data:{descriptor:r,propertyKey:n,target:t},level:2,message:e}),o.apply(this,u)}}}t.b=r,t.a=o;var i=n(1)},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(3),o=n(1),i=function(e){function t(t){var n=e.call(this,t)||this;return n.name="UrlException",o.a.log({data:{},level:3,message:"["+n.name+"]::"+n.message}),n}return r.a(t,e),t}(Error)},function(e,t,n){"use strict";(function(e){function r(e,t){if(void 0!==t&&null!==t){new Request("",{headers:t}).headers.forEach(function(t,n){e.append(n,t)})}}function o(e,t){if(u.a.objectDefinedNotNull(t)){var n=u.a.extend(e.headers||{},t.headers);e=u.a.extend(e,t),e.headers=n}}t.c=r,t.d=o,n.d(t,"b",function(){return c}),n.d(t,"a",function(){return a});var i=n(3),u=n(2),c=function(){function t(){}return t.prototype.fetch=function(t,n){return e.fetch(t,n)},t}(),a=function(e){function t(t){var n=e.call(this)||this;return n._token=t,n}return i.a(t,e),t.prototype.fetch=function(t,n){void 0===n&&(n={});var o=new Headers;return r(o,n.headers),o.set("Authorization","Bearer "+this._token),n.headers=o,e.prototype.fetch.call(this,t,n)},t}(c)}).call(t,n(11))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.d(t,"b",function(){return c}),n.d(t,"a",function(){return s});var r=n(2),o=n(0),i=n(4),u=n(1),c=function(){function e(e,t){void 0===t&&(t=-1),this.store=e,this.defaultTimeoutMinutes=t,this.enabled=this.test(),i.a.enableCacheExpiration&&(u.a.write("Enabling cache expiration.",1),this.cacheExpirationHandler())}return e.prototype.get=function(e){if(!this.enabled)return null;var t=this.store.getItem(e);if(null==t)return null;var n=JSON.parse(t);return new Date(n.expiration)<=new Date?(u.a.write("Removing item with key '"+e+"' from cache due to expiration.",1),this.delete(e),null):n.value},e.prototype.put=function(e,t,n){this.enabled&&this.store.setItem(e,this.createPersistable(t,n))},e.prototype.delete=function(e){this.enabled&&this.store.removeItem(e)},e.prototype.getOrPut=function(e,t,n){var r=this;return this.enabled?new Promise(function(o){var i=r.get(e);null==i?t().then(function(t){r.put(e,t,n),o(t)}):o(i)}):t()},e.prototype.deleteExpired=function(){var e=this;return new Promise(function(t,n){e.enabled||t();try{for(var r=0;r<e.store.length;r++){var o=e.store.key(r);null!==o&&/["|']?pnp["|']? ?: ?1/i.test(e.store.getItem(o))&&e.get(o)}t()}catch(e){n(e)}})},e.prototype.test=function(){try{return this.store.setItem("test","test"),this.store.removeItem("test"),!0}catch(e){return!1}},e.prototype.createPersistable=function(e,t){if(void 0===t){var n=i.a.defaultCachingTimeoutSeconds;this.defaultTimeoutMinutes>0&&(n=60*this.defaultTimeoutMinutes),t=r.a.dateAdd(new Date,"second",n)}return JSON.stringify({pnp:1,expiration:t,value:e})},e.prototype.cacheExpirationHandler=function(){var e=this;u.a.write("Called cache expiration handler.",0),this.deleteExpired().then(function(t){setTimeout(r.a.getCtxCallback(e,e.cacheExpirationHandler),i.a.cacheExpirationIntervalMilliseconds)}).catch(function(e){u.a.log({data:e,level:3,message:"Error deleting expired cache entries, see data for details. Timeout not reset."})})},e}(),a=function(){function e(e){void 0===e&&(e=new o.a),this._store=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this._store.count},enumerable:!0,configurable:!0}),e.prototype.clear=function(){this._store.clear()},e.prototype.getItem=function(e){return this._store.get(e)},e.prototype.key=function(e){return this._store.getKeys()[e]},e.prototype.removeItem=function(e){this._store.remove(e)},e.prototype.setItem=function(e,t){this._store.add(e,t)},e}(),s=function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this._local=e,this._session=t}return Object.defineProperty(e.prototype,"local",{get:function(){return null===this._local&&(this._local=new c("undefined"!=typeof localStorage?localStorage:new a)),this._local},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"session",{get:function(){return null===this._session&&(this._session=new c("undefined"!=typeof sessionStorage?sessionStorage:new a)),this._session},enumerable:!0,configurable:!0}),e}()}])}); | ||
var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};Object.assign},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var i=function(){function e(e,t){void 0===e&&(e=[]),void 0===t&&(t=[]),this.keys=e,this.values=t}return e.prototype.get=function(e){var t=this.keys.indexOf(e);return t<0?null:this.values[t]},e.prototype.add=function(e,t){var n=this.keys.indexOf(e);n>-1?null===t?this.remove(e):this.values[n]=t:null!==t&&(this.keys.push(e),this.values.push(t))},e.prototype.merge=function(e){var t=this;if("getKeys"in e){var n=e;n.getKeys().map(function(e){t.add(e,n.get(e))})}else{var i=e;for(var r in i)i.hasOwnProperty(r)&&this.add(r,i[r])}},e.prototype.remove=function(e){var t=this.keys.indexOf(e);if(t<0)return null;var n=this.values[t];return this.keys.splice(t,1),this.values.splice(t,1),n},e.prototype.getKeys=function(){return this.keys},e.prototype.getValues=function(){return this.values},e.prototype.clear=function(){this.keys=[],this.values=[]},Object.defineProperty(e.prototype,"count",{get:function(){return this.keys.length},enumerable:!0,configurable:!0}),e}()},function(e,t,n){"use strict";n.d(t,"a",function(){return i});/** | ||
@license | ||
* @pnp/logging v1.0.4-0 - pnp - light-weight, subscribable logging framework | ||
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE) | ||
* Copyright (c) 2018 Microsoft | ||
* docs: https://pnp.github.io/pnp/ | ||
* source: https://github.com/pnp/pnp | ||
* bugs: https://github.com/pnp/pnp/issues | ||
*/ | ||
var i=function(){function e(){}return Object.defineProperty(e,"activeLogLevel",{get:function(){return e.instance.activeLogLevel},set:function(t){e.instance.activeLogLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return void 0!==e._instance&&null!==e._instance||(e._instance=new r),e._instance},enumerable:!0,configurable:!0}),e.subscribe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.map(function(t){return e.instance.subscribe(t)})},e.clearSubscribers=function(){return e.instance.clearSubscribers()},Object.defineProperty(e,"count",{get:function(){return e.instance.count},enumerable:!0,configurable:!0}),e.write=function(t,n){void 0===n&&(n=0),e.instance.log({level:n,message:t})},e.writeJSON=function(t,n){void 0===n&&(n=0),e.instance.log({level:n,message:JSON.stringify(t)})},e.log=function(t){e.instance.log(t)},e.error=function(t){e.instance.log({data:t,level:3,message:t.message})},e}(),r=function(){function e(e,t){void 0===e&&(e=2),void 0===t&&(t=[]),this.activeLogLevel=e,this.subscribers=t}return e.prototype.subscribe=function(e){this.subscribers.push(e)},e.prototype.clearSubscribers=function(){var e=this.subscribers.slice(0);return this.subscribers.length=0,e},Object.defineProperty(e.prototype,"count",{get:function(){return this.subscribers.length},enumerable:!0,configurable:!0}),e.prototype.write=function(e,t){void 0===t&&(t=0),this.log({level:t,message:e})},e.prototype.log=function(e){void 0!==e&&this.activeLogLevel<=e.level&&this.subscribers.map(function(t){return t.log(e)})},e}();(function(){function e(){}e.prototype.log=function(e){var t=this.format(e);switch(e.level){case 0:case 1:console.log(t);break;case 2:console.warn(t);break;case 3:console.error(t)}},e.prototype.format=function(e){var t=[];return t.push("Message: "+e.message),void 0!==e.data&&t.push(" Data: "+JSON.stringify(e.data)),t.join("")}})(),function(){function e(e){this.method=e}e.prototype.log=function(e){this.method(e)}}()},function(e,t,n){"use strict";(function(e){function i(e,t){if(void 0!==t&&null!==t){new Request("",{headers:t}).headers.forEach(function(t,n){e.append(n,t)})}}function r(e,t){if(s.a.objectDefinedNotNull(t)){var n=s.a.extend(e.headers||{},t.headers);e=s.a.extend(e,t),e.headers=n}}t.c=i,t.d=r,n.d(t,"b",function(){return a}),n.d(t,"a",function(){return c});var o=n(1),s=n(0),a=function(){function t(){}return t.prototype.fetch=function(t,n){return e.fetch(t,n)},t}(),c=function(e){function t(t){var n=e.call(this)||this;return n._token=t,n}return o.a(t,e),Object.defineProperty(t.prototype,"token",{get:function(){return this._token},set:function(e){this._token=e},enumerable:!0,configurable:!0}),t.prototype.fetch=function(t,n){void 0===n&&(n={});var r=new Headers;return i(r,n.headers),r.set("Authorization","Bearer "+this._token),n.headers=r,e.prototype.fetch.call(this,t,n)},t}(a)}).call(t,n(9))},function(e,t,n){"use strict";function i(e){a.extend(e)}t.c=i,n.d(t,"b",function(){return o}),n.d(t,"a",function(){return a});var r=n(2),o=function(){function e(){this._v=new r.a,this._v.add("defaultCachingStore","session"),this._v.add("defaultCachingTimeoutSeconds",60),this._v.add("globalCacheDisable",!1),this._v.add("enableCacheExpiration",!1),this._v.add("cacheExpirationIntervalMilliseconds",750),this._v.add("spfxContext",null)}return e.prototype.extend=function(e){var t=this;Object.keys(e).forEach(function(n){t._v.add(n,e[n])})},e.prototype.get=function(e){return this._v.get(e)},Object.defineProperty(e.prototype,"defaultCachingStore",{get:function(){return this.get("defaultCachingStore")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultCachingTimeoutSeconds",{get:function(){return this.get("defaultCachingTimeoutSeconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalCacheDisable",{get:function(){return this.get("globalCacheDisable")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableCacheExpiration",{get:function(){return this.get("enableCacheExpiration")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cacheExpirationIntervalMilliseconds",{get:function(){return this.get("cacheExpirationIntervalMilliseconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spfxContext",{get:function(){return this.get("spfxContext")},enumerable:!0,configurable:!0}),e}(),s=new o,a=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(7);n.d(t,"AdalClient",function(){return i.a}),n.d(t,"readBlobAsText",function(){return i.z}),n.d(t,"readBlobAsArrayBuffer",function(){return i.y}),n.d(t,"Dictionary",function(){return i.c}),n.d(t,"deprecated",function(){return i.n}),n.d(t,"beta",function(){return i.k}),n.d(t,"UrlException",function(){return i.i}),n.d(t,"setup",function(){return i.A}),n.d(t,"RuntimeConfigImpl",function(){return i.h}),n.d(t,"RuntimeConfig",function(){return i.g}),n.d(t,"mergeHeaders",function(){return i.v}),n.d(t,"mergeOptions",function(){return i.w}),n.d(t,"FetchClient",function(){return i.d}),n.d(t,"BearerTokenFetchClient",function(){return i.b}),n.d(t,"PnPClientStorageWrapper",function(){return i.f}),n.d(t,"PnPClientStorage",function(){return i.e}),n.d(t,"getCtxCallback",function(){return i.p}),n.d(t,"dateAdd",function(){return i.m}),n.d(t,"combinePaths",function(){return i.l}),n.d(t,"getRandomString",function(){return i.r}),n.d(t,"getGUID",function(){return i.q}),n.d(t,"isFunc",function(){return i.t}),n.d(t,"objectDefinedNotNull",function(){return i.x}),n.d(t,"isArray",function(){return i.s}),n.d(t,"extend",function(){return i.o}),n.d(t,"isUrlAbsolute",function(){return i.u}),n.d(t,"stringIsNullOrEmpty",function(){return i.B}),n.d(t,"Util",function(){return i.j})},function(e,t,n){"use strict";var i=n(8);n.d(t,"a",function(){return i.a});var r=n(11);n.d(t,"y",function(){return r.a}),n.d(t,"z",function(){return r.b});var o=n(2);n.d(t,"c",function(){return o.a});var s=n(12);n.d(t,"k",function(){return s.a}),n.d(t,"n",function(){return s.b});var a=n(13);n.d(t,"i",function(){return a.a});var c=n(5);n.d(t,"g",function(){return c.a}),n.d(t,"h",function(){return c.b}),n.d(t,"A",function(){return c.c});var u=n(4);n.d(t,"b",function(){return u.a}),n.d(t,"d",function(){return u.b}),n.d(t,"v",function(){return u.c}),n.d(t,"w",function(){return u.d});var l=n(14);n.d(t,"e",function(){return l.a}),n.d(t,"f",function(){return l.b});var h=n(0);n.d(t,"j",function(){return h.a}),n.d(t,"l",function(){return h.b}),n.d(t,"m",function(){return h.c}),n.d(t,"o",function(){return h.d}),n.d(t,"p",function(){return h.e}),n.d(t,"q",function(){return h.f}),n.d(t,"r",function(){return h.g}),n.d(t,"s",function(){return h.h}),n.d(t,"t",function(){return h.i}),n.d(t,"u",function(){return h.j}),n.d(t,"x",function(){return h.k}),n.d(t,"B",function(){return h.l})},function(e,t,n){"use strict";n.d(t,"a",function(){return a});var i=n(1),r=n(4),o=n(0),s=n(10),a=(n.n(s),function(e){function t(t,n,i){var r=e.call(this,null)||this;return r.clientId=t,r.tenant=n,r.redirectUri=i,r}return i.a(t,e),t.fromSPFxContext=function(e,n){return void 0===n&&(n="c58637bb-e2e1-4312-8a00-04b5ffcd3403"),new t(n,e.pageContext.aadInfo.tenantId.toString(),Object(o.b)(window.location.origin,"/_forms/spfxsinglesignon.aspx"))},t.prototype.fetch=function(t,n){var i=this;if(!Object(o.j)(t))throw new Error("You must supply absolute urls to AdalClient.fetch.");return this.getToken(this.getResource(t)).then(function(r){return i.token=r,e.prototype.fetch.call(i,t,n)})},t.prototype.getToken=function(e){var n=this;return new Promise(function(i,r){n.ensureAuthContext().then(function(e){return n.login()}).then(function(n){t._authContext.acquireToken(e,function(e,t){if(e)return r(new Error(e));i(t)})}).catch(r)})},t.prototype.ensureAuthContext=function(){var e=this;return new Promise(function(n){null===t._authContext&&(t._authContext=s.inject({clientId:e.clientId,displayCall:function(t){e._displayCallback&&e._displayCallback(t)},navigateToLoginRequestUrl:!1,redirectUri:e.redirectUri,tenant:e.tenant})),n()})},t.prototype.login=function(){var e=this;return this._loginPromise?this._loginPromise:(this._loginPromise=new Promise(function(n,i){if(t._authContext.getCachedUser())return n();e._displayCallback=function(r){var o=window.open(r,"login","width=483, height=600");if(!o)return i(new Error("Could not open pop-up window for auth. Likely pop-ups are blocked by the browser."));o&&o.focus&&o.focus();var s=window.setInterval(function(){o&&!o.closed&&void 0!==o.closed||window.clearInterval(s);try{-1!==o.document.URL.indexOf(e.redirectUri)&&(window.clearInterval(s),t._authContext.handleWindowCallback(o.location.hash),o.close(),n())}catch(e){i(e)}},30)},e.ensureAuthContext().then(function(n){t._authContext._loginInProgress=!1,t._authContext.login(),e._displayCallback=null})}),this._loginPromise)},t.prototype.getResource=function(e){var t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname},t._authContext=null,t}(r.a))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){ | ||
// @preserve Copyright (c) Microsoft Open Technologies, Inc. | ||
var n=function(){"use strict";return n=function(e){if(this.REQUEST_TYPE={LOGIN:"LOGIN",RENEW_TOKEN:"RENEW_TOKEN",UNKNOWN:"UNKNOWN"},this.RESPONSE_TYPE={ID_TOKEN_TOKEN:"id_token token",TOKEN:"token"},this.CONSTANTS={ACCESS_TOKEN:"access_token",EXPIRES_IN:"expires_in",ID_TOKEN:"id_token",ERROR_DESCRIPTION:"error_description",SESSION_STATE:"session_state",ERROR:"error",STORAGE:{TOKEN_KEYS:"adal.token.keys",ACCESS_TOKEN_KEY:"adal.access.token.key",EXPIRATION_KEY:"adal.expiration.key",STATE_LOGIN:"adal.state.login",STATE_RENEW:"adal.state.renew",NONCE_IDTOKEN:"adal.nonce.idtoken",SESSION_STATE:"adal.session.state",USERNAME:"adal.username",IDTOKEN:"adal.idtoken",ERROR:"adal.error",ERROR_DESCRIPTION:"adal.error.description",LOGIN_REQUEST:"adal.login.request",LOGIN_ERROR:"adal.login.error",RENEW_STATUS:"adal.token.renew.status",ANGULAR_LOGIN_REQUEST:"adal.angular.login.request"},RESOURCE_DELIMETER:"|",CACHE_DELIMETER:"||",LOADFRAME_TIMEOUT:6e3,TOKEN_RENEW_STATUS_CANCELED:"Canceled",TOKEN_RENEW_STATUS_COMPLETED:"Completed",TOKEN_RENEW_STATUS_IN_PROGRESS:"In Progress",LOGGING_LEVEL:{ERROR:0,WARN:1,INFO:2,VERBOSE:3},LEVEL_STRING_MAP:{0:"ERROR:",1:"WARNING:",2:"INFO:",3:"VERBOSE:"},POPUP_WIDTH:483,POPUP_HEIGHT:600},n.prototype._singletonInstance)return n.prototype._singletonInstance;if(n.prototype._singletonInstance=this,this.instance="https://login.microsoftonline.com/",this.config={},this.callback=null,this.popUp=!1,this.isAngular=!1,this._user=null,this._activeRenewals={},this._loginInProgress=!1,this._acquireTokenInProgress=!1,this._renewStates=[],this._callBackMappedToRenewStates={},this._callBacksMappedToRenewStates={},this._openedWindows=[],this._requestType=this.REQUEST_TYPE.LOGIN,window._adalInstance=this,e.displayCall&&"function"!=typeof e.displayCall)throw new Error("displayCall is not a function");if(!e.clientId)throw new Error("clientId is required");this.config=this._cloneConfig(e),void 0===this.config.navigateToLoginRequestUrl&&(this.config.navigateToLoginRequestUrl=!0),this.config.popUp&&(this.popUp=!0),this.config.callback&&"function"==typeof this.config.callback&&(this.callback=this.config.callback),this.config.instance&&(this.instance=this.config.instance),this.config.loginResource||(this.config.loginResource=this.config.clientId),this.config.redirectUri||(this.config.redirectUri=window.location.href.split("?")[0].split("#")[0]),this.config.postLogoutRedirectUri||(this.config.postLogoutRedirectUri=window.location.href.split("?")[0].split("#")[0]),this.config.anonymousEndpoints||(this.config.anonymousEndpoints=[]),this.config.isAngular&&(this.isAngular=this.config.isAngular),this.config.loadFrameTimeout&&(this.CONSTANTS.LOADFRAME_TIMEOUT=this.config.loadFrameTimeout)},"undefined"!=typeof window&&(window.Logging={piiLoggingEnabled:!1,level:0,log:function(e){}}),n.prototype.login=function(){if(this._loginInProgress)return void this.info("Login in progress");this._loginInProgress=!0;var e=this._guid();this.config.state=e,this._idTokenNonce=this._guid();var t=this._getItem(this.CONSTANTS.STORAGE.ANGULAR_LOGIN_REQUEST);t&&""!==t?this._saveItem(this.CONSTANTS.STORAGE.ANGULAR_LOGIN_REQUEST,""):t=window.location.href,this.verbose("Expected state: "+e+" startPage:"+t),this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST,t),this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR,""),this._saveItem(this.CONSTANTS.STORAGE.STATE_LOGIN,e,!0),this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN,this._idTokenNonce,!0),this._saveItem(this.CONSTANTS.STORAGE.ERROR,""),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,"");var n=this._getNavigateUrl("id_token",null)+"&nonce="+encodeURIComponent(this._idTokenNonce);this.config.displayCall?this.config.displayCall(n):this.popUp?(this._saveItem(this.CONSTANTS.STORAGE.STATE_LOGIN,""),this._renewStates.push(e),this.registerCallback(e,this.config.clientId,this.callback),this._loginPopup(n)):this.promptUser(n)},n.prototype._openPopup=function(e,t,n,i){try{var r=window.screenLeft?window.screenLeft:window.screenX,o=window.screenTop?window.screenTop:window.screenY,s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,a=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,c=s/2-n/2+r,u=a/2-i/2+o,l=window.open(e,t,"width="+n+", height="+i+", top="+u+", left="+c);return l.focus&&l.focus(),l}catch(e){return this.warn("Error opening popup, "+e.message),this._loginInProgress=!1,this._acquireTokenInProgress=!1,null}},n.prototype._handlePopupError=function(e,t,n,i,r){this.warn(i),this._saveItem(this.CONSTANTS.STORAGE.ERROR,n),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,i),this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR,r),t&&this._activeRenewals[t]&&(this._activeRenewals[t]=null),this._loginInProgress=!1,this._acquireTokenInProgress=!1,e&&e(i,null,n)},n.prototype._loginPopup=function(e,t,n){var i=this._openPopup(e,"login",this.CONSTANTS.POPUP_WIDTH,this.CONSTANTS.POPUP_HEIGHT),r=n||this.callback;if(null==i){var o="Popup Window is null. This can happen if you are using IE";return void this._handlePopupError(r,t,"Error opening popup",o,o)}if(this._openedWindows.push(i),-1!=this.config.redirectUri.indexOf("#"))var s=this.config.redirectUri.split("#")[0];else var s=this.config.redirectUri;var a=this,c=window.setInterval(function(){if(!i||i.closed||void 0===i.closed){var e="Popup Window closed",n="Popup Window closed by UI action/ Popup Window handle destroyed due to cross zone navigation in IE/Edge";return a.isAngular&&a._broadcast("adal:popUpClosed",n+a.CONSTANTS.RESOURCE_DELIMETER+e),a._handlePopupError(r,t,e,n,n),void window.clearInterval(c)}try{var o=i.location;if(-1!=encodeURI(o.href).indexOf(encodeURI(s)))return a.isAngular?a._broadcast("adal:popUpHashChanged",o.hash):a.handleWindowCallback(o.hash),window.clearInterval(c),a._loginInProgress=!1,a._acquireTokenInProgress=!1,a.info("Closing popup window"),a._openedWindows=[],void i.close()}catch(e){}},1)},n.prototype._broadcast=function(e,t){!function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}if("function"==typeof window.CustomEvent)return!1;e.prototype=window.Event.prototype,window.CustomEvent=e}();var n=new CustomEvent(e,{detail:t});window.dispatchEvent(n)},n.prototype.loginInProgress=function(){return this._loginInProgress},n.prototype._hasResource=function(e){var t=this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS);return t&&!this._isEmpty(t)&&t.indexOf(e+this.CONSTANTS.RESOURCE_DELIMETER)>-1},n.prototype.getCachedToken=function(e){if(!this._hasResource(e))return null;var t=this._getItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY+e),n=this._getItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY+e),i=this.config.expireOffsetSeconds||300;return n&&n>this._now()+i?t:(this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY+e,""),this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY+e,0),null)},n.prototype.getCachedUser=function(){if(this._user)return this._user;var e=this._getItem(this.CONSTANTS.STORAGE.IDTOKEN);return this._user=this._createUser(e),this._user},n.prototype.registerCallback=function(e,t,n){this._activeRenewals[t]=e,this._callBacksMappedToRenewStates[e]||(this._callBacksMappedToRenewStates[e]=[]);var i=this;this._callBacksMappedToRenewStates[e].push(n),this._callBackMappedToRenewStates[e]||(this._callBackMappedToRenewStates[e]=function(n,r,o,s){i._activeRenewals[t]=null;for(var a=0;a<i._callBacksMappedToRenewStates[e].length;++a)try{i._callBacksMappedToRenewStates[e][a](n,r,o,s)}catch(o){i.warn(o)}i._callBacksMappedToRenewStates[e]=null,i._callBackMappedToRenewStates[e]=null})},n.prototype._renewToken=function(e,t,n){this.info("renewToken is called for resource:"+e);var i=this._addAdalFrame("adalRenewFrame"+e),r=this._guid()+"|"+e;this.config.state=r,this._renewStates.push(r),this.verbose("Renew token Expected state: "+r),n=n||"token";var o=this._urlRemoveQueryStringParameter(this._getNavigateUrl(n,e),"prompt");n===this.RESPONSE_TYPE.ID_TOKEN_TOKEN&&(this._idTokenNonce=this._guid(),this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN,this._idTokenNonce,!0),o+="&nonce="+encodeURIComponent(this._idTokenNonce)),o+="&prompt=none",o=this._addHintParameters(o),this.registerCallback(r,e,t),this.verbosePii("Navigate to:"+o),i.src="about:blank",this._loadFrameTimeout(o,"adalRenewFrame"+e,e)},n.prototype._renewIdToken=function(e,t){this.info("renewIdToken is called");var n=this._addAdalFrame("adalIdTokenFrame"),i=this._guid()+"|"+this.config.clientId;this._idTokenNonce=this._guid(),this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN,this._idTokenNonce,!0),this.config.state=i,this._renewStates.push(i),this.verbose("Renew Idtoken Expected state: "+i);var r=null===t||void 0===t?null:this.config.clientId,t=t||"id_token",o=this._urlRemoveQueryStringParameter(this._getNavigateUrl(t,r),"prompt");o+="&prompt=none",o=this._addHintParameters(o),o+="&nonce="+encodeURIComponent(this._idTokenNonce),this.registerCallback(i,this.config.clientId,e),this.verbosePii("Navigate to:"+o),n.src="about:blank",this._loadFrameTimeout(o,"adalIdTokenFrame",this.config.clientId)},n.prototype._urlContainsQueryStringParameter=function(e,t){return new RegExp("[\\?&]"+e+"=").test(t)},n.prototype._urlRemoveQueryStringParameter=function(e,t){var n=new RegExp("(\\&"+t+"=)[^&]+");return e=e.replace(n,""),n=new RegExp("("+t+"=)[^&]+&"),e=e.replace(n,""),n=new RegExp("("+t+"=)[^&]+"),e=e.replace(n,"")},n.prototype._loadFrameTimeout=function(e,t,n){this.verbose("Set loading state to pending for: "+n),this._saveItem(this.CONSTANTS.STORAGE.RENEW_STATUS+n,this.CONSTANTS.TOKEN_RENEW_STATUS_IN_PROGRESS),this._loadFrame(e,t);var i=this;setTimeout(function(){if(i._getItem(i.CONSTANTS.STORAGE.RENEW_STATUS+n)===i.CONSTANTS.TOKEN_RENEW_STATUS_IN_PROGRESS){i.verbose("Loading frame has timed out after: "+i.CONSTANTS.LOADFRAME_TIMEOUT/1e3+" seconds for resource "+n);var e=i._activeRenewals[n];e&&i._callBackMappedToRenewStates[e]&&i._callBackMappedToRenewStates[e]("Token renewal operation failed due to timeout",null,"Token Renewal Failed"),i._saveItem(i.CONSTANTS.STORAGE.RENEW_STATUS+n,i.CONSTANTS.TOKEN_RENEW_STATUS_CANCELED)}},i.CONSTANTS.LOADFRAME_TIMEOUT)},n.prototype._loadFrame=function(e,t){var n=this;n.info("LoadFrame: "+t);var i=t;setTimeout(function(){var t=n._addAdalFrame(i);""!==t.src&&"about:blank"!==t.src||(t.src=e,n._loadFrame(e,i))},500)},n.prototype.acquireToken=function(e,t){if(this._isEmpty(e))return this.warn("resource is required"),void t("resource is required",null,"resource is required");var n=this.getCachedToken(e);return n?(this.info("Token is already in cache for resource:"+e),void t(null,n,null)):this._user||this.config.extraQueryParameter&&-1!==this.config.extraQueryParameter.indexOf("login_hint")?void(this._activeRenewals[e]?this.registerCallback(this._activeRenewals[e],e,t):(this._requestType=this.REQUEST_TYPE.RENEW_TOKEN,e===this.config.clientId?this._user?(this.verbose("renewing idtoken"),this._renewIdToken(t)):(this.verbose("renewing idtoken and access_token"),this._renewIdToken(t,this.RESPONSE_TYPE.ID_TOKEN_TOKEN)):this._user?(this.verbose("renewing access_token"),this._renewToken(e,t)):(this.verbose("renewing idtoken and access_token"),this._renewToken(e,t,this.RESPONSE_TYPE.ID_TOKEN_TOKEN)))):(this.warn("User login is required"),void t("User login is required",null,"login required"))},n.prototype.acquireTokenPopup=function(e,t,n,i){if(this._isEmpty(e))return this.warn("resource is required"),void i("resource is required",null,"resource is required");if(!this._user)return this.warn("User login is required"),void i("User login is required",null,"login required");if(this._acquireTokenInProgress)return this.warn("Acquire token interactive is already in progress"),void i("Acquire token interactive is already in progress",null,"Acquire token interactive is already in progress");var r=this._guid()+"|"+e;this.config.state=r,this._renewStates.push(r),this._requestType=this.REQUEST_TYPE.RENEW_TOKEN,this.verbose("Renew token Expected state: "+r);var o=this._urlRemoveQueryStringParameter(this._getNavigateUrl("token",e),"prompt");if(o+="&prompt=select_account",t&&(o+=t),n&&-1===o.indexOf("&claims"))o+="&claims="+encodeURIComponent(n);else if(n&&-1!==o.indexOf("&claims"))throw new Error("Claims cannot be passed as an extraQueryParameter");o=this._addHintParameters(o),this._acquireTokenInProgress=!0,this.info("acquireToken interactive is called for the resource "+e),this.registerCallback(r,e,i),this._loginPopup(o,e,i)},n.prototype.acquireTokenRedirect=function(e,t,n){if(this._isEmpty(e))return this.warn("resource is required"),void i("resource is required",null,"resource is required");var i=this.callback;if(!this._user)return this.warn("User login is required"),void i("User login is required",null,"login required");if(this._acquireTokenInProgress)return this.warn("Acquire token interactive is already in progress"),void i("Acquire token interactive is already in progress",null,"Acquire token interactive is already in progress");var r=this._guid()+"|"+e;this.config.state=r,this.verbose("Renew token Expected state: "+r);var o=this._urlRemoveQueryStringParameter(this._getNavigateUrl("token",e),"prompt");if(o+="&prompt=select_account",t&&(o+=t),n&&-1===o.indexOf("&claims"))o+="&claims="+encodeURIComponent(n);else if(n&&-1!==o.indexOf("&claims"))throw new Error("Claims cannot be passed as an extraQueryParameter");o=this._addHintParameters(o),this._acquireTokenInProgress=!0,this.info("acquireToken interactive is called for the resource "+e),this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST,window.location.href),this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW,r,!0),this.promptUser(o)},n.prototype.promptUser=function(e){e?(this.infoPii("Navigate to:"+e),window.location.replace(e)):this.info("Navigate url is empty")},n.prototype.clearCache=function(){this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST,""),this._saveItem(this.CONSTANTS.STORAGE.ANGULAR_LOGIN_REQUEST,""),this._saveItem(this.CONSTANTS.STORAGE.SESSION_STATE,""),this._saveItem(this.CONSTANTS.STORAGE.STATE_LOGIN,""),this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW,""),this._renewStates=[],this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN,""),this._saveItem(this.CONSTANTS.STORAGE.IDTOKEN,""),this._saveItem(this.CONSTANTS.STORAGE.ERROR,""),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,""),this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR,""),this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR,"");var e=this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS);if(!this._isEmpty(e)){e=e.split(this.CONSTANTS.RESOURCE_DELIMETER);for(var t=0;t<e.length&&""!==e[t];t++)this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY+e[t],""),this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY+e[t],0)}this._saveItem(this.CONSTANTS.STORAGE.TOKEN_KEYS,"")},n.prototype.clearCacheForResource=function(e){this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW,""),this._saveItem(this.CONSTANTS.STORAGE.ERROR,""),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,""),this._hasResource(e)&&(this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY+e,""),this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY+e,0))},n.prototype.logOut=function(){this.clearCache(),this._user=null;var e;if(this.config.logOutUri)e=this.config.logOutUri;else{var t="common",n="";this.config.tenant&&(t=this.config.tenant),this.config.postLogoutRedirectUri&&(n="post_logout_redirect_uri="+encodeURIComponent(this.config.postLogoutRedirectUri)),e=this.instance+t+"/oauth2/logout?"+n}this.infoPii("Logout navigate to: "+e),this.promptUser(e)},n.prototype._isEmpty=function(e){return void 0===e||!e||0===e.length},n.prototype.getUser=function(e){if("function"!=typeof e)throw new Error("callback is not a function");if(this._user)return void e(null,this._user);var t=this._getItem(this.CONSTANTS.STORAGE.IDTOKEN);this._isEmpty(t)?(this.warn("User information is not available"),e("User information is not available",null)):(this.info("User exists in cache: "),this._user=this._createUser(t),e(null,this._user))},n.prototype._addHintParameters=function(e){if(this._user&&this._user.profile)if(this._user.profile.sid&&-1!==e.indexOf("&prompt=none"))this._urlContainsQueryStringParameter("sid",e)||(e+="&sid="+encodeURIComponent(this._user.profile.sid));else if(this._user.profile.upn&&(this._urlContainsQueryStringParameter("login_hint",e)||(e+="&login_hint="+encodeURIComponent(this._user.profile.upn)),!this._urlContainsQueryStringParameter("domain_hint",e)&&this._user.profile.upn.indexOf("@")>-1)){var t=this._user.profile.upn.split("@");e+="&domain_hint="+encodeURIComponent(t[t.length-1])}return e},n.prototype._createUser=function(e){var t=null,n=this._extractIdToken(e);return n&&n.hasOwnProperty("aud")&&(n.aud.toLowerCase()===this.config.clientId.toLowerCase()?(t={userName:"",profile:n},n.hasOwnProperty("upn")?t.userName=n.upn:n.hasOwnProperty("email")&&(t.userName=n.email)):this.warn("IdToken has invalid aud field")),t},n.prototype._getHash=function(e){return e.indexOf("#/")>-1?e=e.substring(e.indexOf("#/")+2):e.indexOf("#")>-1&&(e=e.substring(1)),e},n.prototype.isCallback=function(e){e=this._getHash(e);var t=this._deserialize(e);return t.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION)||t.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN)||t.hasOwnProperty(this.CONSTANTS.ID_TOKEN)},n.prototype.getLoginError=function(){return this._getItem(this.CONSTANTS.STORAGE.LOGIN_ERROR)},n.prototype.getRequestInfo=function(e){e=this._getHash(e);var t=this._deserialize(e),n={valid:!1,parameters:{},stateMatch:!1,stateResponse:"",requestType:this.REQUEST_TYPE.UNKNOWN};if(t&&(n.parameters=t,t.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION)||t.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN)||t.hasOwnProperty(this.CONSTANTS.ID_TOKEN))){n.valid=!0;var i="";if(!t.hasOwnProperty("state"))return this.warn("No state returned"),n;if(this.verbose("State: "+t.state),i=t.state,n.stateResponse=i,this._matchState(n))return n;if(!n.stateMatch&&window.parent){n.requestType=this._requestType;for(var r=this._renewStates,o=0;o<r.length;o++)if(r[o]===n.stateResponse){n.stateMatch=!0;break}}}return n},n.prototype._matchNonce=function(e){var t=this._getItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN);if(t){t=t.split(this.CONSTANTS.CACHE_DELIMETER);for(var n=0;n<t.length;n++)if(t[n]===e.profile.nonce)return!0}return!1},n.prototype._matchState=function(e){var t=this._getItem(this.CONSTANTS.STORAGE.STATE_LOGIN);if(t){t=t.split(this.CONSTANTS.CACHE_DELIMETER);for(var n=0;n<t.length;n++)if(t[n]===e.stateResponse)return e.requestType=this.REQUEST_TYPE.LOGIN,e.stateMatch=!0,!0}var i=this._getItem(this.CONSTANTS.STORAGE.STATE_RENEW);if(i){i=i.split(this.CONSTANTS.CACHE_DELIMETER);for(var n=0;n<i.length;n++)if(i[n]===e.stateResponse)return e.requestType=this.REQUEST_TYPE.RENEW_TOKEN,e.stateMatch=!0,!0}return!1},n.prototype._getResourceFromState=function(e){if(e){var t=e.indexOf("|");if(t>-1&&t+1<e.length)return e.substring(t+1)}return""},n.prototype.saveTokenFromHash=function(e){this.info("State status:"+e.stateMatch+"; Request type:"+e.requestType),this._saveItem(this.CONSTANTS.STORAGE.ERROR,""),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,"");var t=this._getResourceFromState(e.stateResponse);if(e.parameters.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION))this.infoPii("Error :"+e.parameters.error+"; Error description:"+e.parameters[this.CONSTANTS.ERROR_DESCRIPTION]),this._saveItem(this.CONSTANTS.STORAGE.ERROR,e.parameters.error),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,e.parameters[this.CONSTANTS.ERROR_DESCRIPTION]),e.requestType===this.REQUEST_TYPE.LOGIN&&(this._loginInProgress=!1,this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR,e.parameters.error_description));else if(e.stateMatch){this.info("State is right"),e.parameters.hasOwnProperty(this.CONSTANTS.SESSION_STATE)&&this._saveItem(this.CONSTANTS.STORAGE.SESSION_STATE,e.parameters[this.CONSTANTS.SESSION_STATE]);var n;e.parameters.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN)&&(this.info("Fragment has access token"),this._hasResource(t)||(n=this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS)||"",this._saveItem(this.CONSTANTS.STORAGE.TOKEN_KEYS,n+t+this.CONSTANTS.RESOURCE_DELIMETER)),this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY+t,e.parameters[this.CONSTANTS.ACCESS_TOKEN]),this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY+t,this._expiresIn(e.parameters[this.CONSTANTS.EXPIRES_IN]))),e.parameters.hasOwnProperty(this.CONSTANTS.ID_TOKEN)&&(this.info("Fragment has id token"),this._loginInProgress=!1,this._user=this._createUser(e.parameters[this.CONSTANTS.ID_TOKEN]),this._user&&this._user.profile?this._matchNonce(this._user)?(this._saveItem(this.CONSTANTS.STORAGE.IDTOKEN,e.parameters[this.CONSTANTS.ID_TOKEN]),t=this.config.loginResource?this.config.loginResource:this.config.clientId,this._hasResource(t)||(n=this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS)||"",this._saveItem(this.CONSTANTS.STORAGE.TOKEN_KEYS,n+t+this.CONSTANTS.RESOURCE_DELIMETER)),this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY+t,e.parameters[this.CONSTANTS.ID_TOKEN]),this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY+t,this._user.profile.exp)):(this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR,"Nonce received: "+this._user.profile.nonce+" is not same as requested: "+this._getItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN)),this._user=null):(e.parameters.error="invalid id_token",e.parameters.error_description="Invalid id_token. id_token: "+e.parameters[this.CONSTANTS.ID_TOKEN],this._saveItem(this.CONSTANTS.STORAGE.ERROR,"invalid id_token"),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,"Invalid id_token. id_token: "+e.parameters[this.CONSTANTS.ID_TOKEN])))}else e.parameters.error="Invalid_state",e.parameters.error_description="Invalid_state. state: "+e.stateResponse,this._saveItem(this.CONSTANTS.STORAGE.ERROR,"Invalid_state"),this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION,"Invalid_state. state: "+e.stateResponse);this._saveItem(this.CONSTANTS.STORAGE.RENEW_STATUS+t,this.CONSTANTS.TOKEN_RENEW_STATUS_COMPLETED)},n.prototype.getResourceForEndpoint=function(e){if(this.config&&this.config.anonymousEndpoints)for(var t=0;t<this.config.anonymousEndpoints.length;t++)if(e.indexOf(this.config.anonymousEndpoints[t])>-1)return null;if(this.config&&this.config.endpoints)for(var n in this.config.endpoints)if(e.indexOf(n)>-1)return this.config.endpoints[n];return e.indexOf("http://")>-1||e.indexOf("https://")>-1?this._getHostFromUri(e)===this._getHostFromUri(this.config.redirectUri)?this.config.loginResource:null:this.config.loginResource},n.prototype._getHostFromUri=function(e){var t=String(e).replace(/^(https?:)\/\//,"");return t=t.split("/")[0]},n.prototype.handleWindowCallback=function(e){if(null==e&&(e=window.location.hash),this.isCallback(e)){var t=null,n=!1;this._openedWindows.length>0&&this._openedWindows[this._openedWindows.length-1].opener&&this._openedWindows[this._openedWindows.length-1].opener._adalInstance?(t=this._openedWindows[this._openedWindows.length-1].opener._adalInstance,n=!0):window.parent&&window.parent._adalInstance&&(t=window.parent._adalInstance);var i,r,o=t.getRequestInfo(e),s=null;r=n||window.parent!==window?t._callBackMappedToRenewStates[o.stateResponse]:t.callback,t.info("Returned from redirect url"),t.saveTokenFromHash(o),o.requestType===this.REQUEST_TYPE.RENEW_TOKEN&&window.parent?(window.parent!==window?t.verbose("Window is in iframe, acquiring token silently"):t.verbose("acquiring token interactive in progress"),i=o.parameters[t.CONSTANTS.ACCESS_TOKEN]||o.parameters[t.CONSTANTS.ID_TOKEN],s=t.CONSTANTS.ACCESS_TOKEN):o.requestType===this.REQUEST_TYPE.LOGIN&&(i=o.parameters[t.CONSTANTS.ID_TOKEN],s=t.CONSTANTS.ID_TOKEN);var a=o.parameters[t.CONSTANTS.ERROR_DESCRIPTION],c=o.parameters[t.CONSTANTS.ERROR];try{r&&r(a,i,c,s)}catch(e){t.error("Error occurred in user defined callback function: "+e)}window.parent!==window||n||(t.config.navigateToLoginRequestUrl?window.location.href=t._getItem(t.CONSTANTS.STORAGE.LOGIN_REQUEST):window.location.hash="")}},n.prototype._getNavigateUrl=function(e,t){var n="common";this.config.tenant&&(n=this.config.tenant);var i=this.instance+n+"/oauth2/authorize"+this._serialize(e,this.config,t)+this._addLibMetadata();return this.info("Navigate url:"+i),i},n.prototype._extractIdToken=function(e){var t=this._decodeJwt(e);if(!t)return null;try{var n=t.JWSPayload,i=this._base64DecodeStringUrlSafe(n);return i?JSON.parse(i):(this.info("The returned id_token could not be base64 url safe decoded."),null)}catch(e){this.error("The returned id_token could not be decoded",e)}return null},n.prototype._base64DecodeStringUrlSafe=function(e){return e=e.replace(/-/g,"+").replace(/_/g,"/"),window.atob?decodeURIComponent(escape(window.atob(e))):decodeURIComponent(escape(this._decode(e)))},n.prototype._decode=function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e=String(e).replace(/=+$/,"");var n=e.length;if(n%4==1)throw new Error("The token to be decoded is not correctly encoded.");for(var i,r,o,s,a,c,u,l,h="",d=0;d<n;d+=4){if(i=t.indexOf(e.charAt(d)),r=t.indexOf(e.charAt(d+1)),o=t.indexOf(e.charAt(d+2)),s=t.indexOf(e.charAt(d+3)),d+2===n-1){a=i<<18|r<<12|o<<6,c=a>>16&255,u=a>>8&255,h+=String.fromCharCode(c,u);break}if(d+1===n-1){a=i<<18|r<<12,c=a>>16&255,h+=String.fromCharCode(c);break}a=i<<18|r<<12|o<<6|s,c=a>>16&255,u=a>>8&255,l=255&a,h+=String.fromCharCode(c,u,l)}return h},n.prototype._decodeJwt=function(e){if(this._isEmpty(e))return null;var t=/^([^\.\s]*)\.([^\.\s]+)\.([^\.\s]*)$/,n=t.exec(e);return!n||n.length<4?(this.warn("The returned id_token is not parseable."),null):{header:n[1],JWSPayload:n[2],JWSSig:n[3]}},n.prototype._convertUrlSafeToRegularBase64EncodedString=function(e){return e.replace("-","+").replace("_","/")},n.prototype._serialize=function(e,t,n){var i=[];if(null!==t){i.push("?response_type="+e),i.push("client_id="+encodeURIComponent(t.clientId)),n&&i.push("resource="+encodeURIComponent(n)),i.push("redirect_uri="+encodeURIComponent(t.redirectUri)),i.push("state="+encodeURIComponent(t.state)),t.hasOwnProperty("slice")&&i.push("slice="+encodeURIComponent(t.slice)),t.hasOwnProperty("extraQueryParameter")&&i.push(t.extraQueryParameter);var r=t.correlationId?t.correlationId:this._guid();i.push("client-request-id="+encodeURIComponent(r))}return i.join("&")},n.prototype._deserialize=function(e){var t,n=/\+/g,i=/([^&=]+)=([^&]*)/g,r=function(e){return decodeURIComponent(e.replace(n," "))},o={};for(t=i.exec(e);t;)o[r(t[1])]=r(t[2]),t=i.exec(e);return o},n.prototype._decimalToHex=function(e){for(var t=e.toString(16);t.length<2;)t="0"+t;return t},n.prototype._guid=function(){var e=window.crypto||window.msCrypto;if(e&&e.getRandomValues){var t=new Uint8Array(16);return e.getRandomValues(t),t[6]|=64,t[6]&=79,t[8]|=128,t[8]&=191,this._decimalToHex(t[0])+this._decimalToHex(t[1])+this._decimalToHex(t[2])+this._decimalToHex(t[3])+"-"+this._decimalToHex(t[4])+this._decimalToHex(t[5])+"-"+this._decimalToHex(t[6])+this._decimalToHex(t[7])+"-"+this._decimalToHex(t[8])+this._decimalToHex(t[9])+"-"+this._decimalToHex(t[10])+this._decimalToHex(t[11])+this._decimalToHex(t[12])+this._decimalToHex(t[13])+this._decimalToHex(t[14])+this._decimalToHex(t[15])}for(var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",i="0123456789abcdef",r=0,o="",s=0;s<36;s++)"-"!==n[s]&&"4"!==n[s]&&(r=16*Math.random()|0),"x"===n[s]?o+=i[r]:"y"===n[s]?(r&=3,r|=8,o+=i[r]):o+=n[s];return o},n.prototype._expiresIn=function(e){return e||(e=3599),this._now()+parseInt(e,10)},n.prototype._now=function(){return Math.round((new Date).getTime()/1e3)},n.prototype._addAdalFrame=function(e){if(void 0!==e){this.info("Add adal frame to document:"+e);var t=document.getElementById(e);if(!t){if(document.createElement&&document.documentElement&&(window.opera||-1===window.navigator.userAgent.indexOf("MSIE 5.0"))){var n=document.createElement("iframe");n.setAttribute("id",e),n.setAttribute("aria-hidden","true"),n.style.visibility="hidden",n.style.position="absolute",n.style.width=n.style.height=n.borderWidth="0px",t=document.getElementsByTagName("body")[0].appendChild(n)}else document.body&&document.body.insertAdjacentHTML&&document.body.insertAdjacentHTML("beforeEnd",'<iframe name="'+e+'" id="'+e+'" style="display:none"></iframe>');window.frames&&window.frames[e]&&(t=window.frames[e])}return t}},n.prototype._saveItem=function(e,t,n){if(this.config&&this.config.cacheLocation&&"localStorage"===this.config.cacheLocation){if(!this._supportsLocalStorage())return this.info("Local storage is not supported"),!1;if(n){var i=this._getItem(e)||"";localStorage.setItem(e,i+t+this.CONSTANTS.CACHE_DELIMETER)}else localStorage.setItem(e,t);return!0}return this._supportsSessionStorage()?(sessionStorage.setItem(e,t),!0):(this.info("Session storage is not supported"),!1)},n.prototype._getItem=function(e){return this.config&&this.config.cacheLocation&&"localStorage"===this.config.cacheLocation?this._supportsLocalStorage()?localStorage.getItem(e):(this.info("Local storage is not supported"),null):this._supportsSessionStorage()?sessionStorage.getItem(e):(this.info("Session storage is not supported"),null)},n.prototype._supportsLocalStorage=function(){try{return!!window.localStorage&&(window.localStorage.setItem("storageTest","A"),"A"==window.localStorage.getItem("storageTest")&&(window.localStorage.removeItem("storageTest"),!window.localStorage.getItem("storageTest")))}catch(e){return!1}},n.prototype._supportsSessionStorage=function(){try{return!!window.sessionStorage&&(window.sessionStorage.setItem("storageTest","A"),"A"==window.sessionStorage.getItem("storageTest")&&(window.sessionStorage.removeItem("storageTest"),!window.sessionStorage.getItem("storageTest")))}catch(e){return!1}},n.prototype._cloneConfig=function(e){if(null===e||"object"!=typeof e)return e;var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},n.prototype._addLibMetadata=function(){return"&x-client-SKU=Js&x-client-Ver="+this._libVersion()},n.prototype.log=function(e,t,n,i){if(e<=Logging.level){if(!Logging.piiLoggingEnabled&&i)return;var r=(new Date).toUTCString(),o="";o=this.config.correlationId?r+":"+this.config.correlationId+"-"+this._libVersion()+"-"+this.CONSTANTS.LEVEL_STRING_MAP[e]+" "+t:r+":"+this._libVersion()+"-"+this.CONSTANTS.LEVEL_STRING_MAP[e]+" "+t,n&&(o+="\nstack:\n"+n.stack),Logging.log(o)}},n.prototype.error=function(e,t){this.log(this.CONSTANTS.LOGGING_LEVEL.ERROR,e,t)},n.prototype.warn=function(e){this.log(this.CONSTANTS.LOGGING_LEVEL.WARN,e,null)},n.prototype.info=function(e){this.log(this.CONSTANTS.LOGGING_LEVEL.INFO,e,null)},n.prototype.verbose=function(e){this.log(this.CONSTANTS.LOGGING_LEVEL.VERBOSE,e,null)},n.prototype.errorPii=function(e,t){this.log(this.CONSTANTS.LOGGING_LEVEL.ERROR,e,t,!0)},n.prototype.warnPii=function(e){this.log(this.CONSTANTS.LOGGING_LEVEL.WARN,e,null,!0)},n.prototype.infoPii=function(e){this.log(this.CONSTANTS.LOGGING_LEVEL.INFO,e,null,!0)},n.prototype.verbosePii=function(e){this.log(this.CONSTANTS.LOGGING_LEVEL.VERBOSE,e,null,!0)},n.prototype._libVersion=function(){return"1.0.17"},void 0!==e&&e.exports&&(e.exports=n,e.exports.inject=function(e){return new n(e)}),n}()},function(e,t,n){"use strict";function i(e){return o(e,"string")}function r(e){return o(e,"buffer")}function o(e,t){return new Promise(function(n,i){try{var r=new FileReader;switch(r.onload=function(e){n(e.target.result)},t){case"string":r.readAsText(e);break;case"buffer":r.readAsArrayBuffer(e)}}catch(e){i(e)}})}t.b=i,t.a=r},function(e,t,n){"use strict";function i(e,t){return function(n,i,r){var s=r.value;r.value=function(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];return o.a.log({data:{descriptor:r,propertyKey:i,target:n},level:2,message:"("+e+") "+t}),s.apply(this,a)}}}function r(e){return void 0===e&&(e="This feature is flagged as beta and is subject to change."),function(t,n,i){var r=i.value;i.value=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];return o.a.log({data:{descriptor:i,propertyKey:n,target:t},level:2,message:e}),r.apply(this,s)}}}t.b=i,t.a=r;var o=n(3)},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var i=n(1),r=n(3),o=function(e){function t(t){var n=e.call(this,t)||this;return n.name="UrlException",r.a.log({data:{},level:3,message:"["+n.name+"]::"+n.message}),n}return i.a(t,e),t}(Error)},function(e,t,n){"use strict";n.d(t,"b",function(){return a}),n.d(t,"a",function(){return u});var i=n(0),r=n(2),o=n(5),s=n(3),a=function(){function e(e,t){void 0===t&&(t=-1),this.store=e,this.defaultTimeoutMinutes=t,this.enabled=this.test(),o.a.enableCacheExpiration&&(s.a.write("Enabling cache expiration.",1),this.cacheExpirationHandler())}return e.prototype.get=function(e){if(!this.enabled)return null;var t=this.store.getItem(e);if(null==t)return null;var n=JSON.parse(t);return new Date(n.expiration)<=new Date?(s.a.write("Removing item with key '"+e+"' from cache due to expiration.",1),this.delete(e),null):n.value},e.prototype.put=function(e,t,n){this.enabled&&this.store.setItem(e,this.createPersistable(t,n))},e.prototype.delete=function(e){this.enabled&&this.store.removeItem(e)},e.prototype.getOrPut=function(e,t,n){var i=this;return this.enabled?new Promise(function(r){var o=i.get(e);null==o?t().then(function(t){i.put(e,t,n),r(t)}):r(o)}):t()},e.prototype.deleteExpired=function(){var e=this;return new Promise(function(t,n){e.enabled||t();try{for(var i=0;i<e.store.length;i++){var r=e.store.key(i);null!==r&&/["|']?pnp["|']? ?: ?1/i.test(e.store.getItem(r))&&e.get(r)}t()}catch(e){n(e)}})},e.prototype.test=function(){try{return this.store.setItem("test","test"),this.store.removeItem("test"),!0}catch(e){return!1}},e.prototype.createPersistable=function(e,t){if(void 0===t){var n=o.a.defaultCachingTimeoutSeconds;this.defaultTimeoutMinutes>0&&(n=60*this.defaultTimeoutMinutes),t=i.a.dateAdd(new Date,"second",n)}return JSON.stringify({pnp:1,expiration:t,value:e})},e.prototype.cacheExpirationHandler=function(){var e=this;s.a.write("Called cache expiration handler.",0),this.deleteExpired().then(function(t){setTimeout(i.a.getCtxCallback(e,e.cacheExpirationHandler),o.a.cacheExpirationIntervalMilliseconds)}).catch(function(e){s.a.log({data:e,level:3,message:"Error deleting expired cache entries, see data for details. Timeout not reset."})})},e}(),c=function(){function e(e){void 0===e&&(e=new r.a),this._store=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this._store.count},enumerable:!0,configurable:!0}),e.prototype.clear=function(){this._store.clear()},e.prototype.getItem=function(e){return this._store.get(e)},e.prototype.key=function(e){return this._store.getKeys()[e]},e.prototype.removeItem=function(e){this._store.remove(e)},e.prototype.setItem=function(e,t){this._store.add(e,t)},e}(),u=function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this._local=e,this._session=t}return Object.defineProperty(e.prototype,"local",{get:function(){return null===this._local&&(this._local=new a("undefined"!=typeof localStorage?localStorage:new c)),this._local},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"session",{get:function(){return null===this._session&&(this._session=new a("undefined"!=typeof sessionStorage?sessionStorage:new c)),this._session},enumerable:!0,configurable:!0}),e}()}])}); | ||
//# sourceMappingURL=common.es5.umd.bundle.min.js.map |
/** | ||
@license | ||
* @pnp/common v1.0.3 - pnp - provides shared functionality across all pnp libraries | ||
* @pnp/common v1.0.4-0 - pnp - provides shared functionality across all pnp libraries | ||
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE) | ||
* Copyright (c) 2018 Microsoft | ||
* docs: http://officedev.github.io/PnP-JS-Core | ||
* docs: https://pnp.github.io/pnp/ | ||
* source: https://github.com/pnp/pnp | ||
@@ -11,298 +11,8 @@ * bugs: https://github.com/pnp/pnp/issues | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@pnp/logging'), require('tslib')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@pnp/logging', 'tslib'], factory) : | ||
(factory((global.pnp = global.pnp || {}, global.pnp.common = {}),global.pnp.logging,global.tslib_1)); | ||
}(this, (function (exports,logging,tslib_1) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('adal-angular'), require('@pnp/logging')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'tslib', 'adal-angular', '@pnp/logging'], factory) : | ||
(factory((global.pnp = global.pnp || {}, global.pnp.common = {}),global.tslib_1,global.adal,global.pnp.logging)); | ||
}(this, (function (exports,tslib_1,adal,logging) { 'use strict'; | ||
/** | ||
* Reads a blob as text | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsText(blob) { | ||
return readBlobAs(blob, "string"); | ||
} | ||
/** | ||
* Reads a blob into an array buffer | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsArrayBuffer(blob) { | ||
return readBlobAs(blob, "buffer"); | ||
} | ||
/** | ||
* Generic method to read blob's content | ||
* | ||
* @param blob The data to read | ||
* @param mode The read mode | ||
*/ | ||
function readBlobAs(blob, mode) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
var reader = new FileReader(); | ||
reader.onload = function (e) { | ||
resolve(e.target.result); | ||
}; | ||
switch (mode) { | ||
case "string": | ||
reader.readAsText(blob); | ||
break; | ||
case "buffer": | ||
reader.readAsArrayBuffer(blob); | ||
break; | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
} | ||
/** | ||
* Generic dictionary | ||
*/ | ||
var Dictionary = /** @class */ (function () { | ||
/** | ||
* Creates a new instance of the Dictionary<T> class | ||
* | ||
* @constructor | ||
*/ | ||
function Dictionary(keys, values) { | ||
if (keys === void 0) { keys = []; } | ||
if (values === void 0) { values = []; } | ||
this.keys = keys; | ||
this.values = values; | ||
} | ||
/** | ||
* Gets a value from the collection using the specified key | ||
* | ||
* @param key The key whose value we want to return, returns null if the key does not exist | ||
*/ | ||
Dictionary.prototype.get = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
return this.values[index]; | ||
}; | ||
/** | ||
* Adds the supplied key and value to the dictionary | ||
* | ||
* @param key The key to add | ||
* @param o The value to add | ||
*/ | ||
Dictionary.prototype.add = function (key, o) { | ||
var index = this.keys.indexOf(key); | ||
if (index > -1) { | ||
if (o === null) { | ||
this.remove(key); | ||
} | ||
else { | ||
this.values[index] = o; | ||
} | ||
} | ||
else { | ||
if (o !== null) { | ||
this.keys.push(key); | ||
this.values.push(o); | ||
} | ||
} | ||
}; | ||
/** | ||
* Merges the supplied typed hash into this dictionary instance. Existing values are updated and new ones are created as appropriate. | ||
*/ | ||
Dictionary.prototype.merge = function (source) { | ||
var _this = this; | ||
if ("getKeys" in source) { | ||
var sourceAsDictionary_1 = source; | ||
sourceAsDictionary_1.getKeys().map(function (key) { | ||
_this.add(key, sourceAsDictionary_1.get(key)); | ||
}); | ||
} | ||
else { | ||
var sourceAsHash = source; | ||
for (var key in sourceAsHash) { | ||
if (sourceAsHash.hasOwnProperty(key)) { | ||
this.add(key, sourceAsHash[key]); | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Removes a value from the dictionary | ||
* | ||
* @param key The key of the key/value pair to remove. Returns null if the key was not found. | ||
*/ | ||
Dictionary.prototype.remove = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
var val = this.values[index]; | ||
this.keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
return val; | ||
}; | ||
/** | ||
* Returns all the keys currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getKeys = function () { | ||
return this.keys; | ||
}; | ||
/** | ||
* Returns all the values currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getValues = function () { | ||
return this.values; | ||
}; | ||
/** | ||
* Clears the current dictionary | ||
*/ | ||
Dictionary.prototype.clear = function () { | ||
this.keys = []; | ||
this.values = []; | ||
}; | ||
Object.defineProperty(Dictionary.prototype, "count", { | ||
/** | ||
* Gets a count of the items currently in the dictionary | ||
*/ | ||
get: function () { | ||
return this.keys.length; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Dictionary; | ||
}()); | ||
function deprecated(deprecationVersion, message) { | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
logging.Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: "(" + deprecationVersion + ") " + message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
function beta(message) { | ||
if (message === void 0) { message = "This feature is flagged as beta and is subject to change."; } | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
logging.Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
var UrlException = /** @class */ (function (_super) { | ||
tslib_1.__extends(UrlException, _super); | ||
function UrlException(msg) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.name = "UrlException"; | ||
logging.Logger.log({ data: {}, level: 3 /* Error */, message: "[" + _this.name + "]::" + _this.message }); | ||
return _this; | ||
} | ||
return UrlException; | ||
}(Error)); | ||
function setup(config) { | ||
RuntimeConfig.extend(config); | ||
} | ||
var RuntimeConfigImpl = /** @class */ (function () { | ||
function RuntimeConfigImpl() { | ||
this._v = new Dictionary(); | ||
// setup defaults | ||
this._v.add("defaultCachingStore", "session"); | ||
this._v.add("defaultCachingTimeoutSeconds", 60); | ||
this._v.add("globalCacheDisable", false); | ||
this._v.add("enableCacheExpiration", false); | ||
this._v.add("cacheExpirationIntervalMilliseconds", 750); | ||
this._v.add("spfxContext", null); | ||
} | ||
/** | ||
* | ||
* @param config The set of properties to add to the globa configuration instance | ||
*/ | ||
RuntimeConfigImpl.prototype.extend = function (config) { | ||
var _this = this; | ||
Object.keys(config).forEach(function (key) { | ||
_this._v.add(key, config[key]); | ||
}); | ||
}; | ||
RuntimeConfigImpl.prototype.get = function (key) { | ||
return this._v.get(key); | ||
}; | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingStore", { | ||
get: function () { | ||
return this.get("defaultCachingStore"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingTimeoutSeconds", { | ||
get: function () { | ||
return this.get("defaultCachingTimeoutSeconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "globalCacheDisable", { | ||
get: function () { | ||
return this.get("globalCacheDisable"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "enableCacheExpiration", { | ||
get: function () { | ||
return this.get("enableCacheExpiration"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "cacheExpirationIntervalMilliseconds", { | ||
get: function () { | ||
return this.get("cacheExpirationIntervalMilliseconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "spfxContext", { | ||
get: function () { | ||
return this.get("spfxContext"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return RuntimeConfigImpl; | ||
}()); | ||
var _runtimeConfig = new RuntimeConfigImpl(); | ||
var RuntimeConfig = _runtimeConfig; | ||
/** | ||
* Gets a callback function which will maintain context across async calls. | ||
@@ -590,2 +300,12 @@ * Allows for the calling pattern getCtxCallback(thisobj, method, methodarg1, methodarg2, ...) | ||
} | ||
Object.defineProperty(BearerTokenFetchClient.prototype, "token", { | ||
get: function () { | ||
return this._token; | ||
}, | ||
set: function (token) { | ||
this._token = token; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
BearerTokenFetchClient.prototype.fetch = function (url, options) { | ||
@@ -603,2 +323,446 @@ if (options === void 0) { options = {}; } | ||
/** | ||
* Azure AD Client for use in the browser | ||
*/ | ||
var AdalClient = /** @class */ (function (_super) { | ||
tslib_1.__extends(AdalClient, _super); | ||
/** | ||
* Creates a new instance of AdalClient | ||
* @param clientId Azure App Id | ||
* @param tenant Office 365 tenant (Ex: {tenant}.onmicrosoft.com) | ||
* @param redirectUri The redirect url used to authenticate the | ||
*/ | ||
function AdalClient(clientId, tenant, redirectUri) { | ||
var _this = _super.call(this, null) || this; | ||
_this.clientId = clientId; | ||
_this.tenant = tenant; | ||
_this.redirectUri = redirectUri; | ||
return _this; | ||
} | ||
/** | ||
* Creates a new AdalClient using the values of the supplied SPFx context | ||
* | ||
* @param spfxContext Current SPFx context | ||
* @param clientId Optional client id to use instead of the built-in SPFx id | ||
* @description Using this method and the default clientId requires that the features described in | ||
* this article https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient are activated in the tenant. If not you can | ||
* creat your own app, grant permissions and use that clientId here along with the SPFx context | ||
*/ | ||
AdalClient.fromSPFxContext = function (spfxContext, cliendId) { | ||
if (cliendId === void 0) { cliendId = "c58637bb-e2e1-4312-8a00-04b5ffcd3403"; } | ||
// this "magic" client id is the one to which permissions are granted behind the scenes | ||
// this redirectUrl is the page as used by spfx | ||
return new AdalClient(cliendId, spfxContext.pageContext.aadInfo.tenantId.toString(), combinePaths(window.location.origin, "/_forms/spfxsinglesignon.aspx")); | ||
}; | ||
/** | ||
* Conducts the fetch opertation against the AAD secured resource | ||
* | ||
* @param url Absolute URL for the request | ||
* @param options Any fetch options passed to the underlying fetch implementation | ||
*/ | ||
AdalClient.prototype.fetch = function (url, options) { | ||
var _this = this; | ||
if (!isUrlAbsolute(url)) { | ||
throw new Error("You must supply absolute urls to AdalClient.fetch."); | ||
} | ||
// the url we are calling is the resource | ||
return this.getToken(this.getResource(url)).then(function (token) { | ||
_this.token = token; | ||
return _super.prototype.fetch.call(_this, url, options); | ||
}); | ||
}; | ||
/** | ||
* Gets a token based on the current user | ||
* | ||
* @param resource The resource for which we are requesting a token | ||
*/ | ||
AdalClient.prototype.getToken = function (resource) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.ensureAuthContext().then(function (_) { return _this.login(); }).then(function (_) { | ||
AdalClient._authContext.acquireToken(resource, function (message, token) { | ||
if (message) { | ||
return reject(new Error(message)); | ||
} | ||
resolve(token); | ||
}); | ||
}).catch(reject); | ||
}); | ||
}; | ||
/** | ||
* Ensures we have created and setup the adal AuthenticationContext instance | ||
*/ | ||
AdalClient.prototype.ensureAuthContext = function () { | ||
var _this = this; | ||
return new Promise(function (resolve) { | ||
if (AdalClient._authContext === null) { | ||
AdalClient._authContext = adal.inject({ | ||
clientId: _this.clientId, | ||
displayCall: function (url) { | ||
if (_this._displayCallback) { | ||
_this._displayCallback(url); | ||
} | ||
}, | ||
navigateToLoginRequestUrl: false, | ||
redirectUri: _this.redirectUri, | ||
tenant: _this.tenant, | ||
}); | ||
} | ||
resolve(); | ||
}); | ||
}; | ||
/** | ||
* Ensures the current user is logged in | ||
*/ | ||
AdalClient.prototype.login = function () { | ||
var _this = this; | ||
if (this._loginPromise) { | ||
return this._loginPromise; | ||
} | ||
this._loginPromise = new Promise(function (resolve, reject) { | ||
if (AdalClient._authContext.getCachedUser()) { | ||
return resolve(); | ||
} | ||
_this._displayCallback = function (url) { | ||
var popupWindow = window.open(url, "login", "width=483, height=600"); | ||
if (!popupWindow) { | ||
return reject(new Error("Could not open pop-up window for auth. Likely pop-ups are blocked by the browser.")); | ||
} | ||
if (popupWindow && popupWindow.focus) { | ||
popupWindow.focus(); | ||
} | ||
var pollTimer = window.setInterval(function () { | ||
if (!popupWindow || popupWindow.closed || popupWindow.closed === undefined) { | ||
window.clearInterval(pollTimer); | ||
} | ||
try { | ||
if (popupWindow.document.URL.indexOf(_this.redirectUri) !== -1) { | ||
window.clearInterval(pollTimer); | ||
AdalClient._authContext.handleWindowCallback(popupWindow.location.hash); | ||
popupWindow.close(); | ||
resolve(); | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}, 30); | ||
}; | ||
// this triggers the login process | ||
_this.ensureAuthContext().then(function (_) { | ||
AdalClient._authContext._loginInProgress = false; | ||
AdalClient._authContext.login(); | ||
_this._displayCallback = null; | ||
}); | ||
}); | ||
return this._loginPromise; | ||
}; | ||
/** | ||
* Parses out the root of the request url to use as the resource when getting the token | ||
* | ||
* After: https://gist.github.com/jlong/2428561 | ||
* @param url The url to parse | ||
*/ | ||
AdalClient.prototype.getResource = function (url) { | ||
var parser = document.createElement("a"); | ||
parser.href = url; | ||
return parser.protocol + "//" + parser.hostname; | ||
}; | ||
/** | ||
* Our auth context | ||
*/ | ||
AdalClient._authContext = null; | ||
return AdalClient; | ||
}(BearerTokenFetchClient)); | ||
/** | ||
* Reads a blob as text | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsText(blob) { | ||
return readBlobAs(blob, "string"); | ||
} | ||
/** | ||
* Reads a blob into an array buffer | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsArrayBuffer(blob) { | ||
return readBlobAs(blob, "buffer"); | ||
} | ||
/** | ||
* Generic method to read blob's content | ||
* | ||
* @param blob The data to read | ||
* @param mode The read mode | ||
*/ | ||
function readBlobAs(blob, mode) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
var reader = new FileReader(); | ||
reader.onload = function (e) { | ||
resolve(e.target.result); | ||
}; | ||
switch (mode) { | ||
case "string": | ||
reader.readAsText(blob); | ||
break; | ||
case "buffer": | ||
reader.readAsArrayBuffer(blob); | ||
break; | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
} | ||
/** | ||
* Generic dictionary | ||
*/ | ||
var Dictionary = /** @class */ (function () { | ||
/** | ||
* Creates a new instance of the Dictionary<T> class | ||
* | ||
* @constructor | ||
*/ | ||
function Dictionary(keys, values) { | ||
if (keys === void 0) { keys = []; } | ||
if (values === void 0) { values = []; } | ||
this.keys = keys; | ||
this.values = values; | ||
} | ||
/** | ||
* Gets a value from the collection using the specified key | ||
* | ||
* @param key The key whose value we want to return, returns null if the key does not exist | ||
*/ | ||
Dictionary.prototype.get = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
return this.values[index]; | ||
}; | ||
/** | ||
* Adds the supplied key and value to the dictionary | ||
* | ||
* @param key The key to add | ||
* @param o The value to add | ||
*/ | ||
Dictionary.prototype.add = function (key, o) { | ||
var index = this.keys.indexOf(key); | ||
if (index > -1) { | ||
if (o === null) { | ||
this.remove(key); | ||
} | ||
else { | ||
this.values[index] = o; | ||
} | ||
} | ||
else { | ||
if (o !== null) { | ||
this.keys.push(key); | ||
this.values.push(o); | ||
} | ||
} | ||
}; | ||
/** | ||
* Merges the supplied typed hash into this dictionary instance. Existing values are updated and new ones are created as appropriate. | ||
*/ | ||
Dictionary.prototype.merge = function (source) { | ||
var _this = this; | ||
if ("getKeys" in source) { | ||
var sourceAsDictionary_1 = source; | ||
sourceAsDictionary_1.getKeys().map(function (key) { | ||
_this.add(key, sourceAsDictionary_1.get(key)); | ||
}); | ||
} | ||
else { | ||
var sourceAsHash = source; | ||
for (var key in sourceAsHash) { | ||
if (sourceAsHash.hasOwnProperty(key)) { | ||
this.add(key, sourceAsHash[key]); | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Removes a value from the dictionary | ||
* | ||
* @param key The key of the key/value pair to remove. Returns null if the key was not found. | ||
*/ | ||
Dictionary.prototype.remove = function (key) { | ||
var index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
var val = this.values[index]; | ||
this.keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
return val; | ||
}; | ||
/** | ||
* Returns all the keys currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getKeys = function () { | ||
return this.keys; | ||
}; | ||
/** | ||
* Returns all the values currently in the dictionary as an array | ||
*/ | ||
Dictionary.prototype.getValues = function () { | ||
return this.values; | ||
}; | ||
/** | ||
* Clears the current dictionary | ||
*/ | ||
Dictionary.prototype.clear = function () { | ||
this.keys = []; | ||
this.values = []; | ||
}; | ||
Object.defineProperty(Dictionary.prototype, "count", { | ||
/** | ||
* Gets a count of the items currently in the dictionary | ||
*/ | ||
get: function () { | ||
return this.keys.length; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Dictionary; | ||
}()); | ||
function deprecated(deprecationVersion, message) { | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
logging.Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: "(" + deprecationVersion + ") " + message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
function beta(message) { | ||
if (message === void 0) { message = "This feature is flagged as beta and is subject to change."; } | ||
return function (target, propertyKey, descriptor) { | ||
var method = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
logging.Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
var UrlException = /** @class */ (function (_super) { | ||
tslib_1.__extends(UrlException, _super); | ||
function UrlException(msg) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.name = "UrlException"; | ||
logging.Logger.log({ data: {}, level: 3 /* Error */, message: "[" + _this.name + "]::" + _this.message }); | ||
return _this; | ||
} | ||
return UrlException; | ||
}(Error)); | ||
function setup(config) { | ||
RuntimeConfig.extend(config); | ||
} | ||
var RuntimeConfigImpl = /** @class */ (function () { | ||
function RuntimeConfigImpl() { | ||
this._v = new Dictionary(); | ||
// setup defaults | ||
this._v.add("defaultCachingStore", "session"); | ||
this._v.add("defaultCachingTimeoutSeconds", 60); | ||
this._v.add("globalCacheDisable", false); | ||
this._v.add("enableCacheExpiration", false); | ||
this._v.add("cacheExpirationIntervalMilliseconds", 750); | ||
this._v.add("spfxContext", null); | ||
} | ||
/** | ||
* | ||
* @param config The set of properties to add to the globa configuration instance | ||
*/ | ||
RuntimeConfigImpl.prototype.extend = function (config) { | ||
var _this = this; | ||
Object.keys(config).forEach(function (key) { | ||
_this._v.add(key, config[key]); | ||
}); | ||
}; | ||
RuntimeConfigImpl.prototype.get = function (key) { | ||
return this._v.get(key); | ||
}; | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingStore", { | ||
get: function () { | ||
return this.get("defaultCachingStore"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "defaultCachingTimeoutSeconds", { | ||
get: function () { | ||
return this.get("defaultCachingTimeoutSeconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "globalCacheDisable", { | ||
get: function () { | ||
return this.get("globalCacheDisable"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "enableCacheExpiration", { | ||
get: function () { | ||
return this.get("enableCacheExpiration"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "cacheExpirationIntervalMilliseconds", { | ||
get: function () { | ||
return this.get("cacheExpirationIntervalMilliseconds"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RuntimeConfigImpl.prototype, "spfxContext", { | ||
get: function () { | ||
return this.get("spfxContext"); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return RuntimeConfigImpl; | ||
}()); | ||
var _runtimeConfig = new RuntimeConfigImpl(); | ||
var RuntimeConfig = _runtimeConfig; | ||
/** | ||
* A wrapper class to provide a consistent interface to browser based storage | ||
@@ -846,2 +1010,3 @@ * | ||
exports.AdalClient = AdalClient; | ||
exports.readBlobAsText = readBlobAsText; | ||
@@ -848,0 +1013,0 @@ exports.readBlobAsArrayBuffer = readBlobAsArrayBuffer; |
/** | ||
@license | ||
* @pnp/common v1.0.3 - pnp - provides shared functionality across all pnp libraries | ||
* @pnp/common v1.0.4-0 - pnp - provides shared functionality across all pnp libraries | ||
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE) | ||
* Copyright (c) 2018 Microsoft | ||
* docs: http://officedev.github.io/PnP-JS-Core | ||
* docs: https://pnp.github.io/pnp/ | ||
* source: https://github.com/pnp/pnp | ||
* bugs: https://github.com/pnp/pnp/issues | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@pnp/logging"),require("tslib")):"function"==typeof define&&define.amd?define(["exports","@pnp/logging","tslib"],t):t((e.pnp=e.pnp||{},e.pnp.common={}),e.pnp.logging,e.tslib_1)}(this,function(e,t,n){"use strict";function r(e,t){return new Promise(function(n,r){try{var o=new FileReader;switch(o.onload=function(e){n(e.target.result)},t){case"string":o.readAsText(e);break;case"buffer":o.readAsArrayBuffer(e)}}catch(e){r(e)}})}var o=function(){function e(e,t){void 0===e&&(e=[]),void 0===t&&(t=[]),this.keys=e,this.values=t}return e.prototype.get=function(e){var t=this.keys.indexOf(e);return t<0?null:this.values[t]},e.prototype.add=function(e,t){var n=this.keys.indexOf(e);n>-1?null===t?this.remove(e):this.values[n]=t:null!==t&&(this.keys.push(e),this.values.push(t))},e.prototype.merge=function(e){var t=this;if("getKeys"in e){var n=e;n.getKeys().map(function(e){t.add(e,n.get(e))})}else{var r=e;for(var o in r)r.hasOwnProperty(o)&&this.add(o,r[o])}},e.prototype.remove=function(e){var t=this.keys.indexOf(e);if(t<0)return null;var n=this.values[t];return this.keys.splice(t,1),this.values.splice(t,1),n},e.prototype.getKeys=function(){return this.keys},e.prototype.getValues=function(){return this.values},e.prototype.clear=function(){this.keys=[],this.values=[]},Object.defineProperty(e.prototype,"count",{get:function(){return this.keys.length},enumerable:!0,configurable:!0}),e}();var i=function(e){function r(n){var r=e.call(this,n)||this;return r.name="UrlException",t.Logger.log({data:{},level:3,message:"["+r.name+"]::"+r.message}),r}return n.__extends(r,e),r}(Error);var a=function(){function e(){this._v=new o,this._v.add("defaultCachingStore","session"),this._v.add("defaultCachingTimeoutSeconds",60),this._v.add("globalCacheDisable",!1),this._v.add("enableCacheExpiration",!1),this._v.add("cacheExpirationIntervalMilliseconds",750),this._v.add("spfxContext",null)}return e.prototype.extend=function(e){var t=this;Object.keys(e).forEach(function(n){t._v.add(n,e[n])})},e.prototype.get=function(e){return this._v.get(e)},Object.defineProperty(e.prototype,"defaultCachingStore",{get:function(){return this.get("defaultCachingStore")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultCachingTimeoutSeconds",{get:function(){return this.get("defaultCachingTimeoutSeconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalCacheDisable",{get:function(){return this.get("globalCacheDisable")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableCacheExpiration",{get:function(){return this.get("enableCacheExpiration")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cacheExpirationIntervalMilliseconds",{get:function(){return this.get("cacheExpirationIntervalMilliseconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spfxContext",{get:function(){return this.get("spfxContext")},enumerable:!0,configurable:!0}),e}(),s=new a;function u(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return function(){t.apply(e,n)}}function c(e,t,n){var r=new Date(e);switch(t.toLowerCase()){case"year":r.setFullYear(r.getFullYear()+n);break;case"quarter":r.setMonth(r.getMonth()+3*n);break;case"month":r.setMonth(r.getMonth()+n);break;case"week":r.setDate(r.getDate()+7*n);break;case"day":r.setDate(r.getDate()+n);break;case"hour":r.setTime(r.getTime()+36e5*n);break;case"minute":r.setTime(r.getTime()+6e4*n);break;case"second":r.setTime(r.getTime()+1e3*n);break;default:r=void 0}return r}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter(function(e){return!m.stringIsNullOrEmpty(e)}).map(function(e){return e.replace(/^[\\|\/]/,"").replace(/[\\|\/]$/,"")}).join("/").replace(/\\/g,"/")}function f(e){for(var t=new Array(e),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=0;r<e;r++)t[r]=n.charAt(Math.floor(Math.random()*n.length));return t.join("")}function p(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)})}function h(e){return"function"==typeof e}function d(e){return void 0!==e&&null!==e}function g(e){return Array.isArray?Array.isArray(e):e&&"number"==typeof e.length&&e.constructor===Array}function y(e,t,n){if(void 0===n&&(n=!1),!m.objectDefinedNotNull(t))return e;var r=n?function(e,t){return!(t in e)}:function(){return!0};return Object.getOwnPropertyNames(t).filter(function(t){return r(e,t)}).reduce(function(e,n){return e[n]=t[n],e},e)}function v(e){return/^https?:\/\/|^\/\//i.test(e)}function b(e){return void 0===e||null===e||e.length<1}var m=function(){function e(){}return e.getCtxCallback=u,e.dateAdd=c,e.combinePaths=l,e.getRandomString=f,e.getGUID=p,e.isFunc=h,e.objectDefinedNotNull=d,e.isArray=g,e.extend=y,e.isUrlAbsolute=v,e.stringIsNullOrEmpty=b,e}();function x(e,t){void 0!==t&&null!==t&&new Request("",{headers:t}).headers.forEach(function(t,n){e.append(n,t)})}var _=function(){function e(){}return e.prototype.fetch=function(e,t){return global.fetch(e,t)},e}(),w=function(e){function t(t){var n=e.call(this)||this;return n._token=t,n}return n.__extends(t,e),t.prototype.fetch=function(t,n){void 0===n&&(n={});var r=new Headers;return x(r,n.headers),r.set("Authorization","Bearer "+this._token),n.headers=r,e.prototype.fetch.call(this,t,n)},t}(_),C=function(){function e(e,n){void 0===n&&(n=-1),this.store=e,this.defaultTimeoutMinutes=n,this.enabled=this.test(),s.enableCacheExpiration&&(t.Logger.write("Enabling cache expiration.",1),this.cacheExpirationHandler())}return e.prototype.get=function(e){if(!this.enabled)return null;var n=this.store.getItem(e);if(null==n)return null;var r=JSON.parse(n);return new Date(r.expiration)<=new Date?(t.Logger.write("Removing item with key '"+e+"' from cache due to expiration.",1),this.delete(e),null):r.value},e.prototype.put=function(e,t,n){this.enabled&&this.store.setItem(e,this.createPersistable(t,n))},e.prototype.delete=function(e){this.enabled&&this.store.removeItem(e)},e.prototype.getOrPut=function(e,t,n){var r=this;return this.enabled?new Promise(function(o){var i=r.get(e);null==i?t().then(function(t){r.put(e,t,n),o(t)}):o(i)}):t()},e.prototype.deleteExpired=function(){var e=this;return new Promise(function(t,n){e.enabled||t();try{for(var r=0;r<e.store.length;r++){var o=e.store.key(r);null!==o&&/["|']?pnp["|']? ?: ?1/i.test(e.store.getItem(o))&&e.get(o)}t()}catch(e){n(e)}})},e.prototype.test=function(){try{return this.store.setItem("test","test"),this.store.removeItem("test"),!0}catch(e){return!1}},e.prototype.createPersistable=function(e,t){if(void 0===t){var n=s.defaultCachingTimeoutSeconds;this.defaultTimeoutMinutes>0&&(n=60*this.defaultTimeoutMinutes),t=m.dateAdd(new Date,"second",n)}return JSON.stringify({pnp:1,expiration:t,value:e})},e.prototype.cacheExpirationHandler=function(){var e=this;t.Logger.write("Called cache expiration handler.",0),this.deleteExpired().then(function(t){setTimeout(m.getCtxCallback(e,e.cacheExpirationHandler),s.cacheExpirationIntervalMilliseconds)}).catch(function(e){t.Logger.log({data:e,level:3,message:"Error deleting expired cache entries, see data for details. Timeout not reset."})})},e}(),k=function(){function e(e){void 0===e&&(e=new o),this._store=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this._store.count},enumerable:!0,configurable:!0}),e.prototype.clear=function(){this._store.clear()},e.prototype.getItem=function(e){return this._store.get(e)},e.prototype.key=function(e){return this._store.getKeys()[e]},e.prototype.removeItem=function(e){this._store.remove(e)},e.prototype.setItem=function(e,t){this._store.add(e,t)},e}(),O=function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this._local=e,this._session=t}return Object.defineProperty(e.prototype,"local",{get:function(){return null===this._local&&(this._local="undefined"!=typeof localStorage?new C(localStorage):new C(new k)),this._local},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"session",{get:function(){return null===this._session&&(this._session="undefined"!=typeof sessionStorage?new C(sessionStorage):new C(new k)),this._session},enumerable:!0,configurable:!0}),e}();e.readBlobAsText=function(e){return r(e,"string")},e.readBlobAsArrayBuffer=function(e){return r(e,"buffer")},e.Dictionary=o,e.deprecated=function(e,n){return function(r,o,i){var a=i.value;i.value=function(){for(var s=[],u=0;u<arguments.length;u++)s[u]=arguments[u];return t.Logger.log({data:{descriptor:i,propertyKey:o,target:r},level:2,message:"("+e+") "+n}),a.apply(this,s)}}},e.beta=function(e){return void 0===e&&(e="This feature is flagged as beta and is subject to change."),function(n,r,o){var i=o.value;o.value=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];return t.Logger.log({data:{descriptor:o,propertyKey:r,target:n},level:2,message:e}),i.apply(this,a)}}},e.UrlException=i,e.setup=function(e){s.extend(e)},e.RuntimeConfigImpl=a,e.RuntimeConfig=s,e.mergeHeaders=x,e.mergeOptions=function(e,t){if(m.objectDefinedNotNull(t)){var n=m.extend(e.headers||{},t.headers);(e=m.extend(e,t)).headers=n}},e.FetchClient=_,e.BearerTokenFetchClient=w,e.PnPClientStorageWrapper=C,e.PnPClientStorage=O,e.getCtxCallback=u,e.dateAdd=c,e.combinePaths=l,e.getRandomString=f,e.getGUID=p,e.isFunc=h,e.objectDefinedNotNull=d,e.isArray=g,e.extend=y,e.isUrlAbsolute=v,e.stringIsNullOrEmpty=b,e.Util=m,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("adal-angular"),require("@pnp/logging")):"function"==typeof define&&define.amd?define(["exports","tslib","adal-angular","@pnp/logging"],t):t((e.pnp=e.pnp||{},e.pnp.common={}),e.tslib_1,e.adal,e.pnp.logging)}(this,function(e,t,n,r){"use strict";function o(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return function(){t.apply(e,n)}}function i(e,t,n){var r=new Date(e);switch(t.toLowerCase()){case"year":r.setFullYear(r.getFullYear()+n);break;case"quarter":r.setMonth(r.getMonth()+3*n);break;case"month":r.setMonth(r.getMonth()+n);break;case"week":r.setDate(r.getDate()+7*n);break;case"day":r.setDate(r.getDate()+n);break;case"hour":r.setTime(r.getTime()+36e5*n);break;case"minute":r.setTime(r.getTime()+6e4*n);break;case"second":r.setTime(r.getTime()+1e3*n);break;default:r=void 0}return r}function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter(function(e){return!g.stringIsNullOrEmpty(e)}).map(function(e){return e.replace(/^[\\|\/]/,"").replace(/[\\|\/]$/,"")}).join("/").replace(/\\/g,"/")}function u(e){for(var t=new Array(e),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=0;r<e;r++)t[r]=n.charAt(Math.floor(Math.random()*n.length));return t.join("")}function s(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)})}function l(e){return"function"==typeof e}function c(e){return void 0!==e&&null!==e}function f(e){return Array.isArray?Array.isArray(e):e&&"number"==typeof e.length&&e.constructor===Array}function h(e,t,n){if(void 0===n&&(n=!1),!g.objectDefinedNotNull(t))return e;var r=n?function(e,t){return!(t in e)}:function(){return!0};return Object.getOwnPropertyNames(t).filter(function(t){return r(e,t)}).reduce(function(e,n){return e[n]=t[n],e},e)}function p(e){return/^https?:\/\/|^\/\//i.test(e)}function d(e){return void 0===e||null===e||e.length<1}var g=function(){function e(){}return e.getCtxCallback=o,e.dateAdd=i,e.combinePaths=a,e.getRandomString=u,e.getGUID=s,e.isFunc=l,e.objectDefinedNotNull=c,e.isArray=f,e.extend=h,e.isUrlAbsolute=p,e.stringIsNullOrEmpty=d,e}();function y(e,t){void 0!==t&&null!==t&&new Request("",{headers:t}).headers.forEach(function(t,n){e.append(n,t)})}var v=function(){function e(){}return e.prototype.fetch=function(e,t){return global.fetch(e,t)},e}(),b=function(e){function n(t){var n=e.call(this)||this;return n._token=t,n}return t.__extends(n,e),Object.defineProperty(n.prototype,"token",{get:function(){return this._token},set:function(e){this._token=e},enumerable:!0,configurable:!0}),n.prototype.fetch=function(t,n){void 0===n&&(n={});var r=new Headers;return y(r,n.headers),r.set("Authorization","Bearer "+this._token),n.headers=r,e.prototype.fetch.call(this,t,n)},n}(v),x=function(e){function r(t,n,r){var o=e.call(this,null)||this;return o.clientId=t,o.tenant=n,o.redirectUri=r,o}return t.__extends(r,e),r.fromSPFxContext=function(e,t){return void 0===t&&(t="c58637bb-e2e1-4312-8a00-04b5ffcd3403"),new r(t,e.pageContext.aadInfo.tenantId.toString(),a(window.location.origin,"/_forms/spfxsinglesignon.aspx"))},r.prototype.fetch=function(t,n){var r=this;if(!p(t))throw new Error("You must supply absolute urls to AdalClient.fetch.");return this.getToken(this.getResource(t)).then(function(o){return r.token=o,e.prototype.fetch.call(r,t,n)})},r.prototype.getToken=function(e){var t=this;return new Promise(function(n,o){t.ensureAuthContext().then(function(e){return t.login()}).then(function(t){r._authContext.acquireToken(e,function(e,t){if(e)return o(new Error(e));n(t)})}).catch(o)})},r.prototype.ensureAuthContext=function(){var e=this;return new Promise(function(t){null===r._authContext&&(r._authContext=n.inject({clientId:e.clientId,displayCall:function(t){e._displayCallback&&e._displayCallback(t)},navigateToLoginRequestUrl:!1,redirectUri:e.redirectUri,tenant:e.tenant})),t()})},r.prototype.login=function(){var e=this;return this._loginPromise?this._loginPromise:(this._loginPromise=new Promise(function(t,n){if(r._authContext.getCachedUser())return t();e._displayCallback=function(o){var i=window.open(o,"login","width=483, height=600");if(!i)return n(new Error("Could not open pop-up window for auth. Likely pop-ups are blocked by the browser."));i&&i.focus&&i.focus();var a=window.setInterval(function(){i&&!i.closed&&void 0!==i.closed||window.clearInterval(a);try{-1!==i.document.URL.indexOf(e.redirectUri)&&(window.clearInterval(a),r._authContext.handleWindowCallback(i.location.hash),i.close(),t())}catch(e){n(e)}},30)},e.ensureAuthContext().then(function(t){r._authContext._loginInProgress=!1,r._authContext.login(),e._displayCallback=null})}),this._loginPromise)},r.prototype.getResource=function(e){var t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname},r._authContext=null,r}(b);function m(e,t){return new Promise(function(n,r){try{var o=new FileReader;switch(o.onload=function(e){n(e.target.result)},t){case"string":o.readAsText(e);break;case"buffer":o.readAsArrayBuffer(e)}}catch(e){r(e)}})}var w=function(){function e(e,t){void 0===e&&(e=[]),void 0===t&&(t=[]),this.keys=e,this.values=t}return e.prototype.get=function(e){var t=this.keys.indexOf(e);return t<0?null:this.values[t]},e.prototype.add=function(e,t){var n=this.keys.indexOf(e);n>-1?null===t?this.remove(e):this.values[n]=t:null!==t&&(this.keys.push(e),this.values.push(t))},e.prototype.merge=function(e){var t=this;if("getKeys"in e){var n=e;n.getKeys().map(function(e){t.add(e,n.get(e))})}else{var r=e;for(var o in r)r.hasOwnProperty(o)&&this.add(o,r[o])}},e.prototype.remove=function(e){var t=this.keys.indexOf(e);if(t<0)return null;var n=this.values[t];return this.keys.splice(t,1),this.values.splice(t,1),n},e.prototype.getKeys=function(){return this.keys},e.prototype.getValues=function(){return this.values},e.prototype.clear=function(){this.keys=[],this.values=[]},Object.defineProperty(e.prototype,"count",{get:function(){return this.keys.length},enumerable:!0,configurable:!0}),e}();var C=function(e){function n(t){var n=e.call(this,t)||this;return n.name="UrlException",r.Logger.log({data:{},level:3,message:"["+n.name+"]::"+n.message}),n}return t.__extends(n,e),n}(Error);var _=function(){function e(){this._v=new w,this._v.add("defaultCachingStore","session"),this._v.add("defaultCachingTimeoutSeconds",60),this._v.add("globalCacheDisable",!1),this._v.add("enableCacheExpiration",!1),this._v.add("cacheExpirationIntervalMilliseconds",750),this._v.add("spfxContext",null)}return e.prototype.extend=function(e){var t=this;Object.keys(e).forEach(function(n){t._v.add(n,e[n])})},e.prototype.get=function(e){return this._v.get(e)},Object.defineProperty(e.prototype,"defaultCachingStore",{get:function(){return this.get("defaultCachingStore")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultCachingTimeoutSeconds",{get:function(){return this.get("defaultCachingTimeoutSeconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalCacheDisable",{get:function(){return this.get("globalCacheDisable")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableCacheExpiration",{get:function(){return this.get("enableCacheExpiration")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cacheExpirationIntervalMilliseconds",{get:function(){return this.get("cacheExpirationIntervalMilliseconds")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spfxContext",{get:function(){return this.get("spfxContext")},enumerable:!0,configurable:!0}),e}(),k=new _,P=function(){function e(e,t){void 0===t&&(t=-1),this.store=e,this.defaultTimeoutMinutes=t,this.enabled=this.test(),k.enableCacheExpiration&&(r.Logger.write("Enabling cache expiration.",1),this.cacheExpirationHandler())}return e.prototype.get=function(e){if(!this.enabled)return null;var t=this.store.getItem(e);if(null==t)return null;var n=JSON.parse(t);return new Date(n.expiration)<=new Date?(r.Logger.write("Removing item with key '"+e+"' from cache due to expiration.",1),this.delete(e),null):n.value},e.prototype.put=function(e,t,n){this.enabled&&this.store.setItem(e,this.createPersistable(t,n))},e.prototype.delete=function(e){this.enabled&&this.store.removeItem(e)},e.prototype.getOrPut=function(e,t,n){var r=this;return this.enabled?new Promise(function(o){var i=r.get(e);null==i?t().then(function(t){r.put(e,t,n),o(t)}):o(i)}):t()},e.prototype.deleteExpired=function(){var e=this;return new Promise(function(t,n){e.enabled||t();try{for(var r=0;r<e.store.length;r++){var o=e.store.key(r);null!==o&&/["|']?pnp["|']? ?: ?1/i.test(e.store.getItem(o))&&e.get(o)}t()}catch(e){n(e)}})},e.prototype.test=function(){try{return this.store.setItem("test","test"),this.store.removeItem("test"),!0}catch(e){return!1}},e.prototype.createPersistable=function(e,t){if(void 0===t){var n=k.defaultCachingTimeoutSeconds;this.defaultTimeoutMinutes>0&&(n=60*this.defaultTimeoutMinutes),t=g.dateAdd(new Date,"second",n)}return JSON.stringify({pnp:1,expiration:t,value:e})},e.prototype.cacheExpirationHandler=function(){var e=this;r.Logger.write("Called cache expiration handler.",0),this.deleteExpired().then(function(t){setTimeout(g.getCtxCallback(e,e.cacheExpirationHandler),k.cacheExpirationIntervalMilliseconds)}).catch(function(e){r.Logger.log({data:e,level:3,message:"Error deleting expired cache entries, see data for details. Timeout not reset."})})},e}(),I=function(){function e(e){void 0===e&&(e=new w),this._store=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this._store.count},enumerable:!0,configurable:!0}),e.prototype.clear=function(){this._store.clear()},e.prototype.getItem=function(e){return this._store.get(e)},e.prototype.key=function(e){return this._store.getKeys()[e]},e.prototype.removeItem=function(e){this._store.remove(e)},e.prototype.setItem=function(e,t){this._store.add(e,t)},e}(),E=function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this._local=e,this._session=t}return Object.defineProperty(e.prototype,"local",{get:function(){return null===this._local&&(this._local="undefined"!=typeof localStorage?new P(localStorage):new P(new I)),this._local},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"session",{get:function(){return null===this._session&&(this._session="undefined"!=typeof sessionStorage?new P(sessionStorage):new P(new I)),this._session},enumerable:!0,configurable:!0}),e}();e.AdalClient=x,e.readBlobAsText=function(e){return m(e,"string")},e.readBlobAsArrayBuffer=function(e){return m(e,"buffer")},e.Dictionary=w,e.deprecated=function(e,t){return function(n,o,i){var a=i.value;i.value=function(){for(var u=[],s=0;s<arguments.length;s++)u[s]=arguments[s];return r.Logger.log({data:{descriptor:i,propertyKey:o,target:n},level:2,message:"("+e+") "+t}),a.apply(this,u)}}},e.beta=function(e){return void 0===e&&(e="This feature is flagged as beta and is subject to change."),function(t,n,o){var i=o.value;o.value=function(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];return r.Logger.log({data:{descriptor:o,propertyKey:n,target:t},level:2,message:e}),i.apply(this,a)}}},e.UrlException=C,e.setup=function(e){k.extend(e)},e.RuntimeConfigImpl=_,e.RuntimeConfig=k,e.mergeHeaders=y,e.mergeOptions=function(e,t){if(g.objectDefinedNotNull(t)){var n=g.extend(e.headers||{},t.headers);(e=g.extend(e,t)).headers=n}},e.FetchClient=v,e.BearerTokenFetchClient=b,e.PnPClientStorageWrapper=P,e.PnPClientStorage=E,e.getCtxCallback=o,e.dateAdd=i,e.combinePaths=a,e.getRandomString=u,e.getGUID=s,e.isFunc=l,e.objectDefinedNotNull=c,e.isArray=f,e.extend=h,e.isUrlAbsolute=p,e.stringIsNullOrEmpty=d,e.Util=g,Object.defineProperty(e,"__esModule",{value:!0})}); |
/** | ||
@license | ||
* @pnp/common v1.0.3 - pnp - provides shared functionality across all pnp libraries | ||
* @pnp/common v1.0.4-0 - pnp - provides shared functionality across all pnp libraries | ||
* MIT (https://github.com/pnp/pnp/blob/master/LICENSE) | ||
* Copyright (c) 2018 Microsoft | ||
* docs: http://officedev.github.io/PnP-JS-Core | ||
* docs: https://pnp.github.io/pnp/ | ||
* source: https://github.com/pnp/pnp | ||
* bugs: https://github.com/pnp/pnp/issues | ||
*/ | ||
import { inject } from 'adal-angular'; | ||
import { Logger } from '@pnp/logging'; | ||
/** | ||
* Reads a blob as text | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsText(blob) { | ||
return readBlobAs(blob, "string"); | ||
} | ||
/** | ||
* Reads a blob into an array buffer | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsArrayBuffer(blob) { | ||
return readBlobAs(blob, "buffer"); | ||
} | ||
/** | ||
* Generic method to read blob's content | ||
* | ||
* @param blob The data to read | ||
* @param mode The read mode | ||
*/ | ||
function readBlobAs(blob, mode) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
const reader = new FileReader(); | ||
reader.onload = (e) => { | ||
resolve(e.target.result); | ||
}; | ||
switch (mode) { | ||
case "string": | ||
reader.readAsText(blob); | ||
break; | ||
case "buffer": | ||
reader.readAsArrayBuffer(blob); | ||
break; | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
} | ||
/** | ||
* Generic dictionary | ||
*/ | ||
class Dictionary { | ||
/** | ||
* Creates a new instance of the Dictionary<T> class | ||
* | ||
* @constructor | ||
*/ | ||
constructor(keys = [], values = []) { | ||
this.keys = keys; | ||
this.values = values; | ||
} | ||
/** | ||
* Gets a value from the collection using the specified key | ||
* | ||
* @param key The key whose value we want to return, returns null if the key does not exist | ||
*/ | ||
get(key) { | ||
const index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
return this.values[index]; | ||
} | ||
/** | ||
* Adds the supplied key and value to the dictionary | ||
* | ||
* @param key The key to add | ||
* @param o The value to add | ||
*/ | ||
add(key, o) { | ||
const index = this.keys.indexOf(key); | ||
if (index > -1) { | ||
if (o === null) { | ||
this.remove(key); | ||
} | ||
else { | ||
this.values[index] = o; | ||
} | ||
} | ||
else { | ||
if (o !== null) { | ||
this.keys.push(key); | ||
this.values.push(o); | ||
} | ||
} | ||
} | ||
/** | ||
* Merges the supplied typed hash into this dictionary instance. Existing values are updated and new ones are created as appropriate. | ||
*/ | ||
merge(source) { | ||
if ("getKeys" in source) { | ||
const sourceAsDictionary = source; | ||
sourceAsDictionary.getKeys().map(key => { | ||
this.add(key, sourceAsDictionary.get(key)); | ||
}); | ||
} | ||
else { | ||
const sourceAsHash = source; | ||
for (const key in sourceAsHash) { | ||
if (sourceAsHash.hasOwnProperty(key)) { | ||
this.add(key, sourceAsHash[key]); | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Removes a value from the dictionary | ||
* | ||
* @param key The key of the key/value pair to remove. Returns null if the key was not found. | ||
*/ | ||
remove(key) { | ||
const index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
const val = this.values[index]; | ||
this.keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
return val; | ||
} | ||
/** | ||
* Returns all the keys currently in the dictionary as an array | ||
*/ | ||
getKeys() { | ||
return this.keys; | ||
} | ||
/** | ||
* Returns all the values currently in the dictionary as an array | ||
*/ | ||
getValues() { | ||
return this.values; | ||
} | ||
/** | ||
* Clears the current dictionary | ||
*/ | ||
clear() { | ||
this.keys = []; | ||
this.values = []; | ||
} | ||
/** | ||
* Gets a count of the items currently in the dictionary | ||
*/ | ||
get count() { | ||
return this.keys.length; | ||
} | ||
} | ||
function deprecated(deprecationVersion, message) { | ||
return function (target, propertyKey, descriptor) { | ||
const method = descriptor.value; | ||
descriptor.value = function (...args) { | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: `(${deprecationVersion}) ${message}`, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
function beta(message = "This feature is flagged as beta and is subject to change.") { | ||
return function (target, propertyKey, descriptor) { | ||
const method = descriptor.value; | ||
descriptor.value = function (...args) { | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
class UrlException extends Error { | ||
constructor(msg) { | ||
super(msg); | ||
this.name = "UrlException"; | ||
Logger.log({ data: {}, level: 3 /* Error */, message: `[${this.name}]::${this.message}` }); | ||
} | ||
} | ||
function setup(config) { | ||
RuntimeConfig.extend(config); | ||
} | ||
class RuntimeConfigImpl { | ||
constructor() { | ||
this._v = new Dictionary(); | ||
// setup defaults | ||
this._v.add("defaultCachingStore", "session"); | ||
this._v.add("defaultCachingTimeoutSeconds", 60); | ||
this._v.add("globalCacheDisable", false); | ||
this._v.add("enableCacheExpiration", false); | ||
this._v.add("cacheExpirationIntervalMilliseconds", 750); | ||
this._v.add("spfxContext", null); | ||
} | ||
/** | ||
* | ||
* @param config The set of properties to add to the globa configuration instance | ||
*/ | ||
extend(config) { | ||
Object.keys(config).forEach((key) => { | ||
this._v.add(key, config[key]); | ||
}); | ||
} | ||
get(key) { | ||
return this._v.get(key); | ||
} | ||
get defaultCachingStore() { | ||
return this.get("defaultCachingStore"); | ||
} | ||
get defaultCachingTimeoutSeconds() { | ||
return this.get("defaultCachingTimeoutSeconds"); | ||
} | ||
get globalCacheDisable() { | ||
return this.get("globalCacheDisable"); | ||
} | ||
get enableCacheExpiration() { | ||
return this.get("enableCacheExpiration"); | ||
} | ||
get cacheExpirationIntervalMilliseconds() { | ||
return this.get("cacheExpirationIntervalMilliseconds"); | ||
} | ||
get spfxContext() { | ||
return this.get("spfxContext"); | ||
} | ||
} | ||
const _runtimeConfig = new RuntimeConfigImpl(); | ||
let RuntimeConfig = _runtimeConfig; | ||
/** | ||
* Gets a callback function which will maintain context across async calls. | ||
@@ -522,2 +279,8 @@ * Allows for the calling pattern getCtxCallback(thisobj, method, methodarg1, methodarg2, ...) | ||
} | ||
get token() { | ||
return this._token; | ||
} | ||
set token(token) { | ||
this._token = token; | ||
} | ||
fetch(url, options = {}) { | ||
@@ -533,2 +296,392 @@ const headers = new Headers(); | ||
/** | ||
* Azure AD Client for use in the browser | ||
*/ | ||
class AdalClient extends BearerTokenFetchClient { | ||
/** | ||
* Creates a new instance of AdalClient | ||
* @param clientId Azure App Id | ||
* @param tenant Office 365 tenant (Ex: {tenant}.onmicrosoft.com) | ||
* @param redirectUri The redirect url used to authenticate the | ||
*/ | ||
constructor(clientId, tenant, redirectUri) { | ||
super(null); | ||
this.clientId = clientId; | ||
this.tenant = tenant; | ||
this.redirectUri = redirectUri; | ||
} | ||
/** | ||
* Creates a new AdalClient using the values of the supplied SPFx context | ||
* | ||
* @param spfxContext Current SPFx context | ||
* @param clientId Optional client id to use instead of the built-in SPFx id | ||
* @description Using this method and the default clientId requires that the features described in | ||
* this article https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient are activated in the tenant. If not you can | ||
* creat your own app, grant permissions and use that clientId here along with the SPFx context | ||
*/ | ||
static fromSPFxContext(spfxContext, cliendId = "c58637bb-e2e1-4312-8a00-04b5ffcd3403") { | ||
// this "magic" client id is the one to which permissions are granted behind the scenes | ||
// this redirectUrl is the page as used by spfx | ||
return new AdalClient(cliendId, spfxContext.pageContext.aadInfo.tenantId.toString(), combinePaths(window.location.origin, "/_forms/spfxsinglesignon.aspx")); | ||
} | ||
/** | ||
* Conducts the fetch opertation against the AAD secured resource | ||
* | ||
* @param url Absolute URL for the request | ||
* @param options Any fetch options passed to the underlying fetch implementation | ||
*/ | ||
fetch(url, options) { | ||
if (!isUrlAbsolute(url)) { | ||
throw new Error("You must supply absolute urls to AdalClient.fetch."); | ||
} | ||
// the url we are calling is the resource | ||
return this.getToken(this.getResource(url)).then(token => { | ||
this.token = token; | ||
return super.fetch(url, options); | ||
}); | ||
} | ||
/** | ||
* Gets a token based on the current user | ||
* | ||
* @param resource The resource for which we are requesting a token | ||
*/ | ||
getToken(resource) { | ||
return new Promise((resolve, reject) => { | ||
this.ensureAuthContext().then(_ => this.login()).then(_ => { | ||
AdalClient._authContext.acquireToken(resource, (message, token) => { | ||
if (message) { | ||
return reject(new Error(message)); | ||
} | ||
resolve(token); | ||
}); | ||
}).catch(reject); | ||
}); | ||
} | ||
/** | ||
* Ensures we have created and setup the adal AuthenticationContext instance | ||
*/ | ||
ensureAuthContext() { | ||
return new Promise(resolve => { | ||
if (AdalClient._authContext === null) { | ||
AdalClient._authContext = inject({ | ||
clientId: this.clientId, | ||
displayCall: (url) => { | ||
if (this._displayCallback) { | ||
this._displayCallback(url); | ||
} | ||
}, | ||
navigateToLoginRequestUrl: false, | ||
redirectUri: this.redirectUri, | ||
tenant: this.tenant, | ||
}); | ||
} | ||
resolve(); | ||
}); | ||
} | ||
/** | ||
* Ensures the current user is logged in | ||
*/ | ||
login() { | ||
if (this._loginPromise) { | ||
return this._loginPromise; | ||
} | ||
this._loginPromise = new Promise((resolve, reject) => { | ||
if (AdalClient._authContext.getCachedUser()) { | ||
return resolve(); | ||
} | ||
this._displayCallback = (url) => { | ||
const popupWindow = window.open(url, "login", "width=483, height=600"); | ||
if (!popupWindow) { | ||
return reject(new Error("Could not open pop-up window for auth. Likely pop-ups are blocked by the browser.")); | ||
} | ||
if (popupWindow && popupWindow.focus) { | ||
popupWindow.focus(); | ||
} | ||
const pollTimer = window.setInterval(() => { | ||
if (!popupWindow || popupWindow.closed || popupWindow.closed === undefined) { | ||
window.clearInterval(pollTimer); | ||
} | ||
try { | ||
if (popupWindow.document.URL.indexOf(this.redirectUri) !== -1) { | ||
window.clearInterval(pollTimer); | ||
AdalClient._authContext.handleWindowCallback(popupWindow.location.hash); | ||
popupWindow.close(); | ||
resolve(); | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}, 30); | ||
}; | ||
// this triggers the login process | ||
this.ensureAuthContext().then(_ => { | ||
AdalClient._authContext._loginInProgress = false; | ||
AdalClient._authContext.login(); | ||
this._displayCallback = null; | ||
}); | ||
}); | ||
return this._loginPromise; | ||
} | ||
/** | ||
* Parses out the root of the request url to use as the resource when getting the token | ||
* | ||
* After: https://gist.github.com/jlong/2428561 | ||
* @param url The url to parse | ||
*/ | ||
getResource(url) { | ||
const parser = document.createElement("a"); | ||
parser.href = url; | ||
return `${parser.protocol}//${parser.hostname}`; | ||
} | ||
} | ||
/** | ||
* Our auth context | ||
*/ | ||
AdalClient._authContext = null; | ||
/** | ||
* Reads a blob as text | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsText(blob) { | ||
return readBlobAs(blob, "string"); | ||
} | ||
/** | ||
* Reads a blob into an array buffer | ||
* | ||
* @param blob The data to read | ||
*/ | ||
function readBlobAsArrayBuffer(blob) { | ||
return readBlobAs(blob, "buffer"); | ||
} | ||
/** | ||
* Generic method to read blob's content | ||
* | ||
* @param blob The data to read | ||
* @param mode The read mode | ||
*/ | ||
function readBlobAs(blob, mode) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
const reader = new FileReader(); | ||
reader.onload = (e) => { | ||
resolve(e.target.result); | ||
}; | ||
switch (mode) { | ||
case "string": | ||
reader.readAsText(blob); | ||
break; | ||
case "buffer": | ||
reader.readAsArrayBuffer(blob); | ||
break; | ||
} | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
} | ||
/** | ||
* Generic dictionary | ||
*/ | ||
class Dictionary { | ||
/** | ||
* Creates a new instance of the Dictionary<T> class | ||
* | ||
* @constructor | ||
*/ | ||
constructor(keys = [], values = []) { | ||
this.keys = keys; | ||
this.values = values; | ||
} | ||
/** | ||
* Gets a value from the collection using the specified key | ||
* | ||
* @param key The key whose value we want to return, returns null if the key does not exist | ||
*/ | ||
get(key) { | ||
const index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
return this.values[index]; | ||
} | ||
/** | ||
* Adds the supplied key and value to the dictionary | ||
* | ||
* @param key The key to add | ||
* @param o The value to add | ||
*/ | ||
add(key, o) { | ||
const index = this.keys.indexOf(key); | ||
if (index > -1) { | ||
if (o === null) { | ||
this.remove(key); | ||
} | ||
else { | ||
this.values[index] = o; | ||
} | ||
} | ||
else { | ||
if (o !== null) { | ||
this.keys.push(key); | ||
this.values.push(o); | ||
} | ||
} | ||
} | ||
/** | ||
* Merges the supplied typed hash into this dictionary instance. Existing values are updated and new ones are created as appropriate. | ||
*/ | ||
merge(source) { | ||
if ("getKeys" in source) { | ||
const sourceAsDictionary = source; | ||
sourceAsDictionary.getKeys().map(key => { | ||
this.add(key, sourceAsDictionary.get(key)); | ||
}); | ||
} | ||
else { | ||
const sourceAsHash = source; | ||
for (const key in sourceAsHash) { | ||
if (sourceAsHash.hasOwnProperty(key)) { | ||
this.add(key, sourceAsHash[key]); | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Removes a value from the dictionary | ||
* | ||
* @param key The key of the key/value pair to remove. Returns null if the key was not found. | ||
*/ | ||
remove(key) { | ||
const index = this.keys.indexOf(key); | ||
if (index < 0) { | ||
return null; | ||
} | ||
const val = this.values[index]; | ||
this.keys.splice(index, 1); | ||
this.values.splice(index, 1); | ||
return val; | ||
} | ||
/** | ||
* Returns all the keys currently in the dictionary as an array | ||
*/ | ||
getKeys() { | ||
return this.keys; | ||
} | ||
/** | ||
* Returns all the values currently in the dictionary as an array | ||
*/ | ||
getValues() { | ||
return this.values; | ||
} | ||
/** | ||
* Clears the current dictionary | ||
*/ | ||
clear() { | ||
this.keys = []; | ||
this.values = []; | ||
} | ||
/** | ||
* Gets a count of the items currently in the dictionary | ||
*/ | ||
get count() { | ||
return this.keys.length; | ||
} | ||
} | ||
function deprecated(deprecationVersion, message) { | ||
return function (target, propertyKey, descriptor) { | ||
const method = descriptor.value; | ||
descriptor.value = function (...args) { | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: `(${deprecationVersion}) ${message}`, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
function beta(message = "This feature is flagged as beta and is subject to change.") { | ||
return function (target, propertyKey, descriptor) { | ||
const method = descriptor.value; | ||
descriptor.value = function (...args) { | ||
Logger.log({ | ||
data: { | ||
descriptor: descriptor, | ||
propertyKey: propertyKey, | ||
target: target, | ||
}, | ||
level: 2 /* Warning */, | ||
message: message, | ||
}); | ||
return method.apply(this, args); | ||
}; | ||
}; | ||
} | ||
class UrlException extends Error { | ||
constructor(msg) { | ||
super(msg); | ||
this.name = "UrlException"; | ||
Logger.log({ data: {}, level: 3 /* Error */, message: `[${this.name}]::${this.message}` }); | ||
} | ||
} | ||
function setup(config) { | ||
RuntimeConfig.extend(config); | ||
} | ||
class RuntimeConfigImpl { | ||
constructor() { | ||
this._v = new Dictionary(); | ||
// setup defaults | ||
this._v.add("defaultCachingStore", "session"); | ||
this._v.add("defaultCachingTimeoutSeconds", 60); | ||
this._v.add("globalCacheDisable", false); | ||
this._v.add("enableCacheExpiration", false); | ||
this._v.add("cacheExpirationIntervalMilliseconds", 750); | ||
this._v.add("spfxContext", null); | ||
} | ||
/** | ||
* | ||
* @param config The set of properties to add to the globa configuration instance | ||
*/ | ||
extend(config) { | ||
Object.keys(config).forEach((key) => { | ||
this._v.add(key, config[key]); | ||
}); | ||
} | ||
get(key) { | ||
return this._v.get(key); | ||
} | ||
get defaultCachingStore() { | ||
return this.get("defaultCachingStore"); | ||
} | ||
get defaultCachingTimeoutSeconds() { | ||
return this.get("defaultCachingTimeoutSeconds"); | ||
} | ||
get globalCacheDisable() { | ||
return this.get("globalCacheDisable"); | ||
} | ||
get enableCacheExpiration() { | ||
return this.get("enableCacheExpiration"); | ||
} | ||
get cacheExpirationIntervalMilliseconds() { | ||
return this.get("cacheExpirationIntervalMilliseconds"); | ||
} | ||
get spfxContext() { | ||
return this.get("spfxContext"); | ||
} | ||
} | ||
const _runtimeConfig = new RuntimeConfigImpl(); | ||
let RuntimeConfig = _runtimeConfig; | ||
/** | ||
* A wrapper class to provide a consistent interface to browser based storage | ||
@@ -754,3 +907,3 @@ * | ||
export { readBlobAsText, readBlobAsArrayBuffer, Dictionary, deprecated, beta, UrlException, setup, RuntimeConfigImpl, RuntimeConfig, mergeHeaders, mergeOptions, FetchClient, BearerTokenFetchClient, PnPClientStorageWrapper, PnPClientStorage, getCtxCallback, dateAdd, combinePaths, getRandomString, getGUID, isFunc, objectDefinedNotNull, isArray, extend, isUrlAbsolute, stringIsNullOrEmpty, Util }; | ||
export { AdalClient, readBlobAsText, readBlobAsArrayBuffer, Dictionary, deprecated, beta, UrlException, setup, RuntimeConfigImpl, RuntimeConfig, mergeHeaders, mergeOptions, FetchClient, BearerTokenFetchClient, PnPClientStorageWrapper, PnPClientStorage, getCtxCallback, dateAdd, combinePaths, getRandomString, getGUID, isFunc, objectDefinedNotNull, isArray, extend, isUrlAbsolute, stringIsNullOrEmpty, Util }; | ||
//# sourceMappingURL=common.js.map |
@@ -11,3 +11,3 @@ # @pnp/common | ||
`npm install @pnp\logging @pnp\common --save` | ||
`npm install @pnp/logging @pnp/common --save` | ||
@@ -24,2 +24,3 @@ Import and use functionality, see details on modules below. | ||
* [adalclient](adalclient.md) | ||
* [blobutil](blobutil.md) | ||
@@ -26,0 +27,0 @@ * [collections](collections.md) |
{ | ||
"name": "@pnp/common", | ||
"version": "1.0.3", | ||
"version": "1.0.4-0", | ||
"description": "pnp - provides shared functionality across all pnp libraries", | ||
@@ -8,6 +8,8 @@ "main": "./dist/common.es5.umd.js", | ||
"dependencies": { | ||
"@types/adal-angular": "1.0.0", | ||
"adal-angular": "1.0.17", | ||
"tslib": "1.8.1" | ||
}, | ||
"peerDependencies": { | ||
"@pnp/logging": "1.0.3" | ||
"@pnp/logging": "1.0.4-0" | ||
}, | ||
@@ -14,0 +16,0 @@ "author": { |
@@ -0,1 +1,2 @@ | ||
export * from "./adalclient"; | ||
export * from "./blobutil"; | ||
@@ -2,0 +3,0 @@ export * from "./collections"; |
@@ -38,3 +38,4 @@ export interface ConfigOptions { | ||
constructor(_token: string); | ||
token: string; | ||
fetch(url: string, options?: FetchOptions): Promise<Response>; | ||
} |
@@ -7,2 +7,11 @@ export interface ISPFXGraphHttpClient { | ||
pageContext: { | ||
aadInfo: { | ||
tenantId: { | ||
toString(): string; | ||
}; | ||
}; | ||
legacyPageContext: { | ||
aadTenantId: string; | ||
msGraphEndpointUrl: string; | ||
}; | ||
web: { | ||
@@ -9,0 +18,0 @@ absoluteUrl: string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1107011
38
6991
4
2
+ Added@types/adal-angular@1.0.0
+ Addedadal-angular@1.0.17
+ Added@pnp/logging@1.0.4-0(transitive)
+ Added@types/adal-angular@1.0.0(transitive)
+ Addedadal-angular@1.0.17(transitive)
- Removed@pnp/logging@1.0.3(transitive)