Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/SPRIND-18' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	yarn.lock
  • Loading branch information
nklomp committed Jul 4, 2024
2 parents ad9ee5a + 3cd97cc commit 582cc2f
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 44 deletions.
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.26.1-next.132",
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.26.1-next.132",
"@sphereon/ssi-types": "0.26.1-next.132",
"@sphereon/ui-components.core": "0.2.1-unstable.44",
"@sphereon/ui-components.ssi-react-native": "0.2.1-unstable.44",
"@sphereon/ui-components.credential-branding": "0.2.1-unstable.44",
"@sphereon/ui-components.core": "0.2.1-next.49",
"@sphereon/ui-components.ssi-react-native": "0.2.1-next.49",
"@sphereon/ui-components.credential-branding": "0.2.1-next.49",
"@veramo/core": "4.2.0",
"@veramo/credential-w3c": "4.2.0",
"@veramo/data-store": "4.2.0",
Expand Down Expand Up @@ -250,12 +250,8 @@
"@sphereon/did-auth-siop": "0.6.4",
"@sphereon/ssi-sdk-ext.key-utils": "0.22.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.22.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.22.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.22.0",
"@sphereon/ssi-types": "0.26.1-next.132",
"@sphereon/ssi-sdk.core": "0.26.1-next.132",
"@sphereon/ssi-sdk.data-store": "0.26.1-next.132",
"@sphereon/ssi-sdk.contact-manager": "0.26.1-next.132",
"@sphereon/oid4vci-client": "0.13.0",
"@sphereon/oid4vci-common": "0.13.0",
"@sphereon/pex": "3.3.3",
Expand Down
Binary file added src/agent/.index.ts.swp
Binary file not shown.
1 change: 1 addition & 0 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const dataStoreDeleteVerifiableCredential = agent.dataStoreDeleteVerifiab
export const createVerifiableCredential = agent.createVerifiableCredential;
export const ibAddCredentialBranding = agent.ibAddCredentialBranding;
export const ibGetCredentialBranding = agent.ibGetCredentialBranding;
export const ibGetIssuerBranding = agent.ibGetIssuerBranding;
export const ibCredentialLocaleBrandingFrom = agent.ibCredentialLocaleBrandingFrom;
export const ibRemoveCredentialBranding = agent.ibRemoveCredentialBranding;

Expand Down
4 changes: 2 additions & 2 deletions src/components/views/SSIConnectionDetailsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SSIConnectionDetailsView: FC<IProps> = (props: IProps): JSX.Element => {
// TODO rename to identity?
const {identity} = props;

const renderItem = (itemInfo: ListRenderItemInfo<MetadataItem>) => {
const renderItem = (itemInfo: ListRenderItemInfo<MetadataItem<any>>) => {
return (
<LabelRow>
<Column>
Expand Down Expand Up @@ -51,7 +51,7 @@ const SSIConnectionDetailsView: FC<IProps> = (props: IProps): JSX.Element => {
// TODO has a ItemSeparatorComponent which is a bit nicer to use then the logic now with margins
data={identity.metadata}
renderItem={renderItem}
keyExtractor={(item: MetadataItem) => item.id}
keyExtractor={(item: MetadataItem<any>) => item.id}
initialNumToRender={DETAILS_INITIAL_NUMBER_TO_RENDER}
removeClippedSubviews
/>
Expand Down
15 changes: 10 additions & 5 deletions src/components/views/SSIContactViewItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CredentialRole} from '@sphereon/ssi-sdk.data-store';
import {CredentialRole, IImageAttributes} from '@sphereon/ssi-sdk.data-store';
import React, {FC} from 'react';
import {View} from 'react-native';

Expand All @@ -9,24 +9,29 @@ import {
SSIContactViewItemContactUriCaptionStyled as ContactUriCaption,
SSIContactViewItemContainerStyled as Container,
SSIContactViewItemLogoContainerStyled as LogoContainer,
SSIContactViewItemPlaceholderLogoStyled as PlaceholderLogo,
SSIContactViewItemNewStatusContainerStyled as StatusContainer,
} from '../../../styles/components';
import Debug, {Debugger} from 'debug';
import {APP_ID} from '../../../@config/constants';
import {SSILogo as Logo} from '@sphereon/ui-components.ssi-react-native';

const debug: Debugger = Debug(`${APP_ID}:SSIContactViewItem`);

export interface Props {
name: string;
uri?: string;
logo?: IImageAttributes;
roles: Array<CredentialRole>;
}

const SSIContactViewItem: FC<Props> = (props: Props): JSX.Element => {
const {name, uri, roles} = props;

const {name, uri, roles, logo} = props;
debug(`logo: ${logo ? JSON.stringify(logo) : ''}`);
return (
<Container>
<StatusContainer />
<LogoContainer>
<PlaceholderLogo />
<Logo logo={logo} />
</LogoContainer>
<View>
<ContactDetailsContainer>
Expand Down
4 changes: 2 additions & 2 deletions src/navigation/machines/oid4vciStateNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const navigateAddContact = async (args: OID4VCIMachineNavigationArgs): Promise<v

const navigateSelectCredentials = async (args: OID4VCIMachineNavigationArgs): Promise<void> => {
const {navigation, state, oid4vciMachine, onNext, onBack} = args;
const {contact, credentialSelection} = state.context;
const {contact, selectedCredentials} = state.context;

if (!contact) {
return Promise.reject(Error('Missing contact in context'));
Expand All @@ -169,7 +169,7 @@ const navigateSelectCredentials = async (args: OID4VCIMachineNavigationArgs): Pr
screen: ScreenRoutesEnum.CREDENTIAL_SELECT_TYPE,
params: {
issuer: contact.contact.displayName,
credentialTypes: credentialSelection,
credentialTypes: selectedCredentials,
onSelectType,
onSelect: onNext,
onBack,
Expand Down
1 change: 0 additions & 1 deletion src/screens/SSIContactAddScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class SSIContactAddScreen extends PureComponent<IProps, IState> {
const {loading} = this.props;
const {isCreateDisabled} = this.props.route.params;
const {contactAlias, hasConsent} = this.state;

return (
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<Container>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SSIContactDetailsScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const SSIContactDetailsScreen: FC<Props> = (props: Props): JSX.Element => {

return (
<Container>
<SSIContactViewItem name={contact.contact.displayName} uri={contact.uri} roles={contact.roles} />
<SSIContactViewItem name={contact.contact.displayName} uri={contact.uri} roles={contact.roles} logo={contact.branding?.logo} />
<SSITabView routes={routes} />
</Container>
);
Expand Down
9 changes: 8 additions & 1 deletion src/screens/SSIContactsOverviewScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ class SSIContactsOverviewScreen extends PureComponent<IProps, IState> {

renderItem = (itemInfo: ListRenderItemInfo<Party>): JSX.Element => {
const {activeUser, contacts} = this.props;
const contactItem = <SSIContactViewItem name={itemInfo.item.contact.displayName} uri={itemInfo.item.uri} roles={itemInfo.item.roles} />;
const contactItem = (
<SSIContactViewItem
name={itemInfo.item.contact.displayName}
uri={itemInfo.item.uri}
roles={itemInfo.item.roles}
logo={itemInfo.item.branding?.logo}
/>
);
const backgroundStyle = {
backgroundColor: itemInfo.index % 2 === 0 ? backgroundColors.secondaryDark : backgroundColors.primaryDark,
};
Expand Down
1 change: 0 additions & 1 deletion src/screens/SSICredentialsOverviewScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class SSICredentialsOverviewScreen extends PureComponent<IProps, IState> {
};

render() {
console.log('this.props.verifiableCredentials:', this.props.verifiableCredentials);
return (
<Container>
<StatusBar />
Expand Down
16 changes: 14 additions & 2 deletions src/services/brandingService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {ICredentialBranding} from '@sphereon/ssi-sdk.data-store';
import {ICredentialBranding, IGetIssuerBrandingArgs, IIssuerBranding} from '@sphereon/ssi-sdk.data-store';
import {IDeletionResult} from '@sphereon/ssi-sdk.issuance-branding';
import Debug, {Debugger} from 'debug';

import {APP_ID} from '../@config/constants';
import {ibAddCredentialBranding, ibRemoveCredentialBranding} from '../agent';
import {ibAddCredentialBranding, ibGetIssuerBranding, ibRemoveCredentialBranding} from '../agent';
import {IAddCredentialBrandingArgs, IRemoveCredentialBrandingArgs} from '../types';

const debug: Debugger = Debug(`${APP_ID}:brandingService`);
Expand All @@ -17,3 +17,15 @@ export const removeCredentialBranding = async (args: IRemoveCredentialBrandingAr
debug(`removeCredentialBranding(${JSON.stringify(args)})...`);
return ibRemoveCredentialBranding(args);
};

export const getIssuerBrandingFromStorage = async (args: IGetIssuerBrandingArgs): Promise<IIssuerBranding[]> => {
debug(`getBrandingFromStorage(${JSON.stringify(args)})...`);
try {
const branding = await ibGetIssuerBranding(args);
debug(`getBrandingFromStorage(${JSON.stringify(args)}), result: ${JSON.stringify(branding)}`);
return branding;
} catch (e) {
debug(`Error on getting the branding! ${e}`);
throw e;
}
};
13 changes: 11 additions & 2 deletions src/services/machines/siopV2MachineService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import {SupportedVersion, VerifiedAuthorizationRequest} from '@sphereon/did-auth-siop';
import {ConnectionType, CorrelationIdentifierType, DidAuthConfig, CredentialRole, NonPersistedIdentity, Party} from '@sphereon/ssi-sdk.data-store';
import {
ConnectionType,
CorrelationIdentifierType,
CredentialRole,
DidAuthConfig,
IdentityOrigin,
NonPersistedIdentity,
Party,
} from '@sphereon/ssi-sdk.data-store';
import {W3CVerifiableCredential} from '@sphereon/ssi-types';
import {Linking} from 'react-native';
import {URL} from 'react-native-url-polyfill';
Expand Down Expand Up @@ -111,8 +119,9 @@ export const addContactIdentity = async (context: Pick<SiopV2MachineContext, 'co

if (correlationId) {
const identity: NonPersistedIdentity = {
origin: IdentityOrigin.EXTERNAL,
alias: correlationId,
roles: [CredentialRole.ISSUER],
roles: [CredentialRole.VERIFIER],
identifier: {
type: CorrelationIdentifierType.DID,
correlationId,
Expand Down
47 changes: 34 additions & 13 deletions src/store/actions/contact.actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import {CorrelationIdentifierType, Party, CredentialRole, Identity, PartyTypeType, PartyOrigin, IdentityOrigin} from '@sphereon/ssi-sdk.data-store';
import {
CorrelationIdentifierType,
CredentialRole,
Identity,
PartyTypeType,
PartyOrigin,
IdentityOrigin,
IIssuerBranding,
} from '@sphereon/ssi-sdk.data-store';
import {Action} from 'redux';
import {ThunkAction, ThunkDispatch} from 'redux-thunk';
import {v4 as uuidv4} from 'uuid';
Expand Down Expand Up @@ -30,24 +38,37 @@ import {
import {showToast} from '../../utils/ToastUtils';
import store from '../index';
import {IUserState} from '../../types/store/user.types';
import {getIssuerBrandingFromStorage} from '../../services/brandingService';
import {Party} from '@sphereon/ssi-sdk.data-store';

export const getContacts = (): ThunkAction<Promise<Array<Party>>, RootState, unknown, Action> => {
return async (dispatch: ThunkDispatch<RootState, unknown, Action>): Promise<Array<Party>> => {
dispatch({type: CONTACTS_LOADING});
return getUserContact()
.then((userContact: Party) => {
return getContactsFromStorage().then((contacts: Array<Party>): Array<Party> => {
dispatch({type: GET_CONTACTS_SUCCESS, payload: [...contacts, userContact]});
return [...contacts, userContact];
});
})
.catch((error: Error) => {
dispatch({type: GET_CONTACTS_FAILED});
return Promise.reject(error);
});
dispatch({type: 'CONTACTS_LOADING'});
try {
const userContact = await getUserContact();
let contacts = await getContactsFromStorage();

contacts = await Promise.all(contacts.map(fetchBrandingForContact));

const allContacts = [...contacts, userContact];
dispatch({type: GET_CONTACTS_SUCCESS, payload: allContacts});
return allContacts;
} catch (error) {
dispatch({type: GET_CONTACTS_FAILED});
return Promise.reject(error);
}
};
};

async function fetchBrandingForContact(contact: Party): Promise<Party> {
const correlationIds: string[] = contact.identities.map(identity => identity.identifier.correlationId);
const brandingPromises = correlationIds.map(correlationId => getIssuerBrandingFromStorage({filter: [{issuerCorrelationId: correlationId}]}));
const brandingResults = await Promise.all(brandingPromises);
const flattenedBrandingResults: IIssuerBranding[] = brandingResults.flat();
contact.branding = flattenedBrandingResults[0]?.localeBranding?.[0] ?? contact.branding;
return contact;
}

export const createContact = (args: ICreateContactArgs): ThunkAction<Promise<Party>, RootState, unknown, Action> => {
return async (dispatch: ThunkDispatch<RootState, unknown, Action>): Promise<Party> => {
dispatch({type: CONTACTS_LOADING});
Expand Down
6 changes: 1 addition & 5 deletions src/styles/components/components/SSIContactViewItem/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components/native';

import {SSIPlaceholderLogo} from '@sphereon/ui-components.ssi-react-native';
import {SSILogo, SSIPlaceholderLogo} from '@sphereon/ui-components.ssi-react-native';
import {SSIFlexDirectionRowViewStyled} from '../../containers';
import {SSITextH5LightStyled} from '../../fonts';

Expand Down Expand Up @@ -28,7 +28,3 @@ export const SSIContactViewItemContactDetailsContainerStyled = styled.View`
export const SSIContactViewItemContactUriCaptionStyled = styled(SSITextH5LightStyled)`
opacity: 0.8;
`;

export const SSIContactViewItemPlaceholderLogoStyled = styled(SSIPlaceholderLogo).attrs({
size: 26,
})``;
2 changes: 1 addition & 1 deletion src/types/machines/siopV2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {BaseActionObject, Interpreter, ResolveTypegenMeta, ServiceMap, State, St
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
import {IIdentifier} from '@veramo/core';
import {VerifiedAuthorizationRequest, PresentationDefinitionWithLocation, RPRegistrationMetadataPayload, URI} from '@sphereon/did-auth-siop';
import {Party, DidAuthConfig} from '@sphereon/ssi-sdk.data-store';
import {DidAuthConfig, Party} from '@sphereon/ssi-sdk.data-store';
import {OriginalVerifiableCredential} from '@sphereon/ssi-types';
import {ErrorDetails} from '../../error';
import {IQrData} from '../../qr';
Expand Down
2 changes: 1 addition & 1 deletion src/types/store/contact.action.types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
NonPersistedIdentity,
Party,
Identity,
NonPersistedParty,
NonPersistedContact,
NonPersistedPartyType as NonPersistedContactType,
Party,
} from '@sphereon/ssi-sdk.data-store';

export const CONTACTS_LOADING = '[CONTACT] CONTACTS_LOADING';
Expand Down

0 comments on commit 582cc2f

Please sign in to comment.