diff --git a/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts b/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts index 4e7fe6af..3d070ce6 100644 --- a/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts +++ b/packages/client/lib/__tests__/OpenID4VCIClient.spec.ts @@ -170,6 +170,7 @@ describe('OpenID4VCIClient should', () => { 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid', ); }); + it('create an authorization request url with authorization_details and scope', async () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore @@ -199,4 +200,26 @@ describe('OpenID4VCIClient should', () => { 'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22locations%22%3A%5B%22https%3A%2F%2Ftest%2Ecom%22%2C%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid', ); }); + }); +describe('should successfully handle isEbsi function', ()=>{ + it('should return true when calling isEbsi function', async () => { + const client = await OpenID4VCIClient.fromURI({ + clientId: 'test-client', + uri: 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Fserver.example.com%22%2C%22credential_configuration_ids%22%3A%5B%22TestCredential%22%5D%7D', + createAuthorizationRequestURL: false, + }); + nock(MOCK_URL).get(/.*/).reply(200, {}); + nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {}); + nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {}); + + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + client._state.endpointMetadata?.credentialIssuerMetadata?.credential_configurations_supported['TestCredential'] = { + trust_framework: { + name: 'ebsi_trust' + } + } + expect(client.isEBSI()).toBe(true) + }) +}) diff --git a/packages/common/lib/types/Generic.types.ts b/packages/common/lib/types/Generic.types.ts index 026c0ebf..ab0a4600 100644 --- a/packages/common/lib/types/Generic.types.ts +++ b/packages/common/lib/types/Generic.types.ts @@ -3,8 +3,16 @@ import { ICredentialContextType, IVerifiableCredential, W3CVerifiableCredential import { ProofOfPossession } from './CredentialIssuance.types'; import { AuthorizationServerMetadata } from './ServerMetadata'; import { CredentialOfferSession } from './StateManager.types'; -import { CredentialRequestV1_0_11 } from './v1_0_11.types'; -import { CredentialRequestV1_0_13 } from './v1_0_13.types'; +import { IssuerMetadataV1_0_08 } from './v1_0_08.types' +import { + CredentialRequestV1_0_11, + EndpointMetadataResultV1_0_11 +} from './v1_0_11.types' +import { + CredentialRequestV1_0_13, + EndpointMetadataResultV1_0_13, + IssuerMetadataV1_0_13 +} from './v1_0_13.types' export type InputCharSet = 'numeric' | 'text'; export type KeyProofType = 'jwt' | 'cwt' | 'ldp_vp'; @@ -353,3 +361,7 @@ export interface GrantUrnIetf { } export const PRE_AUTH_CODE_LITERAL = 'pre-authorized_code'; + +export type EndpointMetadataResult = EndpointMetadataResultV1_0_13 | EndpointMetadataResultV1_0_11 + +export type IssuerMetadata = IssuerMetadataV1_0_13 | IssuerMetadataV1_0_08 \ No newline at end of file