Skip to content

Commit

Permalink
Merge pull request #23 from VirgilSecurity/v0.3.3
Browse files Browse the repository at this point in the history
v0.3.3
  • Loading branch information
vadimavdeev authored Oct 10, 2019
2 parents 6b623d5 + fb24ed5 commit 0338285
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "virgil-pythia",
"version": "0.3.2",
"version": "0.3.3",
"description": "Virgil Pythia SDK allows developers to implement Pythia protocol to create breach-proof passwords, immune to offline and online attacks.",
"main": "./dist/pythia.cjs.js",
"module": "./dist/pythia.es.js",
Expand All @@ -13,7 +13,7 @@
"license": "BSD-3-Clause",
"scripts": {
"lint": "eslint 'src/**/*.ts'",
"test": "mocha -t 0 -r ts-node/register -r dotenv/config src/**/*.test.ts",
"test": "mocha -t 0 -r ts-node/register -r dotenv/config -r setup-mocha src/**/*.test.ts",
"build": "rollup -c",
"clean": "rimraf .rpt2_cache dist",
"prepare": "npm run clean && npm run build"
Expand Down Expand Up @@ -43,8 +43,8 @@
"rimraf": "^2.6.3",
"rollup": "^1.14.6",
"rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-typescript2": "^0.21.1",
"ts-node": "^8.3.0",
Expand Down
9 changes: 7 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');

const commonjs = require('rollup-plugin-commonjs');
const json = require('rollup-plugin-json');
const nodeResolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-replace');
const { terser } = require('rollup-plugin-terser');
const typescript = require('rollup-plugin-typescript2');

Expand All @@ -11,6 +11,8 @@ const packageJson = require('./package.json');
const dependencies = Object.keys(packageJson.dependencies);
const peerDependencies = Object.keys(packageJson.peerDependencies);

const PRODUCT_NAME = 'pythia';

const FORMAT = {
CJS: 'cjs',
ES: 'es',
Expand All @@ -32,7 +34,10 @@ const createEntry = format => ({
},
},
plugins: [
json({ compact: true }),
replace({
'process.env.PRODUCT_NAME': JSON.stringify(PRODUCT_NAME),
'process.env.PRODUCT_VERSION': JSON.stringify(packageJson.version),
}),
format === FORMAT.UMD && nodeResolve({ browser: true }),
format === FORMAT.UMD && commonjs(),
typescript({
Expand Down
4 changes: 4 additions & 0 deletions setup-mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { version } = require('./package.json');

process.env.PRODUCT_NAME = 'pythia';
process.env.PRODUCT_VERSION = version;
6 changes: 3 additions & 3 deletions src/PythiaClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from 'axios';
import { VirgilAgent } from 'virgil-sdk';

import { version } from '../package.json';
import { PythiaError, PythiaClientError } from './errors';
import { IPythiaClient, TransformPasswordResult } from './IPythiaClient';
import { AxiosError, IAccessTokenProvider, IAccessToken } from './types';
Expand All @@ -22,7 +21,6 @@ interface TransformPasswordRequestBody {

export class PythiaClient implements IPythiaClient {
private static readonly DEFAULT_URL = 'https://api.virgilsecurity.com';
private static readonly PRODUCT_NAME = 'pythia';

private readonly accessTokenProvider: IAccessTokenProvider;
private readonly axios: AxiosInstance;
Expand All @@ -38,7 +36,9 @@ export class PythiaClient implements IPythiaClient {
}
this.accessTokenProvider = accessTokenProvider;
this.axios = axios.create({ baseURL: apiUrl || PythiaClient.DEFAULT_URL });
this.virgilAgent = virgilAgent || new VirgilAgent(PythiaClient.PRODUCT_NAME, version);
this.virgilAgent =
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
virgilAgent || new VirgilAgent(process.env.PRODUCT_NAME!, process.env.PRODUCT_VERSION!);
this.axios.interceptors.response.use(undefined, PythiaClient.onBadResponse);
}

Expand Down

0 comments on commit 0338285

Please sign in to comment.