Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.uploadToken = function uploadToken(options) {
options = options || {};
options.scope = options.scope || this.options.bucket;
options.deadline = options.deadline || (utility.timestamp() + 3600);
var flags = options;
// 步骤2:将 Flags 进行安全编码
var encodedFlags = utility.base64encode(JSON.stringify(flags), true);
// 步骤3:将编码后的元数据混入私钥进行签名
// 步骤4:将签名摘要值进行安全编码
var encodedSign = this.signData(encodedFlags);
// 步骤5:连接各字符串,生成上传授权凭证
return this.options.accessKey + ':' + encodedSign + ':' + encodedFlags;
};
exports.fetch = function (url, key, callback) {
var encodedURL = utility.base64encode(url);
var pathname = '/fetch/' + encodedURL + '/to/' + this.encodeEntryURI(key);
this._rsAction(pathname, callback, 'http://iovip.qbox.me');
};
exports.encodeEntryURI = function (key) {
key = this.resourceKey(key);
return utility.base64encode(this.options.bucket + ':' + key, true);
};
exports.getGithubBasicAuth = function (argument) {
return config.githubToken
? 'Basic ' + utility.base64encode(util.format('%s:x-oauth-basic', config.githubToken))
: '';
};
function rc4Encrypt(data) {
return encodeHex(rc4(utility.base64encode(data), KEY));
}
exports.request = function request(url, args) {
assert(url, 'url required');
args = args || {};
var input = utility.base64encode(JSON.stringify({
url: url,
args: args
}));
var requestPath = path.join(__dirname, './request.js');
var cmd = process.execPath;
var _args = [requestPath, input];
var res = cp.spawnSync(cmd, _args, {
timeout: (args.timeout || 3000) + 1000
});
if (res.error) {
res.error.url = url;
res.error.args = args;
throw res.error;
}