Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: lint
Browse files Browse the repository at this point in the history
yanlow committed Sep 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 272e149 commit fb1a8eb
Showing 8 changed files with 26 additions and 32 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -84,7 +84,8 @@
}
},
"prettier": {
"printWidth": 120
"printWidth": 120,
"trailingComma": "es5"
},
"snyk": true
}
35 changes: 14 additions & 21 deletions scripts/generate.v3.ts
Original file line number Diff line number Diff line change
@@ -135,9 +135,8 @@ const generateDnsDid = async () => {
},
},
};
const wrappedInvalidDnsDidDocument = await __unsafe__use__it__at__your__own__risks__wrapDocument(
validSignatureWithoutDnsTxt
);
const wrappedInvalidDnsDidDocument =
await __unsafe__use__it__at__your__own__risks__wrapDocument(validSignatureWithoutDnsTxt);
const signatureForInvalidDocument = await signMerkleRoot(`0x${wrappedInvalidDnsDidDocument.proof.merkleRoot}`);
const signedInvalidDnsDidDocument: v3.SignedWrappedDocument = {
...wrappedInvalidDnsDidDocument,
@@ -176,9 +175,8 @@ const generateDid = async () => {
},
},
};
const wrappedInvalidDnsDidDocument = await __unsafe__use__it__at__your__own__risks__wrapDocument(
validSignatureWithoutDnsTxt
);
const wrappedInvalidDnsDidDocument =
await __unsafe__use__it__at__your__own__risks__wrapDocument(validSignatureWithoutDnsTxt);
const signatureForInvalidDocument = await signMerkleRoot(`0x${wrappedInvalidDnsDidDocument.proof.merkleRoot}`);
const signedInvalidDnsDidDocument: v3.SignedWrappedDocument = {
...wrappedInvalidDnsDidDocument,
@@ -194,23 +192,20 @@ const generateDid = async () => {
const generateDocumentStore = async () => {
info("Generating Document Store files");
writeFileSync("./test/fixtures/v3/documentStore.json", JSON.stringify(baseDocumentStoreDocument, null, 2));
const wrappedBaseDocumentStoreDocument = await __unsafe__use__it__at__your__own__risks__wrapDocument(
baseDocumentStoreDocument
);
const wrappedBaseDocumentStoreDocument =
await __unsafe__use__it__at__your__own__risks__wrapDocument(baseDocumentStoreDocument);
writeFileSync(
"./test/fixtures/v3/documentStore-wrapped.json",
JSON.stringify(wrappedBaseDocumentStoreDocument, null, 2)
);
const issuedBaseDocumentStoreDocument = await __unsafe__use__it__at__your__own__risks__wrapDocument(
baseDocumentStoreDocument
);
const issuedBaseDocumentStoreDocument =
await __unsafe__use__it__at__your__own__risks__wrapDocument(baseDocumentStoreDocument);
writeFileSync(
"./test/fixtures/v3/documentStore-issued.json",
JSON.stringify(issuedBaseDocumentStoreDocument, null, 2)
);
const revokedBaseDocumentStoreDocument = await __unsafe__use__it__at__your__own__risks__wrapDocument(
baseDocumentStoreDocument
);
const revokedBaseDocumentStoreDocument =
await __unsafe__use__it__at__your__own__risks__wrapDocument(baseDocumentStoreDocument);
writeFileSync(
"./test/fixtures/v3/documentStore-revoked.json",
JSON.stringify(revokedBaseDocumentStoreDocument, null, 2)
@@ -246,16 +241,14 @@ const generateDocumentStore = async () => {
const generateTokenRegistry = async () => {
info("Generating Token Registry files");
writeFileSync("./test/fixtures/v3/tokenRegistry.json", JSON.stringify(baseTokenRegistryDocument, null, 2));
const wrappedBaseTokenRegistryDocument = await __unsafe__use__it__at__your__own__risks__wrapDocument(
baseTokenRegistryDocument
);
const wrappedBaseTokenRegistryDocument =
await __unsafe__use__it__at__your__own__risks__wrapDocument(baseTokenRegistryDocument);
writeFileSync(
"./test/fixtures/v3/tokenRegistry-wrapped.json",
JSON.stringify(wrappedBaseTokenRegistryDocument, null, 2)
);
const issuedBaseTokenRegistryDocument = await __unsafe__use__it__at__your__own__risks__wrapDocument(
baseTokenRegistryDocument
);
const issuedBaseTokenRegistryDocument =
await __unsafe__use__it__at__your__own__risks__wrapDocument(baseTokenRegistryDocument);
writeFileSync(
"./test/fixtures/v3/tokenRegistry-issued.json",
JSON.stringify(issuedBaseTokenRegistryDocument, null, 2)
4 changes: 2 additions & 2 deletions src/common/utils.test.ts
Original file line number Diff line number Diff line change
@@ -346,14 +346,14 @@ describe("generateProvider", () => {
const options = { apiKey: "abc123" } as ProviderDetails;
expect(() => {
generateProvider(options);
}).toThrowError(
}).toThrow(
"We could not link the apiKey provided to a provider, please state the provider to use in the parameter."
);
});

it("should throw an error when if process.env is using the wrong value for PROVIDER", () => {
process.env.PROVIDER_ENDPOINT_TYPE = "ABC";
expect(() => generateProvider()).toThrowError(
expect(() => generateProvider()).toThrow(
"The provider provided is not on the list of providers. Please use one of the following: infura, alchemy or jsonrpc."
);
});
4 changes: 2 additions & 2 deletions src/getIdentifier.test.ts
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ const malformedVerificationFragment2: ValidVerificationFragment<undefined> = {

describe("getIdentifier", () => {
it("should throw an error when no fragments are provided", () => {
expect(() => getIdentifier([])).toThrowError("Please provide at least one verification fragment");
expect(() => getIdentifier([])).toThrow("Please provide at least one verification fragment");
});
it("should return an unknown identity proof, when fragment.name is out of specification", () => {
expect(getIdentifier([verificationFragment1, malformedVerificationFragment1])).toStrictEqual({
@@ -97,7 +97,7 @@ describe("getIdentifier", () => {
});
});
it("should throw an error when fragment.data cannot be handled", () => {
expect(() => getIdentifier([verificationFragment1, malformedVerificationFragment2])).toThrowError(
expect(() => getIdentifier([verificationFragment1, malformedVerificationFragment2])).toThrow(
"No data property found in fragment, malformed fragment"
);
});
4 changes: 2 additions & 2 deletions src/validator.test.ts
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@ import { VerificationFragment } from "./types/core";

describe("isValid", () => {
it("should throw an error when no fragments are provided", () => {
expect(() => isValid([])).toThrowError("Please provide at least one verification fragment to check");
expect(() => isValid([])).toThrow("Please provide at least one verification fragment to check");
});
it("should throw an error when empty types are provided", () => {
const verificationFragment: VerificationFragment = {
status: "VALID",
name: "any",
type: "DOCUMENT_STATUS",
};
expect(() => isValid([verificationFragment], [])).toThrowError("Please provide at least one type to check");
expect(() => isValid([verificationFragment], [])).toThrow("Please provide at least one type to check");
});

describe("with one provided type", () => {
Original file line number Diff line number Diff line change
@@ -311,8 +311,8 @@ const verifyV3 = async (
const reason = InvalidDidSignedIssuanceStatus.guard(verificationResult)
? verificationResult.reason
: InvalidRevocationStatus.guard(revocationStatus)
? revocationStatus.reason
: undefined;
? revocationStatus.reason
: undefined;
if (!reason) {
throw new CodedError(
"Unable to retrieve the reason of the failure",
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ const isMissingTokenRegistry = (error: any) => {
);
};
const decodeError = (error: any) => {
const reason = error.reason && Array.isArray(error.reason) ? error.reason[0] : error.reason ?? "";
const reason = error.reason && Array.isArray(error.reason) ? error.reason[0] : (error.reason ?? "");
switch (true) {
case isNonExistentToken(error):
return `Document has not been issued under token registry`;
2 changes: 1 addition & 1 deletion src/verifiers/documentStatus/utils.ts
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ export const getIntermediateHashes = (targetHash: Hash, proofs: Hash[] = []) =>
* In case where we cannot tell, we throw an error
* */
export const decodeError = (error: any) => {
const reason = error.reason && Array.isArray(error.reason) ? error.reason[0] : error.reason ?? "";
const reason = error.reason && Array.isArray(error.reason) ? error.reason[0] : (error.reason ?? "");
switch (true) {
case !error.reason &&
(error.method?.toLowerCase() === "isRevoked(bytes32)".toLowerCase() ||

0 comments on commit fb1a8eb

Please sign in to comment.