@danielmyerfenton/react-native-aws3
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@danielmyerfenton/react-native-aws3", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Pure JavaScript react native library for uploading to AWS S3", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -65,43 +65,2 @@ /** | ||
const getDate = () => { | ||
let date = new Date(); | ||
let yymmdd = date.toISOString().slice(0, 10).replace(/-/g, ""); | ||
let amzDate = yymmdd + "T000000Z"; | ||
return { yymmdd: yymmdd, amzDate: amzDate } | ||
} | ||
/** | ||
* Expires in 5 minutes. Amazon will reject request | ||
* if it arrives after the expiration date. | ||
* | ||
* returns string in ISO8601 GMT format, i.e. | ||
* | ||
* 2016-03-24T20:43:47.314Z | ||
*/ | ||
const getExpirationDate = () => { | ||
return new Date( | ||
(new Date).getTime() + FIVE_MINUTES | ||
).toISOString(); | ||
} | ||
const getPolicyParams = (options) => { | ||
let date = getDate(); | ||
let expiration = getExpirationDate(); | ||
return { | ||
acl: options.acl || AWS_ACL, | ||
algorithm: AWS_ALGORITHM, | ||
bucket: options.bucket, | ||
contentType: options.contentType, | ||
credential: options.accessKey + "/" + date.yymmdd + "/" + options.region + "/" + AWS_SERVICE_NAME + "/" + AWS_REQUEST_POLICY_VERSION, | ||
date: date, | ||
expiration: expiration, | ||
key: options.key, | ||
region: options.region, | ||
secretKey: options.secretKey, | ||
successActionStatus: '' + (options.successActionStatus || DEFAULT_SUCCESS_ACTION_STATUS), | ||
metadata: options.metadata | ||
} | ||
} | ||
const formatPolicyForRequestBody = (base64EncodedPolicy, signature, options) => { | ||
@@ -118,2 +77,3 @@ return { | ||
"X-Amz-Signature": signature, | ||
metadata: options.metadata | ||
} | ||
@@ -124,3 +84,3 @@ } | ||
let policyForEncoding = { | ||
"expiration": policy.expiration, | ||
"expiration": policy.expirationDate, | ||
"conditions": [ | ||
@@ -137,4 +97,3 @@ {"bucket": policy.bucket}, | ||
} | ||
if (policy.metdata) { | ||
if (policy.metadata) { | ||
Object.keys(policy.metadata).forEach((k) => { | ||
@@ -141,0 +100,0 @@ let metadata = String(policy.metadata[k]) |
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
32971
683