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

asap-cli

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asap-cli - npm Package Compare versions

Comparing version 0.3.6 to 0.4.0

17

lib/asap-config.js

@@ -5,2 +5,3 @@ var _ = require('lodash');

var q = require('q');
var qs = require('qs');

@@ -25,13 +26,7 @@ function readFileIfExists(path) {

} else {
return additionalClaims.split(',')
.map(function(claims) {
var parsed = claims.split('=');
if (parsed && parsed.length > 1) {
var obj = {};
obj[parsed[0]] = parsed.splice(1).join('=');
return obj;
}
})
.filter(function(obj) { return !!obj; })
.reduce(function(accumulated, current) { return _.assign(accumulated, current); }, {});
if (additionalClaims.indexOf('=') > 0) {
return qs.parse(additionalClaims, {delimiter: ','});
} else {
return {};
}
}

@@ -38,0 +33,0 @@ }

{
"name": "asap-cli",
"version": "0.3.6",
"version": "0.4.0",
"description": "A command line utility for generating ASAP (JWT tokens as per the Atlassian Service Authentication Protocol) token and making curl calls with the same.",

@@ -30,3 +30,3 @@ "license": "MIT",

"expand-tilde": "^2.0.2",
"http-mitm-proxy": "^0.5.1",
"http-mitm-proxy": "0.5.1",
"jwt-authentication": "^0.3.0",

@@ -37,2 +37,3 @@ "lodash": "^4.13.1",

"q": "^1.4.1",
"qs": "^6.5.2",
"readline-sync": "^1.4.2",

@@ -39,0 +40,0 @@ "string-template": "^1.0.0"

@@ -102,2 +102,27 @@ # ASAP CLI

or when lists are required the following patterns are supported
```
asap --additional-claims "list=a,b"
```
```
asap --additional-claims "list=[a,b]"
```
```
asap --additional-claims "list=a,list=b"
```
```
asap --additional-claims "list[]=a,list[]=b"
```
```
asap --additional-claims "list[0]=a,list[1]=b"
```
```
asap --additional-claims '{"list":["a","b"]}'
```
Note that passing in additional claims in the command line will completely override any `additionalClaims`

@@ -104,0 +129,0 @@ already present in the config file

@@ -252,2 +252,69 @@ var requireWithMocks = require('proxyquire').noCallThru().noPreserveCache();

it('will parse multiple exact matched keys as an array of values', willResolve(function () {
mockFs.exists.and.returnValue(q(true));
mockFs.readFile.and.returnValue(q(asapConfigFileContent));
const additionalClaims = 'key1=value1a,key1=value1b';
return asapConfig.getFromOptions({additionalClaims}).then(function(options) {
expect(options.additionalClaims).toEqual({key1: ['value1a', 'value1b']});
});
}));
it('will parse array syntax keys as an array of values', willResolve(function () {
mockFs.exists.and.returnValue(q(true));
mockFs.readFile.and.returnValue(q(asapConfigFileContent));
const additionalClaims = 'key1[]=value1a,key1[]=value1b';
return asapConfig.getFromOptions({additionalClaims}).then(function(options) {
expect(options.additionalClaims).toEqual({key1: ['value1a', 'value1b']});
});
}));
it('will parse indexed array syntax keys as an ordered array of values', willResolve(function () {
mockFs.exists.and.returnValue(q(true));
mockFs.readFile.and.returnValue(q(asapConfigFileContent));
const additionalClaims = 'key1[1]=value1b,key1[0]=value1a';
return asapConfig.getFromOptions({additionalClaims}).then(function(options) {
expect(options.additionalClaims).toEqual({key1: ['value1a', 'value1b']});
});
}));
it('will not parse a comma delimited string after equals as a list of values', willResolve(function () {
mockFs.exists.and.returnValue(q(true));
mockFs.readFile.and.returnValue(q(asapConfigFileContent));
const additionalClaims = 'key1=value1a,value1b,key2=value2';
return asapConfig.getFromOptions({additionalClaims}).then(function(options) {
expect(options.additionalClaims).toEqual({key1: 'value1a', value1b: '', key2: 'value2'});
});
}));
it('will set additionalClaim key as empty string if no value is provided', willResolve(function () {
mockFs.exists.and.returnValue(q(true));
mockFs.readFile.and.returnValue(q(asapConfigFileContent));
const additionalClaims = 'key1=';
return asapConfig.getFromOptions({additionalClaims}).then(function(options) {
expect(options.additionalClaims).toEqual({key1: ''});
});
}));
it('will set key2 as value and key1 as empty string as no value is provided', willResolve(function () {
mockFs.exists.and.returnValue(q(true));
mockFs.readFile.and.returnValue(q(asapConfigFileContent));
const additionalClaims = 'key1=,key2=value2';
return asapConfig.getFromOptions({additionalClaims}).then(function(options) {
expect(options.additionalClaims).toEqual({key1: '', key2: 'value2'});
});
}));
it('will return empty object if additionalClaims is malformed', willResolve(function () {

@@ -254,0 +321,0 @@ mockFs.exists.and.returnValue(q(true));

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