Skip to content

Commit

Permalink
feat(scan): implement scan functionality (#43)
Browse files Browse the repository at this point in the history
closes #42
  • Loading branch information
RomanReznichenko committed Apr 29, 2022
1 parent 797a6ae commit b034b63
Show file tree
Hide file tree
Showing 79 changed files with 4,632 additions and 20 deletions.
131 changes: 120 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@
},
"homepage": "https://github.com/NeuraLegion/secbox-sdk-js#readme",
"dependencies": {
"@har-sdk/core": "^1.4.3",
"amqp-connection-manager": "^4.1.1",
"amqplib": "^0.8.0",
"axios": "^0.26.1",
"axios-rate-limit": "^1.3.0",
"chalk": "^4.1.2",
"content-type": "^1.0.4",
"form-data": "^4.0.0",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",
"request-promise": "^4.2.6",
Expand Down
10 changes: 9 additions & 1 deletion packages/bus/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
"tsConfig": "packages/bus/tsconfig.lib.json",
"packageJson": "packages/bus/package.json",
"main": "packages/bus/src/index.ts",
"assets": ["packages/bus/*.md", "LICENSE"]
"assets": [
"packages/bus/*.md",
{
"glob": "LICENSE",
"input": "",
"output": ""
}
],
"buildableProjectDepsInPackageJsonType": "dependencies"
}
},
"lint": {
Expand Down
12 changes: 12 additions & 0 deletions packages/bus/src/dispatchers/HttpCommandDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CommandDispatcher } from '@secbox/core';
import { inject, injectable } from 'tsyringe';
import axios, { AxiosRequestConfig } from 'axios';
import rateLimit, { RateLimitedAxiosInstance } from 'axios-rate-limit';
import FormData from 'form-data';
import { finished, Readable } from 'stream';
import { promisify } from 'util';

Expand Down Expand Up @@ -55,6 +56,7 @@ export class HttpCommandDispatcher implements CommandDispatcher {
timeout,
params,
headers: {
...this.inferHeaders(data),
'x-correlation-id': correlationId,
'date': createdAt.toISOString()
},
Expand Down Expand Up @@ -89,4 +91,14 @@ export class HttpCommandDispatcher implements CommandDispatcher {
perMilliseconds: rate.window
});
}

private inferHeaders<T>(data: T): Record<string, string | string[]> {
let headers: Record<string, string | string[]> = {};

if (data instanceof FormData) {
headers = data.getHeaders();
}

return headers;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { delay } from '../utils';
import { RetryStrategy } from '@secbox/core';
import { RetryStrategy, delay } from '@secbox/core';

export interface ExponentialBackoffOptions {
readonly maxDepth: number;
Expand Down
1 change: 0 additions & 1 deletion packages/bus/src/utils/index.ts

This file was deleted.

6 changes: 5 additions & 1 deletion packages/core/src/configuration/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../credentials-provider';
import { first } from '../utils';
import { LogLevel } from '../logger';
import { secbox } from '../../package.json';
import { name, secbox } from '../../package.json';
import { container, injectable } from 'tsyringe';

export interface ConfigurationOptions {
Expand Down Expand Up @@ -61,6 +61,10 @@ export class Configuration {
return secbox.repeaterVersion;
}

get name() {
return name;
}

constructor({
cluster,
credentials,
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,17 @@ export * from './bus';
export * from './configuration';
export * from './credentials-provider';
export * from './logger';
export {
delay,
isObject,
isURLSearchParams,
isBoolean,
isString,
isFormData,
isNumber,
isDate,
isPresent,
checkBoundaries,
contains,
NumBoundaries
} from './utils';

0 comments on commit b034b63

Please sign in to comment.