From f0005a9ed3487a9b4ea9ef0f8378e225bcc338c7 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Sat, 10 Apr 2021 09:01:35 -0500 Subject: [PATCH] Add exposure notification example to reference implementation --- test_clients.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test_clients.js b/test_clients.js index bbcba78..9c95155 100644 --- a/test_clients.js +++ b/test_clients.js @@ -16,6 +16,13 @@ class TestClient { return bcrypt.hashSync(`${lesserId}-${greaterId}`, this.salt) } + buildExposure() { + return { + clientID: this.id, + timestamp: (new Date).getTime(), + } + } + async interactWith(otherClient) { const hash = otherClient.getHash(this.id) const message = openpgp.Message.fromText(hash) @@ -43,9 +50,15 @@ class TestClient { const a_transact = await client_a.interactWith(client_b) const b_transact = await client_b.interactWith(client_a) + // Simulate an encounter between A and B console.log(a_transact, b_transact) postTo('/api/v1/encounter', a_transact) postTo('/api/v1/encounter', b_transact) + + // Simulate B being exposed + const b_exposure = client_b.buildExposure() + console.log(b_exposure) + postTo('/api/v1/exposure', b_exposure) })() function postTo(endpoint, data) {