@pnp/common
Advanced tools
Comparing version 2.0.0-5 to 2.0.0-6
{ | ||
"name": "@pnp/common", | ||
"version": "2.0.0-5", | ||
"version": "2.0.0-6", | ||
"description": "pnp - provides shared functionality across all pnp libraries", | ||
@@ -11,3 +11,2 @@ "main": "./index.js", | ||
}, | ||
"peerDependencies": {}, | ||
"devDependencies": { | ||
@@ -14,0 +13,0 @@ "@types/adal-angular": "1.0.1" |
@@ -1,2 +0,2 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { __awaiter, __extends, __generator } from "tslib"; | ||
import { BearerTokenFetchClient } from "./netutil"; | ||
@@ -21,3 +21,3 @@ import { isUrlAbsolute } from "./util"; | ||
var AdalClient = /** @class */ (function (_super) { | ||
tslib_1.__extends(AdalClient, _super); | ||
__extends(AdalClient, _super); | ||
/** | ||
@@ -55,5 +55,5 @@ * Creates a new instance of AdalClient | ||
AdalClient.prototype.fetch = function (url, options) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var token; | ||
return tslib_1.__generator(this, function (_a) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -79,5 +79,5 @@ case 0: | ||
AdalClient.prototype.getToken = function (resource) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var token; | ||
return tslib_1.__generator(this, function (_a) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -181,3 +181,3 @@ case 0: return [4 /*yield*/, this.ensureAuthContext()]; | ||
var SPFxAdalClient = /** @class */ (function (_super) { | ||
tslib_1.__extends(SPFxAdalClient, _super); | ||
__extends(SPFxAdalClient, _super); | ||
/** | ||
@@ -199,6 +199,13 @@ * | ||
SPFxAdalClient.prototype.fetch = function (url, options) { | ||
var _this = this; | ||
return this.getToken(getResource(url)).then(function (token) { | ||
_this.token = token; | ||
return _super.prototype.fetch.call(_this, url, options); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var token; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getToken(getResource(url))]; | ||
case 1: | ||
token = _a.sent(); | ||
this.token = token; | ||
return [2 /*return*/, _super.prototype.fetch.call(this, url, options)]; | ||
} | ||
}); | ||
}); | ||
@@ -212,4 +219,12 @@ }; | ||
SPFxAdalClient.prototype.getToken = function (resource) { | ||
return this.context.aadTokenProviderFactory.getTokenProvider().then(function (provider) { | ||
return provider.getToken(resource); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var provider; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.context.aadTokenProviderFactory.getTokenProvider()]; | ||
case 1: | ||
provider = _a.sent(); | ||
return [2 /*return*/, provider.getToken(resource)]; | ||
} | ||
}); | ||
}); | ||
@@ -216,0 +231,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import * as tslib_1 from "tslib"; | ||
import { __extends } from "tslib"; | ||
import { assign, objectDefinedNotNull } from "./util"; | ||
@@ -34,3 +34,3 @@ export function mergeHeaders(target, source) { | ||
var BearerTokenFetchClient = /** @class */ (function (_super) { | ||
tslib_1.__extends(BearerTokenFetchClient, _super); | ||
__extends(BearerTokenFetchClient, _super); | ||
function BearerTokenFetchClient(_token) { | ||
@@ -37,0 +37,0 @@ var _this = _super.call(this) || this; |
@@ -0,1 +1,2 @@ | ||
import { __awaiter, __generator } from "tslib"; | ||
import { dateAdd, getCtxCallback, jsS, objectDefinedNotNull } from "./util"; | ||
@@ -76,17 +77,20 @@ import { RuntimeConfig } from "./libconfig"; | ||
PnPClientStorageWrapper.prototype.getOrPut = function (key, getter, expire) { | ||
var _this = this; | ||
if (!this.enabled) { | ||
return getter(); | ||
} | ||
return new Promise(function (resolve) { | ||
var o = _this.get(key); | ||
if (o == null) { | ||
getter().then(function (d) { | ||
_this.put(key, d, expire); | ||
resolve(d); | ||
}); | ||
} | ||
else { | ||
resolve(o); | ||
} | ||
return __awaiter(this, void 0, void 0, function () { | ||
var o; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!this.enabled) { | ||
return [2 /*return*/, getter()]; | ||
} | ||
o = this.get(key); | ||
if (!(o === null)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, getter()]; | ||
case 1: | ||
o = _a.sent(); | ||
this.put(key, o, expire); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, o]; | ||
} | ||
}); | ||
}); | ||
@@ -98,23 +102,20 @@ }; | ||
PnPClientStorageWrapper.prototype.deleteExpired = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
if (!_this.enabled) { | ||
resolve(); | ||
} | ||
try { | ||
for (var i = 0; i < _this.store.length; i++) { | ||
var key = _this.store.key(i); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var i, key; | ||
return __generator(this, function (_a) { | ||
if (!this.enabled) { | ||
return [2 /*return*/]; | ||
} | ||
for (i = 0; i < this.store.length; i++) { | ||
key = this.store.key(i); | ||
if (key !== null) { | ||
// test the stored item to see if we stored it | ||
if (/["|']?pnp["|']? ?: ?1/i.test(_this.store.getItem(key))) { | ||
if (/["|']?pnp["|']? ?: ?1/i.test(this.store.getItem(key))) { | ||
// get those items as get will delete from cache if they are expired | ||
_this.get(key); | ||
this.get(key); | ||
} | ||
} | ||
} | ||
resolve(); | ||
} | ||
catch (e) { | ||
reject(e); | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
@@ -121,0 +122,0 @@ }; |
import { TypedHash } from "./collections"; | ||
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
/** | ||
@@ -82,10 +81,2 @@ * Gets a callback function which will maintain context across async calls. | ||
/** | ||
* Gets an attribute value from an html/xml string block. NOTE: if the input attribute value has | ||
* RegEx special characters they will be escaped in the returned string | ||
* | ||
* @param html HTML to search | ||
* @param attrName The name of the attribute to find | ||
*/ | ||
export declare function getAttrValueFromString(html: string, attrName: string): string | null; | ||
/** | ||
* Ensures guid values are represented consistently as "ea123463-137d-4ae3-89b8-cf3fc578ca05" | ||
@@ -92,0 +83,0 @@ * |
@@ -178,16 +178,2 @@ /** | ||
/** | ||
* Gets an attribute value from an html/xml string block. NOTE: if the input attribute value has | ||
* RegEx special characters they will be escaped in the returned string | ||
* | ||
* @param html HTML to search | ||
* @param attrName The name of the attribute to find | ||
*/ | ||
export function getAttrValueFromString(html, attrName) { | ||
// make the input safe for regex | ||
html = html.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
var reg = new RegExp(attrName + "\\s*?=\\s*?(\"|')([^\\1]*?)\\1", "i"); | ||
var match = reg.exec(html); | ||
return match !== null && match.length > 0 ? match[2] : null; | ||
} | ||
/** | ||
* Ensures guid values are represented consistently as "ea123463-137d-4ae3-89b8-cf3fc578ca05" | ||
@@ -194,0 +180,0 @@ * |
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
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
52075
1346