@procivis/one-react-native-components 0.3.121 → 0.3.132
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.
- package/lib/commonjs/components/credential/credential.js +2 -1
- package/lib/commonjs/components/credential/credential.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item-icon.js +3 -3
- package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item.js +5 -12
- package/lib/commonjs/components/history/history-list-item.js.map +1 -1
- package/lib/commonjs/components/history/history-list-screen.js +1 -1
- package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
- package/lib/commonjs/components/index.js +0 -11
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/select-credential.js +2 -1
- package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/share-credential.js +2 -1
- package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js +2 -1
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js +3 -1
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js +7 -3
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js +3 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
- package/lib/commonjs/ui-components/header/header.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-details.js +2 -2
- package/lib/commonjs/ui-components/history/history-details.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-section-list-item.js +2 -2
- package/lib/commonjs/ui-components/history/history-section-list-item.js.map +1 -1
- package/lib/commonjs/ui-components/history/index.js +0 -8
- package/lib/commonjs/ui-components/history/index.js.map +1 -1
- package/lib/commonjs/ui-components/icons/contact.js.map +1 -1
- package/lib/commonjs/ui-components/icons/credential.js +3 -3
- package/lib/commonjs/ui-components/icons/credential.js.map +1 -1
- package/lib/commonjs/ui-components/icons/icons.js +20 -1
- package/lib/commonjs/ui-components/icons/icons.js.map +1 -1
- package/lib/commonjs/ui-components/list/index.js +8 -0
- package/lib/commonjs/ui-components/list/index.js.map +1 -1
- package/lib/commonjs/ui-components/{history/history-item.js → list/list-item.js} +32 -22
- package/lib/commonjs/ui-components/list/list-item.js.map +1 -0
- package/lib/commonjs/ui-components/loader/loading-result.js +2 -0
- package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
- package/lib/commonjs/ui-components/screens/nerd-mode-screen.js +7 -33
- package/lib/commonjs/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/commonjs/utils/date.js +4 -5
- package/lib/commonjs/utils/date.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/cache.js +7 -4
- package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-config.js +1 -6
- package/lib/commonjs/utils/hooks/core/core-config.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-context.js +0 -15
- package/lib/commonjs/utils/hooks/core/core-context.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +15 -1
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/index.js +0 -11
- package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-list.js +19 -3
- package/lib/commonjs/utils/hooks/core/trust-list.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/verifier-instance.js +22 -3
- package/lib/commonjs/utils/hooks/core/verifier-instance.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/wallet-unit.js +2 -2
- package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js +23 -18
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js +20 -18
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +36 -22
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +2 -2
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/commonjs/utils/translations.js +15 -0
- package/lib/commonjs/utils/translations.js.map +1 -0
- package/lib/module/components/credential/credential.js +2 -1
- package/lib/module/components/credential/credential.js.map +1 -1
- package/lib/module/components/history/history-list-item-icon.js +3 -3
- package/lib/module/components/history/history-list-item-icon.js.map +1 -1
- package/lib/module/components/history/history-list-item.js +7 -14
- package/lib/module/components/history/history-list-item.js.map +1 -1
- package/lib/module/components/history/history-list-screen.js +1 -1
- package/lib/module/components/history/history-list-screen.js.map +1 -1
- package/lib/module/components/index.js +0 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/proof-request/v1/select-credential.js +2 -1
- package/lib/module/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/module/components/proof-request/v1/share-credential.js +2 -1
- package/lib/module/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/module/components/proof-request/v2/select-credential-v2.js +2 -1
- package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -1
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js +3 -1
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
- package/lib/module/components/proof-request/v2/share-credential-v2.js +7 -3
- package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/module/ui-components/credential/card/credential-details-card.js +3 -1
- package/lib/module/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/module/ui-components/header/foldable-header.js.map +1 -1
- package/lib/module/ui-components/header/header.js.map +1 -1
- package/lib/module/ui-components/history/history-details.js +3 -3
- package/lib/module/ui-components/history/history-details.js.map +1 -1
- package/lib/module/ui-components/history/history-section-list-item.js +2 -2
- package/lib/module/ui-components/history/history-section-list-item.js.map +1 -1
- package/lib/module/ui-components/history/index.js +0 -2
- package/lib/module/ui-components/history/index.js.map +1 -1
- package/lib/module/ui-components/icons/contact.js.map +1 -1
- package/lib/module/ui-components/icons/credential.js +1 -1
- package/lib/module/ui-components/icons/credential.js.map +1 -1
- package/lib/module/ui-components/icons/icons.js +18 -0
- package/lib/module/ui-components/icons/icons.js.map +1 -1
- package/lib/module/ui-components/list/index.js +2 -0
- package/lib/module/ui-components/list/index.js.map +1 -1
- package/lib/module/ui-components/{history/history-item.js → list/list-item.js} +32 -22
- package/lib/module/ui-components/list/list-item.js.map +1 -0
- package/lib/module/ui-components/loader/loading-result.js +2 -0
- package/lib/module/ui-components/loader/loading-result.js.map +1 -1
- package/lib/module/ui-components/screens/nerd-mode-screen.js +7 -33
- package/lib/module/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/module/utils/date.js +4 -5
- package/lib/module/utils/date.js.map +1 -1
- package/lib/module/utils/hooks/core/cache.js +7 -4
- package/lib/module/utils/hooks/core/cache.js.map +1 -1
- package/lib/module/utils/hooks/core/core-config.js +0 -4
- package/lib/module/utils/hooks/core/core-config.js.map +1 -1
- package/lib/module/utils/hooks/core/core-context.js +0 -15
- package/lib/module/utils/hooks/core/core-context.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +13 -0
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/index.js +0 -1
- package/lib/module/utils/hooks/core/index.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-list.js +20 -4
- package/lib/module/utils/hooks/core/trust-list.js.map +1 -1
- package/lib/module/utils/hooks/core/verifier-instance.js +20 -2
- package/lib/module/utils/hooks/core/verifier-instance.js.map +1 -1
- package/lib/module/utils/hooks/core/wallet-unit.js +2 -2
- package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing-v2.js +24 -19
- package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing.js +20 -18
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +37 -23
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/query.js +2 -2
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/module/utils/translations.js +8 -0
- package/lib/module/utils/translations.js.map +1 -0
- package/lib/typescript/components/credential/credential.d.ts +1 -0
- package/lib/typescript/components/history/history-list-item.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +0 -1
- package/lib/typescript/components/proof-request/v1/select-credential.d.ts +1 -0
- package/lib/typescript/components/proof-request/v1/share-credential.d.ts +1 -0
- package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +1 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +1 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +1 -0
- package/lib/typescript/ui-components/history/history-details.d.ts +2 -2
- package/lib/typescript/ui-components/history/history-section-list-item.d.ts +2 -2
- package/lib/typescript/ui-components/history/index.d.ts +0 -3
- package/lib/typescript/ui-components/icons/credential.d.ts +1 -1
- package/lib/typescript/ui-components/icons/icons.d.ts +1 -0
- package/lib/typescript/ui-components/list/index.d.ts +3 -0
- package/lib/typescript/ui-components/{history/history-item.d.ts → list/list-item.d.ts} +4 -4
- package/lib/typescript/ui-components/screens/nerd-mode-screen.d.ts +0 -12
- package/lib/typescript/utils/hooks/core/core-config.d.ts +0 -1
- package/lib/typescript/utils/hooks/core/core-context.d.ts +0 -1
- package/lib/typescript/utils/hooks/core/credentials.d.ts +1 -0
- package/lib/typescript/utils/hooks/core/index.d.ts +0 -1
- package/lib/typescript/utils/hooks/core/trust-list.d.ts +1 -4
- package/lib/typescript/utils/hooks/core/verifier-instance.d.ts +2 -0
- package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +2 -2
- package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +3 -3
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +6 -6
- package/lib/typescript/utils/parsers/credential.d.ts +5 -5
- package/lib/typescript/utils/parsers/query.d.ts +2 -2
- package/lib/typescript/utils/translations.d.ts +1 -0
- package/package.json +3 -3
- package/src/components/credential/credential.tsx +3 -0
- package/src/components/history/history-list-item-icon.tsx +2 -2
- package/src/components/history/history-list-item.tsx +7 -12
- package/src/components/history/history-list-screen.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/components/proof-request/v1/select-credential.tsx +3 -1
- package/src/components/proof-request/v1/share-credential.tsx +3 -0
- package/src/components/proof-request/v2/select-credential-v2.tsx +3 -1
- package/src/components/proof-request/v2/share-credential-v2-group.tsx +4 -0
- package/src/components/proof-request/v2/share-credential-v2.tsx +7 -0
- package/src/ui-components/credential/card/credential-details-card.tsx +3 -2
- package/src/ui-components/header/foldable-header.tsx +10 -9
- package/src/ui-components/header/header.tsx +10 -1
- package/src/ui-components/history/history-details.tsx +4 -4
- package/src/ui-components/history/history-section-list-item.tsx +3 -3
- package/src/ui-components/history/index.ts +0 -3
- package/src/ui-components/icons/contact.tsx +1 -1
- package/src/ui-components/icons/credential.tsx +1 -1
- package/src/ui-components/icons/icons.tsx +18 -0
- package/src/ui-components/list/index.ts +3 -0
- package/src/ui-components/{history/history-item.tsx → list/list-item.tsx} +36 -33
- package/src/ui-components/loader/loading-result.tsx +7 -1
- package/src/ui-components/screens/nerd-mode-screen.tsx +2 -52
- package/src/utils/date.ts +7 -14
- package/src/utils/hooks/core/cache.ts +10 -3
- package/src/utils/hooks/core/core-config.ts +1 -6
- package/src/utils/hooks/core/core-context.tsx +0 -24
- package/src/utils/hooks/core/credentials.ts +13 -0
- package/src/utils/hooks/core/index.ts +0 -1
- package/src/utils/hooks/core/trust-list.ts +22 -11
- package/src/utils/hooks/core/verifier-instance.ts +23 -2
- package/src/utils/hooks/core/wallet-unit.ts +3 -3
- package/src/utils/parsers/credential-sharing-v2.tsx +34 -14
- package/src/utils/parsers/credential-sharing.tsx +33 -16
- package/src/utils/parsers/credential.ts +45 -14
- package/src/utils/parsers/query.ts +5 -0
- package/src/utils/translations.ts +10 -0
- package/lib/commonjs/components/entity/EntityButtons.js +0 -64
- package/lib/commonjs/components/entity/EntityButtons.js.map +0 -1
- package/lib/commonjs/components/entity/entity-attributes.js +0 -65
- package/lib/commonjs/components/entity/entity-attributes.js.map +0 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +0 -67
- package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +0 -1
- package/lib/commonjs/components/entity/entity-details.js +0 -101
- package/lib/commonjs/components/entity/entity-details.js.map +0 -1
- package/lib/commonjs/components/entity/index.js +0 -14
- package/lib/commonjs/components/entity/index.js.map +0 -1
- package/lib/commonjs/ui-components/history/history-item.js.map +0 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js +0 -147
- package/lib/commonjs/utils/hooks/core/trust-entity.js.map +0 -1
- package/lib/module/components/entity/EntityButtons.js +0 -56
- package/lib/module/components/entity/EntityButtons.js.map +0 -1
- package/lib/module/components/entity/entity-attributes.js +0 -57
- package/lib/module/components/entity/entity-attributes.js.map +0 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +0 -58
- package/lib/module/components/entity/entity-details-with-buttons.js.map +0 -1
- package/lib/module/components/entity/entity-details.js +0 -92
- package/lib/module/components/entity/entity-details.js.map +0 -1
- package/lib/module/components/entity/index.js +0 -3
- package/lib/module/components/entity/index.js.map +0 -1
- package/lib/module/ui-components/history/history-item.js.map +0 -1
- package/lib/module/utils/hooks/core/trust-entity.js +0 -136
- package/lib/module/utils/hooks/core/trust-entity.js.map +0 -1
- package/lib/typescript/components/entity/EntityButtons.d.ts +0 -14
- package/lib/typescript/components/entity/entity-attributes.d.ts +0 -15
- package/lib/typescript/components/entity/entity-details-with-buttons.d.ts +0 -18
- package/lib/typescript/components/entity/entity-details.d.ts +0 -21
- package/lib/typescript/components/entity/index.d.ts +0 -3
- package/lib/typescript/utils/hooks/core/trust-entity.d.ts +0 -17
- package/src/components/entity/EntityButtons.tsx +0 -79
- package/src/components/entity/entity-attributes.tsx +0 -80
- package/src/components/entity/entity-details-with-buttons.tsx +0 -75
- package/src/components/entity/entity-details.tsx +0 -145
- package/src/components/entity/index.ts +0 -4
- package/src/utils/hooks/core/trust-entity.ts +0 -172
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","useState","SectionList","StyleSheet","View","Animated","useAnimatedScrollHandler","useSharedValue","useSafeAreaInsets","TrustInfo","EntityDetailsWithButtons","ContrastingStatusBar","concatTestID","TouchableOpacity","SectionEntityCluster","NavigationHeader","CloseIcon","NerdModeItem","Typography","useAppColorScheme","EntityType","isSectionEntityCluster","item","identifier","undefined","AnimatedSectionList","createAnimatedComponent","NerdModeScreen","sections","labels","onClose","onCopyToClipboard","onOpenTrustInfoDetails","entityCluster","testID","title","insets","colorScheme","scrollOffset","expandedAttributes","setExpandedAttributes","onExpand","expanded","prev","onScroll","contentOffset","value","y","lastElementsForSection","reduce","acc","sectionTitle","data","lastElement","length","attributeKey","listHeader","_entityCluster$testID2","_entityCluster$trustI","legacyTrustManagementEnabled","_entityCluster$testID","createElement","_extends","entityType","ProofEntity","entityLabels","attributesLabels","style","styles","backgroundColor","nerdView","background","textColor","white","trustInfoLabels","onPress","trustInformation","eudiEcosystem","Fragment","leftItem","color","paddingTop","top","titleColor","ListHeaderComponent","renderItem","section","index","_item$testID","_item$testID2","_item$trustInformatio","CredentialEntity","toString","last","renderSectionHeader","sectionHeaderContainer","sectionHeaderText","scrollEventThrottle","stickySectionHeadersEnabled","create","paddingHorizontal","paddingVertical","justifyContent","marginTop","opacity"],"sources":["nerd-mode-screen.tsx"],"sourcesContent":["import { IdentifierListItem, TrustInformationDetail } from '@procivis/react-native-one-core';\nimport React, { FunctionComponent, useMemo, useState } from 'react';\nimport { SectionList, StyleSheet, View } from 'react-native';\nimport Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { TrustInfo, TrustInfoLabels } from '../../components';\nimport EntityDetailsWithButtons, { ContextRole } from '../../components/entity/entity-details-with-buttons';\nimport ContrastingStatusBar from '../../utils/contrasting-status-bar';\nimport { concatTestID } from '../../utils/testID';\nimport { TouchableOpacity } from '../accessibility/accessibilityHistoryWrappers';\nimport SectionEntityCluster from '../entity/entity-cluster';\nimport NavigationHeader from '../header/navigation-header';\nimport { CloseIcon } from '../icons/icons';\nimport NerdModeItem, { NerdModeItemProps } from '../nerd-view/nerd-mode-item';\nimport Typography from '../text/typography';\nimport { useAppColorScheme } from '../theme/color-scheme-context';\n\nexport interface EntityLabels {\n trusted: string;\n unknownIssuer: string;\n unknownVerifier: string;\n visitWebsite: string;\n termsAndServices: string;\n privacyPolicy: string;\n}\n\nexport interface AttributesLabels {\n trustRegistry: string;\n issuerIdentifier: string;\n entityIdentifier: string;\n role: string;\n expand: string;\n collapse: string;\n}\n\ninterface SectionEntityCluster {\n identifier?: IdentifierListItem;\n subline?: string;\n entityLabels: EntityLabels;\n legacyTrustManagementEnabled: boolean;\n role: ContextRole;\n testID?: string;\n trustInfoLabels: TrustInfoLabels;\n trustInformation?: TrustInformationDetail;\n}\n\ntype SectionAttribute = Omit<NerdModeItemProps, 'labels' | 'onCopyToClipboard'>;\n\ntype NerdModeSectionItem = SectionAttribute | SectionEntityCluster;\n\nexport type NerdModeSection = {\n data: NerdModeSectionItem[];\n title?: string;\n};\n\nexport type NerdModeScreenProps = {\n entityCluster?: SectionEntityCluster;\n labels: AttributesLabels;\n onClose: () => void;\n onCopyToClipboard: (value: string) => void;\n onOpenTrustInfoDetails?: (trustInformation: TrustInformationDetail) => void;\n sections: NerdModeSection[];\n testID: string;\n title: string;\n};\n\nexport enum EntityType {\n CredentialEntity,\n ProofEntity,\n}\n\nfunction isSectionEntityCluster(item: NerdModeSectionItem): item is SectionEntityCluster {\n return (item as SectionEntityCluster).identifier !== undefined;\n}\n\nconst AnimatedSectionList = Animated.createAnimatedComponent(SectionList<NerdModeSectionItem>);\n\nconst NerdModeScreen: FunctionComponent<NerdModeScreenProps> = ({\n sections,\n labels,\n onClose,\n onCopyToClipboard,\n onOpenTrustInfoDetails,\n entityCluster,\n testID,\n title,\n}) => {\n const insets = useSafeAreaInsets();\n const colorScheme = useAppColorScheme();\n const scrollOffset = useSharedValue(0);\n const [expandedAttributes, setExpandedAttributes] = useState(0);\n\n // This is a bit of a hack. It's used to notify attributes that another attribute has been expanded\n // which will allow them to update their scroll offset accordingly.\n const onExpand = (expanded: boolean) => {\n setExpandedAttributes((prev) => (expanded ? prev + 1 : prev - 1));\n };\n\n const onScroll = useAnimatedScrollHandler({\n onScroll: ({ contentOffset }) => {\n scrollOffset.value = contentOffset.y;\n },\n });\n\n const lastElementsForSection = sections.reduce((acc, { title: sectionTitle = '', data }) => {\n const lastElement = data[data.length - 1];\n return {\n ...acc,\n [sectionTitle]: lastElement && !isSectionEntityCluster(lastElement) ? lastElement.attributeKey : '',\n };\n }, {} as Record<string, string>);\n\n const listHeader = useMemo(() => {\n if (!entityCluster) {\n return null;\n }\n if (entityCluster.legacyTrustManagementEnabled) {\n return (\n <EntityDetailsWithButtons\n {...entityCluster}\n entityType={EntityType.ProofEntity}\n entityLabels={entityCluster.entityLabels}\n attributesLabels={labels}\n style={[\n styles.entityCluster,\n {\n backgroundColor: colorScheme.nerdView.background,\n },\n ]}\n onCopyToClipboard={onCopyToClipboard}\n testID={entityCluster.testID ?? concatTestID(testID, 'entityCluster')}\n textColor={colorScheme.white}\n />\n );\n }\n return (\n <TrustInfo\n labels={entityCluster.trustInfoLabels}\n onPress={\n onOpenTrustInfoDetails && entityCluster.trustInformation\n ? () => onOpenTrustInfoDetails(entityCluster.trustInformation!)\n : undefined\n }\n style={[\n styles.entityCluster,\n {\n backgroundColor: colorScheme.nerdView.background,\n },\n ]}\n testID={entityCluster.testID ?? concatTestID(testID, 'trustInfo')}\n textColor={colorScheme.white}\n trustInformation={entityCluster.trustInformation?.eudiEcosystem}\n />\n );\n }, [\n entityCluster,\n colorScheme.nerdView.background,\n colorScheme.white,\n labels,\n onCopyToClipboard,\n onOpenTrustInfoDetails,\n testID,\n ]);\n\n return (\n <>\n <ContrastingStatusBar backgroundColor={colorScheme.nerdView.background} />\n <NavigationHeader\n leftItem={\n <TouchableOpacity onPress={onClose} testID={concatTestID(testID, 'closeIcon')}>\n <CloseIcon color={colorScheme.white} />\n </TouchableOpacity>\n }\n style={{\n backgroundColor: colorScheme.nerdView.background,\n paddingTop: insets.top,\n }}\n title={title}\n titleColor={colorScheme.white}\n />\n <AnimatedSectionList\n ListHeaderComponent={listHeader}\n onScroll={onScroll}\n renderItem={({ item, section, index }) => {\n if (isSectionEntityCluster(item)) {\n return item.legacyTrustManagementEnabled ? (\n <EntityDetailsWithButtons\n {...item}\n entityType={EntityType.CredentialEntity}\n entityLabels={item!.entityLabels}\n attributesLabels={labels}\n style={[\n styles.entityCluster,\n {\n backgroundColor: colorScheme.nerdView.background,\n },\n ]}\n onCopyToClipboard={onCopyToClipboard}\n testID={item.testID ?? concatTestID(testID, 'sectionEntityCluster', index.toString())}\n textColor={colorScheme.white}\n />\n ) : (\n <TrustInfo\n labels={item.trustInfoLabels}\n onPress={\n onOpenTrustInfoDetails && item.trustInformation\n ? () => onOpenTrustInfoDetails(item.trustInformation!)\n : undefined\n }\n style={[\n styles.entityCluster,\n {\n backgroundColor: colorScheme.nerdView.background,\n },\n ]}\n testID={item.testID ?? concatTestID(testID, 'trustInfo')}\n textColor={colorScheme.white}\n trustInformation={item.trustInformation?.eudiEcosystem}\n />\n );\n } else {\n return (\n <NerdModeItem\n {...item}\n expandedAttributes={expandedAttributes}\n labels={labels}\n last={lastElementsForSection[section.title] === item.attributeKey}\n onCopyToClipboard={onCopyToClipboard}\n onExpand={onExpand}\n scrollOffset={scrollOffset}\n testID={concatTestID(testID, item.testID)}\n />\n );\n }\n }}\n renderSectionHeader={({ section }) => {\n return section.title ? (\n <View style={styles.sectionHeaderContainer} testID={concatTestID(testID, section.title)}>\n <Typography color={colorScheme.white} style={styles.sectionHeaderText}>\n {section.title}\n </Typography>\n </View>\n ) : null;\n }}\n scrollEventThrottle={16}\n sections={sections}\n stickySectionHeadersEnabled={false}\n style={{ backgroundColor: colorScheme.nerdView.background }}\n testID={testID}\n />\n </>\n );\n};\n\nconst styles = StyleSheet.create({\n entityCluster: {\n paddingHorizontal: 24,\n paddingVertical: 20,\n },\n sectionHeaderContainer: {\n justifyContent: 'center',\n marginTop: 20,\n paddingVertical: 16,\n },\n sectionHeaderText: {\n opacity: 0.7,\n paddingHorizontal: 20,\n },\n});\n\nexport default NerdModeScreen;\n"],"mappings":";AACA,OAAOA,KAAK,IAAuBC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,WAAW,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC5D,OAAOC,QAAQ,IAAIC,wBAAwB,EAAEC,cAAc,QAAQ,yBAAyB;AAC5F,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,SAASC,SAAS,QAAyB,kBAAkB;AAC7D,OAAOC,wBAAwB,MAAuB,qDAAqD;AAC3G,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,gBAAgB,QAAQ,+CAA+C;AAChF,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,OAAOC,YAAY,MAA6B,6BAA6B;AAC7E,OAAOC,UAAU,MAAM,oBAAoB;AAC3C,SAASC,iBAAiB,QAAQ,+BAA+B;AAmDjE,WAAYC,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAA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E;IACbmE,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE;EACnB,CAAC;EACDN,sBAAsB,EAAE;IACtBO,cAAc,EAAE,QAAQ;IACxBC,SAAS,EAAE,EAAE;IACbF,eAAe,EAAE;EACnB,CAAC;EACDL,iBAAiB,EAAE;IACjBQ,OAAO,EAAE,GAAG;IACZJ,iBAAiB,EAAE;EACrB;AACF,CAAC,CAAC;AAEF,eAAezE,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useMemo","useState","SectionList","StyleSheet","View","Animated","useAnimatedScrollHandler","useSharedValue","useSafeAreaInsets","TrustInfo","ContrastingStatusBar","concatTestID","TouchableOpacity","SectionEntityCluster","NavigationHeader","CloseIcon","NerdModeItem","Typography","useAppColorScheme","EntityType","isSectionEntityCluster","item","identifier","undefined","AnimatedSectionList","createAnimatedComponent","NerdModeScreen","sections","labels","onClose","onCopyToClipboard","onOpenTrustInfoDetails","entityCluster","testID","title","insets","colorScheme","scrollOffset","expandedAttributes","setExpandedAttributes","onExpand","expanded","prev","onScroll","contentOffset","value","y","lastElementsForSection","reduce","acc","sectionTitle","data","lastElement","length","attributeKey","listHeader","_entityCluster$testID","_entityCluster$trustI","createElement","trustInfoLabels","onPress","trustInformation","style","styles","backgroundColor","nerdView","background","textColor","white","eudiEcosystem","Fragment","leftItem","color","paddingTop","top","titleColor","ListHeaderComponent","renderItem","section","_item$testID","_item$trustInformatio","_extends","last","renderSectionHeader","sectionHeaderContainer","sectionHeaderText","scrollEventThrottle","stickySectionHeadersEnabled","create","paddingHorizontal","paddingVertical","justifyContent","marginTop","opacity"],"sources":["nerd-mode-screen.tsx"],"sourcesContent":["import { IdentifierListItem, TrustInformationDetail } from '@procivis/react-native-one-core';\nimport React, { FunctionComponent, useMemo, useState } from 'react';\nimport { SectionList, StyleSheet, View } from 'react-native';\nimport Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { TrustInfo, TrustInfoLabels } from '../../components';\nimport ContrastingStatusBar from '../../utils/contrasting-status-bar';\nimport { concatTestID } from '../../utils/testID';\nimport { TouchableOpacity } from '../accessibility/accessibilityHistoryWrappers';\nimport SectionEntityCluster from '../entity/entity-cluster';\nimport NavigationHeader from '../header/navigation-header';\nimport { CloseIcon } from '../icons/icons';\nimport NerdModeItem, { NerdModeItemProps } from '../nerd-view/nerd-mode-item';\nimport Typography from '../text/typography';\nimport { useAppColorScheme } from '../theme/color-scheme-context';\n\nexport interface AttributesLabels {\n trustRegistry: string;\n issuerIdentifier: string;\n entityIdentifier: string;\n role: string;\n expand: string;\n collapse: string;\n}\n\ninterface SectionEntityCluster {\n identifier?: IdentifierListItem;\n subline?: string;\n testID?: string;\n trustInfoLabels: TrustInfoLabels;\n trustInformation?: TrustInformationDetail;\n}\n\ntype SectionAttribute = Omit<NerdModeItemProps, 'labels' | 'onCopyToClipboard'>;\n\ntype NerdModeSectionItem = SectionAttribute | SectionEntityCluster;\n\nexport type NerdModeSection = {\n data: NerdModeSectionItem[];\n title?: string;\n};\n\nexport type NerdModeScreenProps = {\n entityCluster?: SectionEntityCluster;\n labels: AttributesLabels;\n onClose: () => void;\n onCopyToClipboard: (value: string) => void;\n onOpenTrustInfoDetails?: (trustInformation: TrustInformationDetail) => void;\n sections: NerdModeSection[];\n testID: string;\n title: string;\n};\n\nexport enum EntityType {\n CredentialEntity,\n ProofEntity,\n}\n\nfunction isSectionEntityCluster(item: NerdModeSectionItem): item is SectionEntityCluster {\n return (item as SectionEntityCluster).identifier !== undefined;\n}\n\nconst AnimatedSectionList = Animated.createAnimatedComponent(SectionList<NerdModeSectionItem>);\n\nconst NerdModeScreen: FunctionComponent<NerdModeScreenProps> = ({\n sections,\n labels,\n onClose,\n onCopyToClipboard,\n onOpenTrustInfoDetails,\n entityCluster,\n testID,\n title,\n}) => {\n const insets = useSafeAreaInsets();\n const colorScheme = useAppColorScheme();\n const scrollOffset = useSharedValue(0);\n const [expandedAttributes, setExpandedAttributes] = useState(0);\n\n // This is a bit of a hack. It's used to notify attributes that another attribute has been expanded\n // which will allow them to update their scroll offset accordingly.\n const onExpand = (expanded: boolean) => {\n setExpandedAttributes((prev) => (expanded ? prev + 1 : prev - 1));\n };\n\n const onScroll = useAnimatedScrollHandler({\n onScroll: ({ contentOffset }) => {\n scrollOffset.value = contentOffset.y;\n },\n });\n\n const lastElementsForSection = sections.reduce((acc, { title: sectionTitle = '', data }) => {\n const lastElement = data[data.length - 1];\n return {\n ...acc,\n [sectionTitle]: lastElement && !isSectionEntityCluster(lastElement) ? lastElement.attributeKey : '',\n };\n }, {} as Record<string, string>);\n\n const listHeader = useMemo(() => {\n if (!entityCluster) {\n return null;\n }\n return (\n <TrustInfo\n labels={entityCluster.trustInfoLabels}\n onPress={\n onOpenTrustInfoDetails && entityCluster.trustInformation\n ? () => onOpenTrustInfoDetails(entityCluster.trustInformation!)\n : undefined\n }\n style={[\n styles.entityCluster,\n {\n backgroundColor: colorScheme.nerdView.background,\n },\n ]}\n testID={entityCluster.testID ?? concatTestID(testID, 'trustInfo')}\n textColor={colorScheme.white}\n trustInformation={entityCluster.trustInformation?.eudiEcosystem}\n />\n );\n }, [\n entityCluster,\n colorScheme.nerdView.background,\n colorScheme.white,\n onOpenTrustInfoDetails,\n testID,\n ]);\n\n return (\n <>\n <ContrastingStatusBar backgroundColor={colorScheme.nerdView.background} />\n <NavigationHeader\n leftItem={\n <TouchableOpacity onPress={onClose} testID={concatTestID(testID, 'closeIcon')}>\n <CloseIcon color={colorScheme.white} />\n </TouchableOpacity>\n }\n style={{\n backgroundColor: colorScheme.nerdView.background,\n paddingTop: insets.top,\n }}\n title={title}\n titleColor={colorScheme.white}\n />\n <AnimatedSectionList\n ListHeaderComponent={listHeader}\n onScroll={onScroll}\n renderItem={({ item, section }) => {\n if (isSectionEntityCluster(item)) {\n return (\n <TrustInfo\n labels={item.trustInfoLabels}\n onPress={\n onOpenTrustInfoDetails && item.trustInformation\n ? () => onOpenTrustInfoDetails(item.trustInformation!)\n : undefined\n }\n style={[\n styles.entityCluster,\n {\n backgroundColor: colorScheme.nerdView.background,\n },\n ]}\n testID={item.testID ?? concatTestID(testID, 'trustInfo')}\n textColor={colorScheme.white}\n trustInformation={item.trustInformation?.eudiEcosystem}\n />\n );\n } else {\n return (\n <NerdModeItem\n {...item}\n expandedAttributes={expandedAttributes}\n labels={labels}\n last={lastElementsForSection[section.title] === item.attributeKey}\n onCopyToClipboard={onCopyToClipboard}\n onExpand={onExpand}\n scrollOffset={scrollOffset}\n testID={concatTestID(testID, item.testID)}\n />\n );\n }\n }}\n renderSectionHeader={({ section }) => {\n return section.title ? (\n <View style={styles.sectionHeaderContainer} testID={concatTestID(testID, section.title)}>\n <Typography color={colorScheme.white} style={styles.sectionHeaderText}>\n {section.title}\n </Typography>\n </View>\n ) : null;\n }}\n scrollEventThrottle={16}\n sections={sections}\n stickySectionHeadersEnabled={false}\n style={{ backgroundColor: colorScheme.nerdView.background }}\n testID={testID}\n />\n </>\n );\n};\n\nconst styles = StyleSheet.create({\n entityCluster: {\n paddingHorizontal: 24,\n paddingVertical: 20,\n },\n sectionHeaderContainer: {\n justifyContent: 'center',\n marginTop: 20,\n paddingVertical: 16,\n },\n sectionHeaderText: {\n opacity: 0.7,\n paddingHorizontal: 20,\n },\n});\n\nexport default NerdModeScreen;\n"],"mappings":";AACA,OAAOA,KAAK,IAAuBC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,WAAW,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC5D,OAAOC,QAAQ,IAAIC,wBAAwB,EAAEC,cAAc,QAAQ,yBAAyB;AAC5F,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,SAASC,SAAS,QAAyB,kBAAkB;AAC7D,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,gBAAgB,QAAQ,+CAA+C;AAChF,OAAOC,oBAAo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V,CAAE;IACFoD,mBAAmB,EAAE,EAAG;IACxB3D,QAAQ,EAAEA,QAAS;IACnB4D,2BAA2B,EAAE,KAAM;IACnCzB,KAAK,EAAE;MAAEE,eAAe,EAAE5B,WAAW,CAAC6B,QAAQ,CAACC;IAAW,CAAE;IAC5DjC,MAAM,EAAEA;EAAO,CAChB,CACD,CAAC;AAEP,CAAC;AAED,MAAM8B,MAAM,GAAG5D,UAAU,CAACqF,MAAM,CAAC;EAC/BxD,aAAa,EAAE;IACbyD,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE;EACnB,CAAC;EACDN,sBAAsB,EAAE;IACtBO,cAAc,EAAE,QAAQ;IACxBC,SAAS,EAAE,EAAE;IACbF,eAAe,EAAE;EACnB,CAAC;EACDL,iBAAiB,EAAE;IACjBQ,OAAO,EAAE,GAAG;IACZJ,iBAAiB,EAAE;EACrB;AACF,CAAC,CAAC;AAEF,eAAe/D,cAAc","ignoreList":[]}
|
package/lib/module/utils/date.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _ref;
|
|
2
2
|
// Date & Time formatted as specified in SW-610
|
|
3
3
|
|
|
4
4
|
import { I18nManager, Platform, Settings } from 'react-native';
|
|
@@ -7,7 +7,7 @@ const MINUTE = 60 * 1000;
|
|
|
7
7
|
const DAY = 24 * 60 * MINUTE;
|
|
8
8
|
|
|
9
9
|
// OS locale
|
|
10
|
-
const systemLocale = (
|
|
10
|
+
const systemLocale = (_ref = Platform.OS === 'ios' ? Settings.get('AppleLocale') : I18nManager.getConstants().localeIdentifier) === null || _ref === void 0 || (_ref = _ref.match(/[a-zA-Z]+_[a-zA-Z]+/)[0]) === null || _ref === void 0 ? void 0 : _ref.replaceAll('_', '-');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Date only format
|
|
@@ -129,11 +129,10 @@ export const formatDateOnlyFromUTCTimestamp = utcTimestamp => {
|
|
|
129
129
|
const utcDate = new Date(utcTimestamp);
|
|
130
130
|
return (_formatDate = formatDate(convertDateStrToLocalDate(`${utcDate.getUTCFullYear()}-${pad(utcDate.getUTCMonth() + 1)}-${pad(utcDate.getUTCDate())}`))) !== null && _formatDate !== void 0 ? _formatDate : '';
|
|
131
131
|
};
|
|
132
|
-
const locale = (_ref = Platform.OS === 'ios' ? Settings.get('AppleLocale') : I18nManager.getConstants().localeIdentifier) === null || _ref === void 0 ? void 0 : _ref.split('@')[0].replace('_', '-');
|
|
133
132
|
export const formatDateTimeLocalized = date => {
|
|
134
|
-
return formatDateTime(date,
|
|
133
|
+
return formatDateTime(date, systemLocale);
|
|
135
134
|
};
|
|
136
135
|
export const formatDateLocalized = date => {
|
|
137
|
-
return formatDate(date,
|
|
136
|
+
return formatDate(date, systemLocale);
|
|
138
137
|
};
|
|
139
138
|
//# sourceMappingURL=date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["I18nManager","Platform","Settings","format","MINUTE","DAY","systemLocale","
|
|
1
|
+
{"version":3,"names":["I18nManager","Platform","Settings","format","MINUTE","DAY","systemLocale","_ref","OS","get","getConstants","localeIdentifier","match","replaceAll","formatDate","date","locale","options","toLocaleDateString","undefined","formatTime","toLocaleTimeString","hour","minute","formatDateTime","toLocaleString","year","month","day","hour12","formatMonth","getFullYear","formatTimeAgo","formatTimestamp","nowLabel","_formatDateTime2","now","Date","timestamp","getTime","_formatDateTime","pad","x","String","convertDateToUTCTimestamp","parse","getMonth","getDate","convertDateStrToLocalDate","select","android","timezoneOffset","getTimezoneOffset","default","formatDateOnlyFromUTCTimestamp","utcTimestamp","_formatDate","utcDate","getUTCFullYear","getUTCMonth","getUTCDate","formatDateTimeLocalized","formatDateLocalized"],"sources":["date.ts"],"sourcesContent":["// Date & Time formatted as specified in SW-610\n\nimport { I18nManager, Platform, Settings } from 'react-native';\nimport { format } from 'timeago.js';\n\nconst MINUTE = 60 * 1000;\nconst DAY = 24 * 60 * MINUTE;\n\n// OS locale\nconst systemLocale: string | undefined = (\n Platform.OS === 'ios' ? Settings.get('AppleLocale') : I18nManager.getConstants().localeIdentifier\n)\n ?.match(/[a-zA-Z]+_[a-zA-Z]+/)[0]\n ?.replaceAll('_', '-');\n\n/**\n * Date only format\n */\nexport const formatDate = (date: Date, locale?: string, options?: Intl.DateTimeFormatOptions) => {\n try {\n return date.toLocaleDateString(locale || systemLocale, options);\n } catch {\n return undefined;\n }\n};\n\n/**\n * Time only format\n */\nexport const formatTime = (date: Date, locale?: string) => {\n try {\n return date.toLocaleTimeString(locale || systemLocale, { hour: '2-digit', minute: '2-digit' });\n } catch {\n return undefined;\n }\n};\n\n/**\n * Date and time format\n */\nexport const formatDateTime = (date: Date, locale?: string) => {\n try {\n return date.toLocaleString(locale || systemLocale, {\n hour: '2-digit',\n minute: '2-digit',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour12: locale === 'en-US',\n });\n } catch {\n return undefined;\n }\n};\n\n/**\n * Month format\n */\nexport const formatMonth = (date: Date, locale: string): string => {\n return `${date.toLocaleString(locale, {\n month: 'long',\n })} ${date.getFullYear()}`;\n};\n\n/**\n * Time-ago format\n */\nexport const formatTimeAgo = (date: Date, locale: string): string => {\n return format(date, locale);\n};\n\n/**\n * Timestamp formatted for general use\n */\nexport const formatTimestamp = (date: Date, locale: string, nowLabel: string): string => {\n const now = Date.now();\n const timestamp = date.getTime();\n if (now < timestamp) {\n // in the future\n return formatDateTime(date, locale) ?? '';\n }\n\n // in the past\n if (now - timestamp < MINUTE) {\n // less than a minute ago\n return nowLabel;\n }\n\n // less than a day ago\n if (now - timestamp < DAY) {\n return formatTimeAgo(date, locale);\n }\n\n // longer ago\n return formatDateTime(date, locale) ?? '';\n};\n\nconst pad = (x: number) => (x >= 0 && x < 10 ? `0${x}` : String(x));\n\n/**\n * Utility function to deal with `date`-type attributes\n * @param {Date} date local timezone representation\n * @returns {number} the same day, but UTC timezone with midnight time\n */\nexport const convertDateToUTCTimestamp = (date: Date): number =>\n Date.parse(`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`);\n\n/**\n * Utility function to deal with `date`-type attributes\n * @param {string} date in YYYY-MM-DD representation\n * @returns {Date} the same day, but local timezone with midnight time\n */\nexport const convertDateStrToLocalDate = (date: string): Date =>\n Platform.select({\n // android conversion using the standard date parsing doesn't work, computing the timestamp manually\n android: (() => {\n const timestamp = Date.parse(date);\n const timezoneOffset = new Date(date).getTimezoneOffset();\n return new Date(timestamp + timezoneOffset * MINUTE);\n })(),\n default: new Date(`${date}T00:00:00`),\n });\n\n/**\n * Inverted function to {@link convertDateToUTCTimestamp}\n * @param {number} utcTimestamp date timestamp represented as midnight UTC time\n * @returns {string} formatted date (based on locale settings, e.g. `21/02/2021`)\n */\nexport const formatDateOnlyFromUTCTimestamp = (utcTimestamp: number): string => {\n const utcDate = new Date(utcTimestamp);\n return (\n formatDate(\n convertDateStrToLocalDate(\n `${utcDate.getUTCFullYear()}-${pad(utcDate.getUTCMonth() + 1)}-${pad(utcDate.getUTCDate())}`,\n ),\n ) ?? ''\n );\n};\n\nexport const formatDateTimeLocalized = (date: Date) => {\n return formatDateTime(date, systemLocale);\n};\n\nexport const formatDateLocalized = (date: Date) => {\n return formatDate(date, systemLocale);\n};\n"],"mappings":";AAAA;;AAEA,SAASA,WAAW,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AAC9D,SAASC,MAAM,QAAQ,YAAY;AAEnC,MAAMC,MAAM,GAAG,EAAE,GAAG,IAAI;AACxB,MAAMC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAGD,MAAM;;AAE5B;AACA,MAAME,YAAgC,IAAAC,IAAA,GACpCN,QAAQ,CAACO,EAAE,KAAK,KAAK,GAAGN,QAAQ,CAACO,GAAG,CAAC,aAAa,CAAC,GAAGT,WAAW,CAACU,YAAY,CAAC,CAAC,CAACC,gBAAgB,cAAAJ,IAAA,gBAAAA,IAAA,GAD1DA,IAAA,CAGrCK,KAAK,CAAC,qBAAqB,CAAC,CAAC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acheType } from '@procivis/react-native-one-core';
|
|
|
2
2
|
import { useMutation, useQueryClient } from 'react-query';
|
|
3
3
|
import { useONECore } from './core-context';
|
|
4
4
|
import { CREDENTIAL_DETAIL_QUERY_KEY, CREDENTIAL_LIST_PAGED_QUERY_KEY, CREDENTIAL_LIST_QUERY_KEY } from './credentials';
|
|
5
|
-
import {
|
|
5
|
+
import { VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY } from './verifier-instance';
|
|
6
|
+
import { WALLET_UNIT_QUERY_KEY, WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY } from './wallet-unit';
|
|
6
7
|
const CREDENTIAL_QUERY_KEYS = [CREDENTIAL_LIST_QUERY_KEY, CREDENTIAL_LIST_PAGED_QUERY_KEY, CREDENTIAL_DETAIL_QUERY_KEY];
|
|
7
|
-
const
|
|
8
|
+
const WALLET_VERIFIER_INSTANCE_QUERY_KEYS = [WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY, WALLET_UNIT_QUERY_KEY, VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY];
|
|
8
9
|
|
|
9
10
|
// Map each CacheType to the query keys that should be invalidated when that cache is cleared.
|
|
10
11
|
const cacheTypeToQueryKeys = {
|
|
@@ -13,11 +14,13 @@ const cacheTypeToQueryKeys = {
|
|
|
13
14
|
[CacheType.STATUS_LIST_CREDENTIAL]: CREDENTIAL_QUERY_KEYS,
|
|
14
15
|
[CacheType.VCT_METADATA]: CREDENTIAL_QUERY_KEYS,
|
|
15
16
|
[CacheType.JSON_SCHEMA]: CREDENTIAL_QUERY_KEYS,
|
|
16
|
-
[CacheType.TRUST_LIST]:
|
|
17
|
+
[CacheType.TRUST_LIST]: CREDENTIAL_QUERY_KEYS,
|
|
17
18
|
[CacheType.X509_CRL]: CREDENTIAL_QUERY_KEYS,
|
|
18
19
|
[CacheType.ANDROID_ATTESTATION_CRL]: CREDENTIAL_QUERY_KEYS,
|
|
19
20
|
[CacheType.OPEN_ID_METADATA_HOLDER]: CREDENTIAL_QUERY_KEYS,
|
|
20
|
-
[CacheType.OPEN_ID_METADATA_ISSUER]: CREDENTIAL_QUERY_KEYS
|
|
21
|
+
[CacheType.OPEN_ID_METADATA_ISSUER]: CREDENTIAL_QUERY_KEYS,
|
|
22
|
+
[CacheType.WALLET_PROVIDER_METADATA]: WALLET_VERIFIER_INSTANCE_QUERY_KEYS,
|
|
23
|
+
[CacheType.REMOTE_TRUST_COLLECTION]: WALLET_VERIFIER_INSTANCE_QUERY_KEYS
|
|
21
24
|
};
|
|
22
25
|
export const useCacheClear = () => {
|
|
23
26
|
const queryClient = useQueryClient();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CacheType","useMutation","useQueryClient","useONECore","CREDENTIAL_DETAIL_QUERY_KEY","CREDENTIAL_LIST_PAGED_QUERY_KEY","CREDENTIAL_LIST_QUERY_KEY","
|
|
1
|
+
{"version":3,"names":["CacheType","useMutation","useQueryClient","useONECore","CREDENTIAL_DETAIL_QUERY_KEY","CREDENTIAL_LIST_PAGED_QUERY_KEY","CREDENTIAL_LIST_QUERY_KEY","VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY","WALLET_UNIT_QUERY_KEY","WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY","CREDENTIAL_QUERY_KEYS","WALLET_VERIFIER_INSTANCE_QUERY_KEYS","cacheTypeToQueryKeys","DID_DOCUMENT","JSON_LD_CONTEXT","STATUS_LIST_CREDENTIAL","VCT_METADATA","JSON_SCHEMA","TRUST_LIST","X509_CRL","ANDROID_ATTESTATION_CRL","OPEN_ID_METADATA_HOLDER","OPEN_ID_METADATA_ISSUER","WALLET_PROVIDER_METADATA","REMOTE_TRUST_COLLECTION","useCacheClear","queryClient","core","cacheTypes","deleteCache","onSuccess","_","queryKeysToInvalidate","Set","forEach","cacheType","keys","key","add","Promise","all","map","queryKey","invalidateQueries"],"sources":["cache.ts"],"sourcesContent":["import { CacheType } from '@procivis/react-native-one-core';\nimport { useMutation, useQueryClient } from 'react-query';\n\nimport { useONECore } from './core-context';\nimport { CREDENTIAL_DETAIL_QUERY_KEY, CREDENTIAL_LIST_PAGED_QUERY_KEY, CREDENTIAL_LIST_QUERY_KEY } from './credentials';\nimport { VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY } from './verifier-instance';\nimport { WALLET_UNIT_QUERY_KEY, WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY } from './wallet-unit';\n\nconst CREDENTIAL_QUERY_KEYS = [CREDENTIAL_LIST_QUERY_KEY, CREDENTIAL_LIST_PAGED_QUERY_KEY, CREDENTIAL_DETAIL_QUERY_KEY];\nconst WALLET_VERIFIER_INSTANCE_QUERY_KEYS = [\n WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY,\n WALLET_UNIT_QUERY_KEY,\n VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY,\n];\n\n// Map each CacheType to the query keys that should be invalidated when that cache is cleared.\nconst cacheTypeToQueryKeys: Record<CacheType, string[]> = {\n [CacheType.DID_DOCUMENT]: CREDENTIAL_QUERY_KEYS,\n [CacheType.JSON_LD_CONTEXT]: CREDENTIAL_QUERY_KEYS,\n [CacheType.STATUS_LIST_CREDENTIAL]: CREDENTIAL_QUERY_KEYS,\n [CacheType.VCT_METADATA]: CREDENTIAL_QUERY_KEYS,\n [CacheType.JSON_SCHEMA]: CREDENTIAL_QUERY_KEYS,\n [CacheType.TRUST_LIST]: CREDENTIAL_QUERY_KEYS,\n [CacheType.X509_CRL]: CREDENTIAL_QUERY_KEYS,\n [CacheType.ANDROID_ATTESTATION_CRL]: CREDENTIAL_QUERY_KEYS,\n [CacheType.OPEN_ID_METADATA_HOLDER]: CREDENTIAL_QUERY_KEYS,\n [CacheType.OPEN_ID_METADATA_ISSUER]: CREDENTIAL_QUERY_KEYS,\n [CacheType.WALLET_PROVIDER_METADATA]: WALLET_VERIFIER_INSTANCE_QUERY_KEYS,\n [CacheType.REMOTE_TRUST_COLLECTION]: WALLET_VERIFIER_INSTANCE_QUERY_KEYS,\n};\n\nexport const useCacheClear = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (cacheTypes: CacheType[]) => {\n await core.deleteCache(cacheTypes);\n return cacheTypes;\n },\n {\n onSuccess: async (_, cacheTypes) => {\n const queryKeysToInvalidate = new Set<string>();\n\n cacheTypes.forEach((cacheType) => {\n const keys = cacheTypeToQueryKeys[cacheType] || [];\n keys.forEach((key) => queryKeysToInvalidate.add(key));\n });\n\n await Promise.all([...queryKeysToInvalidate].map((queryKey) => queryClient.invalidateQueries(queryKey)));\n },\n },\n );\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,iCAAiC;AAC3D,SAASC,WAAW,EAAEC,cAAc,QAAQ,aAAa;AAEzD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,2BAA2B,EAAEC,+BAA+B,EAAEC,yBAAyB,QAAQ,eAAe;AACvH,SAASC,6CAA6C,QAAQ,qBAAqB;AACnF,SAASC,qBAAqB,EAAEC,uCAAuC,QAAQ,eAAe;AAE9F,MAAMC,qBAAqB,GAAG,CAACJ,yBAAyB,EAAED,+BAA+B,EAAED,2BAA2B,CAAC;AACvH,MAAMO,mCAAmC,GAAG,CAC1CF,uCAAuC,EACvCD,qBAAqB,EACrBD,6CAA6C,CAC9C;;AAED;AACA,MAAMK,oBAAiD,GAAG;EACxD,CAACZ,SAAS,CAACa,YAAY,GAAGH,qBAAqB;EAC/C,CAACV,SAAS,CAACc,eAAe,GAAGJ,qBAAqB;EAClD,CAACV,SAAS,CAACe,sBAAsB,GAAGL,qBAAqB;EACzD,CAACV,SAAS,CAACgB,YAAY,GAAGN,qBAAqB;EAC/C,CAACV,SAAS,CAACiB,WAAW,GAAGP,qBAAqB;EAC9C,CAACV,SAAS,CAACkB,UAAU,GAAGR,qBAAqB;EAC7C,CAACV,SAAS,CAACmB,QAAQ,GAAGT,qBAAqB;EAC3C,CAACV,SAAS,CAACoB,uBAAuB,GAAGV,qBAAqB;EAC1D,CAACV,SAAS,CAACqB,uBAAuB,GAAGX,qBAAqB;EAC1D,CAACV,SAAS,CAACsB,uBAAuB,GAAGZ,qBAAqB;EAC1D,CAACV,SAAS,CAACuB,wBAAwB,GAAGZ,mCAAmC;EACzE,CAACX,SAAS,CAACwB,uBAAuB,GAAGb;AACvC,CAAC;AAED,OAAO,MAAMc,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAMC,WAAW,GAAGxB,cAAc,CAAC,CAAC;EACpC,MAAM;IAAEyB;EAAK,CAAC,GAAGxB,UAAU,CAAC,CAAC;EAE7B,OAAOF,WAAW,CAChB,MAAO2B,UAAuB,IAAK;IACjC,MAAMD,IAAI,CAACE,WAAW,CAACD,UAAU,CAAC;IAClC,OAAOA,UAAU;EACnB,CAAC,EACD;IACEE,SAAS,EAAE,MAAAA,CAAOC,CAAC,EAAEH,UAAU,KAAK;MAClC,MAAMI,qBAAqB,GAAG,IAAIC,GAAG,CAAS,CAAC;MAE/CL,UAAU,CAACM,OAAO,CAAEC,SAAS,IAAK;QAChC,MAAMC,IAAI,GAAGxB,oBAAoB,CAACuB,SAAS,CAAC,IAAI,EAAE;QAClDC,IAAI,CAACF,OAAO,CAAEG,GAAG,IAAKL,qBAAqB,CAACM,GAAG,CAACD,GAAG,CAAC,CAAC;MACvD,CAAC,CAAC;MAEF,MAAME,OAAO,CAACC,GAAG,CAAC,CAAC,GAAGR,qBAAqB,CAAC,CAACS,GAAG,CAAEC,QAAQ,IAAKhB,WAAW,CAACiB,iBAAiB,CAACD,QAAQ,CAAC,CAAC,CAAC;IAC1G;EACF,CACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -16,8 +16,4 @@ export const getEnabledTransports = config => {
|
|
|
16
16
|
export const getEnabledExchangeProtocols = exchangeProtocol => {
|
|
17
17
|
return Object.values(exchangeProtocol !== null && exchangeProtocol !== void 0 ? exchangeProtocol : {}).filter(t => t.enabled !== false).map(exchange => exchange.type);
|
|
18
18
|
};
|
|
19
|
-
export const getEnabledTrustManagement = config => {
|
|
20
|
-
var _config$trustManageme;
|
|
21
|
-
return Object.values((_config$trustManageme = config === null || config === void 0 ? void 0 : config.trustManagement) !== null && _config$trustManageme !== void 0 ? _config$trustManageme : {}).filter(t => t.enabled !== false).map(trustManagement => trustManagement.type);
|
|
22
|
-
};
|
|
23
19
|
//# sourceMappingURL=core-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useQuery","useONECore","CONFIG_QUERY_KEY","useCoreConfig","core","getConfig","keepPreviousData","getEnabledTransports","config","_config$transport","Object","values","transport","filter","t","enabled","map","type","getEnabledExchangeProtocols","exchangeProtocol","exchange"
|
|
1
|
+
{"version":3,"names":["useQuery","useONECore","CONFIG_QUERY_KEY","useCoreConfig","core","getConfig","keepPreviousData","getEnabledTransports","config","_config$transport","Object","values","transport","filter","t","enabled","map","type","getEnabledExchangeProtocols","exchangeProtocol","exchange"],"sources":["core-config.ts"],"sourcesContent":["import { ConfigEntities, CoreConfig } from '@procivis/react-native-one-core';\nimport { useQuery } from 'react-query';\n\nimport { useONECore } from './core-context';\n\nconst CONFIG_QUERY_KEY = 'config';\n\nexport const useCoreConfig = () => {\n const { core } = useONECore();\n\n return useQuery([CONFIG_QUERY_KEY], () => core?.getConfig(), {\n keepPreviousData: true,\n });\n};\n\nexport const getEnabledTransports = (config: CoreConfig): string[] => {\n return Object.values(config?.transport ?? {})\n .filter((t) => t.enabled !== false)\n .map((transport) => transport.type);\n};\n\nexport const getEnabledExchangeProtocols = (exchangeProtocol: ConfigEntities<any>): string[] => {\n return Object.values(exchangeProtocol ?? {})\n .filter((t) => t.enabled !== false)\n .map((exchange) => exchange.type);\n};\n\n"],"mappings":"AACA,SAASA,QAAQ,QAAQ,aAAa;AAEtC,SAASC,UAAU,QAAQ,gBAAgB;AAE3C,MAAMC,gBAAgB,GAAG,QAAQ;AAEjC,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAM;IAAEC;EAAK,CAAC,GAAGH,UAAU,CAAC,CAAC;EAE7B,OAAOD,QAAQ,CAAC,CAACE,gBAAgB,CAAC,EAAE,MAAME,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEC,SAAS,CAAC,CAAC,EAAE;IAC3DC,gBAAgB,EAAE;EACpB,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAIC,MAAkB,IAAe;EAAA,IAAAC,iBAAA;EACpE,OAAOC,MAAM,CAACC,MAAM,EAAAF,iBAAA,GAACD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEI,SAAS,cAAAH,iBAAA,cAAAA,iBAAA,GAAI,CAAC,CAAC,CAAC,CAC1CI,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,KAAK,KAAK,CAAC,CAClCC,GAAG,CAAEJ,SAAS,IAAKA,SAAS,CAACK,IAAI,CAAC;AACvC,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAIC,gBAAqC,IAAe;EAC9F,OAAOT,MAAM,CAACC,MAAM,CAACQ,gBAAgB,aAAhBA,gBAAgB,cAAhBA,gBAAgB,GAAI,CAAC,CAAC,CAAC,CACzCN,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,OAAO,KAAK,KAAK,CAAC,CAClCC,GAAG,CAAEI,QAAQ,IAAKA,QAAQ,CAACH,IAAI,CAAC;AACrC,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { initializeCore } from '@procivis/react-native-one-core';
|
|
2
2
|
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { reportException } from '../../reporting';
|
|
4
|
-
import { getEnabledTrustManagement } from './core-config';
|
|
5
|
-
import { TrustManagementEnum, useCreateTrustAnchor } from './trust-entity';
|
|
6
4
|
const defaultContextValue = {
|
|
7
5
|
core: {},
|
|
8
6
|
organisationId: '11111111-2222-3333-a444-ffffffffffff',
|
|
@@ -12,11 +10,9 @@ const ONECoreContext = /*#__PURE__*/createContext(defaultContextValue);
|
|
|
12
10
|
export const ONECoreContextProvider = ({
|
|
13
11
|
children,
|
|
14
12
|
organisationId = defaultContextValue.organisationId,
|
|
15
|
-
publisherReference,
|
|
16
13
|
config
|
|
17
14
|
}) => {
|
|
18
15
|
const [core, setCore] = useState();
|
|
19
|
-
const createTrustAnchor = useCreateTrustAnchor();
|
|
20
16
|
const initialize = useCallback(async force => {
|
|
21
17
|
if (core && !force) {
|
|
22
18
|
return core;
|
|
@@ -40,17 +36,6 @@ export const ONECoreContextProvider = ({
|
|
|
40
36
|
},
|
|
41
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
38
|
[]);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (!core || !publisherReference) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
core.getConfig().then(coreConfig => {
|
|
48
|
-
const trustManagementEnabled = getEnabledTrustManagement(coreConfig).includes(TrustManagementEnum.SimpleTrustList);
|
|
49
|
-
if (trustManagementEnabled) {
|
|
50
|
-
createTrustAnchor(core, publisherReference).catch(() => {});
|
|
51
|
-
}
|
|
52
|
-
}).catch(() => {});
|
|
53
|
-
}, [core, createTrustAnchor, publisherReference]);
|
|
54
39
|
const contextValue = useMemo(() => ({
|
|
55
40
|
core: core !== null && core !== void 0 ? core : defaultContextValue.core,
|
|
56
41
|
organisationId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initializeCore","React","createContext","useCallback","useContext","useEffect","useMemo","useState","reportException","
|
|
1
|
+
{"version":3,"names":["initializeCore","React","createContext","useCallback","useContext","useEffect","useMemo","useState","reportException","defaultContextValue","core","organisationId","initialize","Promise","reject","ONECoreContext","ONECoreContextProvider","children","config","setCore","force","coreInstance","e","corePromise","then","c","uninitialize","catch","contextValue","createElement","Provider","value","useONECore"],"sources":["core-context.tsx"],"sourcesContent":["import { initializeCore, ONECore } from '@procivis/react-native-one-core';\nimport React, {\n createContext,\n FC,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { reportException } from '../../reporting';\n\ninterface ContextValue {\n core: ONECore;\n organisationId: string;\n initialize: (force?: boolean) => Promise<ONECore>;\n}\n\nconst defaultContextValue: ContextValue = {\n core: {} as ONECore,\n organisationId: '11111111-2222-3333-a444-ffffffffffff',\n initialize: () => Promise.reject(),\n};\n\nexport type ONECoreContextProviderProps = {\n config?: Record<string, unknown>;\n organisationId?: string;\n};\n\nconst ONECoreContext = createContext<ContextValue>(defaultContextValue);\n\nexport const ONECoreContextProvider: FC<PropsWithChildren<ONECoreContextProviderProps>> = ({\n children,\n organisationId = defaultContextValue.organisationId,\n config,\n}) => {\n const [core, setCore] = useState<ONECore>();\n\n const initialize = useCallback(\n async (force?: boolean) => {\n if (core && !force) {\n return core;\n }\n\n try {\n const coreInstance = await initializeCore(config);\n setCore(coreInstance);\n return coreInstance;\n } catch (e) {\n reportException(e, 'Failed to initialize core');\n throw e;\n }\n },\n [core, config],\n );\n\n useEffect(\n () => {\n const corePromise = initialize();\n return () => {\n corePromise\n .then((c) => c?.uninitialize(false))\n .catch((e) => {\n reportException(e, 'Core uninitialization error');\n });\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n const contextValue = useMemo(\n () => ({\n core: core ?? defaultContextValue.core,\n organisationId,\n initialize,\n }),\n [core, initialize, organisationId],\n );\n\n if (!core) {\n return null;\n }\n\n return <ONECoreContext.Provider value={contextValue}>{children}</ONECoreContext.Provider>;\n};\n\nexport const useONECore = () => useContext(ONECoreContext);\n"],"mappings":"AAAA,SAASA,cAAc,QAAiB,iCAAiC;AACzE,OAAOC,KAAK,IACVC,aAAa,EAGbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,OAAO;AAEd,SAASC,eAAe,QAAQ,iBAAiB;AAQjD,MA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,IAAI,GAAID,mBAAmB,CAACC,IAAI;IACtCC,cAAc;IACdC;EACF,CAAC,CAAC,EACF,CAACF,IAAI,EAAEE,UAAU,EAAED,cAAc,CACnC,CAAC;EAED,IAAI,CAACD,IAAI,EAAE;IACT,OAAO,IAAI;EACb;EAEA,oBAAOT,KAAA,CAAA4B,aAAA,CAACd,cAAc,CAACe,QAAQ;IAACC,KAAK,EAAEH;EAAa,GAAEX,QAAkC,CAAC;AAC3F,CAAC;AAED,OAAO,MAAMe,UAAU,GAAGA,CAAA,KAAM5B,UAAU,CAACW,cAAc,CAAC","ignoreList":[]}
|
|
@@ -140,6 +140,19 @@ export const useCredentialDelete = () => {
|
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
|
+
export const useCredentialRefresh = () => {
|
|
144
|
+
const queryClient = useQueryClient();
|
|
145
|
+
const {
|
|
146
|
+
core
|
|
147
|
+
} = useONECore();
|
|
148
|
+
return useMutation(async interactionId => core.holderRefreshCredential(interactionId), {
|
|
149
|
+
onSuccess: async () => {
|
|
150
|
+
await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);
|
|
151
|
+
await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);
|
|
152
|
+
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
};
|
|
143
156
|
export const useInvalidateCredentialDetails = () => {
|
|
144
157
|
const queryClient = useQueryClient();
|
|
145
158
|
return credentialId => queryClient.invalidateQueries([CREDENTIAL_DETAIL_QUERY_KEY, credentialId]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CredentialState","OneError","useInfiniteQuery","useMutation","useQueries","useQuery","useQueryClient","getQueryKeyFromCredentialListQueryParams","useONECore","CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY","CREDENTIAL_SCHEMA_LIST_QUERY_KEY","OneErrorCode","HISTORY_LIST_QUERY_KEY","PROOF_LIST_QUERY_KEY","PAGE_SIZE","CREDENTIAL_LIST_QUERY_KEY","CREDENTIAL_LIST_PAGED_QUERY_KEY","CREDENTIAL_DETAIL_QUERY_KEY","CREDENTIAL_TRUST_INFORMATION_QUERY_KEY","useCredentials","queryParams","core","organisationId","values","listCredentials","page","pageSize","states","ACCEPTED","SUSPENDED","REVOKED","keepPreviousData","usePagedCredentials","pageParam","getNextPageParam","lastPage","allPages","length","totalPages","undefined","useCredentialDetail","credentialId","active","getCredential","enabled","Boolean","useInvitationHandler","queryClient","request","handleInvitation","onSuccess","result","type_","invalidateQueries","useCredentialAccept","credentialAcceptHookParams","holderAcceptCredential","useCredentialReject","interactionId","holderRejectCredential","catch","e","code","OperationNotSupported","useCredentialRevocationCheck","forceRefresh","credentialIds","checkRevocation","useCredentialDelete","deleteCredential","_","removeQueries","useInvalidateCredentialDetails","useInitiateIssuance","initiateIssuance","useContinueIssuance","url","continueIssuance","useCredentialTrustInformation","getCredentialTrustInformation","useCredentialsTrustInformation","map","id","meta","queryFn","queryKey"],"sources":["credentials.ts"],"sourcesContent":["import {\n CredentialListQuery,\n CredentialState,\n HandleInvitationRequest,\n HandleInvitationResponse,\n HolderAcceptCredentialRequest,\n InitiateIssuanceRequest,\n OneError,\n} from '@procivis/react-native-one-core';\nimport { useInfiniteQuery, useMutation, useQueries, useQuery, useQueryClient } from 'react-query';\n\nimport { getQueryKeyFromCredentialListQueryParams } from '../../parsers/query';\nimport { useONECore } from './core-context';\nimport { CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY, CREDENTIAL_SCHEMA_LIST_QUERY_KEY } from './credential-schemas';\nimport { OneErrorCode } from './error-code';\nimport { HISTORY_LIST_QUERY_KEY } from './history';\nimport { PROOF_LIST_QUERY_KEY } from './proofs';\n\nconst PAGE_SIZE = 20;\nexport const CREDENTIAL_LIST_QUERY_KEY = 'credential-list';\nexport const CREDENTIAL_LIST_PAGED_QUERY_KEY = 'credential-list-paged';\nexport const CREDENTIAL_DETAIL_QUERY_KEY = 'credential-detail';\nexport const CREDENTIAL_TRUST_INFORMATION_QUERY_KEY = 'credential-trust-information';\n\nexport const useCredentials = (queryParams?: Partial<CredentialListQuery>) => {\n const { core, organisationId } = useONECore();\n\n return useQuery(\n [CREDENTIAL_LIST_QUERY_KEY, ...getQueryKeyFromCredentialListQueryParams(queryParams)],\n async () => {\n const { values } = await core.listCredentials({\n organisationId,\n page: 0,\n // TODO: workaround pagination for now, until it's supported by UI\n pageSize: 10000,\n states: [CredentialState.ACCEPTED, CredentialState.SUSPENDED, CredentialState.REVOKED],\n ...queryParams,\n });\n return values;\n },\n {\n keepPreviousData: true,\n },\n );\n};\n\nexport const usePagedCredentials = (queryParams?: Partial<CredentialListQuery>) => {\n const { core, organisationId } = useONECore();\n\n return useInfiniteQuery(\n [\n CREDENTIAL_LIST_QUERY_KEY,\n CREDENTIAL_LIST_PAGED_QUERY_KEY,\n ...getQueryKeyFromCredentialListQueryParams(queryParams),\n ],\n ({ pageParam = 0 }) =>\n core.listCredentials({\n organisationId,\n page: pageParam,\n pageSize: PAGE_SIZE,\n states: [CredentialState.ACCEPTED, CredentialState.SUSPENDED, CredentialState.REVOKED],\n ...queryParams,\n }),\n {\n getNextPageParam: (lastPage, allPages) => (allPages.length < lastPage.totalPages ? allPages.length : undefined),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useCredentialDetail = (credentialId: string | undefined, active = true) => {\n const { core } = useONECore();\n\n return useQuery(\n [CREDENTIAL_DETAIL_QUERY_KEY, credentialId],\n () => (credentialId ? core.getCredential(credentialId) : undefined),\n {\n enabled: active && Boolean(credentialId),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useInvitationHandler = () => {\n const queryClient = useQueryClient();\n const { core, organisationId } = useONECore();\n\n return useMutation(\n async (request: Omit<HandleInvitationRequest, 'organisationId'>) =>\n core.handleInvitation({ organisationId, ...request }),\n {\n onSuccess: async (result: HandleInvitationResponse) => {\n if (result.type_ === 'PROOF_REQUEST') {\n await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);\n } else {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);\n }\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useCredentialAccept = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (credentialAcceptHookParams: HolderAcceptCredentialRequest) =>\n core.holderAcceptCredential(credentialAcceptHookParams),\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useCredentialReject = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (interactionId: string) =>\n core.holderRejectCredential(interactionId).catch((e) => {\n if (e instanceof OneError && e.code === OneErrorCode.OperationNotSupported) {\n return;\n }\n throw e;\n }),\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useCredentialRevocationCheck = (forceRefresh: boolean) => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (credentialIds: string[]) => core.checkRevocation(credentialIds, forceRefresh), {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useCredentialDelete = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (credentialId: string) => core.deleteCredential(credentialId), {\n onSuccess: async (_, credentialId) => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.removeQueries([CREDENTIAL_DETAIL_QUERY_KEY, credentialId]);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useInvalidateCredentialDetails = () => {\n const queryClient = useQueryClient();\n\n return (credentialId: string | undefined) =>\n queryClient.invalidateQueries([CREDENTIAL_DETAIL_QUERY_KEY, credentialId]);\n};\n\nexport const useInitiateIssuance = () => {\n const queryClient = useQueryClient();\n const { core, organisationId } = useONECore();\n\n return useMutation(\n async (request: Omit<InitiateIssuanceRequest, 'organisationId'>) =>\n core.initiateIssuance({ organisationId, ...request }),\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useContinueIssuance = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (url: string) => core.continueIssuance(url), {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useCredentialTrustInformation = (credentialId: string | undefined) => {\n const { core } = useONECore();\n\n return useQuery(\n [CREDENTIAL_TRUST_INFORMATION_QUERY_KEY, credentialId],\n () => (credentialId ? core.getCredentialTrustInformation(credentialId) : undefined),\n {\n enabled: Boolean(credentialId),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useCredentialsTrustInformation = (credentialIds: string[]) => {\n const { core } = useONECore();\n\n return useQueries(\n credentialIds.map((id) => ({\n keepPreviousData: true,\n meta: {\n id,\n },\n queryFn: () => core.getCredentialTrustInformation(id),\n queryKey: [CREDENTIAL_TRUST_INFORMATION_QUERY_KEY, id],\n })),\n );\n};\n"],"mappings":"AAAA,SAEEA,eAAe,EAKfC,QAAQ,QACH,iCAAiC;AACxC,SAASC,gBAAgB,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,aAAa;AAEjG,SAASC,wCAAwC,QAAQ,qBAAqB;AAC9E,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,kCAAkC,EAAEC,gCAAgC,QAAQ,sBAAsB;AAC3G,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,sBAAsB,QAAQ,WAAW;AAClD,SAASC,oBAAoB,QAAQ,UAAU;AAE/C,MAAMC,SAAS,GAAG,EAAE;AACpB,OAAO,MAAMC,yBAAyB,GAAG,iBAAiB;AAC1D,OAAO,MAAMC,+BAA+B,GAAG,uBAAuB;AACtE,OAAO,MAAMC,2BAA2B,GAAG,mBAAmB;AAC9D,OAAO,MAAMC,sCAAsC,GAAG,8BAA8B;AAEpF,OAAO,MAAMC,cAAc,GAAIC,WAA0C,IAAK;EAC5E,MAAM;IAAEC,IAAI;IAAEC;EAAe,CAAC,GAAGd,UAAU,CAAC,CAAC;EAE7C,OAAOH,QAAQ,CACb,CAACU,yBAAyB,EAAE,GAAGR,wCAAwC,CAACa,WAAW,CAAC,CAAC,EACrF,YAAY;IACV,MAAM;MAAEG;IAAO,CAAC,GAAG,MAAMF,IAAI,CAACG,eAAe,CAAC;MAC5CF,cAAc;MACdG,IAAI,EAAE,CAAC;MACP;MACAC,QAAQ,EAAE,KAAK;MACfC,MAAM,EAAE,CAAC3B,eAAe,CAAC4B,QAAQ,EAAE5B,eAAe,CAAC6B,SAAS,EAAE7B,eAAe,CAAC8B,OAAO,CAAC;MACtF,GAAGV;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,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["CredentialState","OneError","useInfiniteQuery","useMutation","useQueries","useQuery","useQueryClient","getQueryKeyFromCredentialListQueryParams","useONECore","CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY","CREDENTIAL_SCHEMA_LIST_QUERY_KEY","OneErrorCode","HISTORY_LIST_QUERY_KEY","PROOF_LIST_QUERY_KEY","PAGE_SIZE","CREDENTIAL_LIST_QUERY_KEY","CREDENTIAL_LIST_PAGED_QUERY_KEY","CREDENTIAL_DETAIL_QUERY_KEY","CREDENTIAL_TRUST_INFORMATION_QUERY_KEY","useCredentials","queryParams","core","organisationId","values","listCredentials","page","pageSize","states","ACCEPTED","SUSPENDED","REVOKED","keepPreviousData","usePagedCredentials","pageParam","getNextPageParam","lastPage","allPages","length","totalPages","undefined","useCredentialDetail","credentialId","active","getCredential","enabled","Boolean","useInvitationHandler","queryClient","request","handleInvitation","onSuccess","result","type_","invalidateQueries","useCredentialAccept","credentialAcceptHookParams","holderAcceptCredential","useCredentialReject","interactionId","holderRejectCredential","catch","e","code","OperationNotSupported","useCredentialRevocationCheck","forceRefresh","credentialIds","checkRevocation","useCredentialDelete","deleteCredential","_","removeQueries","useCredentialRefresh","holderRefreshCredential","useInvalidateCredentialDetails","useInitiateIssuance","initiateIssuance","useContinueIssuance","url","continueIssuance","useCredentialTrustInformation","getCredentialTrustInformation","useCredentialsTrustInformation","map","id","meta","queryFn","queryKey"],"sources":["credentials.ts"],"sourcesContent":["import {\n CredentialListQuery,\n CredentialState,\n HandleInvitationRequest,\n HandleInvitationResponse,\n HolderAcceptCredentialRequest,\n InitiateIssuanceRequest,\n OneError,\n} from '@procivis/react-native-one-core';\nimport { useInfiniteQuery, useMutation, useQueries, useQuery, useQueryClient } from 'react-query';\n\nimport { getQueryKeyFromCredentialListQueryParams } from '../../parsers/query';\nimport { useONECore } from './core-context';\nimport { CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY, CREDENTIAL_SCHEMA_LIST_QUERY_KEY } from './credential-schemas';\nimport { OneErrorCode } from './error-code';\nimport { HISTORY_LIST_QUERY_KEY } from './history';\nimport { PROOF_LIST_QUERY_KEY } from './proofs';\n\nconst PAGE_SIZE = 20;\nexport const CREDENTIAL_LIST_QUERY_KEY = 'credential-list';\nexport const CREDENTIAL_LIST_PAGED_QUERY_KEY = 'credential-list-paged';\nexport const CREDENTIAL_DETAIL_QUERY_KEY = 'credential-detail';\nexport const CREDENTIAL_TRUST_INFORMATION_QUERY_KEY = 'credential-trust-information';\n\nexport const useCredentials = (queryParams?: Partial<CredentialListQuery>) => {\n const { core, organisationId } = useONECore();\n\n return useQuery(\n [CREDENTIAL_LIST_QUERY_KEY, ...getQueryKeyFromCredentialListQueryParams(queryParams)],\n async () => {\n const { values } = await core.listCredentials({\n organisationId,\n page: 0,\n // TODO: workaround pagination for now, until it's supported by UI\n pageSize: 10000,\n states: [CredentialState.ACCEPTED, CredentialState.SUSPENDED, CredentialState.REVOKED],\n ...queryParams,\n });\n return values;\n },\n {\n keepPreviousData: true,\n },\n );\n};\n\nexport const usePagedCredentials = (queryParams?: Partial<CredentialListQuery>) => {\n const { core, organisationId } = useONECore();\n\n return useInfiniteQuery(\n [\n CREDENTIAL_LIST_QUERY_KEY,\n CREDENTIAL_LIST_PAGED_QUERY_KEY,\n ...getQueryKeyFromCredentialListQueryParams(queryParams),\n ],\n ({ pageParam = 0 }) =>\n core.listCredentials({\n organisationId,\n page: pageParam,\n pageSize: PAGE_SIZE,\n states: [CredentialState.ACCEPTED, CredentialState.SUSPENDED, CredentialState.REVOKED],\n ...queryParams,\n }),\n {\n getNextPageParam: (lastPage, allPages) => (allPages.length < lastPage.totalPages ? allPages.length : undefined),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useCredentialDetail = (credentialId: string | undefined, active = true) => {\n const { core } = useONECore();\n\n return useQuery(\n [CREDENTIAL_DETAIL_QUERY_KEY, credentialId],\n () => (credentialId ? core.getCredential(credentialId) : undefined),\n {\n enabled: active && Boolean(credentialId),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useInvitationHandler = () => {\n const queryClient = useQueryClient();\n const { core, organisationId } = useONECore();\n\n return useMutation(\n async (request: Omit<HandleInvitationRequest, 'organisationId'>) =>\n core.handleInvitation({ organisationId, ...request }),\n {\n onSuccess: async (result: HandleInvitationResponse) => {\n if (result.type_ === 'PROOF_REQUEST') {\n await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);\n } else {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);\n }\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useCredentialAccept = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (credentialAcceptHookParams: HolderAcceptCredentialRequest) =>\n core.holderAcceptCredential(credentialAcceptHookParams),\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useCredentialReject = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (interactionId: string) =>\n core.holderRejectCredential(interactionId).catch((e) => {\n if (e instanceof OneError && e.code === OneErrorCode.OperationNotSupported) {\n return;\n }\n throw e;\n }),\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useCredentialRevocationCheck = (forceRefresh: boolean) => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (credentialIds: string[]) => core.checkRevocation(credentialIds, forceRefresh), {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useCredentialDelete = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (credentialId: string) => core.deleteCredential(credentialId), {\n onSuccess: async (_, credentialId) => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.removeQueries([CREDENTIAL_DETAIL_QUERY_KEY, credentialId]);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useCredentialRefresh = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (interactionId: string) => core.holderRefreshCredential(interactionId), {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useInvalidateCredentialDetails = () => {\n const queryClient = useQueryClient();\n\n return (credentialId: string | undefined) =>\n queryClient.invalidateQueries([CREDENTIAL_DETAIL_QUERY_KEY, credentialId]);\n};\n\nexport const useInitiateIssuance = () => {\n const queryClient = useQueryClient();\n const { core, organisationId } = useONECore();\n\n return useMutation(\n async (request: Omit<InitiateIssuanceRequest, 'organisationId'>) =>\n core.initiateIssuance({ organisationId, ...request }),\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useContinueIssuance = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async (url: string) => core.continueIssuance(url), {\n onSuccess: async () => {\n await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);\n await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n });\n};\n\nexport const useCredentialTrustInformation = (credentialId: string | undefined) => {\n const { core } = useONECore();\n\n return useQuery(\n [CREDENTIAL_TRUST_INFORMATION_QUERY_KEY, credentialId],\n () => (credentialId ? core.getCredentialTrustInformation(credentialId) : undefined),\n {\n enabled: Boolean(credentialId),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useCredentialsTrustInformation = (credentialIds: string[]) => {\n const { core } = useONECore();\n\n return useQueries(\n credentialIds.map((id) => ({\n keepPreviousData: true,\n meta: {\n id,\n },\n queryFn: () => core.getCredentialTrustInformation(id),\n queryKey: [CREDENTIAL_TRUST_INFORMATION_QUERY_KEY, id],\n })),\n );\n};\n"],"mappings":"AAAA,SAEEA,eAAe,EAKfC,QAAQ,QACH,iCAAiC;AACxC,SAASC,gBAAgB,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,aAAa;AAEjG,SAASC,wCAAwC,QAAQ,qBAAqB;AAC9E,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,kCAAkC,EAAEC,gCAAgC,QAAQ,sBAAsB;AAC3G,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,sBAAsB,QAAQ,WAAW;AAClD,SAASC,oBAAoB,QAAQ,UAAU;AAE/C,MAAMC,SAAS,GAAG,EAAE;AACpB,OAAO,MAAMC,yBAAyB,GAAG,iBAAiB;AAC1D,OAAO,MAAMC,+BAA+B,GAAG,uBAAuB;AACtE,OAAO,MAAMC,2BAA2B,GAAG,mBAAmB;AA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ACrB,MAAMH,WAAW,CAACM,iBAAiB,CAACtC,yBAAyB,CAAC;MAC9D,MAAMgC,WAAW,CAACM,iBAAiB,CAAC3C,gCAAgC,CAAC;MACrE,MAAMqC,WAAW,CAACM,iBAAiB,CAAC5C,kCAAkC,CAAC;MACvE,MAAMsC,WAAW,CAACM,iBAAiB,CAACzC,sBAAsB,CAAC;IAC7D;EACF,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,MAAMoE,6BAA6B,GAAIvC,YAAgC,IAAK;EACjF,MAAM;IAAEpB;EAAK,CAAC,GAAGb,UAAU,CAAC,CAAC;EAE7B,OAAOH,QAAQ,CACb,CAACa,sCAAsC,EAAEuB,YAAY,CAAC,EACtD,MAAOA,YAAY,GAAGpB,IAAI,CAAC4D,6BAA6B,CAACxC,YAAY,CAAC,GAAGF,SAAU,EACnF;IACEK,OAAO,EAAEC,OAAO,CAACJ,YAAY,CAAC;IAC9BV,gBAAgB,EAAE;EACpB,CACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMmD,8BAA8B,GAAIhB,aAAuB,IAAK;EACzE,MAAM;IAAE7C;EAAK,CAAC,GAAGb,UAAU,CAAC,CAAC;EAE7B,OAAOJ,UAAU,CACf8D,aAAa,CAACiB,GAAG,CAAEC,EAAE,KAAM;IACzBrD,gBAAgB,EAAE,IAAI;IACtBsD,IAAI,EAAE;MACJD;IACF,CAAC;IACDE,OAAO,EAAEA,CAAA,KAAMjE,IAAI,CAAC4D,6BAA6B,CAACG,EAAE,CAAC;IACrDG,QAAQ,EAAE,CAACrE,sCAAsC,EAAEkE,EAAE;EACvD,CAAC,CAAC,CACJ,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -11,7 +11,6 @@ export * from './identifiers';
|
|
|
11
11
|
export * from './proof-schemas';
|
|
12
12
|
export * from './proofs';
|
|
13
13
|
export * from './query';
|
|
14
|
-
export * from './trust-entity';
|
|
15
14
|
export * from './trust-list';
|
|
16
15
|
export * from './verifier-instance';
|
|
17
16
|
export * from './wallet-unit';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './backup';\nexport * from './cache';\nexport * from './core-config';\nexport * from './core-context';\nexport * from './core-init';\nexport * from './credential-schemas';\nexport * from './credentials';\nexport * from './dids';\nexport * from './history';\nexport * from './identifiers';\nexport * from './proof-schemas';\nexport * from './proofs';\nexport * from './query';\nexport * from './trust-
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './backup';\nexport * from './cache';\nexport * from './core-config';\nexport * from './core-context';\nexport * from './core-init';\nexport * from './credential-schemas';\nexport * from './credentials';\nexport * from './dids';\nexport * from './history';\nexport * from './identifiers';\nexport * from './proof-schemas';\nexport * from './proofs';\nexport * from './query';\nexport * from './trust-list';\nexport * from './verifier-instance';\nexport * from './wallet-unit';\n"],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,sBAAsB;AACpC,cAAc,eAAe;AAC7B,cAAc,QAAQ;AACtB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,qBAAqB;AACnC,cAAc,eAAe","ignoreList":[]}
|
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
import { useMutation } from 'react-query';
|
|
1
|
+
import { useMutation, useQueryClient } from 'react-query';
|
|
2
2
|
import { reportException } from '../../reporting';
|
|
3
3
|
import { useONECore } from './core-context';
|
|
4
|
+
import { VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY } from './verifier-instance';
|
|
5
|
+
import { WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY } from './wallet-unit';
|
|
4
6
|
export const useTrustCollectionSync = () => {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
5
8
|
const {
|
|
6
9
|
core
|
|
7
10
|
} = useONECore();
|
|
8
|
-
return useMutation(async
|
|
9
|
-
onError: err => {
|
|
11
|
+
return useMutation(async () => core.runTask('TRUST_COLLECTION_SYNC', undefined), {
|
|
12
|
+
onError: async err => {
|
|
10
13
|
reportException(err, 'TRUST_COLLECTION_SYNC error');
|
|
14
|
+
await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);
|
|
15
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);
|
|
16
|
+
},
|
|
17
|
+
onSuccess: async () => {
|
|
18
|
+
await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);
|
|
19
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);
|
|
11
20
|
}
|
|
12
21
|
});
|
|
13
22
|
};
|
|
14
23
|
export const useTrustListSubscriptionUpdate = () => {
|
|
24
|
+
const queryClient = useQueryClient();
|
|
15
25
|
const {
|
|
16
26
|
core
|
|
17
27
|
} = useONECore();
|
|
18
28
|
return useMutation(async () => core.runTask('TRUST_LIST_SUBSCRIPTION_UPDATE', undefined), {
|
|
19
|
-
onError: err => {
|
|
29
|
+
onError: async err => {
|
|
20
30
|
reportException(err, 'TRUST_LIST_SUBSCRIPTION_UPDATE error');
|
|
31
|
+
await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);
|
|
32
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);
|
|
33
|
+
},
|
|
34
|
+
onSuccess: async () => {
|
|
35
|
+
await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);
|
|
36
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);
|
|
21
37
|
}
|
|
22
38
|
});
|
|
23
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMutation","reportException","useONECore","
|
|
1
|
+
{"version":3,"names":["useMutation","useQueryClient","reportException","useONECore","VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY","WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY","useTrustCollectionSync","queryClient","core","runTask","undefined","onError","err","invalidateQueries","onSuccess","useTrustListSubscriptionUpdate"],"sources":["trust-list.ts"],"sourcesContent":["import { useMutation, useQueryClient } from 'react-query';\n\nimport { reportException } from '../../reporting';\nimport { useONECore } from './core-context';\nimport { VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY } from './verifier-instance';\nimport { WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY } from './wallet-unit';\n\nexport const useTrustCollectionSync = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async () => core.runTask('TRUST_COLLECTION_SYNC', undefined), {\n onError: async (err) => {\n reportException(err, 'TRUST_COLLECTION_SYNC error');\n await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);\n },\n });\n};\n\nexport const useTrustListSubscriptionUpdate = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(async () => core.runTask('TRUST_LIST_SUBSCRIPTION_UPDATE', undefined), {\n onError: async (err) => {\n reportException(err, 'TRUST_LIST_SUBSCRIPTION_UPDATE error');\n await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries(WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY);\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);\n },\n });\n};\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,cAAc,QAAQ,aAAa;AAEzD,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,6CAA6C,QAAQ,qBAAqB;AACnF,SAASC,uCAAuC,QAAQ,eAAe;AAEvE,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,WAAW,GAAGN,cAAc,CAAC,CAAC;EACpC,MAAM;IAAEO;EAAK,CAAC,GAAGL,UAAU,CAAC,CAAC;EAE7B,OAAOH,WAAW,CAAC,YAAYQ,IAAI,CAACC,OAAO,CAAC,uBAAuB,EAAEC,SAAS,CAAC,EAAE;IAC/EC,OAAO,EAAE,MAAOC,GAAG,IAAK;MACtBV,eAAe,CAACU,GAAG,EAAE,6BAA6B,CAAC;MACnD,MAAML,WAAW,CAACM,iBAAiB,CAACR,uCAAuC,CAAC;MAC5E,MAAME,WAAW,CAACM,iBAAiB,CAACT,6CAA6C,CAAC;IACpF,CAAC;IACDU,SAAS,EAAE,MAAAA,CAAA,KAAY;MACrB,MAAMP,WAAW,CAACM,iBAAiB,CAACR,uCAAuC,CAAC;MAC5E,MAAME,WAAW,CAACM,iBAAiB,CAACT,6CAA6C,CAAC;IACpF;EACF,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,MAAMW,8BAA8B,GAAGA,CAAA,KAAM;EAClD,MAAMR,WAAW,GAAGN,cAAc,CAAC,CAAC;EACpC,MAAM;IAAEO;EAAK,CAAC,GAAGL,UAAU,CAAC,CAAC;EAE7B,OAAOH,WAAW,CAAC,YAAYQ,IAAI,CAACC,OAAO,CAAC,gCAAgC,EAAEC,SAAS,CAAC,EAAE;IACxFC,OAAO,EAAE,MAAOC,GAAG,IAAK;MACtBV,eAAe,CAACU,GAAG,EAAE,sCAAsC,CAAC;MAC5D,MAAML,WAAW,CAACM,iBAAiB,CAACR,uCAAuC,CAAC;MAC5E,MAAME,WAAW,CAACM,iBAAiB,CAACT,6CAA6C,CAAC;IACpF,CAAC;IACDU,SAAS,EAAE,MAAAA,CAAA,KAAY;MACrB,MAAMP,WAAW,CAACM,iBAAiB,CAACR,uCAAuC,CAAC;MAC5E,MAAME,WAAW,CAACM,iBAAiB,CAACT,6CAA6C,CAAC;IACpF;EACF,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
2
2
|
import { reportException } from '../../reporting';
|
|
3
3
|
import { useONECore } from './core-context';
|
|
4
|
+
export const VERIFIER_INSTANCE_QUERY_KEY = 'verifier-instance';
|
|
4
5
|
export const VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY = 'verifier-instance-trust-collections';
|
|
6
|
+
export const useVerifierInstance = (active = true) => {
|
|
7
|
+
const {
|
|
8
|
+
core,
|
|
9
|
+
organisationId
|
|
10
|
+
} = useONECore();
|
|
11
|
+
return useQuery([VERIFIER_INSTANCE_QUERY_KEY], () => core.getOrganisation(organisationId).then(org => org.verifierInstance), {
|
|
12
|
+
enabled: active,
|
|
13
|
+
keepPreviousData: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
5
16
|
export const useVerifierInstanceTrustCollections = (verifierInstanceId, active = true) => {
|
|
6
17
|
const {
|
|
7
18
|
core
|
|
@@ -21,7 +32,10 @@ export const useRegisterVerifierInstance = () => {
|
|
|
21
32
|
organisationId,
|
|
22
33
|
...request
|
|
23
34
|
}), {
|
|
24
|
-
onSuccess: () =>
|
|
35
|
+
onSuccess: async () => {
|
|
36
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_QUERY_KEY);
|
|
37
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);
|
|
38
|
+
}
|
|
25
39
|
});
|
|
26
40
|
};
|
|
27
41
|
export const useVerifierInstanceUpdate = () => {
|
|
@@ -35,9 +49,13 @@ export const useVerifierInstanceUpdate = () => {
|
|
|
35
49
|
}) => core.updateVerifierInstance(verifierInstanceId, update), {
|
|
36
50
|
onError: async err => {
|
|
37
51
|
reportException(err, 'Update verifier instance failure');
|
|
52
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_QUERY_KEY);
|
|
38
53
|
await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);
|
|
39
54
|
},
|
|
40
|
-
onSuccess: () =>
|
|
55
|
+
onSuccess: async () => {
|
|
56
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_QUERY_KEY);
|
|
57
|
+
await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);
|
|
58
|
+
}
|
|
41
59
|
});
|
|
42
60
|
};
|
|
43
61
|
//# sourceMappingURL=verifier-instance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMutation","useQuery","useQueryClient","reportException","useONECore","
|
|
1
|
+
{"version":3,"names":["useMutation","useQuery","useQueryClient","reportException","useONECore","VERIFIER_INSTANCE_QUERY_KEY","VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY","useVerifierInstance","active","core","organisationId","getOrganisation","then","org","verifierInstance","enabled","keepPreviousData","useVerifierInstanceTrustCollections","verifierInstanceId","getVerifierInstanceTrustCollections","undefined","Boolean","useRegisterVerifierInstance","queryClient","request","registerVerifierInstance","onSuccess","invalidateQueries","useVerifierInstanceUpdate","update","updateVerifierInstance","onError","err"],"sources":["verifier-instance.ts"],"sourcesContent":["import { RegisterVerifierInstanceRequest, UpdateVerifierInstanceRequest } from '@procivis/react-native-one-core';\nimport { useMutation, useQuery, useQueryClient } from 'react-query';\n\nimport { reportException } from '../../reporting';\nimport { useONECore } from './core-context';\n\nexport const VERIFIER_INSTANCE_QUERY_KEY = 'verifier-instance';\nexport const VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY = 'verifier-instance-trust-collections';\n\nexport const useVerifierInstance = (active = true) => {\n const { core, organisationId } = useONECore();\n\n return useQuery(\n [VERIFIER_INSTANCE_QUERY_KEY],\n () => core.getOrganisation(organisationId).then((org) => org.verifierInstance),\n {\n enabled: active,\n keepPreviousData: true,\n },\n );\n};\n\nexport const useVerifierInstanceTrustCollections = (verifierInstanceId: string | undefined, active = true) => {\n const { core } = useONECore();\n\n return useQuery(\n [VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY, verifierInstanceId],\n () => (verifierInstanceId ? core.getVerifierInstanceTrustCollections(verifierInstanceId) : undefined),\n {\n enabled: active && Boolean(verifierInstanceId),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useRegisterVerifierInstance = () => {\n const queryClient = useQueryClient();\n const { core, organisationId } = useONECore();\n\n return useMutation(\n async (request: Omit<RegisterVerifierInstanceRequest, 'organisationId'>) =>\n core.registerVerifierInstance({\n organisationId,\n ...request,\n }),\n\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_QUERY_KEY);\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useVerifierInstanceUpdate = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async ({ verifierInstanceId, update }: { verifierInstanceId: string; update: UpdateVerifierInstanceRequest }) =>\n core.updateVerifierInstance(verifierInstanceId, update),\n {\n onError: async (err) => {\n reportException(err, 'Update verifier instance failure');\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_QUERY_KEY);\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_TRUST_COLLECTIONS_QUERY_KEY);\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries(VERIFIER_INSTANCE_QUER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CAAC,CAAC;EAE7C,OAAOJ,WAAW,CAChB,MAAOwB,OAAgE,IACrEf,IAAI,CAACgB,wBAAwB,CAAC;IAC5Bf,cAAc;IACd,GAAGc;EACL,CAAC,CAAC,EAEJ;IACEE,SAAS,EAAE,MAAAA,CAAA,KAAY;MACrB,MAAMH,WAAW,CAACI,iBAAiB,CAACtB,2BAA2B,CAAC;MAChE,MAAMkB,WAAW,CAACI,iBAAiB,CAACrB,6CAA6C,CAAC;IACpF;EACF,CACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMsB,yBAAyB,GAAGA,CAAA,KAAM;EAC7C,MAAML,WAAW,GAAGrB,cAAc,CAAC,CAAC;EACpC,MAAM;IAAEO;EAAK,CAAC,GAAGL,UAAU,CAAC,CAAC;EAE7B,OAAOJ,WAAW,CAChB,OAAO;IAAEkB,kBAAkB;IAAEW;EAA8E,CAAC,KAC1GpB,IAAI,CAACqB,sBAAsB,CAACZ,kBAAkB,EAAEW,MAAM,CAAC,EACzD;IACEE,OAAO,EAAE,MAAOC,GAAG,IAAK;MACtB7B,eAAe,CAAC6B,GAAG,EAAE,kCAAkC,CAAC;MACxD,MAAMT,WAAW,CAACI,iBAAiB,CAACtB,2BAA2B,CAAC;MAChE,MAAMkB,WAAW,CAACI,iBAAiB,CAACrB,6CAA6C,CAAC;IACpF,CAAC;IACDoB,SAAS,EAAE,MAAAA,CAAA,KAAY;MACrB,MAAMH,WAAW,CAACI,iBAAiB,CAACtB,2BAA2B,CAAC;MAChE,MAAMkB,WAAW,CAACI,iBAAiB,CAACrB,6CAA6C,CAAC;IACpF;EACF,CACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -29,10 +29,10 @@ export const useRegisterWalletUnit = () => {
|
|
|
29
29
|
core,
|
|
30
30
|
organisationId
|
|
31
31
|
} = useONECore();
|
|
32
|
-
return useMutation(async
|
|
32
|
+
return useMutation(async request => core.holderRegisterWalletUnit({
|
|
33
33
|
keyType: 'ECDSA',
|
|
34
34
|
organisationId,
|
|
35
|
-
|
|
35
|
+
...request
|
|
36
36
|
}), {
|
|
37
37
|
onSuccess: async () => {
|
|
38
38
|
await queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY);
|