Skip to content

Commit

Permalink
chore: SDK-38 update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Oct 23, 2024
1 parent 0af330d commit 10e7492
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
16 changes: 16 additions & 0 deletions packages/callback-example/lib/__tests__/issuerCallback.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<JwtVerifyResult<DIDDocument>> {
const result = await jose.jwtVerify(args.jwt, keypair.publicKey)
const kid = result.protectedHeader.kid ?? args.kid
Expand Down Expand Up @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions packages/client/lib/__tests__/SdJwt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions packages/oid4vci-common/lib/types/v1_0_13.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, CredentialConfigurationSupportedV1_0_13>; // 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;
Expand Down

0 comments on commit 10e7492

Please sign in to comment.