@middy/sts 2.5.6 → 3.0.0-alpha.3

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.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/index.js +8 -11
  4. package/package.json +10 -8
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2021 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
3
+ Copyright (c) 2017-2022 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -91,7 +91,7 @@ Everyone is very welcome to contribute to this repository. Feel free to [raise i
91
91
 
92
92
  ## License
93
93
 
94
- Licensed under [MIT License](LICENSE). Copyright (c) 2017-2021 Luciano Mammino, will Farrell, and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
94
+ Licensed under [MIT License](LICENSE). Copyright (c) 2017-2022 Luciano Mammino, will Farrell, and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
95
95
 
96
96
  <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
97
97
  <img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy.svg?type=large" alt="FOSSA Status" style="max-width:100%;">
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
- const {
1
+ import {
2
2
  canPrefetch,
3
3
  createPrefetchClient,
4
4
  createClient,
5
+ getCache,
5
6
  getInternal,
6
7
  processCache,
7
- getCache,
8
8
  modifyCache
9
- } = require('@middy/util')
10
- const STS = require('aws-sdk/clients/sts') // v2
11
- // const { STS } = require('@aws-sdk/client-sts') // v3
9
+ } from '@middy/util'
10
+ import STS from 'aws-sdk/clients/sts.js' // v2
11
+ // import { STS } from '@aws-sdk/client-sts' // v3
12
12
 
13
13
  const defaults = {
14
14
  AwsClient: STS,
@@ -19,7 +19,6 @@ const defaults = {
19
19
  disablePrefetch: false,
20
20
  cacheKey: 'sts',
21
21
  cacheExpiry: -1,
22
- // setToEnv: false, // returns object, cannot set to process.env
23
22
  setToContext: false
24
23
  }
25
24
 
@@ -33,9 +32,7 @@ const stsMiddleware = (opts = {}) => {
33
32
  if (cachedValues[internalKey]) continue
34
33
  const assumeRoleOptions = options.fetchData[internalKey]
35
34
  // Date cannot be used here to assign default session name, possibility of collision when > 1 role defined
36
- assumeRoleOptions.RoleSessionName =
37
- assumeRoleOptions?.RoleSessionName ??
38
- 'middy-sts-session-' + Math.ceil(Math.random() * 99999)
35
+ assumeRoleOptions.RoleSessionName ??= 'middy-sts-session-' + Math.ceil(Math.random() * 99999)
39
36
  values[internalKey] = client
40
37
  .assumeRole(assumeRoleOptions)
41
38
  .promise() // Required for aws-sdk v2
@@ -45,7 +42,7 @@ const stsMiddleware = (opts = {}) => {
45
42
  sessionToken: resp.Credentials.SessionToken
46
43
  }))
47
44
  .catch((e) => {
48
- const value = getCache(options.cacheKey)?.value ?? {}
45
+ const value = getCache(options.cacheKey).value ?? {}
49
46
  value[internalKey] = undefined
50
47
  modifyCache(options.cacheKey, value)
51
48
  throw e
@@ -81,4 +78,4 @@ const stsMiddleware = (opts = {}) => {
81
78
  before: stsMiddlewareBefore
82
79
  }
83
80
  }
84
- module.exports = stsMiddleware
81
+ export default stsMiddleware
package/package.json CHANGED
@@ -1,23 +1,25 @@
1
1
  {
2
2
  "name": "@middy/sts",
3
- "version": "2.5.6",
3
+ "version": "3.0.0-alpha.3",
4
4
  "description": "STS (Security Token Service) credentials middleware for the middy framework",
5
- "type": "commonjs",
5
+ "type": "module",
6
6
  "engines": {
7
- "node": ">=12"
7
+ "node": ">=14"
8
8
  },
9
9
  "engineStrict": true,
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "main": "index.js",
13
+ "exports": "./index.js",
14
14
  "types": "index.d.ts",
15
15
  "files": [
16
+ "index.js",
16
17
  "index.d.ts"
17
18
  ],
18
19
  "scripts": {
19
20
  "test": "npm run test:unit",
20
- "test:unit": "ava"
21
+ "test:unit": "ava",
22
+ "test:benchmark": "node __benchmarks__/index.js"
21
23
  },
22
24
  "license": "MIT",
23
25
  "keywords": [
@@ -46,12 +48,12 @@
46
48
  },
47
49
  "homepage": "https://github.com/middyjs/middy#readme",
48
50
  "dependencies": {
49
- "@middy/util": "^2.5.6"
51
+ "@middy/util": "^3.0.0-alpha.3"
50
52
  },
51
53
  "devDependencies": {
52
- "@middy/core": "^2.5.6",
54
+ "@middy/core": "^3.0.0-alpha.3",
53
55
  "aws-sdk": "^2.939.0",
54
56
  "aws-xray-sdk": "^3.3.3"
55
57
  },
56
- "gitHead": "0c789f55b4adf691f977b0d9904d1a805bb3bb2b"
58
+ "gitHead": "1441158711580313765e6d156046ef0fade0d156"
57
59
  }