Socket
Socket
Sign inDemoInstall

s3u

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.6 to 0.2.7

2

package.json
{
"name": "s3u",
"version": "0.2.6",
"version": "0.2.7",
"description": "S3 URL manipulation helper similar to standard URL class",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -15,2 +15,3 @@ # s3u

- Typescript support
- Built-in presigned URL generation

@@ -65,2 +66,6 @@ ## Installation

const httpUrl = s3Url.clone({ protocol: 'http:' }).href;
// Generaing presigned URL, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
// env vars can be used instead of passing arguments
const presignedUrl = s3Url.sign({ accessKeyId, secretAccessKey });
```

@@ -67,0 +72,0 @@

@@ -32,2 +32,3 @@ export class S3Url {

setKey(key: string): this;
setProtocol(protocol: string): this;
setRegion(region: string): this;

@@ -34,0 +35,0 @@

@@ -27,2 +27,28 @@ 'use strict';

async buildSignedUrl({
accessKeyId,
secretAccessKey,
expires,
method,
s3Url,
}) {
const s3UrlCopy = s3Url.clone();
if (!s3UrlCopy.region) {
s3UrlCopy.setRegion('us-east-1');
}
if (s3UrlCopy.protocol === 's3:') {
s3UrlCopy.setProtocol('https:');
}
return super.buildSignedUrl({
accessKeyId,
secretAccessKey,
expires,
method,
s3Url: s3UrlCopy,
});
}
parseBucket(hostname, s3Url) {

@@ -29,0 +55,0 @@ const hostnameParts = hostname.split('.');

@@ -56,2 +56,9 @@ 'use strict';

url.pathname = url.pathname
.replace(/\+/g, '%20')
// eslint-disable-next-line arrow-body-style
.replace(/[!'()*]/g, (c) => {
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
});
const request = [

@@ -58,0 +65,0 @@ method.toUpperCase(),

@@ -106,2 +106,7 @@ 'use strict';

setProtocol(protocol) {
this.protocol = protocol;
return this;
}
setRegion(region) {

@@ -108,0 +113,0 @@ this.region = region;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc