Comparing version 7.0.16 to 7.0.17
@@ -18,3 +18,3 @@ "use strict"; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
@@ -21,0 +21,0 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } |
@@ -130,3 +130,3 @@ "use strict"; | ||
function isVirtualHostStyle(endpoint, protocol, bucket) { | ||
function isVirtualHostStyle(endpoint, protocol, bucket, pathStyle) { | ||
if (protocol === 'https:' && bucket.indexOf('.') > -1) { | ||
@@ -136,3 +136,3 @@ return false; | ||
return isAmazonEndpoint(endpoint); | ||
return isAmazonEndpoint(endpoint) || !pathStyle; | ||
} | ||
@@ -139,0 +139,0 @@ |
@@ -22,3 +22,3 @@ "use strict"; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
@@ -25,0 +25,0 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } |
@@ -30,3 +30,3 @@ "use strict"; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
@@ -33,0 +33,0 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } |
@@ -72,3 +72,5 @@ "use strict"; | ||
var headersArray = signedHeaders.reduce(function (acc, i) { | ||
acc.push(`${i.toLowerCase()}:${headers[i]}`); | ||
// Trim spaces from the value (required by V4 spec) | ||
var val = `${headers[i]}`.replace(/ +/g, " "); | ||
acc.push(`${i.toLowerCase()}:${val}`); | ||
return acc; | ||
@@ -75,0 +77,0 @@ }, []); |
@@ -19,3 +19,3 @@ "use strict"; | ||
var _xml2js = _interopRequireDefault(require("xml2js")); | ||
var _fastXmlParser = _interopRequireDefault(require("fast-xml-parser")); | ||
@@ -47,21 +47,8 @@ var _lodash = _interopRequireDefault(require("lodash")); | ||
*/ | ||
var options = { | ||
// options passed to xml2js parser | ||
explicitRoot: false, | ||
// return the root node in the resulting object? | ||
ignoreAttrs: true // ignore attributes, only create text nodes | ||
}; | ||
var parseXml = function parseXml(xml) { | ||
var result = null; | ||
var error = null; | ||
var parser = new _xml2js.default.Parser(options); | ||
parser.parseString(xml, function (e, r) { | ||
error = e; | ||
result = r; | ||
}); | ||
result = _fastXmlParser.default.parse(xml); | ||
if (error) { | ||
throw new Error('XML parse error'); | ||
if (result.Error) { | ||
throw result.Error; | ||
} | ||
@@ -75,19 +62,14 @@ | ||
function parseError(xml, headerInfo) { | ||
var xmlError = {}; | ||
var xmlobj = parseXml(xml); | ||
var message; | ||
var xmlErr = {}; | ||
_lodash.default.each(xmlobj, function (n, key) { | ||
if (key === 'Message') { | ||
message = xmlobj[key][0]; | ||
return; | ||
} | ||
var xmlObj = _fastXmlParser.default.parse(xml); | ||
xmlError[key.toLowerCase()] = xmlobj[key][0]; | ||
}); | ||
if (xmlObj.Error) { | ||
xmlErr = xmlObj.Error; | ||
} | ||
var e = new errors.S3Error(message); | ||
var e = new errors.S3Error(); | ||
_lodash.default.each(xmlError, function (value, key) { | ||
e[key] = value; | ||
_lodash.default.each(xmlErr, function (value, key) { | ||
e[key.toLowerCase()] = value; | ||
}); | ||
@@ -109,4 +91,10 @@ | ||
var xmlobj = parseXml(xml); | ||
if (xmlobj.ETag) result.etag = xmlobj.ETag[0].replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/^"$/g, ''); | ||
if (xmlobj.LastModified) result.lastModified = new Date(xmlobj.LastModified[0]); | ||
if (!xmlobj.CopyObjectResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "CopyObjectResult"'); | ||
} | ||
xmlobj = xmlobj.CopyObjectResult; | ||
if (xmlobj.ETag) result.etag = xmlobj.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
if (xmlobj.LastModified) result.lastModified = new Date(xmlobj.LastModified); | ||
return result; | ||
@@ -123,4 +111,10 @@ } // parse XML response for listing in-progress multipart uploads | ||
var xmlobj = parseXml(xml); | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated[0] === 'true') result.isTruncated = true; | ||
if (xmlobj.NextKeyMarker) result.nextKeyMarker = xmlobj.NextKeyMarker[0]; | ||
if (!xmlobj.ListMultipartUploadsResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "ListMultipartUploadsResult"'); | ||
} | ||
xmlobj = xmlobj.ListMultipartUploadsResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.NextKeyMarker) result.nextKeyMarker = xmlobj.NextKeyMarker; | ||
if (xmlobj.NextUploadIdMarker) result.nextUploadIdMarker = xmlobj.NextUploadIdMarker[0]; | ||
@@ -132,9 +126,32 @@ if (xmlobj.CommonPrefixes) xmlobj.CommonPrefixes.forEach(function (prefix) { | ||
}); | ||
if (xmlobj.Upload) xmlobj.Upload.forEach(function (upload) { | ||
result.uploads.push({ | ||
key: upload.Key[0], | ||
uploadId: upload.UploadId[0], | ||
initiated: new Date(upload.Initiated[0]) | ||
if (xmlobj.Upload) { | ||
if (!Array.isArray(xmlobj.Upload)) { | ||
xmlobj.Upload = Array(xmlobj.Upload); | ||
} | ||
xmlobj.Upload.forEach(function (upload) { | ||
var key = upload.Key; | ||
var uploadId = upload.UploadId; | ||
var initiator = { | ||
id: upload.Initiator.ID, | ||
displayName: upload.Initiator.DisplayName | ||
}; | ||
var owner = { | ||
id: upload.Owner.ID, | ||
displayName: upload.Owner.DisplayName | ||
}; | ||
var storageClass = upload.StorageClass; | ||
var initiated = new Date(upload.Initiated); | ||
result.uploads.push({ | ||
key, | ||
uploadId, | ||
initiator, | ||
owner, | ||
storageClass, | ||
initiated | ||
}); | ||
}); | ||
}); | ||
} | ||
return result; | ||
@@ -148,7 +165,17 @@ } // parse XML response to list all the owned buckets | ||
if (!xmlobj.ListAllMyBucketsResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "ListAllMyBucketsResult"'); | ||
} | ||
xmlobj = xmlobj.ListAllMyBucketsResult; | ||
if (xmlobj.Buckets) { | ||
if (xmlobj.Buckets[0].Bucket) { | ||
xmlobj.Buckets[0].Bucket.forEach(function (bucket) { | ||
var name = bucket.Name[0]; | ||
var creationDate = new Date(bucket.CreationDate[0]); | ||
if (xmlobj.Buckets.Bucket) { | ||
if (!Array.isArray(xmlobj.Buckets.Bucket)) { | ||
xmlobj.Buckets.Bucket = Array(xmlobj.Buckets.Bucket); | ||
} | ||
xmlobj.Buckets.Bucket.forEach(function (bucket) { | ||
var name = bucket.Name; | ||
var creationDate = new Date(bucket.CreationDate); | ||
result.push({ | ||
@@ -257,3 +284,4 @@ name, | ||
function parseBucketRegion(xml) { | ||
return parseXml(xml); | ||
// return region information | ||
return parseXml(xml).LocationConstraint; | ||
} // parse XML response for list parts of an in progress multipart upload | ||
@@ -269,3 +297,3 @@ | ||
}; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated[0] === 'true') result.isTruncated = true; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.NextPartNumberMarker) result.marker = +xmlobj.NextPartNumberMarker[0]; | ||
@@ -276,4 +304,4 @@ | ||
var part = +p.PartNumber[0]; | ||
var lastModified = new Date(p.LastModified[0]); | ||
var etag = p.ETag[0].replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/^"$/g, ''); | ||
var lastModified = new Date(p.LastModified); | ||
var etag = p.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
result.parts.push({ | ||
@@ -292,5 +320,5 @@ part, | ||
function parseInitiateMultipart(xml) { | ||
var xmlobj = parseXml(xml); | ||
if (xmlobj.UploadId) return xmlobj.UploadId[0]; | ||
throw new errors.InvalidXMLError('UploadId missing in XML'); | ||
var xmlobj = parseXml(xml).InitiateMultipartUploadResult; | ||
if (xmlobj.UploadId) return xmlobj.UploadId; | ||
throw new errors.InvalidXMLError('Missing tag: "UploadId"'); | ||
} // parse XML response when a multipart upload is completed | ||
@@ -300,3 +328,3 @@ | ||
function parseCompleteMultipart(xml) { | ||
var xmlobj = parseXml(xml); | ||
var xmlobj = parseXml(xml).CompleteMultipartUploadResult; | ||
@@ -306,4 +334,4 @@ if (xmlobj.Location) { | ||
var bucket = xmlobj.Bucket[0]; | ||
var key = xmlobj.Key[0]; | ||
var etag = xmlobj.ETag[0].replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/^"$/g, ''); | ||
var key = xmlobj.Key; | ||
var etag = xmlobj.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
return { | ||
@@ -336,10 +364,20 @@ location, | ||
var xmlobj = parseXml(xml); | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated[0] === 'true') result.isTruncated = true; | ||
if (!xmlobj.ListBucketResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "ListBucketResult"'); | ||
} | ||
xmlobj = xmlobj.ListBucketResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') xmlobj.isTruncated = true; | ||
if (xmlobj.Contents) { | ||
if (!Array.isArray(xmlobj.Contents)) { | ||
xmlobj.Contents = Array(xmlobj.Contents); | ||
} | ||
xmlobj.Contents.forEach(function (content) { | ||
var name = content.Key[0]; | ||
var lastModified = new Date(content.LastModified[0]); | ||
var etag = content.ETag[0].replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/^"$/g, ''); | ||
var size = +content.Size[0]; | ||
var name = content.Key; | ||
var lastModified = new Date(content.LastModified); | ||
var etag = content.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
var size = +content.Size; | ||
result.objects.push({ | ||
@@ -380,11 +418,21 @@ name, | ||
var xmlobj = parseXml(xml); | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated[0] === 'true') result.isTruncated = true; | ||
if (!xmlobj.ListBucketResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "ListBucketResult"'); | ||
} | ||
xmlobj = xmlobj.ListBucketResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.NextContinuationToken) result.nextContinuationToken = xmlobj.NextContinuationToken[0]; | ||
if (xmlobj.Contents) { | ||
if (!Array.isArray(xmlobj.Contents)) { | ||
xmlobj.Contents = Array(xmlobj.Contents); | ||
} | ||
xmlobj.Contents.forEach(function (content) { | ||
var name = content.Key[0]; | ||
var lastModified = new Date(content.LastModified[0]); | ||
var etag = content.ETag[0].replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/^"$/g, ''); | ||
var size = +content.Size[0]; | ||
var name = content.Key; | ||
var lastModified = new Date(content.LastModified); | ||
var etag = content.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
var size = +content.Size; | ||
result.objects.push({ | ||
@@ -420,11 +468,21 @@ name, | ||
var xmlobj = parseXml(xml); | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated[0] === 'true') result.isTruncated = true; | ||
if (!xmlobj.ListBucketResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "ListBucketResult"'); | ||
} | ||
xmlobj = xmlobj.ListBucketResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.NextContinuationToken) result.nextContinuationToken = xmlobj.NextContinuationToken[0]; | ||
if (xmlobj.Contents) { | ||
if (!Array.isArray(xmlobj.Contents)) { | ||
xmlobj.Contents = Array(xmlobj.Contents); | ||
} | ||
xmlobj.Contents.forEach(function (content) { | ||
var name = content.Key[0]; | ||
var lastModified = new Date(content.LastModified[0]); | ||
var etag = content.ETag[0].replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/^"$/g, ''); | ||
var size = +content.Size[0]; | ||
var name = content.Key; | ||
var lastModified = new Date(content.LastModified); | ||
var etag = content.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
var size = +content.Size; | ||
var metadata; | ||
@@ -431,0 +489,0 @@ |
{ | ||
"name": "minio", | ||
"version": "7.0.16", | ||
"version": "7.0.17", | ||
"description": "S3 Compatible Cloud Storage client", | ||
@@ -44,9 +44,9 @@ "main": "./dist/main/minio.js", | ||
"xml": "^1.0.0", | ||
"xml2js": "^0.4.15" | ||
"fast-xml-parser": "^3.17.4" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/core": "^7.11.0", | ||
"@babel/preset-env": "^7.11.0", | ||
"babelify": "^10.0.0", | ||
"browserify": "^16.3.0", | ||
"browserify": "^16.5.1", | ||
"chai": "^4.2.0", | ||
@@ -53,0 +53,0 @@ "eslint": "^6.1.0", |
Sorry, the diff of this file is too big to display
225656
4313
+ Addedfast-xml-parser@^3.17.4
+ Addedfast-xml-parser@3.21.1(transitive)
+ Addedstrnum@1.0.5(transitive)
- Removedxml2js@^0.4.15
- Removedsax@1.4.1(transitive)
- Removedxml2js@0.4.23(transitive)
- Removedxmlbuilder@11.0.1(transitive)