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

ovh

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ovh - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

tests/no_auth/05_REST_noAuth.js

6

CHANGELOG.md
# Changelog
## 1.0.2
* Fix noAuthenticated calls
* Optionnal consumer key, now checked only on debug
* Fix unicode (thanks to @naholyr #4)
## 1.0.1

@@ -4,0 +10,0 @@

56

ovh.js

@@ -330,2 +330,10 @@ //

if (typeof(this.consumerKey) !== 'string' &&
!api._api.operations[i].noAuthentication) {
return this.warn(
'[OVH] The API call ' + pathStr + ' requires an authentication' +
' with a consumer key.'
);
}
return true;

@@ -357,3 +365,3 @@ }

}
// Time drift

@@ -376,6 +384,2 @@ if (this.apiTimeDiff === null && path !== '/auth/time') {

if (path.indexOf('/auth') < 0 && typeof(this.consumerKey) !== 'string') {
return callback('[OVH] No consumerKey defined');
}
// Replace "{str}", used for $call()

@@ -418,5 +422,10 @@ if (path.indexOf('{') >= 0) {

var reqBody = null;
if (typeof(params) === 'object' && Object.keys(params).length > 0) {
if (httpMethod === 'PUT' || httpMethod === 'POST') {
options.headers['Content-Length'] = JSON.stringify(params).length;
// Escape unicode
reqBody = JSON.stringify(params).replace(/[\u0080-\uFFFF]/g, function(m) {
return "\\u" + ("0000" + m.charCodeAt(0).toString(16)).slice(-4);
});
options.headers['Content-Length'] = reqBody.length;
}

@@ -428,12 +437,15 @@ else {

// Sign request
if (path.indexOf('/auth') < 0) {
options.headers['X-Ovh-Consumer'] = this.consumerKey;
options.headers['X-Ovh-Timestamp'] =
Math.round(Date.now() / 1000) + this.apiTimeDiff;
options.headers['X-Ovh-Signature'] =
this.signRequest(
httpMethod, 'https://' + options.host + options.path,
params, options.headers['X-Ovh-Timestamp']
);
// Sign request
if (typeof(this.consumerKey) === 'string') {
options.headers['X-Ovh-Consumer'] = this.consumerKey;
options.headers['X-Ovh-Signature'] =
this.signRequest(
httpMethod, 'https://' + options.host + options.path,
reqBody, options.headers['X-Ovh-Timestamp']
);
}
}

@@ -445,7 +457,4 @@

options.method, options.path,
(httpMethod === 'PUT' || httpMethod === 'POST' &&
typeof(params) === 'object' && Object.keys(params).length > 0) ?
JSON.stringify(params) : ''
);
reqBody || ''
);
}

@@ -512,5 +521,4 @@

if (httpMethod === 'PUT' || httpMethod === 'POST' &&
typeof(params) === 'object' && Object.keys(params).length > 0) {
req.write(JSON.stringify(params));
if (reqBody !== null) {
req.write(reqBody);
}

@@ -521,3 +529,3 @@

Ovh.prototype.signRequest = function (httpMethod, url, params, timestamp) {
Ovh.prototype.signRequest = function (httpMethod, url, body, timestamp) {
var s = [

@@ -528,5 +536,3 @@ this.appSecret,

url,
(httpMethod === 'PUT' || httpMethod === 'POST') &&
typeof(params) === 'object' &&
Object.keys(params).length > 0 ? JSON.stringify(params) : '',
body || '',
timestamp

@@ -533,0 +539,0 @@ ];

{
"name": "ovh",
"version": "1.0.1",
"version": "1.0.2",
"description": "A helper library to use OVH.com REST API (v6)",
"homepage": "https://github.com/gierschv/node-ovh",
"homepage": "http://gierschv.github.io/node-ovh",
"author": "Vincent Giersch <mail@vincent.sh>",

@@ -7,0 +7,0 @@ "contributors": [],

@@ -34,1 +34,5 @@ node-ovh

```
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gierschv/node-ovh/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

@@ -43,4 +43,4 @@ //

var rest = ovh({ appKey: 'XXX', appSecret: 'XXX', apis: [] });
rest.request('GET', '/me', function (err) {
assert.equal(err, '[OVH] No consumerKey defined');
rest.request('GET', '/me', function (err, message) {
assert.equal(err, 401);
done();

@@ -47,0 +47,0 @@ });

@@ -64,3 +64,20 @@ //

});
}
},
'Call method without CK': function (done) {
"use strict";
var rest = ovh({
appKey: APP_KEY,
appSecret: APP_SECRET,
apis: ['me'],
warn: function (err) {
assert.equal(err, '[OVH] The API call /me requires an authentication with a consumer key.');
done();
}
});
rest.request('GET', '/me', function (err) {
assert.ok(err);
});
},
};

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