Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sparkly-turkeys-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bifold/core': patch
---

Added custom subheader component for CredentialDetails
3 changes: 3 additions & 0 deletions packages/core/src/container-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { OnboardingStackParams, OnboardingTask, ScreenLayoutConfig, ScreenOption
import { CustomNotification } from './types/notification'
import { State } from './types/state'
import { IVersionCheckService } from './types/version-check'
import { DidCommCredentialExchangeRecord } from '@credo-ts/didcomm'

export type FN_ONBOARDING_DONE = (
dispatch: React.Dispatch<ReducerAction<unknown>>,
Expand Down Expand Up @@ -106,6 +107,7 @@ export const FN_TOKENS = {
COMPONENT_CRED_LIST_HEADER_RIGHT: 'fn.credListHeaderRight',
COMPONENT_CRED_LIST_OPTIONS: 'fn.credListOptions',
COMPONENT_CRED_LIST_FOOTER: 'fn.credListFooter',
COMPONENT_CRED_SUBHEADER: 'fn.credSubHeader',
} as const

export const HISTORY_TOKENS = {
Expand Down Expand Up @@ -238,6 +240,7 @@ export type TokenMapping = {
[TOKENS.COMPONENT_CRED_LIST_HEADER_RIGHT]: React.FC
[TOKENS.COMPONENT_CRED_LIST_OPTIONS]: React.FC
[TOKENS.COMPONENT_CRED_LIST_FOOTER]: React.FC<CredentialListFooterProps>
[TOKENS.COMPONENT_CRED_SUBHEADER]: React.FC<{ credential?: DidCommCredentialExchangeRecord }>
[TOKENS.COMPONENT_HOME_HEADER]: React.FC
[TOKENS.COMPONENT_NOTIFICATION_BANNER]: React.FC
[TOKENS.COMPONENT_HOME_NOTIFICATIONS_EMPTY_LIST]: React.FC
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/container-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class MainContainer implements Container {
this._container.registerInstance(TOKENS.COMPONENT_CRED_LIST_HEADER_RIGHT, () => null)
this._container.registerInstance(TOKENS.COMPONENT_CRED_LIST_OPTIONS, () => null)
this._container.registerInstance(TOKENS.COMPONENT_CRED_LIST_FOOTER, () => null)
this._container.registerInstance(TOKENS.COMPONENT_CRED_SUBHEADER, () => null)
this._container.registerInstance(TOKENS.COMPONENT_HOME_HEADER, HomeHeaderView)
this._container.registerInstance(TOKENS.COMPONENT_NOTIFICATION_BANNER, Banner)
this._container.registerInstance(TOKENS.COMPONENT_HOME_NOTIFICATIONS_EMPTY_LIST, NoNewUpdates)
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
export { buildFieldsFromAnonCredsCredential } from './utils/oca'
export { parsedSchema } from './utils/schema'
export { testIdForAccessabilityLabel, testIdWithKey } from './utils/testable'
import { getCredentialDefinitionIdForRecord } from './utils/helpers'

export { default as OpenIDCredentialDetails } from './modules/openid/screens/OpenIDCredentialDetails'
export { default as CredentialDetails } from './screens/CredentialDetails'
Expand Down Expand Up @@ -274,6 +275,7 @@
useTour,
usePreventDoublePress,
walletTimeout,
getCredentialDefinitionIdForRecord,

Check warning on line 278 in packages/core/src/index.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use `export…from` to re-export `getCredentialDefinitionIdForRecord`.

See more on https://sonarcloud.io/project/issues?id=openwallet-foundation_bifold-wallet&issues=AZ9se972TmWl-0RxzmRQ&open=AZ9se972TmWl-0RxzmRQ&pullRequest=1882
}
export type { BannerMessage, DeepPartial, IButton }

Expand Down
18 changes: 11 additions & 7 deletions packages/core/src/screens/CredentialDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ const CredentialDetails: React.FC<CredentialDetailsProps> = ({ navigation, route
const didcommCredentials = (agent as any)?.modules?.didcomm?.credentials ?? (agent as any)?.credentials
const { t, i18n } = useTranslation()
const { ColorPalette, Assets } = useTheme()
const [bundleResolver, logger, historyManagerCurried, historyEnabled, historyEventsLogger] = useServices([
TOKENS.UTIL_OCA_RESOLVER,
TOKENS.UTIL_LOGGER,
TOKENS.FN_LOAD_HISTORY,
TOKENS.HISTORY_ENABLED,
TOKENS.HISTORY_EVENTS_LOGGER,
])
const [bundleResolver, logger, historyManagerCurried, historyEnabled, historyEventsLogger, CredentialSubHeader] =
useServices([
TOKENS.UTIL_OCA_RESOLVER,
TOKENS.UTIL_LOGGER,
TOKENS.FN_LOAD_HISTORY,
TOKENS.HISTORY_ENABLED,
TOKENS.HISTORY_EVENTS_LOGGER,
TOKENS.COMPONENT_CRED_SUBHEADER,
])
const [isRevoked, setIsRevoked] = useState<boolean>(false)
const [revocationDate, setRevocationDate] = useState<string>('')
const [preciseRevocationDate, setPreciseRevocationDate] = useState<string>('')
Expand Down Expand Up @@ -383,6 +385,7 @@ const CredentialDetails: React.FC<CredentialDetailsProps> = ({ navigation, route
</View>
) : null}
{credential && <CredentialCardGen credential={credential} style={{ margin: 16 }} />}
<CredentialSubHeader credential={credential} />
</View>
) : (
<View style={styles.container}>
Expand All @@ -398,6 +401,7 @@ const CredentialDetails: React.FC<CredentialDetailsProps> = ({ navigation, route
{credential && <CredentialRevocationMessage credential={credential} />}
</View>
) : null}
<CredentialSubHeader credential={credential} />
</View>
)
}
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AnonCredsCredentialInfo,
AnonCredsCredentialMetadataKey,
AnonCredsCredentialsForProofRequest,
AnonCredsPredicateType,
AnonCredsProofRequest,
Expand Down Expand Up @@ -1278,14 +1279,14 @@ export function isChildFunction<T>(children: ReactNode | ChildFn<T>): children i

// Fetches the credential definition id for a given credential exchange record, returns null if ID is not found
export const getCredentialDefinitionIdForRecord = (record: DidCommCredentialExchangeRecord): string | null => {
// assumes record is anonCred
return record.metadata.get('_anoncreds/credential')?.credentialDefinitionId ?? null
// assumes record is anonCred ie: "_anoncreds/credential"
return record.metadata.get(AnonCredsCredentialMetadataKey)?.credentialDefinitionId ?? null
}

// Fetches the schema id for a given credential exchange record, returns null if ID is not found
export const getCredentialSchemaIdForRecord = (record: DidCommCredentialExchangeRecord): string | null => {
// assumes record is anonCred
return record.metadata.get('_anoncreds/credential')?.schemaId ?? null
// assumes record is anonCred ie: "_anoncreds/credential"
return record.metadata.get(AnonCredsCredentialMetadataKey)?.schemaId ?? null
}

export function getCredentialEventRole(record: DidCommCredentialExchangeRecord) {
Expand Down
Loading