Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User agent version #140

Merged
merged 7 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install -g npm@8
- run: npm ci
- run: npm run build --if-present
- run: npm pack
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
token: ${{ secrets.RELEASE_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: '12.x'
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: |
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ const fireblocks = new FireblocksSDK(privateKey, apiKey, baseUrl, authProvider,
The `options` argument has the following structure:
```typescript
interface SDKOptions {
timeoutInMs?: number; // HTTP request timeout
proxy?: AxiosProxyConfig | false; // Proxy configuration
anonymousPlatform?: boolean; // Whether to remove platform from User-Agent header
/** HTTP request timeout */
timeoutInMs?: number;

/** Proxy configurations */
proxy?: AxiosProxyConfig | false;

/** Whether to remove platform from User-Agent header */
anonymousPlatform?: boolean;

/** Additional product identifier to be prepended to the User-Agent header */
userAgent?: string;
}
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "fireblocks-sdk",
"version": "3.1.2",
"main": "dist/fireblocks-sdk.js",
"types": "dist/fireblocks-sdk.d.ts",
"main": "dist/src/fireblocks-sdk.js",
"types": "dist/src/fireblocks-sdk.d.ts",
"scripts": {
"build": "tsc && npm run tslint",
"tslint": "tslint -c tslint.json -p tsconfig.json --fix",
Expand Down
6 changes: 5 additions & 1 deletion src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IAuthProvider } from "./iauth-provider";
import { RequestOptions } from "./types";
import { SDKOptions } from "./fireblocks-sdk";
import axios, { AxiosInstance } from "axios";
import { version as SDK_VERSION } from "../package.json";

export class ApiClient {
private axiosInstance: AxiosInstance;
Expand All @@ -21,10 +22,13 @@ export class ApiClient {
}

private getUserAgent(): string {
let userAgent = `fireblocks-sdk-js`;
let userAgent = `fireblocks-sdk-js/${SDK_VERSION}`;
if (!this.options?.anonymousPlatform) {
userAgent += ` (${os.type()} ${os.release()}; ${platform.name} ${platform.version}; ${os.arch()})`;
}
if (this.options?.userAgent) {
userAgent = `${this.options.userAgent} ${userAgent}`;
}
return userAgent;
}

Expand Down
8 changes: 8 additions & 0 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,17 @@ import { AxiosProxyConfig } from "axios";
export * from "./types";

export interface SDKOptions {
/** HTTP request timeout */
timeoutInMs?: number;

/** Proxy configurations */
proxy?: AxiosProxyConfig | false;

/** Whether to remove platform from User-Agent header */
anonymousPlatform?: boolean;

/** Additional product identifier to be prepended to the User-Agent header */
userAgent?: string;
}

export class FireblocksSDK {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"declaration": true,
"sourceMap": true,
"outDir": "dist",
"baseUrl": "."
"baseUrl": ".",
"resolveJsonModule": true
},
"include": [
"./src/**/*"
Expand Down