Skip to content

Commit

Permalink
fix: remove util (Open-Attestation#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
simboonlong authored Mar 25, 2021
1 parent bd88108 commit c8cf37d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 231 deletions.
198 changes: 0 additions & 198 deletions src/common/utils.test.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v2, v3, WrappedDocument, utils } from "@govtechsg/open-attestation";
import { providers } from "ethers";
import { VerificationBuilderOptions, VerificationBuilderOptionsWithNetwork } from "../types/core";
import { INFURA_API_KEY } from "../config";
Expand All @@ -10,35 +9,3 @@ export const getDefaultProvider = (options: VerificationBuilderOptionsWithNetwor
export const getProvider = (options: VerificationBuilderOptions): providers.Provider => {
return "provider" in options ? options.provider : getDefaultProvider(options);
};

export const isObfuscated = (
document: WrappedDocument<v3.OpenAttestationDocument> | WrappedDocument<v2.OpenAttestationDocument>
): boolean => {
if (utils.isWrappedV3Document(document)) {
return !!document.proof.privacy?.obfuscated?.length;
}

if (utils.isWrappedV2Document(document)) {
return !!document.privacy?.obfuscatedData?.length;
}

throw new Error(
"Unsupported document type: Can only check if there are obfuscated data from wrapped OpenAttestation v2 & v3 documents."
);
};

export const getObfuscatedData = (
document: WrappedDocument<v3.OpenAttestationDocument> | WrappedDocument<v2.OpenAttestationDocument>
): string[] => {
if (utils.isWrappedV3Document(document)) {
return document.proof.privacy?.obfuscated;
}

if (utils.isWrappedV2Document(document)) {
return document.privacy?.obfuscatedData || [];
}

throw new Error(
"Unsupported document type: Can only retrieve obfuscated data from wrapped OpenAttestation v2 & v3 documents."
);
};

0 comments on commit c8cf37d

Please sign in to comment.