exposure-keys 1.17.1 → 1.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ExposureKeys.d.ts +3 -3
- package/dist/ExposureKeys.js +20 -20
- package/package.json +2 -2
package/dist/ExposureKeys.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TEKSignatureList, TemporaryExposureKeyExport } from '../proto/export.js';
|
|
2
|
+
export declare function loadKeys(fileContent: Buffer): TemporaryExposureKeyExport;
|
|
3
|
+
export declare function loadSignature(fileContent: Buffer): TEKSignatureList;
|
|
2
4
|
export declare function loadZip(fileContent: Buffer): Promise<{
|
|
3
5
|
keys: Buffer;
|
|
4
6
|
signature: Buffer;
|
|
5
7
|
}>;
|
|
6
|
-
export declare function loadKeys(fileContent: Buffer): TemporaryExposureKeyExport;
|
|
7
|
-
export declare function loadSignature(fileContent: Buffer): TEKSignatureList;
|
|
8
8
|
export declare function riskCount(temporaryExposureKeyExport: TemporaryExposureKeyExport, transmissionRiskLevel: number): number;
|
package/dist/ExposureKeys.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { loadAsync } from 'jszip';
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { TEKSignatureList, TemporaryExposureKeyExport } from '../proto/export.js';
|
|
3
|
+
export function loadKeys(fileContent) {
|
|
4
|
+
if (isZip(fileContent)) {
|
|
5
|
+
throw new Error('You are trying to load a zip file. Please use `loadZip()` for that');
|
|
6
|
+
}
|
|
7
|
+
const wantedHeader = 'EK Export v1 ';
|
|
8
|
+
const header = fileContent.slice(0, wantedHeader.length);
|
|
9
|
+
const key = fileContent.slice(wantedHeader.length);
|
|
10
|
+
if (header.toString('utf-8') !== wantedHeader) {
|
|
11
|
+
throw new Error('The key is missing a correct header');
|
|
12
|
+
}
|
|
13
|
+
return TemporaryExposureKeyExport.decode(key);
|
|
14
|
+
}
|
|
15
|
+
export function loadSignature(fileContent) {
|
|
16
|
+
return TEKSignatureList.decode(fileContent);
|
|
7
17
|
}
|
|
8
18
|
export async function loadZip(fileContent) {
|
|
9
19
|
var _a, _b;
|
|
@@ -21,21 +31,11 @@ export async function loadZip(fileContent) {
|
|
|
21
31
|
}
|
|
22
32
|
return { keys: keyData, signature: signatureData };
|
|
23
33
|
}
|
|
24
|
-
export function loadKeys(fileContent) {
|
|
25
|
-
if (isZip(fileContent)) {
|
|
26
|
-
throw new Error('You are trying to load a zip file. Please use `loadZip()` for that');
|
|
27
|
-
}
|
|
28
|
-
const wantedHeader = 'EK Export v1 ';
|
|
29
|
-
const header = fileContent.slice(0, wantedHeader.length);
|
|
30
|
-
const key = fileContent.slice(wantedHeader.length);
|
|
31
|
-
if (header.toString('utf-8') !== wantedHeader) {
|
|
32
|
-
throw new Error('The key is missing a correct header');
|
|
33
|
-
}
|
|
34
|
-
return TemporaryExposureKeyExport.decode(key);
|
|
35
|
-
}
|
|
36
|
-
export function loadSignature(fileContent) {
|
|
37
|
-
return TEKSignatureList.decode(fileContent);
|
|
38
|
-
}
|
|
39
34
|
export function riskCount(temporaryExposureKeyExport, transmissionRiskLevel) {
|
|
40
35
|
return temporaryExposureKeyExport.keys.filter(key => key.transmissionRiskLevel && key.transmissionRiskLevel === transmissionRiskLevel).length;
|
|
41
36
|
}
|
|
37
|
+
function isZip(fileContent) {
|
|
38
|
+
// eslint-disable-next-line no-magic-numbers
|
|
39
|
+
const zipHeader = [0x50, 0x4b];
|
|
40
|
+
return Buffer.from(zipHeader).compare(fileContent, 0, 2) === 0;
|
|
41
|
+
}
|
package/package.json
CHANGED