-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: oa v4 (alpha) #254
feat: oa v4 (alpha) #254
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
eslint
src/4.0/schema/schema.test.ts|377 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|383 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|399 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|415 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|431 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|449 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|469 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|490 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|491 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|500 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|533 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|553 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|588 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|623 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|646 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|669 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|694 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|695 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|700 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|709 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|718 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|723 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|728 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|735 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|756 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|779 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|799 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|820 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|840 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|861 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|883 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|884 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|895 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|920 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|947 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|948 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|957 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|966 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|976 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|996 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|1017 col 3| Some tests seem to be commented
src/4.0/schema/schema.test.ts|1038 col 3| Some tests seem to be commented
src/4.0/wrap.ts|15 col 3| 'options' is defined but never used. Allowed unused args must match /^_/u.
src/shared/@types/wrap.ts|15 col 18| An empty interface is equivalent to {}
.
dbbdd93
to
d120e21
Compare
c324812
to
f2a87bf
Compare
src/4.0/wrap.ts
Outdated
document["@context"] = Array.from(contexts).sort((a, b) => { | ||
const order = Array.from(contexts); | ||
if (order.indexOf(a) === -1) return 1; | ||
if (order.indexOf(b) === -1) return -1; | ||
return order.indexOf(a) - order.indexOf(b); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
talked to kyle about this, perhaps could be expressed clearer with just an iteration over the Sets since they preserve insertion order.
the reason why he did this is so to guarantee that the order will not be affected once the Set has been coerced into an Array, and he was cautious about it since sets in general are known to be unordered in other languages.
1b9327a
to
6e369c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once you've made the pushes and github services are restored lets merge this.
const contexts = new Set(["https://www.w3.org/2018/credentials/v1", ContextUrl.v4_alpha]); | ||
|
||
if (typeof document["@context"] === "string") { | ||
contexts.add(document["@context"]); | ||
} else if (isStringArray(document["@context"])) { | ||
document["@context"].forEach((context) => contexts.add(context)); | ||
} | ||
|
||
// Since JavaScript Sets preserve insertion order and duplicated inserts do not affect the order, we can do this: | ||
document["@context"] = Array.from(contexts); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small thing, I notice you have another part below at around line 36-40 doing something quite similar. You see if you want to create function for convenience sake. For eg:
function mergeDocSet<T extends string>(existing: T | T[], required: T[]): T[] {
const set = new Set(required);
if (typeof existing === "string") {
set.add(existing);
} else if (Array.isArray(existing)) {
existing.forEach((item) => set.add(item));
}
return Array.from(set);
}
Then you turn this part into just:
document["@context"] = mergeDocSet(document["@context"], ["https://www.w3.org/2018/credentials/v1", ContextUrl.v4_alpha]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this suggestion! As discussed, we can improve on this in the subsequent alpha version
const types = new Set(["VerifiableCredential", "OpenAttestationCredential"]); | ||
|
||
if (typeof document["type"] === "string") { | ||
types.add(document["type"]); | ||
} else if (isStringArray(document["type"])) { | ||
document["type"].forEach((type) => types.add(type)); | ||
} | ||
|
||
// Since JavaScript Sets preserve insertion order and duplicated inserts do not affect the order, we can do this: | ||
document["type"] = Array.from(types); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming if we use the above helper function, we can turn this part into just this:
document["type"] = mergeDocSet(document["type"], ["VerifiableCredential", "OpenAttestationCredential"]);
🎉 This PR is included in version 6.8.0-alpha.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* 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
* feat: init release (#4) * feat: trigger tagged build (#8) * feat: oa v4 (alpha) (Open-Attestation#254) * 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 * feat: idvc on v4 (#6) * chore: ds store * feat: init release * chore: commit lock * feat: idvc feature * feat: idvc feature * chore: fix lint errors * feat: regenerate test fixtures for ttv4 * fix: lint errors * chore: update readme * chore: fix lint errors * feat: add additional fixtures for invalid idvc case * feat: add fixtures for error case when idvc is missing * fix: lint errors * feat: tagged release, update badge for github actions * feat: trigger release after rebase of alpha --------- Co-authored-by: Kyle Huang Junyuan <[email protected]>
* 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 <[email protected]> Co-authored-by: Phan Shi Yu <[email protected]>
* feat: oa v4 (alpha) (#254) * 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 <[email protected]> Co-authored-by: Phan Shi Yu <[email protected]> * Chore: tidy v4 exports (#278) * refactor: shift context constants into 4.0 * refactor: bring context down to root of 4.0 * refactor: add custom error class, change algorithm to non enum * refactor: only leave the bare essentials of v4 in root index, fix tests * refactor: free up 4.0 from the mess of dependencies caused by importing of utils * fix: circular dependency caused by getData * feat: v4 utility guards * feat: export v4 * chore: generate v4 json schemas based with zod (#279) * chore: generate v4 json schemas based with zod * fix: small typo * chore: sign document should be clear on what errors it could throw, export of v4 verify shd be more explicit (#280) * chore: sign document should be clear on what errors it could throw * fix: verify export naming shd be more explicit * fix: bump target platform, and remove baseUrl as it is not supported (#282) * fix: bump target platform, and remove baseUrl as it is not supported * refactor: lint * Feat:document builder (#283) * feat: document builder poc * test: happy flow tests * refactor: improve comments * chore: export builder * test: more tests * fix: added logic to prevent re-setting of values * fix: guard constructor and added more test cases to test guards * fix: revocation support (#285) * fix: added revocation methods, refactor: revamp state management in instance * fix: tests * feat: added revocation store revocation method * feat: implemented revocation store revocation builder method * test: update to check credentialStatus * fix: improve ethereum address validation * tests: added tests for revocation store revocation method * chore: update json schemas * chore: update descriptions * chore: setup husky and lintstaged * fix: clean up hashing utils from utils and fix brokenreferences * feat: remove the need to polyfill manually in browser envs * fix: test * fix: remove use of crypto completely * fix: import buffer based on docs * fix: rendering methods (#287) * fix: missing svg renderer props and no renderer method * fix: only add render method if its defined * chore: improve handle bar template description * fix: improved descriptions on documentLoader's interface * fix: improving naming and description * feat: computeDigestMultibase (#288) * fix: only generate json fixtures when fixtures.ts changes (#289) * fix: move attachments into credentialSubject (#290) * fix: renamed document (#291) * fix: obfuscate typing and guard exports (#292) * fix: obfuscate typing refused to accept document that could be multiple version * fix: improve consistency of utils guard * fix: simplify obfuscateVerifiableCredential typing * fix: obfuscation return type should still have a compliant attachment… (#293) * fix: obfuscation return type should still have a compliant attachment array * fix: improve typing more * fix: mark v3 functions as deprecated (#298) --------- Co-authored-by: Phan Shi Yu <[email protected]> Co-authored-by: Phan Shi Yu <[email protected]>
* feat: oa v4 (alpha) (#254) * 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 <[email protected]> Co-authored-by: Phan Shi Yu <[email protected]> * Chore: tidy v4 exports (#278) * refactor: shift context constants into 4.0 * refactor: bring context down to root of 4.0 * refactor: add custom error class, change algorithm to non enum * refactor: only leave the bare essentials of v4 in root index, fix tests * refactor: free up 4.0 from the mess of dependencies caused by importing of utils * fix: circular dependency caused by getData * feat: v4 utility guards * feat: export v4 * chore: generate v4 json schemas based with zod (#279) * chore: generate v4 json schemas based with zod * fix: small typo * chore: sign document should be clear on what errors it could throw, export of v4 verify shd be more explicit (#280) * chore: sign document should be clear on what errors it could throw * fix: verify export naming shd be more explicit * fix: bump target platform, and remove baseUrl as it is not supported (#282) * fix: bump target platform, and remove baseUrl as it is not supported * refactor: lint * Feat:document builder (#283) * feat: document builder poc * test: happy flow tests * refactor: improve comments * chore: export builder * test: more tests * fix: added logic to prevent re-setting of values * fix: guard constructor and added more test cases to test guards * fix: revocation support (#285) * fix: added revocation methods, refactor: revamp state management in instance * fix: tests * feat: added revocation store revocation method * feat: implemented revocation store revocation builder method * test: update to check credentialStatus * fix: improve ethereum address validation * tests: added tests for revocation store revocation method * chore: update json schemas * chore: update descriptions * chore: setup husky and lintstaged * fix: clean up hashing utils from utils and fix brokenreferences * feat: remove the need to polyfill manually in browser envs * fix: test * fix: remove use of crypto completely * fix: import buffer based on docs * fix: rendering methods (#287) * fix: missing svg renderer props and no renderer method * fix: only add render method if its defined * chore: improve handle bar template description * fix: improved descriptions on documentLoader's interface * fix: improving naming and description * feat: computeDigestMultibase (#288) * fix: only generate json fixtures when fixtures.ts changes (#289) * fix: move attachments into credentialSubject (#290) * fix: renamed document (#291) * fix: obfuscate typing and guard exports (#292) * fix: obfuscate typing refused to accept document that could be multiple version * fix: improve consistency of utils guard * fix: simplify obfuscateVerifiableCredential typing * fix: obfuscation return type should still have a compliant attachment… (#293) * fix: obfuscation return type should still have a compliant attachment array * fix: improve typing more * fix: mark v3 functions as deprecated (#298) --------- Co-authored-by: Phan Shi Yu <[email protected]> Co-authored-by: Phan Shi Yu <[email protected]>
* feat: oa v4 (alpha) (#254) * 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 <[email protected]> Co-authored-by: Phan Shi Yu <[email protected]> * Chore: tidy v4 exports (#278) * refactor: shift context constants into 4.0 * refactor: bring context down to root of 4.0 * refactor: add custom error class, change algorithm to non enum * refactor: only leave the bare essentials of v4 in root index, fix tests * refactor: free up 4.0 from the mess of dependencies caused by importing of utils * fix: circular dependency caused by getData * feat: v4 utility guards * feat: export v4 * chore: generate v4 json schemas based with zod (#279) * chore: generate v4 json schemas based with zod * fix: small typo * chore: sign document should be clear on what errors it could throw, export of v4 verify shd be more explicit (#280) * chore: sign document should be clear on what errors it could throw * fix: verify export naming shd be more explicit * fix: bump target platform, and remove baseUrl as it is not supported (#282) * fix: bump target platform, and remove baseUrl as it is not supported * refactor: lint * Feat:document builder (#283) * feat: document builder poc * test: happy flow tests * refactor: improve comments * chore: export builder * test: more tests * fix: added logic to prevent re-setting of values * fix: guard constructor and added more test cases to test guards * fix: revocation support (#285) * fix: added revocation methods, refactor: revamp state management in instance * fix: tests * feat: added revocation store revocation method * feat: implemented revocation store revocation builder method * test: update to check credentialStatus * fix: improve ethereum address validation * tests: added tests for revocation store revocation method * chore: update json schemas * chore: update descriptions * chore: setup husky and lintstaged * fix: clean up hashing utils from utils and fix brokenreferences * feat: remove the need to polyfill manually in browser envs * fix: test * fix: remove use of crypto completely * fix: import buffer based on docs * fix: rendering methods (#287) * fix: missing svg renderer props and no renderer method * fix: only add render method if its defined * chore: improve handle bar template description * fix: improved descriptions on documentLoader's interface * fix: improving naming and description * feat: computeDigestMultibase (#288) * fix: only generate json fixtures when fixtures.ts changes (#289) * fix: move attachments into credentialSubject (#290) * fix: renamed document (#291) * fix: obfuscate typing and guard exports (#292) * fix: obfuscate typing refused to accept document that could be multiple version * fix: improve consistency of utils guard * fix: simplify obfuscateVerifiableCredential typing * fix: obfuscation return type should still have a compliant attachment… (#293) * fix: obfuscation return type should still have a compliant attachment array * fix: improve typing more * fix: mark v3 functions as deprecated (#298) --------- Co-authored-by: Phan Shi Yu <[email protected]> Co-authored-by: Phan Shi Yu <[email protected]>
What does this PR do?
alpha
branchCaveat