Comparing version 6.9.0 to 6.9.1
const assert = require('assert'); | ||
const _checkBucketName = require('../common/utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../common/utils/checkBucketName'); | ||
@@ -5,0 +5,0 @@ const proto = exports; |
@@ -14,5 +14,5 @@ const debug = require('debug')('ali-oss'); | ||
const signUtils = require('../common/signUtils'); | ||
const _isIP = require('../common/utils/isIP'); | ||
const { isIP: _isIP } = require('../common/utils/isIP'); | ||
const _initOptions = require('../common/client/initOptions'); | ||
const createRequest = require('../common/utils/createRequest'); | ||
const { createRequest } = require('../common/utils/createRequest'); | ||
@@ -19,0 +19,0 @@ const globalHttpAgent = new AgentKeepalive(); |
@@ -9,4 +9,4 @@ | ||
const copy = require('copy-to'); | ||
const isBlob = require('../common/utils/isBlob'); | ||
const isFile = require('../common/utils/isFile'); | ||
const { isBlob } = require('../common/utils/isBlob'); | ||
const { isFile } = require('../common/utils/isFile'); | ||
@@ -135,2 +135,3 @@ const proto = exports; | ||
let uploadPartJob = function uploadPartJob(self, partNo) { | ||
// eslint-disable-next-line no-async-promise-executor | ||
return new Promise(async (resolve, reject) => { | ||
@@ -137,0 +138,0 @@ try { |
@@ -13,4 +13,4 @@ | ||
const merge = require('merge-descriptors'); | ||
const isBlob = require('../common/utils/isBlob'); | ||
const isFile = require('../common/utils/isFile'); | ||
const { isBlob } = require('../common/utils/isBlob'); | ||
const { isFile } = require('../common/utils/isFile'); | ||
@@ -17,0 +17,0 @@ // var assert = require('assert'); |
const assert = require('assert'); | ||
const isArray = require('./common/utils/isArray'); | ||
const _checkBucketName = require('../lib/common/utils/checkBucketName'); | ||
const { isArray } = require('./common/utils/isArray'); | ||
const { checkBucketName: _checkBucketName } = require('../lib/common/utils/checkBucketName'); | ||
@@ -7,0 +7,0 @@ const proto = exports; |
@@ -17,5 +17,5 @@ | ||
const signUtils = require('./common/signUtils'); | ||
const _isIP = require('./common/utils/isIP'); | ||
const { isIP: _isIP } = require('./common/utils/isIP'); | ||
const _initOptions = require('./common/client/initOptions'); | ||
const createRequest = require('./common/utils/createRequest'); | ||
const { createRequest } = require('./common/utils/createRequest'); | ||
@@ -22,0 +22,0 @@ const globalHttpAgent = new AgentKeepalive(); |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,4 +0,4 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const isArray = require('../utils/isArray'); | ||
const formatObjKey = require('../utils/formatObjKey'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { isArray } = require('../utils/isArray'); | ||
const { formatObjKey } = require('../utils/formatObjKey'); | ||
@@ -5,0 +5,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
const proto = exports; | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const isObject = require('../utils/isObject'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { isObject } = require('../utils/isObject'); | ||
/** | ||
@@ -5,0 +5,0 @@ * getBucketTags |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
@@ -1,3 +0,3 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const isObject = require('../utils/isObject'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { isObject } = require('../utils/isObject'); | ||
@@ -4,0 +4,0 @@ const proto = exports; |
const proto = exports; | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
@@ -5,0 +5,0 @@ proto.putBucket = async function putBucket(name, options) { |
const proto = exports; | ||
// const jstoxml = require('jstoxml'); | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
/** | ||
@@ -6,0 +6,0 @@ * putBucketEncryption |
/* eslint-disable no-use-before-define */ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const isArray = require('../utils/isArray'); | ||
const deepCopy = require('../utils/deepCopy'); | ||
const isObject = require('../utils/isObject'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const checkObjectTag = require('../utils/checkObjectTag'); | ||
const getStrBytesCount = require('../utils/getStrBytesCount'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { isArray } = require('../utils/isArray'); | ||
const { deepCopy } = require('../utils/deepCopy'); | ||
const { isObject } = require('../utils/isObject'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
const { checkObjectTag } = require('../utils/checkObjectTag'); | ||
const { getStrBytesCount } = require('../utils/getStrBytesCount'); | ||
@@ -10,0 +10,0 @@ const proto = exports; |
@@ -1,4 +0,4 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const policy2Str = require('../utils/policy2Str'); | ||
const isObject = require('../utils/isObject'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { policy2Str } = require('../utils/policy2Str'); | ||
const { isObject } = require('../utils/isObject'); | ||
@@ -5,0 +5,0 @@ const proto = exports; |
@@ -1,3 +0,3 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
@@ -4,0 +4,0 @@ const proto = exports; |
@@ -1,4 +0,4 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const checkTag = require('../utils/checkBucketTag'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
const { checkBucketTag } = require('../utils/checkBucketTag'); | ||
@@ -15,3 +15,3 @@ const proto = exports; | ||
_checkBucketName(name); | ||
checkTag(tag); | ||
checkBucketTag(tag); | ||
const params = this._bucketRequestParams('PUT', name, 'tagging', options); | ||
@@ -18,0 +18,0 @@ params.successStatuses = [200]; |
@@ -1,3 +0,3 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
@@ -4,0 +4,0 @@ const proto = exports; |
@@ -1,4 +0,4 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const isArray = require('../utils/isArray'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
const { isArray } = require('../utils/isArray'); | ||
@@ -5,0 +5,0 @@ const proto = exports; |
const ms = require('humanize-ms'); | ||
const urlutil = require('url'); | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -5,0 +5,0 @@ function setEndpoint(endpoint, secure) { |
/* eslint-disable no-use-before-define */ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
const querystring = require('querystring'); | ||
@@ -4,0 +4,0 @@ const { Base64: { encode: str2Base64 } } = require('js-base64'); |
const copy = require('copy-to'); | ||
const callback = require('./callback'); | ||
const deepCopy = require('./utils/deepCopy'); | ||
const { deepCopy } = require('./utils/deepCopy'); | ||
@@ -6,0 +6,0 @@ const proto = exports; |
const policy2Str = require('../utils/policy2Str'); | ||
const { policy2Str } = require('../utils/policy2Str'); | ||
const signHelper = require('../signUtils'); | ||
const isObject = require('../utils/isObject'); | ||
const { isObject } = require('../utils/isObject'); | ||
@@ -6,0 +6,0 @@ const proto = exports; |
@@ -1,2 +0,2 @@ | ||
const _checkBucketName = require('../utils/checkBucketName'); | ||
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName'); | ||
@@ -3,0 +3,0 @@ const proto = exports; |
/* eslint-disable object-curly-newline */ | ||
const utility = require('utility'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
@@ -5,0 +5,0 @@ const proto = exports; |
/* eslint-disable no-use-before-define */ | ||
const proto = exports; | ||
const isObject = require('../utils/isObject'); | ||
const isArray = require('../utils/isArray'); | ||
const { isObject } = require('../utils/isObject'); | ||
const { isArray } = require('../utils/isArray'); | ||
@@ -6,0 +6,0 @@ |
const proto = exports; | ||
const isObject = require('../utils/isObject'); | ||
const { isObject } = require('../utils/isObject'); | ||
/** | ||
@@ -4,0 +4,0 @@ * getObjectTagging |
@@ -20,2 +20,4 @@ const merge = require('merge-descriptors'); | ||
merge(proto, require('./get')); | ||
merge(proto, require('./postAsyncFetch')); | ||
merge(proto, require('./getAsyncFetch')); | ||
@@ -1,3 +0,3 @@ | ||
const obj2xml = require('../utils/obj2xml'); | ||
const checkTag = require('../utils/checkObjectTag'); | ||
const { obj2xml } = require('../utils/obj2xml'); | ||
const { checkObjectTag } = require('../utils/checkObjectTag'); | ||
@@ -13,3 +13,3 @@ const proto = exports; | ||
proto.putObjectTagging = async function putObjectTagging(name, tag, options = {}) { | ||
checkTag(tag); | ||
checkObjectTag(tag); | ||
@@ -16,0 +16,0 @@ options.subres = Object.assign({ tagging: '' }, options.subres); |
@@ -1,10 +0,9 @@ | ||
/** | ||
* check Bucket Name | ||
*/ | ||
module.exports = function (name, createBucket) { | ||
const bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/; | ||
if (!bucketRegex.test(name)) { | ||
throw new Error('The bucket must be conform to the specifications'); | ||
} | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkBucketName = void 0; | ||
exports.checkBucketName = (name, createBucket) => { | ||
const bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/; | ||
if (!bucketRegex.test(name)) { | ||
throw new Error('The bucket must be conform to the specifications'); | ||
} | ||
}; |
@@ -1,52 +0,49 @@ | ||
const checkValid = require('./checkValid'); | ||
const isObject = require('./isObject'); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkBucketTag = void 0; | ||
const { checkValid } = require('./checkValid'); | ||
const { isObject } = require('./isObject'); | ||
const commonRules = [ | ||
{ | ||
validator: (value) => { | ||
if (typeof value !== 'string') { | ||
throw new Error('the key and value of the tag must be String'); | ||
} | ||
{ | ||
validator: (value) => { | ||
if (typeof value !== 'string') { | ||
throw new Error('the key and value of the tag must be String'); | ||
} | ||
} | ||
} | ||
} | ||
]; | ||
const rules = { | ||
key: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{1,64}$/, | ||
msg: 'tag key can be a maximum of 64 bytes in length' | ||
}, | ||
{ | ||
pattern: /^(?!https*:\/\/|Aliyun)/, | ||
msg: 'tag key can not startsWith: http://, https://, Aliyun' | ||
key: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{1,64}$/, | ||
msg: 'tag key can be a maximum of 64 bytes in length' | ||
}, | ||
{ | ||
pattern: /^(?!https*:\/\/|Aliyun)/, | ||
msg: 'tag key can not startsWith: http://, https://, Aliyun' | ||
} | ||
], | ||
value: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{0,128}$/, | ||
msg: 'tag value can be a maximum of 128 bytes in length' | ||
} | ||
] | ||
}; | ||
exports.checkBucketTag = (tag) => { | ||
if (!isObject(tag)) { | ||
throw new Error('bucket tag must be Object'); | ||
} | ||
], | ||
value: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{0,128}$/, | ||
msg: 'tag value can be a maximum of 128 bytes in length' | ||
const entries = Object.entries(tag); | ||
if (entries.length > 20) { | ||
throw new Error('maximum of 20 tags for a bucket'); | ||
} | ||
] | ||
}; | ||
module.exports = function checkTag(tag) { | ||
if (!isObject(tag)) { | ||
throw new Error('bucket tag must be Object'); | ||
} | ||
const entries = Object.entries(tag); | ||
if (entries.length > 20) { | ||
throw new Error('maximum of 20 tags for a bucket'); | ||
} | ||
const rulesIndexKey = ['key', 'value']; | ||
entries.forEach((keyValue) => { | ||
keyValue.forEach((item, index) => { | ||
checkValid(item, rules[rulesIndexKey[index]]); | ||
const rulesIndexKey = ['key', 'value']; | ||
entries.forEach((keyValue) => { | ||
keyValue.forEach((item, index) => { | ||
checkValid(item, rules[rulesIndexKey[index]]); | ||
}); | ||
}); | ||
}); | ||
}; |
@@ -1,53 +0,50 @@ | ||
const checkValid = require('./checkValid'); | ||
const isObject = require('./isObject'); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkObjectTag = void 0; | ||
const { checkValid } = require('./checkValid'); | ||
const { isObject } = require('./isObject'); | ||
const commonRules = [ | ||
{ | ||
validator: (value) => { | ||
if (typeof value !== 'string') { | ||
throw new Error('the key and value of the tag must be String'); | ||
} | ||
{ | ||
validator: (value) => { | ||
if (typeof value !== 'string') { | ||
throw new Error('the key and value of the tag must be String'); | ||
} | ||
} | ||
}, | ||
{ | ||
pattern: /^[a-zA-Z0-9 +-=._:/]+$/, | ||
msg: 'tag can contain letters, numbers, spaces, and the following symbols: plus sign (+), hyphen (-), equal sign (=), period (.), underscore (_), colon (:), and forward slash (/)' | ||
} | ||
}, | ||
{ | ||
pattern: /^[a-zA-Z0-9 +-=._:/]+$/, | ||
msg: 'tag can contain letters, numbers, spaces, and the following symbols: plus sign (+), hyphen (-), equal sign (=), period (.), underscore (_), colon (:), and forward slash (/)' | ||
} | ||
]; | ||
const rules = { | ||
key: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{1,128}$/, | ||
msg: 'tag key can be a maximum of 128 bytes in length' | ||
key: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{1,128}$/, | ||
msg: 'tag key can be a maximum of 128 bytes in length' | ||
} | ||
], | ||
value: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{0,256}$/, | ||
msg: 'tag value can be a maximum of 256 bytes in length' | ||
} | ||
] | ||
}; | ||
function checkObjectTag(tag) { | ||
if (!isObject(tag)) { | ||
throw new Error('tag must be Object'); | ||
} | ||
], | ||
value: [ | ||
...commonRules, | ||
{ | ||
pattern: /^.{0,256}$/, | ||
msg: 'tag value can be a maximum of 256 bytes in length' | ||
const entries = Object.entries(tag); | ||
if (entries.length > 10) { | ||
throw new Error('maximum of 10 tags for a object'); | ||
} | ||
] | ||
}; | ||
module.exports = function checkTag(tag) { | ||
if (!isObject(tag)) { | ||
throw new Error('tag must be Object'); | ||
} | ||
const entries = Object.entries(tag); | ||
if (entries.length > 10) { | ||
throw new Error('maximum of 10 tags for a object'); | ||
} | ||
const rulesIndexKey = ['key', 'value']; | ||
entries.forEach((keyValue) => { | ||
keyValue.forEach((item, index) => { | ||
checkValid(item, rules[rulesIndexKey[index]]); | ||
const rulesIndexKey = ['key', 'value']; | ||
entries.forEach((keyValue) => { | ||
keyValue.forEach((item, index) => { | ||
checkValid(item, rules[rulesIndexKey[index]]); | ||
}); | ||
}); | ||
}); | ||
}; | ||
} | ||
exports.checkObjectTag = checkObjectTag; |
@@ -1,9 +0,14 @@ | ||
module.exports = function checkValid(_value, _rules) { | ||
_rules.forEach((rule) => { | ||
if (rule.validator) { | ||
rule.validator(_value); | ||
} else if (rule.pattern && !rule.pattern.test(_value)) { | ||
throw new Error(rule.msg); | ||
} | ||
}); | ||
}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkValid = void 0; | ||
function checkValid(_value, _rules) { | ||
_rules.forEach((rule) => { | ||
if (rule.validator) { | ||
rule.validator(_value); | ||
} | ||
else if (rule.pattern && !rule.pattern.test(_value)) { | ||
throw new Error(rule.msg); | ||
} | ||
}); | ||
} | ||
exports.checkValid = checkValid; |
@@ -0,1 +1,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createRequest = void 0; | ||
const crypto = require('crypto'); | ||
@@ -7,85 +10,74 @@ const debug = require('debug')('ali-oss'); | ||
const path = require('path'); | ||
function getHeader(headers, name) { | ||
return headers[name] || headers[name.toLowerCase()]; | ||
return headers[name] || headers[name.toLowerCase()]; | ||
} | ||
function delHeader(headers, name) { | ||
delete headers[name]; | ||
delete headers[name.toLowerCase()]; | ||
delete headers[name]; | ||
delete headers[name.toLowerCase()]; | ||
} | ||
module.exports = function createRequest(params) { | ||
let date = new Date(); | ||
if (this.options.amendTimeSkewed) { | ||
date = +new Date() + this.options.amendTimeSkewed; | ||
} | ||
const headers = { | ||
'x-oss-date': dateFormat(date, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''), | ||
'x-oss-user-agent': this.userAgent | ||
}; | ||
if (this.userAgent.includes('nodejs')) { | ||
headers['User-Agent'] = this.userAgent; | ||
} | ||
if (this.options.isRequestPay) { | ||
Object.assign(headers, { 'x-oss-request-payer': 'requester' }); | ||
} | ||
if (this.options.stsToken) { | ||
headers['x-oss-security-token'] = this.options.stsToken; | ||
} | ||
copy(params.headers).to(headers); | ||
if (!getHeader(headers, 'Content-Type')) { | ||
if (params.mime && params.mime.indexOf('/') > 0) { | ||
headers['Content-Type'] = params.mime; | ||
} else { | ||
headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || '')); | ||
function createRequest(params) { | ||
let date = new Date(); | ||
if (this.options.amendTimeSkewed) { | ||
date = +new Date() + this.options.amendTimeSkewed; | ||
} | ||
} | ||
if (!getHeader(headers, 'Content-Type')) { | ||
delHeader(headers, 'Content-Type'); | ||
} | ||
if (params.content) { | ||
headers['Content-Md5'] = crypto | ||
.createHash('md5') | ||
.update(Buffer.from(params.content, 'utf8')) | ||
.digest('base64'); | ||
if (!headers['Content-Length']) { | ||
headers['Content-Length'] = params.content.length; | ||
const headers = { | ||
'x-oss-date': dateFormat(date, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''), | ||
'x-oss-user-agent': this.userAgent | ||
}; | ||
if (this.userAgent.includes('nodejs')) { | ||
headers['User-Agent'] = this.userAgent; | ||
} | ||
} | ||
const authResource = this._getResource(params); | ||
headers.authorization = this.authorization(params.method, authResource, params.subres, headers); | ||
const url = this._getReqUrl(params); | ||
debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream); | ||
const timeout = params.timeout || this.options.timeout; | ||
const reqParams = { | ||
method: params.method, | ||
content: params.content, | ||
stream: params.stream, | ||
headers, | ||
timeout, | ||
writeStream: params.writeStream, | ||
customResponse: params.customResponse, | ||
ctx: params.ctx || this.ctx | ||
}; | ||
if (this.agent) { | ||
reqParams.agent = this.agent; | ||
} | ||
if (this.httpsAgent) { | ||
reqParams.httpsAgent = this.httpsAgent; | ||
} | ||
return { | ||
url, | ||
params: reqParams | ||
}; | ||
}; | ||
if (this.options.isRequestPay) { | ||
Object.assign(headers, { 'x-oss-request-payer': 'requester' }); | ||
} | ||
if (this.options.stsToken) { | ||
headers['x-oss-security-token'] = this.options.stsToken; | ||
} | ||
copy(params.headers).to(headers); | ||
if (!getHeader(headers, 'Content-Type')) { | ||
if (params.mime && params.mime.indexOf('/') > 0) { | ||
headers['Content-Type'] = params.mime; | ||
} | ||
else { | ||
headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || '')); | ||
} | ||
} | ||
if (!getHeader(headers, 'Content-Type')) { | ||
delHeader(headers, 'Content-Type'); | ||
} | ||
if (params.content) { | ||
headers['Content-Md5'] = crypto | ||
.createHash('md5') | ||
.update(Buffer.from(params.content, 'utf8')) | ||
.digest('base64'); | ||
if (!headers['Content-Length']) { | ||
headers['Content-Length'] = params.content.length; | ||
} | ||
} | ||
const authResource = this._getResource(params); | ||
headers.authorization = this.authorization(params.method, authResource, params.subres, headers); | ||
const url = this._getReqUrl(params); | ||
debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream); | ||
const timeout = params.timeout || this.options.timeout; | ||
const reqParams = { | ||
method: params.method, | ||
content: params.content, | ||
stream: params.stream, | ||
headers, | ||
timeout, | ||
writeStream: params.writeStream, | ||
customResponse: params.customResponse, | ||
ctx: params.ctx || this.ctx | ||
}; | ||
if (this.agent) { | ||
reqParams.agent = this.agent; | ||
} | ||
if (this.httpsAgent) { | ||
reqParams.httpsAgent = this.httpsAgent; | ||
} | ||
return { | ||
url, | ||
params: reqParams | ||
}; | ||
} | ||
exports.createRequest = createRequest; |
@@ -1,20 +0,13 @@ | ||
module.exports = function deepCopy(obj, cache = []) { | ||
if (obj === null || typeof obj !== 'object') { | ||
return obj; | ||
} | ||
const hit = cache.filter(c => c.original === obj)[0]; | ||
if (hit) { | ||
return hit.copy; | ||
} | ||
const copy = Array.isArray(obj) ? [] : {}; | ||
cache.push({ | ||
original: obj, | ||
copy | ||
}); | ||
Object.keys(obj).forEach((key) => { | ||
copy[key] = deepCopy(obj[key], cache); | ||
}); | ||
return copy; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deepCopy = void 0; | ||
exports.deepCopy = (obj) => { | ||
if (obj === null || typeof obj !== 'object') { | ||
return obj; | ||
} | ||
const copy = Array.isArray(obj) ? [] : {}; | ||
Object.keys(obj).forEach((key) => { | ||
copy[key] = exports.deepCopy(obj[key]); | ||
}); | ||
return copy; | ||
}; |
@@ -1,29 +0,32 @@ | ||
/* eslint-disable no-use-before-define */ | ||
module.exports = function formatObjKey(obj, type) { | ||
if (obj === null || typeof obj !== 'object') { | ||
return obj; | ||
} | ||
let o; | ||
if (Array.isArray(obj)) { | ||
o = []; | ||
for (let i = 0; i < obj.length; i++) { | ||
o.push(formatObjKey(obj[i], type)); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatObjKey = void 0; | ||
function formatObjKey(obj, type) { | ||
if (obj === null || typeof obj !== 'object') { | ||
return obj; | ||
} | ||
} else { | ||
o = {}; | ||
Object.keys(obj).forEach((key) => { | ||
o[handelFormat(key, type)] = formatObjKey(obj[key], type); | ||
}); | ||
} | ||
return o; | ||
}; | ||
let o; | ||
if (Array.isArray(obj)) { | ||
o = []; | ||
for (let i = 0; i < obj.length; i++) { | ||
o.push(formatObjKey(obj[i], type)); | ||
} | ||
} | ||
else { | ||
o = {}; | ||
Object.keys(obj).forEach((key) => { | ||
o[handelFormat(key, type)] = formatObjKey(obj[key], type); | ||
}); | ||
} | ||
return o; | ||
} | ||
exports.formatObjKey = formatObjKey; | ||
function handelFormat(key, type) { | ||
if (type === 'firstUpperCase') { | ||
key = key.replace(/^./, _ => _.toUpperCase()); | ||
} else if (type === 'firstLowerCase') { | ||
key = key.replace(/^./, _ => _.toLowerCase()); | ||
} | ||
return key; | ||
if (type === 'firstUpperCase') { | ||
key = key.replace(/^./, (_) => _.toUpperCase()); | ||
} | ||
else if (type === 'firstLowerCase') { | ||
key = key.replace(/^./, (_) => _.toLowerCase()); | ||
} | ||
return key; | ||
} |
@@ -1,12 +0,17 @@ | ||
module.exports = function getStrBytesCount(str) { | ||
let bytesCount = 0; | ||
for (let i = 0; i < str.length; i++) { | ||
const c = str.charAt(i); | ||
if (/^[\u00-\uff]$/.test(c)) { | ||
bytesCount += 1; | ||
} else { | ||
bytesCount += 2; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getStrBytesCount = void 0; | ||
function getStrBytesCount(str) { | ||
let bytesCount = 0; | ||
for (let i = 0; i < str.length; i++) { | ||
const c = str.charAt(i); | ||
if (/^[\u00-\uff]$/.test(c)) { | ||
bytesCount += 1; | ||
} | ||
else { | ||
bytesCount += 2; | ||
} | ||
} | ||
} | ||
return bytesCount; | ||
}; | ||
return bytesCount; | ||
} | ||
exports.getStrBytesCount = getStrBytesCount; |
@@ -1,3 +0,6 @@ | ||
module.exports = function isArray(obj) { | ||
return Object.prototype.toString.call(obj) === '[object Array]'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isArray = void 0; | ||
exports.isArray = (obj) => { | ||
return Object.prototype.toString.call(obj) === '[object Array]'; | ||
}; |
@@ -1,3 +0,7 @@ | ||
module.exports = function isBlob(blob) { | ||
return typeof (Blob) !== 'undefined' && blob instanceof Blob; | ||
}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isBlob = void 0; | ||
function isBlob(blob) { | ||
return typeof (Blob) !== 'undefined' && blob instanceof Blob; | ||
} | ||
exports.isBlob = isBlob; |
@@ -1,3 +0,6 @@ | ||
module.exports = function isFile(obj) { | ||
return typeof (File) !== 'undefined' && obj instanceof File; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isFile = void 0; | ||
exports.isFile = (obj) => { | ||
return typeof (File) !== 'undefined' && obj instanceof File; | ||
}; |
@@ -0,1 +1,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isIP = void 0; | ||
// it provide commont methods for node and browser , we will add more solutions later in this file | ||
@@ -7,7 +10,6 @@ /** | ||
*/ | ||
module.exports = function (host) { | ||
const ipv4Regex = /^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/; | ||
const ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; | ||
const isIP = ipv4Regex.test(host) || ipv6Regex.test(host); | ||
return isIP; | ||
exports.isIP = (host) => { | ||
const ipv4Regex = /^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/; | ||
const ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; | ||
return ipv4Regex.test(host) || ipv6Regex.test(host); | ||
}; |
@@ -1,3 +0,6 @@ | ||
module.exports = function isObject(obj) { | ||
return Object.prototype.toString.call(obj) === '[object Object]'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isObject = void 0; | ||
exports.isObject = (obj) => { | ||
return Object.prototype.toString.call(obj) === '[object Object]'; | ||
}; |
@@ -1,38 +0,42 @@ | ||
const formatObjKey = require('./formatObjKey'); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.obj2xml = void 0; | ||
const formatObjKey_1 = require("./formatObjKey"); | ||
function type(params) { | ||
return Object.prototype.toString | ||
.call(params) | ||
.replace(/(.*? |])/g, '') | ||
.toLowerCase(); | ||
return Object.prototype.toString | ||
.call(params) | ||
.replace(/(.*? |])/g, '') | ||
.toLowerCase(); | ||
} | ||
function obj2xml(obj, options) { | ||
let s = ''; | ||
if (options && options.headers) { | ||
s = '<?xml version="1.0" encoding="UTF-8"?>\n'; | ||
} | ||
if (options && options.firstUpperCase) { | ||
obj = formatObjKey(obj, 'firstUpperCase'); | ||
} | ||
if (type(obj) === 'object') { | ||
Object.keys(obj).forEach((key) => { | ||
if (type(obj[key]) === 'string' || type(obj[key]) === 'number') { | ||
s += `<${key}>${obj[key]}</${key}>`; | ||
} else if (type(obj[key]) === 'object') { | ||
s += `<${key}>${obj2xml(obj[key])}</${key}>`; | ||
} else if (type(obj[key]) === 'array') { | ||
s += obj[key] | ||
.map(keyChild => `<${key}>${obj2xml(keyChild)}</${key}>`) | ||
.join(''); | ||
} else { | ||
s += `<${key}>${obj[key].toString()}</${key}>`; | ||
} | ||
}); | ||
} else { | ||
s += obj.toString(); | ||
} | ||
return s; | ||
let s = ''; | ||
if (options && options.headers) { | ||
s = '<?xml version="1.0" encoding="UTF-8"?>\n'; | ||
} | ||
if (options && options.firstUpperCase) { | ||
obj = formatObjKey_1.formatObjKey(obj, 'firstUpperCase'); | ||
} | ||
if (type(obj) === 'object') { | ||
Object.keys(obj).forEach((key) => { | ||
if (type(obj[key]) === 'string' || type(obj[key]) === 'number') { | ||
s += `<${key}>${obj[key]}</${key}>`; | ||
} | ||
else if (type(obj[key]) === 'object') { | ||
s += `<${key}>${obj2xml(obj[key])}</${key}>`; | ||
} | ||
else if (type(obj[key]) === 'array') { | ||
s += obj[key] | ||
.map(keyChild => `<${key}>${obj2xml(keyChild)}</${key}>`) | ||
.join(''); | ||
} | ||
else { | ||
s += `<${key}>${obj[key].toString()}</${key}>`; | ||
} | ||
}); | ||
} | ||
else { | ||
s += obj.toString(); | ||
} | ||
return s; | ||
} | ||
module.exports = obj2xml; | ||
exports.obj2xml = obj2xml; |
@@ -0,17 +1,21 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.policy2Str = void 0; | ||
function policy2Str(policy) { | ||
let policyStr; | ||
if (policy) { | ||
if (typeof policy === 'string') { | ||
try { | ||
policyStr = JSON.stringify(JSON.parse(policy)); | ||
} catch (err) { | ||
throw new Error(`Policy string is not a valid JSON: ${err.message}`); | ||
} | ||
} else { | ||
policyStr = JSON.stringify(policy); | ||
let policyStr; | ||
if (policy) { | ||
if (typeof policy === 'string') { | ||
try { | ||
policyStr = JSON.stringify(JSON.parse(policy)); | ||
} | ||
catch (err) { | ||
throw new Error(`Policy string is not a valid JSON: ${err.message}`); | ||
} | ||
} | ||
else { | ||
policyStr = JSON.stringify(policy); | ||
} | ||
} | ||
} | ||
return policyStr; | ||
return policyStr; | ||
} | ||
module.exports = policy2Str; | ||
exports.policy2Str = policy2Str; |
@@ -7,3 +7,3 @@ | ||
const mime = require('mime'); | ||
const isFile = require('./common/utils/isFile'); | ||
const { isFile } = require('./common/utils/isFile'); | ||
@@ -115,2 +115,3 @@ const proto = exports; | ||
let uploadPartJob = function uploadPartJob(self, partNo) { | ||
// eslint-disable-next-line no-async-promise-executor | ||
return new Promise(async (resolve, reject) => { | ||
@@ -117,0 +118,0 @@ try { |
{ | ||
"name": "ali-oss", | ||
"version": "6.9.0", | ||
"version": "6.9.1", | ||
"description": "aliyun oss(object storage service) node client", | ||
@@ -30,3 +30,3 @@ "main": "lib/client.js", | ||
"browser-test": "npm run build-test && karma start", | ||
"build-dist": "node browser-build.js > dist/aliyun-oss-sdk.js && MINIFY=1 node browser-build.js > dist/aliyun-oss-sdk.min.js", | ||
"build-dist": "npm run tsc && node browser-build.js > dist/aliyun-oss-sdk.js && MINIFY=1 node browser-build.js > dist/aliyun-oss-sdk.min.js", | ||
"publish-to-npm": "node publish-npm-check.js && npm publish", | ||
@@ -37,3 +37,7 @@ "publish-to-cdn": "node publish.js", | ||
"lint-staged": "lint-staged", | ||
"detect-secrets": "node task/detect-secrets" | ||
"detect-secrets": "node task/detect-secrets", | ||
"tsc": "npm run tsc:clean && npm run tsc:build", | ||
"tsc:build": "tsc -b tsconfig.json tsconfig-cjs.json", | ||
"tsc:watch": "tsc -b tsconfig.json tsconfig-cjs.json --watch", | ||
"tsc:clean": "tsc -b tsconfig.json tsconfig-cjs.json --clean " | ||
}, | ||
@@ -68,2 +72,5 @@ "git-pre-hooks": { | ||
"devDependencies": { | ||
"@types/node": "^14.0.12", | ||
"@typescript-eslint/eslint-plugin": "^2.34.0", | ||
"@typescript-eslint/parser": "^2.34.0", | ||
"aliasify": "^2.0.0", | ||
@@ -84,5 +91,6 @@ "autod": "^2.6.1", | ||
"crypto-js": "^3.1.9-1", | ||
"eslint": "^6.7.2", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-plugin-import": "^2.9.0", | ||
"eslint-config-ali": "^9.0.2", | ||
"eslint-plugin-import": "^2.21.1", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
@@ -112,2 +120,3 @@ "eslint-plugin-react": "^7.7.0", | ||
"timemachine": "^0.3.0", | ||
"typescript": "^3.9.5", | ||
"uglify-js": "^2.8.29", | ||
@@ -114,0 +123,0 @@ "watchify": "^3.9.0" |
const { Stream } = require('stream'); | ||
const isArray = require('../lib/common/utils/isArray'); | ||
const { isArray } = require('../lib/common/utils/isArray'); | ||
@@ -4,0 +4,0 @@ module.exports.string = function isString(obj) { |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
1689957
139
33019
49
16