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

openwhisk

Package Overview
Dependencies
Maintainers
3
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openwhisk - npm Package Compare versions

Comparing version 3.16.0 to 3.17.0

42

lib/client.js

@@ -69,2 +69,3 @@ // Licensed to the Apache Software Foundation (ASF) under one or more contributor

* @param {string} [options.apigw_space_guid]
* @param {Function} [options.auth_handler]
*/

@@ -95,4 +96,4 @@ constructor (options) {

if (!apiKey) {
throw new Error(`${messages.INVALID_OPTIONS_ERROR} Missing api_key parameter.`)
if (!apiKey && !options.auth_handler) {
throw new Error(`${messages.INVALID_OPTIONS_ERROR} Missing api_key parameter or token plugin.`)
} else if (!api) {

@@ -102,3 +103,3 @@ throw new Error(`${messages.INVALID_OPTIONS_ERROR} Missing either api or apihost parameters.`)

return {apiKey: apiKey, api, ignoreCerts: ignoreCerts, namespace: options.namespace, apigwToken: apigwToken, apigwSpaceGuid: apigwSpaceGuid}
return {apiKey: apiKey, api, ignoreCerts: ignoreCerts, namespace: options.namespace, apigwToken: apigwToken, apigwSpaceGuid: apigwSpaceGuid, authHandler: options.auth_handler}
}

@@ -119,17 +120,19 @@

request (method, path, options) {
const req = this.params(method, path, options)
return rp(req).catch(err => this.handleErrors(err))
const params = this.params(method, path, options)
return params.then(req => rp(req)).catch(err => this.handleErrors(err))
}
params (method, path, options) {
return Object.assign({
json: true,
method: method,
url: this.pathUrl(path),
rejectUnauthorized: !this.options.ignoreCerts,
headers: {
'User-Agent': (options && options['User-Agent']) || 'openwhisk-client-js',
Authorization: this.authHeader()
}
}, options)
return this.authHeader().then(header => {
return Object.assign({
json: true,
method: method,
url: this.pathUrl(path),
rejectUnauthorized: !this.options.ignoreCerts,
headers: {
'User-Agent': (options && options['User-Agent']) || 'openwhisk-client-js',
Authorization: header
}
}, options)
})
}

@@ -150,6 +153,9 @@

authHeader () {
const apiKeyBase64 = Buffer.from(this.options.apiKey).toString('base64')
return `Basic ${apiKeyBase64}`
if (this.options.authHandler) {
return this.options.authHandler.getAuthHeader()
} else {
const apiKeyBase64 = Buffer.from(this.options.apiKey).toString('base64')
return Promise.resolve(`Basic ${apiKeyBase64}`)
}
}
handleErrors (reason) {

@@ -156,0 +162,0 @@ let message = `Unknown Error From API: ${reason.message}`

@@ -42,9 +42,9 @@ // Licensed to the Apache Software Foundation (ASF) under one or more contributor

invoke(options: string): Promise<{ activationId: string }>
invoke(options: { name: string; namespace?: string; blocking: true; params?: Dict; result: true; }): Promise<Dict>;
invoke(options: { name: string; namespace?: string; blocking: true; params?: Dict; result?: false; }): Promise<Activation<Dict>>;
invoke(options: { name: string; namespace?: string; blocking?: false; params?: Dict; result?: boolean; }): Promise<{ activationId: string }>;
invoke(options: { name: string; namespace?: string; blocking: boolean; params?: Dict; result: boolean; }): Promise<Dict>;
invoke(options: { name: string; namespace?: string; blocking: boolean; params?: Dict; result?: boolean; }): Promise<Activation<Dict>>;
invoke(options: { name: string; namespace?: string; blocking?: boolean; params?: Dict; result?: boolean; }): Promise<{ activationId: string }>;
invoke(options: (string | { name: string; namespace?: string; blocking?: boolean; params?: Dict; result?: boolean; })[]): Promise<{ activationId: string }[]>;
invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?: string; blocking: true; params?: In; result: true; }): Promise<Out>;
invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?: string; blocking: true; params?: In; result?: false; }): Promise<Activation<Out>>;
invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?: string; blocking?: false; params?: In; result?: boolean; }): Promise<{ activationId: string }>;
invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?: string; blocking: boolean; params?: In; result: boolean; }): Promise<Out>;
invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?: string; blocking: boolean; params?: In; result?: boolean; }): Promise<Activation<Out>>;
invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?: string; blocking?: boolean; params?: In; result?: boolean; }): Promise<{ activationId: string }>;
create(options: { name: string; namespace?: string; action: (string | Buffer | Action); kind?: Kind; overwrite?: boolean; params?: Dict; annotations?: Dict; limits?: Limits; version?: string; }): Promise<Action>;

@@ -51,0 +51,0 @@ //create(options: { name: string; namespace?: string; action: (string | Buffer | Action); kind?: Kind; overwrite?: boolean; params?: Dict; version?: string; }[]): Promise<Action[]>;

{
"name": "openwhisk",
"version": "3.16.0",
"version": "3.17.0",
"description": "JavaScript client library for the OpenWhisk platform",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

@@ -67,2 +67,20 @@ # OpenWhisk Client for JavaScript

#### using 3rd party authentication handler
You can specify an authentication handler in `options.auth_handler` this is an object that provides a function `getAuthHeader` that returns a Promise or String to be used in the `Authorization` http header for every http request.
```javascript
const authHandler = {
getAuthHeader: ()=>{
return Promise.resolve('Basic user:password')
}
}
var openwhisk = require('openwhisk');
var options = {
apihost: 'openwhisk.ng.bluemix.net',
auth_handler: authHandler
}
var ow = openwhisk(options)
ow.actions.invoke('sample').then(result => console.log(result))
```
### constructor options

@@ -69,0 +87,0 @@

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