Socket
Socket
Sign inDemoInstall

@aws-sdk/s3-presigned-post

Package Overview
Dependencies
Maintainers
5
Versions
389
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/s3-presigned-post - npm Package Compare versions

Comparing version 3.267.0 to 3.473.0

30

dist-cjs/createPresignedPost.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc