From b85527391fd2072c427dc34a69ad026b60a70be0 Mon Sep 17 00:00:00 2001 From: nklomp Date: Thu, 16 Dec 2021 15:26:50 +0100 Subject: [PATCH] fix: move to ES6 import for cross-fetch --- packages/vc-api-issuer/src/agent/VcApiIssuer.ts | 4 ++-- packages/vc-api-verifier/src/agent/VcApiVerifier.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/vc-api-issuer/src/agent/VcApiIssuer.ts b/packages/vc-api-issuer/src/agent/VcApiIssuer.ts index a9d953900..cb267c360 100644 --- a/packages/vc-api-issuer/src/agent/VcApiIssuer.ts +++ b/packages/vc-api-issuer/src/agent/VcApiIssuer.ts @@ -4,7 +4,7 @@ import { schema } from '../index' import { events, IIssueCredentialArgs, IRequiredContext, IVcApiIssuer, IVcApiIssuerArgs } from '../types/IVcApiIssuer' import { VerifiableCredentialSP } from '@sphereon/ssi-sdk-core' -const fetch = require('cross-fetch') +import { fetch } from 'cross-fetch' /** * {@inheritDoc IVcApiIssuer} @@ -32,7 +32,7 @@ export class VcApiIssuer implements IAgentPlugin { Authorization: `bearer ${this.authorizationToken}`, }, body: JSON.stringify({ credential: args.credential }), - }).then(async (response: { status: number; text: () => string | PromiseLike | undefined; json: () => string }) => { + }).then(async (response) => { if (response.status >= 400) { throw new Error(await response.text()) } else { diff --git a/packages/vc-api-verifier/src/agent/VcApiVerifier.ts b/packages/vc-api-verifier/src/agent/VcApiVerifier.ts index 630598c75..0eb4af56d 100644 --- a/packages/vc-api-verifier/src/agent/VcApiVerifier.ts +++ b/packages/vc-api-verifier/src/agent/VcApiVerifier.ts @@ -3,7 +3,7 @@ import { IAgentPlugin } from '@veramo/core' import { schema } from '../index' import { events, IRequiredContext, IVcApiVerifier, IVcApiVerifierArgs, IVerifyCredentialArgs, IVerifyCredentialResult } from '../types/IVcApiVerifier' -const fetch = require('cross-fetch') +import { fetch } from 'cross-fetch' /** * {@inheritDoc IVcApiVerifier} @@ -29,14 +29,14 @@ export class VcApiVerifier implements IAgentPlugin { }, body: JSON.stringify({ verifiableCredential: args.credential }), }) - .then(async (response: { status: number; text: () => string | PromiseLike | undefined; json: () => string }) => { + .then(async (response) => { if (response.status >= 400) { throw new Error(await response.text()) } else { return response.json() } }) - .then(async (verificationResult: string) => { + .then(async (verificationResult) => { await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult) return verificationResult })