@vizamodo/aws-sts-core 0.3.8 → 0.3.10

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.
@@ -13,10 +13,5 @@ export function hex(buf) {
13
13
  }
14
14
  export async function sha256Hex(input) {
15
15
  const hash = await crypto.subtle.digest("SHA-256", textEncoder.encode(input));
16
- const bytes = new Uint8Array(hash);
17
- const hexParts = new Array(32);
18
- for (let i = 0; i < 32; i++) {
19
- hexParts[i] = HEX_TABLE[bytes[i]];
20
- }
21
- return hexParts.join("");
16
+ return hex(hash);
22
17
  }
@@ -30,7 +30,7 @@ function toUint8(buf) {
30
30
  * Derive SigV4 signing key
31
31
  */
32
32
  async function getSignatureKey(secretKey, date, region, service) {
33
- const kDate = await hmac(new TextEncoder().encode("AWS4" + secretKey), date);
33
+ const kDate = await hmac(encoder.encode("AWS4" + secretKey), date);
34
34
  const kRegion = await hmac(toUint8(kDate), region);
35
35
  const kService = await hmac(toUint8(kRegion), service);
36
36
  return hmac(toUint8(kService), "aws4_request");
@@ -68,7 +68,6 @@ export async function buildSignedAwsRequest(input) {
68
68
  "/\n" +
69
69
  "\n" +
70
70
  canonicalHeaders +
71
- "\n" +
72
71
  signedHeaders +
73
72
  "\n" +
74
73
  payloadHash;
@@ -78,19 +77,20 @@ export async function buildSignedAwsRequest(input) {
78
77
  "/" +
79
78
  service +
80
79
  "/aws4_request";
80
+ const canonicalRequestHash = await sha256Hex(canonicalRequest);
81
81
  const stringToSign = "AWS4-HMAC-SHA256\n" +
82
82
  amzDate +
83
83
  "\n" +
84
84
  credentialScope +
85
85
  "\n" +
86
- await sha256Hex(canonicalRequest);
87
- const cacheKey = await sha256Hex(credentials.secretAccessKey +
86
+ canonicalRequestHash;
87
+ const cacheKey = credentials.secretAccessKey +
88
88
  "|" +
89
89
  dateStamp +
90
90
  "|" +
91
91
  region +
92
92
  "|" +
93
- service);
93
+ service;
94
94
  let signingKey = signingKeyCache.get(cacheKey);
95
95
  if (!signingKey) {
96
96
  signingKey = await getSignatureKey(credentials.secretAccessKey, dateStamp, region, service);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/aws-sts-core",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "Pure AWS STS + SigV4 (X509 Roles Anywhere) core logic",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",