Skip to content
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 JS packaging for verification functions #111

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft

Conversation

bgins
Copy link
Contributor

@bgins bgins commented Jun 12, 2023

This is a draft PR that still needs work! It's open to initial feedback, but see the remaining tasks section to get an idea of what needs to be implemented.

Description

This PR implements the following features:

  • Add TypeScript bindings for checkSignature, decode, isExpired, isTooEarly, toCID, validate functions
  • Add ucan-wasm crate with JavaScript packaging support
  • Add packaging support for browser, node, deno, and workerd targets (workerd is Cloudflare workers)

Link to issue

Implements #93

Type of change

  • New feature (non-breaking change that adds functionality)

Test plan (required)

The test suite includes unit tests for each function. Tests read from a set of fixtures written in the style of the spec repo fixtures (https://github.com/ucan-wg/spec/tree/main/fixtures/0.8.1) but upgraded to UCAN 0.9.0. (Side note: It would be nice to eventually add these to the spec repo and pull them from there.)

The tests are run in node and headless browser environments including chromium, firefox, and webkit.

Remaining tasks

  • Upgrade to UCAN 0.10.0
  • Convert test fixtures to UCAN 0.10.0
  • Optimize for size where possible
  • Investigate DID parsing options. Bringing in key support here doubles the size of the Wasm binary:

const SUPPORTED_KEYS: &KeyConstructorSlice = &[
(ED25519_MAGIC_BYTES, bytes_to_ed25519_key),
(RSA_MAGIC_BYTES, bytes_to_rsa_key),
(P256_MAGIC_BYTES, bytes_to_p256_key),
];

  • Add bindings for more validation functions
  • Add deno tests
  • Add workerd tests (if possible)
  • Add bundler tests for a couple of commonly used bundlers

bgins added 15 commits May 26, 2023 13:21
Cloudflare workers use the workerd key.
Use playwright-tests for browser tests instead of vitest. It is
currently more stable than vitest for browser testing.

Convert tests from expect to assert for a purely JS implementation.
Unify tests into a single module which is loaded by each environment
after import and initialization (where required).

Add coverage. Write coverage and test results for each environment to
JSON files.
@bgins bgins changed the title Add JS packaging Add JS packaging for verification functions Jun 13, 2023
@bgins bgins requested a review from zeeshanlakhani June 16, 2023 17:02
@bgins bgins force-pushed the bgins/add-js-support branch from cf69289 to a3c8aef Compare July 5, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant