Skip to content

Commit

Permalink
Merge pull request #58 from Sphereon-Opensource/feature/MWALL-702
Browse files Browse the repository at this point in the history
feature/MWALL-702
  • Loading branch information
nklomp authored Jul 31, 2024
2 parents 77c6997 + d6159f8 commit b0f8ffa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions packages/credential-branding/src/details/CredentialDetails.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import {v4 as uuidv4} from 'uuid'
import {VerifiableCredential} from '@veramo/core'
import {asArray, computeEntryHash} from '@veramo/utils'
import {IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding, Identity, Party} from '@sphereon/ssi-sdk.data-store'
import {
CredentialRole,
IBasicCredentialLocaleBranding,
IBasicIssuerLocaleBranding,
Identity,
Party,
} from '@sphereon/ssi-sdk.data-store'
import {EPOCH_MILLISECONDS, Localization} from '@sphereon/ui-components.core'
import {downloadImage, getImageDimensions} from '@sphereon/ssi-sdk.core'
import {CredentialDetailsRow, CredentialSummary, ISelectAppLocaleBrandingArgs} from '../types'
Expand All @@ -15,7 +21,7 @@ function findCorrelationIdName(correlationId: string, parties: Party[], activeUs
parties.push(activeUser)
}
return (
allParties.find((contact: Party) => contact.identities.some((identity: Identity): boolean => identity.identifier.correlationId === correlationId))
allParties?.find((contact: Party) => contact.identities.some((identity: Identity): boolean => identity.identifier.correlationId === correlationId))
?.contact.displayName ?? correlationId
)
}
Expand Down Expand Up @@ -97,21 +103,23 @@ const toCredentialDetailsRow = async (object: Record<string, any>, subject?: Par
*/
export const toNonPersistedCredentialSummary = (
verifiableCredential: ICredential | VerifiableCredential,
credentialRole: CredentialRole,
branding?: Array<IBasicCredentialLocaleBranding>,
issuer?: Party,
subject?: Party,
): Promise<CredentialSummary> => {
return toCredentialSummary(
verifiableCredential as VerifiableCredential,
computeEntryHash(verifiableCredential as VerifiableCredential),
credentialRole,
branding,
issuer,
subject,
)
}

export const getDate = (...dates: (number | string | undefined)[]): number | undefined => {
const date = dates.find(date => date !== null && date !== undefined)
const date = dates?.find(date => date !== null && date !== undefined)
if (!date) {
return
} else if (typeof date === 'number') {
Expand Down Expand Up @@ -198,6 +206,7 @@ const getTermsOfUse = ({
export const toCredentialSummary = async (
verifiableCredential: VerifiableCredential,
hash: string,
credentialRole: CredentialRole,
branding?: Array<IBasicCredentialLocaleBranding>,
issuer?: Party,
subject?: Party,
Expand All @@ -217,6 +226,7 @@ export const toCredentialSummary = async (
id: verifiableCredential.id,
title,
credentialStatus,
credentialRole,
issueDate,
expirationDate,
properties,
Expand Down
3 changes: 2 additions & 1 deletion packages/credential-branding/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {CredentialStatus, ImageSize, IssuerStatus} from '@sphereon/ui-components.core'
import {IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding} from '@sphereon/ssi-sdk.data-store'
import {CredentialRole, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding} from '@sphereon/ssi-sdk.data-store'

export type CredentialSummary = {
hash: string
id?: string // The id of the credential (optional according to VCDM)
title: string
issuer: IssuerSummary
credentialStatus: CredentialStatus
credentialRole: CredentialRole
issueDate: number
expirationDate: number
properties: CredentialDetailsRow[]
Expand Down

0 comments on commit b0f8ffa

Please sign in to comment.