Skip to content

Commit

Permalink
fix: mf rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulis committed Jul 4, 2020
1 parent 89d2639 commit 88ec82e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 19 deletions.
13 changes: 7 additions & 6 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 @@ -44,8 +44,8 @@
]
},
"dependencies": {
"@govtechsg/oa-verify": "3.3.0",
"@govtechsg/open-attestation": "3.1.1",
"@govtechsg/oa-verify": "3.4.0",
"@govtechsg/open-attestation": "3.9.0",
"debug": "4.1.1",
"node-fetch": "2.6.0"
},
Expand Down
9 changes: 4 additions & 5 deletions src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import {
Verifier,
VerificationFragment,
VerificationFragmentType,
VerificationManagerOptions,
isWrappedV3Document
VerificationManagerOptions
} from "@govtechsg/oa-verify";
import fetch from "node-fetch";
import { getData, v2, v3, WrappedDocument } from "@govtechsg/open-attestation";
import { getData, v2, v3, WrappedDocument, utils } from "@govtechsg/open-attestation";

export interface RegistryEntry {
name: string;
Expand Down Expand Up @@ -84,7 +83,7 @@ export const registryVerifier: Verifier<
OpencertsRegistryVerificationFragmentData | OpencertsRegistryVerificationFragmentData[]
> = {
test: document => {
if (isWrappedV3Document(document)) {
if (utils.isWrappedV3Document(document)) {
const documentData = getData(document);
return documentData.proof.method === v3.Method.DocumentStore;
}
Expand All @@ -106,7 +105,7 @@ export const registryVerifier: Verifier<
verify: async document => {
const registry: Registry = await fetch("https://opencerts.io/static/registry.json").then(res => res.json());

if (isWrappedV3Document(document)) {
if (utils.isWrappedV3Document(document)) {
const documentData = getData(document);
return storeToFragment(registry, documentData.proof.value);
}
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/v3/document.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { v3, WrappedDocument } from "@govtechsg/open-attestation";
import { SchemaId, v3, WrappedDocument } from "@govtechsg/open-attestation";

const issuerInRegistry = "0x532C9Ff853CA54370D7492cD84040F9f8099f11B";
const issuerNotInRegistry = "0x8FC57204C35FB9317D91285EF52D6B892EC08CD3";

export const documentWithDocumentStoreIssuerInRegistryAndValidDns: WrappedDocument<v3.OpenAttestationDocument> = {
version: "open-attestation/3.0",
version: SchemaId.v3,
data: {
reference: "23099a48-5d9f-463e-941f-28fffaabaec7:string:ABCXXXXX00",
name: "f7da877a-ba98-4317-9434-67b072bd620a:string:Certificate of whatever",
Expand Down Expand Up @@ -36,7 +36,7 @@ export const documentWithDocumentStoreIssuerInRegistryAndValidDns: WrappedDocume
}
};
export const documentWithDocumentStoreIssuerInRegistryAndInvalidDns: WrappedDocument<v3.OpenAttestationDocument> = {
version: "open-attestation/3.0",
version: SchemaId.v3,
data: {
reference: "23099a48-5d9f-463e-941f-28fffaabaec7:string:ABCXXXXX00",
name: "f7da877a-ba98-4317-9434-67b072bd620a:string:Certificate of whatever",
Expand Down Expand Up @@ -68,7 +68,7 @@ export const documentWithDocumentStoreIssuerInRegistryAndInvalidDns: WrappedDocu
}
};
export const documentWithDocumentStoreIssuerNotInRegistryAndValidDns: WrappedDocument<v3.OpenAttestationDocument> = {
version: "open-attestation/3.0",
version: SchemaId.v3,
data: {
reference: "23099a48-5d9f-463e-941f-28fffaabaec7:string:ABCXXXXX00",
name: "f7da877a-ba98-4317-9434-67b072bd620a:string:Certificate of whatever",
Expand Down Expand Up @@ -101,7 +101,7 @@ export const documentWithDocumentStoreIssuerNotInRegistryAndValidDns: WrappedDoc
};

export const documentWithDocumentStoreIssuerNotInRegistryAndInvalidDns: WrappedDocument<v3.OpenAttestationDocument> = {
version: "open-attestation/3.0",
version: SchemaId.v3,
data: {
reference: "23099a48-5d9f-463e-941f-28fffaabaec7:string:ABCXXXXX00",
name: "f7da877a-ba98-4317-9434-67b072bd620a:string:Certificate of whatever",
Expand Down Expand Up @@ -134,7 +134,7 @@ export const documentWithDocumentStoreIssuerNotInRegistryAndInvalidDns: WrappedD
};

export const documentRopstenValidWithDocumentStore: WrappedDocument<v3.OpenAttestationDocument> = {
version: "open-attestation/3.0",
version: SchemaId.v3,
data: {
reference: "8354acc7-74ab-4cab-be1c-1bf1e10a6920:string:ABCXXXXX00",
name: "1c1df86c-168e-4519-805b-f38698e5b00e:string:Certificate of whatever",
Expand Down
10 changes: 10 additions & 0 deletions test/verify.v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ describe("verify", () => {
name: "OpenAttestationHash",
type: "DOCUMENT_INTEGRITY"
},
{
name: "OpenAttestationSignedProof",
reason: {
code: 4,
codeString: "SKIPPED",
message: "Document does not have a proof block"
},
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
{
data: {
details: [
Expand Down
20 changes: 20 additions & 0 deletions test/verify.v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ describe("verify", () => {
name: "OpenAttestationHash",
type: "DOCUMENT_INTEGRITY"
},
{
name: "OpenAttestationSignedProof",
reason: {
code: 4,
codeString: "SKIPPED",
message: "Document does not have a proof block"
},
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
{
data: {
details: {
Expand Down Expand Up @@ -108,6 +118,16 @@ describe("verify", () => {
name: "OpenAttestationHash",
type: "DOCUMENT_INTEGRITY"
},
{
name: "OpenAttestationSignedProof",
reason: {
code: 4,
codeString: "SKIPPED",
message: "Document does not have a proof block"
},
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
{
data: {
details: {
Expand Down

0 comments on commit 88ec82e

Please sign in to comment.