Skip to content

Commit 845c7e5

Browse files
committed
strated dependencies update
1 parent ef9274f commit 845c7e5

File tree

9 files changed

+114
-66
lines changed

9 files changed

+114
-66
lines changed

karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ module.exports = function(config) {
4848
new webpack.EnvironmentPlugin({
4949
browser: JSON.stringify(true),
5050
VERSION: JSON.stringify(packageJson.version),
51-
API_KEY_PRIVATE_KEY: JSON.stringify(process.env.API_KEY_PRIVATE_KEY),
52-
API_KEY_ID: JSON.stringify(process.env.API_KEY_ID),
51+
API_KEY_PRIVATE_KEY: JSON.stringify(process.env.APP_KEY),
52+
API_KEY_ID: JSON.stringify(process.env.APP_KEY_ID),
5353
APP_ID: JSON.stringify(process.env.APP_ID),
5454
API_URL: JSON.stringify(process.env.API_URL),
5555
}),

package.json

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,58 +38,61 @@
3838
],
3939
"license": "BSD-3-Clause",
4040
"devDependencies": {
41-
"@types/chai": "^4.1.7",
42-
"@types/chai-as-promised": "^7.1.0",
43-
"@types/mkdirp": "^1.0.0",
44-
"@types/mocha": "^7.0.2",
45-
"@types/node": "^13.13.2",
46-
"@types/rimraf": "^3.0.0",
47-
"@types/sinon": "^5.0.6",
48-
"@types/sinon-chai": "^3.2.1",
41+
"@types/chai": "^4.3.4",
42+
"@types/chai-as-promised": "^7.1.5",
43+
"@types/jest": "^29.2.2",
44+
"@types/mkdirp": "^1.0.2",
45+
"@types/mocha": "^10.0.0",
46+
"@types/node": "^18.11.9",
47+
"@types/rimraf": "^3.0.2",
48+
"@types/sinon": "^10.0.13",
49+
"@types/sinon-chai": "^3.2.9",
4950
"buffer-es6": "^4.9.3",
50-
"builtin-modules": "^3.0.0",
51-
"chai": "^4.2.0",
51+
"builtin-modules": "^3.3.0",
52+
"chai": "^4.3.7",
5253
"chai-as-promised": "^7.1.1",
53-
"dotenv": "^8.2.0",
54-
"file-loader": "^6.0.0",
55-
"karma": "^6.0.0",
54+
"dotenv": "^16.0.3",
55+
"file-loader": "^6.2.0",
56+
"karma": "^6.4.1",
5657
"karma-chai-plugins": "^0.9.0",
57-
"karma-chrome-launcher": "^3.1.0",
58+
"karma-chrome-launcher": "^3.1.1",
5859
"karma-mocha": "^2.0.0",
59-
"karma-rollup-preprocessor": "^7.0.2",
60-
"karma-webpack": "^4.0.2",
61-
"mocha": "^7.1.1",
62-
"rollup": "^2.7.2",
60+
"karma-rollup-preprocessor": "^7.0.8",
61+
"karma-webpack": "^5.0.0",
62+
"mocha": "^10.1.0",
63+
"rollup": "^3.2.5",
6364
"rollup-plugin-commonjs": "^10.0.2",
6465
"rollup-plugin-node-resolve": "^5.2.0",
6566
"rollup-plugin-replace": "^2.2.0",
66-
"rollup-plugin-terser": "^5.1.1",
67-
"rollup-plugin-typescript2": "^0.27.0",
67+
"rollup-plugin-terser": "^7.0.2",
68+
"rollup-plugin-typescript2": "^0.34.1",
6869
"rollup-plugin-wasm": "^3.0.0",
69-
"sinon": "^9.0.2",
70-
"sinon-chai": "^3.0.0",
71-
"ts-loader": "^7.0.1",
72-
"ts-node": "^8.1.0",
73-
"typedoc": "^0.17.3",
74-
"typescript": "^3.1.6",
70+
"sinon": "^14.0.2",
71+
"sinon-chai": "^3.7.0",
72+
"ts-loader": "^9.4.1",
73+
"ts-node": "^10.9.1",
74+
"typedoc": "^0.23.20",
75+
"typescript": "^4.8.4",
7576
"virgil-crypto": "^4.0.0"
7677
},
7778
"dependencies": {
78-
"@types/base-64": "^0.1.3",
79-
"@types/utf8": "^2.1.6",
79+
"@types/base-64": "^1.0.0",
80+
"@types/utf8": "^3.0.1",
8081
"@virgilsecurity/crypto-types": "^1.0.0",
81-
"base-64": "^0.1.0",
82-
"fetch-ponyfill": "^6.1.1",
83-
"mkdirp": "^1.0.3",
82+
"base-64": "^1.0.0",
83+
"fetch-ponyfill": "^7.1.0",
84+
"mkdirp": "^1.0.4",
8485
"rimraf": "^3.0.2",
86+
"ts-mocha": "^10.0.0",
8587
"utf8": "^3.0.0",
86-
"webpack": "^4.43.0"
88+
"webpack": "^5.74.0"
8789
},
90+
"type": "module",
8891
"scripts": {
8992
"clean": "rimraf .rpt2_cache dist",
9093
"build": "rollup -c",
9194
"prepare": "npm run clean && npm run build",
92-
"test:node": "mocha --require ts-node/register --require dotenv/config --require scripts/register-assert \"src/**/*.test.ts\"",
95+
"test:node": "ts-mocha -p tsconfig.spec.json \"src/**/*.test.ts\"",
9396
"test:browser": "karma start",
9497
"test": "npm run test:node && npm run test:browser",
9598
"preversion": "npm run test",

src/Storage/PrivateKeyStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class PrivateKeyStorage {
4444
const privateKeyData = this.privateKeyExporter.exportPrivateKey(privateKey);
4545
try {
4646
await this.keyEntryStorage.save({ name, value: privateKeyData.toString('base64'), meta });
47-
} catch (error) {
47+
} catch (error: any) {
4848
if (error && error.name === 'KeyEntryAlreadyExistsError') {
4949
throw new PrivateKeyExistsError(`Private key with the name ${name} already exists.`);
5050
}

src/Storage/adapters/IndexedDbStorageAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ function _getConnection(dbInfo: DbInfo, upgradeNeeded: boolean): Promise<IDBData
467467
const db = openReq.result;
468468
try {
469469
db.createObjectStore(dbInfo.storeName);
470-
} catch (ex) {
470+
} catch (ex: any) {
471471
if (ex.name === 'ConstraintError') {
472472
console.warn(
473473
'The database "' +
@@ -597,7 +597,7 @@ function createTransaction(
597597
try {
598598
const tx = dbInfo.db!.transaction(dbInfo.storeName!, mode);
599599
callback(null, tx);
600-
} catch (err) {
600+
} catch (err: any) {
601601
if (
602602
retries > 0 &&
603603
(!dbInfo.db ||

src/__tests__/declarations.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="sinon" />
22

3+
import * as Chai from "chai";
34
import AssertStatic = Chai.AssertStatic;
45
import SinonSpy = sinon.SinonSpy;
56
import SinonSpyCall = sinon.SinonSpyCall;
@@ -46,3 +47,4 @@ declare module NodeJS {
4647
browser?: boolean;
4748
}
4849
}
50+

src/__tests__/integration/CardManager.test.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ import {
1010
} from '../..';
1111
import { VirgilCardVerificationError } from '../../Cards/errors';
1212
import { ICard } from '../../Cards/ICard';
13-
13+
import * as chaiAsPromised from "chai-as-promised";
1414
import { compatData } from './data';
15+
import { use } from "chai";
16+
// @ts-ignore
17+
import {
18+
assert,
19+
sinon
20+
} from '../declarations';
1521

1622
const WELL_KNOWN_IDENTITY = `js_sdk_well_known_identity${Date.now()}@virgil.com`;
1723
let WELL_KNOWN_CARD_ID:string;
@@ -21,20 +27,20 @@ const init = (identity: string = WELL_KNOWN_IDENTITY) => {
2127
const accessTokenSigner = new VirgilAccessTokenSigner(crypto);
2228
const cardCrypto = new VirgilCardCrypto(crypto);
2329

24-
const apiPrivateKey = crypto.importPrivateKey(process.env.API_KEY_PRIVATE_KEY!);
30+
const apiPrivateKey = crypto.importPrivateKey(process.env.APP_KEY!);
2531

2632
const jwtGenerator = new JwtGenerator({
2733
appId: process.env.APP_ID!,
2834
apiKey: apiPrivateKey,
29-
apiKeyId: process.env.API_KEY_ID!,
35+
apiKeyId: process.env.APP_KEY_ID!,
3036
accessTokenSigner,
3137
millisecondsToLive: 20 * 60 * 1000
3238
});
3339

3440
const expiredTokenGenerator = new JwtGenerator({
3541
appId: process.env.APP_ID!,
3642
apiKey: apiPrivateKey,
37-
apiKeyId: process.env.API_KEY_ID!,
43+
apiKeyId: process.env.APP_KEY_ID!,
3844
accessTokenSigner,
3945
millisecondsToLive: 1000
4046
});
@@ -59,15 +65,13 @@ const init = (identity: string = WELL_KNOWN_IDENTITY) => {
5965
};
6066
};
6167

62-
describe('CardManager', function () {
68+
describe('CardManager', async function () {
6369

64-
this.timeout(10000);
70+
//this.timeout(10000);
71+
await initCrypto();
6572

66-
before(async () => {
67-
await initCrypto();
68-
});
69-
70-
before(() => {
73+
before( () => {
74+
use(chaiAsPromised)
7175
const { cardManager, crypto, cardVerifier } = init();
7276
const keypair = crypto.generateKeys();
7377
cardVerifier.verifySelfSignature = false;
@@ -195,10 +199,10 @@ describe('CardManager', function () {
195199
);
196200
});
197201

198-
it ('verifies cards after publishing', () => {
202+
it ('verifies cards after publishing', async() => {
199203
const keypair = crypto.generateKeys();
200204

201-
return assert.isRejected(
205+
return await assert.isRejected(
202206
cardManager.publishCard({
203207
privateKey: keypair.privateKey,
204208
publicKey: keypair.publicKey,
@@ -208,7 +212,7 @@ describe('CardManager', function () {
208212
);
209213
});
210214

211-
it ('verifies cards after publishing as raw model', () => {
215+
it ('verifies cards after publishing as raw model', async () => {
212216
const keypair = crypto.generateKeys();
213217
const rawCard = cardManager.generateRawCard({
214218
privateKey: keypair.privateKey,
@@ -222,14 +226,14 @@ describe('CardManager', function () {
222226
);
223227
});
224228

225-
it ('verifies cards on get', () => {
229+
it ('verifies cards on get', async () => {
226230
return assert.isRejected(
227231
cardManager.getCard(WELL_KNOWN_CARD_ID),
228232
VirgilCardVerificationError
229233
);
230234
});
231235

232-
it ('verifies cards on search', () => {
236+
it ('verifies cards on search', async () => {
233237
return assert.isRejected(
234238
cardManager.searchCards(WELL_KNOWN_IDENTITY),
235239
VirgilCardVerificationError
@@ -476,19 +480,19 @@ describe('CardManager', function () {
476480
.callsFake(getTokenFn as any);
477481
});
478482

479-
it ('retries get card', () => {
483+
it ('retries get card', async () => {
480484
return assert.isFulfilled(
481485
cardManager.getCard(WELL_KNOWN_CARD_ID)
482486
);
483487
});
484488

485-
it ('retries search cards', () => {
489+
it ('retries search cards', async () => {
486490
return assert.isFulfilled(
487491
cardManager.searchCards(WELL_KNOWN_IDENTITY)
488492
);
489493
});
490494

491-
it ('retries publish card', () => {
495+
it ('retries publish card', async () => {
492496
const { privateKey, publicKey } = crypto.generateKeys();
493497
return assert.isFulfilled(
494498
cardManager.publishCard({

src/__tests__/unit/PrivateKeyStorage.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ describe ('PrivateKeyStorage', () => {
4848
describe ('load', () => {
4949
it ('imports private key data before returning', () => {
5050
const thePrivateKey = {};
51-
privateKeyExporterStub.importPrivateKey.returns(thePrivateKey);
51+
privateKeyExporterStub.importPrivateKey.returns(thePrivateKey as IPrivateKey);
5252
storageBackendStub.load.withArgs('test').resolves({
5353
name: 'test',
54-
value: Buffer.from('private_key'),
54+
value: Buffer.from('private_key') as unknown as string,
55+
creationDate: new Date(),
56+
modificationDate: new Date(),
5557
meta: { meta: 'data' }
5658
});
5759

tsconfig.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
{
2-
"compilerOptions": {
3-
"moduleResolution": "node",
4-
"target": "es5",
5-
"lib": ["es2015", "es2016", "es2017", "es2018", "dom"],
2+
"compilerOptions": {
3+
"lib": ["es5", "es6", "dom", "dom.iterable"],
4+
"baseUrl": ".",
5+
"target": "es2020",
6+
"outDir": "./dist",
7+
"forceConsistentCasingInFileNames": true,
68
"strict": true,
9+
"noImplicitReturns": false,
10+
"strictPropertyInitialization": false,
11+
"noFallthroughCasesInSwitch": true,
712
"sourceMap": true,
813
"declaration": true,
9-
"esModuleInterop": true,
14+
"declarationDir": "./dist/types",
15+
"downlevelIteration": true,
16+
"experimentalDecorators": true,
17+
"moduleResolution": "node",
18+
"importHelpers": true,
1019
"allowSyntheticDefaultImports": true,
11-
"declarationDir": "dist/types",
12-
"resolveJsonModule": true
20+
"types": ["node", "jest", "mocha"],
21+
"module": "es2015",
22+
"noImplicitAny": true,
23+
"resolveJsonModule": true,
1324
},
1425
"include": [
1526
"src"

tsconfig.spec.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"outDir": "./dist",
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitReturns": false,
8+
"strictPropertyInitialization": false,
9+
"noFallthroughCasesInSwitch": true,
10+
"sourceMap": true,
11+
"declaration": true,
12+
"declarationDir": "./dist/types",
13+
"downlevelIteration": true,
14+
"experimentalDecorators": true,
15+
"noImplicitAny": true,
16+
"moduleResolution": "node",
17+
"importHelpers": true,
18+
"esModuleInterop": true,
19+
"target": "es2020",
20+
"module": "commonjs",
21+
"lib": [
22+
"es2018",
23+
"dom"
24+
]
25+
},
26+
}

0 commit comments

Comments
 (0)