@smithy/property-provider
Advanced tools
Comparing version 2.0.17 to 2.1.0
@@ -1,25 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.chain = void 0; | ||
const ProviderError_1 = require("./ProviderError"); | ||
const chain = (...providers) => async () => { | ||
if (providers.length === 0) { | ||
throw new ProviderError_1.ProviderError("No providers in chain"); | ||
} | ||
let lastProviderError; | ||
for (const provider of providers) { | ||
try { | ||
const credentials = await provider(); | ||
return credentials; | ||
} | ||
catch (err) { | ||
lastProviderError = err; | ||
if (err === null || err === void 0 ? void 0 : err.tryNextLink) { | ||
continue; | ||
} | ||
throw err; | ||
} | ||
} | ||
throw lastProviderError; | ||
}; | ||
exports.chain = chain; | ||
module.exports = require("./index.js"); |
@@ -1,13 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CredentialsProviderError = void 0; | ||
const ProviderError_1 = require("./ProviderError"); | ||
class CredentialsProviderError extends ProviderError_1.ProviderError { | ||
constructor(message, tryNextLink = true) { | ||
super(message, tryNextLink); | ||
this.tryNextLink = tryNextLink; | ||
this.name = "CredentialsProviderError"; | ||
Object.setPrototypeOf(this, CredentialsProviderError.prototype); | ||
} | ||
} | ||
exports.CredentialsProviderError = CredentialsProviderError; | ||
module.exports = require("./index.js"); |
@@ -1,5 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fromStatic = void 0; | ||
const fromStatic = (staticValue) => () => Promise.resolve(staticValue); | ||
exports.fromStatic = fromStatic; | ||
module.exports = require("./index.js"); |
@@ -1,9 +0,148 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./CredentialsProviderError"), exports); | ||
tslib_1.__exportStar(require("./ProviderError"), exports); | ||
tslib_1.__exportStar(require("./TokenProviderError"), exports); | ||
tslib_1.__exportStar(require("./chain"), exports); | ||
tslib_1.__exportStar(require("./fromStatic"), exports); | ||
tslib_1.__exportStar(require("./memoize"), exports); | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
CredentialsProviderError: () => CredentialsProviderError, | ||
ProviderError: () => ProviderError, | ||
TokenProviderError: () => TokenProviderError, | ||
chain: () => chain, | ||
fromStatic: () => fromStatic, | ||
memoize: () => memoize | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/ProviderError.ts | ||
var _ProviderError = class _ProviderError extends Error { | ||
constructor(message, tryNextLink = true) { | ||
super(message); | ||
this.tryNextLink = tryNextLink; | ||
this.name = "ProviderError"; | ||
Object.setPrototypeOf(this, _ProviderError.prototype); | ||
} | ||
static from(error, tryNextLink = true) { | ||
return Object.assign(new this(error.message, tryNextLink), error); | ||
} | ||
}; | ||
__name(_ProviderError, "ProviderError"); | ||
var ProviderError = _ProviderError; | ||
// src/CredentialsProviderError.ts | ||
var _CredentialsProviderError = class _CredentialsProviderError extends ProviderError { | ||
constructor(message, tryNextLink = true) { | ||
super(message, tryNextLink); | ||
this.tryNextLink = tryNextLink; | ||
this.name = "CredentialsProviderError"; | ||
Object.setPrototypeOf(this, _CredentialsProviderError.prototype); | ||
} | ||
}; | ||
__name(_CredentialsProviderError, "CredentialsProviderError"); | ||
var CredentialsProviderError = _CredentialsProviderError; | ||
// src/TokenProviderError.ts | ||
var _TokenProviderError = class _TokenProviderError extends ProviderError { | ||
constructor(message, tryNextLink = true) { | ||
super(message, tryNextLink); | ||
this.tryNextLink = tryNextLink; | ||
this.name = "TokenProviderError"; | ||
Object.setPrototypeOf(this, _TokenProviderError.prototype); | ||
} | ||
}; | ||
__name(_TokenProviderError, "TokenProviderError"); | ||
var TokenProviderError = _TokenProviderError; | ||
// src/chain.ts | ||
var chain = /* @__PURE__ */ __name((...providers) => async () => { | ||
if (providers.length === 0) { | ||
throw new ProviderError("No providers in chain"); | ||
} | ||
let lastProviderError; | ||
for (const provider of providers) { | ||
try { | ||
const credentials = await provider(); | ||
return credentials; | ||
} catch (err) { | ||
lastProviderError = err; | ||
if (err == null ? void 0 : err.tryNextLink) { | ||
continue; | ||
} | ||
throw err; | ||
} | ||
} | ||
throw lastProviderError; | ||
}, "chain"); | ||
// src/fromStatic.ts | ||
var fromStatic = /* @__PURE__ */ __name((staticValue) => () => Promise.resolve(staticValue), "fromStatic"); | ||
// src/memoize.ts | ||
var memoize = /* @__PURE__ */ __name((provider, isExpired, requiresRefresh) => { | ||
let resolved; | ||
let pending; | ||
let hasResult; | ||
let isConstant = false; | ||
const coalesceProvider = /* @__PURE__ */ __name(async () => { | ||
if (!pending) { | ||
pending = provider(); | ||
} | ||
try { | ||
resolved = await pending; | ||
hasResult = true; | ||
isConstant = false; | ||
} finally { | ||
pending = void 0; | ||
} | ||
return resolved; | ||
}, "coalesceProvider"); | ||
if (isExpired === void 0) { | ||
return async (options) => { | ||
if (!hasResult || (options == null ? void 0 : options.forceRefresh)) { | ||
resolved = await coalesceProvider(); | ||
} | ||
return resolved; | ||
}; | ||
} | ||
return async (options) => { | ||
if (!hasResult || (options == null ? void 0 : options.forceRefresh)) { | ||
resolved = await coalesceProvider(); | ||
} | ||
if (isConstant) { | ||
return resolved; | ||
} | ||
if (requiresRefresh && !requiresRefresh(resolved)) { | ||
isConstant = true; | ||
return resolved; | ||
} | ||
if (isExpired(resolved)) { | ||
await coalesceProvider(); | ||
return resolved; | ||
} | ||
return resolved; | ||
}; | ||
}, "memoize"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
CredentialsProviderError, | ||
ProviderError, | ||
TokenProviderError, | ||
chain, | ||
fromStatic, | ||
memoize | ||
}); |
@@ -1,49 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.memoize = void 0; | ||
const memoize = (provider, isExpired, requiresRefresh) => { | ||
let resolved; | ||
let pending; | ||
let hasResult; | ||
let isConstant = false; | ||
const coalesceProvider = async () => { | ||
if (!pending) { | ||
pending = provider(); | ||
} | ||
try { | ||
resolved = await pending; | ||
hasResult = true; | ||
isConstant = false; | ||
} | ||
finally { | ||
pending = undefined; | ||
} | ||
return resolved; | ||
}; | ||
if (isExpired === undefined) { | ||
return async (options) => { | ||
if (!hasResult || (options === null || options === void 0 ? void 0 : options.forceRefresh)) { | ||
resolved = await coalesceProvider(); | ||
} | ||
return resolved; | ||
}; | ||
} | ||
return async (options) => { | ||
if (!hasResult || (options === null || options === void 0 ? void 0 : options.forceRefresh)) { | ||
resolved = await coalesceProvider(); | ||
} | ||
if (isConstant) { | ||
return resolved; | ||
} | ||
if (requiresRefresh && !requiresRefresh(resolved)) { | ||
isConstant = true; | ||
return resolved; | ||
} | ||
if (isExpired(resolved)) { | ||
await coalesceProvider(); | ||
return resolved; | ||
} | ||
return resolved; | ||
}; | ||
}; | ||
exports.memoize = memoize; | ||
module.exports = require("./index.js"); |
@@ -1,15 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ProviderError = void 0; | ||
class ProviderError extends Error { | ||
constructor(message, tryNextLink = true) { | ||
super(message); | ||
this.tryNextLink = tryNextLink; | ||
this.name = "ProviderError"; | ||
Object.setPrototypeOf(this, ProviderError.prototype); | ||
} | ||
static from(error, tryNextLink = true) { | ||
return Object.assign(new this(error.message, tryNextLink), error); | ||
} | ||
} | ||
exports.ProviderError = ProviderError; | ||
module.exports = require("./index.js"); |
@@ -1,13 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TokenProviderError = void 0; | ||
const ProviderError_1 = require("./ProviderError"); | ||
class TokenProviderError extends ProviderError_1.ProviderError { | ||
constructor(message, tryNextLink = true) { | ||
super(message, tryNextLink); | ||
this.tryNextLink = tryNextLink; | ||
this.name = "TokenProviderError"; | ||
Object.setPrototypeOf(this, TokenProviderError.prototype); | ||
} | ||
} | ||
exports.TokenProviderError = TokenProviderError; | ||
module.exports = require("./index.js"); |
{ | ||
"name": "@smithy/property-provider", | ||
"version": "2.0.17", | ||
"version": "2.1.0", | ||
"scripts": { | ||
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'", | ||
"build:cjs": "yarn g:tsc -p tsconfig.cjs.json", | ||
"build:cjs": "node ../../scripts/inline property-provider", | ||
"build:es": "yarn g:tsc -p tsconfig.es.json", | ||
@@ -25,3 +25,3 @@ "build:types": "yarn g:tsc -p tsconfig.types.json", | ||
"dependencies": { | ||
"@smithy/types": "^2.8.0", | ||
"@smithy/types": "^2.9.0", | ||
"tslib": "^2.5.0" | ||
@@ -28,0 +28,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
32120
509
Updated@smithy/types@^2.9.0