Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade packages #30

Merged
merged 8 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Commit Lint Dependencies
run: npm install @commitlint/config-conventional
run: npm install --force @commitlint/config-conventional@v17
- uses: JulienKode/pull-request-name-linter-action@v0.5.0
3,603 changes: 1,420 additions & 2,183 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:type",
"build:cjs": "tsc --module commonjs --outDir dist/cjs --project ./tsconfig.prod.json",
"build:esm": "tsc --module es2015 --outDir dist/esm --project ./tsconfig.prod.json",
"build:esm": "tsc --module es2022 --outDir dist/esm --project ./tsconfig.prod.json",
"build:type": "tsc -d --emitDeclarationOnly --outDir dist/types",
"clean": "rm -rf dist/",
"commit": "git-cz",
Expand All @@ -25,10 +25,10 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@tradetrust-tt/dnsprove": "^2.15.0",
"@tradetrust-tt/dnsprove": "^2.16.0",
"@tradetrust-tt/document-store": "^4.1.0",
"@tradetrust-tt/token-registry": "^5.1.0",
"@tradetrust-tt/tradetrust": "^6.9.7",
"@tradetrust-tt/tradetrust": "^6.10.0",
"axios": "^1.7.2",
"debug": "^4.3.1",
"did-resolver": "^3.1.0",
Expand All @@ -42,9 +42,9 @@
"ethers": "^5.7.2"
},
"devDependencies": {
"@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.2.4",
"@commitlint/prompt": "^16.1.0",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@commitlint/prompt": "^19.3.1",
"@types/debug": "^4.1.5",
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.22.0",
Expand All @@ -58,10 +58,10 @@
"git-cz": "^4.9.0",
"jest": "^29.7.0",
"jest-watch-typeahead": "^2.2.2",
"msw": "^0.28.2",
"msw": "^2.4.5",
"prettier": "^2.2.1",
"semantic-release": "^19.0.2",
"snyk": "^1.931.0",
"snyk": "^1.1293.0",
"ts-jest": "^29.2.5",
"typescript": "^4.9.5"
},
Expand Down
15 changes: 10 additions & 5 deletions src/did/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DIDDocument, Resolver, VerificationMethod } from "did-resolver";
import { DIDDocument, Resolver, ResolverRegistry, VerificationMethod } from "did-resolver";
import { getResolver as ethrGetResolver } from "ethr-did-resolver";
import { getResolver as webGetResolver } from "web-did-resolver";
import NodeCache from "node-cache";
Expand Down Expand Up @@ -29,12 +29,17 @@ export const getProviderConfig = () => {

const didResolutionCache = new NodeCache({ stdTTL: 5 * 60 }); // 5 min

const defaultResolver = new Resolver({ ...ethrGetResolver(getProviderConfig()), ...webGetResolver() });
const defaultResolver = new Resolver({
...(ethrGetResolver(getProviderConfig()) as ResolverRegistry),
...(webGetResolver() as ResolverRegistry),
});

export const createResolver = ({ ethrResolverConfig }: { ethrResolverConfig?: EthrResolverConfig }): Resolver => {
return ethrResolverConfig
? new Resolver({ ...ethrGetResolver(ethrResolverConfig), ...webGetResolver() })
: defaultResolver;
const resolverRegistry: ResolverRegistry = {
...(ethrGetResolver(ethrResolverConfig ?? {}) as ResolverRegistry),
...(webGetResolver() as ResolverRegistry),
};
return ethrResolverConfig ? new Resolver(resolverRegistry) : defaultResolver;
};

export const resolve = async (didUrl: string, resolver?: Resolver): Promise<DIDDocument | undefined> => {
Expand Down
108 changes: 39 additions & 69 deletions src/verifiers/documentStatus/didSigned/didSignedDocumentStatus.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SignedWrappedDocument, v2, v3, WrappedDocument } from "@tradetrust-tt/tradetrust";
import { rest } from "msw";
import { http, HttpResponse } from "msw";
import { setupServer, SetupServerApi } from "msw/node";
import { documentDidCustomRevocation } from "../../../../test/fixtures/v2/documentDidCustomRevocation";
import { documentDidObfuscatedRevocation } from "../../../../test/fixtures/v2/documentDidObfuscatedRevocation";
Expand Down Expand Up @@ -468,28 +468,18 @@ describe("verify", () => {
whenPublicKeyResolvesSuccessfully();

const handlers = [
rest.get(
"https://ocsp.example.com/0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824",
(_, res, ctx) => {
return res(
ctx.json({
revoked: false,
documentHash: "0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824",
})
);
}
),
rest.get(
"https://ocsp.example.com/0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c",
(_, res, ctx) => {
return res(
ctx.json({
revoked: false,
documentHash: "0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c",
})
);
}
),
http.get("https://ocsp.example.com/0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824", () => {
return HttpResponse.json({
revoked: false,
documentHash: "0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824",
});
}),
http.get("https://ocsp.example.com/0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c", () => {
return HttpResponse.json({
revoked: false,
documentHash: "0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c",
});
}),
];

const server: SetupServerApi = setupServer(...handlers);
Expand Down Expand Up @@ -528,29 +518,19 @@ describe("verify", () => {
whenPublicKeyResolvesSuccessfully();

const handlers = [
rest.get(
"https://ocsp.example.com/0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824",
(_, res, ctx) => {
return res(
ctx.json({
revoked: true,
documentHash: "0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824",
reasonCode: 4,
})
);
}
),
rest.get(
"https://ocsp.example.com/0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c",
(_, res, ctx) => {
return res(
ctx.json({
revoked: false,
documentHash: "0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c",
})
);
}
),
http.get("https://ocsp.example.com/0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824", () => {
return HttpResponse.json({
revoked: true,
documentHash: "0x28b221f6287d8e4f8da09a835bcb750537cc8385e2535ff63591fdf0162be824",
reasonCode: 4,
});
}),
http.get("https://ocsp.example.com/0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c", () => {
return HttpResponse.json({
revoked: false,
documentHash: "0x56961854a82feafe9a56eb57acfe3b97f17eda5d497b622c9acc9f03c412618c",
});
}),
];

const server: SetupServerApi = setupServer(...handlers);
Expand Down Expand Up @@ -895,17 +875,12 @@ describe("verify", () => {
whenPublicKeyResolvesSuccessfully("0x1245e5B64D785b25057f7438F715f4aA5D965733");

const handlers = [
rest.get(
"https://ocsp.example.com/0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40",
(_, res, ctx) => {
return res(
ctx.json({
revoked: false,
documentHash: "0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40",
})
);
}
),
http.get("https://ocsp.example.com/0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40", () => {
return HttpResponse.json({
revoked: false,
documentHash: "0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40",
});
}),
];

const server: SetupServerApi = setupServer(...handlers);
Expand Down Expand Up @@ -940,18 +915,13 @@ describe("verify", () => {
whenPublicKeyResolvesSuccessfully("0x1245e5B64D785b25057f7438F715f4aA5D965733");

const handlers = [
rest.get(
"https://ocsp.example.com/0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40",
(_, res, ctx) => {
return res(
ctx.json({
revoked: true,
documentHash: "0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40",
reasonCode: 4,
})
);
}
),
http.get("https://ocsp.example.com/0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40", () => {
return HttpResponse.json({
revoked: true,
documentHash: "0x69e1a174ea67e1c3119639f713f8a7348bbda54fdce60903621398cc2fea4d40",
reasonCode: 4,
});
}),
];

const server: SetupServerApi = setupServer(...handlers);
Expand Down
4 changes: 2 additions & 2 deletions src/verifiers/documentStatus/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "../../types/error";
import { CodedError } from "../../common/error";
import { OcspResponderRevocationReason, RevocationStatus } from "./revocation.types";
import axios from "axios";
import { ValidOcspResponse, ValidOcspResponseRevoked } from "./didSigned/didSignedDocumentStatus.type";

export const getIntermediateHashes = (targetHash: Hash, proofs: Hash[] = []) => {
Expand Down Expand Up @@ -134,13 +133,14 @@ export const isRevokedByOcspResponder = async ({
const intermediateHashes = getIntermediateHashes(targetHash, proofs);

for (const hash of intermediateHashes) {
const { data } = await axios.get(`${location}/${hash}`).catch((e) => {
const res = await fetch(`${location}/${hash}`).catch((e) => {
throw new CodedError(
`Invalid or unexpected response from OCSP Responder - ${e}`,
OpenAttestationDidSignedDocumentStatusCode.OCSP_RESPONSE_INVALID,
"OCSP_RESPONSE_INVALID"
);
});
const data = await res.json();

if (ValidOcspResponse.guard(data)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("test", () => {
],
},
};
const toVerify = await openAttestationDnsTxtIdentityProof.test(documentWithoutIdentityProof, options);
const toVerify = await openAttestationDnsTxtIdentityProof.test(documentWithoutIdentityProof as any, options);
expect(toVerify).toBe(false);
});

Expand Down Expand Up @@ -116,7 +116,10 @@ describe("test", () => {
],
},
};
const toVerify = await openAttestationDnsTxtIdentityProof.test(documentWithMultipleIssuersWithoutDnsTxt, options);
const toVerify = await openAttestationDnsTxtIdentityProof.test(
documentWithMultipleIssuersWithoutDnsTxt as any,
options
);
expect(toVerify).toBe(false);
});
});
Expand Down Expand Up @@ -245,7 +248,7 @@ describe("verify", () => {
],
},
};
const fragment = await openAttestationDnsTxtIdentityProof.verify(document, options);
const fragment = await openAttestationDnsTxtIdentityProof.verify(document as any, options);
expect(fragment).toMatchInlineSnapshot(`
{
"data": [Error: Document does not match either v2 or v3 formats],
Expand Down Expand Up @@ -331,7 +334,7 @@ describe("verify", () => {
],
},
};
const fragment = await openAttestationDnsTxtIdentityProof.verify(document, options);
const fragment = await openAttestationDnsTxtIdentityProof.verify(document as any, options);
expect(fragment).toMatchInlineSnapshot(`
{
"data": [Error: Document does not match either v2 or v3 formats],
Expand Down
Loading
Loading