diff --git a/packages/qr-code-generator/__tests__/shared/fixtures.tsx b/packages/qr-code-generator/__tests__/shared/fixtures.tsx index 91beb7710..b6ed539b5 100644 --- a/packages/qr-code-generator/__tests__/shared/fixtures.tsx +++ b/packages/qr-code-generator/__tests__/shared/fixtures.tsx @@ -193,9 +193,7 @@ export const openid4vciCreateElementByValue: CreateElementArgs = { data: openid4vciDataValid, - onGenerate: (result: ValueResult) => { - console.log(result, null, 2) - }, + onGenerate: (result: ValueResult) => {}, } export const openid4vciCreateElementValid: CreateElementArgs = { @@ -203,6 +201,5 @@ export const openid4vciCreateElementValid: CreateElementArgs) => { render(
{result.data.object.credentialOfferUri}
) - console.log(result.value) }, } diff --git a/packages/siopv2-oid4vp-op-auth/__tests__/shared/didAuthSiopOpAuthenticatorAgentLogic.ts b/packages/siopv2-oid4vp-op-auth/__tests__/shared/didAuthSiopOpAuthenticatorAgentLogic.ts index e1f75e97a..ae4a970ca 100644 --- a/packages/siopv2-oid4vp-op-auth/__tests__/shared/didAuthSiopOpAuthenticatorAgentLogic.ts +++ b/packages/siopv2-oid4vp-op-auth/__tests__/shared/didAuthSiopOpAuthenticatorAgentLogic.ts @@ -41,6 +41,7 @@ type ConfiguredAgent = TAgent const didMethod = 'ethr' const did = 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a' +// @ts-ignore const identifier = { did, provider: '', @@ -75,7 +76,6 @@ const authKeys = [ }, ] -console.log(identifier) const sessionId = 'sessionId' const otherSessionId = 'other_sessionId' const redirectUrl = 'http://example/ext/get-auth-request-url' diff --git a/packages/siopv2-oid4vp-rp-auth/src/functions.ts b/packages/siopv2-oid4vp-rp-auth/src/functions.ts index c25858646..3a94fe975 100644 --- a/packages/siopv2-oid4vp-rp-auth/src/functions.ts +++ b/packages/siopv2-oid4vp-rp-auth/src/functions.ts @@ -68,7 +68,6 @@ export function getPresentationVerificationCallback(didOpts: IDIDOptions, contex fetchRemoteContexts: true, domain: getDID(didOpts.identifierOpts), }) - console.log(`VP verification result: ${JSON.stringify(result, null, 2)}`) return { verified: result.verified } } diff --git a/packages/siopv2-oid4vp-rp-rest-api/__tests__/agent.ts b/packages/siopv2-oid4vp-rp-rest-api/__tests__/agent.ts index 12151e7c6..3de8da9f1 100644 --- a/packages/siopv2-oid4vp-rp-rest-api/__tests__/agent.ts +++ b/packages/siopv2-oid4vp-rp-rest-api/__tests__/agent.ts @@ -26,6 +26,9 @@ import { ISIOPv2RP, SIOPv2RP } from '@sphereon/ssi-sdk-siopv2-oid4vp-rp-auth' import { IPresentationExchange, PresentationExchange } from '@sphereon/ssi-sdk-presentation-exchange' import { CheckLinkedDomain } from '@sphereon/did-auth-siop' import { entraAndSphereonCompatibleDef, entraVerifiedIdPresentation } from './presentationDefinitions' +import Debug from 'debug' + +const debug = Debug('ssi-sdk-siopv2-oid4vp-rp-rest-api') export const DIF_UNIRESOLVER_RESOLVE_URL = 'https://dev.uniresolver.io/1.0/identifiers' export const APP_ID = 'sphereon:rp-demo' @@ -197,9 +200,9 @@ agent }, }) .then((value) => { - console.log(`IDENTIFIER: ${value.did}`) + debug(`IDENTIFIER: ${value.did}`) }) .catch((reason) => { - console.log(`WHOOPSIE: ${reason}`) + debug(`error on creation: ${reason}`) }) export default agent diff --git a/packages/siopv2-oid4vp-rp-rest-api/src/SIOPv2RPRestAPI.ts b/packages/siopv2-oid4vp-rp-rest-api/src/SIOPv2RPRestAPI.ts index f767cdd50..071e2b9c1 100644 --- a/packages/siopv2-oid4vp-rp-rest-api/src/SIOPv2RPRestAPI.ts +++ b/packages/siopv2-oid4vp-rp-rest-api/src/SIOPv2RPRestAPI.ts @@ -95,17 +95,17 @@ export class SIOPv2RPRestAPI { private removeAuthRequestStateWebappEndpoint() { this.express.delete( - this._opts?.webappDeleteAuthRequestPath ?? '/webapp/definitions/:definitionId/auth-requests/:correlationId', - async (request, response) => { - const correlationId: string = request.params.correlationId - const definitionId: string = request.params.definitionId - if (!correlationId || !definitionId) { - console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`) - return SIOPv2RPRestAPI.sendErrorResponse(response, 404, 'No authorization request could be found') + this._opts?.webappDeleteAuthRequestPath ?? '/webapp/definitions/:definitionId/auth-requests/:correlationId', + async (request, response) => { + const correlationId: string = request.params.correlationId + const definitionId: string = request.params.definitionId + if (!correlationId || !definitionId) { + console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`) + return SIOPv2RPRestAPI.sendErrorResponse(response, 404, 'No authorization request could be found') + } + response.statusCode = 200 + return response.send(this.agent.siopDeleteAuthState({ definitionId, correlationId })) } - response.statusCode = 200 - return response.send(this.agent.siopDeleteAuthState({ definitionId, correlationId })) - } ) } @@ -115,16 +115,16 @@ export class SIOPv2RPRestAPI { const correlationId: string = request.body.correlationId as string const definitionId: string = request.body.definitionId as string const requestState = - correlationId && definitionId - ? await this.agent.siopGetAuthRequestState({ - correlationId, - definitionId, - errorOnNotFound: false, - }) - : undefined + correlationId && definitionId + ? await this.agent.siopGetAuthRequestState({ + correlationId, + definitionId, + errorOnNotFound: false, + }) + : undefined if (!requestState || !definitionId || !correlationId) { console.log( - `No authentication request mapping could be found for the given URL. correlation: ${correlationId}, definitionId: ${definitionId}` + `No authentication request mapping could be found for the given URL. correlation: ${correlationId}, definitionId: ${definitionId}` ) response.statusCode = 404 @@ -155,8 +155,8 @@ export class SIOPv2RPRestAPI { definitionId, lastUpdated: overallState.lastUpdated, ...(responseState && responseState.status === AuthorizationResponseStateStatus.VERIFIED - ? { payload: await responseState.response.mergedPayloads() } - : {}), + ? { payload: await responseState.response.mergedPayloads() } + : {}), } console.log(`Will send auth status: ${JSON.stringify(statusBody)}`) if (overallState.status === AuthorizationRequestStateStatus.ERROR || overallState.status === AuthorizationResponseStateStatus.ERROR) { @@ -170,19 +170,19 @@ export class SIOPv2RPRestAPI { private createAuthRequestWebappEndpoint() { this.express.post( - this._opts?.webappCreateAuthRequestPath || '/webapp/definitions/:definitionId/auth-requests', - (request: RequestWithAgent, response) => { - // if (!request.agent) throw Error('No agent configured') - const definitionId = request.params.definitionId - const state: string = uuid.uuid() - const correlationId = state + this._opts?.webappCreateAuthRequestPath || '/webapp/definitions/:definitionId/auth-requests', + (request: RequestWithAgent, response) => { + // if (!request.agent) throw Error('No agent configured') + const definitionId = request.params.definitionId + const state: string = uuid.uuid() + const correlationId = state - const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${correlationId}`, { - baseURI: this._opts?.siopBaseURI, - }) - const redirectURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${correlationId}`, { baseURI: this._opts?.siopBaseURI }) + const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${correlationId}`, { + baseURI: this._opts?.siopBaseURI, + }) + const redirectURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${correlationId}`, { baseURI: this._opts?.siopBaseURI }) - this.agent + this.agent .siopCreateAuthRequestURI({ definitionId, correlationId, @@ -204,31 +204,31 @@ export class SIOPv2RPRestAPI { console.error(e, e.stack) return SIOPv2RPRestAPI.sendErrorResponse(response, 500, 'Could not create an authorization request URI: ' + e.message) }) - } + } ) } private verifyAuthResponseSIOPv2Endpoint() { this.express.post( - this._opts?.siopVerifyAuthResponsePath ?? '/siop/definitions/:definitionId/auth-responses/:correlationId', - async (request, response) => { - const correlationId = request.params.correlationId - const definitionId = request.params.definitionId - if (!correlationId || !definitionId) { - console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`) - return SIOPv2RPRestAPI.sendErrorResponse(response, 404, 'No authorization request could be found') - } - console.log('Authorization Response (siop-sessions') - console.log(JSON.stringify(request.body, null, 2)) - const definition = await this.agent.pexStoreGetDefinition({ definitionId }) - const authorizationResponse = typeof request.body === 'string' ? request.body : (request.body as AuthorizationResponsePayload) - console.log(`URI: ${JSON.stringify(authorizationResponse)}`) - if (!definition) { - response.statusCode = 404 - response.statusMessage = `No definition ${definitionId}` - return response.send() - } - await this.agent + this._opts?.siopVerifyAuthResponsePath ?? '/siop/definitions/:definitionId/auth-responses/:correlationId', + async (request, response) => { + const correlationId = request.params.correlationId + const definitionId = request.params.definitionId + if (!correlationId || !definitionId) { + console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`) + return SIOPv2RPRestAPI.sendErrorResponse(response, 404, 'No authorization request could be found') + } + console.log('Authorization Response (siop-sessions') + console.log(JSON.stringify(request.body, null, 2)) + const definition = await this.agent.pexStoreGetDefinition({ definitionId }) + const authorizationResponse = typeof request.body === 'string' ? request.body : (request.body as AuthorizationResponsePayload) + console.log(`URI: ${JSON.stringify(authorizationResponse)}`) + if (!definition) { + response.statusCode = 404 + response.statusMessage = `No definition ${definitionId}` + return response.send() + } + await this.agent .siopVerifyAuthResponse({ authorizationResponse, correlationId, @@ -263,50 +263,50 @@ export class SIOPv2RPRestAPI { response.statusMessage = reason.message return response.send() }) - } + } ) } private getAuthRequestSIOPv2Endpoint() { this.express.get( - this._opts?.siopGetAuthRequestPath ?? '/siop/definitions/:definitionId/auth-requests/:correlationId', - async (request, response) => { - const correlationId = request.params.correlationId - const definitionId = request.params.definitionId - if (!correlationId || !definitionId) { - console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`) - return SIOPv2RPRestAPI.sendErrorResponse(response, 404, 'No authorization request could be found') - } - const requestState = await this.agent.siopGetAuthRequestState({ - correlationId, - definitionId, - errorOnNotFound: false, - }) - if (!requestState) { - console.log( - `No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${definitionId}` - ) - return SIOPv2RPRestAPI.sendErrorResponse(response, 404, `No authorization request could be found`) - } - const requestObject = await requestState.request?.requestObject?.toJwt() - console.log('JWT Request object:') - console.log(requestObject) - - let error: string | undefined - try { - response.statusCode = 200 - return response.send(requestObject) - } catch (e) { - error = typeof e === 'string' ? e : e instanceof Error ? e.message : undefined - } finally { - this.agent.siopUpdateAuthRequestState({ + this._opts?.siopGetAuthRequestPath ?? '/siop/definitions/:definitionId/auth-requests/:correlationId', + async (request, response) => { + const correlationId = request.params.correlationId + const definitionId = request.params.definitionId + if (!correlationId || !definitionId) { + console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`) + return SIOPv2RPRestAPI.sendErrorResponse(response, 404, 'No authorization request could be found') + } + const requestState = await this.agent.siopGetAuthRequestState({ correlationId, definitionId, - state: AuthorizationRequestStateStatus.SENT, - error, + errorOnNotFound: false, }) + if (!requestState) { + console.log( + `No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${definitionId}` + ) + return SIOPv2RPRestAPI.sendErrorResponse(response, 404, `No authorization request could be found`) + } + const requestObject = await requestState.request?.requestObject?.toJwt() + console.log('JWT Request object:') + console.log(requestObject) + + let error: string | undefined + try { + response.statusCode = 200 + return response.send(requestObject) + } catch (e) { + error = typeof e === 'string' ? e : e instanceof Error ? e.message : undefined + } finally { + this.agent.siopUpdateAuthRequestState({ + correlationId, + definitionId, + state: AuthorizationRequestStateStatus.SENT, + error, + }) + } } - } ) } } diff --git a/packages/siopv2-oid4vp-rp-rest-client/__tests__/integration.test.ts b/packages/siopv2-oid4vp-rp-rest-client/__tests__/integration.test.ts index 6b36cb249..def1b3e48 100644 --- a/packages/siopv2-oid4vp-rp-rest-client/__tests__/integration.test.ts +++ b/packages/siopv2-oid4vp-rp-rest-client/__tests__/integration.test.ts @@ -6,7 +6,7 @@ const definitionId = '9449e2db-791f-407c-b086-c21cc677d2e0' const baseUrl = 'https://ssi-backend.sphereon.com' const agent = createAgent({ - plugins: [new SIOPv2OID4VPRPRestClient(baseUrl, definitionId)], + plugins: [new SIOPv2OID4VPRPRestClient({baseUrl, definitionId})], }) describe('@sphereon/siopv2-oid4vp-rp-rest-client', () => { diff --git a/packages/siopv2-oid4vp-rp-rest-client/__tests__/mockedEndpoints.test.ts b/packages/siopv2-oid4vp-rp-rest-client/__tests__/mockedEndpoints.test.ts index bb822921d..47780c6d6 100644 --- a/packages/siopv2-oid4vp-rp-rest-client/__tests__/mockedEndpoints.test.ts +++ b/packages/siopv2-oid4vp-rp-rest-client/__tests__/mockedEndpoints.test.ts @@ -7,7 +7,7 @@ const definitionId = '9449e2db-791f-407c-b086-c21cc677d2e0' const baseUrl = 'https://my-siop-endpoint' const agent = createAgent({ - plugins: [new SIOPv2OID4VPRPRestClient(baseUrl, definitionId)], + plugins: [new SIOPv2OID4VPRPRestClient({baseUrl, definitionId})], }) afterAll(() => { nock.cleanAll() diff --git a/packages/siopv2-oid4vp-rp-rest-client/src/agent/SIOPv2OID4VPRPRestClient.ts b/packages/siopv2-oid4vp-rp-rest-client/src/agent/SIOPv2OID4VPRPRestClient.ts index 5465361ba..1f94d6f53 100644 --- a/packages/siopv2-oid4vp-rp-rest-client/src/agent/SIOPv2OID4VPRPRestClient.ts +++ b/packages/siopv2-oid4vp-rp-rest-client/src/agent/SIOPv2OID4VPRPRestClient.ts @@ -22,12 +22,12 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin { private readonly baseUrl?: string private readonly definitionId?: string - constructor(baseUrl?: string, definitionId?: string) { - if (baseUrl) { - this.baseUrl = baseUrl + constructor(args?: { baseUrl?: string, definitionId?: string }) { + if (args?.baseUrl) { + this.baseUrl = args.baseUrl } - if (definitionId) { - this.definitionId = definitionId + if (args?.definitionId) { + this.definitionId = args.definitionId } } diff --git a/packages/vc-handler-ld-local/src/__tests__/issue-verify-flow.test.ts b/packages/vc-handler-ld-local/src/__tests__/issue-verify-flow.test.ts index 999dd34c6..136b405bb 100644 --- a/packages/vc-handler-ld-local/src/__tests__/issue-verify-flow.test.ts +++ b/packages/vc-handler-ld-local/src/__tests__/issue-verify-flow.test.ts @@ -120,7 +120,6 @@ describe('credential-LD full flow', () => { }) expect(verifiableCredential).toBeDefined() - // console.log(verifiableCredential) const verifiedCredential = await agent.verifyCredentialLDLocal({ credential: verifiableCredential, diff --git a/packages/vc-handler-ld-local/src/__tests__/localAgent.test.ts b/packages/vc-handler-ld-local/src/__tests__/localAgent.test.ts index e5d82c2ae..e59c874d1 100644 --- a/packages/vc-handler-ld-local/src/__tests__/localAgent.test.ts +++ b/packages/vc-handler-ld-local/src/__tests__/localAgent.test.ts @@ -15,7 +15,6 @@ let agent: any const setup = async (): Promise => { const config = getConfig('packages/vc-handler-ld-local/agent.yml') - console.log(JSON.stringify(config.agent.$args[0], null, 1)) config.agent.$args[0].plugins[1].$args[0].contextMaps = [LdDefaultContexts] config.agent.$args[0].plugins[1].$args[0].suites = [SphereonEd25519Signature2018, SphereonEd25519Signature2020, SphereonBbsBlsSignature2020] const { localAgent } = createObjects(config, { localAgent: '/agent' }) diff --git a/packages/vc-handler-ld-local/src/ld-credential-module.ts b/packages/vc-handler-ld-local/src/ld-credential-module.ts index 1b22b62b4..b1a4d0445 100644 --- a/packages/vc-handler-ld-local/src/ld-credential-module.ts +++ b/packages/vc-handler-ld-local/src/ld-credential-module.ts @@ -175,7 +175,6 @@ export class LdCredentialModule { // result can include raw Error debug(`Error verifying LD Verifiable Credential: ${JSON.stringify(result, null, 2)}`) - console.log(JSON.stringify(result, null, 2)) context.agent.emit(events.CREDENTIAL_VERIFY_FAILED, credential) throw Error('Error verifying LD Verifiable Credential') } @@ -196,7 +195,6 @@ export class LdCredentialModule { checkStatus?: Function //AssertionProofPurpose() ): Promise { - // console.log(JSON.stringify(presentation, null, 2)) let result if (presentation.proof.type?.includes('BbsBlsSignature2020')) { //Should never be null or undefined @@ -246,8 +244,7 @@ export class LdCredentialModule { // NOT verified. // result can include raw Error - console.log(`Error verifying LD Verifiable Presentation`) - console.log(JSON.stringify(result, null, 2)) + debug(`Error verifying LD Verifiable Presentation: ${JSON.stringify(result, null, 2)}`) context.agent.emit(events.PRESENTATION_VERIFY_FAILED, presentation) throw Error('Error verifying LD Verifiable Presentation') } diff --git a/packages/vc-handler-ld-local/src/ld-document-loader.ts b/packages/vc-handler-ld-local/src/ld-document-loader.ts index e4bd2f92a..3b03d2eb7 100644 --- a/packages/vc-handler-ld-local/src/ld-document-loader.ts +++ b/packages/vc-handler-ld-local/src/ld-document-loader.ts @@ -25,8 +25,6 @@ export class LdDocumentLoader { getLoader(context: IAgentContext, attemptToFetchContexts = false) { return extendContextLoader(async (url: string) => { - // console.log(`resolving context for: ${url}`) - // did resolution if (url.toLowerCase().startsWith('did:')) { let didDoc: DIDDocument | null @@ -78,7 +76,6 @@ export class LdDocumentLoader { // and LD suites to be fixed specifically within the Veramo LD Suites definition this.ldSuiteLoader.getAllSignatureSuites().forEach((x) => x.preDidResolutionModification(url, didDoc as DIDDocument)) - // console.log(`Returning from Documentloader: ${JSON.stringify(returnDocument)}`) return { contextUrl: null, documentUrl: url, diff --git a/packages/vc-handler-ld-local/src/ld-suite-loader.ts b/packages/vc-handler-ld-local/src/ld-suite-loader.ts index df9611646..70ae47e9a 100644 --- a/packages/vc-handler-ld-local/src/ld-suite-loader.ts +++ b/packages/vc-handler-ld-local/src/ld-suite-loader.ts @@ -1,17 +1,18 @@ import { TKeyType } from '@veramo/core' import { SphereonLdSignature } from './ld-suites' - +import Debug from 'debug' /** * Initializes a list of Veramo-wrapped LD Signature suites and exposes those to the Agent Module */ +const debug = Debug('sphereon:ssi-sdk-vc-handler-ld-local') export class LdSuiteLoader { constructor(options: { ldSignatureSuites: SphereonLdSignature[] }) { options.ldSignatureSuites.forEach((obj) => { const veramoKeyType = obj.getSupportedVeramoKeyType() const verificationType = obj.getSupportedVerificationType() if (this.signatureMap[veramoKeyType]) { - console.log( + debug( `Registered another signature suite ${obj} for key type: ${veramoKeyType} overriding the old one. Previous one: ${this.signatureMap[veramoKeyType]}` ) // throw Error(`Cannot register 2 suites for the same type ${veramoKeyType}`) diff --git a/packages/vc-handler-ld-local/src/suites/Ed25519Signature2018.ts b/packages/vc-handler-ld-local/src/suites/Ed25519Signature2018.ts index 991334d71..4a60d41a2 100644 --- a/packages/vc-handler-ld-local/src/suites/Ed25519Signature2018.ts +++ b/packages/vc-handler-ld-local/src/suites/Ed25519Signature2018.ts @@ -95,7 +95,6 @@ export class SphereonEd25519Signature2018 extends SphereonLdSignature { // preSigningCredModification(credential: CredentialPayload): void { preSigningCredModification(): void { - // console.log(credential) // nothing to do here } diff --git a/packages/vc-handler-ld-local/src/suites/impl/JsonWebSignatureWithRSASupport.ts b/packages/vc-handler-ld-local/src/suites/impl/JsonWebSignatureWithRSASupport.ts index c0f53b3e0..a2aff5468 100644 --- a/packages/vc-handler-ld-local/src/suites/impl/JsonWebSignatureWithRSASupport.ts +++ b/packages/vc-handler-ld-local/src/suites/impl/JsonWebSignatureWithRSASupport.ts @@ -120,8 +120,6 @@ export class JsonWebSignature { } } - // console.log(document); - // ensure proof type is set proof.type = this.type diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index 2ef706969..1f25bf926 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -47,8 +47,6 @@ export class WellKnownDidVerifier implements IAgentPlugin { /** {@inheritDoc IWellKnownDidVerifier.verifyDomainLinkage} */ private async verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise { - console.log(args.onlyVerifyServiceDids) - const signatureVerification: VerifyCallback = typeof args.signatureVerification === 'string' ? await this.getSignatureVerification(args.signatureVerification)