Comparing version 7.0.17 to 7.0.18
@@ -55,2 +55,13 @@ "use strict"; | ||
return result; | ||
}; // toArray returns a single element array with param being the element, | ||
// if param is just a string, and returns 'param' back if it is an array | ||
// So, it makes sure param is always an array | ||
var toArray = function toArray(param) { | ||
if (!Array.isArray(param)) { | ||
return Array(param); | ||
} | ||
return param; | ||
}; // Parse XML and return information as Javascript types | ||
@@ -114,17 +125,16 @@ // parse error XML response | ||
xmlobj = xmlobj.ListMultipartUploadsResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.IsTruncated) result.isTruncated = xmlobj.IsTruncated; | ||
if (xmlobj.NextKeyMarker) result.nextKeyMarker = xmlobj.NextKeyMarker; | ||
if (xmlobj.NextUploadIdMarker) result.nextUploadIdMarker = xmlobj.NextUploadIdMarker[0]; | ||
if (xmlobj.CommonPrefixes) xmlobj.CommonPrefixes.forEach(function (prefix) { | ||
result.prefixes.push({ | ||
prefix: prefix[0] | ||
if (xmlobj.NextUploadIdMarker) result.nextUploadIdMarker = xmlobj.nextUploadIdMarker; | ||
if (xmlobj.CommonPrefixes) { | ||
toArray(xmlobj.CommonPrefixes).forEach(function (prefix) { | ||
result.prefixes.push({ | ||
prefix: toArray(prefix)[0] | ||
}); | ||
}); | ||
}); | ||
} | ||
if (xmlobj.Upload) { | ||
if (!Array.isArray(xmlobj.Upload)) { | ||
xmlobj.Upload = Array(xmlobj.Upload); | ||
} | ||
xmlobj.Upload.forEach(function (upload) { | ||
toArray(xmlobj.Upload).forEach(function (upload) { | ||
var key = upload.Key; | ||
@@ -169,7 +179,3 @@ var uploadId = upload.UploadId; | ||
if (xmlobj.Buckets.Bucket) { | ||
if (!Array.isArray(xmlobj.Buckets.Bucket)) { | ||
xmlobj.Buckets.Bucket = Array(xmlobj.Buckets.Bucket); | ||
} | ||
xmlobj.Buckets.Bucket.forEach(function (bucket) { | ||
toArray(xmlobj.Buckets.Bucket).forEach(function (bucket) { | ||
var name = bucket.Name; | ||
@@ -200,3 +206,3 @@ var creationDate = new Date(bucket.CreationDate); | ||
if (events) { | ||
events.forEach(function (s3event) { | ||
toArray(events).forEach(function (s3event) { | ||
result.push(s3event); | ||
@@ -213,11 +219,19 @@ }); | ||
if (filters && filters[0].S3Key && filters[0].S3Key[0].FilterRule) { | ||
filters[0].S3Key[0].FilterRule.forEach(function (rule) { | ||
var Name = rule.Name[0]; | ||
var Value = rule.Value[0]; | ||
result.push({ | ||
Name, | ||
Value | ||
}); | ||
}); | ||
if (filters) { | ||
filters = toArray(filters); | ||
if (filters[0].S3Key) { | ||
filters[0].S3Key = toArray(filters[0].S3Key); | ||
if (filters[0].S3Key[0].FilterRule) { | ||
toArray(filters[0].S3Key[0].FilterRule).forEach(function (rule) { | ||
var Name = toArray(rule.Name)[0]; | ||
var Value = toArray(rule.Value)[0]; | ||
result.push({ | ||
Name, | ||
Value | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
@@ -228,8 +242,9 @@ | ||
var xmlobj = parseXml(xml); // Parse all topic configurations in the xml | ||
var xmlobj = parseXml(xml); | ||
xmlobj = xmlobj.NotificationConfiguration; // Parse all topic configurations in the xml | ||
if (xmlobj.TopicConfiguration) { | ||
xmlobj.TopicConfiguration.forEach(function (config) { | ||
var Id = config.Id[0]; | ||
var Topic = config.Topic[0]; | ||
toArray(xmlobj.TopicConfiguration).forEach(function (config) { | ||
var Id = toArray(config.Id)[0]; | ||
var Topic = toArray(config.Topic)[0]; | ||
var Event = genEvents(config.Event); | ||
@@ -248,5 +263,5 @@ var Filter = genFilterRules(config.Filter); | ||
if (xmlobj.QueueConfiguration) { | ||
xmlobj.QueueConfiguration.forEach(function (config) { | ||
var Id = config.Id[0]; | ||
var Queue = config.Queue[0]; | ||
toArray(xmlobj.QueueConfiguration).forEach(function (config) { | ||
var Id = toArray(config.Id)[0]; | ||
var Queue = toArray(config.Queue)[0]; | ||
var Event = genEvents(config.Event); | ||
@@ -265,5 +280,5 @@ var Filter = genFilterRules(config.Filter); | ||
if (xmlobj.CloudFunctionConfiguration) { | ||
xmlobj.CloudFunctionConfiguration.forEach(function (config) { | ||
var Id = config.Id[0]; | ||
var CloudFunction = config.CloudFunction[0]; | ||
toArray(xmlobj.CloudFunctionConfiguration).forEach(function (config) { | ||
var Id = toArray(config.Id)[0]; | ||
var CloudFunction = toArray(config.CloudFunction)[0]; | ||
var Event = genEvents(config.Event); | ||
@@ -297,8 +312,14 @@ var Filter = genFilterRules(config.Filter); | ||
}; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.NextPartNumberMarker) result.marker = +xmlobj.NextPartNumberMarker[0]; | ||
if (!xmlobj.ListPartsResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "ListPartsResult"'); | ||
} | ||
xmlobj = xmlobj.ListPartsResult; | ||
if (xmlobj.IsTruncated) result.isTruncated = xmlobj.IsTruncated; | ||
if (xmlobj.NextPartNumberMarker) result.marker = +toArray(xmlobj.NextPartNumberMarker)[0]; | ||
if (xmlobj.Part) { | ||
xmlobj.Part.forEach(function (p) { | ||
var part = +p.PartNumber[0]; | ||
toArray(xmlobj.Part).forEach(function (p) { | ||
var part = +toArray(p.PartNumber)[0]; | ||
var lastModified = new Date(p.LastModified); | ||
@@ -319,3 +340,9 @@ var etag = p.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
function parseInitiateMultipart(xml) { | ||
var xmlobj = parseXml(xml).InitiateMultipartUploadResult; | ||
var xmlobj = parseXml(xml); | ||
if (!xmlobj.InitiateMultipartUploadResult) { | ||
throw new errors.InvalidXMLError('Missing tag: "InitiateMultipartUploadResult"'); | ||
} | ||
xmlobj = xmlobj.InitiateMultipartUploadResult; | ||
if (xmlobj.UploadId) return xmlobj.UploadId; | ||
@@ -330,4 +357,4 @@ throw new errors.InvalidXMLError('Missing tag: "UploadId"'); | ||
if (xmlobj.Location) { | ||
var location = xmlobj.Location[0]; | ||
var bucket = xmlobj.Bucket[0]; | ||
var location = toArray(xmlobj.Location)[0]; | ||
var bucket = toArray(xmlobj.Bucket)[0]; | ||
var key = xmlobj.Key; | ||
@@ -345,4 +372,4 @@ var etag = xmlobj.ETag.replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
if (xmlobj.Code && xmlobj.Message) { | ||
var errCode = xmlobj.Code[0]; | ||
var errMessage = xmlobj.Message[0]; | ||
var errCode = toArray(xmlobj.Code)[0]; | ||
var errMessage = toArray(xmlobj.Message)[0]; | ||
return { | ||
@@ -369,14 +396,10 @@ errCode, | ||
xmlobj = xmlobj.ListBucketResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') xmlobj.isTruncated = true; | ||
if (xmlobj.IsTruncated) result.isTruncated = xmlobj.IsTruncated; | ||
if (xmlobj.Contents) { | ||
if (!Array.isArray(xmlobj.Contents)) { | ||
xmlobj.Contents = Array(xmlobj.Contents); | ||
} | ||
xmlobj.Contents.forEach(function (content) { | ||
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 name = toArray(content.Key)[0]; | ||
var lastModified = new Date(toArray(content.LastModified)[0]); | ||
var etag = toArray(content.ETag)[0].replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, '').replace(/^"/g, '').replace(/"$/g, ''); | ||
var size = content.Size; | ||
result.objects.push({ | ||
@@ -393,4 +416,4 @@ name, | ||
if (xmlobj.CommonPrefixes) { | ||
xmlobj.CommonPrefixes.forEach(function (commonPrefix) { | ||
var prefix = commonPrefix.Prefix[0]; | ||
toArray(xmlobj.CommonPrefixes).forEach(function (commonPrefix) { | ||
var prefix = toArray(commonPrefix.Prefix)[0]; | ||
var size = 0; | ||
@@ -405,3 +428,3 @@ result.objects.push({ | ||
if (result.isTruncated) { | ||
result.nextMarker = xmlobj.NextMarker ? xmlobj.NextMarker[0] : nextMarker; | ||
result.nextMarker = xmlobj.NextMarker ? toArray(xmlobj.NextMarker)[0] : nextMarker; | ||
} | ||
@@ -425,15 +448,11 @@ | ||
xmlobj = xmlobj.ListBucketResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.NextContinuationToken) result.nextContinuationToken = xmlobj.NextContinuationToken[0]; | ||
if (xmlobj.IsTruncated) result.isTruncated = xmlobj.IsTruncated; | ||
if (xmlobj.NextContinuationToken) result.nextContinuationToken = xmlobj.NextContinuationToken; | ||
if (xmlobj.Contents) { | ||
if (!Array.isArray(xmlobj.Contents)) { | ||
xmlobj.Contents = Array(xmlobj.Contents); | ||
} | ||
xmlobj.Contents.forEach(function (content) { | ||
toArray(xmlobj.Contents).forEach(function (content) { | ||
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 size = content.Size; | ||
result.objects.push({ | ||
@@ -449,4 +468,4 @@ name, | ||
if (xmlobj.CommonPrefixes) { | ||
xmlobj.CommonPrefixes.forEach(function (commonPrefix) { | ||
var prefix = commonPrefix.Prefix[0]; | ||
toArray(xmlobj.CommonPrefixes).forEach(function (commonPrefix) { | ||
var prefix = toArray(commonPrefix.Prefix)[0]; | ||
var size = 0; | ||
@@ -476,19 +495,15 @@ result.objects.push({ | ||
xmlobj = xmlobj.ListBucketResult; | ||
if (xmlobj.IsTruncated && xmlobj.IsTruncated === 'true') result.isTruncated = true; | ||
if (xmlobj.NextContinuationToken) result.nextContinuationToken = xmlobj.NextContinuationToken[0]; | ||
if (xmlobj.IsTruncated) result.isTruncated = xmlobj.IsTruncated; | ||
if (xmlobj.NextContinuationToken) result.nextContinuationToken = xmlobj.NextContinuationToken; | ||
if (xmlobj.Contents) { | ||
if (!Array.isArray(xmlobj.Contents)) { | ||
xmlobj.Contents = Array(xmlobj.Contents); | ||
} | ||
xmlobj.Contents.forEach(function (content) { | ||
toArray(xmlobj.Contents).forEach(function (content) { | ||
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 size = content.Size; | ||
var metadata; | ||
if (content.UserMetadata != null) { | ||
metadata = content.UserMetadata[0]; | ||
metadata = toArray(content.UserMetadata)[0]; | ||
} else { | ||
@@ -509,4 +524,4 @@ metadata = null; | ||
if (xmlobj.CommonPrefixes) { | ||
xmlobj.CommonPrefixes.forEach(function (commonPrefix) { | ||
var prefix = commonPrefix.Prefix[0]; | ||
toArray(xmlobj.CommonPrefixes).forEach(function (commonPrefix) { | ||
var prefix = toArray(commonPrefix.Prefix)[0]; | ||
var size = 0; | ||
@@ -513,0 +528,0 @@ result.objects.push({ |
{ | ||
"name": "minio", | ||
"version": "7.0.17", | ||
"version": "7.0.18", | ||
"description": "S3 Compatible Cloud Storage client", | ||
@@ -37,4 +37,5 @@ "main": "./dist/main/minio.js", | ||
"es6-error": "^4.1.1", | ||
"fast-xml-parser": "^3.17.5", | ||
"json-stream": "^1.0.0", | ||
"lodash": "^4.14.2", | ||
"lodash": "^4.17.20", | ||
"mime-types": "^2.1.14", | ||
@@ -45,9 +46,9 @@ "mkdirp": "^0.5.1", | ||
"xml": "^1.0.0", | ||
"fast-xml-parser": "^3.17.4" | ||
"xml2js": "^0.4.15" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.0", | ||
"@babel/preset-env": "^7.11.0", | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.10", | ||
"babelify": "^10.0.0", | ||
"browserify": "^16.5.1", | ||
"browserify": "^16.5.2", | ||
"chai": "^4.2.0", | ||
@@ -54,0 +55,0 @@ "eslint": "^6.1.0", |
Sorry, the diff of this file is too big to display
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
226231
4323
12
+ Addedxml2js@^0.4.15
+ Addedsax@1.4.1(transitive)
+ Addedxml2js@0.4.23(transitive)
+ Addedxmlbuilder@11.0.1(transitive)
Updatedfast-xml-parser@^3.17.5
Updatedlodash@^4.17.20