@middy/sts 3.0.0-alpha.7 → 3.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +3 -0
- package/index.js +1 -1
- package/package.json +13 -6
package/index.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _util=require("@middy/util");var _stsJs=_interopRequireDefault(require("aws-sdk/clients/sts.js"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var _assumeRoleOptions;const defaults={AwsClient:_stsJs.default,awsClientOptions:{},awsClientCapture:undefined,fetchData:{},disablePrefetch:false,cacheKey:"sts",cacheExpiry:-1,setToContext:false};const stsMiddleware=(opts={})=>{const options={...defaults,...opts};const fetch=(request,cachedValues={})=>{const values={};for(const internalKey of Object.keys(options.fetchData)){if(cachedValues[internalKey])continue;const assumeRoleOptions=options.fetchData[internalKey];(_assumeRoleOptions=assumeRoleOptions).RoleSessionName??(_assumeRoleOptions.RoleSessionName="middy-sts-session-"+Math.ceil(Math.random()*99999));values[internalKey]=client.assumeRole(assumeRoleOptions).promise().then(resp=>({accessKeyId:resp.Credentials.AccessKeyId,secretAccessKey:resp.Credentials.SecretAccessKey,sessionToken:resp.Credentials.SessionToken})).catch(e=>{const value=(0,_util).getCache(options.cacheKey).value??{};value[internalKey]=undefined;(0,_util).modifyCache(options.cacheKey,value);throw e})}return values};let prefetch,client;if((0,_util).canPrefetch(options)){client=(0,_util).createPrefetchClient(options);prefetch=(0,_util).processCache(options,fetch)}const stsMiddlewareBefore=async request=>{if(!client){client=await (0,_util).createClient(options,request)}const{value}=prefetch??(0,_util).processCache(options,fetch,request);Object.assign(request.internal,value);if(options.setToContext){const data=await (0,_util).getInternal(Object.keys(options.fetchData),request);if(options.setToContext)Object.assign(request.context,data)}prefetch=null};return{before:stsMiddlewareBefore}};var _default=stsMiddleware;exports.default=_default
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{canPrefetch,createPrefetchClient,createClient,getCache,getInternal,processCache,modifyCache}from
|
|
1
|
+
var _assumeRoleOptions;import{canPrefetch,createPrefetchClient,createClient,getCache,getInternal,processCache,modifyCache}from"@middy/util";import STS from"aws-sdk/clients/sts.js";const defaults={AwsClient:STS,awsClientOptions:{},awsClientCapture:undefined,fetchData:{},disablePrefetch:false,cacheKey:"sts",cacheExpiry:-1,setToContext:false};const stsMiddleware=(opts={})=>{const options={...defaults,...opts};const fetch=(request,cachedValues={})=>{const values={};for(const internalKey of Object.keys(options.fetchData)){if(cachedValues[internalKey])continue;const assumeRoleOptions=options.fetchData[internalKey];(_assumeRoleOptions=assumeRoleOptions).RoleSessionName??(_assumeRoleOptions.RoleSessionName="middy-sts-session-"+Math.ceil(Math.random()*99999));values[internalKey]=client.assumeRole(assumeRoleOptions).promise().then(resp=>({accessKeyId:resp.Credentials.AccessKeyId,secretAccessKey:resp.Credentials.SecretAccessKey,sessionToken:resp.Credentials.SessionToken})).catch(e=>{const value=getCache(options.cacheKey).value??{};value[internalKey]=undefined;modifyCache(options.cacheKey,value);throw e})}return values};let prefetch,client;if(canPrefetch(options)){client=createPrefetchClient(options);prefetch=processCache(options,fetch)}const stsMiddlewareBefore=async request=>{if(!client){client=await createClient(options,request)}const{value}=prefetch??processCache(options,fetch,request);Object.assign(request.internal,value);if(options.setToContext){const data=await getInternal(Object.keys(options.fetchData),request);if(options.setToContext)Object.assign(request.context,data)}prefetch=null};return{before:stsMiddlewareBefore}};export default stsMiddleware
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/sts",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.8",
|
|
4
4
|
"description": "STS (Security Token Service) credentials middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -10,10 +10,17 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"exports":
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./index.js",
|
|
16
|
+
"require": "./index.cjs",
|
|
17
|
+
"types": "./index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
14
20
|
"types": "index.d.ts",
|
|
15
21
|
"files": [
|
|
16
22
|
"index.js",
|
|
23
|
+
"index.cjs",
|
|
17
24
|
"index.d.ts"
|
|
18
25
|
],
|
|
19
26
|
"scripts": {
|
|
@@ -46,14 +53,14 @@
|
|
|
46
53
|
"bugs": {
|
|
47
54
|
"url": "https://github.com/middyjs/middy/issues"
|
|
48
55
|
},
|
|
49
|
-
"homepage": "https://
|
|
56
|
+
"homepage": "https://middy.js.org",
|
|
50
57
|
"dependencies": {
|
|
51
|
-
"@middy/util": "^3.0.0-alpha.
|
|
58
|
+
"@middy/util": "^3.0.0-alpha.8"
|
|
52
59
|
},
|
|
53
60
|
"devDependencies": {
|
|
54
|
-
"@middy/core": "^3.0.0-alpha.
|
|
61
|
+
"@middy/core": "^3.0.0-alpha.8",
|
|
55
62
|
"aws-sdk": "^2.939.0",
|
|
56
63
|
"aws-xray-sdk": "^3.3.3"
|
|
57
64
|
},
|
|
58
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "c04b3a0c2f326906b34973878d6f823778a5ea99"
|
|
59
66
|
}
|