@aws-sdk/signature-v4-multi-region 3.489.0 → 3.496.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.
|
@@ -1,67 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignatureV4MultiRegion = void 0;
|
|
4
|
-
const middleware_sdk_s3_1 = require("@aws-sdk/middleware-sdk-s3");
|
|
5
|
-
const signature_v4_crt_container_1 = require("./signature-v4-crt-container");
|
|
6
|
-
class SignatureV4MultiRegion {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
this.sigv4Signer = new middleware_sdk_s3_1.SignatureV4S3Express(options);
|
|
9
|
-
this.signerOptions = options;
|
|
10
|
-
}
|
|
11
|
-
async sign(requestToSign, options = {}) {
|
|
12
|
-
if (options.signingRegion === "*") {
|
|
13
|
-
if (this.signerOptions.runtime !== "node")
|
|
14
|
-
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
15
|
-
return this.getSigv4aSigner().sign(requestToSign, options);
|
|
16
|
-
}
|
|
17
|
-
return this.sigv4Signer.sign(requestToSign, options);
|
|
18
|
-
}
|
|
19
|
-
async signWithCredentials(requestToSign, credentials, options = {}) {
|
|
20
|
-
if (options.signingRegion === "*") {
|
|
21
|
-
if (this.signerOptions.runtime !== "node")
|
|
22
|
-
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
23
|
-
return this.getSigv4aSigner().signWithCredentials(requestToSign, credentials, options);
|
|
24
|
-
}
|
|
25
|
-
return this.sigv4Signer.signWithCredentials(requestToSign, credentials, options);
|
|
26
|
-
}
|
|
27
|
-
async presign(originalRequest, options = {}) {
|
|
28
|
-
if (options.signingRegion === "*") {
|
|
29
|
-
if (this.signerOptions.runtime !== "node")
|
|
30
|
-
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
31
|
-
return this.getSigv4aSigner().presign(originalRequest, options);
|
|
32
|
-
}
|
|
33
|
-
return this.sigv4Signer.presign(originalRequest, options);
|
|
34
|
-
}
|
|
35
|
-
async presignWithCredentials(originalRequest, credentials, options = {}) {
|
|
36
|
-
if (options.signingRegion === "*") {
|
|
37
|
-
throw new Error("Method presignWithCredentials is not supported for [signingRegion=*].");
|
|
38
|
-
}
|
|
39
|
-
return this.sigv4Signer.presignWithCredentials(originalRequest, credentials, options);
|
|
40
|
-
}
|
|
41
|
-
getSigv4aSigner() {
|
|
42
|
-
if (!this.sigv4aSigner) {
|
|
43
|
-
let CrtSignerV4 = null;
|
|
44
|
-
try {
|
|
45
|
-
CrtSignerV4 = signature_v4_crt_container_1.signatureV4CrtContainer.CrtSignerV4;
|
|
46
|
-
if (typeof CrtSignerV4 !== "function")
|
|
47
|
-
throw new Error();
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
e.message =
|
|
51
|
-
`${e.message}\n` +
|
|
52
|
-
`Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. \n` +
|
|
53
|
-
`You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] ` +
|
|
54
|
-
`or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. \n` +
|
|
55
|
-
"For more information please go to " +
|
|
56
|
-
"https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt";
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
this.sigv4aSigner = new CrtSignerV4({
|
|
60
|
-
...this.signerOptions,
|
|
61
|
-
signingAlgorithm: 1,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return this.sigv4aSigner;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.SignatureV4MultiRegion = SignatureV4MultiRegion;
|
|
1
|
+
module.exports = require("./index.js");
|
package/dist-cjs/index.js
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
SignatureV4MultiRegion: () => SignatureV4MultiRegion,
|
|
24
|
+
signatureV4CrtContainer: () => signatureV4CrtContainer
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/SignatureV4MultiRegion.ts
|
|
29
|
+
var import_middleware_sdk_s3 = require("@aws-sdk/middleware-sdk-s3");
|
|
30
|
+
|
|
31
|
+
// src/signature-v4-crt-container.ts
|
|
32
|
+
var signatureV4CrtContainer = {
|
|
33
|
+
CrtSignerV4: null
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/SignatureV4MultiRegion.ts
|
|
37
|
+
var _SignatureV4MultiRegion = class _SignatureV4MultiRegion {
|
|
38
|
+
constructor(options) {
|
|
39
|
+
this.sigv4Signer = new import_middleware_sdk_s3.SignatureV4S3Express(options);
|
|
40
|
+
this.signerOptions = options;
|
|
41
|
+
}
|
|
42
|
+
async sign(requestToSign, options = {}) {
|
|
43
|
+
if (options.signingRegion === "*") {
|
|
44
|
+
if (this.signerOptions.runtime !== "node")
|
|
45
|
+
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
46
|
+
return this.getSigv4aSigner().sign(requestToSign, options);
|
|
47
|
+
}
|
|
48
|
+
return this.sigv4Signer.sign(requestToSign, options);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sign with alternate credentials to the ones provided in the constructor.
|
|
52
|
+
*/
|
|
53
|
+
async signWithCredentials(requestToSign, credentials, options = {}) {
|
|
54
|
+
if (options.signingRegion === "*") {
|
|
55
|
+
if (this.signerOptions.runtime !== "node")
|
|
56
|
+
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
57
|
+
return this.getSigv4aSigner().signWithCredentials(requestToSign, credentials, options);
|
|
58
|
+
}
|
|
59
|
+
return this.sigv4Signer.signWithCredentials(requestToSign, credentials, options);
|
|
60
|
+
}
|
|
61
|
+
async presign(originalRequest, options = {}) {
|
|
62
|
+
if (options.signingRegion === "*") {
|
|
63
|
+
if (this.signerOptions.runtime !== "node")
|
|
64
|
+
throw new Error("This request requires signing with SigV4Asymmetric algorithm. It's only available in Node.js");
|
|
65
|
+
return this.getSigv4aSigner().presign(originalRequest, options);
|
|
66
|
+
}
|
|
67
|
+
return this.sigv4Signer.presign(originalRequest, options);
|
|
68
|
+
}
|
|
69
|
+
async presignWithCredentials(originalRequest, credentials, options = {}) {
|
|
70
|
+
if (options.signingRegion === "*") {
|
|
71
|
+
throw new Error("Method presignWithCredentials is not supported for [signingRegion=*].");
|
|
72
|
+
}
|
|
73
|
+
return this.sigv4Signer.presignWithCredentials(originalRequest, credentials, options);
|
|
74
|
+
}
|
|
75
|
+
getSigv4aSigner() {
|
|
76
|
+
if (!this.sigv4aSigner) {
|
|
77
|
+
let CrtSignerV4 = null;
|
|
78
|
+
try {
|
|
79
|
+
CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4;
|
|
80
|
+
if (typeof CrtSignerV4 !== "function")
|
|
81
|
+
throw new Error();
|
|
82
|
+
} catch (e) {
|
|
83
|
+
e.message = `${e.message}
|
|
84
|
+
Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly.
|
|
85
|
+
You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";].
|
|
86
|
+
For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`;
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
this.sigv4aSigner = new CrtSignerV4({
|
|
90
|
+
...this.signerOptions,
|
|
91
|
+
signingAlgorithm: 1
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return this.sigv4aSigner;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
__name(_SignatureV4MultiRegion, "SignatureV4MultiRegion");
|
|
98
|
+
var SignatureV4MultiRegion = _SignatureV4MultiRegion;
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
SignatureV4MultiRegion,
|
|
103
|
+
signatureV4CrtContainer
|
|
104
|
+
});
|
|
105
|
+
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/signature-v4-multi-region",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.496.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
6
|
-
"build:cjs": "
|
|
6
|
+
"build:cjs": "node ../../scripts/compilation/inline signature-v4-multi-region",
|
|
7
7
|
"build:es": "tsc -p tsconfig.es.json",
|
|
8
8
|
"build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
|
|
9
9
|
"build:types": "tsc -p tsconfig.types.json",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/middleware-sdk-s3": "3.
|
|
24
|
-
"@aws-sdk/types": "3.
|
|
25
|
-
"@smithy/protocol-http": "^3.
|
|
26
|
-
"@smithy/signature-v4": "^2.
|
|
27
|
-
"@smithy/types": "^2.
|
|
23
|
+
"@aws-sdk/middleware-sdk-s3": "3.496.0",
|
|
24
|
+
"@aws-sdk/types": "3.496.0",
|
|
25
|
+
"@smithy/protocol-http": "^3.1.1",
|
|
26
|
+
"@smithy/signature-v4": "^2.1.1",
|
|
27
|
+
"@smithy/types": "^2.9.1",
|
|
28
28
|
"tslib": "^2.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|