Skip to content

Commit

Permalink
chore: bump oa alpha version
Browse files Browse the repository at this point in the history
  • Loading branch information
phanshiyu committed May 14, 2024
1 parent fed1cbc commit 6549d75
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion example/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: "" },
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 10 additions & 9 deletions src/components/TheRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -73,7 +73,7 @@ function getVersionedDocument(
document,
wrappedDocument: document,
};
} else if (v4.isDocument(document)) {
} else if (v4.isOpenAttestationDocument(document)) {
return {
version: "4.0",
document,
Expand All @@ -94,9 +94,10 @@ type RenderMethod =
function getRenderMethod(versionedDocument: VersionedDocument): RenderMethod {
// we always prioritise svg renderer
const isSvgRenderer =
(versionedDocument.document as Partial<V2OpenAttestationDocumentWithSvg> | v4.Document)?.renderMethod?.find(
({ type }) => type === "SvgRenderingTemplate2023"
) !== undefined;
(versionedDocument.document as
| Partial<V2OpenAttestationDocumentWithSvg>
| v4.OpenAttestationDocument)?.renderMethod?.find(({ type }) => type === "SvgRenderingTemplate2023") !==
undefined;

if (isSvgRenderer) {
return {
Expand Down Expand Up @@ -282,10 +283,10 @@ const TheEmbeddedRenderer: React.FunctionComponent<TheEmbeddedRendererProps> = (
}
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;
Expand Down Expand Up @@ -378,7 +379,7 @@ const TheEmbeddedRenderer: React.FunctionComponent<TheEmbeddedRendererProps> = (
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;
Expand Down

0 comments on commit 6549d75

Please sign in to comment.