Skip to content

Commit

Permalink
Merge pull request #21 from VirgilSecurity/update-crypto-types
Browse files Browse the repository at this point in the history
Update @virgilsecurity/crypto-types
  • Loading branch information
vadimavdeev authored Oct 7, 2019
2 parents 562b73f + f7b2ec6 commit 4a451c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@virgilsecurity/keyknox",
"version": "0.4.0-next.0",
"version": "0.4.0-next.1",
"description": "Keyknox SDK allows developers to communicate with Virgil Keyknox Service to upload, download, and synchronize encrypted sensitive data (private keys) between different devices.",
"main": "./dist/keyknox.cjs.js",
"module": "./dist/keyknox.es.js",
Expand All @@ -20,7 +20,7 @@
},
"dependencies": {
"@types/base-64": "^0.1.3",
"@virgilsecurity/crypto-types": "^0.1.4",
"@virgilsecurity/crypto-types": "^0.2.0",
"axios": "^0.19.0",
"base-64": "^0.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/CloudGroupTicketStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class CloudGroupTicketStorage {
root: this.root,
path: sessionId,
key: epochNumber.toString(),
value: data.toString('base64'),
value: data,
});
} catch (error) {
if (error instanceof KeyknoxClientError && error.code === ERROR_CODE_INVALID_PREVIOUS_HASH) {
Expand Down
22 changes: 8 additions & 14 deletions src/__tests__/CloudGroupTicketStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ describe('CloudGroupTicketStorage', () => {
const sessionId = groupSession.getSessionId();
const epochNumber = groupSession.getCurrentEpochNumber();
const data = groupSession.export()[0];
const results: IGroupSessionMessageInfo[] = [{ sessionId, epochNumber, data }];
const results: IGroupSessionMessageInfo[] = [
{ sessionId, epochNumber, data: data.toString('base64') },
];
for (let i = 0; i < myAmount - 1; i += 1) {
results.push(groupSession.addNewEpoch());
}
Expand Down Expand Up @@ -146,7 +148,7 @@ describe('CloudGroupTicketStorage', () => {
privateKey: keyPair.privateKey,
publicKeys: keyPair.publicKey,
});
expect(decryptedKeyknoxValue.value).to.equal(groupSessionMessageInfo.data.toString('base64'));
expect(decryptedKeyknoxValue.value).to.equal(groupSessionMessageInfo.data);
});

it('stores message info for card', async () => {
Expand All @@ -161,9 +163,7 @@ describe('CloudGroupTicketStorage', () => {
groupSessionMessageInfo.epochNumber,
);
expect(ticket.groupSessionMessageInfo.sessionId).to.equal(groupSessionMessageInfo.sessionId);
expect(ticket.groupSessionMessageInfo.data).to.equal(
groupSessionMessageInfo.data.toString('base64'),
);
expect(ticket.groupSessionMessageInfo.data).to.equal(groupSessionMessageInfo.data);
});

it('throws if message info already exists', async () => {
Expand Down Expand Up @@ -195,14 +195,10 @@ describe('CloudGroupTicketStorage', () => {
}
expect(myGroupSessionMessageInfo1.sessionId).to.equal(groupSessionMessageInfo1.sessionId);
expect(myGroupSessionMessageInfo1.epochNumber).to.equal(groupSessionMessageInfo1.epochNumber);
expect(myGroupSessionMessageInfo1.data).to.equal(
groupSessionMessageInfo1.data.toString('base64'),
);
expect(myGroupSessionMessageInfo1.data).to.equal(groupSessionMessageInfo1.data);
expect(myGroupSessionMessageInfo2.sessionId).to.equal(groupSessionMessageInfo2.sessionId);
expect(myGroupSessionMessageInfo2.epochNumber).to.equal(groupSessionMessageInfo2.epochNumber);
expect(myGroupSessionMessageInfo2.data).to.equal(
groupSessionMessageInfo2.data.toString('base64'),
);
expect(myGroupSessionMessageInfo2.data).to.equal(groupSessionMessageInfo2.data);
});

it('retrieves group session for identity', async () => {
Expand All @@ -217,9 +213,7 @@ describe('CloudGroupTicketStorage', () => {
expect(ticket.groupSessionMessageInfo.epochNumber).to.equal(
groupSessionMessageInfo.epochNumber,
);
expect(ticket.groupSessionMessageInfo.data).to.equal(
groupSessionMessageInfo.data.toString('base64'),
);
expect(ticket.groupSessionMessageInfo.data).to.equal(groupSessionMessageInfo.data);
});

it('throws if we try to retrieve non-existent group session', async () => {
Expand Down

0 comments on commit 4a451c9

Please sign in to comment.