New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ali-oss

Package Overview
Dependencies
Maintainers
7
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ali-oss - npm Package Compare versions

Comparing version 6.15.1 to 6.15.2-parallel.1

lib/common/utils/isFunction.d.ts

16

lib/browser/client.js

@@ -17,2 +17,3 @@ const debug = require('debug')('ali-oss');

const { retry } = require('../common/utils/retry');
const { isFunction } = require('../common/utils/isFunction');

@@ -218,2 +219,5 @@ const globalHttpAgent = new AgentKeepalive();

async function request(params) {
if (this.options.stsToken && isFunction(this.options.refreshSTSToken)) {
await setSTSToken.call(this);
}
const reqParams = createRequest.call(this, params);

@@ -246,12 +250,2 @@ if (!this.options.useFetch) {

if (err) {
if (err.status === 403 && err.code === 'InvalidAccessKeyId' &&
this.options.accessKeyId.startsWith('STS.') &&
typeof this.options.refreshSTSToken === 'function') {
// prevent infinite loop, only trigger once within 10 seconds
if (!this._setOptions || Date.now() - this._setOptions > 10000) {
this._setOptions = Date.now();
await setSTSToken.call(this);
return this.request(params);
}
}
throw err;

@@ -265,3 +259,3 @@ }

return result;
};
}

@@ -268,0 +262,0 @@ proto._getResource = function _getResource(params) {

@@ -20,2 +20,3 @@

const { retry } = require('./common/utils/retry');
const { isFunction } = require('./common/utils/isFunction');

@@ -190,2 +191,5 @@ const globalHttpAgent = new AgentKeepalive();

async function request(params) {
if (this.options.stsToken && isFunction(this.options.refreshSTSToken)) {
await setSTSToken.call(this);
}
const reqParams = createRequest.call(this, params);

@@ -214,15 +218,2 @@ let result;

if (err.status === 403 && err.code === 'InvalidAccessKeyId' &&
this.options.accessKeyId.startsWith('STS.') &&
typeof this.options.refreshSTSToken === 'function') {
// prevent infinite loop, only trigger once within 10 seconds
if (!this._setOptions || Date.now() - this._setOptions > 10000) {
this._setOptions = Date.now();
await setSTSToken.call(this);
if (!params.stream) {
return this.request(params);
}
}
}
if (err.name === 'ResponseTimeoutError') {

@@ -229,0 +220,0 @@ err.message = `${err.message.split(',')[0]}, please increase the timeout or use multipartDownload.`;

@@ -26,5 +26,6 @@ const ms = require('humanize-ms');

}
if (options.stsToken && !options.refreshSTSToken) {
if (options.stsToken && !options.refreshSTSToken && !options.refreshSTSTokenInterval) {
console.warn(
"It's recommended to set `refreshSTSToken` to refresh stsToken、accessKeyId、accessKeySecret automatically when sts info expires"
"It's recommended to set 'refreshSTSToken' and 'refreshSTSTokenInterval' to refresh" +
' stsToken、accessKeyId、accessKeySecret automatically when sts token has expired'
);

@@ -48,2 +49,3 @@ }

refreshSTSToken: null,
refreshSTSTokenInterval: 60000 * 5,
retryMax: 0

@@ -50,0 +52,0 @@ },

@@ -1,2 +0,2 @@

const { isArray } = require("./utils/isArray");
const { isArray } = require('./utils/isArray');

@@ -3,0 +3,0 @@ const proto = exports;

@@ -1,1 +0,1 @@

export declare function setSTSToken(this: any): Promise<void>;
export declare function setSTSToken(this: any): Promise<null>;

@@ -8,9 +8,19 @@ "use strict";

this.options = {};
let credentials = await this.options.refreshSTSToken();
credentials = formatObjKey_1.formatObjKey(credentials, 'firstLowerCase');
if (credentials.securityToken) {
credentials.stsToken = credentials.securityToken;
const now = new Date();
if (this.stsTokenFreshTime) {
if (+now - this.stsTokenFreshTime >= this.options.refreshSTSTokenInterval) {
this.stsTokenFreshTime = now;
let credentials = await this.options.refreshSTSToken();
credentials = formatObjKey_1.formatObjKey(credentials, 'firstLowerCase');
if (credentials.securityToken) {
credentials.stsToken = credentials.securityToken;
}
checkCredentials(credentials);
Object.assign(this.options, credentials);
}
}
checkCredentials(credentials);
Object.assign(this.options, credentials);
else {
this.stsTokenFreshTime = now;
}
return null;
}

@@ -17,0 +27,0 @@ exports.setSTSToken = setSTSToken;

@@ -5,9 +5,19 @@ import { formatObjKey } from './formatObjKey';

if (!this.options) this.options = {};
let credentials = await this.options.refreshSTSToken();
credentials = formatObjKey(credentials, 'firstLowerCase');
if (credentials.securityToken) {
credentials.stsToken = credentials.securityToken;
const now = new Date();
if (this.stsTokenFreshTime) {
if (+now - this.stsTokenFreshTime >= this.options.refreshSTSTokenInterval) {
this.stsTokenFreshTime = now;
let credentials = await this.options.refreshSTSToken();
credentials = formatObjKey(credentials, 'firstLowerCase');
if (credentials.securityToken) {
credentials.stsToken = credentials.securityToken;
}
checkCredentials(credentials);
Object.assign(this.options, credentials);
}
} else {
this.stsTokenFreshTime = now;
}
checkCredentials(credentials);
Object.assign(this.options, credentials);
return null;
}

@@ -14,0 +24,0 @@

@@ -110,2 +110,3 @@ const fs = require('fs');

proto._resumeMultipart = async function _resumeMultipart(checkpoint, options) {
const that = this;
if (this.isCancel()) {

@@ -211,3 +212,9 @@ throw this._makeCancelEvent();

// upload in parallel
const jobErr = await this._parallelNode(todo, parallel, uploadPartJob);
const jobErr = await this._parallel(todo, parallel,
value => new Promise((resolve, reject) => {
uploadPartJob(that, value).then(res => {
console.log(res, 'res');
resolve();
}).catch(reject);
}));

@@ -214,0 +221,0 @@ const abortEvent = jobErr.find(err => err.name === 'abort');

{
"name": "ali-oss",
"version": "6.15.1",
"version": "6.15.2-parallel.1",
"description": "aliyun oss(object storage service) node client",

@@ -24,4 +24,4 @@ "main": "lib/client.js",

"build-change-log": "standard-version",
"test": "mocha -t 60000 -r thunk-mocha -r should -r dotenv/config test/node/*.test.js test/node/**/*.test.js",
"test-cov": "nyc --reporter=lcov node_modules/.bin/_mocha -t 60000 -r thunk-mocha -r should test/node/*.test.js test/node/**/*.test.js",
"test": "npm run tsc && mocha -t 60000 -r thunk-mocha -r should -r dotenv/config test/node/*.test.js test/node/**/*.test.js",
"test-cov": "npm run tsc && nyc --reporter=lcov node_modules/.bin/_mocha -t 60000 -r thunk-mocha -r should test/node/*.test.js test/node/**/*.test.js",
"jshint": "jshint .",

@@ -115,3 +115,3 @@ "autod": "autod",

"sinon": "^1.17.7",
"snyk": "^1.520.0",
"snyk": "1.454.0",
"standard-version": "^8.0.1",

@@ -118,0 +118,0 @@ "stream-equal": "^1.1.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc