@aws-sdk/signature-v4-crt 3.451.0 → 3.461.0

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.
@@ -25,8 +25,8 @@ class CrtSignerV4 {
25
25
  this.credentialProvider = (0, util_middleware_1.normalizeProvider)(credentials);
26
26
  aws_crt_1.io.enable_logging(aws_crt_1.io.LogLevel.ERROR);
27
27
  }
28
- async options2crtConfigure({ signingDate = new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService, } = {}, viaHeader, payloadHash, expiresIn) {
29
- const credentials = await this.credentialProvider();
28
+ async options2crtConfigure({ signingDate = new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService, } = {}, viaHeader, payloadHash, expiresIn, _credentials) {
29
+ const credentials = _credentials !== null && _credentials !== void 0 ? _credentials : (await this.credentialProvider());
30
30
  const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : (await this.regionProvider());
31
31
  const service = signingService !== null && signingService !== void 0 ? signingService : this.service;
32
32
  if ((signableHeaders === null || signableHeaders === void 0 ? void 0 : signableHeaders.has("x-amzn-trace-id")) || (signableHeaders === null || signableHeaders === void 0 ? void 0 : signableHeaders.has("user-agent"))) {
@@ -66,6 +66,12 @@ class CrtSignerV4 {
66
66
  request.headers = crtSignedRequest.headers._flatten().reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
67
67
  return request;
68
68
  }
69
+ async signWithCredentials(toSign, credentials, options) {
70
+ const request = (0, signature_v4_1.prepareRequest)(toSign);
71
+ const crtSignedRequest = await this.signRequest(request, await this.options2crtConfigure(options, true, await (0, signature_v4_1.getPayloadHash)(toSign, this.sha256), undefined, credentials));
72
+ request.headers = crtSignedRequest.headers._flatten().reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
73
+ return request;
74
+ }
69
75
  getQueryParam(crtPath) {
70
76
  const start = crtPath.search(/\?/);
71
77
  const startHash = crtPath.search(/\#/);
@@ -22,8 +22,8 @@ export class CrtSignerV4 {
22
22
  this.credentialProvider = normalizeProvider(credentials);
23
23
  crtIO.enable_logging(crtIO.LogLevel.ERROR);
24
24
  }
25
- async options2crtConfigure({ signingDate = new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService, } = {}, viaHeader, payloadHash, expiresIn) {
26
- const credentials = await this.credentialProvider();
25
+ async options2crtConfigure({ signingDate = new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService, } = {}, viaHeader, payloadHash, expiresIn, _credentials) {
26
+ const credentials = _credentials ?? (await this.credentialProvider());
27
27
  const region = signingRegion ?? (await this.regionProvider());
28
28
  const service = signingService ?? this.service;
29
29
  if (signableHeaders?.has("x-amzn-trace-id") || signableHeaders?.has("user-agent")) {
@@ -63,6 +63,12 @@ export class CrtSignerV4 {
63
63
  request.headers = crtSignedRequest.headers._flatten().reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
64
64
  return request;
65
65
  }
66
+ async signWithCredentials(toSign, credentials, options) {
67
+ const request = prepareRequest(toSign);
68
+ const crtSignedRequest = await this.signRequest(request, await this.options2crtConfigure(options, true, await getPayloadHash(toSign, this.sha256), undefined, credentials));
69
+ request.headers = crtSignedRequest.headers._flatten().reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
70
+ return request;
71
+ }
66
72
  getQueryParam(crtPath) {
67
73
  const start = crtPath.search(/\?/);
68
74
  const startHash = crtPath.search(/\#/);
@@ -1,3 +1,4 @@
1
+ import { AwsCredentialIdentity } from "@aws-sdk/types";
1
2
  import { SignatureV4CryptoInit, SignatureV4Init } from "@smithy/signature-v4";
2
3
  import { HttpRequest, RequestPresigner, RequestPresigningArguments, RequestSigner, RequestSigningArguments } from "@smithy/types";
3
4
  import { auth as crtAuth } from "aws-crt";
@@ -31,6 +32,10 @@ export declare class CrtSignerV4 implements RequestPresigner, RequestSigner {
31
32
  private options2crtConfigure;
32
33
  presign(originalRequest: HttpRequest, options?: RequestPresigningArguments): Promise<HttpRequest>;
33
34
  sign(toSign: HttpRequest, options?: RequestSigningArguments): Promise<HttpRequest>;
35
+ /**
36
+ * Sign with alternate credentials to the ones provided in the constructor.
37
+ */
38
+ signWithCredentials(toSign: HttpRequest, credentials: AwsCredentialIdentity, options?: RequestSigningArguments): Promise<HttpRequest>;
34
39
  private getQueryParam;
35
40
  private signRequest;
36
41
  /**
@@ -1,3 +1,4 @@
1
+ import { AwsCredentialIdentity } from "@aws-sdk/types";
1
2
  import { SignatureV4CryptoInit, SignatureV4Init } from "@smithy/signature-v4";
2
3
  import {
3
4
  HttpRequest,
@@ -37,6 +38,11 @@ export declare class CrtSignerV4 implements RequestPresigner, RequestSigner {
37
38
  toSign: HttpRequest,
38
39
  options?: RequestSigningArguments
39
40
  ): Promise<HttpRequest>;
41
+ signWithCredentials(
42
+ toSign: HttpRequest,
43
+ credentials: AwsCredentialIdentity,
44
+ options?: RequestSigningArguments
45
+ ): Promise<HttpRequest>;
40
46
  private getQueryParam;
41
47
  private signRequest;
42
48
  verifySigv4aSigning(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/signature-v4-crt",
3
- "version": "3.451.0",
3
+ "version": "3.461.0",
4
4
  "description": "A revision of AWS Signature V4 request signer based on AWS Common Runtime https://github.com/awslabs/aws-crt-nodejs",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -22,8 +22,9 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@aws-sdk/signature-v4-multi-region": "3.451.0",
26
- "@aws-sdk/util-user-agent-node": "3.451.0",
25
+ "@aws-sdk/signature-v4-multi-region": "3.461.0",
26
+ "@aws-sdk/types": "3.460.0",
27
+ "@aws-sdk/util-user-agent-node": "3.460.0",
27
28
  "@smithy/querystring-parser": "^2.0.0",
28
29
  "@smithy/signature-v4": "^2.0.0",
29
30
  "@smithy/types": "^2.5.0",
@@ -33,7 +34,6 @@
33
34
  },
34
35
  "devDependencies": {
35
36
  "@aws-crypto/sha256-js": "3.0.0",
36
- "@aws-sdk/types": "3.451.0",
37
37
  "@smithy/protocol-http": "^3.0.9",
38
38
  "@tsconfig/recommended": "1.0.1",
39
39
  "concurrently": "7.0.0",