Skip to content

Commit

Permalink
throw error on oidf client if fetch response code is not 200
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Nov 14, 2024
1 parent ffd8ec6 commit fc61962
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'cross-fetch/polyfill'
import { ResourceResolver } from "@sphereon/ssi-sdk.resource-resolver";
import { createAgent, TAgent } from '@veramo/core'
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/oidf-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
},
"dependencies": {
"@sphereon/ssi-types": "workspace:*",
"@sphereon/ssi-sdk.resource-resolver": "workspace:*",
"@sphereon/openid-federation-open-api": "0.1.0-unstable.c303a90",
"@sphereon/openid-federation-client": "0.1.0-unstable.c303a90",
"@sphereon/openid-federation-common": "0.1.0-unstable.c303a90",
"@sphereon/ssi-sdk-ext.jwt-service": "0.25.0"
},
"devDependencies": {
"@sphereon/ssi-sdk.resource-resolver": "workspace:*",
"@sphereon/ssi-sdk.agent-config": "workspace:*",
"@veramo/remote-client": "4.2.0",
"@veramo/remote-server": "4.2.0"
Expand Down
9 changes: 7 additions & 2 deletions packages/oidf-client/src/agent/OIDFClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import {FederationClient, ICryptoService, IFetchService} from '@sphereon/openid-
import {JWK} from "@sphereon/ssi-types";
import {IAgentPlugin} from '@veramo/core'
import {Request} from "cross-fetch";
import {ResolveTrustChainCallbackResult, schema} from '../index'
import {schema} from '../'
import {
IOIDFClient,
OIDFClientArgs,
IRequiredContext,
ResolveTrustChainArgs
ResolveTrustChainArgs,
ResolveTrustChainCallbackResult
} from '../types/IOIDFClient'

export const oidfClientMethods: Array<string> = ['resolveTrustChain']
Expand Down Expand Up @@ -48,6 +49,10 @@ export class OIDFClient implements IAgentPlugin {
resourceType: 'application/entity-statement+jwt',
})

if (response.status != 200) {
throw new Error(`Failed to fetch statement from ${endpoint}`)
}

return await response.text()
}
}
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

0 comments on commit fc61962

Please sign in to comment.