@procivis/one-react-native-components 0.3.47 → 0.3.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,7 @@ const EntityDetails = ({
49
49
  uri: trustEntity.logo
50
50
  }
51
51
  } : undefined;
52
- const placeholderText = (identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === 'CERTIFICATE' && (_identifierDetail$cer = identifierDetail.certificates) !== null && _identifierDetail$cer !== void 0 && _identifierDetail$cer[0] ? (_getCertificateCommon = getCertificateCommonName(identifierDetail.certificates[0])) === null || _getCertificateCommon === void 0 ? void 0 : _getCertificateCommon.substring(0, 1) : 'D';
52
+ const placeholderText = (identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === _reactNativeOneCore.IdentifierTypeEnum.CERTIFICATE && (_identifierDetail$cer = identifierDetail.certificates) !== null && _identifierDetail$cer !== void 0 && _identifierDetail$cer[0] ? (_getCertificateCommon = getCertificateCommonName(identifierDetail.certificates[0])) === null || _getCertificateCommon === void 0 ? void 0 : _getCertificateCommon.substring(0, 1) : 'D';
53
53
  const statusIcon = trusted ? /*#__PURE__*/_react.default.createElement(_icons.EntityTrustedIcon, {
54
54
  testID: (0, _utils.concatTestID)(testID, 'statusIcon', 'trusted')
55
55
  }) : /*#__PURE__*/_react.default.createElement(_icons.EntityNotTrustedIcon, {
@@ -73,7 +73,7 @@ const EntityDetails = ({
73
73
  if (isLoading) {
74
74
  return '';
75
75
  }
76
- if ((identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === 'CERTIFICATE' && (_identifierDetail$cer2 = identifierDetail.certificates) !== null && _identifierDetail$cer2 !== void 0 && _identifierDetail$cer2[0]) {
76
+ if ((identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === _reactNativeOneCore.IdentifierTypeEnum.CERTIFICATE && (_identifierDetail$cer2 = identifierDetail.certificates) !== null && _identifierDetail$cer2 !== void 0 && _identifierDetail$cer2[0]) {
77
77
  const commonName = getCertificateCommonName(identifierDetail.certificates[0]);
78
78
  if (commonName) {
79
79
  return commonName;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeOneCore","require","_react","_interopRequireWildcard","_entityCluster","_interopRequireDefault","_icons","_utils","_trustEntity","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getCertificateCommonName","certificate","_certificate$x509Attr","x509Attributes","subject","split","find","s","startsWith","pop","EntityDetails","labels","renderMore","role","style","testID","sublineColor","textColor","props","_props$identifier","_props$identifier2","data","isLoading","isLoadingTrustEntity","useTrustEntity","identifier","id","undefined","trustEntity","entity","identifierDetail","isLoadingIdentifier","useIdentifierDetails","trusted","state","TrustEntityStateEnum","ACTIVE","TrustEntityRoleEnum","BOTH","avatarProps","useMemo","_identifierDetail$cer","_getCertificateCommon","avatar","type","logo","imageSource","uri","placeholderText","certificates","substring","statusIcon","createElement","EntityTrustedIcon","concatTestID","EntityNotTrustedIcon","name","trustEntityName","_identifierDetail$cer2","_identifierDetail$did","commonName","did","replaceBreakingHyphens","unknown","Fragment","entityName","_default","exports"],"sources":["entity-details.tsx"],"sourcesContent":["import { IdentifierCertificateDetail, IdentifierListItem,TrustEntity, TrustEntityRoleEnum, TrustEntityStateEnum } from '@procivis/react-native-one-core';\nimport React, { FC, ReactNode, useMemo } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { AvatarProps } from '../../ui-components';\nimport EntityCluster from '../../ui-components/entity/entity-cluster';\nimport { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';\nimport { concatTestID, replaceBreakingHyphens, useIdentifierDetails } from '../../utils';\nimport { useTrustEntity } from '../../utils/hooks/core/trust-entity';\n\nexport type EntityDetailsLabels = {\n unknown: string;\n};\n\nexport type EntityDetailsProps = {\n labels: EntityDetailsLabels;\n renderMore?: (trustEntity: TrustEntity) => ReactNode;\n role: Exclude<TrustEntityRoleEnum, TrustEntityRoleEnum.BOTH>;\n style?: StyleProp<ViewStyle>;\n sublineColor?: string;\n textColor?: string;\n testID?: string;\n} & (\n | {\n identifier?: IdentifierListItem;\n }\n | {\n entity: TrustEntity;\n }\n );\n\nconst getCertificateCommonName = (certificate: IdentifierCertificateDetail): string | undefined => {\n return certificate.x509Attributes.subject.split(', ').find((s) => s.startsWith('CN'))?.split('=')?.pop();\n}\n\nconst EntityDetails: FC<EntityDetailsProps> = ({ labels, renderMore, role, style, testID, sublineColor, textColor, ...props }) => {\n const { data, isLoading: isLoadingTrustEntity } = useTrustEntity('identifier' in props ? props.identifier?.id : undefined);\n const trustEntity: TrustEntity | undefined = 'entity' in props ? props.entity : data ?? undefined;\n const { data: identifierDetail, isLoading: isLoadingIdentifier } = useIdentifierDetails('identifier' in props ? props.identifier?.id : undefined);\n\n const trusted =\n trustEntity &&\n trustEntity.state === TrustEntityStateEnum.ACTIVE &&\n (trustEntity.role === TrustEntityRoleEnum.BOTH || trustEntity.role === role);\n\n const isLoading = isLoadingIdentifier || isLoadingTrustEntity;\n\n const avatarProps: AvatarProps | undefined = useMemo(() => {\n if (isLoading) {\n return undefined;\n }\n\n const avatar = trusted && identifierDetail?.type === 'DID' && trustEntity.logo ? { imageSource: { uri: trustEntity.logo } } : undefined;\n\n const placeholderText = identifierDetail?.type === 'CERTIFICATE' && identifierDetail.certificates?.[0] ? getCertificateCommonName(identifierDetail.certificates[0])?.substring(0, 1) : 'D';\n\n const statusIcon = trusted ? \n <EntityTrustedIcon testID={concatTestID(testID, 'statusIcon', 'trusted')} /> :\n <EntityNotTrustedIcon testID={concatTestID(testID, 'statusIcon', 'notTrusted')} />;\n\n if (trustEntity) {\n return {\n avatar,\n placeholderText: trusted && identifierDetail?.type === 'DID' ? trustEntity.name.substring(0, 1) : placeholderText,\n statusIcon,\n testID: concatTestID(testID, 'avatar'),\n };\n }\n\n return {\n placeholderText,\n statusIcon,\n }\n }, [trustEntity, trusted, identifierDetail, isLoading, testID]);\n\n const trustEntityName = useMemo(() => {\n if (isLoading) {\n return '';\n }\n if (identifierDetail?.type === 'CERTIFICATE' && identifierDetail.certificates?.[0]) {\n const commonName = getCertificateCommonName(identifierDetail.certificates[0]);\n if (commonName) {\n return commonName;\n }\n }\n if (trustEntity) {\n return trustEntity.name;\n }\n if (identifierDetail?.did?.did) {\n return replaceBreakingHyphens(identifierDetail.did.did);\n }\n\n return labels.unknown;\n }, [labels.unknown, trustEntity, identifierDetail, isLoading]);\n\n return (\n <>\n <EntityCluster\n avatar={avatarProps}\n entityName={trustEntityName}\n style={style}\n testID={testID}\n textColor={textColor}\n sublineColor={sublineColor}\n isLoading={isLoading}\n />\n {trustEntity && renderMore && renderMore(trustEntity)}\n </>\n );\n};\n\nexport default EntityDetails;\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAIA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAAqE,SAAAI,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,G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U,CAACgB,WAAW,CACpD,CAAC;AAEP,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAArF,OAAA,GAEa4B,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeOneCore","require","_react","_interopRequireWildcard","_entityCluster","_interopRequireDefault","_icons","_utils","_trustEntity","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getCertificateCommonName","certificate","_certificate$x509Attr","x509Attributes","subject","split","find","s","startsWith","pop","EntityDetails","labels","renderMore","role","style","testID","sublineColor","textColor","props","_props$identifier","_props$identifier2","data","isLoading","isLoadingTrustEntity","useTrustEntity","identifier","id","undefined","trustEntity","entity","identifierDetail","isLoadingIdentifier","useIdentifierDetails","trusted","state","TrustEntityStateEnum","ACTIVE","TrustEntityRoleEnum","BOTH","avatarProps","useMemo","_identifierDetail$cer","_getCertificateCommon","avatar","type","logo","imageSource","uri","placeholderText","IdentifierTypeEnum","CERTIFICATE","certificates","substring","statusIcon","createElement","EntityTrustedIcon","concatTestID","EntityNotTrustedIcon","name","trustEntityName","_identifierDetail$cer2","_identifierDetail$did","commonName","did","replaceBreakingHyphens","unknown","Fragment","entityName","_default","exports"],"sources":["entity-details.tsx"],"sourcesContent":["import {\n IdentifierCertificateDetail,\n IdentifierListItem,\n IdentifierTypeEnum,\n TrustEntity,\n TrustEntityRoleEnum,\n TrustEntityStateEnum,\n} from '@procivis/react-native-one-core';\nimport React, { FC, ReactNode, useMemo } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { AvatarProps } from '../../ui-components';\nimport EntityCluster from '../../ui-components/entity/entity-cluster';\nimport { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';\nimport { concatTestID, replaceBreakingHyphens, useIdentifierDetails } from '../../utils';\nimport { useTrustEntity } from '../../utils/hooks/core/trust-entity';\n\nexport type EntityDetailsLabels = {\n unknown: string;\n};\n\nexport type EntityDetailsProps = {\n labels: EntityDetailsLabels;\n renderMore?: (trustEntity: TrustEntity) => ReactNode;\n role: Exclude<TrustEntityRoleEnum, TrustEntityRoleEnum.BOTH>;\n style?: StyleProp<ViewStyle>;\n sublineColor?: string;\n textColor?: string;\n testID?: string;\n} & (\n | {\n identifier?: IdentifierListItem;\n }\n | {\n entity: TrustEntity;\n }\n);\n\nconst getCertificateCommonName = (certificate: IdentifierCertificateDetail): string | undefined => {\n return certificate.x509Attributes.subject\n .split(', ')\n .find((s) => s.startsWith('CN'))\n ?.split('=')\n ?.pop();\n};\n\nconst EntityDetails: FC<EntityDetailsProps> = ({\n labels,\n renderMore,\n role,\n style,\n testID,\n sublineColor,\n textColor,\n ...props\n}) => {\n const { data, isLoading: isLoadingTrustEntity } = useTrustEntity(\n 'identifier' in props ? props.identifier?.id : undefined,\n );\n const trustEntity: TrustEntity | undefined = 'entity' in props ? props.entity : data ?? undefined;\n const { data: identifierDetail, isLoading: isLoadingIdentifier } = useIdentifierDetails(\n 'identifier' in props ? props.identifier?.id : undefined,\n );\n\n const trusted =\n trustEntity &&\n trustEntity.state === TrustEntityStateEnum.ACTIVE &&\n (trustEntity.role === TrustEntityRoleEnum.BOTH || trustEntity.role === role);\n\n const isLoading = isLoadingIdentifier || isLoadingTrustEntity;\n\n const avatarProps: AvatarProps | undefined = useMemo(() => {\n if (isLoading) {\n return undefined;\n }\n\n const avatar =\n trusted && identifierDetail?.type === 'DID' && trustEntity.logo\n ? { imageSource: { uri: trustEntity.logo } }\n : undefined;\n\n const placeholderText =\n identifierDetail?.type === IdentifierTypeEnum.CERTIFICATE && identifierDetail.certificates?.[0]\n ? getCertificateCommonName(identifierDetail.certificates[0])?.substring(0, 1)\n : 'D';\n\n const statusIcon = trusted ? (\n <EntityTrustedIcon testID={concatTestID(testID, 'statusIcon', 'trusted')} />\n ) : (\n <EntityNotTrustedIcon testID={concatTestID(testID, 'statusIcon', 'notTrusted')} />\n );\n\n if (trustEntity) {\n return {\n avatar,\n placeholderText:\n trusted && identifierDetail?.type === 'DID' ? trustEntity.name.substring(0, 1) : placeholderText,\n statusIcon,\n testID: concatTestID(testID, 'avatar'),\n };\n }\n\n return {\n placeholderText,\n statusIcon,\n };\n }, [trustEntity, trusted, identifierDetail, isLoading, testID]);\n\n const trustEntityName = useMemo(() => {\n if (isLoading) {\n return '';\n }\n if (identifierDetail?.type === IdentifierTypeEnum.CERTIFICATE && identifierDetail.certificates?.[0]) {\n const commonName = getCertificateCommonName(identifierDetail.certificates[0]);\n if (commonName) {\n return commonName;\n }\n }\n if (trustEntity) {\n return trustEntity.name;\n }\n if (identifierDetail?.did?.did) {\n return replaceBreakingHyphens(identifierDetail.did.did);\n }\n\n return labels.unknown;\n }, [labels.unknown, trustEntity, identifierDetail, isLoading]);\n\n return (\n <>\n <EntityCluster\n avatar={avatarProps}\n entityName={trustEntityName}\n style={style}\n testID={testID}\n textColor={textColor}\n sublineColor={sublineColor}\n isLoading={isLoading}\n />\n {trustEntity && renderMore && renderMore(trustEntity)}\n </>\n );\n};\n\nexport default EntityDetails;\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAIA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAAqE,SAAAI,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAN,wBAAAM,CAA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KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfE,SAAS,EAAEA,SAAU;IACrBD,YAAY,EAAEA,YAAa;IAC3BM,SAAS,EAAEA;EAAU,CACtB,CAAC,EACDM,WAAW,IAAIhB,UAAU,IAAIA,UAAU,CAACgB,WAAW,CACpD,CAAC;AAEP,CAAC;AAAC,IAAAwC,QAAA,GAAAC,OAAA,CAAAvF,OAAA,GAEa4B,aAAa","ignoreList":[]}
@@ -53,11 +53,12 @@ const useTrustEntity = identifierId => {
53
53
  var _identifierDetail$cer;
54
54
  return identifierId && identifierDetail ? core.resolveTrustEntityByIdentifier({
55
55
  identifiers: [{
56
- certificateId: identifierDetail.type === 'CERTIFICATE' ? (_identifierDetail$cer = identifierDetail.certificates) === null || _identifierDetail$cer === void 0 || (_identifierDetail$cer = _identifierDetail$cer[0]) === null || _identifierDetail$cer === void 0 ? void 0 : _identifierDetail$cer.id : undefined,
56
+ certificateId: (identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === _reactNativeOneCore.IdentifierTypeEnum.CERTIFICATE ? (_identifierDetail$cer = identifierDetail.certificates) === null || _identifierDetail$cer === void 0 || (_identifierDetail$cer = _identifierDetail$cer[0]) === null || _identifierDetail$cer === void 0 ? void 0 : _identifierDetail$cer.id : undefined,
57
57
  id: identifierId
58
58
  }]
59
59
  }).then(result => {
60
- return result[identifierId];
60
+ var _result$identifierId$, _result$identifierId;
61
+ return (_result$identifierId$ = (_result$identifierId = result[identifierId]) === null || _result$identifierId === void 0 || (_result$identifierId = _result$identifierId[0]) === null || _result$identifierId === void 0 ? void 0 : _result$identifierId.trustEntity) !== null && _result$identifierId$ !== void 0 ? _result$identifierId$ : null;
61
62
  }).catch(e => {
62
63
  if (e instanceof _reactNativeOneCore.OneError && e.code === _errorCode.OneErrorCode.NoTrustEntityFound) {
63
64
  return null;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeOneCore","require","_react","_reactQuery","_reporting","_client","_coreContext","_errorCode","_history","_identifiers","TRUST_ENTITY_DETAIL_QUERY_KEY","exports","REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY","useCreateTrustAnchor","publisherReference","httpClient","useHTTPClient","useCallback","core","trustAnchors","getTrustAnchors","page","pageSize","values","length","response","get","ok","data","trustAnchor","createTrustAnchor","isPublisher","name","type","TrustManagementEnum","SimpleTrustList","catch","err","reportException","useTrustEntity","identifierId","useONECore","identifierDetail","useIdentifierDetails","useQuery","_identifierDetail$cer","resolveTrustEntityByIdentifier","identifiers","certificateId","certificates","id","undefined","then","result","e","OneError","code","OneErrorCode","NoTrustEntityFound","enabled","Boolean","keepPreviousData","useRemoteTrustEntity","did","getRemoteTrustEntity","useCreateRemoteTrustEntity","queryClient","useQueryClient","useMutation","request","didId","entityDidId","_identifierDetail$did","getIdentifier","createRemoteTrustEntity","onSuccess","invalidateQueries","HISTORY_LIST_QUERY_KEY","useUpdateRemoteTrustEntity","_identifierDetail$did2","updateRemoteTrustEntity"],"sources":["trust-entity.ts"],"sourcesContent":["import {\n CreateRemoteTrustEntityRequest,\n ONECore,\n OneError,\n TrustAnchor,\n UpdateRemoteTrustEntityRequest,\n} from '@procivis/react-native-one-core';\nimport { useCallback } from 'react';\nimport { useMutation, useQuery, useQueryClient } from 'react-query';\n\nimport { reportException } from '../../reporting';\nimport { useHTTPClient } from '../http/client';\nimport { useONECore } from './core-context';\nimport { OneErrorCode } from './error-code';\nimport { HISTORY_LIST_QUERY_KEY } from './history';\nimport { useIdentifierDetails } from './identifiers';\n\nexport const TRUST_ENTITY_DETAIL_QUERY_KEY = 'trust-entity-detail';\nexport const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = 'remote-trust-entity-detail';\n\nexport const useCreateTrustAnchor = (publisherReference: string) => {\n const httpClient = useHTTPClient();\n\n return useCallback(\n async (core: ONECore) => {\n const trustAnchors = await core.getTrustAnchors({\n page: 0,\n pageSize: 1,\n });\n if (trustAnchors.values.length > 0) {\n return;\n }\n const response = await httpClient.get<TrustAnchor>(publisherReference);\n if (!response.ok || !response.data) {\n return;\n }\n const trustAnchor = response.data;\n await core\n .createTrustAnchor({\n isPublisher: false,\n name: trustAnchor.name,\n publisherReference,\n type: TrustManagementEnum.SimpleTrustList,\n })\n .catch((err) => {\n reportException(err, 'Failed to create trust anchor');\n throw err;\n });\n },\n [publisherReference, httpClient],\n );\n};\n\nexport const useTrustEntity = (identifierId: string | undefined) => {\n const { core } = useONECore();\n\n const { data: identifierDetail } = useIdentifierDetails(identifierId);\n\n return useQuery(\n [TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],\n () => identifierId && identifierDetail\n ? core.resolveTrustEntityByIdentifier({\n identifiers: [{\n certificateId: identifierDetail.type === 'CERTIFICATE' ? identifierDetail.certificates?.[0]?.id : undefined,\n id: identifierId,\n }],\n }).then((result) => {\n return result[identifierId];\n }).catch((e) => {\n if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {\n return null;\n }\n throw e;\n })\n : undefined,\n {\n enabled: Boolean(identifierDetail),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useRemoteTrustEntity = (identifierId: string | undefined) => {\n const { core } = useONECore();\n\n const { data: identifierDetail } = useIdentifierDetails(identifierId);\n\n return useQuery(\n [REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],\n () => (identifierDetail?.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined),\n {\n enabled: Boolean(identifierDetail?.did),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useCreateRemoteTrustEntity = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (request: Omit<CreateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string, didId?: string }) => {\n const { identifierId, didId } = request\n\n let entityDidId = didId;\n\n if (identifierId) {\n const identifierDetail = await core.getIdentifier(identifierId);\n entityDidId = identifierDetail?.did?.id;\n }\n\n return core.createRemoteTrustEntity({\n ...request,\n didId: entityDidId!,\n })\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useUpdateRemoteTrustEntity = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (request: Omit<UpdateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string, didId?: string }) => {\n const { identifierId, didId } = request\n\n let entityDidId = didId;\n if (identifierId) {\n const identifierDetail = await core.getIdentifier(identifierId);\n entityDidId = identifierDetail?.did?.id;\n }\n\n return core.updateRemoteTrustEntity({\n ...request,\n didId: entityDidId!,\n })\n }, {\n onSuccess: async () => {\n await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport enum TrustManagementEnum {\n SimpleTrustList = 'SIMPLE_TRUST_LIST',\n}\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEO,MAAMS,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAG,qBAAqB;AAC3D,MAAME,oCAAoC,GAAAD,OAAA,CAAAC,oCAAA,GAAG,4BAA4B;AAEzE,MAAMC,oBAAoB,GAAIC,kBAA0B,IAAK;EAClE,MAAMC,UAAU,GAAG,IAAAC,qBAAa,EAAC,CAAC;EAElC,OAAO,IAAAC,kBAAW,EAChB,MAAOC,IAAa,IAAK;IACvB,MAAMC,YAAY,GAAG,MAAMD,IAAI,CAACE,eAAe,C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KAAK;IACvB,IAAI9B,YAAY,EAAE;MAAA,IAAAuC,sBAAA;MAChB,MAAMrC,gBAAgB,GAAG,MAAMxB,IAAI,CAACuD,aAAa,CAACjC,YAAY,CAAC;MAC/D+B,WAAW,GAAG7B,gBAAgB,aAAhBA,gBAAgB,gBAAAqC,sBAAA,GAAhBrC,gBAAgB,CAAEqB,GAAG,cAAAgB,sBAAA,uBAArBA,sBAAA,CAAuB7B,EAAE;IACzC;IAEA,OAAOhC,IAAI,CAAC8D,uBAAuB,CAAC;MAClC,GAAGX,OAAO;MACVC,KAAK,EAAEC;IACT,CAAC,CAAC;EACJ,CAAC,EAAE;IACDI,SAAS,EAAE,MAAAA,CAAA,KAAY;MACrB,MAAMT,WAAW,CAACU,iBAAiB,CAAChE,oCAAoC,CAAC;MACzE,MAAMsD,WAAW,CAACU,iBAAiB,CAACC,+BAAsB,CAAC;IAC7D;EACF,CAAC,CAAC;AACJ,CAAC;AAAClE,OAAA,CAAAmE,0BAAA,GAAAA,0BAAA;AAAA,IAEU5C,mBAAmB,GAAAvB,OAAA,CAAAuB,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeOneCore","require","_react","_reactQuery","_reporting","_client","_coreContext","_errorCode","_history","_identifiers","TRUST_ENTITY_DETAIL_QUERY_KEY","exports","REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY","useCreateTrustAnchor","publisherReference","httpClient","useHTTPClient","useCallback","core","trustAnchors","getTrustAnchors","page","pageSize","values","length","response","get","ok","data","trustAnchor","createTrustAnchor","isPublisher","name","type","TrustManagementEnum","SimpleTrustList","catch","err","reportException","useTrustEntity","identifierId","useONECore","identifierDetail","useIdentifierDetails","useQuery","_identifierDetail$cer","resolveTrustEntityByIdentifier","identifiers","certificateId","IdentifierTypeEnum","CERTIFICATE","certificates","id","undefined","then","result","_result$identifierId$","_result$identifierId","trustEntity","e","OneError","code","OneErrorCode","NoTrustEntityFound","enabled","Boolean","keepPreviousData","useRemoteTrustEntity","did","getRemoteTrustEntity","useCreateRemoteTrustEntity","queryClient","useQueryClient","useMutation","request","didId","entityDidId","_identifierDetail$did","getIdentifier","createRemoteTrustEntity","onSuccess","invalidateQueries","HISTORY_LIST_QUERY_KEY","useUpdateRemoteTrustEntity","_identifierDetail$did2","updateRemoteTrustEntity"],"sources":["trust-entity.ts"],"sourcesContent":["import {\n CreateRemoteTrustEntityRequest,\n IdentifierTypeEnum,\n ONECore,\n OneError,\n TrustAnchor,\n UpdateRemoteTrustEntityRequest,\n} from '@procivis/react-native-one-core';\nimport { useCallback } from 'react';\nimport { useMutation, useQuery, useQueryClient } from 'react-query';\n\nimport { reportException } from '../../reporting';\nimport { useHTTPClient } from '../http/client';\nimport { useONECore } from './core-context';\nimport { OneErrorCode } from './error-code';\nimport { HISTORY_LIST_QUERY_KEY } from './history';\nimport { useIdentifierDetails } from './identifiers';\n\nexport const TRUST_ENTITY_DETAIL_QUERY_KEY = 'trust-entity-detail';\nexport const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = 'remote-trust-entity-detail';\n\nexport const useCreateTrustAnchor = (publisherReference: string) => {\n const httpClient = useHTTPClient();\n\n return useCallback(\n async (core: ONECore) => {\n const trustAnchors = await core.getTrustAnchors({\n page: 0,\n pageSize: 1,\n });\n if (trustAnchors.values.length > 0) {\n return;\n }\n const response = await httpClient.get<TrustAnchor>(publisherReference);\n if (!response.ok || !response.data) {\n return;\n }\n const trustAnchor = response.data;\n await core\n .createTrustAnchor({\n isPublisher: false,\n name: trustAnchor.name,\n publisherReference,\n type: TrustManagementEnum.SimpleTrustList,\n })\n .catch((err) => {\n reportException(err, 'Failed to create trust anchor');\n throw err;\n });\n },\n [publisherReference, httpClient],\n );\n};\n\nexport const useTrustEntity = (identifierId: string | undefined) => {\n const { core } = useONECore();\n\n const { data: identifierDetail } = useIdentifierDetails(identifierId);\n\n return useQuery(\n [TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],\n () =>\n identifierId && identifierDetail\n ? core\n .resolveTrustEntityByIdentifier({\n identifiers: [\n {\n certificateId:\n identifierDetail?.type === IdentifierTypeEnum.CERTIFICATE\n ? identifierDetail.certificates?.[0]?.id\n : undefined,\n id: identifierId,\n },\n ],\n })\n .then((result) => {\n return result[identifierId]?.[0]?.trustEntity ?? null;\n })\n .catch((e) => {\n if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {\n return null;\n }\n throw e;\n })\n : undefined,\n {\n enabled: Boolean(identifierDetail),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useRemoteTrustEntity = (identifierId: string | undefined) => {\n const { core } = useONECore();\n\n const { data: identifierDetail } = useIdentifierDetails(identifierId);\n\n return useQuery(\n [REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],\n () => (identifierDetail?.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined),\n {\n enabled: Boolean(identifierDetail?.did),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useCreateRemoteTrustEntity = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (request: Omit<CreateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string; didId?: string }) => {\n const { identifierId, didId } = request;\n\n let entityDidId = didId;\n\n if (identifierId) {\n const identifierDetail = await core.getIdentifier(identifierId);\n entityDidId = identifierDetail?.did?.id;\n }\n\n return core.createRemoteTrustEntity({\n ...request,\n didId: entityDidId!,\n });\n },\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useUpdateRemoteTrustEntity = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (request: Omit<UpdateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string; didId?: string }) => {\n const { identifierId, didId } = request;\n\n let entityDidId = didId;\n if (identifierId) {\n const identifierDetail = await core.getIdentifier(identifierId);\n entityDidId = identifierDetail?.did?.id;\n }\n\n return core.updateRemoteTrustEntity({\n ...request,\n didId: entityDidId!,\n });\n },\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport enum TrustManagementEnum {\n SimpleTrustList = 'SIMPLE_TRUST_LIST',\n}\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEO,MAAMS,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAG,qBAAqB;AAC3D,MAAME,oCAAoC,GAAAD,OAAA,CAAAC,oCAAA,GAAG,4BAA4B;AAEzE,MAAMC,oBAAoB,GAAIC,kBAA0B,IAAK;EAClE,MAAMC,UAAU,GAAG,IAAAC,qBAAa,EAAC,CAAC;EAElC,OAAO,IAAAC,kBAAW,EAChB,MAAOC,IAAa,IAAK;IACvB,MAAMC,YAAY,GAAG,MAAMD,IAAI,CAACE,eAAe,CAAC;MAC9CC,IAAI,EAAE,CAAC;MACPC,QAAQ,EAAE;IACZ,CAAC,CAAC;IACF,IAAIH,YAAY,CAACI,MAAM,CAACC,MAAM,GAAG,CAAC,EAAE;MAClC;IACF;IACA,MAAMC,QAAQ,GAAG,MAAMV,UAAU,CAACW,GAAG,CAAcZ,kBAAkB,CAAC;IACtE,IAAI,CAACW,QAAQ,CAACE,EAAE,IAAI,CAACF,QAAQ,C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K;IACvB,IAAInC,YAAY,EAAE;MAAA,IAAA4C,sBAAA;MAChB,MAAM1C,gBAAgB,GAAG,MAAMxB,IAAI,CAAC4D,aAAa,CAACtC,YAAY,CAAC;MAC/DoC,WAAW,GAAGlC,gBAAgB,aAAhBA,gBAAgB,gBAAA0C,sBAAA,GAAhB1C,gBAAgB,CAAE0B,GAAG,cAAAgB,sBAAA,uBAArBA,sBAAA,CAAuBhC,EAAE;IACzC;IAEA,OAAOlC,IAAI,CAACmE,uBAAuB,CAAC;MAClC,GAAGX,OAAO;MACVC,KAAK,EAAEC;IACT,CAAC,CAAC;EACJ,CAAC,EACD;IACEI,SAAS,EAAE,MAAAA,CAAA,KAAY;MACrB,MAAMT,WAAW,CAACU,iBAAiB,CAACrE,oCAAoC,CAAC;MACzE,MAAM2D,WAAW,CAACU,iBAAiB,CAACC,+BAAsB,CAAC;IAC7D;EACF,CACF,CAAC;AACH,CAAC;AAACvE,OAAA,CAAAwE,0BAAA,GAAAA,0BAAA;AAAA,IAEUjD,mBAAmB,GAAAvB,OAAA,CAAAuB,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA","ignoreList":[]}
@@ -58,8 +58,8 @@ const hasMsoValidityIssues = credential => {
58
58
  };
59
59
  exports.hasMsoValidityIssues = hasMsoValidityIssues;
60
60
  const cardHeaderFromCredential = (credential, claims = [], config, testID, labels) => {
61
- var _formatDateTimeLocali, _layoutProperties$log, _layoutProperties$log2, _layoutProperties$log3;
62
- let credentialDetailPrimary = (_formatDateTimeLocali = (0, _date.formatDateTimeLocalized)(new Date(credential.issuanceDate))) !== null && _formatDateTimeLocali !== void 0 ? _formatDateTimeLocali : '';
61
+ var _formatDateTimeLocali, _credential$issuanceD, _layoutProperties$log, _layoutProperties$log2, _layoutProperties$log3;
62
+ let credentialDetailPrimary = (_formatDateTimeLocali = (0, _date.formatDateTimeLocalized)(new Date((_credential$issuanceD = credential.issuanceDate) !== null && _credential$issuanceD !== void 0 ? _credential$issuanceD : credential.createdDate))) !== null && _formatDateTimeLocali !== void 0 ? _formatDateTimeLocali : '';
63
63
  let credentialDetailSecondary;
64
64
  let credentialDetailErrorColor;
65
65
  let credentialDetailTestID;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeOneCore","require","_icons","_date","_testID","_credentialImages","ValidityState","exports","getValidityState","credential","state","CredentialStateEnum","REVOKED","Revoked","SUSPENDED","Suspended","Valid","supportsSelectiveDisclosure","config","_formatConfig$capabil","formatConfig","format","schema","Boolean","capabilities","features","includes","FormatFeatureEnum","SelectiveDisclosure","undefined","findClaimByPathParts","path","claims","length","first","second","rest","claim","find","c","key","dataType","DataTypeEnum","Object","value","findClaimByPath","split","formatCredentialDetail","testID","_attributeValue$value","attributeValue","detailsCardAttributeValueFromClaim","hasMsoValidityIssues","mdocMsoValidity","mdocMsoValidityIssue","nextUpdate","Date","cardHeaderFromCredential","labels","_formatDateTimeLocali","_layoutProperties$log","_layoutProperties$log2","_layoutProperties$log3","credentialDetailPrimary","formatDateTimeLocalized","issuanceDate","credentialDetailSecondary","credentialDetailErrorColor","credentialDetailTestID","statusIcon","layoutProperties","suspendEndDate","suspendedUntil","suspended","concatTestID","CredentialWarningIcon","revoked","CredentialErrorIcon","validityIssues","primary","primaryAttribute","secondary","secondaryAttribute","color","logo","backgroundColor","credentialName","name","icon","image","imageSource","uri","iconLabelColor","fontColor","getCredentialCardPropsFromCredential","notice","_layoutProperties$bac","_layoutProperties$bac2","text","validityIssuesNotice","noticeIcon","CredentialNoticeWarningIcon","result","cardCarouselImages","getCarouselImagesFromClaims","cardImage","background","header","detailsCardAttributeFromClaim","id","pop","typeConfig","datatype","array","values","map","arrayValue","index","toString","type","Array","isArray","attributes","nestedClaim","_formatDateLocalized","String","date","formatDateLocalized","File","_typeConfig$params","params","showAs","detailsCardFromCredential","detailsCardFromCredentialWithClaims","card","nestAttributes","attribute","attributePath","push","parent","a","insertAttributeInObject","join","nestAttributeInDummyObject","pathParts","disabled","object","_object$attributes","nextParent","_object$attributes2","parseBase64Image","getCredentialSchemaWithoutImages","credentialSchema","_credentialSchema$lay","_credentialSchema$lay2","_credentialSchema$lay3","_credentialSchema$lay4"],"sources":["credential.ts"],"sourcesContent":["import {\n Claim,\n Config,\n CredentialDetail,\n CredentialListItem,\n CredentialSchema,\n CredentialStateEnum,\n DataTypeEnum,\n FormatFeatureEnum,\n} from '@procivis/react-native-one-core';\n\nimport {\n CredentialAttribute,\n CredentialAttributeValue,\n CredentialCardProps,\n CredentialDetailsCardProps,\n CredentialHeaderProps,\n} from '../../ui-components/credential';\nimport { CredentialCardNotice } from '../../ui-components/credential/card/credential-card';\nimport { CredentialErrorIcon, CredentialNoticeWarningIcon, CredentialWarningIcon } from '../../ui-components/icons';\nimport { formatDateLocalized, formatDateTimeLocalized } from '../date';\nimport { concatTestID } from '../testID';\nimport { getCarouselImagesFromClaims } from './credential-images';\n\nexport enum ValidityState {\n Revoked = 'revoked',\n Suspended = 'suspended',\n Valid = 'valid',\n}\n\nexport const getValidityState = (credential: CredentialListItem | undefined) => {\n if (credential?.state === CredentialStateEnum.REVOKED) {\n return ValidityState.Revoked;\n }\n if (credential?.state === CredentialStateEnum.SUSPENDED) {\n return ValidityState.Suspended;\n }\n return ValidityState.Valid;\n};\n\nexport const supportsSelectiveDisclosure = (credential: CredentialListItem | undefined, config: Config | undefined) => {\n const formatConfig = credential && config?.format[credential.schema.format];\n return formatConfig\n ? Boolean(formatConfig.capabilities?.features?.includes(FormatFeatureEnum.SelectiveDisclosure))\n : undefined;\n};\n\nconst findClaimByPathParts = (path: string[], claims?: Claim[]): Claim | undefined => {\n if (!claims?.length) {\n return undefined;\n }\n const [first, second, ...rest] = path;\n const claim = claims.find((c) => c.key === first);\n if (claim === undefined || second === undefined || claim.dataType !== DataTypeEnum.Object) {\n return claim;\n }\n\n return findClaimByPathParts([`${first}/${second}`, ...rest], claim.value as Claim[]);\n};\n\nexport const findClaimByPath = (path: string | undefined, claims: Claim[] | undefined) =>\n path ? findClaimByPathParts(path.split('/'), claims) : undefined;\n\nconst formatCredentialDetail = (claim: Claim, config: Config, testID: string): string => {\n const attributeValue = detailsCardAttributeValueFromClaim(claim, config, testID);\n return attributeValue.value ?? '';\n};\n\nexport const hasMsoValidityIssues = (credential: CredentialDetail): boolean => {\n const mdocMsoValidity: { nextUpdate: string } | undefined =\n 'mdocMsoValidity' in credential ? (credential.mdocMsoValidity as { nextUpdate: string }) : undefined;\n\n const mdocMsoValidityIssue = Boolean(\n mdocMsoValidity?.nextUpdate && new Date(mdocMsoValidity.nextUpdate) < new Date(),\n );\n\n return mdocMsoValidityIssue;\n};\n\nexport type CardHeaderLabels = {\n validityIssues: string;\n revoked: string;\n suspended: string;\n suspendedUntil: (date: string) => string;\n};\n\nexport const cardHeaderFromCredential = (\n credential: CredentialDetail,\n claims: Claim[] = [],\n config: Config,\n testID: string,\n labels: CardHeaderLabels,\n): Omit<CredentialHeaderProps, 'style'> => {\n let credentialDetailPrimary = formatDateTimeLocalized(new Date(credential.issuanceDate)) ?? '';\n\n let credentialDetailSecondary: string | undefined;\n let credentialDetailErrorColor: boolean | undefined;\n let credentialDetailTestID: string | undefined;\n let statusIcon;\n\n const { layoutProperties } = credential.schema;\n\n switch (credential.state) {\n case CredentialStateEnum.SUSPENDED:\n credentialDetailPrimary = credential.suspendEndDate\n ? labels.suspendedUntil(formatDateTimeLocalized(new Date(credential.suspendEndDate))!)\n : labels.suspended;\n credentialDetailTestID = concatTestID(testID, 'suspended');\n statusIcon = CredentialWarningIcon;\n break;\n case CredentialStateEnum.REVOKED:\n credentialDetailPrimary = labels.revoked;\n credentialDetailErrorColor = true;\n credentialDetailTestID = concatTestID(testID, 'revoked');\n statusIcon = CredentialErrorIcon;\n break;\n default: {\n if (hasMsoValidityIssues(credential)) {\n credentialDetailPrimary = labels.validityIssues;\n credentialDetailTestID = concatTestID(testID, 'validity-issue');\n statusIcon = CredentialWarningIcon;\n } else {\n const primary = findClaimByPath(layoutProperties?.primaryAttribute, claims);\n\n if (primary) {\n credentialDetailPrimary = formatCredentialDetail(primary, config, concatTestID(testID, 'primary'));\n }\n\n const secondary = findClaimByPath(layoutProperties?.secondaryAttribute, claims);\n\n if (secondary) {\n credentialDetailSecondary = formatCredentialDetail(secondary, config, concatTestID(testID, 'secondary'));\n }\n\n credentialDetailTestID = concatTestID(testID, 'detail');\n }\n break;\n }\n }\n return {\n color: layoutProperties?.logo?.backgroundColor,\n credentialDetailErrorColor,\n credentialDetailPrimary,\n credentialDetailSecondary,\n credentialDetailTestID,\n credentialName: credential.schema.name,\n icon: layoutProperties?.logo?.image\n ? {\n imageSource: {\n uri: layoutProperties.logo.image,\n },\n }\n : undefined,\n iconLabelColor: layoutProperties?.logo?.fontColor,\n statusIcon,\n testID,\n };\n};\n\nexport type CardLabels = CardHeaderLabels & {\n validityIssuesNotice: string;\n};\n\nexport const getCredentialCardPropsFromCredential = (\n credential: CredentialDetail,\n claims: Claim[] = [],\n config: Config,\n notice: CredentialCardNotice | undefined,\n testID: string,\n labels: CardLabels,\n): Omit<CredentialCardProps, 'onHeaderPress' | 'style'> => {\n const { layoutProperties } = credential.schema;\n\n if (hasMsoValidityIssues(credential)) {\n notice = {\n text: labels.validityIssuesNotice,\n noticeIcon: CredentialNoticeWarningIcon,\n };\n }\n\n const result: Omit<CredentialCardProps, 'onHeaderPress' | 'style'> = {\n cardCarouselImages: getCarouselImagesFromClaims(claims, layoutProperties, concatTestID(testID, 'carousel')),\n cardImage: layoutProperties?.background?.image\n ? { imageSource: { uri: layoutProperties.background.image } }\n : undefined,\n color: layoutProperties?.background?.color,\n header: cardHeaderFromCredential(credential, claims, config, concatTestID(testID, 'header'), labels),\n testID,\n notice,\n };\n\n return result;\n};\n\nexport const detailsCardAttributeFromClaim = (claim: Claim, config: Config, testID: string): CredentialAttribute => {\n const value = detailsCardAttributeValueFromClaim(claim, config, testID);\n return {\n id: claim.id,\n name: claim.key.split('/').pop(),\n path: claim.key,\n ...value,\n };\n};\n\nconst detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID: string): CredentialAttributeValue => {\n const typeConfig = config?.datatype[claim.dataType];\n\n if (claim.array) {\n return {\n values: (claim.value || []).map((arrayValue, index) => {\n return detailsCardAttributeFromClaim(\n {\n ...arrayValue,\n id: `${arrayValue.id}/${index}`,\n },\n config,\n concatTestID(testID, index.toString()),\n );\n }),\n };\n } else {\n switch (typeConfig?.type) {\n case DataTypeEnum.Object: {\n if (!Array.isArray(claim.value)) {\n return { attributes: [] };\n }\n return {\n attributes: (claim.value as Claim[]).map((nestedClaim, index) =>\n detailsCardAttributeFromClaim(nestedClaim, config, concatTestID(testID, index.toString())),\n ),\n };\n }\n case DataTypeEnum.Date: {\n if (!claim.value) {\n // Don't try to parse empty values (which will return \"Invalid Date\")\n return { testID: testID, value: String(claim.value) };\n }\n const date = claim.value as string;\n return {\n testID: testID,\n value: formatDateLocalized(new Date(date)) ?? date,\n };\n }\n case DataTypeEnum.File: {\n if (typeConfig.params?.showAs === 'IMAGE') {\n return { image: { uri: claim.value as string }, testID: testID };\n } else {\n return { testID: testID, value: claim.value as string };\n }\n }\n default:\n return { testID: testID, value: String(claim.value) };\n }\n }\n};\n\nexport const detailsCardFromCredential = (\n credential: CredentialDetail,\n config: Config,\n testID: string,\n labels: CardLabels,\n): Omit<CredentialDetailsCardProps, 'expanded'> => {\n return detailsCardFromCredentialWithClaims(credential, credential.claims, config, testID, labels);\n};\n\nexport const detailsCardFromCredentialWithClaims = (\n credential: CredentialDetail,\n claims: Claim[],\n config: Config,\n testID: string,\n labels: CardLabels,\n): Omit<CredentialDetailsCardProps, 'expanded'> => {\n const attributes: CredentialAttribute[] = claims.map((claim, index) =>\n detailsCardAttributeFromClaim(claim, config, concatTestID(testID, 'attribute', index.toString())),\n );\n\n const card = getCredentialCardPropsFromCredential(\n credential,\n claims,\n config,\n undefined,\n concatTestID(testID, 'card'),\n labels,\n );\n\n return {\n attributes,\n card,\n };\n};\n\n// Converts a flat list of attributes into a nested structure\n// modifies the names to not include slashes\nexport const nestAttributes = (attributes: CredentialAttribute[]): CredentialAttribute[] => {\n const result: CredentialAttribute[] = [];\n\n for (const attribute of attributes) {\n const attributePath = attribute.path.split('/');\n if (attributePath.length === 0) {\n result.push(attribute);\n } else {\n const [first, ...rest] = attributePath;\n const parent = result.find((a) => a.name === first);\n if (parent) {\n insertAttributeInObject({ ...attribute, path: rest.join('/') }, parent);\n } else {\n result.push(nestAttributeInDummyObject(attribute));\n }\n }\n }\n\n return result;\n};\n\n// We nest the leaf node in a (one or more) nested object(s)\n// to make sure the tree structure is correctly rendered in proof request screens.\nconst nestAttributeInDummyObject = (attribute: CredentialAttribute): CredentialAttribute => {\n const pathParts = attribute.path.split('/');\n const [first, ...rest] = pathParts;\n if (!rest.length) {\n return attribute;\n }\n\n // The dummy object is not selectable, and contains a placeholder ID\n // the user can't interact with it.\n return {\n attributes: [nestAttributeInDummyObject({ ...attribute, path: rest.join('/') })],\n disabled: true,\n id: `${attribute.id}/${first}`,\n name: first,\n path: attribute.path,\n };\n};\n\n// Recursively insert an attribute into an object\n// Will create nested objects if necessary\nconst insertAttributeInObject = (attribute: CredentialAttribute, object: CredentialAttribute) => {\n const pathParts = attribute.path.split('/');\n const [first, ...rest] = pathParts;\n\n const nextParent = object.attributes?.find((a) => a.name === first);\n\n if (!nextParent) {\n object.attributes?.push(nestAttributeInDummyObject(attribute));\n } else {\n insertAttributeInObject({ ...attribute, path: rest.join('/') }, nextParent);\n }\n};\n\nfunction parseBase64Image(image: string | undefined) {\n return image ? '__BASE64IMAGE__' : '';\n}\n\nexport function getCredentialSchemaWithoutImages(credentialSchema: CredentialSchema) {\n return {\n ...credentialSchema,\n layoutProperties: {\n ...credentialSchema.layoutProperties,\n background: {\n ...credentialSchema.layoutProperties?.background,\n image: parseBase64Image(credentialSchema.layoutProperties?.background?.image),\n },\n logo: {\n ...credentialSchema.layoutProperties?.logo,\n image: parseBase64Image(credentialSchema.layoutProperties?.logo?.image),\n },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AE;MAChB,GAAGkF,gBAAgB,CAAClF,gBAAgB;MACpCoC,UAAU,EAAE;QACV,KAAA+C,qBAAA,GAAGD,gBAAgB,CAAClF,gBAAgB,cAAAmF,qBAAA,uBAAjCA,qBAAA,CAAmC/C,UAAU;QAChDjB,KAAK,EAAE6D,gBAAgB,EAAAI,sBAAA,GAACF,gBAAgB,CAAClF,gBAAgB,cAAAoF,sBAAA,gBAAAA,sBAAA,GAAjCA,sBAAA,CAAmChD,UAAU,cAAAgD,sBAAA,uBAA7CA,sBAAA,CAA+CjE,KAAK;MAC9E,CAAC;MACDL,IAAI,EAAE;QACJ,KAAAuE,sBAAA,GAAGH,gBAAgB,CAAClF,gBAAgB,cAAAqF,sBAAA,uBAAjCA,sBAAA,CAAmCvE,IAAI;QAC1CK,KAAK,EAAE6D,gBAAgB,EAAAM,sBAAA,GAACJ,gBAAgB,CAAClF,gBAAgB,cAAAsF,sBAAA,gBAAAA,sBAAA,GAAjCA,sBAAA,CAAmCxE,IAAI,cAAAwE,sBAAA,uBAAvCA,sBAAA,CAAyCnE,KAAK;MACxE;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeOneCore","require","_icons","_date","_testID","_credentialImages","ValidityState","exports","getValidityState","credential","state","CredentialStateEnum","REVOKED","Revoked","SUSPENDED","Suspended","Valid","supportsSelectiveDisclosure","config","_formatConfig$capabil","formatConfig","format","schema","Boolean","capabilities","features","includes","FormatFeatureEnum","SelectiveDisclosure","undefined","findClaimByPathParts","path","claims","length","first","second","rest","claim","find","c","key","dataType","DataTypeEnum","Object","value","findClaimByPath","split","formatCredentialDetail","testID","_attributeValue$value","attributeValue","detailsCardAttributeValueFromClaim","hasMsoValidityIssues","mdocMsoValidity","mdocMsoValidityIssue","nextUpdate","Date","cardHeaderFromCredential","labels","_formatDateTimeLocali","_credential$issuanceD","_layoutProperties$log","_layoutProperties$log2","_layoutProperties$log3","credentialDetailPrimary","formatDateTimeLocalized","issuanceDate","createdDate","credentialDetailSecondary","credentialDetailErrorColor","credentialDetailTestID","statusIcon","layoutProperties","suspendEndDate","suspendedUntil","suspended","concatTestID","CredentialWarningIcon","revoked","CredentialErrorIcon","validityIssues","primary","primaryAttribute","secondary","secondaryAttribute","color","logo","backgroundColor","credentialName","name","icon","image","imageSource","uri","iconLabelColor","fontColor","getCredentialCardPropsFromCredential","notice","_layoutProperties$bac","_layoutProperties$bac2","text","validityIssuesNotice","noticeIcon","CredentialNoticeWarningIcon","result","cardCarouselImages","getCarouselImagesFromClaims","cardImage","background","header","detailsCardAttributeFromClaim","id","pop","typeConfig","datatype","array","values","map","arrayValue","index","toString","type","Array","isArray","attributes","nestedClaim","_formatDateLocalized","String","date","formatDateLocalized","File","_typeConfig$params","params","showAs","detailsCardFromCredential","detailsCardFromCredentialWithClaims","card","nestAttributes","attribute","attributePath","push","parent","a","insertAttributeInObject","join","nestAttributeInDummyObject","pathParts","disabled","object","_object$attributes","nextParent","_object$attributes2","parseBase64Image","getCredentialSchemaWithoutImages","credentialSchema","_credentialSchema$lay","_credentialSchema$lay2","_credentialSchema$lay3","_credentialSchema$lay4"],"sources":["credential.ts"],"sourcesContent":["import {\n Claim,\n Config,\n CredentialDetail,\n CredentialListItem,\n CredentialSchema,\n CredentialStateEnum,\n DataTypeEnum,\n FormatFeatureEnum,\n} from '@procivis/react-native-one-core';\n\nimport {\n CredentialAttribute,\n CredentialAttributeValue,\n CredentialCardProps,\n CredentialDetailsCardProps,\n CredentialHeaderProps,\n} from '../../ui-components/credential';\nimport { CredentialCardNotice } from '../../ui-components/credential/card/credential-card';\nimport { CredentialErrorIcon, CredentialNoticeWarningIcon, CredentialWarningIcon } from '../../ui-components/icons';\nimport { formatDateLocalized, formatDateTimeLocalized } from '../date';\nimport { concatTestID } from '../testID';\nimport { getCarouselImagesFromClaims } from './credential-images';\n\nexport enum ValidityState {\n Revoked = 'revoked',\n Suspended = 'suspended',\n Valid = 'valid',\n}\n\nexport const getValidityState = (credential: CredentialListItem | undefined) => {\n if (credential?.state === CredentialStateEnum.REVOKED) {\n return ValidityState.Revoked;\n }\n if (credential?.state === CredentialStateEnum.SUSPENDED) {\n return ValidityState.Suspended;\n }\n return ValidityState.Valid;\n};\n\nexport const supportsSelectiveDisclosure = (credential: CredentialListItem | undefined, config: Config | undefined) => {\n const formatConfig = credential && config?.format[credential.schema.format];\n return formatConfig\n ? Boolean(formatConfig.capabilities?.features?.includes(FormatFeatureEnum.SelectiveDisclosure))\n : undefined;\n};\n\nconst findClaimByPathParts = (path: string[], claims?: Claim[]): Claim | undefined => {\n if (!claims?.length) {\n return undefined;\n }\n const [first, second, ...rest] = path;\n const claim = claims.find((c) => c.key === first);\n if (claim === undefined || second === undefined || claim.dataType !== DataTypeEnum.Object) {\n return claim;\n }\n\n return findClaimByPathParts([`${first}/${second}`, ...rest], claim.value as Claim[]);\n};\n\nexport const findClaimByPath = (path: string | undefined, claims: Claim[] | undefined) =>\n path ? findClaimByPathParts(path.split('/'), claims) : undefined;\n\nconst formatCredentialDetail = (claim: Claim, config: Config, testID: string): string => {\n const attributeValue = detailsCardAttributeValueFromClaim(claim, config, testID);\n return attributeValue.value ?? '';\n};\n\nexport const hasMsoValidityIssues = (credential: CredentialDetail): boolean => {\n const mdocMsoValidity: { nextUpdate: string } | undefined =\n 'mdocMsoValidity' in credential ? (credential.mdocMsoValidity as { nextUpdate: string }) : undefined;\n\n const mdocMsoValidityIssue = Boolean(\n mdocMsoValidity?.nextUpdate && new Date(mdocMsoValidity.nextUpdate) < new Date(),\n );\n\n return mdocMsoValidityIssue;\n};\n\nexport type CardHeaderLabels = {\n validityIssues: string;\n revoked: string;\n suspended: string;\n suspendedUntil: (date: string) => string;\n};\n\nexport const cardHeaderFromCredential = (\n credential: CredentialDetail,\n claims: Claim[] = [],\n config: Config,\n testID: string,\n labels: CardHeaderLabels,\n): Omit<CredentialHeaderProps, 'style'> => {\n let credentialDetailPrimary =\n formatDateTimeLocalized(new Date(credential.issuanceDate ?? credential.createdDate)) ?? '';\n\n let credentialDetailSecondary: string | undefined;\n let credentialDetailErrorColor: boolean | undefined;\n let credentialDetailTestID: string | undefined;\n let statusIcon;\n\n const { layoutProperties } = credential.schema;\n\n switch (credential.state) {\n case CredentialStateEnum.SUSPENDED:\n credentialDetailPrimary = credential.suspendEndDate\n ? labels.suspendedUntil(formatDateTimeLocalized(new Date(credential.suspendEndDate))!)\n : labels.suspended;\n credentialDetailTestID = concatTestID(testID, 'suspended');\n statusIcon = CredentialWarningIcon;\n break;\n case CredentialStateEnum.REVOKED:\n credentialDetailPrimary = labels.revoked;\n credentialDetailErrorColor = true;\n credentialDetailTestID = concatTestID(testID, 'revoked');\n statusIcon = CredentialErrorIcon;\n break;\n default: {\n if (hasMsoValidityIssues(credential)) {\n credentialDetailPrimary = labels.validityIssues;\n credentialDetailTestID = concatTestID(testID, 'validity-issue');\n statusIcon = CredentialWarningIcon;\n } else {\n const primary = findClaimByPath(layoutProperties?.primaryAttribute, claims);\n\n if (primary) {\n credentialDetailPrimary = formatCredentialDetail(primary, config, concatTestID(testID, 'primary'));\n }\n\n const secondary = findClaimByPath(layoutProperties?.secondaryAttribute, claims);\n\n if (secondary) {\n credentialDetailSecondary = formatCredentialDetail(secondary, config, concatTestID(testID, 'secondary'));\n }\n\n credentialDetailTestID = concatTestID(testID, 'detail');\n }\n break;\n }\n }\n return {\n color: layoutProperties?.logo?.backgroundColor,\n credentialDetailErrorColor,\n credentialDetailPrimary,\n credentialDetailSecondary,\n credentialDetailTestID,\n credentialName: credential.schema.name,\n icon: layoutProperties?.logo?.image\n ? {\n imageSource: {\n uri: layoutProperties.logo.image,\n },\n }\n : undefined,\n iconLabelColor: layoutProperties?.logo?.fontColor,\n statusIcon,\n testID,\n };\n};\n\nexport type CardLabels = CardHeaderLabels & {\n validityIssuesNotice: string;\n};\n\nexport const getCredentialCardPropsFromCredential = (\n credential: CredentialDetail,\n claims: Claim[] = [],\n config: Config,\n notice: CredentialCardNotice | undefined,\n testID: string,\n labels: CardLabels,\n): Omit<CredentialCardProps, 'onHeaderPress' | 'style'> => {\n const { layoutProperties } = credential.schema;\n\n if (hasMsoValidityIssues(credential)) {\n notice = {\n text: labels.validityIssuesNotice,\n noticeIcon: CredentialNoticeWarningIcon,\n };\n }\n\n const result: Omit<CredentialCardProps, 'onHeaderPress' | 'style'> = {\n cardCarouselImages: getCarouselImagesFromClaims(claims, layoutProperties, concatTestID(testID, 'carousel')),\n cardImage: layoutProperties?.background?.image\n ? { imageSource: { uri: layoutProperties.background.image } }\n : undefined,\n color: layoutProperties?.background?.color,\n header: cardHeaderFromCredential(credential, claims, config, concatTestID(testID, 'header'), labels),\n testID,\n notice,\n };\n\n return result;\n};\n\nexport const detailsCardAttributeFromClaim = (claim: Claim, config: Config, testID: string): CredentialAttribute => {\n const value = detailsCardAttributeValueFromClaim(claim, config, testID);\n return {\n id: claim.id,\n name: claim.key.split('/').pop(),\n path: claim.key,\n ...value,\n };\n};\n\nconst detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID: string): CredentialAttributeValue => {\n const typeConfig = config?.datatype[claim.dataType];\n\n if (claim.array) {\n return {\n values: (claim.value || []).map((arrayValue, index) => {\n return detailsCardAttributeFromClaim(\n {\n ...arrayValue,\n id: `${arrayValue.id}/${index}`,\n },\n config,\n concatTestID(testID, index.toString()),\n );\n }),\n };\n } else {\n switch (typeConfig?.type) {\n case DataTypeEnum.Object: {\n if (!Array.isArray(claim.value)) {\n return { attributes: [] };\n }\n return {\n attributes: (claim.value as Claim[]).map((nestedClaim, index) =>\n detailsCardAttributeFromClaim(nestedClaim, config, concatTestID(testID, index.toString())),\n ),\n };\n }\n case DataTypeEnum.Date: {\n if (!claim.value) {\n // Don't try to parse empty values (which will return \"Invalid Date\")\n return { testID: testID, value: String(claim.value) };\n }\n const date = claim.value as string;\n return {\n testID: testID,\n value: formatDateLocalized(new Date(date)) ?? date,\n };\n }\n case DataTypeEnum.File: {\n if (typeConfig.params?.showAs === 'IMAGE') {\n return { image: { uri: claim.value as string }, testID: testID };\n } else {\n return { testID: testID, value: claim.value as string };\n }\n }\n default:\n return { testID: testID, value: String(claim.value) };\n }\n }\n};\n\nexport const detailsCardFromCredential = (\n credential: CredentialDetail,\n config: Config,\n testID: string,\n labels: CardLabels,\n): Omit<CredentialDetailsCardProps, 'expanded'> => {\n return detailsCardFromCredentialWithClaims(credential, credential.claims, config, testID, labels);\n};\n\nexport const detailsCardFromCredentialWithClaims = (\n credential: CredentialDetail,\n claims: Claim[],\n config: Config,\n testID: string,\n labels: CardLabels,\n): Omit<CredentialDetailsCardProps, 'expanded'> => {\n const attributes: CredentialAttribute[] = claims.map((claim, index) =>\n detailsCardAttributeFromClaim(claim, config, concatTestID(testID, 'attribute', index.toString())),\n );\n\n const card = getCredentialCardPropsFromCredential(\n credential,\n claims,\n config,\n undefined,\n concatTestID(testID, 'card'),\n labels,\n );\n\n return {\n attributes,\n card,\n };\n};\n\n// Converts a flat list of attributes into a nested structure\n// modifies the names to not include slashes\nexport const nestAttributes = (attributes: CredentialAttribute[]): CredentialAttribute[] => {\n const result: CredentialAttribute[] = [];\n\n for (const attribute of attributes) {\n const attributePath = attribute.path.split('/');\n if (attributePath.length === 0) {\n result.push(attribute);\n } else {\n const [first, ...rest] = attributePath;\n const parent = result.find((a) => a.name === first);\n if (parent) {\n insertAttributeInObject({ ...attribute, path: rest.join('/') }, parent);\n } else {\n result.push(nestAttributeInDummyObject(attribute));\n }\n }\n }\n\n return result;\n};\n\n// We nest the leaf node in a (one or more) nested object(s)\n// to make sure the tree structure is correctly rendered in proof request screens.\nconst nestAttributeInDummyObject = (attribute: CredentialAttribute): CredentialAttribute => {\n const pathParts = attribute.path.split('/');\n const [first, ...rest] = pathParts;\n if (!rest.length) {\n return attribute;\n }\n\n // The dummy object is not selectable, and contains a placeholder ID\n // the user can't interact with it.\n return {\n attributes: [nestAttributeInDummyObject({ ...attribute, path: rest.join('/') })],\n disabled: true,\n id: `${attribute.id}/${first}`,\n name: first,\n path: attribute.path,\n };\n};\n\n// Recursively insert an attribute into an object\n// Will create nested objects if necessary\nconst insertAttributeInObject = (attribute: CredentialAttribute, object: CredentialAttribute) => {\n const pathParts = attribute.path.split('/');\n const [first, ...rest] = pathParts;\n\n const nextParent = object.attributes?.find((a) => a.name === first);\n\n if (!nextParent) {\n object.attributes?.push(nestAttributeInDummyObject(attribute));\n } else {\n insertAttributeInObject({ ...attribute, path: rest.join('/') }, nextParent);\n }\n};\n\nfunction parseBase64Image(image: string | undefined) {\n return image ? '__BASE64IMAGE__' : '';\n}\n\nexport function getCredentialSchemaWithoutImages(credentialSchema: CredentialSchema) {\n return {\n ...credentialSchema,\n layoutProperties: {\n ...credentialSchema.layoutProperties,\n background: {\n ...credentialSchema.layoutProperties?.background,\n image: parseBase64Image(credentialSchema.layoutProperties?.background?.image),\n },\n logo: {\n ...credentialSchema.layoutProperties?.logo,\n image: parseBase64Image(credentialSchema.layoutProperties?.logo?.image),\n },\n },\n };\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAmBA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAAkE,IAEtDK,aAAa,GAAAC,OAAA,CAAAD,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAMlB,MAAME,gBAAgB,GAAIC,UAA0C,IAAK;EAC9E,IAAI,CAAAA,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEC,KAAK,MAAKC,uCAAmB,CAACC,OAAO,EAAE;IACrD,OAAON,aAAa,CAACO,OAAO;EAC9B;EACA,IAAI,CAAAJ,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEC,KAAK,MAAKC,uCAAmB,CAACG,SAAS,EAAE;IACvD,OAAOR,aAAa,CAACS,SAAS;EAChC;EACA,OAAOT,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B,cAAAsF,sBAAA,gBAAAA,sBAAA,GAAjCA,sBAAA,CAAmCxE,IAAI,cAAAwE,sBAAA,uBAAvCA,sBAAA,CAAyCnE,KAAK;MACxE;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -4,119 +4,38 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getQueryKeyFromProofSchemaListQueryParams = exports.getQueryKeyFromProofListQueryParams = exports.getQueryKeyFromIdentifierListQueryParams = exports.getQueryKeyFromHistoryListQueryParams = exports.getQueryKeyFromDidListQueryParams = exports.getQueryKeyFromCredentialSchemaListQueryParams = exports.getQueryKeyFromCredentialListQueryParams = void 0;
7
- const getQueryKeyFromCredentialListQueryParams = queryParams => {
8
- if (!queryParams) {
9
- return [];
10
- }
11
- const {
12
- name,
13
- sort,
14
- sortDirection,
15
- exact,
16
- role,
17
- ids,
18
- status,
19
- include
20
- } = queryParams;
21
- return [name, sort, sortDirection, exact, role, ids, status, include];
7
+ // otherwise produce a wrong return type which should trigger compilation error
8
+
9
+ /** Typecheck that all query params are included in the query key */
10
+ function getQueryKey(queryParams, params) {
11
+ return params.map(param => queryParams[param]);
12
+ }
13
+ const getQueryKeyFromCredentialListQueryParams = (queryParams = {}) => {
14
+ return getQueryKey(queryParams, ['page', 'pageSize', 'organisationId', 'name', 'searchText', 'searchType', 'sort', 'sortDirection', 'exact', 'role', 'ids', 'status', 'include', 'profile']);
22
15
  };
23
16
  exports.getQueryKeyFromCredentialListQueryParams = getQueryKeyFromCredentialListQueryParams;
24
- const getQueryKeyFromHistoryListQueryParams = queryParams => {
25
- if (!queryParams) {
26
- return [];
27
- }
28
- const {
29
- entityId,
30
- actions,
31
- entityTypes,
32
- createdDateFrom,
33
- createdDateTo,
34
- identifierId,
35
- credentialId,
36
- credentialSchemaId,
37
- searchText,
38
- searchType,
39
- proofSchemaId
40
- } = queryParams;
41
- return [entityId, actions, entityTypes, createdDateFrom, createdDateTo, identifierId, credentialId, credentialSchemaId, searchText, searchType, proofSchemaId];
17
+ const getQueryKeyFromHistoryListQueryParams = (queryParams = {}) => {
18
+ return getQueryKey(queryParams, ['page', 'pageSize', 'organisationId', 'entityId', 'actions', 'entityTypes', 'createdDateFrom', 'createdDateTo', 'identifierId', 'credentialId', 'credentialSchemaId', 'proofSchemaId', 'searchText', 'searchType']);
42
19
  };
43
20
  exports.getQueryKeyFromHistoryListQueryParams = getQueryKeyFromHistoryListQueryParams;
44
- const getQueryKeyFromCredentialSchemaListQueryParams = queryParams => {
45
- if (!queryParams) {
46
- return [];
47
- }
48
- const {
49
- name,
50
- sort,
51
- sortDirection,
52
- exact,
53
- ids,
54
- include
55
- } = queryParams;
56
- return [name, sort, sortDirection, exact, ids, include];
21
+ const getQueryKeyFromCredentialSchemaListQueryParams = (queryParams = {}) => {
22
+ return getQueryKey(queryParams, ['page', 'pageSize', 'organisationId', 'name', 'sort', 'sortDirection', 'exact', 'ids', 'include', 'schemaId', 'formats']);
57
23
  };
58
24
  exports.getQueryKeyFromCredentialSchemaListQueryParams = getQueryKeyFromCredentialSchemaListQueryParams;
59
- const getQueryKeyFromProofSchemaListQueryParams = queryParams => {
60
- if (!queryParams) {
61
- return [];
62
- }
63
- const {
64
- name,
65
- sort,
66
- sortDirection,
67
- exact,
68
- ids
69
- } = queryParams;
70
- return [name, sort, sortDirection, exact, ids];
25
+ const getQueryKeyFromProofSchemaListQueryParams = (queryParams = {}) => {
26
+ return getQueryKey(queryParams, ['page', 'pageSize', 'organisationId', 'name', 'sort', 'sortDirection', 'exact', 'ids', 'formats']);
71
27
  };
72
28
  exports.getQueryKeyFromProofSchemaListQueryParams = getQueryKeyFromProofSchemaListQueryParams;
73
- const getQueryKeyFromProofListQueryParams = queryParams => {
74
- if (!queryParams) {
75
- return [];
76
- }
77
- const {
78
- name,
79
- sort,
80
- sortDirection,
81
- exact,
82
- ids,
83
- proofStates,
84
- proofSchemaIds
85
- } = queryParams;
86
- return [name, sort, sortDirection, exact, ids, proofStates, proofSchemaIds];
29
+ const getQueryKeyFromProofListQueryParams = (queryParams = {}) => {
30
+ return getQueryKey(queryParams, ['page', 'pageSize', 'organisationId', 'sort', 'sortDirection', 'name', 'ids', 'proofStates', 'proofRoles', 'proofSchemaIds', 'exact', 'profile']);
87
31
  };
88
32
  exports.getQueryKeyFromProofListQueryParams = getQueryKeyFromProofListQueryParams;
89
- const getQueryKeyFromDidListQueryParams = queryParams => {
90
- if (!queryParams) {
91
- return [];
92
- }
93
- const {
94
- name,
95
- did,
96
- type,
97
- deactivated,
98
- keyAlgorithms,
99
- keyRoles
100
- } = queryParams;
101
- return [name, did, type, deactivated, keyAlgorithms, keyRoles];
33
+ const getQueryKeyFromDidListQueryParams = (queryParams = {}) => {
34
+ return getQueryKey(queryParams, ['page', 'pageSize', 'organisationId', 'sort', 'sortDirection', 'name', 'did', 'type', 'deactivated', 'exact', 'keyAlgorithms', 'keyRoles', 'keyStorages', 'keyIds', 'didMethods']);
102
35
  };
103
36
  exports.getQueryKeyFromDidListQueryParams = getQueryKeyFromDidListQueryParams;
104
- const getQueryKeyFromIdentifierListQueryParams = queryParams => {
105
- if (!queryParams) {
106
- return [];
107
- }
108
- const {
109
- isRemote,
110
- didMethods,
111
- state,
112
- keyStorages,
113
- keyAlgorithms,
114
- exact,
115
- keyRoles,
116
- types,
117
- name
118
- } = queryParams;
119
- return [name, types, state, isRemote, didMethods, keyStorages, keyAlgorithms, exact, keyRoles];
37
+ const getQueryKeyFromIdentifierListQueryParams = (queryParams = {}) => {
38
+ return getQueryKey(queryParams, ['page', 'pageSize', 'organisationId', 'sort', 'sortDirection', 'name', 'types', 'state', 'exact', 'didMethods', 'isRemote', 'keyAlgorithms', 'keyRoles', 'keyStorages']);
120
39
  };
121
40
  exports.getQueryKeyFromIdentifierListQueryParams = getQueryKeyFromIdentifierListQueryParams;
122
41
  //# sourceMappingURL=query.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getQueryKeyFromCredentialListQueryParams","queryParams","name","sort","sortDirection","exact","role","ids","status","include","exports","getQueryKeyFromHistoryListQueryParams","entityId","actions","entityTypes","createdDateFrom","createdDateTo","identifierId","credentialId","credentialSchemaId","searchText","searchType","proofSchemaId","getQueryKeyFromCredentialSchemaListQueryParams","getQueryKeyFromProofSchemaListQueryParams","getQueryKeyFromProofListQueryParams","proofStates","proofSchemaIds","getQueryKeyFromDidListQueryParams","did","type","deactivated","keyAlgorithms","keyRoles","getQueryKeyFromIdentifierListQueryParams","isRemote","didMethods","state","keyStorages","types"],"sources":["query.tsx"],"sourcesContent":["import {\n CredentialListQuery,\n CredentialSchemaListQuery,\n DidListQuery,\n HistoryListQuery,\n IdentifierListQuery,\n ProofListQuery,\n ProofSchemaListQuery,\n} from '@procivis/react-native-one-core';\n\nexport const getQueryKeyFromCredentialListQueryParams = (queryParams?: Partial<CredentialListQuery>) => {\n if (!queryParams) {\n return [];\n }\n const { name, sort, sortDirection, exact, role, ids, status, include } = queryParams;\n return [name, sort, sortDirection, exact, role, ids, status, include];\n};\n\nexport const getQueryKeyFromHistoryListQueryParams = (queryParams?: Partial<HistoryListQuery>) => {\n if (!queryParams) {\n return [];\n }\n\n const {\n entityId,\n actions,\n entityTypes,\n createdDateFrom,\n createdDateTo,\n identifierId,\n credentialId,\n credentialSchemaId,\n searchText,\n searchType,\n proofSchemaId,\n } = queryParams;\n return [\n entityId,\n actions,\n entityTypes,\n createdDateFrom,\n createdDateTo,\n identifierId,\n credentialId,\n credentialSchemaId,\n searchText,\n searchType,\n proofSchemaId,\n ];\n};\n\nexport const getQueryKeyFromCredentialSchemaListQueryParams = (queryParams?: Partial<CredentialSchemaListQuery>) => {\n if (!queryParams) {\n return [];\n }\n const { name, sort, sortDirection, exact, ids, include } = queryParams;\n return [name, sort, sortDirection, exact, ids, include];\n};\n\nexport const getQueryKeyFromProofSchemaListQueryParams = (queryParams?: Partial<ProofSchemaListQuery>) => {\n if (!queryParams) {\n return [];\n }\n const { name, sort, sortDirection, exact, ids } = queryParams;\n return [name, sort, sortDirection, exact, ids];\n};\n\nexport const getQueryKeyFromProofListQueryParams = (queryParams?: Partial<ProofListQuery>) => {\n if (!queryParams) {\n return [];\n }\n const { name, sort, sortDirection, exact, ids, proofStates, proofSchemaIds } = queryParams;\n return [name, sort, sortDirection, exact, ids, proofStates, proofSchemaIds];\n};\n\nexport const getQueryKeyFromDidListQueryParams = (queryParams?: Partial<DidListQuery>) => {\n if (!queryParams) {\n return [];\n }\n\n const { name, did, type, deactivated, keyAlgorithms, keyRoles } = queryParams;\n return [name, did, type, deactivated, keyAlgorithms, keyRoles];\n};\n\nexport const getQueryKeyFromIdentifierListQueryParams = (queryParams?: Partial<IdentifierListQuery>) => {\n if (!queryParams) {\n return [];\n }\n\n const { isRemote, didMethods, state, keyStorages, keyAlgorithms, exact, keyRoles, types, name } = queryParams;\n return [name, types, state, isRemote, didMethods, keyStorages, keyAlgorithms, exact, keyRoles];\n};\n"],"mappings":";;;;;;AAUO,MAAMA,wCAAwC,GAAIC,WAA0C,IAAK;EACtG,IAAI,CAACA,WAAW,EAAE;IAChB,OAAO,EAAE;EACX;EACA,MAAM;IAAEC,IAAI;IAAEC,IAAI;IAAEC,aAAa;IAAEC,KAAK;IAAEC,IAAI;IAAEC,GAAG;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGR,WAAW;EACpF,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,aAAa,EAAEC,KAAK,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,CAAC;AACvE,CAAC;AAACC,OAAA,CAAAV,wCAAA,GAAAA,wCAAA;AAEK,MAAMW,qCAAqC,GAAIV,WAAuC,IAAK;EAChG,IAAI,CAACA,WAAW,EAAE;IAChB,OAAO,EAAE;EACX;EAEA,MAAM;IACJW,QAAQ;IACRC,OAAO;IACPC,WAAW;IACXC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,kBAAkB;IAClBC,UAAU;IACVC,UAAU;IACVC;EACF,CAA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Ac,CAAC;AAC7E,CAAC;AAACjB,OAAA,CAAAe,mCAAA,GAAAA,mCAAA;AAEK,MAAMG,iCAAiC,GAAI3B,WAAmC,IAAK;EACxF,IAAI,CAACA,WAAW,EAAE;IAChB,OAAO,EAAE;EACX;EAEA,MAAM;IAAEC,IAAI;IAAE2B,GAAG;IAAEC,IAAI;IAAEC,WAAW;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGhC,WAAW;EAC7E,OAAO,CAACC,IAAI,EAAE2B,GAAG,EAAEC,IAAI,EAAEC,WAAW,EAAEC,aAAa,EAAEC,QAAQ,CAAC;AAChE,CAAC;AAACvB,OAAA,CAAAkB,iCAAA,GAAAA,iCAAA;AAEK,MAAMM,wCAAwC,GAAIjC,WAA0C,IAAK;EACtG,IAAI,CAACA,WAAW,EAAE;IAChB,OAAO,EAAE;EACX;EAEA,MAAM;IAAEkC,QAAQ;IAAEC,UAAU;IAAEC,KAAK;IAAEC,WAAW;IAAEN,aAAa;IAAE3B,KAAK;IAAE4B,QAAQ;IAAEM,KAAK;IAAErC;EAAK,CAAC,GAAGD,WAAW;EAC7G,OAAO,CAACC,IAAI,EAAEqC,KAAK,EAAEF,KAAK,EAAEF,QAAQ,EAAEC,UAAU,EAAEE,WAAW,EAAEN,aAAa,EAAE3B,KAAK,EAAE4B,QAAQ,CAAC;AAChG,CAAC;AAACvB,OAAA,CAAAwB,wCAAA,GAAAA,wCAAA","ignoreList":[]}
1
+ {"version":3,"names":["getQueryKey","queryParams","params","map","param","getQueryKeyFromCredentialListQueryParams","exports","getQueryKeyFromHistoryListQueryParams","getQueryKeyFromCredentialSchemaListQueryParams","getQueryKeyFromProofSchemaListQueryParams","getQueryKeyFromProofListQueryParams","getQueryKeyFromDidListQueryParams","getQueryKeyFromIdentifierListQueryParams"],"sources":["query.ts"],"sourcesContent":["import {\n CredentialListQuery,\n CredentialSchemaListQuery,\n DidListQuery,\n HistoryListQuery,\n IdentifierListQuery,\n ProofListQuery,\n ProofSchemaListQuery,\n} from '@procivis/react-native-one-core';\n\ntype QueryKey<ListQuery, ParamList> = ParamList extends ReadonlyArray<keyof ListQuery> // all params are inside the ListQuery\n ? keyof ListQuery extends ParamList[number] // all ListQuery fields are in the params\n ? Array<ListQuery[keyof ListQuery]>\n : void\n : void; // otherwise produce a wrong return type which should trigger compilation error\n\n/** Typecheck that all query params are included in the query key */\nfunction getQueryKey<ListQuery extends {}, ParamList extends ReadonlyArray<keyof ListQuery>>(\n queryParams: ListQuery,\n params: ParamList,\n): QueryKey<ListQuery, ParamList> {\n return params.map((param) => queryParams[param]) as QueryKey<ListQuery, ParamList>;\n}\n\nexport const getQueryKeyFromCredentialListQueryParams = (queryParams: Partial<CredentialListQuery> = {}) => {\n return getQueryKey(queryParams, [\n 'page',\n 'pageSize',\n 'organisationId',\n 'name',\n 'searchText',\n 'searchType',\n 'sort',\n 'sortDirection',\n 'exact',\n 'role',\n 'ids',\n 'status',\n 'include',\n 'profile',\n ]);\n};\n\nexport const getQueryKeyFromHistoryListQueryParams = (queryParams: Partial<HistoryListQuery> = {}) => {\n return getQueryKey(queryParams, [\n 'page',\n 'pageSize',\n 'organisationId',\n 'entityId',\n 'actions',\n 'entityTypes',\n 'createdDateFrom',\n 'createdDateTo',\n 'identifierId',\n 'credentialId',\n 'credentialSchemaId',\n 'proofSchemaId',\n 'searchText',\n 'searchType',\n ]);\n};\n\nexport const getQueryKeyFromCredentialSchemaListQueryParams = (\n queryParams: Partial<CredentialSchemaListQuery> = {},\n) => {\n return getQueryKey(queryParams, [\n 'page',\n 'pageSize',\n 'organisationId',\n 'name',\n 'sort',\n 'sortDirection',\n 'exact',\n 'ids',\n 'include',\n 'schemaId',\n 'formats',\n ]);\n};\n\nexport const getQueryKeyFromProofSchemaListQueryParams = (queryParams: Partial<ProofSchemaListQuery> = {}) => {\n return getQueryKey(queryParams, [\n 'page',\n 'pageSize',\n 'organisationId',\n 'name',\n 'sort',\n 'sortDirection',\n 'exact',\n 'ids',\n 'formats',\n ]);\n};\n\nexport const getQueryKeyFromProofListQueryParams = (queryParams: Partial<ProofListQuery> = {}) => {\n return getQueryKey(queryParams, [\n 'page',\n 'pageSize',\n 'organisationId',\n 'sort',\n 'sortDirection',\n 'name',\n 'ids',\n 'proofStates',\n 'proofRoles',\n 'proofSchemaIds',\n 'exact',\n 'profile',\n ]);\n};\n\nexport const getQueryKeyFromDidListQueryParams = (queryParams: Partial<DidListQuery> = {}) => {\n return getQueryKey(queryParams, [\n 'page',\n 'pageSize',\n 'organisationId',\n 'sort',\n 'sortDirection',\n 'name',\n 'did',\n 'type',\n 'deactivated',\n 'exact',\n 'keyAlgorithms',\n 'keyRoles',\n 'keyStorages',\n 'keyIds',\n 'didMethods',\n ]);\n};\n\nexport const getQueryKeyFromIdentifierListQueryParams = (queryParams: Partial<IdentifierListQuery> = {}) => {\n return getQueryKey(queryParams, [\n 'page',\n 'pageSize',\n 'organisationId',\n 'sort',\n 'sortDirection',\n 'name',\n 'types',\n 'state',\n 'exact',\n 'didMethods',\n 'isRemote',\n 'keyAlgorithms',\n 'keyRoles',\n 'keyStorages',\n ]);\n};\n"],"mappings":";;;;;;AAcU;;AAEV;AACA,SAASA,WAAWA,CAClBC,WAAsB,EACtBC,MAAiB,EACe;EAChC,OAAOA,MAAM,CAACC,GAAG,CAAEC,KAAK,IAAKH,WAAW,CAACG,KAAK,CAAC,CAAC;AAClD;AAEO,MAAMC,wCAAwC,GAAGA,CAACJ,WAAyC,GAAG,CAAC,CAAC,KAAK;EAC1G,OAAOD,WAAW,CAACC,WAAW,EAAE,CAC9B,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,eAAe,EACf,OAAO,EACP,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,CACV,CAAC;AACJ,CAAC;AAACK,OAAA,CAAAD,wCAAA,GAAAA,wCAAA;AAEK,MAAME,qCAAqC,GAAGA,CAACN,WAAsC,GAAG,C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AAOD,WAAW,CAACC,WAAW,EAAE,CAC9B,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,eAAe,EACf,MAAM,EACN,KAAK,EACL,MAAM,EACN,aAAa,EACb,OAAO,EACP,eAAe,EACf,UAAU,EACV,aAAa,EACb,QAAQ,EACR,YAAY,CACb,CAAC;AACJ,CAAC;AAACK,OAAA,CAAAK,iCAAA,GAAAA,iCAAA;AAEK,MAAMC,wCAAwC,GAAGA,CAACX,WAAyC,GAAG,CAAC,CAAC,KAAK;EAC1G,OAAOD,WAAW,CAACC,WAAW,EAAE,CAC9B,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,eAAe,EACf,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACV,eAAe,EACf,UAAU,EACV,aAAa,CACd,CAAC;AACJ,CAAC;AAACK,OAAA,CAAAM,wCAAA,GAAAA,wCAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { TrustEntityRoleEnum, TrustEntityStateEnum } from '@procivis/react-native-one-core';
1
+ import { IdentifierTypeEnum, TrustEntityRoleEnum, TrustEntityStateEnum } from '@procivis/react-native-one-core';
2
2
  import React, { useMemo } from 'react';
3
3
  import EntityCluster from '../../ui-components/entity/entity-cluster';
4
4
  import { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';
@@ -40,7 +40,7 @@ const EntityDetails = ({
40
40
  uri: trustEntity.logo
41
41
  }
42
42
  } : undefined;
43
- const placeholderText = (identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === 'CERTIFICATE' && (_identifierDetail$cer = identifierDetail.certificates) !== null && _identifierDetail$cer !== void 0 && _identifierDetail$cer[0] ? (_getCertificateCommon = getCertificateCommonName(identifierDetail.certificates[0])) === null || _getCertificateCommon === void 0 ? void 0 : _getCertificateCommon.substring(0, 1) : 'D';
43
+ const placeholderText = (identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === IdentifierTypeEnum.CERTIFICATE && (_identifierDetail$cer = identifierDetail.certificates) !== null && _identifierDetail$cer !== void 0 && _identifierDetail$cer[0] ? (_getCertificateCommon = getCertificateCommonName(identifierDetail.certificates[0])) === null || _getCertificateCommon === void 0 ? void 0 : _getCertificateCommon.substring(0, 1) : 'D';
44
44
  const statusIcon = trusted ? /*#__PURE__*/React.createElement(EntityTrustedIcon, {
45
45
  testID: concatTestID(testID, 'statusIcon', 'trusted')
46
46
  }) : /*#__PURE__*/React.createElement(EntityNotTrustedIcon, {
@@ -64,7 +64,7 @@ const EntityDetails = ({
64
64
  if (isLoading) {
65
65
  return '';
66
66
  }
67
- if ((identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === 'CERTIFICATE' && (_identifierDetail$cer2 = identifierDetail.certificates) !== null && _identifierDetail$cer2 !== void 0 && _identifierDetail$cer2[0]) {
67
+ if ((identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === IdentifierTypeEnum.CERTIFICATE && (_identifierDetail$cer2 = identifierDetail.certificates) !== null && _identifierDetail$cer2 !== void 0 && _identifierDetail$cer2[0]) {
68
68
  const commonName = getCertificateCommonName(identifierDetail.certificates[0]);
69
69
  if (commonName) {
70
70
  return commonName;
@@ -1 +1 @@
1
- {"version":3,"names":["TrustEntityRoleEnum","TrustEntityStateEnum","React","useMemo","EntityCluster","EntityNotTrustedIcon","EntityTrustedIcon","concatTestID","replaceBreakingHyphens","useIdentifierDetails","useTrustEntity","getCertificateCommonName","certificate","_certificate$x509Attr","x509Attributes","subject","split","find","s","startsWith","pop","EntityDetails","labels","renderMore","role","style","testID","sublineColor","textColor","props","_props$identifier","_props$identifier2","data","isLoading","isLoadingTrustEntity","identifier","id","undefined","trustEntity","entity","identifierDetail","isLoadingIdentifier","trusted","state","ACTIVE","BOTH","avatarProps","_identifierDetail$cer","_getCertificateCommon","avatar","type","logo","imageSource","uri","placeholderText","certificates","substring","statusIcon","createElement","name","trustEntityName","_identifierDetail$cer2","_identifierDetail$did","commonName","did","unknown","Fragment","entityName"],"sources":["entity-details.tsx"],"sourcesContent":["import { IdentifierCertificateDetail, IdentifierListItem,TrustEntity, TrustEntityRoleEnum, TrustEntityStateEnum } from '@procivis/react-native-one-core';\nimport React, { FC, ReactNode, useMemo } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { AvatarProps } from '../../ui-components';\nimport EntityCluster from '../../ui-components/entity/entity-cluster';\nimport { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';\nimport { concatTestID, replaceBreakingHyphens, useIdentifierDetails } from '../../utils';\nimport { useTrustEntity } from '../../utils/hooks/core/trust-entity';\n\nexport type EntityDetailsLabels = {\n unknown: string;\n};\n\nexport type EntityDetailsProps = {\n labels: EntityDetailsLabels;\n renderMore?: (trustEntity: TrustEntity) => ReactNode;\n role: Exclude<TrustEntityRoleEnum, TrustEntityRoleEnum.BOTH>;\n style?: StyleProp<ViewStyle>;\n sublineColor?: string;\n textColor?: string;\n testID?: string;\n} & (\n | {\n identifier?: IdentifierListItem;\n }\n | {\n entity: TrustEntity;\n }\n );\n\nconst getCertificateCommonName = (certificate: IdentifierCertificateDetail): string | undefined => {\n return certificate.x509Attributes.subject.split(', ').find((s) => s.startsWith('CN'))?.split('=')?.pop();\n}\n\nconst EntityDetails: FC<EntityDetailsProps> = ({ labels, renderMore, role, style, testID, sublineColor, textColor, ...props }) => {\n const { data, isLoading: isLoadingTrustEntity } = useTrustEntity('identifier' in props ? props.identifier?.id : undefined);\n const trustEntity: TrustEntity | undefined = 'entity' in props ? props.entity : data ?? undefined;\n const { data: identifierDetail, isLoading: isLoadingIdentifier } = useIdentifierDetails('identifier' in props ? props.identifier?.id : undefined);\n\n const trusted =\n trustEntity &&\n trustEntity.state === TrustEntityStateEnum.ACTIVE &&\n (trustEntity.role === TrustEntityRoleEnum.BOTH || trustEntity.role === role);\n\n const isLoading = isLoadingIdentifier || isLoadingTrustEntity;\n\n const avatarProps: AvatarProps | undefined = useMemo(() => {\n if (isLoading) {\n return undefined;\n }\n\n const avatar = trusted && identifierDetail?.type === 'DID' && trustEntity.logo ? { imageSource: { uri: trustEntity.logo } } : undefined;\n\n const placeholderText = identifierDetail?.type === 'CERTIFICATE' && identifierDetail.certificates?.[0] ? getCertificateCommonName(identifierDetail.certificates[0])?.substring(0, 1) : 'D';\n\n const statusIcon = trusted ? \n <EntityTrustedIcon testID={concatTestID(testID, 'statusIcon', 'trusted')} /> :\n <EntityNotTrustedIcon testID={concatTestID(testID, 'statusIcon', 'notTrusted')} />;\n\n if (trustEntity) {\n return {\n avatar,\n placeholderText: trusted && identifierDetail?.type === 'DID' ? trustEntity.name.substring(0, 1) : placeholderText,\n statusIcon,\n testID: concatTestID(testID, 'avatar'),\n };\n }\n\n return {\n placeholderText,\n statusIcon,\n }\n }, [trustEntity, trusted, identifierDetail, isLoading, testID]);\n\n const trustEntityName = useMemo(() => {\n if (isLoading) {\n return '';\n }\n if (identifierDetail?.type === 'CERTIFICATE' && identifierDetail.certificates?.[0]) {\n const commonName = getCertificateCommonName(identifierDetail.certificates[0]);\n if (commonName) {\n return commonName;\n }\n }\n if (trustEntity) {\n return trustEntity.name;\n }\n if (identifierDetail?.did?.did) {\n return replaceBreakingHyphens(identifierDetail.did.did);\n }\n\n return labels.unknown;\n }, [labels.unknown, trustEntity, identifierDetail, isLoading]);\n\n return (\n <>\n <EntityCluster\n avatar={avatarProps}\n entityName={trustEntityName}\n style={style}\n testID={testID}\n textColor={textColor}\n sublineColor={sublineColor}\n isLoading={isLoading}\n />\n {trustEntity && renderMore && renderMore(trustEntity)}\n </>\n );\n};\n\nexport default EntityDetails;\n"],"mappings":"AAAA,SAAsEA,mBAAmB,EAAEC,oBAAoB,QAAQ,iCAAiC;AACxJ,OAAOC,KAAK,IAAmBC,OAAO,QAAQ,OAAO;AAIrD,OAAOC,aAAa,MAAM,2CAA2C;AACrE,SAASC,oBAAoB,EAAEC,iBAAiB,QAAQ,2B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;IAEA,OAAO1C,MAAM,CAAC2C,OAAO;EACvB,CAAC,EAAE,CAAC3C,MAAM,CAAC2C,OAAO,EAAE3B,WAAW,EAAEE,gBAAgB,EAAEP,SAAS,CAAC,CAAC;EAE9D,oBACE/B,KAAA,CAAAwD,aAAA,CAAAxD,KAAA,CAAAgE,QAAA,qBACEhE,KAAA,CAAAwD,aAAA,CAACtD,aAAa;IACZ6C,MAAM,EAAEH,WAAY;IACpBqB,UAAU,EAAEP,eAAgB;IAC5BnC,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfE,SAAS,EAAEA,SAAU;IACrBD,YAAY,EAAEA,YAAa;IAC3BM,SAAS,EAAEA;EAAU,CACtB,CAAC,EACDK,WAAW,IAAIf,UAAU,IAAIA,UAAU,CAACe,WAAW,CACpD,CAAC;AAEP,CAAC;AAED,eAAejB,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["IdentifierTypeEnum","TrustEntityRoleEnum","TrustEntityStateEnum","React","useMemo","EntityCluster","EntityNotTrustedIcon","EntityTrustedIcon","concatTestID","replaceBreakingHyphens","useIdentifierDetails","useTrustEntity","getCertificateCommonName","certificate","_certificate$x509Attr","x509Attributes","subject","split","find","s","startsWith","pop","EntityDetails","labels","renderMore","role","style","testID","sublineColor","textColor","props","_props$identifier","_props$identifier2","data","isLoading","isLoadingTrustEntity","identifier","id","undefined","trustEntity","entity","identifierDetail","isLoadingIdentifier","trusted","state","ACTIVE","BOTH","avatarProps","_identifierDetail$cer","_getCertificateCommon","avatar","type","logo","imageSource","uri","placeholderText","CERTIFICATE","certificates","substring","statusIcon","createElement","name","trustEntityName","_identifierDetail$cer2","_identifierDetail$did","commonName","did","unknown","Fragment","entityName"],"sources":["entity-details.tsx"],"sourcesContent":["import {\n IdentifierCertificateDetail,\n IdentifierListItem,\n IdentifierTypeEnum,\n TrustEntity,\n TrustEntityRoleEnum,\n TrustEntityStateEnum,\n} from '@procivis/react-native-one-core';\nimport React, { FC, ReactNode, useMemo } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\n\nimport { AvatarProps } from '../../ui-components';\nimport EntityCluster from '../../ui-components/entity/entity-cluster';\nimport { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';\nimport { concatTestID, replaceBreakingHyphens, useIdentifierDetails } from '../../utils';\nimport { useTrustEntity } from '../../utils/hooks/core/trust-entity';\n\nexport type EntityDetailsLabels = {\n unknown: string;\n};\n\nexport type EntityDetailsProps = {\n labels: EntityDetailsLabels;\n renderMore?: (trustEntity: TrustEntity) => ReactNode;\n role: Exclude<TrustEntityRoleEnum, TrustEntityRoleEnum.BOTH>;\n style?: StyleProp<ViewStyle>;\n sublineColor?: string;\n textColor?: string;\n testID?: string;\n} & (\n | {\n identifier?: IdentifierListItem;\n }\n | {\n entity: TrustEntity;\n }\n);\n\nconst getCertificateCommonName = (certificate: IdentifierCertificateDetail): string | undefined => {\n return certificate.x509Attributes.subject\n .split(', ')\n .find((s) => s.startsWith('CN'))\n ?.split('=')\n ?.pop();\n};\n\nconst EntityDetails: FC<EntityDetailsProps> = ({\n labels,\n renderMore,\n role,\n style,\n testID,\n sublineColor,\n textColor,\n ...props\n}) => {\n const { data, isLoading: isLoadingTrustEntity } = useTrustEntity(\n 'identifier' in props ? props.identifier?.id : undefined,\n );\n const trustEntity: TrustEntity | undefined = 'entity' in props ? props.entity : data ?? undefined;\n const { data: identifierDetail, isLoading: isLoadingIdentifier } = useIdentifierDetails(\n 'identifier' in props ? props.identifier?.id : undefined,\n );\n\n const trusted =\n trustEntity &&\n trustEntity.state === TrustEntityStateEnum.ACTIVE &&\n (trustEntity.role === TrustEntityRoleEnum.BOTH || trustEntity.role === role);\n\n const isLoading = isLoadingIdentifier || isLoadingTrustEntity;\n\n const avatarProps: AvatarProps | undefined = useMemo(() => {\n if (isLoading) {\n return undefined;\n }\n\n const avatar =\n trusted && identifierDetail?.type === 'DID' && trustEntity.logo\n ? { imageSource: { uri: trustEntity.logo } }\n : undefined;\n\n const placeholderText =\n identifierDetail?.type === IdentifierTypeEnum.CERTIFICATE && identifierDetail.certificates?.[0]\n ? getCertificateCommonName(identifierDetail.certificates[0])?.substring(0, 1)\n : 'D';\n\n const statusIcon = trusted ? (\n <EntityTrustedIcon testID={concatTestID(testID, 'statusIcon', 'trusted')} />\n ) : (\n <EntityNotTrustedIcon testID={concatTestID(testID, 'statusIcon', 'notTrusted')} />\n );\n\n if (trustEntity) {\n return {\n avatar,\n placeholderText:\n trusted && identifierDetail?.type === 'DID' ? trustEntity.name.substring(0, 1) : placeholderText,\n statusIcon,\n testID: concatTestID(testID, 'avatar'),\n };\n }\n\n return {\n placeholderText,\n statusIcon,\n };\n }, [trustEntity, trusted, identifierDetail, isLoading, testID]);\n\n const trustEntityName = useMemo(() => {\n if (isLoading) {\n return '';\n }\n if (identifierDetail?.type === IdentifierTypeEnum.CERTIFICATE && identifierDetail.certificates?.[0]) {\n const commonName = getCertificateCommonName(identifierDetail.certificates[0]);\n if (commonName) {\n return commonName;\n }\n }\n if (trustEntity) {\n return trustEntity.name;\n }\n if (identifierDetail?.did?.did) {\n return replaceBreakingHyphens(identifierDetail.did.did);\n }\n\n return labels.unknown;\n }, [labels.unknown, trustEntity, identifierDetail, isLoading]);\n\n return (\n <>\n <EntityCluster\n avatar={avatarProps}\n entityName={trustEntityName}\n style={style}\n testID={testID}\n textColor={textColor}\n sublineColor={sublineColor}\n isLoading={isLoading}\n />\n {trustEntity && renderMore && renderMore(trustEntity)}\n </>\n );\n};\n\nexport default EntityDetails;\n"],"mappings":"AAAA,SAGEA,kBAAkB,EAElBC,mBAAmB,EACnBC,oBAAoB,QACf,iCAAiC;AACxC,OAAOC,KAAK,IAAmBC,OAAO,QAAQ,OAAO;AAIrD,OAAOC,aAAa,MAAM,2CAA2C;AACrE,SAASC,oBAAoB,EAAEC,iBAAiB,QAAQ,2BAA2B;AACnF,SAASC,YAAY,EAAEC,sBAAsB,EAAEC,oBAAoB,QAAQ,aAAa;AACxF,SAASC,c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,MAAM,CAAC4C,OAAO,EAAE5B,WAAW,EAAEE,gBAAgB,EAAEP,SAAS,CAAC,CAAC;EAE9D,oBACE/B,KAAA,CAAAyD,aAAA,CAAAzD,KAAA,CAAAiE,QAAA,qBACEjE,KAAA,CAAAyD,aAAA,CAACvD,aAAa;IACZ6C,MAAM,EAAEH,WAAY;IACpBsB,UAAU,EAAEP,eAAgB;IAC5BpC,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfE,SAAS,EAAEA,SAAU;IACrBD,YAAY,EAAEA,YAAa;IAC3BM,SAAS,EAAEA;EAAU,CACtB,CAAC,EACDK,WAAW,IAAIf,UAAU,IAAIA,UAAU,CAACe,WAAW,CACpD,CAAC;AAEP,CAAC;AAED,eAAejB,aAAa","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { OneError } from '@procivis/react-native-one-core';
1
+ import { IdentifierTypeEnum, OneError } from '@procivis/react-native-one-core';
2
2
  import { useCallback } from 'react';
3
3
  import { useMutation, useQuery, useQueryClient } from 'react-query';
4
4
  import { reportException } from '../../reporting';
@@ -46,11 +46,12 @@ export const useTrustEntity = identifierId => {
46
46
  var _identifierDetail$cer;
47
47
  return identifierId && identifierDetail ? core.resolveTrustEntityByIdentifier({
48
48
  identifiers: [{
49
- certificateId: identifierDetail.type === 'CERTIFICATE' ? (_identifierDetail$cer = identifierDetail.certificates) === null || _identifierDetail$cer === void 0 || (_identifierDetail$cer = _identifierDetail$cer[0]) === null || _identifierDetail$cer === void 0 ? void 0 : _identifierDetail$cer.id : undefined,
49
+ certificateId: (identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === IdentifierTypeEnum.CERTIFICATE ? (_identifierDetail$cer = identifierDetail.certificates) === null || _identifierDetail$cer === void 0 || (_identifierDetail$cer = _identifierDetail$cer[0]) === null || _identifierDetail$cer === void 0 ? void 0 : _identifierDetail$cer.id : undefined,
50
50
  id: identifierId
51
51
  }]
52
52
  }).then(result => {
53
- return result[identifierId];
53
+ var _result$identifierId$, _result$identifierId;
54
+ return (_result$identifierId$ = (_result$identifierId = result[identifierId]) === null || _result$identifierId === void 0 || (_result$identifierId = _result$identifierId[0]) === null || _result$identifierId === void 0 ? void 0 : _result$identifierId.trustEntity) !== null && _result$identifierId$ !== void 0 ? _result$identifierId$ : null;
54
55
  }).catch(e => {
55
56
  if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
56
57
  return null;