Skip to content

Commit

Permalink
fix: add v13 param to createIssuer
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra committed Jul 18, 2024
1 parent a12d80c commit 6595e5e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
25 changes: 17 additions & 8 deletions packages/openid4vc/src/openid4vc-issuer/OpenId4VcIssuerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,21 @@ export class OpenId4VcIssuerService {
keyType: KeyType.Ed25519,
})

const credentialsSupported = Array.isArray(options.credentialsSupported)
? options.credentialsSupported
: credentialsSupportedV13ToV11(options.credentialsSupported)
const openId4VcIssuer = new OpenId4VcIssuerRecord({
const openId4VcIssuerBase = {
issuerId: options.issuerId ?? utils.uuid(),
display: options.display,
accessTokenPublicKeyFingerprint: accessTokenSignerKey.fingerprint,
credentialsSupported,
})
} as const

const openId4VcIssuer = options.credentialsSupported
? new OpenId4VcIssuerRecord({
...openId4VcIssuerBase,
credentialsSupported: options.credentialsSupported,
})
: new OpenId4VcIssuerRecord({
...openId4VcIssuerBase,
credentialConfigurationsSupported: options.credentialConfigurationsSupported,
})

await this.openId4VcIssuerRepository.save(agentContext, openId4VcIssuer)
await storeActorIdForContextCorrelationId(agentContext, openId4VcIssuer.issuerId)
Expand All @@ -334,6 +340,9 @@ export class OpenId4VcIssuerService {
tokenEndpoint: joinUriParts(issuerUrl, [config.accessTokenEndpoint.endpointPath]),
credentialEndpoint: joinUriParts(issuerUrl, [config.credentialEndpoint.endpointPath]),
credentialsSupported: issuerRecord.credentialsSupported,
credentialConfigurationsSupported:
issuerRecord.credentialConfigurationsSupported ??
credentialsSupportedV11ToV13(agentContext, issuerRecord.credentialsSupported),
issuerDisplay: issuerRecord.display,
} satisfies OpenId4VcIssuerMetadata

Expand Down Expand Up @@ -426,7 +435,7 @@ export class OpenId4VcIssuerService {
agentContext: AgentContext,
credentialOffer: OpenId4VciCredentialOfferPayload,
credentialRequest: OpenId4VciCredentialRequest,
credentialsSupported: OpenId4VciCredentialSupportedWithId[],
credentialsSupported: OpenId4VciCredentialSupportedWithId[] | OpenId4VciCredentialConfigurationsSupported,
issuanceSession: OpenId4VcIssuanceSessionRecord
): OpenId4VciCredentialConfigurationsSupported {
const offeredCredentialsData = isCredentialOfferV1Draft13(credentialOffer)
Expand Down Expand Up @@ -616,7 +625,7 @@ export class OpenId4VcIssuerService {
agentContext,
options.issuanceSession.credentialOfferPayload,
credentialRequest,
issuerMetadata.credentialsSupported,
issuerMetadata.credentialConfigurationsSupported,
issuanceSession
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { OpenId4VcIssuanceSessionRecord } from './repository'
import type {
OpenId4VcIssuanceSessionRecord,
OpenId4VcIssuerRecordCredentialConfigurationsSupportedProps,
OpenId4VcIssuerRecordCredentialSupportedProps,
} from './repository'
import type {
OpenId4VcCredentialHolderBinding,
OpenId4VciCredentialConfigurationsSupported,
Expand Down Expand Up @@ -34,6 +38,7 @@ export type OpenId4VcIssuerMetadata = {

issuerDisplay?: OpenId4VciIssuerMetadataDisplay[]
credentialsSupported: OpenId4VciCredentialSupportedWithId[]
credentialConfigurationsSupported: OpenId4VciCredentialConfigurationsSupported
}

export interface OpenId4VciCreateCredentialOfferOptions {
Expand Down Expand Up @@ -140,12 +145,11 @@ export interface OpenId4VciSignW3cCredential {
credential: W3cCredential
}

export interface OpenId4VciCreateIssuerOptions {
export type OpenId4VciCreateIssuerOptions = {
/**
* Id of the issuer, not the id of the issuer record. Will be exposed publicly
*/
issuerId?: string

credentialsSupported: OpenId4VciCredentialSupportedWithId[] | OpenId4VciCredentialConfigurationsSupported
display?: OpenId4VciIssuerMetadataDisplay[]
}
} & (OpenId4VcIssuerRecordCredentialSupportedProps | OpenId4VcIssuerRecordCredentialConfigurationsSupportedProps)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { OpenId4VcIssuanceRequest } from './requestContext'
import type { CredentialIssuerMetadata } from '@sphereon/oid4vci-common'
import type { Router, Response } from 'express'

import { credentialsSupportedV11ToV13 } from '../../shared/issuerMetadataUtils'
import { getRequestContext, sendErrorResponse } from '../../shared/router'
import { OpenId4VcIssuerService } from '../OpenId4VcIssuerService'

Expand All @@ -21,9 +20,7 @@ export function configureIssuerMetadataEndpoint(router: Router) {
authorization_server: issuerMetadata.authorizationServer,
authorization_servers: issuerMetadata.authorizationServer ? [issuerMetadata.authorizationServer] : undefined,
credentials_supported: issuerMetadata.credentialsSupported,
credential_configurations_supported:
issuer.credentialConfigurationsSupported ??
credentialsSupportedV11ToV13(agentContext, issuerMetadata.credentialsSupported),
credential_configurations_supported: issuerMetadata.credentialConfigurationsSupported,
display: issuerMetadata.issuerDisplay,
} satisfies CredentialIssuerMetadata

Expand Down

0 comments on commit 6595e5e

Please sign in to comment.