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

armlet

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

armlet - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

.editorconfig

12

index.js
const url = require('url')
const requester = require('./lib/requester')
const simpleRequester = require('./lib/simpleRequester')
const poller = require('./lib/poller')
const defaultApiUrl = 'https://api.mythril.ai'
const defaultApiVersion = 'v1'

@@ -76,3 +78,13 @@ module.exports = (bytecode, apiKey, inputApiUrl = defaultApiUrl) => {

module.exports.ApiVersion = (inputApiUrl = defaultApiUrl) => {
return simpleRequester.do({url: `${inputApiUrl}/${defaultApiVersion}/version`, json: true})
}
module.exports.OpenApiSpec = (inputApiUrl = defaultApiUrl) => {
return simpleRequester.do({url: `${inputApiUrl}/${defaultApiVersion}/openapi.yaml`})
}
module.exports.Client = Client
module.exports.defaultApiUrl = url.parse(defaultApiUrl)
module.exports.defaultApiHost = defaultApiUrl
module.exports.defaultApiVersion = defaultApiVersion

2

lib/poller.js

@@ -34,3 +34,3 @@ exports.do = (uuid, apiKey, apiUrl, pollStep = 1000, timeout = 10000) => {

clearActions()
reject(new Error(`Unauthorized analysis request, API key: ${this.apiKey}`))
reject(new Error(`Unauthorized analysis request, API key: ${apiKey}`))
}

@@ -37,0 +37,0 @@ if (res.statusCode === 500) {

@@ -27,3 +27,3 @@ const basePath = '/v1/analyses'

[400, 'validation failed'],
[401, `unauthorized analysis request, API key: ${this.apiKey}`],
[401, `unauthorized analysis request, API key: ${apiKey}`],
[429, 'request limit exceeded'],

@@ -30,0 +30,0 @@ [500, 'received error from API server']])

{
"name": "armlet",
"version": "0.1.8",
"version": "0.1.9",
"description": "A Mythril Platform API client.",

@@ -8,3 +8,5 @@ "main": "index.js",

"lint": "standard",
"test": "npm run lint && mocha --reporter spec --recursive"
"lint-fix": "standard --fix",
"pretest": "npm run lint",
"test": "mocha --reporter spec --recursive"
},

@@ -18,3 +20,3 @@ "standard": {

"type": "git",
"url": "git+https://github.com/fgimenez/armlet.git"
"url": "git+https://github.com/consensys/armlet.git"
},

@@ -24,5 +26,5 @@ "author": "Federico Gimenez <federico.gimenez@gmail.com>",

"bugs": {
"url": "https://github.com/fgimenez/armlet/issues"
"url": "https://github.com/consensys/armlet/issues"
},
"homepage": "https://github.com/fgimenez/armlet#readme",
"homepage": "https://github.com/consensys/armlet#readme",
"devDependencies": {

@@ -35,3 +37,6 @@ "chai": "^4.1.2",

"standard": "^11.0.1"
},
"dependencies": {
"request": "^2.88.0"
}
}

@@ -10,2 +10,3 @@ const analyze = require('../index')

const requester = require('../lib/requester')
const simpleRequester = require('../lib/simpleRequester')
const poller = require('../lib/poller')

@@ -17,10 +18,12 @@

const userEmail = 'my-userEmail'
const apiUrl = 'http://localhost:3100'
describe('#armlet', () => {
afterEach(() => {
requester.do.restore()
poller.do.restore()
})
describe('interface', () => {
afterEach(() => {
requester.do.restore()
poller.do.restore()
simpleRequester.do.restore()
})
describe('interface', () => {
beforeEach(() => {

@@ -31,2 +34,4 @@ sinon.stub(requester, 'do')

.returns(new Promise((resolve, reject) => resolve(true)))
sinon.stub(simpleRequester, 'do')
.returns(new Promise((resolve, reject) => resolve(true)))
})

@@ -103,2 +108,26 @@

})
describe('ApiVersion', () => {
it('should be a function', () => {
analyze.ApiVersion.should.be.a('function')
})
it('should return a thenable', () => {
const result = analyze.ApiVersion(apiUrl)
result.then.should.be.a('function')
})
})
describe('OpenApiSpec', () => {
it('should be a function', () => {
analyze.OpenApiSpec.should.be.a('function')
})
it('should return a thenable', () => {
const result = analyze.OpenApiSpec(apiUrl)
result.then.should.be.a('function')
})
})
})

@@ -109,6 +138,10 @@

const issues = ['issue1', 'issue2']
const apiUrl = 'http://localhost:3100'
const parsedApiUrl = url.parse(apiUrl)
describe('default', () => {
afterEach(() => {
requester.do.restore()
poller.do.restore()
})
it('should chain requester and poller', async () => {

@@ -163,2 +196,7 @@ sinon.stub(requester, 'do')

describe('Client', () => {
afterEach(() => {
requester.do.restore()
poller.do.restore()
})
beforeEach(() => {

@@ -232,4 +270,65 @@ this.instance = new Client({userEmail: userEmail, apiKey: apiKey}, apiUrl)

})
describe('ApiVersion', () => {
const url = `${apiUrl}/${analyze.defaultApiVersion}/version`
afterEach(() => {
simpleRequester.do.restore()
})
it('should use simpleRequester', async () => {
const result = {result: 'result'}
sinon.stub(simpleRequester, 'do')
.withArgs({url, json: true})
.returns(new Promise(resolve => {
resolve(result)
}))
await analyze.ApiVersion(apiUrl).should.eventually.equal(result)
})
it('should reject with simpleRequester failures', async () => {
const errorMsg = 'Booom!'
sinon.stub(simpleRequester, 'do')
.withArgs({url, json: true})
.returns(new Promise((resolve, reject) => {
reject(new Error(errorMsg))
}))
await analyze.ApiVersion(apiUrl).should.be.rejectedWith(Error, errorMsg)
})
})
describe('OpenApiSpec', () => {
const url = `${apiUrl}/${analyze.defaultApiVersion}/openapi.yaml`
afterEach(() => {
simpleRequester.do.restore()
})
it('should use simpleRequester', async () => {
const result = 'result'
sinon.stub(simpleRequester, 'do')
.withArgs({url})
.returns(new Promise(resolve => {
resolve(result)
}))
await analyze.OpenApiSpec(apiUrl).should.eventually.equal(result)
})
it('should reject with simpleRequester failures', async () => {
const errorMsg = 'Booom!'
sinon.stub(simpleRequester, 'do')
.withArgs({url})
.returns(new Promise((resolve, reject) => {
reject(new Error(errorMsg))
}))
await analyze.OpenApiSpec(apiUrl).should.be.rejectedWith(Error, errorMsg)
})
})
})
})
})
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