From 10e74924e36f9b907e7f60e71c8d464b61bdfc1b Mon Sep 17 00:00:00 2001 From: sanderPostma Date: Wed, 23 Oct 2024 15:09:47 +0200 Subject: [PATCH] chore: SDK-38 update tests --- .../lib/__tests__/issuerCallback.spec.ts | 16 ++++++++++++++++ packages/client/lib/__tests__/SdJwt.spec.ts | 5 +++-- .../oid4vci-common/lib/types/v1_0_13.types.ts | 2 -- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/callback-example/lib/__tests__/issuerCallback.spec.ts b/packages/callback-example/lib/__tests__/issuerCallback.spec.ts index 62bafbe5..7541f357 100644 --- a/packages/callback-example/lib/__tests__/issuerCallback.spec.ts +++ b/packages/callback-example/lib/__tests__/issuerCallback.spec.ts @@ -24,6 +24,9 @@ import { DIDDocument } from 'did-resolver' import * as jose from 'jose' import { generateDid, getIssuerCallbackV1_0_11, getIssuerCallbackV1_0_13, verifyCredential } from '../IssuerCallback' +import { + AuthorizationServerMetadataBuilder +} from '@sphereon/oid4vci-issuer/dist/builder/AuthorizationServerMetadataBuilder' const INITIATION_TEST_URI = 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22:%22https://credential-issuer.example.com%22,%22credential_configuration_ids%22:%5B%22UniversityDegreeCredential%22%5D,%22grants%22:%7B%22urn:ietf:params:oauth:grant-type:pre-authorized_code%22:%7B%22pre-authorized_code%22:%22oaKazRN8I0IbtZ0C7JuMn5%22,%22tx_code%22:%7B%22input_mode%22:%22text%22,%22description%22:%22Please%20enter%20the%20serial%20number%20of%20your%20physical%20drivers%20license%22%7D%7D%7D%7D' @@ -47,6 +50,18 @@ async function proofOfPossessionCallbackFunction(args: Jwt, kid?: string): Promi .sign(keypair.privateKey) } + +const authorizationServerMetadata = new AuthorizationServerMetadataBuilder() + .withIssuer(IDENTIPROOF_ISSUER_URL) + .withCredentialEndpoint('http://localhost:3456/test/credential-endpoint') + .withTokenEndpoint('http://localhost:3456/test/token') + .withAuthorizationEndpoint('https://token-endpoint.example.com/authorize') + .withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post']) + .withResponseTypesSupported(['code', 'token', 'id_token']) + .withScopesSupported(['openid', 'abcdef']) + .build(); + + async function verifyCallbackFunction(args: { jwt: string; kid?: string }): Promise> { const result = await jose.jwtVerify(args.jwt, keypair.publicKey) const kid = result.protectedHeader.kid ?? args.kid @@ -150,6 +165,7 @@ describe('issuerCallback', () => { .withAuthorizationServers('https://authorization-server') .withCredentialEndpoint('https://credential-endpoint') .withCredentialIssuer(IDENTIPROOF_ISSUER_URL) + .withAuthorizationMetadata(authorizationServerMetadata) .withIssuerDisplay({ name: 'example issuer', locale: 'en-US', diff --git a/packages/client/lib/__tests__/SdJwt.spec.ts b/packages/client/lib/__tests__/SdJwt.spec.ts index 1f1b6a38..0265c7a8 100644 --- a/packages/client/lib/__tests__/SdJwt.spec.ts +++ b/packages/client/lib/__tests__/SdJwt.spec.ts @@ -29,15 +29,16 @@ const issuerMetadata = new IssuerMetadataBuilderV1_13() .build(); const authorizationServerMetadata = new AuthorizationServerMetadataBuilder() - .withIssuer(issuerMetadata.issuer) + .withIssuer(issuerMetadata.credential_issuer) .withCredentialEndpoint(issuerMetadata.credential_endpoint) - .withTokenEndpoint(issuerMetadata.token_endpoint) + .withTokenEndpoint(issuerMetadata.token_endpoint!) .withAuthorizationEndpoint('https://token-endpoint.example.com/authorize') .withTokenEndpointAuthMethodsSupported(['none', 'client_secret_basic', 'client_secret_jwt', 'client_secret_post']) .withResponseTypesSupported(['code', 'token', 'id_token']) .withScopesSupported(['openid', 'abcdef']) .build(); + const vcIssuer = new VcIssuerBuilder() .withIssuerMetadata(issuerMetadata) .withAuthorizationMetadata(authorizationServerMetadata) diff --git a/packages/oid4vci-common/lib/types/v1_0_13.types.ts b/packages/oid4vci-common/lib/types/v1_0_13.types.ts index fecab1c4..e601f4d9 100644 --- a/packages/oid4vci-common/lib/types/v1_0_13.types.ts +++ b/packages/oid4vci-common/lib/types/v1_0_13.types.ts @@ -23,12 +23,10 @@ import { QRCodeOpts } from './QRCode.types'; import { AuthorizationServerMetadata, AuthorizationServerType, EndpointMetadata } from './ServerMetadata'; export interface IssuerMetadataV1_0_13 { - issuer?: string; credential_configurations_supported: Record; // REQUIRED. A JSON object containing a list of key value pairs, where the key is a string serving as an abstract identifier of the Credential. This identifier is RECOMMENDED to be collision resistant - it can be globally unique, but does not have to be when naming conflicts are unlikely to arise in a given use case. The value is a JSON object. The JSON object MUST conform to the structure of the Section 11.2.1. credential_issuer: string; // A Credential Issuer is identified by a case sensitive URL using the https scheme that contains scheme, host and, optionally, port number and path components, but no query or fragment components. credential_endpoint: string; // REQUIRED. URL of the OP's Credential Endpoint. This URL MUST use the https scheme and MAY contain port, path and query parameter components. authorization_servers?: string[]; - batch_credential_endpoint?: string; deferred_credential_endpoint?: string; notification_endpoint?: string; credential_response_encryption?: ResponseEncryption;