@aws-sdk/signature-v4-multi-region 3.996.24 → 3.996.26
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/dist-cjs/index.js +38 -2
- package/dist-es/SignatureV4MultiRegion.js +2 -2
- package/dist-es/SignatureV4SignWithCredentials.js +36 -0
- package/dist-es/index.js +3 -2
- package/dist-types/SignatureV4MultiRegion.d.ts +1 -1
- package/dist-types/SignatureV4SignWithCredentials.d.ts +20 -0
- package/dist-types/index.d.ts +3 -5
- package/dist-types/ts3.4/SignatureV4SignWithCredentials.d.ts +21 -0
- package/dist-types/ts3.4/index.d.ts +9 -2
- package/package.json +3 -4
package/dist-cjs/index.js
CHANGED
|
@@ -1,12 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var middlewareSdkS3 = require('@aws-sdk/middleware-sdk-s3');
|
|
4
3
|
var signatureV4 = require('@smithy/signature-v4');
|
|
5
4
|
|
|
6
5
|
const signatureV4CrtContainer = {
|
|
7
6
|
CrtSignerV4: null,
|
|
8
7
|
};
|
|
9
8
|
|
|
9
|
+
const SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
|
|
10
|
+
const SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
|
|
11
|
+
class SignatureV4SignWithCredentials extends signatureV4.SignatureV4 {
|
|
12
|
+
async signWithCredentials(requestToSign, credentials, options) {
|
|
13
|
+
const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
|
|
14
|
+
requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
|
|
15
|
+
const privateAccess = this;
|
|
16
|
+
setSingleOverride(privateAccess, credentialsWithoutSessionToken);
|
|
17
|
+
return privateAccess.signRequest(requestToSign, options ?? {});
|
|
18
|
+
}
|
|
19
|
+
async presignWithCredentials(requestToSign, credentials, options) {
|
|
20
|
+
const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
|
|
21
|
+
delete requestToSign.headers[SESSION_TOKEN_HEADER];
|
|
22
|
+
requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
|
23
|
+
requestToSign.query = requestToSign.query ?? {};
|
|
24
|
+
requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
|
25
|
+
const privateAccess = this;
|
|
26
|
+
setSingleOverride(privateAccess, credentialsWithoutSessionToken);
|
|
27
|
+
return this.presign(requestToSign, options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function getCredentialsWithoutSessionToken(credentials) {
|
|
31
|
+
return {
|
|
32
|
+
accessKeyId: credentials.accessKeyId,
|
|
33
|
+
secretAccessKey: credentials.secretAccessKey,
|
|
34
|
+
expiration: credentials.expiration,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
|
|
38
|
+
const currentCredentialProvider = privateAccess.credentialProvider;
|
|
39
|
+
privateAccess.credentialProvider = () => {
|
|
40
|
+
privateAccess.credentialProvider = currentCredentialProvider;
|
|
41
|
+
return Promise.resolve(credentialsWithoutSessionToken);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
10
45
|
class SignatureV4MultiRegion {
|
|
11
46
|
sigv4aSigner;
|
|
12
47
|
sigv4Signer;
|
|
@@ -21,7 +56,7 @@ class SignatureV4MultiRegion {
|
|
|
21
56
|
return "none";
|
|
22
57
|
}
|
|
23
58
|
constructor(options) {
|
|
24
|
-
this.sigv4Signer = new
|
|
59
|
+
this.sigv4Signer = new SignatureV4SignWithCredentials(options);
|
|
25
60
|
this.signerOptions = options;
|
|
26
61
|
}
|
|
27
62
|
async sign(requestToSign, options = {}) {
|
|
@@ -118,4 +153,5 @@ class SignatureV4MultiRegion {
|
|
|
118
153
|
}
|
|
119
154
|
|
|
120
155
|
exports.SignatureV4MultiRegion = SignatureV4MultiRegion;
|
|
156
|
+
exports.SignatureV4SignWithCredentials = SignatureV4SignWithCredentials;
|
|
121
157
|
exports.signatureV4CrtContainer = signatureV4CrtContainer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SignatureV4S3Express } from "@aws-sdk/middleware-sdk-s3";
|
|
2
1
|
import { signatureV4aContainer } from "@smithy/signature-v4";
|
|
3
2
|
import { signatureV4CrtContainer } from "./signature-v4-crt-container";
|
|
3
|
+
import { SignatureV4SignWithCredentials } from "./SignatureV4SignWithCredentials";
|
|
4
4
|
export class SignatureV4MultiRegion {
|
|
5
5
|
sigv4aSigner;
|
|
6
6
|
sigv4Signer;
|
|
@@ -15,7 +15,7 @@ export class SignatureV4MultiRegion {
|
|
|
15
15
|
return "none";
|
|
16
16
|
}
|
|
17
17
|
constructor(options) {
|
|
18
|
-
this.sigv4Signer = new
|
|
18
|
+
this.sigv4Signer = new SignatureV4SignWithCredentials(options);
|
|
19
19
|
this.signerOptions = options;
|
|
20
20
|
}
|
|
21
21
|
async sign(requestToSign, options = {}) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SignatureV4 } from "@smithy/signature-v4";
|
|
2
|
+
export const SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
|
|
3
|
+
export const SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase();
|
|
4
|
+
export class SignatureV4SignWithCredentials extends SignatureV4 {
|
|
5
|
+
async signWithCredentials(requestToSign, credentials, options) {
|
|
6
|
+
const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
|
|
7
|
+
requestToSign.headers[SESSION_TOKEN_HEADER] = credentials.sessionToken;
|
|
8
|
+
const privateAccess = this;
|
|
9
|
+
setSingleOverride(privateAccess, credentialsWithoutSessionToken);
|
|
10
|
+
return privateAccess.signRequest(requestToSign, options ?? {});
|
|
11
|
+
}
|
|
12
|
+
async presignWithCredentials(requestToSign, credentials, options) {
|
|
13
|
+
const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials);
|
|
14
|
+
delete requestToSign.headers[SESSION_TOKEN_HEADER];
|
|
15
|
+
requestToSign.headers[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
|
16
|
+
requestToSign.query = requestToSign.query ?? {};
|
|
17
|
+
requestToSign.query[SESSION_TOKEN_QUERY_PARAM] = credentials.sessionToken;
|
|
18
|
+
const privateAccess = this;
|
|
19
|
+
setSingleOverride(privateAccess, credentialsWithoutSessionToken);
|
|
20
|
+
return this.presign(requestToSign, options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getCredentialsWithoutSessionToken(credentials) {
|
|
24
|
+
return {
|
|
25
|
+
accessKeyId: credentials.accessKeyId,
|
|
26
|
+
secretAccessKey: credentials.secretAccessKey,
|
|
27
|
+
expiration: credentials.expiration,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function setSingleOverride(privateAccess, credentialsWithoutSessionToken) {
|
|
31
|
+
const currentCredentialProvider = privateAccess.credentialProvider;
|
|
32
|
+
privateAccess.credentialProvider = () => {
|
|
33
|
+
privateAccess.credentialProvider = currentCredentialProvider;
|
|
34
|
+
return Promise.resolve(credentialsWithoutSessionToken);
|
|
35
|
+
};
|
|
36
|
+
}
|
package/dist-es/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { SignatureV4MultiRegion } from "./SignatureV4MultiRegion";
|
|
2
|
+
export { signatureV4CrtContainer } from "./signature-v4-crt-container";
|
|
3
|
+
export { SignatureV4SignWithCredentials } from "./SignatureV4SignWithCredentials";
|
|
@@ -7,7 +7,7 @@ export type SignatureV4MultiRegionInit = SignatureV4Init & SignatureV4CryptoInit
|
|
|
7
7
|
runtime?: string;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* A SigV4-compatible signer for
|
|
10
|
+
* A SigV4-compatible signer for Sigv4a. In order to support SigV4a algorithm according to the operation input
|
|
11
11
|
* dynamically, the signer wraps native module SigV4a signer and JS SigV4 signer. It signs the request with SigV4a
|
|
12
12
|
* algorithm if the request needs to be signed with `*` region. Otherwise, it signs the request with normal SigV4
|
|
13
13
|
* signer.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AwsCredentialIdentity } from "@aws-sdk/types";
|
|
2
|
+
import { SignatureV4 } from "@smithy/signature-v4";
|
|
3
|
+
import type { HttpRequest as IHttpRequest, RequestPresigningArguments, RequestSigningArguments } from "@smithy/types";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const SESSION_TOKEN_HEADER: string;
|
|
12
|
+
/**
|
|
13
|
+
* A SignatureV4 signer that supports signing/presigning with alternate credentials.
|
|
14
|
+
* Used for S3 Express session-based auth.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare class SignatureV4SignWithCredentials extends SignatureV4 {
|
|
18
|
+
signWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, options?: RequestSigningArguments): Promise<IHttpRequest>;
|
|
19
|
+
presignWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, options?: RequestPresigningArguments): Promise<IHttpRequest>;
|
|
20
|
+
}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from "./SignatureV4MultiRegion";
|
|
5
|
-
export * from "./signature-v4-crt-container";
|
|
1
|
+
export { type SignatureV4MultiRegionInit, SignatureV4MultiRegion } from "./SignatureV4MultiRegion";
|
|
2
|
+
export { type OptionalCrtSignerV4, signatureV4CrtContainer } from "./signature-v4-crt-container";
|
|
3
|
+
export { SignatureV4SignWithCredentials } from "./SignatureV4SignWithCredentials";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AwsCredentialIdentity } from "@aws-sdk/types";
|
|
2
|
+
import { SignatureV4 } from "@smithy/signature-v4";
|
|
3
|
+
import {
|
|
4
|
+
HttpRequest as IHttpRequest,
|
|
5
|
+
RequestPresigningArguments,
|
|
6
|
+
RequestSigningArguments,
|
|
7
|
+
} from "@smithy/types";
|
|
8
|
+
export declare const SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token";
|
|
9
|
+
export declare const SESSION_TOKEN_HEADER: string;
|
|
10
|
+
export declare class SignatureV4SignWithCredentials extends SignatureV4 {
|
|
11
|
+
signWithCredentials(
|
|
12
|
+
requestToSign: IHttpRequest,
|
|
13
|
+
credentials: AwsCredentialIdentity,
|
|
14
|
+
options?: RequestSigningArguments
|
|
15
|
+
): Promise<IHttpRequest>;
|
|
16
|
+
presignWithCredentials(
|
|
17
|
+
requestToSign: IHttpRequest,
|
|
18
|
+
credentials: AwsCredentialIdentity,
|
|
19
|
+
options?: RequestPresigningArguments
|
|
20
|
+
): Promise<IHttpRequest>;
|
|
21
|
+
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
SignatureV4MultiRegionInit,
|
|
3
|
+
SignatureV4MultiRegion,
|
|
4
|
+
} from "./SignatureV4MultiRegion";
|
|
5
|
+
export {
|
|
6
|
+
OptionalCrtSignerV4,
|
|
7
|
+
signatureV4CrtContainer,
|
|
8
|
+
} from "./signature-v4-crt-container";
|
|
9
|
+
export { SignatureV4SignWithCredentials } from "./SignatureV4SignWithCredentials";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/signature-v4-multi-region",
|
|
3
|
-
"version": "3.996.
|
|
3
|
+
"version": "3.996.26",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline signature-v4-multi-region",
|
|
@@ -25,10 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/middleware-sdk-s3": "^3.972.36",
|
|
29
28
|
"@aws-sdk/types": "^3.973.8",
|
|
30
|
-
"@smithy/
|
|
31
|
-
"@smithy/signature-v4": "^5.
|
|
29
|
+
"@smithy/core": "^3.24.1",
|
|
30
|
+
"@smithy/signature-v4": "^5.4.1",
|
|
32
31
|
"@smithy/types": "^4.14.1",
|
|
33
32
|
"tslib": "^2.6.2"
|
|
34
33
|
},
|