Skip to content

Commit

Permalink
fix: revert earlier commit to strictly match oa v4 context url
Browse files Browse the repository at this point in the history
  • Loading branch information
HJunyuan committed Jul 26, 2024
1 parent f22ba1c commit 48905c2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 36 deletions.
12 changes: 2 additions & 10 deletions src/4.0/jsonSchemas/__generated__/v4-document.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 2 additions & 10 deletions src/4.0/jsonSchemas/__generated__/v4-wrapped-document.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/4.0/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ const URI_REGEX =
const Uri = z.string().regex(URI_REGEX, { message: "Invalid URI" });
const ETHEREUM_ADDRESS_REGEX = /^(0x)?[0-9a-fA-F]{40}$/;
const EthereumAddress = z.string().regex(ETHEREUM_ADDRESS_REGEX, { message: "Invalid Ethereum address" });
const OA_V4_CONTEXT_LIKE = z.union([
z.literal(ContextUrl.oa_vc_v4),
z.string().startsWith(ContextUrl.oa_vc_v4.split("/context.json")[0]),
]);

const _W3cVerifiableCredential = z.object({
"@context": z.union([
Expand Down Expand Up @@ -205,8 +201,9 @@ export const RevocationStoreRevocation = z.object({
export const V4OpenAttestationDocument = _W3cVerifiableCredential
.extend({
"@context": z
// Must be an array that starts with [baseContext, oaV4ContextLike, ...]
.tuple([z.literal(ContextUrl.w3c_vc_v2), OA_V4_CONTEXT_LIKE])

// Must be an array that starts with [baseContext, v4Context, ...]
.tuple([z.literal(ContextUrl.w3c_vc_v2), z.literal(ContextUrl.oa_vc_v4)])
// Remaining items can be string or object
.rest(z.union([z.string(), z.record(z.any())])),

Expand Down

0 comments on commit 48905c2

Please sign in to comment.