-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for EdDSA
and ES256K
key types in the browser.
#26
Comments
> [email protected] test:browser
> cross-env BABEL_ENV=test karma start karma.conf.cjs
START:
30 03 2022 00:32:07.390:INFO [preprocessor.rollup]: Generating bundle for ./tests/interfaces/permissions/permission-tests.ts
30 03 2022 00:32:07.709:INFO [karma-server]: Karma v6.3.17 server started at http://localhost:9876/
30 03 2022 00:32:07.710:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
30 03 2022 00:32:07.713:INFO [launcher]: Starting browser ChromeHeadless
30 03 2022 00:32:08.126:INFO [Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)]: Connected on socket hsphXG2iYbjYW9-6AAAB with id 15540964
Permission Tests
constructor
✖ throws an exception if expiration is in the past (skipped)
✖ throws an exception if expiration is before nbf (skipped)
toUnixEpochSeconds
✔ adds duration to the current time and returns that as a unix epoch timestamp
✖ converts a date to a unix epoch timestamp (skipped)
Message Tests
validateMessage
✖ throws exception if interface method isnt supported (skipped)
✖ throws exception if message is invalid relative to interface method (skipped)
verifyMessageSignature
✖ throws an exception if attestation property is missing (skipped)
✔ throws an exception if attestation payload is not a valid CID
✖ throws an exception if CID of descriptor !== attestation payload
✖ throws an exception if provided CID doesnt utilize cbor codec
✖ throws an exception if provided CID uses unsupported hashing algo
✖ throws an exception if DID could not be resolved
✖ throws an exception if appropriate key isnt present in DID Doc
✖ throws an exception if signature does not match
✖ resolves if signature is successfully verified
Finished in 0.031 secs / 0.015 secs @ 00:32:08 GMT-0500 (Central Daylight Time)
SUMMARY:
✔ 2 tests completed
ℹ 6 tests skipped
✖ 7 tests failed
FAILED TESTS:
Message Tests
verifyMessageSignature
✖ throws an exception if CID of descriptor !== attestation payload
Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)
TypeError: Unknown encoding: base64url
at Uint8Array.slowToString (tests/message-tests.js:682:34)
at Uint8Array.toString (tests/message-tests.js:740:25)
at _callee2$ (tests/message-tests.ts:71:49 <- tests/message-tests.js:62116:55)
at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40 <- tests/message-tests.js:2101:42)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22 <- tests/message-tests.js:2332:24)
at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21 <- tests/message-tests.js:2157:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:24 <- tests/message-tests.js:1978:26)
at _next (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25:9 <- tests/message-tests.js:2000:11)
✖ throws an exception if provided CID doesnt utilize cbor codec
Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)
TypeError: Unknown encoding: base64url
at Uint8Array.slowToString (tests/message-tests.js:682:34)
at Uint8Array.toString (tests/message-tests.js:740:25)
at _callee3$ (tests/message-tests.ts:120:49 <- tests/message-tests.js:62181:55)
at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40 <- tests/message-tests.js:2101:42)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22 <- tests/message-tests.js:2332:24)
at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21 <- tests/message-tests.js:2157:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:24 <- tests/message-tests.js:1978:26)
at _next (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25:9 <- tests/message-tests.js:2000:11)
✖ throws an exception if provided CID uses unsupported hashing algo
Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)
TypeError: Unknown encoding: base64url
at Uint8Array.slowToString (tests/message-tests.js:682:34)
at Uint8Array.toString (tests/message-tests.js:740:25)
at _callee4$ (tests/message-tests.ts:154:49 <- tests/message-tests.js:62230:55)
at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40 <- tests/message-tests.js:2101:42)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22 <- tests/message-tests.js:2332:24)
at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21 <- tests/message-tests.js:2157:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:24 <- tests/message-tests.js:1978:26)
at _next (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25:9 <- tests/message-tests.js:2000:11)
✖ throws an exception if DID could not be resolved
Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)
TypeError: Unknown encoding: base64url
at Uint8Array.slowToString (tests/message-tests.js:682:34)
at Uint8Array.toString (tests/message-tests.js:740:25)
at _callee5$ (tests/message-tests.ts:188:49 <- tests/message-tests.js:62280:55)
at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40 <- tests/message-tests.js:2101:42)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22 <- tests/message-tests.js:2332:24)
at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21 <- tests/message-tests.js:2157:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:24 <- tests/message-tests.js:1978:26)
at _next (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25:9 <- tests/message-tests.js:2000:11)
✖ throws an exception if appropriate key isnt present in DID Doc
Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)
TypeError: Unknown encoding: base64url
at Uint8Array.slowToString (tests/message-tests.js:682:34)
at Uint8Array.toString (tests/message-tests.js:740:25)
at _callee6$ (tests/message-tests.ts:234:49 <- tests/message-tests.js:62342:55)
at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40 <- tests/message-tests.js:2101:42)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22 <- tests/message-tests.js:2332:24)
at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21 <- tests/message-tests.js:2157:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:24 <- tests/message-tests.js:1978:26)
at _next (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25:9 <- tests/message-tests.js:2000:11)
✖ throws an exception if signature does not match
Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)
JOSENotSupported: Invalid or unsupported JWK "alg" (Algorithm) Parameter value
at generateKeyPair$1 (node_modules/jose/dist/browser/runtime/generate.js:127:19 <- tests/message-tests.js:36539:21)
at generateKeyPair (node_modules/jose/dist/browser/key/generate_key_pair.js:3:12 <- tests/message-tests.js:36545:14)
at _callee7$ (tests/message-tests.ts:283:32 <- tests/message-tests.js:62404:24)
at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40 <- tests/message-tests.js:2101:42)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22 <- tests/message-tests.js:2332:24)
at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21 <- tests/message-tests.js:2157:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:24 <- tests/message-tests.js:1978:26)
at _next (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25:9 <- tests/message-tests.js:2000:11)
✖ resolves if signature is successfully verified
Chrome Headless 99.0.4844.84 (Mac OS 10.15.7)
JOSENotSupported: Invalid or unsupported JWK "alg" (Algorithm) Parameter value
at generateKeyPair$1 (node_modules/jose/dist/browser/runtime/generate.js:127:19 <- tests/message-tests.js:36539:21)
at generateKeyPair (node_modules/jose/dist/browser/key/generate_key_pair.js:3:12 <- tests/message-tests.js:36545:14)
at _callee8$ (tests/message-tests.ts:340:32 <- tests/message-tests.js:62488:24)
at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40 <- tests/message-tests.js:2101:42)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22 <- tests/message-tests.js:2332:24)
at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21 <- tests/message-tests.js:2157:23)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3:24 <- tests/message-tests.js:1978:26)
at _next (node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25:9 <- tests/message-tests.js:2000:11) |
Some of the browser tests are failing because |
* made code DWN browser compatible * generalized signing algorithm support * explicit public and private key types * added eslint rules * remove use of `AJV` within JOSE algorithms. validation already happens in a previous step * move to using a single base64url lib across the codebase instead of two * resolve some TODOs * favor `Uint8Array` over `Buffer`. Reasoning here: https://stackoverflow.com/a/54814368/4471535 * add function to generate `secp256k1` keypairs * simplify `secp256k1.verify` by leaning on underlying lib * fix `secp256k1.sign` by hashing the payload prior to signing * add JSDoc where missing Co-authored-by: Moe Jangda <[email protected]>
JOSE doesn't support
EdDSA
orES256K
(akasecp256k1
) in the browser. I went ahead and added automated headless browser testing against our browser bundles so that we can fish out issues like these programmatically.The tests that generate
EdDSA
keys are currently failing in the browser.The text was updated successfully, but these errors were encountered: