Skip to content

Commit

Permalink
fixing a few NPEs
Browse files Browse the repository at this point in the history
  • Loading branch information
Echsecutor committed Nov 14, 2024
1 parent ff80a70 commit ee85dca
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/src/routes/verify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class VerifyRoutes {

return res
.status(StatusCodes.OK)
.json(await GS1Verifier.verify(req.body, challenge, domain));
.json(await GS1Verifier.verify(req?.body, challenge, domain));
} catch (error) {
console.error(error);
return res
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/documentLoader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const documentLoader: (url: string) => Promise<any> =
}

if (
!document.type ||
!document?.type ||
!Array.isArray(document.type) ||
!uncachedStatusListCredentialTypes.some((t: string) =>
document.type.includes(t)
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function fetch_jsonld(url: string): Promise<any> {
// search for json-ld link if no json-ld is returned
const link = parseLink(response.headers.get('Link'));

if (link && link.alternate && link.alternate.rel == 'alternate' && link.alternate.type == 'application/ld+json') {
if (link?.alternate?.rel == 'alternate' && link?.alternate?.type == 'application/ld+json') {

const linkResponse = await fetch(url + link.alternate.url, { method: 'GET', headers: HEADERS });

Expand Down
4 changes: 2 additions & 2 deletions api/src/services/verifier/gs1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ export class GS1Verifier {
domain?: string
): Promise<gs1RulesResult | gs1RulesResultContainer> {
let result;
if (verifiable.type.includes("VerifiableCredential")) {
if (verifiable?.type.includes?.("VerifiableCredential")) {
result = await checkGS1Credential(
verifiable,
getVerifierFunction(challenge, domain)
);
}

if (verifiable.type.includes("VerifiablePresentation")) {
if (verifiable?.type.includes?.("VerifiablePresentation")) {
const presentation = verifiable as VerifiablePresentation;

result = await verifyGS1Credentials(
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/verifier/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
} = jsigs;

function getSuite(proof: Proof): unknown[] {
switch (proof.type) {
switch (proof?.type) {
case "Ed25519Signature2018":
return new Ed25519Signature2018();

Expand All @@ -36,7 +36,7 @@ function getSuite(proof: Proof): unknown[] {
});

default:
throw new Error(`${proof.type} not implemented`);
throw new Error(`${proof?.type} not implemented`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

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

0 comments on commit ee85dca

Please sign in to comment.