@aws-sdk/s3-request-presigner
Advanced tools
Comparing version 3.254.0 to 3.481.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSignedUrl = void 0; | ||
const middleware_endpoint_1 = require("@aws-sdk/middleware-endpoint"); | ||
const protocol_http_1 = require("@aws-sdk/protocol-http"); | ||
const util_format_url_1 = require("@aws-sdk/util-format-url"); | ||
const middleware_endpoint_1 = require("@smithy/middleware-endpoint"); | ||
const protocol_http_1 = require("@smithy/protocol-http"); | ||
const presigner_1 = require("./presigner"); | ||
@@ -32,7 +32,14 @@ const getSignedUrl = async (client, command, options = {}) => { | ||
delete request.headers["x-amz-user-agent"]; | ||
const presigned = await s3Presigner.presign(request, { | ||
let presigned; | ||
const presignerOptions = { | ||
...options, | ||
signingRegion: (_a = options.signingRegion) !== null && _a !== void 0 ? _a : context["signing_region"], | ||
signingService: (_b = options.signingService) !== null && _b !== void 0 ? _b : context["signing_service"], | ||
}); | ||
}; | ||
if (context.s3ExpressIdentity) { | ||
presigned = await s3Presigner.presignWithCredentials(request, context.s3ExpressIdentity, presignerOptions); | ||
} | ||
else { | ||
presigned = await s3Presigner.presign(request, presignerOptions); | ||
} | ||
return { | ||
@@ -39,0 +46,0 @@ response: {}, |
@@ -17,2 +17,26 @@ "use strict"; | ||
presign(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) { | ||
this.prepareRequest(requestToSign, { | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
}); | ||
return this.signer.presign(requestToSign, { | ||
expiresIn: 900, | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
...options, | ||
}); | ||
} | ||
presignWithCredentials(requestToSign, credentials, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) { | ||
this.prepareRequest(requestToSign, { | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
}); | ||
return this.signer.presignWithCredentials(requestToSign, credentials, { | ||
expiresIn: 900, | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
...options, | ||
}); | ||
} | ||
prepareRequest(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set() } = {}) { | ||
unsignableHeaders.add("content-type"); | ||
@@ -32,10 +56,4 @@ Object.keys(requestToSign.headers) | ||
} | ||
return this.signer.presign(requestToSign, { | ||
expiresIn: 900, | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
...options, | ||
}); | ||
} | ||
} | ||
exports.S3RequestPresigner = S3RequestPresigner; |
@@ -1,4 +0,4 @@ | ||
import { getEndpointFromInstructions } from "@aws-sdk/middleware-endpoint"; | ||
import { HttpRequest } from "@aws-sdk/protocol-http"; | ||
import { formatUrl } from "@aws-sdk/util-format-url"; | ||
import { getEndpointFromInstructions } from "@smithy/middleware-endpoint"; | ||
import { HttpRequest } from "@smithy/protocol-http"; | ||
import { S3RequestPresigner } from "./presigner"; | ||
@@ -27,7 +27,14 @@ export const getSignedUrl = async (client, command, options = {}) => { | ||
delete request.headers["x-amz-user-agent"]; | ||
const presigned = await s3Presigner.presign(request, { | ||
let presigned; | ||
const presignerOptions = { | ||
...options, | ||
signingRegion: options.signingRegion ?? context["signing_region"], | ||
signingService: options.signingService ?? context["signing_service"], | ||
}); | ||
}; | ||
if (context.s3ExpressIdentity) { | ||
presigned = await s3Presigner.presignWithCredentials(request, context.s3ExpressIdentity, presignerOptions); | ||
} | ||
else { | ||
presigned = await s3Presigner.presign(request, presignerOptions); | ||
} | ||
return { | ||
@@ -34,0 +41,0 @@ response: {}, |
@@ -14,2 +14,26 @@ import { SignatureV4MultiRegion } from "@aws-sdk/signature-v4-multi-region"; | ||
presign(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) { | ||
this.prepareRequest(requestToSign, { | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
}); | ||
return this.signer.presign(requestToSign, { | ||
expiresIn: 900, | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
...options, | ||
}); | ||
} | ||
presignWithCredentials(requestToSign, credentials, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) { | ||
this.prepareRequest(requestToSign, { | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
}); | ||
return this.signer.presignWithCredentials(requestToSign, credentials, { | ||
expiresIn: 900, | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
...options, | ||
}); | ||
} | ||
prepareRequest(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set() } = {}) { | ||
unsignableHeaders.add("content-type"); | ||
@@ -29,9 +53,3 @@ Object.keys(requestToSign.headers) | ||
} | ||
return this.signer.presign(requestToSign, { | ||
expiresIn: 900, | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
...options, | ||
}); | ||
} | ||
} |
@@ -1,3 +0,6 @@ | ||
import { Client, Command } from "@aws-sdk/smithy-client"; | ||
import { MetadataBearer, RequestPresigningArguments } from "@aws-sdk/types"; | ||
import { Client, Command } from "@smithy/smithy-client"; | ||
import { MetadataBearer, RequestPresigningArguments } from "@smithy/types"; | ||
/** | ||
* @public | ||
*/ | ||
export declare const getSignedUrl: <InputTypesUnion extends object, InputType extends InputTypesUnion, OutputType extends MetadataBearer = MetadataBearer>(client: Client<any, InputTypesUnion, MetadataBearer, any>, command: Command<InputType, OutputType, any, InputTypesUnion, MetadataBearer>, options?: RequestPresigningArguments) => Promise<string>; |
import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region"; | ||
import { RequestPresigner, RequestPresigningArguments } from "@aws-sdk/types"; | ||
import { HttpRequest as IHttpRequest } from "@aws-sdk/types"; | ||
declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
export declare type S3RequestPresignerOptions = PartialBy<SignatureV4MultiRegionInit, "service" | "uriEscapePath"> & { | ||
import { AwsCredentialIdentity, RequestPresigner, RequestPresigningArguments } from "@smithy/types"; | ||
import { HttpRequest as IHttpRequest } from "@smithy/types"; | ||
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
export type S3RequestPresignerOptions = PartialBy<SignatureV4MultiRegionInit, "service" | "uriEscapePath"> & { | ||
signingName?: string; | ||
@@ -12,3 +12,5 @@ }; | ||
presign(requestToSign: IHttpRequest, { unsignableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>; | ||
presignWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, { unsignableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>; | ||
private prepareRequest; | ||
} | ||
export {}; |
@@ -1,3 +0,3 @@ | ||
import { Client, Command } from "@aws-sdk/smithy-client"; | ||
import { MetadataBearer, RequestPresigningArguments } from "@aws-sdk/types"; | ||
import { Client, Command } from "@smithy/smithy-client"; | ||
import { MetadataBearer, RequestPresigningArguments } from "@smithy/types"; | ||
export declare const getSignedUrl: < | ||
@@ -4,0 +4,0 @@ InputTypesUnion extends object, |
import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region"; | ||
import { RequestPresigner, RequestPresigningArguments } from "@aws-sdk/types"; | ||
import { HttpRequest as IHttpRequest } from "@aws-sdk/types"; | ||
declare type PartialBy<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & | ||
import { | ||
AwsCredentialIdentity, | ||
RequestPresigner, | ||
RequestPresigningArguments, | ||
} from "@smithy/types"; | ||
import { HttpRequest as IHttpRequest } from "@smithy/types"; | ||
type PartialBy<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & | ||
Partial<Pick<T, K>>; | ||
export declare type S3RequestPresignerOptions = PartialBy< | ||
export type S3RequestPresignerOptions = PartialBy< | ||
SignatureV4MultiRegionInit, | ||
@@ -23,3 +27,13 @@ "service" | "uriEscapePath" | ||
): Promise<IHttpRequest>; | ||
presignWithCredentials( | ||
requestToSign: IHttpRequest, | ||
credentials: AwsCredentialIdentity, | ||
{ | ||
unsignableHeaders, | ||
unhoistableHeaders, | ||
...options | ||
}?: RequestPresigningArguments | ||
): Promise<IHttpRequest>; | ||
private prepareRequest; | ||
} | ||
export {}; |
{ | ||
"name": "@aws-sdk/s3-request-presigner", | ||
"version": "3.254.0", | ||
"version": "3.481.0", | ||
"scripts": { | ||
@@ -12,2 +12,3 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo", | ||
"extract:docs": "api-extractor run --local", | ||
"test": "jest" | ||
@@ -24,15 +25,14 @@ }, | ||
"dependencies": { | ||
"@aws-sdk/middleware-endpoint": "3.254.0", | ||
"@aws-sdk/middleware-sdk-s3": "3.254.0", | ||
"@aws-sdk/protocol-http": "3.254.0", | ||
"@aws-sdk/signature-v4-multi-region": "3.254.0", | ||
"@aws-sdk/smithy-client": "3.254.0", | ||
"@aws-sdk/types": "3.254.0", | ||
"@aws-sdk/util-create-request": "3.254.0", | ||
"@aws-sdk/util-format-url": "3.254.0", | ||
"tslib": "^2.3.1" | ||
"@aws-sdk/signature-v4-multi-region": "3.481.0", | ||
"@aws-sdk/types": "3.468.0", | ||
"@aws-sdk/util-format-url": "3.468.0", | ||
"@smithy/middleware-endpoint": "^2.2.3", | ||
"@smithy/protocol-http": "^3.0.11", | ||
"@smithy/smithy-client": "^2.2.0", | ||
"@smithy/types": "^2.7.0", | ||
"tslib": "^2.5.0" | ||
}, | ||
"devDependencies": { | ||
"@aws-sdk/client-s3": "3.254.0", | ||
"@aws-sdk/hash-node": "3.254.0", | ||
"@aws-sdk/client-s3": "3.481.0", | ||
"@smithy/hash-node": "^2.0.17", | ||
"@tsconfig/recommended": "1.0.1", | ||
@@ -43,4 +43,3 @@ "@types/node": "^14.14.31", | ||
"rimraf": "3.0.2", | ||
"typedoc": "0.19.2", | ||
"typescript": "~4.6.2" | ||
"typescript": "~4.9.5" | ||
}, | ||
@@ -58,3 +57,3 @@ "engines": { | ||
"files": [ | ||
"dist-*" | ||
"dist-*/**" | ||
], | ||
@@ -61,0 +60,0 @@ "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/s3-request-presigner", |
@@ -51,3 +51,3 @@ # @aws-sdk/s3-request-presigner | ||
const { Sha256 } = require("@aws-crypto/sha256-browser"); | ||
const { Hash } = require("@aws-sdk/hash-node"); | ||
const { Hash } = require("@smithy/hash-node"); | ||
const signer = new S3RequestPresigner({ | ||
@@ -54,0 +54,0 @@ region: regionProvider, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33070
8
8
355
+ Added@smithy/smithy-client@^2.2.0
+ Added@smithy/types@^2.7.0
+ Added@aws-sdk/middleware-sdk-s3@3.481.0(transitive)
+ Added@aws-sdk/signature-v4-multi-region@3.481.0(transitive)
+ Added@aws-sdk/types@3.468.0(transitive)
+ Added@aws-sdk/util-arn-parser@3.465.0(transitive)
+ Added@aws-sdk/util-format-url@3.468.0(transitive)
+ Added@smithy/abort-controller@2.2.0(transitive)
+ Added@smithy/fetch-http-handler@2.5.0(transitive)
+ Added@smithy/is-array-buffer@2.2.0(transitive)
+ Added@smithy/middleware-endpoint@2.5.1(transitive)
+ Added@smithy/middleware-serde@2.3.0(transitive)
+ Added@smithy/middleware-stack@2.2.0(transitive)
+ Added@smithy/node-config-provider@2.3.0(transitive)
+ Added@smithy/node-http-handler@2.5.0(transitive)
+ Added@smithy/property-provider@2.2.0(transitive)
+ Added@smithy/protocol-http@3.3.0(transitive)
+ Added@smithy/querystring-builder@2.2.0(transitive)
+ Added@smithy/querystring-parser@2.2.0(transitive)
+ Added@smithy/shared-ini-file-loader@2.4.0(transitive)
+ Added@smithy/signature-v4@2.3.0(transitive)
+ Added@smithy/smithy-client@2.5.1(transitive)
+ Added@smithy/types@2.12.0(transitive)
+ Added@smithy/url-parser@2.2.0(transitive)
+ Added@smithy/util-base64@2.3.0(transitive)
+ Added@smithy/util-buffer-from@2.2.0(transitive)
+ Added@smithy/util-config-provider@2.3.0(transitive)
+ Added@smithy/util-hex-encoding@2.2.0(transitive)
+ Added@smithy/util-middleware@2.2.0(transitive)
+ Added@smithy/util-stream@2.2.0(transitive)
+ Added@smithy/util-uri-escape@2.2.0(transitive)
+ Added@smithy/util-utf8@2.3.0(transitive)
- Removed@aws-sdk/middleware-endpoint@3.254.0
- Removed@aws-sdk/middleware-sdk-s3@3.254.0
- Removed@aws-sdk/protocol-http@3.254.0
- Removed@aws-sdk/smithy-client@3.254.0
- Removed@aws-sdk/util-create-request@3.254.0
- Removed@aws-sdk/is-array-buffer@3.201.0(transitive)
- Removed@aws-sdk/middleware-endpoint@3.254.0(transitive)
- Removed@aws-sdk/middleware-sdk-s3@3.254.0(transitive)
- Removed@aws-sdk/middleware-serde@3.254.0(transitive)
- Removed@aws-sdk/middleware-stack@3.254.0(transitive)
- Removed@aws-sdk/protocol-http@3.254.0(transitive)
- Removed@aws-sdk/querystring-builder@3.254.0(transitive)
- Removed@aws-sdk/querystring-parser@3.254.0(transitive)
- Removed@aws-sdk/signature-v4@3.254.0(transitive)
- Removed@aws-sdk/signature-v4-multi-region@3.254.0(transitive)
- Removed@aws-sdk/smithy-client@3.254.0(transitive)
- Removed@aws-sdk/types@3.254.0(transitive)
- Removed@aws-sdk/url-parser@3.254.0(transitive)
- Removed@aws-sdk/util-arn-parser@3.208.0(transitive)
- Removed@aws-sdk/util-buffer-from@3.208.0(transitive)
- Removed@aws-sdk/util-config-provider@3.208.0(transitive)
- Removed@aws-sdk/util-create-request@3.254.0(transitive)
- Removed@aws-sdk/util-format-url@3.254.0(transitive)
- Removed@aws-sdk/util-hex-encoding@3.201.0(transitive)
- Removed@aws-sdk/util-middleware@3.254.0(transitive)
- Removed@aws-sdk/util-uri-escape@3.201.0(transitive)
- Removed@aws-sdk/util-utf8@3.254.0(transitive)
Updated@aws-sdk/types@3.468.0
Updatedtslib@^2.5.0