-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from vault12/vault12-integration
vault12-integration
- Loading branch information
Showing
18 changed files
with
331 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
const sessionTimeoutBuffer = 30 * 1000; | ||
|
||
export const config = { | ||
NONCE_TAG: '__nc', | ||
SKEY_TAG: 'storage_key', | ||
STORAGE_ROOT: '.v2.stor.vlt12', | ||
// Relay tokens, keys and hashes are 32 bytes | ||
RELAY_TOKEN_LEN: 32, | ||
// 5 min - Token expiration on the server side, matched with config.x.relay.token_timeout on Zax server | ||
RELAY_TOKEN_TIMEOUT: 5 * 60 * 1000, | ||
RELAY_TOKEN_TIMEOUT: 5 * 60 * 1000 - sessionTimeoutBuffer, | ||
// 20 min - Session expiration on the server side, matched with config.x.relay.session_timeout on Zax server | ||
RELAY_SESSION_TIMEOUT: 20 * 60 * 1000 - sessionTimeoutBuffer, | ||
// 5 sec - Ajax request timeout | ||
RELAY_AJAX_TIMEOUT: 5 * 1000 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { NaCl } from '../nacl/nacl'; | ||
import { Mailbox } from './mailbox'; | ||
import { testRelayURL, testRelayURL2 } from '../tests.helper'; | ||
import { CryptoStorage } from '../crypto-storage/crypto-storage'; | ||
|
||
describe('Mailbox simultaneously', () => { | ||
let Alice: Mailbox; | ||
let Bob: Mailbox; | ||
const msg1 = 'hi'; | ||
const msg2 = 'hi there'; | ||
|
||
beforeAll(async () => { | ||
NaCl.setDefaultInstance(); | ||
CryptoStorage.setDefaultStorageDriver(); | ||
|
||
}); | ||
|
||
describe('using different mailboxes simultaneously', () => { | ||
|
||
beforeAll(async () => { | ||
await createMailboxes(); | ||
}); | ||
|
||
it('send messages from different mailboxes', async() => { | ||
await Promise.all([ | ||
Alice.upload(testRelayURL, 'Bob', msg1), | ||
Alice.upload(testRelayURL, 'Bob', msg2), | ||
Bob.upload(testRelayURL, 'Alice', msg2) | ||
]); | ||
}); | ||
|
||
it('receive messages', async() => { | ||
const [aliceMsgs, bobMsgs] = await Promise.all([ | ||
Alice.download(testRelayURL), | ||
Bob.download(testRelayURL) | ||
]); | ||
expect(aliceMsgs.map(m => m.data)).toEqual([msg2]); | ||
expect(bobMsgs.map(m => m.data).sort()).toEqual([msg1, msg2].sort()); | ||
await Promise.all([ | ||
Alice.delete(testRelayURL, aliceMsgs.map(m => m.nonce)), | ||
Bob.delete(testRelayURL, bobMsgs.map(m => m.nonce)) | ||
]); | ||
}); | ||
}); | ||
|
||
describe('using different relays simultaneously', () => { | ||
|
||
beforeAll(async () => { | ||
await createMailboxes(); | ||
}); | ||
|
||
it('send messages', async () => { | ||
await Promise.all([ | ||
Alice.upload(testRelayURL, 'Bob', msg1), | ||
Alice.upload(testRelayURL2, 'Bob', msg1), | ||
Alice.upload(testRelayURL2, 'Bob', msg2), | ||
]); | ||
}); | ||
|
||
it('receive messages', async () => { | ||
const [msgsRelay1, msgsRelay2] = await Promise.all([ | ||
Bob.download(testRelayURL), | ||
Bob.download(testRelayURL2), | ||
]); | ||
expect(msgsRelay1.map(m => m.data)).toEqual([msg1]); | ||
expect(msgsRelay2.map(m => m.data).sort()).toEqual([msg1, msg2].sort()); | ||
Bob.delete(testRelayURL, msgsRelay1.map(m => m.nonce)); | ||
Bob.delete(testRelayURL2, msgsRelay2.map(m => m.nonce)); | ||
}); | ||
}); | ||
|
||
|
||
async function createMailboxes() { | ||
|
||
Alice = await Mailbox.new('Alice'); | ||
Bob = await Mailbox.new('Bob'); | ||
|
||
await Alice.keyRing.addGuest('Bob', Bob.keyRing.getPubCommKey()); | ||
await Bob.keyRing.addGuest('Alice', Alice.keyRing.getPubCommKey()); | ||
} | ||
|
||
}); |
Oops, something went wrong.