-
Notifications
You must be signed in to change notification settings - Fork 21
/
demo.js
27 lines (22 loc) · 834 Bytes
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const cryptobox = require('../../');
const {MemoryEngine} = require('@wireapp/store-engine');
const Logdown = require('logdown');
const logger = new Logdown('Demo', {alignOutput: true});
logger.state.isEnabled = true;
logger.log(`Testing Cryptobox v${cryptobox.Cryptobox.VERSION}`);
(async () => {
try {
const MIN_AMOUNT_PREKEYS = 5;
const engine = new MemoryEngine();
await engine.init('cache');
const store = new cryptobox.store.CryptoboxCRUDStore(engine);
const box = new cryptobox.Cryptobox(store, MIN_AMOUNT_PREKEYS);
await box.create();
const fingerprint = box.identity.public_key.fingerprint();
logger.log(`Public Fingerprint: ${fingerprint}`);
process.exit(0);
} catch (error) {
logger.log(`Self test broken: ${error.message} (${error.stack})`);
process.exit(1);
}
})();