From 9e1a4f53bc14a2bbe250cc63b3af46419355fc06 Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Fri, 20 Mar 2026 12:14:57 +0530 Subject: [PATCH 1/3] refactor: enhance type definitions and improve DomListener component * Added Document type to include SignedVerifiableCredential and OpenAttestationDocument. * Made handleObfuscation optional in TemplateProps interface. * Replaced ReactDOM.findDOMNode with a ref in DomListener for better React practices. * Updated sandbox attribute in FrameConnector to include allow-presentation. --- src/components/common/DomListener.tsx | 8 ++++---- src/components/frame/FrameConnector.tsx | 2 +- src/types.ts | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/common/DomListener.tsx b/src/components/common/DomListener.tsx index 5e7a397..348d6d4 100644 --- a/src/components/common/DomListener.tsx +++ b/src/components/common/DomListener.tsx @@ -1,5 +1,4 @@ import React, { Component } from "react"; -import ReactDOM from "react-dom"; // no tests because js-dom doesn't support MutationObserver // https://github.com/jsdom/jsdom/issues/639 @@ -24,15 +23,16 @@ export class DomListener extends Component { public observer: MutationObserver; private readonly onResize: () => void; private readonly onDomChange: () => void; + private readonly rootRef: React.RefObject; constructor(props: DomListenerProps) { super(props); this.onResize = this.onUpdateHeight("resize").bind(this); this.onDomChange = this.onUpdateHeight("domChange").bind(this); this.observer = new MutationObserver(this.onDomChange); + this.rootRef = React.createRef(); } componentDidMount(): void { - // eslint-disable-next-line react/no-find-dom-node - const rootNode = ReactDOM.findDOMNode(this); + const rootNode = this.rootRef.current; if (rootNode) { this.observer.observe(rootNode, { attributes: true, childList: true, subtree: true, characterData: true }); // need an initial trigger, make it run on next tick :shrug: @@ -51,6 +51,6 @@ export class DomListener extends Component { } render(): React.ReactNode { - return
{this.props.children}
; + return
{this.props.children}
; } } diff --git a/src/components/frame/FrameConnector.tsx b/src/components/frame/FrameConnector.tsx index e10e36d..e99cd7e 100644 --- a/src/components/frame/FrameConnector.tsx +++ b/src/components/frame/FrameConnector.tsx @@ -59,7 +59,7 @@ export const FrameConnector: FunctionComponent = ({ onConnected, style, className = "", - sandbox = "allow-scripts allow-same-origin allow-modals allow-popups", + sandbox = "allow-scripts allow-same-origin allow-modals allow-popups allow-presentation", useFallbackRenderer = false, }) => { // this is used to store internally the latest templates shared in order to automatically transform diff --git a/src/types.ts b/src/types.ts index 5ab82fd..983d6a1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,9 @@ import { ComponentType } from "react"; import { v2, WrappedDocument, OpenAttestationDocument, v3, SignedVerifiableCredential } from "@trustvc/trustvc"; +export type Document = SignedVerifiableCredential | OpenAttestationDocument; +export type { OpenAttestationDocument, SignedVerifiableCredential } from '@trustvc/trustvc'; + export type Attachment = v2.Attachment | v3.Attachment; export interface Renderer { attachment: Attachment; @@ -9,7 +12,7 @@ export interface Renderer { export interface TemplateProps { document: D; wrappedDocument?: WrappedDocument | SignedVerifiableCredential; - handleObfuscation: (field: string) => void; + handleObfuscation?: (field: string) => void; errorType?: string; } From 74277144a76f1c5fc169ab08f5ff8a9a672b57eb Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Tue, 24 Mar 2026 22:19:13 +0530 Subject: [PATCH 2/3] Update src/types.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 983d6a1..66508cc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,7 +2,7 @@ import { ComponentType } from "react"; import { v2, WrappedDocument, OpenAttestationDocument, v3, SignedVerifiableCredential } from "@trustvc/trustvc"; export type Document = SignedVerifiableCredential | OpenAttestationDocument; -export type { OpenAttestationDocument, SignedVerifiableCredential } from '@trustvc/trustvc'; +export type { OpenAttestationDocument, SignedVerifiableCredential } from "@trustvc/trustvc"; export type Attachment = v2.Attachment | v3.Attachment; export interface Renderer { From 500f74b9d938a373edeb59cead6e6b190b20a548 Mon Sep 17 00:00:00 2001 From: manishdex25 Date: Tue, 24 Mar 2026 22:28:20 +0530 Subject: [PATCH 3/3] fix: update sandbox attribute in FrameConnector component * Removed 'allow-presentation' from the sandbox attribute for improved security. --- src/components/frame/FrameConnector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/frame/FrameConnector.tsx b/src/components/frame/FrameConnector.tsx index e99cd7e..e10e36d 100644 --- a/src/components/frame/FrameConnector.tsx +++ b/src/components/frame/FrameConnector.tsx @@ -59,7 +59,7 @@ export const FrameConnector: FunctionComponent = ({ onConnected, style, className = "", - sandbox = "allow-scripts allow-same-origin allow-modals allow-popups allow-presentation", + sandbox = "allow-scripts allow-same-origin allow-modals allow-popups", useFallbackRenderer = false, }) => { // this is used to store internally the latest templates shared in order to automatically transform