@aws-sdk/s3-presigned-post
Advanced tools
Comparing version 3.267.0 to 3.473.0
@@ -5,7 +5,7 @@ "use strict"; | ||
const client_s3_1 = require("@aws-sdk/client-s3"); | ||
const middleware_endpoint_1 = require("@aws-sdk/middleware-endpoint"); | ||
const signature_v4_1 = require("@aws-sdk/signature-v4"); | ||
const util_format_url_1 = require("@aws-sdk/util-format-url"); | ||
const util_hex_encoding_1 = require("@aws-sdk/util-hex-encoding"); | ||
const util_utf8_1 = require("@aws-sdk/util-utf8"); | ||
const middleware_endpoint_1 = require("@smithy/middleware-endpoint"); | ||
const signature_v4_1 = require("@smithy/signature-v4"); | ||
const util_hex_encoding_1 = require("@smithy/util-hex-encoding"); | ||
const util_utf8_1 = require("@smithy/util-utf8"); | ||
const constants_1 = require("./constants"); | ||
@@ -30,9 +30,17 @@ const createPresignedPost = async (client, { Bucket, Key, Conditions = [], Fields = {}, Expires = 3600 }) => { | ||
const expiration = new Date(now.valueOf() + Expires * 1000); | ||
const conditions = [ | ||
...Conditions, | ||
...Object.entries(fields).map(([k, v]) => ({ [k]: v })), | ||
Key.endsWith("${filename}") | ||
? ["starts-with", "$key", Key.substring(0, Key.lastIndexOf("${filename}"))] | ||
: { key: Key }, | ||
]; | ||
const conditionsSet = new Set(); | ||
for (const condition of Conditions) { | ||
const stringifiedCondition = JSON.stringify(condition); | ||
conditionsSet.add(stringifiedCondition); | ||
} | ||
for (const [k, v] of Object.entries(fields)) { | ||
conditionsSet.add(JSON.stringify({ [k]: v })); | ||
} | ||
if (Key.endsWith("${filename}")) { | ||
conditionsSet.add(JSON.stringify(["starts-with", "$key", Key.substring(0, Key.lastIndexOf("${filename}"))])); | ||
} | ||
else { | ||
conditionsSet.add(JSON.stringify({ key: Key })); | ||
} | ||
const conditions = Array.from(conditionsSet).map((item) => JSON.parse(item)); | ||
const encodedPolicy = base64Encoder(utf8Decoder(JSON.stringify({ | ||
@@ -39,0 +47,0 @@ expiration: iso8601(expiration), |
import { PutObjectCommand } from "@aws-sdk/client-s3"; | ||
import { getEndpointFromInstructions, toEndpointV1, } from "@aws-sdk/middleware-endpoint"; | ||
import { createScope, getSigningKey } from "@aws-sdk/signature-v4"; | ||
import { formatUrl } from "@aws-sdk/util-format-url"; | ||
import { toHex } from "@aws-sdk/util-hex-encoding"; | ||
import { toUint8Array } from "@aws-sdk/util-utf8"; | ||
import { getEndpointFromInstructions, toEndpointV1, } from "@smithy/middleware-endpoint"; | ||
import { createScope, getSigningKey } from "@smithy/signature-v4"; | ||
import { toHex } from "@smithy/util-hex-encoding"; | ||
import { toUint8Array } from "@smithy/util-utf8"; | ||
import { ALGORITHM_IDENTIFIER, ALGORITHM_QUERY_PARAM, AMZ_DATE_QUERY_PARAM, CREDENTIAL_QUERY_PARAM, SIGNATURE_QUERY_PARAM, TOKEN_QUERY_PARAM, } from "./constants"; | ||
@@ -26,9 +26,17 @@ export const createPresignedPost = async (client, { Bucket, Key, Conditions = [], Fields = {}, Expires = 3600 }) => { | ||
const expiration = new Date(now.valueOf() + Expires * 1000); | ||
const conditions = [ | ||
...Conditions, | ||
...Object.entries(fields).map(([k, v]) => ({ [k]: v })), | ||
Key.endsWith("${filename}") | ||
? ["starts-with", "$key", Key.substring(0, Key.lastIndexOf("${filename}"))] | ||
: { key: Key }, | ||
]; | ||
const conditionsSet = new Set(); | ||
for (const condition of Conditions) { | ||
const stringifiedCondition = JSON.stringify(condition); | ||
conditionsSet.add(stringifiedCondition); | ||
} | ||
for (const [k, v] of Object.entries(fields)) { | ||
conditionsSet.add(JSON.stringify({ [k]: v })); | ||
} | ||
if (Key.endsWith("${filename}")) { | ||
conditionsSet.add(JSON.stringify(["starts-with", "$key", Key.substring(0, Key.lastIndexOf("${filename}"))])); | ||
} | ||
else { | ||
conditionsSet.add(JSON.stringify({ key: Key })); | ||
} | ||
const conditions = Array.from(conditionsSet).map((item) => JSON.parse(item)); | ||
const encodedPolicy = base64Encoder(utf8Decoder(JSON.stringify({ | ||
@@ -35,0 +43,0 @@ expiration: iso8601(expiration), |
import { S3Client } from "@aws-sdk/client-s3"; | ||
import { Conditions as PolicyEntry } from "./types"; | ||
declare type Fields = Record<string, string>; | ||
type Fields = Record<string, string>; | ||
export interface PresignedPostOptions { | ||
@@ -5,0 +5,0 @@ Bucket: string; |
import { S3Client } from "@aws-sdk/client-s3"; | ||
import { Conditions as PolicyEntry } from "./types"; | ||
declare type Fields = Record<string, string>; | ||
type Fields = Record<string, string>; | ||
export interface PresignedPostOptions { | ||
@@ -5,0 +5,0 @@ Bucket: string; |
@@ -1,9 +0,5 @@ | ||
declare type EqualCondition = ["eq", string, string] | Record<string, string>; | ||
declare type StartsWithCondition = ["starts-with", string, string]; | ||
declare type ContentLengthRangeCondition = [ | ||
"content-length-range", | ||
number, | ||
number | ||
]; | ||
export declare type Conditions = | ||
type EqualCondition = ["eq", string, string] | Record<string, string>; | ||
type StartsWithCondition = ["starts-with", string, string]; | ||
type ContentLengthRangeCondition = ["content-length-range", number, number]; | ||
export type Conditions = | ||
| EqualCondition | ||
@@ -10,0 +6,0 @@ | StartsWithCondition |
@@ -1,5 +0,5 @@ | ||
declare type EqualCondition = ["eq", string, string] | Record<string, string>; | ||
declare type StartsWithCondition = ["starts-with", string, string]; | ||
declare type ContentLengthRangeCondition = ["content-length-range", number, number]; | ||
export declare type Conditions = EqualCondition | StartsWithCondition | ContentLengthRangeCondition; | ||
type EqualCondition = ["eq", string, string] | Record<string, string>; | ||
type StartsWithCondition = ["starts-with", string, string]; | ||
type ContentLengthRangeCondition = ["content-length-range", number, number]; | ||
export type Conditions = EqualCondition | StartsWithCondition | ContentLengthRangeCondition; | ||
export {}; |
{ | ||
"name": "@aws-sdk/s3-presigned-post", | ||
"version": "3.267.0", | ||
"version": "3.473.0", | ||
"scripts": { | ||
@@ -12,3 +12,5 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo", | ||
"test": "jest" | ||
"extract:docs": "api-extractor run --local", | ||
"test": "jest", | ||
"test:e2e": "jest -c jest.config.e2e.js" | ||
}, | ||
@@ -24,14 +26,13 @@ "main": "./dist-cjs/index.js", | ||
"dependencies": { | ||
"@aws-sdk/middleware-endpoint": "3.267.0", | ||
"@aws-sdk/signature-v4": "3.267.0", | ||
"@aws-sdk/types": "3.267.0", | ||
"@aws-sdk/util-format-url": "3.267.0", | ||
"@aws-sdk/util-hex-encoding": "3.201.0", | ||
"@aws-sdk/util-utf8": "3.254.0", | ||
"tslib": "^2.3.1" | ||
"@aws-sdk/client-s3": "3.473.0", | ||
"@aws-sdk/types": "3.468.0", | ||
"@aws-sdk/util-format-url": "3.468.0", | ||
"@smithy/middleware-endpoint": "^2.2.3", | ||
"@smithy/signature-v4": "^2.0.0", | ||
"@smithy/types": "^2.7.0", | ||
"@smithy/util-hex-encoding": "^2.0.0", | ||
"@smithy/util-utf8": "^2.0.2", | ||
"tslib": "^2.5.0" | ||
}, | ||
"devDependencies": { | ||
"@aws-sdk/client-s3": "3.267.0", | ||
"@aws-sdk/hash-node": "3.267.0", | ||
"@aws-sdk/protocol-http": "3.267.0", | ||
"@tsconfig/recommended": "1.0.1", | ||
@@ -43,4 +44,3 @@ "@types/node": "^14.14.31", | ||
"rimraf": "3.0.2", | ||
"typedoc": "0.19.2", | ||
"typescript": "~4.6.2" | ||
"typescript": "~4.9.5" | ||
}, | ||
@@ -58,3 +58,3 @@ "engines": { | ||
"files": [ | ||
"dist-*" | ||
"dist-*/**" | ||
], | ||
@@ -61,0 +61,0 @@ "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/s3-presigned-post", |
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
27266
7
226
9
+ Added@aws-sdk/client-s3@3.473.0
+ Added@smithy/signature-v4@^2.0.0
+ Added@smithy/types@^2.7.0
+ Added@smithy/util-utf8@^2.0.2
+ Added@aws-crypto/crc32@3.0.0(transitive)
+ Added@aws-crypto/crc32c@3.0.0(transitive)
+ Added@aws-crypto/ie11-detection@3.0.0(transitive)
+ Added@aws-crypto/sha1-browser@3.0.0(transitive)
+ Added@aws-crypto/sha256-browser@3.0.0(transitive)
+ Added@aws-crypto/sha256-js@3.0.0(transitive)
+ Added@aws-crypto/supports-web-crypto@3.0.0(transitive)
+ Added@aws-crypto/util@3.0.0(transitive)
+ Added@aws-sdk/client-s3@3.473.0(transitive)
+ Added@aws-sdk/client-sso@3.470.0(transitive)
+ Added@aws-sdk/client-sts@3.473.0(transitive)
+ Added@aws-sdk/core@3.468.0(transitive)
+ Added@aws-sdk/credential-provider-env@3.468.0(transitive)
+ Added@aws-sdk/credential-provider-ini@3.470.0(transitive)
+ Added@aws-sdk/credential-provider-node@3.470.0(transitive)
+ Added@aws-sdk/credential-provider-process@3.468.0(transitive)
+ Added@aws-sdk/credential-provider-sso@3.470.0(transitive)
+ Added@aws-sdk/credential-provider-web-identity@3.468.0(transitive)
+ Added@aws-sdk/middleware-bucket-endpoint@3.470.0(transitive)
+ Added@aws-sdk/middleware-expect-continue@3.468.0(transitive)
+ Added@aws-sdk/middleware-flexible-checksums@3.468.0(transitive)
+ Added@aws-sdk/middleware-host-header@3.468.0(transitive)
+ Added@aws-sdk/middleware-location-constraint@3.468.0(transitive)
+ Added@aws-sdk/middleware-logger@3.468.0(transitive)
+ Added@aws-sdk/middleware-recursion-detection@3.468.0(transitive)
+ Added@aws-sdk/middleware-sdk-s3@3.470.0(transitive)
+ Added@aws-sdk/middleware-sdk-sts@3.468.0(transitive)
+ Added@aws-sdk/middleware-signing@3.468.0(transitive)
+ Added@aws-sdk/middleware-ssec@3.468.0(transitive)
+ Added@aws-sdk/middleware-user-agent@3.470.0(transitive)
+ Added@aws-sdk/region-config-resolver@3.470.0(transitive)
+ Added@aws-sdk/signature-v4-multi-region@3.470.0(transitive)
+ Added@aws-sdk/token-providers@3.470.0(transitive)
+ Added@aws-sdk/types@3.468.0(transitive)
+ Added@aws-sdk/util-arn-parser@3.465.0(transitive)
+ Added@aws-sdk/util-endpoints@3.470.0(transitive)
+ Added@aws-sdk/util-format-url@3.468.0(transitive)
+ Added@aws-sdk/util-locate-window@3.568.0(transitive)
+ Added@aws-sdk/util-user-agent-browser@3.468.0(transitive)
+ Added@aws-sdk/util-user-agent-node@3.470.0(transitive)
+ Added@aws-sdk/util-utf8-browser@3.259.0(transitive)
+ Added@aws-sdk/xml-builder@3.472.0(transitive)
+ Added@smithy/abort-controller@2.2.0(transitive)
+ Added@smithy/chunked-blob-reader@2.2.0(transitive)
+ Added@smithy/chunked-blob-reader-native@2.2.0(transitive)
+ Added@smithy/config-resolver@2.2.0(transitive)
+ Added@smithy/credential-provider-imds@2.3.0(transitive)
+ Added@smithy/eventstream-codec@2.2.0(transitive)
+ Added@smithy/eventstream-serde-browser@2.2.0(transitive)
+ Added@smithy/eventstream-serde-config-resolver@2.2.0(transitive)
+ Added@smithy/eventstream-serde-node@2.2.0(transitive)
+ Added@smithy/eventstream-serde-universal@2.2.0(transitive)
+ Added@smithy/fetch-http-handler@2.5.0(transitive)
+ Added@smithy/hash-blob-browser@2.2.0(transitive)
+ Added@smithy/hash-node@2.2.0(transitive)
+ Added@smithy/hash-stream-node@2.2.0(transitive)
+ Added@smithy/invalid-dependency@2.2.0(transitive)
+ Added@smithy/is-array-buffer@2.2.0(transitive)
+ Added@smithy/md5-js@2.2.0(transitive)
+ Added@smithy/middleware-content-length@2.2.0(transitive)
+ Added@smithy/middleware-endpoint@2.5.1(transitive)
+ Added@smithy/middleware-retry@2.3.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/service-error-classification@2.1.5(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-body-length-browser@2.2.0(transitive)
+ Added@smithy/util-body-length-node@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-defaults-mode-browser@2.2.1(transitive)
+ Added@smithy/util-defaults-mode-node@2.3.1(transitive)
+ Added@smithy/util-endpoints@1.2.0(transitive)
+ Added@smithy/util-hex-encoding@2.2.0(transitive)
+ Added@smithy/util-middleware@2.2.0(transitive)
+ Added@smithy/util-retry@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)
+ Added@smithy/util-waiter@2.2.0(transitive)
+ Addedbowser@2.11.0(transitive)
+ Addedfast-xml-parser@4.2.5(transitive)
+ Addedstrnum@1.0.5(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addeduuid@9.0.1(transitive)
- Removed@aws-sdk/middleware-endpoint@3.267.0
- Removed@aws-sdk/signature-v4@3.267.0
- Removed@aws-sdk/util-hex-encoding@3.201.0
- Removed@aws-sdk/util-utf8@3.254.0
- Removed@aws-sdk/is-array-buffer@3.201.0(transitive)
- Removed@aws-sdk/middleware-endpoint@3.267.0(transitive)
- Removed@aws-sdk/middleware-serde@3.267.0(transitive)
- Removed@aws-sdk/protocol-http@3.267.0(transitive)
- Removed@aws-sdk/querystring-builder@3.267.0(transitive)
- Removed@aws-sdk/querystring-parser@3.267.0(transitive)
- Removed@aws-sdk/signature-v4@3.267.0(transitive)
- Removed@aws-sdk/types@3.267.0(transitive)
- Removed@aws-sdk/url-parser@3.267.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-format-url@3.267.0(transitive)
- Removed@aws-sdk/util-hex-encoding@3.201.0(transitive)
- Removed@aws-sdk/util-middleware@3.267.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