Skip to content

Commit

Permalink
feat: oa v4 (alpha) (#254)
Browse files Browse the repository at this point in the history
* ci: prepare alpha release

* feat: oa v4 alpha

* fix: lint errors

* test: update fixtures

* chore: update id description

* test: update fixtures

* chore: improve readability

* fix: pr review suggestions

* fix: stricter checks for isStringArray

* fix: getDocumentData for v4

* chore: update getTemplateURL error message

chore: remove required fields (#271)

feat: align against W3C VC 2.0 test suite and complete unit tests (#272)

* chore: npm install jsonld & joi

- upgrade @types/jsonld and ts-node

* chore: add vc 2.0 context url and store as cache

- instead of keeping a local copy, may consider to use node-cache in the future

* fix: align validation with vc 2.0 test suite

- fix: utilise "expand" from jsonld to ensure provided @context are interpretable
- fix: improve readability and allow flexibility in oa v4 schema (wrap vs unwrapped, etc.)

* fix: set additionalProperties to false due to AJV false positive

* fix: allow additional properties in credentialStatus

* fix: include error details instead of console log

* test: update v4 alpha test fixtures

* lint: ignore unused argument options

* chore: upgrade jest and ts-jest

* fix: segmentation fault when using default nodeDocumentLoader()

* fix: use scoped context types

avoid using sub types (e.g. renderMethodType = EMBEDDED_RENDERER) and just utilise a scoped context (e.g. type = OpenAttestationEmbeddedRenderer)

* test: no more auto-correct for @context based on vc 2.0 test suite

expected behaviour is to throw error

* fix: digest should handle falsy values correctly

* fix: rename to renderMethod.templateName

* fix: make renderMethod an array

* fix: remove json schema validation in v4.0 wrap

* test: update v4.0 fixtures

* fix: digest test

* fix: make renderMethod.templateName required in v4.0 json schema

* fix: migrate to zod for input vc data model validation

* wip: oa v4 types

* refactor: prefer string union

* refactor: reference constant tuple instead

* refactor: finalTypes follows pattern of finalContexts

* refactor: document -> raw document for clarity

* fix: rawDocument should not be used directly for digest and salting

* fix: remove asserting to string to let the literal infer properly

* fix: typings

* refactor: move assertion earlier

* refactor: assert oa vc than try vc

* fix: refer to new oa vc type in digest and verify

* fix: refer to new oa vc typings

* fix: refer to new oa vc typings

* fix: refer to new oa vc typings

* refactor: improve naming consistency

* fix: typing, should be looser

* fix: a union b does not override a props with b props

* fix: added assertion type to prevent accident extension to base type

* refactor: wording

* refactor: better readability for wrapped types

* refactor: move things within file and some renaming

* refactor: improve naming of variables

* fix: use new typings

* fix: passthroughs needed to allow extension, added name and render method so they dont get stripped

* test: added a guard test which is currently failing

* refactor: merged data model with types and renamed VC type

* refactor: improve helper fn naming

* fix: use extend instead of and since it results in dup errors, remove hex validation since these props are generated by us, allow passthrough for wrap proof so that a signed wrap can pass a wrap only validation test

* test: update snapshot

* fix: was using the wrong document for the check

* test: added tests for wrapped only document

* fix: diagnose to use new guards

* fix: path

* chore: remove vscode

* chore: ignore vscode settings

* chore: remove experimental version guard

* fix: add back the missing wrapDocuments that was accidentally removed

* fix: replace back original implementation of getMerkleRoot

* fix: make our own real types stricter

* fix: diagnose did not handle raw v4

* refactor: remove useless renaming

* fix: object object in test case

* refactor: improve type safety of wrap document v4

* chore: remove to make way for auto generated fixtures

* chore: auto generate v4 fixtures

* fix: could not generated nested dir

* test: add wrap unit tests

* test: extra assertion for proof

* fix: salt test

* fix: allow resigning and validate proof before using

* fix: v4 sign tests

* chore: add batch wrapped document fixture. freeze all documents before exporting

* fix: obfuscate typing was loses the initial input typing

* fix: should not allow obfuscate to produce non compliant v4 wrapped document

* fix: partially fix obfuscate test

* fix: it is more accurate that credentials subject after obfuscastion shd be deeply partial

* fix: clean up digest test

* feat: support attachments

* fix: digestMultibase shd be optional, added descriptions to fields

* refactor: remove renderMethod from w3c model and force it to be exported in passthrough mode

* chore: improve guard test to use direct output of our fns as test case

* fix: allow attachment item to be empty so that obfuscation of a single attachment item is possible

* refactor: improve typing

* fix: partial fix of obfuscate test

* wip: draft of changes to address issues raised

* fix: wrongly returned object for boolean

* fix: shd not allow new empty objects after obfuscation or removing array items

* chore: update fixtures

* fix: digest should not include proof

* fix: skip finding leaf nodes to hash if document without proof is empty

* refactor: improve naming

* fix: broken tests

* fix: revert target bump

* fix: all obfuscate tests

* fix: verify should treat salt not found error as invalid

* fix: partial fix of verify tests, added bunch of todos

* chore: add batched signed documents

* fix: complete verify tests

* refactor: typo remove redundant top describe

* fix: fixtures and test it will break on update

* refactor: improve error message to provide more guidance

* fix: array items cannot be undefined

* chore: commit generated fixtures and allow ci tests to catch any drifts

* chore: added remedy action if fixture test fails

* chore: remove lint for all generated files

* fix: v4 e2e

* refactor: improve error types and exporting

---------

Co-authored-by: Phan Shi Yu <phan_shi_yu@tech.gov.sg>
Co-authored-by: Phan Shi Yu <phan_shi_yu@hive.gov.sg>
  • Loading branch information
3 people committed May 3, 2024
1 parent 70059b2 commit 4cd2187
Show file tree
Hide file tree
Showing 49 changed files with 5,665 additions and 1,919 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
coverage
dist
src/__generated__
__generated__
vc-test-suite
*.d.ts
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"func-names": ["error", "as-needed"],
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches:
- master
- alpha
- beta
- +([0-9])?(.{+([0-9]),x}).x

Expand Down Expand Up @@ -30,12 +31,8 @@ jobs:
node-version: 18.x
- run: npm ci && npm run postinstall
- run: npm run build
- uses: codfish/semantic-release-action@v2
id: semantic
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Output new release version
if: steps.semantic.outputs.new-release-published == 'true'
run: |
echo "🎉 New Release Published: ${{ steps.semantic.outputs.release-version }}"
run: npx semantic-release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ yarn.lock
*.iml
/public
/vc-test-suite
/.vscode
13 changes: 13 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"branches": [
"master",
{
"name": "alpha",
"prerelease": true
},
{
"name": "beta",
"prerelease": true
}
]
}

0 comments on commit 4cd2187

Please sign in to comment.