Since our wrapper adds OA-specific properties, I feel that we should check if the OA v3 context is missing or not. In the original unwrapped document, the user can:
choose to add in the OA v3 context, then wrap will not add it in
choose not to add in the OA v3 context, then wrap will add it in
(This is also to ensure we can pass the W3C test inputs since the original inputs does not come with OA v3's context)
This is the logic:
If @context doesn't exist (i.e. undefined):
wrap will create the @context array with https://www.w3.org/2018/credentials/v1 as the first item
(Now this would mean that some @context validations check in validateW3C may be unreachable)
Next, if @context exists and is an array, and if OA v3 contexts is not in the original @context:
then we add it in for them
But I believe this is something to be discussed.
Also added a new testcase to improve test coverage in case @context is a string.
I agree on this, just have a look on w3c test suite and make sure there is no test that this code would fail. IIRC it should be ok (there is one test that expect a failure f the context is in second position)
wrap.ts
Since our wrapper adds OA-specific properties, I feel that we should check if the OA v3 context is missing or not. In the original unwrapped document, the user can:
wrap
will not add it inwrap
will add it in(This is also to ensure we can pass the W3C test inputs since the original inputs does not come with OA v3's context)
This is the logic:
But I believe this is something to be discussed.
Also added a new testcase to improve test coverage in case
@context
is a string.