-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: enhance type definitions and improve DomListener component #8
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<D extends OpenAttestationDocument | SignedVerifiableCredential> { | ||
| document: D; | ||
| wrappedDocument?: WrappedDocument<OpenAttestationDocument> | SignedVerifiableCredential; | ||
| handleObfuscation: (field: string) => void; | ||
| handleObfuscation?: (field: string) => void; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Find all usages of handleObfuscation that may need optional chaining
# Search for handleObfuscation calls without optional chaining
rg -n "handleObfuscation\s*\(" --type ts --type tsx -g '!*.d.ts' | grep -v "handleObfuscation?."
# Also check for destructuring of handleObfuscation from props
rg -n "handleObfuscation\s*}" --type ts --type tsx -g '!*.d.ts'Repository: TrustVC/decentralized-renderer-react-components Length of output: 1842 🏁 Script executed: #!/bin/bash
# Search for handleObfuscation usages without null checks
rg "handleObfuscation" --type ts --type tsx -B 2 -A 2Repository: TrustVC/decentralized-renderer-react-components Length of output: 118 🌐 Web query:
💡 Result: The query refers to the handleObfuscation function in the context of the decentralized-renderer-react-components library (likely a fork or variant under TrustVC), specifically in a transcript.tsx file. This library is part of the OpenAttestation/TradeTrust ecosystem for rendering verifiable documents in iframes using React components. handleObfuscation is a mandatory prop provided to each configured Template React component (such as a Transcript template in transcript.tsx) when rendering a document. It is a function that triggers obfuscation (redaction/hiding) of sensitive fields in the document. Key details: - Signature/Usage: Called with a path string following lodash#get syntax, e.g., handleObfuscation('a[0].b.c'). - Behavior: Automatically sends a postMessage action { type: "OBFUSCATE", payload: path } to the iframe's decentralized renderer via components like FrameConnector or FramedDocumentRenderer. - Purpose: Allows templates to redact PII (e.g., names, IDs in transcripts) on demand, enhancing privacy in verifiable credential rendering. - Related components: ObfuscatableValue.js (976B in builds), used for rendering redactable values. No exact TrustVC repo found; closest are TradeTrust/decentralized-renderer-react-components (npm: <ObfuscatableValue value={get(document, 'sensitive.field')} path="sensitive.field" onObfuscate={handleObfuscation} /> ); FramedDocumentRenderer auto-calls OBFUSCATE when requested by templates.
Citations:
🏁 Script executed: #!/bin/bash
# Search for handleObfuscation usages in TypeScript/JavaScript files
rg "handleObfuscation" -B 2 -A 2 --type typescript --type javascriptRepository: TrustVC/decentralized-renderer-react-components Length of output: 125 🏁 Script executed: #!/bin/bash
# Find all files containing handleObfuscation
rg "handleObfuscation" -l --max-count=20Repository: TrustVC/decentralized-renderer-react-components Length of output: 314 🏁 Script executed: #!/bin/bash
# List TypeScript/TSX files in the repo
fd -e ts -e tsx | head -20Repository: TrustVC/decentralized-renderer-react-components Length of output: 1304 🏁 Script executed: #!/bin/bash
# Check the transcript.tsx file to see how handleObfuscation is used
cat example/decentralized-renderer/templates/govtechDemoCert/transcript.tsxRepository: TrustVC/decentralized-renderer-react-components Length of output: 7088 🏁 Script executed: #!/bin/bash
# Check current state of src/types.ts
cat src/types.tsRepository: TrustVC/decentralized-renderer-react-components Length of output: 1395 🏁 Script executed: #!/bin/bash
# Check all template files for handleObfuscation usage patterns
for file in $(find example/decentralized-renderer/templates -name "*.tsx" -type f); do
if rg -q "handleObfuscation" "$file"; then
echo "=== $file ==="
rg -n "handleObfuscation" "$file" -A 1
fi
doneRepository: TrustVC/decentralized-renderer-react-components Length of output: 831 Breaking change: Making Fix by updating the template to use optional chaining: 🤖 Prompt for AI Agents |
||
| errorType?: string; | ||
| } | ||
|
|
||
|
|
||
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.
findDOMNode is legacy/deprecated behavior in modern React (especially with Strict Mode / React 18).