Skip to content

Commit

Permalink
feat: added dynamicRegistrationClientMetadata to issuer locale branding
Browse files Browse the repository at this point in the history
  • Loading branch information
Brummos committed Nov 22, 2024
1 parent 3d1d370 commit aa98150
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/oid4vci-holder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"xstate": "^4.38.3"
},
"devDependencies": {
"@sphereon/oid4vc-common": "0.16.1-next.187",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.25.0",
"@types/i18n-js": "^3.8.9",
"@types/lodash.memoize": "^4.1.9",
Expand Down
1 change: 1 addition & 0 deletions packages/oid4vci-holder/src/agent/OID4VCIHolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ export class OID4VCIHolder implements IAgentPlugin {

return getBasicIssuerLocaleBranding({
display: serverMetadata.credentialIssuerMetadata?.display ?? [],
dynamicRegistrationClientMetadata: serverMetadata.credentialIssuerMetadata,
context,
})
}
Expand Down
4 changes: 2 additions & 2 deletions packages/oid4vci-holder/src/agent/OID4VCIHolderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export const getCredentialBranding = async (args: GetCredentialBrandingArgs): Pr
export const getBasicIssuerLocaleBranding = async (args: GetBasicIssuerLocaleBrandingArgs): Promise<Array<IBasicIssuerLocaleBranding>> => { //IBasicIssuerLocaleBranding
const { display, context } = args
return await Promise.all(
display.map(async (metadataDisplay: MetadataDisplay): Promise<IBasicIssuerLocaleBranding> => {
const branding = await issuerLocaleBrandingFrom({ issuerDisplay: metadataDisplay })
display.map(async (issuerDisplay: MetadataDisplay): Promise<IBasicIssuerLocaleBranding> => {
const branding = await issuerLocaleBrandingFrom({ issuerDisplay })
return context.agent.ibIssuerLocaleBrandingFrom({ localeBranding: branding })
}),
)
Expand Down
29 changes: 24 additions & 5 deletions packages/oid4vci-holder/src/agent/OIDC4VCIBrandingMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,29 @@ export const credentialLocaleBrandingFrom = async (args: CredentialLocaleBrandin
}
}

// TODO since dynamicRegistrationClientMetadata can also be on a RP, we should start using this mapper in a more general way
export const issuerLocaleBrandingFrom = async (args: IssuerLocaleBrandingFromArgs): Promise<IBasicIssuerLocaleBranding> => {
const { issuerDisplay } = args
const { issuerDisplay, dynamicRegistrationClientMetadata } = args

return {
...(dynamicRegistrationClientMetadata?.client_name && {
alias: dynamicRegistrationClientMetadata?.client_name
}),
...(issuerDisplay.name && {
alias: issuerDisplay.name,
}),
...(issuerDisplay.locale && {
locale: issuerDisplay.locale,
}),
...(issuerDisplay.logo && {
...((issuerDisplay.logo || dynamicRegistrationClientMetadata?.logo_uri) && {
logo: {
...((issuerDisplay.logo.url || <string>issuerDisplay.logo.uri) && {
uri: issuerDisplay.logo?.url ?? <string>issuerDisplay.logo.uri,
...(dynamicRegistrationClientMetadata?.logo_uri && {
uri: dynamicRegistrationClientMetadata?.logo_uri
}),
...((issuerDisplay.logo?.url || <string>issuerDisplay.logo?.uri) && {
uri: issuerDisplay.logo?.url ?? <string>issuerDisplay.logo?.uri,
}),
...(issuerDisplay.logo.alt_text && {
...(issuerDisplay.logo?.alt_text && {
alt: issuerDisplay.logo?.alt_text,
}),
},
Expand All @@ -91,6 +98,18 @@ export const issuerLocaleBrandingFrom = async (args: IssuerLocaleBrandingFromArg
color: issuerDisplay.text_color,
},
}),
...(dynamicRegistrationClientMetadata?.client_uri && {
clientUri: dynamicRegistrationClientMetadata?.client_uri
}),
...(dynamicRegistrationClientMetadata?.tos_uri && {
tosUri: dynamicRegistrationClientMetadata?.tos_uri
}),
...(dynamicRegistrationClientMetadata?.policy_uri && {
policyUri: dynamicRegistrationClientMetadata?.policy_uri
}),
...(dynamicRegistrationClientMetadata?.contacts && {
contacts: dynamicRegistrationClientMetadata?.contacts
}),
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/oid4vci-holder/src/types/IOID4VCIHolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
CredentialsSupportedDisplay,
IssuerCredentialSubject,
} from '@sphereon/oid4vci-common'
import { DynamicRegistrationClientMetadata } from '@sphereon/oid4vc-common'
import {
CreateOrGetIdentifierOpts,
IdentifierProviderOpts,
Expand Down Expand Up @@ -518,6 +519,7 @@ export type GetCredentialBrandingArgs = {

export type GetBasicIssuerLocaleBrandingArgs = {
display: MetadataDisplay[]
dynamicRegistrationClientMetadata?: DynamicRegistrationClientMetadataDisplay
context: RequiredContext
}

Expand Down Expand Up @@ -672,13 +674,9 @@ export type CredentialLocaleBrandingFromArgs = {
credentialDisplay: CredentialsSupportedDisplay
}

export type IssuerCredentialSubjectLocaleBrandingFromArgs = {
issuerCredentialSubject: IssuerCredentialSubject
locale?: string
}

export type IssuerLocaleBrandingFromArgs = {
issuerDisplay: MetadataDisplay
dynamicRegistrationClientMetadata?: DynamicRegistrationClientMetadataDisplay
}

export type CredentialBrandingFromArgs = {
Expand All @@ -699,4 +697,6 @@ export type CombineLocalesFromArgs = {
issuerCredentialSubjectLocales?: Map<string, Array<IBasicCredentialClaim>>
}

export type DynamicRegistrationClientMetadataDisplay = Pick<DynamicRegistrationClientMetadata, 'client_name' | 'client_uri' | 'contacts' | 'tos_uri' | 'policy_uri' | 'logo_uri'>

export type DidAgents = TAgent<IResolver & IDIDManager>
3 changes: 3 additions & 0 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 aa98150

Please sign in to comment.