Skip to content

Commit 3386761

Browse files
authored
chore: update presignRequest to presign (#1020)
1 parent 9101892 commit 3386761

File tree

9 files changed

+26
-26
lines changed

9 files changed

+26
-26
lines changed

features/s3/step_definitions/objects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function() {
2020
.then(request => {
2121
const expiration = new Date(Date.now() + 1 * 60 * 60 * 1000);
2222
signer
23-
.presignRequest(request, expiration)
23+
.presign(request, expiration)
2424
.then(data => {
2525
callback(null, formatUrl(data));
2626
})

packages/middleware-sdk-ec2/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function copySnapshotPresignedUrlMiddleware(
6262
sha256: options.sha256,
6363
uriEscapePath: options.signingEscapePath
6464
});
65-
const presignedRequest = await signer.presignRequest(
65+
const presignedRequest = await signer.presign(
6666
request,
6767
expirationTime(3600)
6868
);

packages/middleware-sdk-rds/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function crossRegionPresignedUrlMiddleware(
9797
sha256: options.sha256,
9898
uriEscapePath: options.signingEscapePath
9999
});
100-
const presignedRequest = await signer.presignRequest(
100+
const presignedRequest = await signer.presign(
101101
request,
102102
expirationTime(3600)
103103
);

packages/s3-request-presigner/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const signer = new S3Presigner({
1818
});
1919
const Day = 24 * 60 * 60 * 1000;
2020
const expiration = new Date(Date.now() + 1 * Day);
21-
const url = signer.presignRequest(request, expiration);
21+
const url = signer.presign(request, expiration);
2222
```
2323

2424
Typescript Example:
@@ -34,7 +34,7 @@ const signer = new S3RequestPresigner({
3434
});
3535
const Day = 24 * 60 * 60 * 1000;
3636
const expiration = new Date(Date.now() + 1 * Day);
37-
const url = signer.presignRequest(request, expiration);
37+
const url = signer.presign(request, expiration);
3838
```
3939

4040
To avoid redundant construction parameters when instantiate the s3 presigner,

packages/s3-request-presigner/src/index.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe("s3 presigner", () => {
4141

4242
it("should not double uri encode the path", async () => {
4343
const signer = new S3RequestPresigner(s3ResolvedConfig);
44-
const signed = await signer.presignRequest(
44+
const signed = await signer.presign(
4545
minimalRequest,
4646
expiration,
4747
presigningOptions
@@ -51,7 +51,7 @@ describe("s3 presigner", () => {
5151

5252
it("should set the body digest to 'UNSIGNED_PAYLOAD'", async () => {
5353
const signer = new S3RequestPresigner(s3ResolvedConfig);
54-
const signed = await signer.presignRequest(
54+
const signed = await signer.presign(
5555
minimalRequest,
5656
expiration,
5757
presigningOptions
@@ -62,7 +62,7 @@ describe("s3 presigner", () => {
6262
it("should not change original request", async () => {
6363
const signer = new S3RequestPresigner(s3ResolvedConfig);
6464
const originalRequest = { ...minimalRequest };
65-
const signed = await signer.presignRequest(
65+
const signed = await signer.presign(
6666
minimalRequest,
6767
expiration,
6868
presigningOptions
@@ -87,7 +87,7 @@ describe("s3 presigner", () => {
8787
"Content-Type": "application/octet-stream"
8888
}
8989
};
90-
const signed = await signer.presignRequest(
90+
const signed = await signer.presign(
9191
requestWithContentTypeHeader,
9292
expiration,
9393
presigningOptions

packages/s3-request-presigner/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ export class S3RequestPresigner implements RequestPresigner {
3636
this.signer = new SignatureV4(resolvedOptions);
3737
}
3838

39-
public async presignRequest(
39+
public async presign(
4040
requestToSign: IHttpRequest,
4141
expiration: DateInput,
4242
{ unsignableHeaders = new Set(), ...options }: RequestSigningArguments = {}
4343
): Promise<IHttpRequest> {
4444
unsignableHeaders.add("content-type");
4545
requestToSign.headers[SHA256_HEADER] = UNSIGNED_PAYLOAD;
46-
return this.signer.presignRequest(requestToSign, expiration, {
46+
return this.signer.presign(requestToSign, expiration, {
4747
unsignableHeaders,
4848
...options
4949
});

packages/signature-v4/src/SignatureV4.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe("SignatureV4", () => {
5454
};
5555

5656
it("should sign requests without bodies", async () => {
57-
const { query } = await signer.presignRequest(
57+
const { query } = await signer.presign(
5858
minimalRequest,
5959
expiration,
6060
presigningOptions
@@ -71,7 +71,7 @@ describe("SignatureV4", () => {
7171
});
7272

7373
it("should sign requests with string bodies", async () => {
74-
const { query } = await signer.presignRequest(
74+
const { query } = await signer.presign(
7575
new HttpRequest({
7676
...minimalRequest,
7777
body: "It was the best of times, it was the worst of times"
@@ -91,7 +91,7 @@ describe("SignatureV4", () => {
9191
});
9292

9393
it("should sign requests with binary bodies", async () => {
94-
const { query } = await signer.presignRequest(
94+
const { query } = await signer.presign(
9595
new HttpRequest({
9696
...minimalRequest,
9797
body: new Uint8Array([0xde, 0xad, 0xbe, 0xef])
@@ -116,7 +116,7 @@ describe("SignatureV4", () => {
116116
*/
117117
class ExoticStream {}
118118

119-
const { query } = await signer.presignRequest(
119+
const { query } = await signer.presign(
120120
new HttpRequest({
121121
...minimalRequest,
122122
body: new ExoticStream() as any
@@ -145,7 +145,7 @@ describe("SignatureV4", () => {
145145
sessionToken: "baz"
146146
}
147147
});
148-
const { query } = await signer.presignRequest(
148+
const { query } = await signer.presign(
149149
minimalRequest,
150150
expiration,
151151
presigningOptions
@@ -171,7 +171,7 @@ describe("SignatureV4", () => {
171171
credentials
172172
});
173173

174-
const { query } = await signer.presignRequest(
174+
const { query } = await signer.presign(
175175
new HttpRequest({
176176
...minimalRequest,
177177
body: new Uint8Array([0xde, 0xad, 0xbe, 0xef]),
@@ -202,7 +202,7 @@ describe("SignatureV4", () => {
202202
foo: "bar",
203203
"user-agent": "baz"
204204
};
205-
const { headers: headersAsSigned, query } = await signer.presignRequest(
205+
const { headers: headersAsSigned, query } = await signer.presign(
206206
new HttpRequest({
207207
...minimalRequest,
208208
headers
@@ -219,7 +219,7 @@ describe("SignatureV4", () => {
219219

220220
it("should return a rejected promise if the expiration is more than one week in the future", async () => {
221221
await expect(
222-
signer.presignRequest(minimalRequest, new Date(), presigningOptions)
222+
signer.presign(minimalRequest, new Date(), presigningOptions)
223223
).rejects.toMatch(/less than one week in the future/);
224224
});
225225

@@ -237,7 +237,7 @@ describe("SignatureV4", () => {
237237
credentials: credsProvider
238238
});
239239

240-
const { query } = await signer.presignRequest(
240+
const { query } = await signer.presign(
241241
minimalRequest,
242242
expiration,
243243
presigningOptions
@@ -261,7 +261,7 @@ describe("SignatureV4", () => {
261261
}
262262
});
263263

264-
const { query } = await signer.presignRequest(
264+
const { query } = await signer.presign(
265265
minimalRequest,
266266
expiration,
267267
presigningOptions
@@ -284,7 +284,7 @@ describe("SignatureV4", () => {
284284
});
285285

286286
it("should URI-encode the path by default", async () => {
287-
const { query = {} } = await signer.presignRequest(
287+
const { query = {} } = await signer.presign(
288288
minimalRequest,
289289
expiration,
290290
presigningOptions
@@ -311,7 +311,7 @@ describe("SignatureV4", () => {
311311
uriEscapePath: false
312312
});
313313

314-
const { query = {} } = await signer.presignRequest(
314+
const { query = {} } = await signer.presign(
315315
new HttpRequest({
316316
...minimalRequest,
317317
path: "/foo/bar/baz",
@@ -661,7 +661,7 @@ describe("SignatureV4", () => {
661661

662662
it("should use the current date for presigning if no signing date was supplied", async () => {
663663
const date = new Date();
664-
const { query } = await signer.presignRequest(
664+
const { query } = await signer.presign(
665665
minimalRequest,
666666
Math.floor((date.valueOf() + 60 * 60 * 1000) / 1000)
667667
);

packages/signature-v4/src/SignatureV4.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class SignatureV4
127127
}
128128
}
129129

130-
public async presignRequest(
130+
public async presign(
131131
originalRequest: HttpRequest,
132132
expiration: DateInput,
133133
options: RequestSigningArguments = {}

packages/types/src/signature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface RequestPresigner {
5151
* longer be honored.
5252
* @param options Additional signing options.
5353
*/
54-
presignRequest(
54+
presign(
5555
requestToSign: HttpRequest,
5656
expiration: DateInput,
5757
options?: RequestSigningArguments

0 commit comments

Comments
 (0)