Skip to content

Commit

Permalink
fix: upgrade oa-verify to v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulis committed Feb 5, 2020
1 parent 3c6ef58 commit aff5d98
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 55 deletions.
44 changes: 31 additions & 13 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
]
},
"dependencies": {
"@govtechsg/oa-verify": "3.0.3",
"@govtechsg/open-attestation": "3.1.0",
"@govtechsg/oa-verify": "3.1.1",
"@govtechsg/open-attestation": "3.1.1",
"debug": "4.1.1",
"node-fetch": "2.6.0"
},
Expand Down
21 changes: 18 additions & 3 deletions src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ type OpencertsRegistryVerificationFragmentData = Partial<RegistryEntry> & {
const type = "ISSUER_IDENTITY";
const name = "OpencertsRegistryVerifier";

// NEVER EVER REPLACE OR CHANGE A VALUE :)
// code for errors and invalid fragment
export enum OpencertsRegistryCode {
INVALID_IDENTITY = 0,
SKIPPED = 1
}

const storeToFragment = (
registry: Registry,
store: string
Expand All @@ -58,7 +65,11 @@ const storeToFragment = (
value: store,
status: "INVALID" as "INVALID"
},
message: `Document store ${store} not found in the registry`
reason: {
code: OpencertsRegistryCode.INVALID_IDENTITY,
codeString: OpencertsRegistryCode[OpencertsRegistryCode.INVALID_IDENTITY],
message: `Document store ${store} not found in the registry`
}
};
};

Expand All @@ -80,7 +91,11 @@ export const registryVerifier: Verifier<
status: "SKIPPED",
type,
name,
message: `Document issuers doesn't have "documentStore" or "certificateStore" property or ${v3.Method.DocumentStore} method`
reason: {
code: OpencertsRegistryCode.SKIPPED,
codeString: OpencertsRegistryCode[OpencertsRegistryCode.SKIPPED],
message: `Document issuers doesn't have "documentStore" or "certificateStore" property or ${v3.Method.DocumentStore} method`
}
});
},
verify: async document => {
Expand All @@ -104,7 +119,7 @@ export const registryVerifier: Verifier<
message:
status === "INVALID"
? `Document store ${
issuerFragments.find(fragment => fragment.status === "VALID")?.data
issuerFragments.find(fragment => fragment.status === "INVALID")?.data
} not found in the registry`
: undefined
};
Expand Down
17 changes: 13 additions & 4 deletions test/verify.v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ describe("verify", () => {
type: "DOCUMENT_STATUS"
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
type: "DOCUMENT_STATUS",
reason: {
code: 4,
codeString: "SKIPPED",
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method'
}
},
{
data: {
Expand All @@ -63,10 +67,15 @@ describe("verify", () => {
type: "DOCUMENT_STATUS"
},
{
message: `Document issuers doesn't have "documentStore" / "tokenRegistry" property or doesn't use DNS-TXT type`,
status: "SKIPPED",
name: "OpenAttestationDnsTxt",
type: "ISSUER_IDENTITY"
type: "ISSUER_IDENTITY",
reason: {
code: 2,
codeString: "SKIPPED",
message:
'Document issuers doesn\'t have "documentStore" / "tokenRegistry" property or doesn\'t use DNS-TXT type'
}
},
{
data: [
Expand Down
88 changes: 55 additions & 33 deletions test/verify.v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@ describe("verify", () => {
},
{
data: {
details: [
{
address: "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
issued: true
}
],
details: {
address: "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
issued: true
},
issuedOnAll: true
},
status: "VALID",
name: "OpenAttestationEthereumDocumentStoreIssued",
type: "DOCUMENT_STATUS"
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
reason: {
code: 4,
codeString: "SKIPPED",
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method'
},
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
{
data: {
details: [
{
address: "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
revoked: false
}
],
details: {
address: "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
revoked: false
},
revokedOnAny: false
},
status: "VALID",
Expand All @@ -60,7 +60,11 @@ describe("verify", () => {
status: "INVALID",
value: "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3"
},
message: "Certificate issuer identity is invalid",
reason: {
code: 1,
codeString: "INVALID_IDENTITY",
message: "Certificate issuer identity is invalid"
},
name: "OpenAttestationDnsTxt",
status: "INVALID",
type: "ISSUER_IDENTITY"
Expand All @@ -84,46 +88,64 @@ describe("verify", () => {
{
data: false,
status: "INVALID",
message: "Certificate has been tampered with",
reason: {
code: 0,
codeString: "DOCUMENT_TAMPERED",
message: "Certificate has been tampered with"
},
name: "OpenAttestationHash",
type: "DOCUMENT_INTEGRITY"
},
{
data: {
details: [
{
issued: false,
address: "0x532C9Ff853CA54370D7492cD84040F9f8099f11B",
error:
'invalid input argument (arg="document", reason="invalid bytes32 value", value="0xabcd", version=4.0.42)'
details: {
issued: false,
address: "0x532C9Ff853CA54370D7492cD84040F9f8099f11B",
reason: {
code: 3,
codeString: "ETHERS_UNHANDLED_ERROR",
message: "Error with smart contract 0x532C9Ff853CA54370D7492cD84040F9f8099f11B: invalid bytes32 value"
}
],
},
issuedOnAll: false
},
message: "Certificate has not been issued",
reason: {
code: 3,
codeString: "ETHERS_UNHANDLED_ERROR",
message: "Error with smart contract 0x532C9Ff853CA54370D7492cD84040F9f8099f11B: invalid bytes32 value"
},
status: "INVALID",
name: "OpenAttestationEthereumDocumentStoreIssued",
type: "DOCUMENT_STATUS"
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
reason: {
code: 4,
codeString: "SKIPPED",
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method'
},
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
{
data: {
details: [
{
address: "0x532C9Ff853CA54370D7492cD84040F9f8099f11B",
error:
'invalid input argument (arg="document", reason="invalid bytes32 value", value="0xabcd", version=4.0.42)',
revoked: true
}
],
details: {
address: "0x532C9Ff853CA54370D7492cD84040F9f8099f11B",
reason: {
code: 3,
codeString: "ETHERS_UNHANDLED_ERROR",
message: "Error with smart contract 0x532C9Ff853CA54370D7492cD84040F9f8099f11B: invalid bytes32 value"
},
revoked: true
},
revokedOnAny: true
},
message: "Certificate has been revoked",
reason: {
code: 3,
codeString: "ETHERS_UNHANDLED_ERROR",
message: "Error with smart contract 0x532C9Ff853CA54370D7492cD84040F9f8099f11B: invalid bytes32 value"
},
status: "INVALID",
name: "OpenAttestationEthereumDocumentStoreRevoked",
type: "DOCUMENT_STATUS"
Expand Down

0 comments on commit aff5d98

Please sign in to comment.