Socket
Socket
Sign inDemoInstall

aws-s3-form

Package Overview
Dependencies
6
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

40

lib/aws-s3-form.js
(function() {
var AwsS3Form, _, crypto, utils, uuid,
var AwsS3Form, _, crypto, mime, utils, uuid,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },

@@ -14,2 +14,4 @@ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },

mime = require('mime');
utils = require("./utils");

@@ -22,5 +24,2 @@

this.ERRORS = bind(this.ERRORS, this);
this._obj2b64 = bind(this._obj2b64, this);
this._hmac = bind(this._hmac, this);
this._shortDate = bind(this._shortDate, this);
this._createCredential = bind(this._createCredential, this);

@@ -72,2 +71,3 @@ this._calcDate = bind(this._calcDate, this);

@param { String } [options.keyPrefix] Option to overwrite the general `keyPrefix`
@param { String|Boolean } [options.contentType] Option to set the content type of the uploaded file. This could be a string with a fixed mime or a boolean to decide if the mime will be guessed by the filename.
@param { String } [options.redirectUrlTemplate] Option to overwrite the general `redirectUrlTemplate`

@@ -81,3 +81,3 @@ @param { String } [options.successActionStatus] Option to overwrite the general `successActionStatus`

AwsS3Form.prototype.create = function(filename, options) {
var _data, _policyB64, _secure, _signature, data;
var _cType, _data, _policyB64, _secure, _signature, data;
if (options == null) {

@@ -90,6 +90,12 @@ options = {};

}
if ((options.contentType != null) && _.isString(options.contentType)) {
_cType = options.contentType;
} else if (options.contentType) {
_cType = mime.lookup(filename);
}
_data = {
acl: this._acl(options.acl),
credential: this._createCredential(options.now),
amzdate: this._shortDate(options.now)
amzdate: this._shortDate(options.now),
contentType: _cType
};

@@ -136,2 +142,5 @@ if (options.redirectUrlTemplate != null) {

}
if (_cType != null) {
data.fields["Content-Type"] = _cType;
}
return data;

@@ -154,2 +163,3 @@ };

@param { String } [options.keyPrefix] Option to overwrite the general `keyPrefix`
@param { Array } [options.customConditions] Option to set s3 upload conditions. For details see http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html
@param { String } [options.redirectUrlTemplate] Option to overwrite the general `redirectUrlTemplate`

@@ -162,3 +172,3 @@ @param { Number|Date } [options.policyExpiration] Option to overwrite the general `policyExpiration`

AwsS3Form.prototype.policy = function(filename, options, _predef) {
var _date, policy;
var _ctypeCondition, _date, ccond, i, len, policy, ref;
if (options == null) {

@@ -198,2 +208,18 @@ options = {};

}
_ctypeCondition = false;
if (options.customConditions != null) {
ref = options.customConditions;
for (i = 0, len = ref.length; i < len; i++) {
ccond = ref[i];
policy.conditions.push(ccond);
if ((_.isArray(ccond) && ccond[1].toLowerCase() === "$content-type") || (_.isObject(ccond) && (ccond["content-type"] != null))) {
_ctypeCondition = true;
}
}
}
if (!_ctypeCondition && ((_predef != null ? _predef.contentType : void 0) != null)) {
policy.conditions.push({
"content-type": _predef.contentType
});
}
this.debug("generated policy", policy);

@@ -200,0 +226,0 @@ if (options.uuid != null) {

6

lib/utils.js

@@ -10,4 +10,4 @@ (function() {

Generate a random string
@param { Number } string_length string length to generate
@param { Number } string_length string length to generate
@param { Number } speciallevel Level of complexity.

@@ -18,3 +18,3 @@ * 0 = only letters upper and lowercase, 52 possible chars;

* 3 = 2 + may speacial chars, 135 possible chars;
@return { String } The gerated string

@@ -21,0 +21,0 @@ */

{
"name": "aws-s3-form",
"version": "0.2.0",
"version": "0.3.0",
"description": "Generate a signed and reday to use formdata to put files to s3 directly from teh browser. Signing is done by using AWS Signature Version 4 ",
"keywords": [ "aws", "s3", "sign", "signature", "v4", "form", "browser", "post", "client" ],
"keywords": [
"aws",
"s3",
"sign",
"signature",
"v4",
"form",
"browser",
"post",
"client"
],
"homepage": "https://github.com/mpneuried/aws-s3-form",

@@ -26,4 +36,5 @@ "bugs": "https://github.com/mpneuried/aws-s3-form/issues",

"dependencies": {
"lodash": "3.x",
"mime": "1.3.x",
"mpbasic": "0.0.x",
"lodash": "3.x",
"node-uuid": "1.4.x"

@@ -33,3 +44,2 @@ },

"request": "2.x",
"mime": "1.2.x",
"should": "4.3.x",

@@ -36,0 +46,0 @@ "grunt": "0.4.x",

@@ -87,2 +87,4 @@ aws-s3-form

* `options.keyPrefix` : *( `String` optional; default = `config.keyPrefix` )*: Change the configured standard `keyPrefix` type. Details see config object description.
* `options.contentType` : *( `String|Boolean` optional; )*: Option to set the content type of the uploaded file. This could be a string with a fixed mime or a boolean to decide if the mime will be guessed by the filename.
* `options.customConditions` : *( `Array` optional; )*: Option to set s3 upload conditions. For details see http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html
* `options.redirectUrlTemplate` : *( `String` optional; default = `config.redirectUrlTemplate` )*: Change the configured standard `redirectUrlTemplate` type. Details see config object description.

@@ -111,2 +113,3 @@ * `options.successActionStatus` : *( `String|Number` optional; default = `config.successActionStatus` )*: Change the configured standard `successActionStatus` type. Details see config object description.

* `options.keyPrefix` : *( `String` optional; default = `config.keyPrefix` )*: Change the configured standard `keyPrefix` type. Details see config object description.
* `options.customConditions` : *( `Array` optional; )*: Option to set s3 upload conditions. For details see http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html
* `options.redirectUrlTemplate` : *( `String` optional; default = `config.redirectUrlTemplate` )*: Change the configured standard `redirectUrlTemplate` type. Details see config object description.

@@ -196,2 +199,3 @@ * `options.successActionStatus` : *( `Number` optional; default = `config.successActionStatus` )*: Change the configured standard `successActionStatus` type. Details see config object description.

|:--:|:--:|:--|
|0.3.0|2015-05-27|Added `contentType` to options and optional `customConditions` to define a custom aws-s3 policy |
|0.2.0|2015-04-07|Added option `successActionStatus` to make ajax form posts possible|

@@ -198,0 +202,0 @@ |0.1.4|2015-03-17|Added option `secure` to create method|

Sorry, the diff of this file is not supported yet

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