Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ali-oss

Package Overview
Dependencies
Maintainers
2
Versions
127
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 1.0.0 to 1.1.0

History.md

52

build/client.js

@@ -409,7 +409,7 @@ /*!

var debug = require('debug')('ali-oss:client');
var crypto = require('crypto');
var fs = require('fs');
var path = require('path');
var debug = require('debug')('ali-oss:client');
var copy = require('copy-to');

@@ -422,2 +422,3 @@ var is = require('is-type-of');

var ms = require('ms');
var utility = require('utility');

@@ -433,4 +434,4 @@ /**

var DEFAULT_OPTIONS = {
host: 'oss.aliyuncs.com:8080',
timeout: '10s'
host: 'oss.aliyuncs.com',
timeout: '10s',
};

@@ -447,3 +448,3 @@

function Client (options) {
function Client(options) {
if (!options

@@ -461,3 +462,3 @@ || !options.accessKeyId

if(is.string(this.timeout)) {
if (is.string(this.timeout)) {
this.timeout = ms(this.timeout);

@@ -473,2 +474,22 @@ }

proto.signatureUrl = function (name) {
var resourceName = '/' + this.bucket + '/' + name;
var expires = utility.timestamp() + 1800;
var params = [
'GET',
'', // md5
'', // Content-Type
expires, // Expires
resourceName,
];
debug('authorization with params: %j', params);
var signature = crypto.createHmac('sha1', this.accessKeySecret);
signature = signature.update(params.join('\n')).digest('base64');
var url = this._objectUrl(name);
return url + '?OSSAccessKeyId=' + encodeURIComponent(this.accessKeyId) +
'&Expires=' + expires + '&Signature=' + encodeURIComponent(signature);
};
/**

@@ -530,2 +551,6 @@ * get author header

proto._objectUrl = function (name) {
return 'http://' + this.host + '/' + this.bucket + '/' + name;
};
/**

@@ -546,3 +571,3 @@ * request oss server

proto.request = wrapGenerator.mark(function(params) {
var url, type, md5, length, headers, resource;
var url, headers, resource;

@@ -552,6 +577,3 @@ return wrapGenerator(function($ctx0) {

case 0:
url = 'http://' + this.host + '/' + this.bucket + '/' + params.name;
type = null;
md5 = null;
length = null;
url = this._objectUrl(params.name);

@@ -576,3 +598,3 @@ headers = {

debug('request %s %s, with headers %j', params.method, url, headers);
$ctx0.next = 12;
$ctx0.next = 9;

@@ -586,5 +608,5 @@ return urllib.requestThunk(url, {

});
case 12:
case 9:
return $ctx0.abrupt("return", $ctx0.sent);
case 13:
case 10:
case "end":

@@ -880,3 +902,3 @@ return $ctx0.stop();

$ctx5.t8 = $ctx5.catch(6);
$ctx5.t8 = new Error(message);
$ctx5.t8.message += '\nraw xml: ' + message;
$ctx5.t8.status = res.status;

@@ -883,0 +905,0 @@ return $ctx5.abrupt("return", $ctx5.t8);

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

'use strict';
var Oss = require('./');
var oss = require('./');
var co = require('co');
var fs = require('fs');
var client = Oss.create({
var client = oss.create({
bucket: 'node-ali-oss',

@@ -16,12 +16,17 @@ accessKeyId: 'iAeyzYXtZAdM8V2V',

client.upload('./package.json', 'package.json', function (err, data) {
if (err) throw err;
client.upload('./package.json', 'package.json', function (err) {
if (err) {
throw err;
}
client.get('package.json', function (err, data) {
if (err) throw err;
if (err) {
throw err;
}
console.log(data.toString());
client.remove('package.json', function (err, data) {
if (err) throw err;
client.remove('package.json', function (err) {
if (err) {
throw err;
}
});
});
});

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

'use strict';
var Oss = require('./');
var oss = require('./');
var co = require('co');
var fs = require('fs');
var client = Oss.create({
var client = oss.create({
bucket: 'node-ali-oss',

@@ -8,0 +8,0 @@ accessKeyId: 'iAeyzYXtZAdM8V2V',

@@ -13,6 +13,6 @@ /*!

var debug = require('debug')('ali-oss:client');
var crypto = require('crypto');
var fs = require('fs');
var path = require('path');
var debug = require('debug')('ali-oss:client');
var copy = require('copy-to');

@@ -25,2 +25,3 @@ var is = require('is-type-of');

var ms = require('ms');
var utility = require('utility');

@@ -36,4 +37,4 @@ /**

var DEFAULT_OPTIONS = {
host: 'oss.aliyuncs.com:8080',
timeout: '10s'
host: 'oss.aliyuncs.com',
timeout: '10s',
};

@@ -50,3 +51,3 @@

function Client (options) {
function Client(options) {
if (!options

@@ -64,3 +65,3 @@ || !options.accessKeyId

if(is.string(this.timeout)) {
if (is.string(this.timeout)) {
this.timeout = ms(this.timeout);

@@ -76,2 +77,22 @@ }

proto.signatureUrl = function (name) {
var resourceName = '/' + this.bucket + '/' + name;
var expires = utility.timestamp() + 1800;
var params = [
'GET',
'', // md5
'', // Content-Type
expires, // Expires
resourceName,
];
debug('authorization with params: %j', params);
var signature = crypto.createHmac('sha1', this.accessKeySecret);
signature = signature.update(params.join('\n')).digest('base64');
var url = this._objectUrl(name);
return url + '?OSSAccessKeyId=' + encodeURIComponent(this.accessKeyId) +
'&Expires=' + expires + '&Signature=' + encodeURIComponent(signature);
};
/**

@@ -133,2 +154,6 @@ * get author header

proto._objectUrl = function (name) {
return 'http://' + this.host + '/' + this.bucket + '/' + name;
};
/**

@@ -149,7 +174,3 @@ * request oss server

proto.request = function* (params) {
var url = 'http://' + this.host + '/' + this.bucket + '/' + params.name;
var type = null;
var md5 = null;
var length = null;
var url = this._objectUrl(params.name);
var headers = {

@@ -372,3 +393,3 @@ Date: new Date().toGMTString(),

} catch (err) {
err = new Error(message);
err.message += '\nraw xml: ' + message;
err.status = res.status;

@@ -375,0 +396,0 @@ return err;

{
"name": "ali-oss",
"version": "1.0.0",
"version": "1.1.0",
"description": "aliyun oss(open storage service) node client",

@@ -27,5 +27,5 @@ "main": "index.js",

"devDependencies": {
"co": "3",
"ali.regenerator": "*",
"autod": "1",
"co": "^3.0.5",
"co-mocha": "*",

@@ -37,13 +37,13 @@ "istanbul-harmony": "*",

"dependencies": {
"co": "~3.1.0",
"co-read": "~0.1.1",
"copy-to": "~2.0.1",
"debug": "~2.1.0",
"debug": "~2.1.1",
"generator-supported": "~0.0.1",
"is-type-of": "~0.3.1",
"mime": "~1.2.11",
"ms": "~0.6.2",
"urllib": "~2.0.1",
"ms": "~0.7.0",
"urllib": "~2.2.2",
"utility": "~1.2.1",
"xml2js": "~0.4.4"
}
}

@@ -22,7 +22,7 @@ ali-oss

a node.js wrapper for [OSS restful api](http://imgs-storage.cdn.aliyuncs.com/help/oss/OSS_API_20131015.pdf?spm=5176.383663.5.23.AHDSVr&file=OSS_API_20131015.pdf)
a node.js wrapper for [OSS restful api](http://docs.aliyun.com/#/oss/api-reference/abstract)
## Install
```
```bash
npm install ali-oss --save

@@ -39,2 +39,3 @@ ```

var OSS = require('ali-oss');
var client = OSS.create({

@@ -58,3 +59,3 @@ accessKeyId: 'id',

```
```js
yield* client.upload(file, name, options);

@@ -74,3 +75,3 @@ ```

```
```js
yield* client.get(name, path, options);

@@ -89,3 +90,3 @@ ```

```
```js
yield* client.remove(name, options);

@@ -100,2 +101,13 @@ ```

#### signatureUrl
```js
var downloadUrl = client.signatureUrl(name);
// http://oss.aliyuncs.com/oss-api.pdf?OSSAccessKeyId=xxxx&Expires=1141889120&Signature=vjbyPxybdZaNmGa%2ByT272YEAiv4%3D
```
options:
- **name**: object name in oss
## backward compatibility

@@ -107,3 +119,3 @@

```
```js
var co = require('co');

@@ -110,0 +122,0 @@ var OSS = require('ali-oss');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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