-
Notifications
You must be signed in to change notification settings - Fork 7
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 #31 from vaxxnz/feature/minor_improvements
- Loading branch information
Showing
21 changed files
with
164 additions
and
63 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
diff --git a/node_modules/cbor/lib/constants.js b/node_modules/cbor/lib/constants.js | ||
index 932e1c5..9b4502c 100644 | ||
index 932e1c5..9ca7538 100644 | ||
--- a/node_modules/cbor/lib/constants.js | ||
+++ b/node_modules/cbor/lib/constants.js | ||
@@ -2,7 +2,7 @@ | ||
@@ -2,7 +2,10 @@ | ||
|
||
// Let's get consistent first, then we can think about feature testing | ||
// for BigNumber support | ||
-const {BigNumber} = require('bignumber.js') | ||
+const {BigNumber} = require('bignumber.js/bignumber.mjs') | ||
+const isNode = typeof process !== 'undefined' | ||
+ && process.versions != null | ||
+ && process.versions.node != null | ||
+const {BigNumber} = isNode ? require('bignumber.js') : require('bignumber.js/bignumber.mjs') | ||
|
||
exports.BigNumber = BigNumber | ||
|
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,11 @@ | ||
import { base32 } from "rfc4648"; | ||
|
||
test("Base32 library works", async () => { | ||
const base32Example = | ||
"2KCEVIQEIVVWK6JNGEASNICZAEP2KALYDZSGSZB2O5SWEOTOPJRXALTDN53GSZBRHEXGQZLBNR2GQLTOPICRUYMBTIFAIGTUKBAAUYTWMOSGQQDDN5XHIZLYOSBHQJTIOR2HA4Z2F4XXO53XFZ3TGLTPOJTS6MRQGE4C6Y3SMVSGK3TUNFQWY4ZPOYYXQKTIOR2HA4Z2F4XW46TDOAXGG33WNFSDCOJONBSWC3DUNAXG46RPMNXW45DFPB2HGL3WGFTXMZLSONUW63TFGEXDALRQMR2HS4DFQJ2FMZLSNFTGSYLCNRSUG4TFMRSW45DJMFWG6UDVMJWGSY2DN53GSZCQMFZXG4LDOJSWIZLOORUWC3CTOVRGUZLDOSRWSZ3JOZSW4TTBNVSWISTBMNVWUZTBNVUWY6KOMFWWKZ2TOBQXE4TPO5RWI33CNIYTSNRQFUYDILJRGYDVAYFE6VGU4MCDGK7DHLLYWHVPUS2YIDJOA6Y524TD3AZRM263WTY2BE4DPKIF27WKF3UDNNVSVWRDYIYVJ65IRJJJ6Z25M2DO4YZLBHWFQGVQR5ZLIWEQJOZTS3IQ7JTNCFDX"; | ||
|
||
const res = base32.parse(base32Example); | ||
|
||
const base32String = base32.stringify(res); | ||
expect(base32String).toBe(base32Example); | ||
}); |
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,14 @@ | ||
import { base32 } from "rfc4648"; | ||
import cbor from "cbor"; | ||
|
||
test("CBOR library works", async () => { | ||
const res = base32.parse( | ||
"2KCEVIQEIVVWK6JNGEASNICZAEP2KALYDZSGSZB2O5SWEOTOPJRXALTDN53GSZBRHEXGQZLBNR2GQLTOPICRUYMBTIFAIGTUKBAAUYTWMOSGQQDDN5XHIZLYOSBHQJTIOR2HA4Z2F4XXO53XFZ3TGLTPOJTS6MRQGE4C6Y3SMVSGK3TUNFQWY4ZPOYYXQKTIOR2HA4Z2F4XW46TDOAXGG33WNFSDCOJONBSWC3DUNAXG46RPMNXW45DFPB2HGL3WGFTXMZLSONUW63TFGEXDALRQMR2HS4DFQJ2FMZLSNFTGSYLCNRSUG4TFMRSW45DJMFWG6UDVMJWGSY2DN53GSZCQMFZXG4LDOJSWIZLOORUWC3CTOVRGUZLDOSRWSZ3JOZSW4TTBNVSWISTBMNVWUZTBNVUWY6KOMFWWKZ2TOBQXE4TPO5RWI33CNIYTSNRQFUYDILJRGYDVAYFE6VGU4MCDGK7DHLLYWHVPUS2YIDJOA6Y524TD3AZRM263WTY2BE4DPKIF27WKF3UDNNVSVWRDYIYVJ65IRJJJ6Z25M2DO4YZLBHWFQGVQR5ZLIWEQJOZTS3IQ7JTNCFDX" | ||
); | ||
|
||
const cborobj = cbor.decode(res); | ||
|
||
expect(cborobj.err).toEqual(undefined); | ||
expect(cborobj.tag).toEqual(18); | ||
expect(cborobj.value.length).toEqual(4); | ||
}); |
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,8 +1,7 @@ | ||
|
||
type DecodedCOSEValue = (Buffer | Record<string, never>)[] | ||
type DecodedCOSEValue = (Buffer | Record<string, never>)[]; | ||
|
||
export interface DecodedCOSEStructure { | ||
tag: number, | ||
value: DecodedCOSEValue, | ||
err?: Error | ||
tag: number; | ||
value: DecodedCOSEValue; | ||
err?: Error; | ||
} |
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,17 @@ | ||
import { Resolver } from "did-resolver"; | ||
import { getResolver } from "web-did-resolver"; | ||
|
||
const webResolver = getResolver(); | ||
|
||
const didResolver = new Resolver({ | ||
...webResolver, | ||
}); | ||
|
||
test("CBOR library works", async () => { | ||
const doc = await didResolver.resolve("did:web:nzcp.covid19.health.nz"); | ||
expect(doc).toBeTruthy(); | ||
expect(doc.didDocument).toBeTruthy(); | ||
expect(doc.didDocument?.id).toBe("did:web:nzcp.covid19.health.nz"); | ||
expect(doc.didDocumentMetadata).toBeTruthy(); | ||
expect(doc.didResolutionMetadata).toBeTruthy(); | ||
}); |
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,28 @@ | ||
import elliptic from "elliptic"; | ||
|
||
const fromHexString = (hexString: string) => | ||
new Uint8Array( | ||
(hexString.match(/.{1,2}/g) ?? []).map((byte) => parseInt(byte, 16)) | ||
); | ||
|
||
test("elliptic library works", async () => { | ||
const publicKeyHex = | ||
"04cd147e5c6b02a75d95bdb82e8b80c3e8ee9caa685f3ee5cc862d4ec4f97cefad22fe5253a16e5be4d1621e7f18eac995c57f82917f1a9150842383f0b4a4dd3d"; | ||
const messageHashHex = | ||
"0513bb48e77bcfa51209a78d3224b0b2f1a29a9b9c0eff2263b6d08156aee72a"; | ||
const signatureRHex = | ||
"f6a9a841a390a40bd5cee4434cccdb7499d9461840f5c8dff436cba0698b1ab2"; | ||
const signatureSHex = | ||
"4dca052720b9f581200bebac2fff1afa159ce42aeb38d558df9413899db48271"; | ||
|
||
const signature = { | ||
r: fromHexString(signatureRHex), | ||
s: fromHexString(signatureSHex), | ||
}; | ||
|
||
const EC = elliptic.ec; | ||
const ec = new EC("p256"); | ||
const key = ec.keyFromPublic(publicKeyHex, "hex"); | ||
const result = key.verify(fromHexString(messageHashHex), signature); | ||
expect(result).toBe(true); | ||
}); |
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
Oops, something went wrong.