From c361bcddc98e74a9dc7c8425a055b826e64d49d5 Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Tue, 5 May 2026 11:03:47 +0530 Subject: [PATCH 1/4] docs: add migration guide for decentralized renderer W3C VC support - Introduced a new guide to assist in migrating decentralized renderers to support W3C Verifiable Credentials alongside OpenAttestation documents. - Updated sidebars to include the new migration guide for easier navigation. --- ...decentralized-renderer-oa-w3c-migration.md | 99 +++++++++++++++++++ sidebars.json | 3 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 docs/migration-guide/decentralized-renderer-oa-w3c-migration.md diff --git a/docs/migration-guide/decentralized-renderer-oa-w3c-migration.md b/docs/migration-guide/decentralized-renderer-oa-w3c-migration.md new file mode 100644 index 0000000..f8750c9 --- /dev/null +++ b/docs/migration-guide/decentralized-renderer-oa-w3c-migration.md @@ -0,0 +1,99 @@ +--- +id: w3c-vc-support +title: Decentralized Renderer - W3C VC Support +sidebar_label: Decentralized Renderer Migration +--- + +This guide helps you migrate a **decentralized renderer** so it supports **W3C Verifiable Credentials (VC)** alongside existing **OpenAttestation (OA)** documents. + +## Why this matters + +- **Future-proof document support:** One codebase handles OA and W3C VC. +- **Simpler component code:** Shared types and a single payload path reduce branching. +- **Consistent validation:** Canonical detection and known `@context` URLs avoid drift. + +--- + +## 1) Update dependencies + +### 1.1 Core packages + +Use **published** packages from npm (avoid `file:` or other local path dependencies). + +Install the latest renderer components and TrustVC core: + +```bash +npm install @trustvc/decentralized-renderer-react-components@latest @trustvc/trustvc@latest +``` + +--- + +## 2) Type migration (OA + W3C) + +### 2.1 Import canonical types from TrustVC + +Define a single union type for documents your templates accept: + +```typescript +import { + OpenAttestationDocument, + SignedVerifiableCredential, +} from "@trustvc/trustvc"; + +export type SupportedDocument = OpenAttestationDocument | SignedVerifiableCredential; +``` + +### 2.2 Add a payload extraction helper + +Use **one helper** to read display data for both formats: + +- **OA:** payload lives at the **root** of the document. +- **W3C VC:** payload lives under **`credentialSubject`** (which may be an object or an array per the data model). + +```typescript +import { + vc, + SignedVerifiableCredential, + OpenAttestationDocument, +} from "@trustvc/trustvc"; + +type SupportedDocument = OpenAttestationDocument | SignedVerifiableCredential; +type GenericPayload = Record; + +export function getPayload(doc: SupportedDocument): GenericPayload { + if (vc.isSignedDocument(doc)) { + // W3C VC — credentialSubject may be object or array + const subject = (doc as SignedVerifiableCredential).credentialSubject; + return Array.isArray(subject) + ? Object.assign({}, ...subject) + : (subject as GenericPayload); + } + // OA — use root document as payload + return doc as unknown as GenericPayload; +} +``` + +## 3) W3C VC support (new documents) + +### 3.1 Replace custom W3C checks + +Use TrustVC’s canonical detection instead of ad hoc helpers: + +```typescript +import { vc } from "@trustvc/trustvc"; + +const isW3CVC = vc.isSignedDocument(document); +``` + +Remove legacy custom W3C utility modules after switching, so you do not maintain **two** detection paths. + +## 4) Verify both formats + +After migration: + +- Render at least **one OA** sample document end to end. +- Render at least **one W3C VC** sample document end to end. + +## Result + +Your decentralized renderer can serve **OA and W3C VC** from one codebase, with backward compatibility for existing OA documents and a clear path for new W3C VC issuers. diff --git a/sidebars.json b/sidebars.json index e3345cf..49574c5 100644 --- a/sidebars.json +++ b/sidebars.json @@ -198,7 +198,8 @@ "migration-guide/w3c-vc-v2", "migration-guide/igp-i", "migration-guide/migration-tr-v5", - "migration-guide/migration-tt-cli-v5" + "migration-guide/migration-tt-cli-v5", + "migration-guide/w3c-vc-support" ], "Community": ["community/contributing"], "Common Issues & Solutions": [ From 59c9c7fbac270dda6d3cbc52a99162332d4366ff Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Tue, 5 May 2026 11:11:47 +0530 Subject: [PATCH 2/4] fix: handle FileReader error correctly in address resolver documentation - Updated the error handling for the FileReader in the address resolver example to use the onerror event instead of checking for an error property, ensuring proper rejection of the promise. --- docs/how-tos/advanced/address-resolver.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/how-tos/advanced/address-resolver.md b/docs/how-tos/advanced/address-resolver.md index 63ca6cb..86e97b7 100644 --- a/docs/how-tos/advanced/address-resolver.md +++ b/docs/how-tos/advanced/address-resolver.md @@ -38,9 +38,7 @@ So to recap the steps on setting your own local addressbook: const readAsText = async (file: File): Promise => { return new Promise((resolve, reject) => { const reader = new FileReader(); - if (reader.error) { - reject(reader.error); - } + reader.onerror = () => reject(reader.error); reader.onload = () => resolve(reader.result as string); reader.readAsText(file); }); From 545dd2e1897b2fedd84f10e13e40f2ca2560549f Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Tue, 5 May 2026 11:24:29 +0530 Subject: [PATCH 3/4] chore: update deploy-prod workflow to trigger on main branch push --- .github/workflows/deploy-prod.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index c9f3937..8075595 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -1,6 +1,9 @@ name: Deploy Documentation Site (Production) on: + push: + branches: + - main workflow_dispatch: permissions: From e70bec1defef761c0b893c62f455087f592d4d41 Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Tue, 5 May 2026 12:06:25 +0530 Subject: [PATCH 4/4] chore: update deploy-prod workflow to trigger on main branch push --- .github/workflows/deploy-prod.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 8075595..c9f3937 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -1,9 +1,6 @@ name: Deploy Documentation Site (Production) on: - push: - branches: - - main workflow_dispatch: permissions: