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

taskcluster-client

Package Overview
Dependencies
Maintainers
2
Versions
433
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

taskcluster-client - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

47

client.js

@@ -5,2 +5,5 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

// Load superagent-hawk
require('superagent-hawk')(require('superagent'));
var request = require('superagent-promise');

@@ -11,5 +14,18 @@ var debug = require('debug')('taskcluster-client');

/** Construct a client given a base URL and JSON API reference. */
var Client = function(baseUrl, reference) {
// Default credentials
var _defaultCredentials = null;
/**
* Construct a client given a base URL, JSON API reference and credentials.
* If no credentials are provided default credentials will be used.
*/
var Client = function(baseUrl, reference, credentials) {
this._baseUrl = baseUrl;
if (credentials) {
this._credentials = {
id: credentials.clientId,
key: credentials.accessToken,
algorithm: 'sha256'
};
}
var that = this;

@@ -46,2 +62,6 @@ // For each API entry in the reference

}
// Authenticate, if credentials are provided
if (that._credentials || _defaultCredentials) {
req.hawk(that._credentials || _defaultCredentials);
}
// Send request and handle response

@@ -61,6 +81,7 @@ return req.end().then(function(res) {

/**
* Create client given a baseUrl and version (defaults to 1)
* Create client given a baseUrl, version (defaults to 1) and credentials.
* Defaults to default credentials (or no credentials), if none is provided.
* Return a promise for the client instance.
*/
Client.load = function(baseUrl, version) {
Client.load = function(baseUrl, version, credentials) {
if (version === undefined) {

@@ -110,3 +131,21 @@ version = 1;

/**
* Provide default credentials for authentication.
*
* Example: `Client.auth({clientId: '...', accessToken: '...'});`
*/
Client.auth = function(credentials) {
if (credentials) {
_defaultCredentials = {
id: credentials.clientId,
key: credentials.accessToken,
algorithm: 'sha256'
};
} else {
_defaultCredentials = null;
}
};
// Export client
module.exports = Client;

5

package.json
{
"name": "taskcluster-client",
"version": "0.4.1",
"version": "0.4.2",
"author": "Jonas Finnemann Jensen <jopsen@gmail.com>",

@@ -20,3 +20,4 @@ "description": "Client for interfacing taskcluster components",

"superagent": "~0.16.0",
"superagent-promise": "0.1.0"
"superagent-promise": "0.1.0",
"superagent-hawk": "0.0.3"
},

@@ -23,0 +24,0 @@ "devDependencies": {

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