From 6549d754072f84e102242158547fb603e7149e37 Mon Sep 17 00:00:00 2001 From: Phan Shi Yu Date: Tue, 14 May 2024 13:00:56 +0800 Subject: [PATCH] chore: bump oa alpha version --- example/application/app.tsx | 2 +- package-lock.json | 14 +++++++------- package.json | 2 +- src/components/TheRenderer.tsx | 19 ++++++++++--------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/example/application/app.tsx b/example/application/app.tsx index adfa5d5..644796d 100644 --- a/example/application/app.tsx +++ b/example/application/app.tsx @@ -165,7 +165,7 @@ export const App: React.FunctionComponent = (): React.ReactElement => { name: "Yourself", }, }, - } as v4.Document, + } as v4.OpenAttestationDocument, frameSource: "", }, { name: "SVG Embedded Demo (V2)", document: svgEmbeddedDemoV2, frameSource: "" }, diff --git a/package-lock.json b/package-lock.json index bacc364..e3c446b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/react-fontawesome": "^0.1.14", - "@govtechsg/open-attestation": "^6.10.0-alpha.8", + "@govtechsg/open-attestation": "^6.10.0-alpha.12", "bs58": "^5.0.0", "crypto-browserify": "^3.12.0", "debug": "^4.3.1", @@ -3812,9 +3812,9 @@ } }, "node_modules/@govtechsg/open-attestation": { - "version": "6.10.0-alpha.8", - "resolved": "https://registry.npmjs.org/@govtechsg/open-attestation/-/open-attestation-6.10.0-alpha.8.tgz", - "integrity": "sha512-M/xQyW3x/LAThgUX4rcGlRxVmP1+Fq26lSiClisYXYK0Z8NjWbU9vlRlGXgkiGd5chweH6nO6iqdkMUKLIEvWw==", + "version": "6.10.0-alpha.12", + "resolved": "https://registry.npmjs.org/@govtechsg/open-attestation/-/open-attestation-6.10.0-alpha.12.tgz", + "integrity": "sha512-Nd8ex27KVF1XDB+yFKZJkhnUwZk9Szbecyxd5546H8k9hZiDYYaOMqE3D5/SOQ6faC2JzNrIYgp8MknCFZNHUw==", "hasInstallScript": true, "dependencies": { "@aws-crypto/sha256-universal": "^5.2.0", @@ -39582,9 +39582,9 @@ } }, "@govtechsg/open-attestation": { - "version": "6.10.0-alpha.8", - "resolved": "https://registry.npmjs.org/@govtechsg/open-attestation/-/open-attestation-6.10.0-alpha.8.tgz", - "integrity": "sha512-M/xQyW3x/LAThgUX4rcGlRxVmP1+Fq26lSiClisYXYK0Z8NjWbU9vlRlGXgkiGd5chweH6nO6iqdkMUKLIEvWw==", + "version": "6.10.0-alpha.12", + "resolved": "https://registry.npmjs.org/@govtechsg/open-attestation/-/open-attestation-6.10.0-alpha.12.tgz", + "integrity": "sha512-Nd8ex27KVF1XDB+yFKZJkhnUwZk9Szbecyxd5546H8k9hZiDYYaOMqE3D5/SOQ6faC2JzNrIYgp8MknCFZNHUw==", "requires": { "@aws-crypto/sha256-universal": "^5.2.0", "@govtechsg/jsonld": "^0.1.0", diff --git a/package.json b/package.json index b75e284..94aa926 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/react-fontawesome": "^0.1.14", - "@govtechsg/open-attestation": "^6.10.0-alpha.8", + "@govtechsg/open-attestation": "^6.10.0-alpha.12", "bs58": "^5.0.0", "crypto-browserify": "^3.12.0", "debug": "^4.3.1", diff --git a/src/components/TheRenderer.tsx b/src/components/TheRenderer.tsx index f61ed13..4658965 100644 --- a/src/components/TheRenderer.tsx +++ b/src/components/TheRenderer.tsx @@ -50,11 +50,11 @@ type VersionedDocument = } | { version: "4.0"; - document: v4.Document; + document: v4.OpenAttestationDocument; wrappedDocument?: v4.WrappedDocument; }; function getVersionedDocument( - document: v2.OpenAttestationDocument | v2.WrappedDocument | v4.Document + document: v2.OpenAttestationDocument | v2.WrappedDocument | v4.OpenAttestationDocument ): VersionedDocument | { version: null } { if (utils.isWrappedV2Document(document)) { return { @@ -73,7 +73,7 @@ function getVersionedDocument( document, wrappedDocument: document, }; - } else if (v4.isDocument(document)) { + } else if (v4.isOpenAttestationDocument(document)) { return { version: "4.0", document, @@ -94,9 +94,10 @@ type RenderMethod = function getRenderMethod(versionedDocument: VersionedDocument): RenderMethod { // we always prioritise svg renderer const isSvgRenderer = - (versionedDocument.document as Partial | v4.Document)?.renderMethod?.find( - ({ type }) => type === "SvgRenderingTemplate2023" - ) !== undefined; + (versionedDocument.document as + | Partial + | v4.OpenAttestationDocument)?.renderMethod?.find(({ type }) => type === "SvgRenderingTemplate2023") !== + undefined; if (isSvgRenderer) { return { @@ -282,10 +283,10 @@ const TheEmbeddedRenderer: React.FunctionComponent = ( } if (isActionOf(obfuscateField, action)) { let isObfuscated = false; - if (obfuscatedDocumentRef.current) { + if (obfuscatedDocumentRef.current.wrappedDocument) { if (obfuscatedDocumentRef.current.version === "2.0") { + const obfuscated = obfuscate(obfuscatedDocumentRef.current.wrappedDocument, action.payload); if (obfuscatedDocumentRef.current.wrappedDocument) { - const obfuscated = obfuscate(obfuscatedDocumentRef.current.wrappedDocument, action.payload); obfuscatedDocumentRef.current.document = getData(obfuscated); obfuscatedDocumentRef.current.wrappedDocument = obfuscated; isObfuscated = true; @@ -378,7 +379,7 @@ const TheEmbeddedRenderer: React.FunctionComponent = ( type TheRendererProps = { className?: string; style?: React.CSSProperties; - document: v2.OpenAttestationDocument | v2.WrappedDocument | v4.Document | v4.WrappedDocument; + document: v2.OpenAttestationDocument | v2.WrappedDocument | v4.OpenAttestationDocument; loadingComponent?: React.ReactNode; onConnected: (results: ConnectedResults) => void; onError?: (error: RendererError) => void;