@smithy/signature-v4 4.2.3 → 5.0.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.
- package/dist-cjs/index.js +16 -14
- package/dist-types/SignatureV4.d.ts +9 -0
- package/dist-types/credentialDerivation.d.ts +13 -9
- package/dist-types/getCanonicalHeaders.d.ts +1 -1
- package/dist-types/getCanonicalQuery.d.ts +1 -1
- package/dist-types/getPayloadHash.d.ts +1 -1
- package/dist-types/moveHeadersToQuery.d.ts +1 -1
- package/dist-types/prepareRequest.d.ts +1 -1
- package/dist-types/ts3.4/SignatureV4.d.ts +9 -0
- package/dist-types/ts3.4/credentialDerivation.d.ts +13 -9
- package/dist-types/ts3.4/getCanonicalHeaders.d.ts +1 -1
- package/dist-types/ts3.4/getCanonicalQuery.d.ts +1 -1
- package/dist-types/ts3.4/getPayloadHash.d.ts +1 -1
- package/dist-types/ts3.4/moveHeadersToQuery.d.ts +1 -1
- package/dist-types/ts3.4/prepareRequest.d.ts +1 -1
- package/package.json +9 -9
package/dist-cjs/index.js
CHANGED
|
@@ -121,7 +121,7 @@ var getCanonicalHeaders = /* @__PURE__ */ __name(({ headers }, unsignableHeaders
|
|
|
121
121
|
continue;
|
|
122
122
|
}
|
|
123
123
|
const canonicalHeaderName = headerName.toLowerCase();
|
|
124
|
-
if (canonicalHeaderName in ALWAYS_UNSIGNABLE_HEADERS ||
|
|
124
|
+
if (canonicalHeaderName in ALWAYS_UNSIGNABLE_HEADERS || unsignableHeaders?.has(canonicalHeaderName) || PROXY_HEADER_PATTERN.test(canonicalHeaderName) || SEC_HEADER_PATTERN.test(canonicalHeaderName)) {
|
|
125
125
|
if (!signableHeaders || signableHeaders && !signableHeaders.has(canonicalHeaderName)) {
|
|
126
126
|
continue;
|
|
127
127
|
}
|
|
@@ -175,7 +175,10 @@ var getPayloadHash = /* @__PURE__ */ __name(async ({ headers, body }, hashConstr
|
|
|
175
175
|
// src/HeaderFormatter.ts
|
|
176
176
|
|
|
177
177
|
var import_util_utf83 = require("@smithy/util-utf8");
|
|
178
|
-
var
|
|
178
|
+
var HeaderFormatter = class {
|
|
179
|
+
static {
|
|
180
|
+
__name(this, "HeaderFormatter");
|
|
181
|
+
}
|
|
179
182
|
format(headers) {
|
|
180
183
|
const chunks = [];
|
|
181
184
|
for (const headerName of Object.keys(headers)) {
|
|
@@ -242,16 +245,17 @@ var _HeaderFormatter = class _HeaderFormatter {
|
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
247
|
};
|
|
245
|
-
__name(_HeaderFormatter, "HeaderFormatter");
|
|
246
|
-
var HeaderFormatter = _HeaderFormatter;
|
|
247
248
|
var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
248
|
-
var
|
|
249
|
+
var Int64 = class _Int64 {
|
|
249
250
|
constructor(bytes) {
|
|
250
251
|
this.bytes = bytes;
|
|
251
252
|
if (bytes.byteLength !== 8) {
|
|
252
253
|
throw new Error("Int64 buffers must be exactly 8 bytes");
|
|
253
254
|
}
|
|
254
255
|
}
|
|
256
|
+
static {
|
|
257
|
+
__name(this, "Int64");
|
|
258
|
+
}
|
|
255
259
|
static fromNumber(number) {
|
|
256
260
|
if (number > 9223372036854776e3 || number < -9223372036854776e3) {
|
|
257
261
|
throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
|
|
@@ -280,8 +284,6 @@ var _Int64 = class _Int64 {
|
|
|
280
284
|
return String(this.valueOf());
|
|
281
285
|
}
|
|
282
286
|
};
|
|
283
|
-
__name(_Int64, "Int64");
|
|
284
|
-
var Int64 = _Int64;
|
|
285
287
|
function negate(bytes) {
|
|
286
288
|
for (let i = 0; i < 8; i++) {
|
|
287
289
|
bytes[i] ^= 255;
|
|
@@ -308,11 +310,10 @@ var hasHeader = /* @__PURE__ */ __name((soughtHeader, headers) => {
|
|
|
308
310
|
// src/moveHeadersToQuery.ts
|
|
309
311
|
var import_protocol_http = require("@smithy/protocol-http");
|
|
310
312
|
var moveHeadersToQuery = /* @__PURE__ */ __name((request, options = {}) => {
|
|
311
|
-
var _a, _b;
|
|
312
313
|
const { headers, query = {} } = import_protocol_http.HttpRequest.clone(request);
|
|
313
314
|
for (const name of Object.keys(headers)) {
|
|
314
315
|
const lname = name.toLowerCase();
|
|
315
|
-
if (lname.slice(0, 6) === "x-amz-" && !
|
|
316
|
+
if (lname.slice(0, 6) === "x-amz-" && !options.unhoistableHeaders?.has(lname) || options.hoistableHeaders?.has(lname)) {
|
|
316
317
|
query[name] = headers[name];
|
|
317
318
|
delete headers[name];
|
|
318
319
|
}
|
|
@@ -352,7 +353,7 @@ var toDate = /* @__PURE__ */ __name((time) => {
|
|
|
352
353
|
}, "toDate");
|
|
353
354
|
|
|
354
355
|
// src/SignatureV4.ts
|
|
355
|
-
var
|
|
356
|
+
var SignatureV4 = class {
|
|
356
357
|
constructor({
|
|
357
358
|
applyChecksum,
|
|
358
359
|
credentials,
|
|
@@ -369,6 +370,9 @@ var _SignatureV4 = class _SignatureV4 {
|
|
|
369
370
|
this.regionProvider = (0, import_util_middleware.normalizeProvider)(region);
|
|
370
371
|
this.credentialProvider = (0, import_util_middleware.normalizeProvider)(credentials);
|
|
371
372
|
}
|
|
373
|
+
static {
|
|
374
|
+
__name(this, "SignatureV4");
|
|
375
|
+
}
|
|
372
376
|
async presign(originalRequest, options = {}) {
|
|
373
377
|
const {
|
|
374
378
|
signingDate = /* @__PURE__ */ new Date(),
|
|
@@ -517,7 +521,7 @@ ${(0, import_util_hex_encoding.toHex)(hashedRequest)}`;
|
|
|
517
521
|
if (this.uriEscapePath) {
|
|
518
522
|
const normalizedPathSegments = [];
|
|
519
523
|
for (const pathSegment of path.split("/")) {
|
|
520
|
-
if (
|
|
524
|
+
if (pathSegment?.length === 0)
|
|
521
525
|
continue;
|
|
522
526
|
if (pathSegment === ".")
|
|
523
527
|
continue;
|
|
@@ -527,7 +531,7 @@ ${(0, import_util_hex_encoding.toHex)(hashedRequest)}`;
|
|
|
527
531
|
normalizedPathSegments.push(pathSegment);
|
|
528
532
|
}
|
|
529
533
|
}
|
|
530
|
-
const normalizedPath = `${
|
|
534
|
+
const normalizedPath = `${path?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path?.endsWith("/") ? "/" : ""}`;
|
|
531
535
|
const doubleEncoded = (0, import_util_uri_escape.escapeUri)(normalizedPath);
|
|
532
536
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
533
537
|
}
|
|
@@ -550,8 +554,6 @@ ${(0, import_util_hex_encoding.toHex)(hashedRequest)}`;
|
|
|
550
554
|
}
|
|
551
555
|
}
|
|
552
556
|
};
|
|
553
|
-
__name(_SignatureV4, "SignatureV4");
|
|
554
|
-
var SignatureV4 = _SignatureV4;
|
|
555
557
|
var formatDate = /* @__PURE__ */ __name((now) => {
|
|
556
558
|
const longDate = iso8601(now).replace(/[\-:]/g, "");
|
|
557
559
|
return {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AwsCredentialIdentity, ChecksumConstructor, EventSigner, EventSigningArguments, FormattedEvent, HashConstructor, HttpRequest, MessageSigner, Provider, RequestPresigner, RequestPresigningArguments, RequestSigner, RequestSigningArguments, SignableMessage, SignedMessage, SigningArguments, StringSigner } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
2
5
|
export interface SignatureV4Init {
|
|
3
6
|
/**
|
|
4
7
|
* The service signing name.
|
|
@@ -37,9 +40,15 @@ export interface SignatureV4Init {
|
|
|
37
40
|
*/
|
|
38
41
|
applyChecksum?: boolean;
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
40
46
|
export interface SignatureV4CryptoInit {
|
|
41
47
|
sha256: ChecksumConstructor | HashConstructor;
|
|
42
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
43
52
|
export declare class SignatureV4 implements RequestPresigner, RequestSigner, StringSigner, EventSigner, MessageSigner {
|
|
44
53
|
private readonly service;
|
|
45
54
|
private readonly regionProvider;
|
|
@@ -2,21 +2,25 @@ import { AwsCredentialIdentity, ChecksumConstructor, HashConstructor } from "@sm
|
|
|
2
2
|
/**
|
|
3
3
|
* Create a string describing the scope of credentials used to sign a request.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
5
|
+
* @internal
|
|
6
|
+
*
|
|
7
|
+
* @param shortDate - the current calendar date in the form YYYYMMDD.
|
|
8
|
+
* @param region - the AWS region in which the service resides.
|
|
9
|
+
* @param service - the service to which the signed request is being sent.
|
|
8
10
|
*/
|
|
9
11
|
export declare const createScope: (shortDate: string, region: string, service: string) => string;
|
|
10
12
|
/**
|
|
11
|
-
* Derive a signing key from its composite parts
|
|
13
|
+
* Derive a signing key from its composite parts.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
12
16
|
*
|
|
13
|
-
* @param sha256Constructor
|
|
17
|
+
* @param sha256Constructor - a constructor function that can instantiate SHA-256
|
|
14
18
|
* hash objects.
|
|
15
|
-
* @param credentials
|
|
19
|
+
* @param credentials - the credentials with which the request will be
|
|
16
20
|
* signed.
|
|
17
|
-
* @param shortDate
|
|
18
|
-
* @param region
|
|
19
|
-
* @param service
|
|
21
|
+
* @param shortDate - the current calendar date in the form YYYYMMDD.
|
|
22
|
+
* @param region - the AWS region in which the service resides.
|
|
23
|
+
* @param service - the service to which the signed request is being
|
|
20
24
|
* sent.
|
|
21
25
|
*/
|
|
22
26
|
export declare const getSigningKey: (sha256Constructor: ChecksumConstructor | HashConstructor, credentials: AwsCredentialIdentity, shortDate: string, region: string, service: string) => Promise<Uint8Array>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AwsCredentialIdentity, ChecksumConstructor, EventSigner, EventSigningArguments, FormattedEvent, HashConstructor, HttpRequest, MessageSigner, Provider, RequestPresigner, RequestPresigningArguments, RequestSigner, RequestSigningArguments, SignableMessage, SignedMessage, SigningArguments, StringSigner } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
2
5
|
export interface SignatureV4Init {
|
|
3
6
|
/**
|
|
4
7
|
* The service signing name.
|
|
@@ -37,9 +40,15 @@ export interface SignatureV4Init {
|
|
|
37
40
|
*/
|
|
38
41
|
applyChecksum?: boolean;
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
40
46
|
export interface SignatureV4CryptoInit {
|
|
41
47
|
sha256: ChecksumConstructor | HashConstructor;
|
|
42
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
43
52
|
export declare class SignatureV4 implements RequestPresigner, RequestSigner, StringSigner, EventSigner, MessageSigner {
|
|
44
53
|
private readonly service;
|
|
45
54
|
private readonly regionProvider;
|
|
@@ -2,21 +2,25 @@ import { AwsCredentialIdentity, ChecksumConstructor, HashConstructor } from "@sm
|
|
|
2
2
|
/**
|
|
3
3
|
* Create a string describing the scope of credentials used to sign a request.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
5
|
+
* @internal
|
|
6
|
+
*
|
|
7
|
+
* @param shortDate - the current calendar date in the form YYYYMMDD.
|
|
8
|
+
* @param region - the AWS region in which the service resides.
|
|
9
|
+
* @param service - the service to which the signed request is being sent.
|
|
8
10
|
*/
|
|
9
11
|
export declare const createScope: (shortDate: string, region: string, service: string) => string;
|
|
10
12
|
/**
|
|
11
|
-
* Derive a signing key from its composite parts
|
|
13
|
+
* Derive a signing key from its composite parts.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
12
16
|
*
|
|
13
|
-
* @param sha256Constructor
|
|
17
|
+
* @param sha256Constructor - a constructor function that can instantiate SHA-256
|
|
14
18
|
* hash objects.
|
|
15
|
-
* @param credentials
|
|
19
|
+
* @param credentials - the credentials with which the request will be
|
|
16
20
|
* signed.
|
|
17
|
-
* @param shortDate
|
|
18
|
-
* @param region
|
|
19
|
-
* @param service
|
|
21
|
+
* @param shortDate - the current calendar date in the form YYYYMMDD.
|
|
22
|
+
* @param region - the AWS region in which the service resides.
|
|
23
|
+
* @param service - the service to which the signed request is being
|
|
20
24
|
* sent.
|
|
21
25
|
*/
|
|
22
26
|
export declare const getSigningKey: (sha256Constructor: ChecksumConstructor | HashConstructor, credentials: AwsCredentialIdentity, shortDate: string, region: string, service: string) => Promise<Uint8Array>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/signature-v4",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "A standalone implementation of the AWS Signature V4 request signing algorithm",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@smithy/is-array-buffer": "^
|
|
29
|
-
"@smithy/protocol-http": "^
|
|
30
|
-
"@smithy/types": "^
|
|
31
|
-
"@smithy/util-hex-encoding": "^
|
|
32
|
-
"@smithy/util-middleware": "^
|
|
33
|
-
"@smithy/util-uri-escape": "^
|
|
34
|
-
"@smithy/util-utf8": "^
|
|
28
|
+
"@smithy/is-array-buffer": "^4.0.0",
|
|
29
|
+
"@smithy/protocol-http": "^5.0.0",
|
|
30
|
+
"@smithy/types": "^4.0.0",
|
|
31
|
+
"@smithy/util-hex-encoding": "^4.0.0",
|
|
32
|
+
"@smithy/util-middleware": "^4.0.0",
|
|
33
|
+
"@smithy/util-uri-escape": "^4.0.0",
|
|
34
|
+
"@smithy/util-utf8": "^4.0.0",
|
|
35
35
|
"tslib": "^2.6.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"typedoc": "0.23.23"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
45
|
+
"node": ">=18.0.0"
|
|
46
46
|
},
|
|
47
47
|
"typesVersions": {
|
|
48
48
|
"<4.0": {
|