@procivis/one-react-native-components 0.3.27 → 0.3.47
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/entity/entity-attributes.js +14 -1
- package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +9 -42
- package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details.js +60 -32
- package/lib/commonjs/components/entity/entity-details.js.map +1 -1
- package/lib/commonjs/components/entity/index.js +2 -15
- package/lib/commonjs/components/entity/index.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item.js +14 -12
- package/lib/commonjs/components/history/history-list-item.js.map +1 -1
- package/lib/commonjs/components/proof-request/share-credential.js +1 -2
- package/lib/commonjs/components/proof-request/share-credential.js.map +1 -1
- package/lib/commonjs/ui-components/blur/index.js +2 -9
- package/lib/commonjs/ui-components/blur/index.js.map +1 -1
- package/lib/commonjs/ui-components/buttons/hold-button.js +3 -2
- package/lib/commonjs/ui-components/buttons/hold-button.js.map +1 -1
- package/lib/commonjs/ui-components/camera/index.js +2 -9
- package/lib/commonjs/ui-components/camera/index.js.map +1 -1
- package/lib/commonjs/ui-components/control/index.js +0 -12
- package/lib/commonjs/ui-components/control/index.js.map +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/commonjs/ui-components/credential/credential-carousel-images.js +15 -8
- package/lib/commonjs/ui-components/credential/credential-carousel-images.js.map +1 -1
- package/lib/commonjs/ui-components/entity/entity-cluster.js +50 -2
- package/lib/commonjs/ui-components/entity/entity-cluster.js.map +1 -1
- package/lib/commonjs/ui-components/entity/index.js +3 -16
- package/lib/commonjs/ui-components/entity/index.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-details.js +1 -1
- package/lib/commonjs/ui-components/history/history-details.js.map +1 -1
- package/lib/commonjs/ui-components/history/index.js +4 -27
- package/lib/commonjs/ui-components/history/index.js.map +1 -1
- package/lib/commonjs/ui-components/icons/entity.js +10 -13
- package/lib/commonjs/ui-components/icons/entity.js.map +1 -1
- package/lib/commonjs/ui-components/input/index.js +3 -32
- package/lib/commonjs/ui-components/input/index.js.map +1 -1
- package/lib/commonjs/ui-components/list/index.js +4 -19
- package/lib/commonjs/ui-components/list/index.js.map +1 -1
- package/lib/commonjs/ui-components/loader/index.js +2 -13
- package/lib/commonjs/ui-components/loader/index.js.map +1 -1
- package/lib/commonjs/ui-components/pin/index.js +2 -21
- package/lib/commonjs/ui-components/pin/index.js.map +1 -1
- package/lib/commonjs/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/commonjs/ui-components/searchbar/index.js +3 -16
- package/lib/commonjs/ui-components/searchbar/index.js.map +1 -1
- package/lib/commonjs/ui-components/settings/index.js +6 -37
- package/lib/commonjs/ui-components/settings/index.js.map +1 -1
- package/lib/commonjs/ui-components/state/index.js +2 -15
- package/lib/commonjs/ui-components/state/index.js.map +1 -1
- package/lib/commonjs/utils/date.js +1 -1
- package/lib/commonjs/utils/date.js.map +1 -1
- package/lib/commonjs/utils/hooks/connectivity/connectivity.test.js +4 -0
- package/lib/commonjs/utils/hooks/connectivity/connectivity.test.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js +22 -66
- package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-init.js +6 -2
- package/lib/commonjs/utils/hooks/core/core-init.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js +23 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +24 -14
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js +55 -14
- package/lib/commonjs/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js +6 -15
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +21 -3
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/module/components/entity/entity-attributes.js +15 -2
- package/lib/module/components/entity/entity-attributes.js.map +1 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +11 -44
- package/lib/module/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/module/components/entity/entity-details.js +60 -32
- package/lib/module/components/entity/entity-details.js.map +1 -1
- package/lib/module/components/entity/index.js +2 -2
- package/lib/module/components/entity/index.js.map +1 -1
- package/lib/module/components/history/history-list-item.js +15 -13
- package/lib/module/components/history/history-list-item.js.map +1 -1
- package/lib/module/components/proof-request/share-credential.js +1 -2
- package/lib/module/components/proof-request/share-credential.js.map +1 -1
- package/lib/module/ui-components/blur/index.js +2 -2
- package/lib/module/ui-components/blur/index.js.map +1 -1
- package/lib/module/ui-components/buttons/hold-button.js +4 -3
- package/lib/module/ui-components/buttons/hold-button.js.map +1 -1
- package/lib/module/ui-components/camera/index.js +2 -2
- package/lib/module/ui-components/camera/index.js.map +1 -1
- package/lib/module/ui-components/control/index.js +3 -3
- package/lib/module/ui-components/control/index.js.map +1 -1
- package/lib/module/ui-components/credential/card/credential-details-card.js +1 -1
- package/lib/module/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/module/ui-components/credential/credential-carousel-images.js +15 -8
- package/lib/module/ui-components/credential/credential-carousel-images.js.map +1 -1
- package/lib/module/ui-components/entity/entity-cluster.js +51 -3
- package/lib/module/ui-components/entity/entity-cluster.js.map +1 -1
- package/lib/module/ui-components/entity/index.js +4 -4
- package/lib/module/ui-components/entity/index.js.map +1 -1
- package/lib/module/ui-components/history/history-details.js +1 -1
- package/lib/module/ui-components/history/history-details.js.map +1 -1
- package/lib/module/ui-components/history/index.js +6 -6
- package/lib/module/ui-components/history/index.js.map +1 -1
- package/lib/module/ui-components/icons/entity.js +10 -13
- package/lib/module/ui-components/icons/entity.js.map +1 -1
- package/lib/module/ui-components/input/index.js +6 -6
- package/lib/module/ui-components/input/index.js.map +1 -1
- package/lib/module/ui-components/list/index.js +4 -4
- package/lib/module/ui-components/list/index.js.map +1 -1
- package/lib/module/ui-components/loader/index.js +4 -4
- package/lib/module/ui-components/loader/index.js.map +1 -1
- package/lib/module/ui-components/pin/index.js +3 -3
- package/lib/module/ui-components/pin/index.js.map +1 -1
- package/lib/module/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/module/ui-components/searchbar/index.js +4 -4
- package/lib/module/ui-components/searchbar/index.js.map +1 -1
- package/lib/module/ui-components/settings/index.js +10 -10
- package/lib/module/ui-components/settings/index.js.map +1 -1
- package/lib/module/ui-components/state/index.js +2 -2
- package/lib/module/ui-components/state/index.js.map +1 -1
- package/lib/module/utils/date.js +1 -1
- package/lib/module/utils/date.js.map +1 -1
- package/lib/module/utils/hooks/connectivity/connectivity.test.js +4 -0
- package/lib/module/utils/hooks/connectivity/connectivity.test.js.map +1 -1
- package/lib/module/utils/hooks/core/backup.js +24 -68
- package/lib/module/utils/hooks/core/backup.js.map +1 -1
- package/lib/module/utils/hooks/core/core-init.js +5 -3
- package/lib/module/utils/hooks/core/core-init.js.map +1 -1
- package/lib/module/utils/hooks/core/identifiers.js +21 -0
- package/lib/module/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +24 -14
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-entity.js +55 -14
- package/lib/module/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing.js +6 -15
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/query.js +19 -2
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/typescript/components/entity/entity-attributes.d.ts +1 -0
- package/lib/typescript/components/entity/entity-details-with-buttons.d.ts +1 -2
- package/lib/typescript/components/entity/entity-details.d.ts +3 -2
- package/lib/typescript/components/entity/index.d.ts +2 -1
- package/lib/typescript/ui-components/blur/index.d.ts +2 -1
- package/lib/typescript/ui-components/buttons/hold-button.d.ts +2 -2
- package/lib/typescript/ui-components/camera/index.d.ts +2 -1
- package/lib/typescript/ui-components/control/index.d.ts +4 -2
- package/lib/typescript/ui-components/credential/credential-carousel-images.d.ts +1 -0
- package/lib/typescript/ui-components/entity/entity-cluster.d.ts +1 -0
- package/lib/typescript/ui-components/entity/index.d.ts +4 -2
- package/lib/typescript/ui-components/history/history-details.d.ts +4 -1
- package/lib/typescript/ui-components/history/index.d.ts +6 -3
- package/lib/typescript/ui-components/input/index.d.ts +6 -3
- package/lib/typescript/ui-components/list/index.d.ts +4 -2
- package/lib/typescript/ui-components/loader/index.d.ts +4 -2
- package/lib/typescript/ui-components/pin/index.d.ts +4 -2
- package/lib/typescript/ui-components/screens/nerd-mode-screen.d.ts +1 -1
- package/lib/typescript/ui-components/searchbar/index.d.ts +4 -2
- package/lib/typescript/ui-components/settings/index.d.ts +10 -5
- package/lib/typescript/ui-components/state/index.d.ts +2 -1
- package/lib/typescript/utils/hooks/core/backup.d.ts +5 -0
- package/lib/typescript/utils/hooks/core/core-init.d.ts +4 -1
- package/lib/typescript/utils/hooks/core/identifiers.d.ts +4 -1
- package/lib/typescript/utils/hooks/core/proofs.d.ts +1 -0
- package/lib/typescript/utils/hooks/core/trust-entity.d.ts +9 -3
- package/lib/typescript/utils/parsers/query.d.ts +3 -2
- package/package.json +10 -5
- package/src/components/entity/entity-attributes.tsx +16 -2
- package/src/components/entity/entity-details-with-buttons.tsx +11 -42
- package/src/components/entity/entity-details.tsx +60 -30
- package/src/components/entity/index.ts +2 -1
- package/src/components/history/history-list-item.tsx +17 -13
- package/src/components/proof-request/share-credential.tsx +0 -1
- package/src/ui-components/blur/index.ts +2 -1
- package/src/ui-components/buttons/hold-button.tsx +6 -5
- package/src/ui-components/camera/index.tsx +2 -1
- package/src/ui-components/control/index.ts +4 -2
- package/src/ui-components/credential/card/credential-details-card.tsx +1 -1
- package/src/ui-components/credential/credential-carousel-images.tsx +15 -8
- package/src/ui-components/entity/entity-cluster.tsx +63 -10
- package/src/ui-components/entity/index.ts +4 -2
- package/src/ui-components/history/history-details.tsx +5 -2
- package/src/ui-components/history/index.ts +6 -3
- package/src/ui-components/icons/entity.tsx +8 -12
- package/src/ui-components/input/index.ts +6 -3
- package/src/ui-components/list/index.ts +4 -2
- package/src/ui-components/loader/index.ts +4 -2
- package/src/ui-components/pin/index.ts +4 -2
- package/src/ui-components/screens/nerd-mode-screen.tsx +1 -1
- package/src/ui-components/searchbar/index.ts +4 -2
- package/src/ui-components/settings/index.ts +10 -5
- package/src/ui-components/state/index.ts +2 -1
- package/src/utils/date.ts +1 -1
- package/src/utils/hooks/connectivity/connectivity.test.ts +7 -2
- package/src/utils/hooks/core/backup.ts +30 -72
- package/src/utils/hooks/core/core-init.ts +5 -3
- package/src/utils/hooks/core/identifiers.ts +22 -1
- package/src/utils/hooks/core/proofs.ts +27 -16
- package/src/utils/hooks/core/trust-entity.ts +45 -11
- package/src/utils/parsers/credential-sharing.tsx +8 -14
- package/src/utils/parsers/query.tsx +12 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Biometry } from './keypad';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { PinCodeScreenActions, PinCodeScreenProps } from './pin-code-screen';
|
|
3
|
+
import { PinCodeScreen } from './pin-code-screen';
|
|
4
|
+
import type { PinLockModalLabels } from './pin-lock';
|
|
5
|
+
import PinLockModal from './pin-lock';
|
|
4
6
|
|
|
5
7
|
export { Biometry, PinCodeScreen, PinCodeScreenActions, PinCodeScreenProps, PinLockModal, PinLockModalLabels };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IdentifierListItem } from '@procivis/react-native-one-core
|
|
1
|
+
import { IdentifierListItem } from '@procivis/react-native-one-core';
|
|
2
2
|
import React, { FunctionComponent, useState } from 'react';
|
|
3
3
|
import { SectionList, StyleSheet, View } from 'react-native';
|
|
4
4
|
import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type { AnimatedSearchBarProps } from './animated-search-bar';
|
|
2
|
+
import AnimatedSearchBar from './animated-search-bar';
|
|
3
|
+
import type { SearchBarProps } from './search-bar';
|
|
4
|
+
import SearchBar from './search-bar';
|
|
3
5
|
|
|
4
6
|
export { AnimatedSearchBar, AnimatedSearchBarProps };
|
|
5
7
|
export { SearchBar, SearchBarProps };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import type { ButtonSettingProps } from './button-setting';
|
|
2
|
+
import ButtonSetting from './button-setting';
|
|
3
|
+
import type { SettingItemProps } from './setting-item';
|
|
4
|
+
import SettingItem from './setting-item';
|
|
5
|
+
import type { SettingItemSeparatorProps } from './setting-item-separator';
|
|
6
|
+
import SettingItemSeparator from './setting-item-separator';
|
|
7
|
+
import type { SettingsButtonProps } from './settings-button';
|
|
8
|
+
import SettingsButton from './settings-button';
|
|
9
|
+
import type { SwitchSettingProps } from './switch-setting';
|
|
10
|
+
import SwitchSetting from './switch-setting';
|
|
6
11
|
|
|
7
12
|
export { ButtonSetting, ButtonSettingProps };
|
|
8
13
|
export { SettingItem, SettingItemProps };
|
package/src/utils/date.ts
CHANGED
|
@@ -8,12 +8,17 @@ jest.mock('@sentry/react-native', () => ({
|
|
|
8
8
|
captureException: () => {},
|
|
9
9
|
}));
|
|
10
10
|
|
|
11
|
+
jest.mock('../core/core-config', () => ({
|
|
12
|
+
getEnabledTransports: () => [],
|
|
13
|
+
useCoreConfig: () => ({}),
|
|
14
|
+
}));
|
|
15
|
+
|
|
11
16
|
jest.mock('@react-native-community/netinfo', () => ({
|
|
12
|
-
addEventListener: () => {},
|
|
17
|
+
addEventListener: () => { },
|
|
13
18
|
}));
|
|
14
19
|
|
|
15
20
|
jest.mock('react-native-bluetooth-state-manager', () => ({
|
|
16
|
-
onStateChange: () => {},
|
|
21
|
+
onStateChange: () => { },
|
|
17
22
|
}));
|
|
18
23
|
|
|
19
24
|
describe('getInvitationUrlTransports', () => {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IdentifierStateEnum, IdentifierTypeEnum } from '@procivis/react-native-one-core';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { reportException } from '../../reporting';
|
|
6
6
|
import { useONECore } from './core-context';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
generateHwIdentifier,
|
|
9
|
+
generateSwIdentifier,
|
|
10
|
+
IdentifiersInitializationConfig,
|
|
11
|
+
SW_DID_NAME_PREFIX,
|
|
12
|
+
} from './core-init';
|
|
9
13
|
import { HISTORY_LIST_QUERY_KEY } from './history';
|
|
10
14
|
|
|
11
15
|
const BACKUP_INFO_QUERY_KEY = 'backup-info';
|
|
@@ -61,6 +65,11 @@ export const useRollbackImport = () => {
|
|
|
61
65
|
});
|
|
62
66
|
};
|
|
63
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Finalize backup import and extract/prepare identifiers
|
|
70
|
+
* @param {IdentifiersInitializationConfig} config Select desired keys/dids to be restored/created
|
|
71
|
+
* @returns [hwIdentifierId, swIdentifierId]
|
|
72
|
+
*/
|
|
64
73
|
export const useBackupFinalizeImportProcedure = ({ generateHwKey, generateSwKey }: IdentifiersInitializationConfig) => {
|
|
65
74
|
const { mutateAsync: finalizeImport } = useFinalizeImport();
|
|
66
75
|
const { core, organisationId } = useONECore();
|
|
@@ -68,77 +77,26 @@ export const useBackupFinalizeImportProcedure = ({ generateHwKey, generateSwKey
|
|
|
68
77
|
return useCallback(async () => {
|
|
69
78
|
await finalizeImport();
|
|
70
79
|
|
|
71
|
-
// update wallet
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
pageSize: 1,
|
|
77
|
-
type: DidTypeEnum.LOCAL,
|
|
78
|
-
});
|
|
79
|
-
let swDidId = dids.values.find((did) => did.name.startsWith(SW_DID_NAME_PREFIX))?.id;
|
|
80
|
-
|
|
81
|
-
if (!swDidId && generateSwKey) {
|
|
82
|
-
const swKeyId = await core.generateKey({
|
|
83
|
-
keyParams: {},
|
|
84
|
-
keyType: 'EDDSA',
|
|
85
|
-
name: `holder-key-sw-${generateUUID()}`,
|
|
86
|
-
organisationId,
|
|
87
|
-
storageParams: {},
|
|
88
|
-
storageType: 'INTERNAL',
|
|
89
|
-
});
|
|
90
|
-
swDidId = await core.createDid({
|
|
91
|
-
didMethod: 'KEY',
|
|
92
|
-
keys: {
|
|
93
|
-
assertionMethod: [swKeyId],
|
|
94
|
-
authentication: [swKeyId],
|
|
95
|
-
capabilityDelegation: [swKeyId],
|
|
96
|
-
capabilityInvocation: [swKeyId],
|
|
97
|
-
keyAgreement: [swKeyId],
|
|
98
|
-
},
|
|
99
|
-
name: `${SW_DID_NAME_PREFIX}-${generateUUID()}`,
|
|
80
|
+
// update wallet identifier references
|
|
81
|
+
let swIdentifierId: string | undefined;
|
|
82
|
+
if (generateSwKey) {
|
|
83
|
+
const identifiers = await core.getIdentifiers({
|
|
84
|
+
state: IdentifierStateEnum.ACTIVE,
|
|
100
85
|
organisationId,
|
|
101
|
-
|
|
86
|
+
page: 0,
|
|
87
|
+
pageSize: 1,
|
|
88
|
+
types: [IdentifierTypeEnum.DID],
|
|
89
|
+
isRemote: false,
|
|
102
90
|
});
|
|
91
|
+
swIdentifierId = identifiers.values.find((identifier) => identifier.name.startsWith(SW_DID_NAME_PREFIX))?.id;
|
|
103
92
|
}
|
|
104
93
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
organisationId,
|
|
113
|
-
storageParams: {},
|
|
114
|
-
storageType: 'SECURE_ELEMENT',
|
|
115
|
-
})
|
|
116
|
-
.catch((e) => {
|
|
117
|
-
// ignore if HW keys not supported by device
|
|
118
|
-
if (e instanceof OneError && e.code === OneErrorCode.KeyStorageNotSupported) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
throw e;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
let hwDidId: string | null = null;
|
|
126
|
-
if (hwKeyId) {
|
|
127
|
-
hwDidId = await core.createDid({
|
|
128
|
-
didMethod: 'KEY',
|
|
129
|
-
keys: {
|
|
130
|
-
assertionMethod: [hwKeyId],
|
|
131
|
-
authentication: [hwKeyId],
|
|
132
|
-
capabilityDelegation: [hwKeyId],
|
|
133
|
-
capabilityInvocation: [hwKeyId],
|
|
134
|
-
keyAgreement: [hwKeyId],
|
|
135
|
-
},
|
|
136
|
-
name: `${HW_DID_NAME_PREFIX}-${generateUUID()}`,
|
|
137
|
-
organisationId,
|
|
138
|
-
params: {},
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return [hwDidId, swDidId] as [string | null, string | undefined];
|
|
94
|
+
return Promise.all([
|
|
95
|
+
generateHwKey ? generateHwIdentifier(core, organisationId) : null,
|
|
96
|
+
!swIdentifierId && generateSwKey ? generateSwIdentifier(core, organisationId) : swIdentifierId,
|
|
97
|
+
]).catch((err) => {
|
|
98
|
+
reportException(err, 'Failed to create base identifiers');
|
|
99
|
+
throw err;
|
|
100
|
+
});
|
|
143
101
|
}, [core, organisationId, finalizeImport, generateHwKey, generateSwKey]);
|
|
144
102
|
};
|
|
@@ -8,7 +8,7 @@ import { OneErrorCode } from './error-code';
|
|
|
8
8
|
export const SW_DID_NAME_PREFIX = 'holder-did-sw-key';
|
|
9
9
|
export const HW_DID_NAME_PREFIX = 'holder-did-hw-key';
|
|
10
10
|
|
|
11
|
-
const generateHwIdentifier = async (core: ONECore, organisationId: string) => {
|
|
11
|
+
export const generateHwIdentifier = async (core: ONECore, organisationId: string) => {
|
|
12
12
|
const hwKeyId = await core
|
|
13
13
|
.generateKey({
|
|
14
14
|
keyParams: {},
|
|
@@ -30,6 +30,7 @@ const generateHwIdentifier = async (core: ONECore, organisationId: string) => {
|
|
|
30
30
|
return core.createIdentifier({
|
|
31
31
|
did: {
|
|
32
32
|
method: 'KEY',
|
|
33
|
+
name: HW_DID_NAME_PREFIX,
|
|
33
34
|
keys: {
|
|
34
35
|
assertionMethod: [hwKeyId],
|
|
35
36
|
authentication: [hwKeyId],
|
|
@@ -47,7 +48,7 @@ const generateHwIdentifier = async (core: ONECore, organisationId: string) => {
|
|
|
47
48
|
return null;
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
const generateSwIdentifier = async (core: ONECore, organisationId: string) => {
|
|
51
|
+
export const generateSwIdentifier = async (core: ONECore, organisationId: string) => {
|
|
51
52
|
const swKeyId = await core.generateKey({
|
|
52
53
|
keyParams: {},
|
|
53
54
|
keyType: 'ECDSA',
|
|
@@ -60,6 +61,7 @@ const generateSwIdentifier = async (core: ONECore, organisationId: string) => {
|
|
|
60
61
|
return core.createIdentifier({
|
|
61
62
|
did: {
|
|
62
63
|
method: 'KEY',
|
|
64
|
+
name: SW_DID_NAME_PREFIX,
|
|
63
65
|
keys: {
|
|
64
66
|
assertionMethod: [swKeyId],
|
|
65
67
|
authentication: [swKeyId],
|
|
@@ -82,7 +84,7 @@ export interface IdentifiersInitializationConfig {
|
|
|
82
84
|
/**
|
|
83
85
|
* Create base local identifiers
|
|
84
86
|
* @param {IdentifiersInitializationConfig} config Select desired keys/dids to be created
|
|
85
|
-
* @returns [
|
|
87
|
+
* @returns [hwIdentifierId, swIdentifierId]
|
|
86
88
|
*/
|
|
87
89
|
export const useInitializeONECoreIdentifiers = ({ generateHwKey, generateSwKey }: IdentifiersInitializationConfig) => {
|
|
88
90
|
const { core, organisationId } = useONECore();
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { IdentifierListQuery, IdentifierStateEnum, IdentifierTypeEnum } from "@procivis/react-native-one-core";
|
|
1
2
|
import { useQuery } from "react-query";
|
|
2
3
|
|
|
4
|
+
import { getQueryKeyFromIdentifierListQueryParams } from "../../parsers";
|
|
3
5
|
import { useONECore } from "./core-context";
|
|
4
6
|
|
|
5
7
|
export const IDENTIFIER_DETAIL_QUERY_KEY = 'identifier-detail';
|
|
8
|
+
export const IDENTIFIER_LIST_QUERY_KEY = 'identifier-list';
|
|
9
|
+
const PAGE_SIZE = 20;
|
|
6
10
|
|
|
7
11
|
export const useIdentifierDetails = (identifierId: string | undefined) => {
|
|
8
12
|
const { core } = useONECore();
|
|
@@ -15,4 +19,21 @@ export const useIdentifierDetails = (identifierId: string | undefined) => {
|
|
|
15
19
|
keepPreviousData: true,
|
|
16
20
|
},
|
|
17
21
|
);
|
|
18
|
-
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const useIdentifiers = (identifierFilter?: Partial<IdentifierListQuery>) => {
|
|
25
|
+
const { core, organisationId } = useONECore();
|
|
26
|
+
|
|
27
|
+
return useQuery(
|
|
28
|
+
[IDENTIFIER_LIST_QUERY_KEY, ...getQueryKeyFromIdentifierListQueryParams(identifierFilter)],
|
|
29
|
+
({ pageParam = 0 }) => (core.getIdentifiers({
|
|
30
|
+
types: [IdentifierTypeEnum.DID],
|
|
31
|
+
isRemote: false,
|
|
32
|
+
page: pageParam,
|
|
33
|
+
state: IdentifierStateEnum.ACTIVE,
|
|
34
|
+
organisationId: organisationId,
|
|
35
|
+
pageSize: PAGE_SIZE,
|
|
36
|
+
...identifierFilter,
|
|
37
|
+
})),
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Config,
|
|
3
3
|
CreateProofRequest,
|
|
4
|
-
|
|
4
|
+
IdentifierListQuery,
|
|
5
5
|
OneError,
|
|
6
6
|
PresentationSubmitCredentialRequest,
|
|
7
7
|
ProofListQuery,
|
|
@@ -16,9 +16,9 @@ import { getQueryKeyFromProofListQueryParams } from '../../parsers/query';
|
|
|
16
16
|
import { Transport } from '../connectivity/connectivity';
|
|
17
17
|
import { useCoreConfig } from './core-config';
|
|
18
18
|
import { useONECore } from './core-context';
|
|
19
|
-
import { useDids } from './dids';
|
|
20
19
|
import { OneErrorCode } from './error-code';
|
|
21
20
|
import { HISTORY_LIST_QUERY_KEY } from './history';
|
|
21
|
+
import { useIdentifiers } from './identifiers';
|
|
22
22
|
import { useProofSchemaDetail } from './proof-schemas';
|
|
23
23
|
|
|
24
24
|
const PAGE_SIZE = 10;
|
|
@@ -198,7 +198,7 @@ export const useProofCreate = () => {
|
|
|
198
198
|
});
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
-
const
|
|
201
|
+
const getIdentifierFilterForProofSchema = (proofSchema: ProofSchema, config: Config): Partial<IdentifierListQuery> => {
|
|
202
202
|
const requestedFormats = proofSchema.proofInputSchemas.map((schema) => schema.credentialSchema.format);
|
|
203
203
|
const requestedFormatsCapabilities = requestedFormats
|
|
204
204
|
.map((format) => config.format[format]?.capabilities)
|
|
@@ -227,12 +227,12 @@ export const useProofForSchemaIdWithTransport = (
|
|
|
227
227
|
const { data: proofSchema } = useProofSchemaDetail(proofSchemaId, enabled);
|
|
228
228
|
const { data: config } = useCoreConfig();
|
|
229
229
|
|
|
230
|
-
const
|
|
231
|
-
() => (proofSchema && config ?
|
|
230
|
+
const identifierFilter = useMemo(
|
|
231
|
+
() => (proofSchema && config ? getIdentifierFilterForProofSchema(proofSchema, config) : undefined),
|
|
232
232
|
[config, proofSchema],
|
|
233
233
|
);
|
|
234
234
|
|
|
235
|
-
const { data:
|
|
235
|
+
const { data: identifiers } = useIdentifiers(identifierFilter);
|
|
236
236
|
const { mutateAsync: createProof } = useProofCreate();
|
|
237
237
|
const { mutateAsync: deleteProof } = useProofDelete();
|
|
238
238
|
|
|
@@ -264,19 +264,28 @@ export const useProofForSchemaIdWithTransport = (
|
|
|
264
264
|
if (enabled) {
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
+
|
|
267
268
|
if (proofState !== ProofStateEnum.CREATED && proofState !== ProofStateEnum.PENDING) {
|
|
268
269
|
setProofId(undefined);
|
|
270
|
+
} else {
|
|
271
|
+
setDeleting(true);
|
|
272
|
+
deleteProof(proofIdRef.current || '')
|
|
273
|
+
.then(() => {
|
|
274
|
+
setProofId(undefined);
|
|
275
|
+
setDeleting(false);
|
|
276
|
+
})
|
|
277
|
+
.catch(() => {});
|
|
269
278
|
}
|
|
270
|
-
}, [enabled, proofState, setProofId]);
|
|
279
|
+
}, [deleteProof, enabled, proofId, proofState, setProofId]);
|
|
271
280
|
|
|
272
281
|
useEffect(() => {
|
|
273
282
|
if (
|
|
274
283
|
deleting ||
|
|
275
284
|
!enabled ||
|
|
276
285
|
proofId ||
|
|
277
|
-
!
|
|
278
|
-
!
|
|
279
|
-
!
|
|
286
|
+
!identifiers ||
|
|
287
|
+
!identifierFilter ||
|
|
288
|
+
!identifiers.values.length ||
|
|
280
289
|
!transport ||
|
|
281
290
|
transport.length === 0
|
|
282
291
|
) {
|
|
@@ -284,16 +293,16 @@ export const useProofForSchemaIdWithTransport = (
|
|
|
284
293
|
}
|
|
285
294
|
|
|
286
295
|
createProof({
|
|
287
|
-
|
|
296
|
+
protocol: VerificationProtocol.OPENID4VP_PROXIMITY_DRAFT00,
|
|
288
297
|
proofSchemaId,
|
|
289
298
|
transport,
|
|
290
|
-
|
|
299
|
+
verifierIdentifierId: identifiers.values[0].id,
|
|
291
300
|
})
|
|
292
301
|
.then((id) => {
|
|
293
302
|
setProofId(id);
|
|
294
303
|
})
|
|
295
304
|
.catch(() => {});
|
|
296
|
-
}, [proofSchemaId,
|
|
305
|
+
}, [proofSchemaId, identifiers, identifierFilter, createProof, enabled, transport, proofId, setProofId, deleting]);
|
|
297
306
|
|
|
298
307
|
return deleting ? undefined : proofId;
|
|
299
308
|
};
|
|
@@ -323,6 +332,7 @@ export const useShareProof = (proofUrlProps: ProofUrlHookParams | undefined, ena
|
|
|
323
332
|
const [sharedProof, setSharedProof] = useState<{
|
|
324
333
|
bleAdapterDisabled: boolean;
|
|
325
334
|
url?: string;
|
|
335
|
+
error?: unknown;
|
|
326
336
|
}>();
|
|
327
337
|
|
|
328
338
|
// reset when proofId changes or the proof was retracted
|
|
@@ -344,12 +354,13 @@ export const useShareProof = (proofUrlProps: ProofUrlHookParams | undefined, ena
|
|
|
344
354
|
url,
|
|
345
355
|
});
|
|
346
356
|
})
|
|
347
|
-
.catch((
|
|
348
|
-
|
|
349
|
-
if (err instanceof OneError && err.cause?.includes('BLE adapter not enabled')) {
|
|
357
|
+
.catch((error: unknown) => {
|
|
358
|
+
if (error instanceof OneError && error.cause?.includes('BLE adapter not enabled')) {
|
|
350
359
|
setSharedProof({
|
|
351
360
|
bleAdapterDisabled: true,
|
|
352
361
|
});
|
|
362
|
+
} else {
|
|
363
|
+
setSharedProof({ error, bleAdapterDisabled: false });
|
|
353
364
|
}
|
|
354
365
|
});
|
|
355
366
|
}, [enabled, proofUrlProps, shareProof, sharedProof]);
|
|
@@ -51,7 +51,6 @@ export const useCreateTrustAnchor = (publisherReference: string) => {
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
// NOTE: As per ONE-5672, only handles DID Identifier details
|
|
55
54
|
export const useTrustEntity = (identifierId: string | undefined) => {
|
|
56
55
|
const { core } = useONECore();
|
|
57
56
|
|
|
@@ -59,9 +58,15 @@ export const useTrustEntity = (identifierId: string | undefined) => {
|
|
|
59
58
|
|
|
60
59
|
return useQuery(
|
|
61
60
|
[TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
62
|
-
() =>
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
() => identifierId && identifierDetail
|
|
62
|
+
? core.resolveTrustEntityByIdentifier({
|
|
63
|
+
identifiers: [{
|
|
64
|
+
certificateId: identifierDetail.type === 'CERTIFICATE' ? identifierDetail.certificates?.[0]?.id : undefined,
|
|
65
|
+
id: identifierId,
|
|
66
|
+
}],
|
|
67
|
+
}).then((result) => {
|
|
68
|
+
return result[identifierId];
|
|
69
|
+
}).catch((e) => {
|
|
65
70
|
if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
|
|
66
71
|
return null;
|
|
67
72
|
}
|
|
@@ -69,20 +74,22 @@ export const useTrustEntity = (identifierId: string | undefined) => {
|
|
|
69
74
|
})
|
|
70
75
|
: undefined,
|
|
71
76
|
{
|
|
72
|
-
enabled: Boolean(identifierDetail
|
|
77
|
+
enabled: Boolean(identifierDetail),
|
|
73
78
|
keepPreviousData: true,
|
|
74
79
|
},
|
|
75
80
|
);
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
export const useRemoteTrustEntity = (
|
|
83
|
+
export const useRemoteTrustEntity = (identifierId: string | undefined) => {
|
|
79
84
|
const { core } = useONECore();
|
|
80
85
|
|
|
86
|
+
const { data: identifierDetail } = useIdentifierDetails(identifierId);
|
|
87
|
+
|
|
81
88
|
return useQuery(
|
|
82
|
-
[REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY,
|
|
83
|
-
() => (did ? core.getRemoteTrustEntity(did) : undefined),
|
|
89
|
+
[REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
90
|
+
() => (identifierDetail?.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined),
|
|
84
91
|
{
|
|
85
|
-
enabled: Boolean(did),
|
|
92
|
+
enabled: Boolean(identifierDetail?.did),
|
|
86
93
|
keepPreviousData: true,
|
|
87
94
|
},
|
|
88
95
|
);
|
|
@@ -92,7 +99,21 @@ export const useCreateRemoteTrustEntity = () => {
|
|
|
92
99
|
const queryClient = useQueryClient();
|
|
93
100
|
const { core } = useONECore();
|
|
94
101
|
|
|
95
|
-
return useMutation(async (request: CreateRemoteTrustEntityRequest) =>
|
|
102
|
+
return useMutation(async (request: Omit<CreateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string, didId?: string }) => {
|
|
103
|
+
const { identifierId, didId } = request
|
|
104
|
+
|
|
105
|
+
let entityDidId = didId;
|
|
106
|
+
|
|
107
|
+
if (identifierId) {
|
|
108
|
+
const identifierDetail = await core.getIdentifier(identifierId);
|
|
109
|
+
entityDidId = identifierDetail?.did?.id;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return core.createRemoteTrustEntity({
|
|
113
|
+
...request,
|
|
114
|
+
didId: entityDidId!,
|
|
115
|
+
})
|
|
116
|
+
}, {
|
|
96
117
|
onSuccess: async () => {
|
|
97
118
|
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
98
119
|
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
@@ -104,7 +125,20 @@ export const useUpdateRemoteTrustEntity = () => {
|
|
|
104
125
|
const queryClient = useQueryClient();
|
|
105
126
|
const { core } = useONECore();
|
|
106
127
|
|
|
107
|
-
return useMutation(async (request: UpdateRemoteTrustEntityRequest) =>
|
|
128
|
+
return useMutation(async (request: Omit<UpdateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string, didId?: string }) => {
|
|
129
|
+
const { identifierId, didId } = request
|
|
130
|
+
|
|
131
|
+
let entityDidId = didId;
|
|
132
|
+
if (identifierId) {
|
|
133
|
+
const identifierDetail = await core.getIdentifier(identifierId);
|
|
134
|
+
entityDidId = identifierDetail?.did?.id;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return core.updateRemoteTrustEntity({
|
|
138
|
+
...request,
|
|
139
|
+
didId: entityDidId!,
|
|
140
|
+
})
|
|
141
|
+
}, {
|
|
108
142
|
onSuccess: async () => {
|
|
109
143
|
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
110
144
|
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
@@ -143,22 +143,16 @@ const getDisplayedAttributes = (
|
|
|
143
143
|
selectiveDisclosureSupported?: boolean,
|
|
144
144
|
selectedFields?: string[],
|
|
145
145
|
): DisplayedAttribute[] => {
|
|
146
|
-
|
|
147
|
-
return credential.claims.map((claim) => ({
|
|
148
|
-
claim,
|
|
149
|
-
id: claim.id,
|
|
150
|
-
status: SelectorStatus.Required,
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
146
|
+
const claims = credential ? spreadClaims(credential.claims) : undefined;
|
|
153
147
|
|
|
154
148
|
return request.fields.map((field) => {
|
|
155
149
|
const selected = !field.required && selectedFields?.includes(field.id);
|
|
156
150
|
const claim =
|
|
157
|
-
credential
|
|
158
|
-
|
|
151
|
+
credential ?
|
|
152
|
+
claims?.find(({ key }) => {
|
|
159
153
|
return key === field.keyMap[credential.id];
|
|
160
|
-
});
|
|
161
|
-
const status = getAttributeSelectorStatus(field, validityState, credential, claim, selected);
|
|
154
|
+
}) : undefined;
|
|
155
|
+
const status = selectiveDisclosureSupported === false ? SelectorStatus.Required : getAttributeSelectorStatus(field, validityState, credential, claim, selected);
|
|
162
156
|
return { claim, field, id: field.id, selected, status };
|
|
163
157
|
});
|
|
164
158
|
};
|
|
@@ -236,7 +230,7 @@ export const shareCredentialCardFromCredential = (
|
|
|
236
230
|
labels: ShareCredentialCardLabels,
|
|
237
231
|
): Omit<CredentialDetailsCardProps, 'expanded'> => {
|
|
238
232
|
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
239
|
-
credential ? { ...credential,
|
|
233
|
+
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
240
234
|
config,
|
|
241
235
|
);
|
|
242
236
|
const notice: CredentialCardNotice | undefined =
|
|
@@ -260,7 +254,7 @@ export const shareCredentialCardFromCredential = (
|
|
|
260
254
|
)
|
|
261
255
|
: missingCredentialCardFromRequest(request, notice, cardTestId, labels);
|
|
262
256
|
const validityState = getValidityState(
|
|
263
|
-
credential ? { ...credential,
|
|
257
|
+
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
264
258
|
);
|
|
265
259
|
const displayedAttributes = getDisplayedAttributes(
|
|
266
260
|
request,
|
|
@@ -320,7 +314,7 @@ export const selectCredentialCardFromCredential = (
|
|
|
320
314
|
labels: ShareCredentialCardLabels,
|
|
321
315
|
): Omit<CredentialDetailsCardProps, 'expanded'> => {
|
|
322
316
|
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
323
|
-
credential ? { ...credential,
|
|
317
|
+
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
324
318
|
config,
|
|
325
319
|
);
|
|
326
320
|
const rightAccessory = <Selector status={selected ? SelectorStatus.SelectedRadio : SelectorStatus.Empty} />;
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CredentialSchemaListQuery,
|
|
4
4
|
DidListQuery,
|
|
5
5
|
HistoryListQuery,
|
|
6
|
+
IdentifierListQuery,
|
|
6
7
|
ProofListQuery,
|
|
7
8
|
ProofSchemaListQuery,
|
|
8
9
|
} from '@procivis/react-native-one-core';
|
|
@@ -22,7 +23,7 @@ export const getQueryKeyFromHistoryListQueryParams = (queryParams?: Partial<Hist
|
|
|
22
23
|
|
|
23
24
|
const {
|
|
24
25
|
entityId,
|
|
25
|
-
|
|
26
|
+
actions,
|
|
26
27
|
entityTypes,
|
|
27
28
|
createdDateFrom,
|
|
28
29
|
createdDateTo,
|
|
@@ -35,7 +36,7 @@ export const getQueryKeyFromHistoryListQueryParams = (queryParams?: Partial<Hist
|
|
|
35
36
|
} = queryParams;
|
|
36
37
|
return [
|
|
37
38
|
entityId,
|
|
38
|
-
|
|
39
|
+
actions,
|
|
39
40
|
entityTypes,
|
|
40
41
|
createdDateFrom,
|
|
41
42
|
createdDateTo,
|
|
@@ -80,3 +81,12 @@ export const getQueryKeyFromDidListQueryParams = (queryParams?: Partial<DidListQ
|
|
|
80
81
|
const { name, did, type, deactivated, keyAlgorithms, keyRoles } = queryParams;
|
|
81
82
|
return [name, did, type, deactivated, keyAlgorithms, keyRoles];
|
|
82
83
|
};
|
|
84
|
+
|
|
85
|
+
export const getQueryKeyFromIdentifierListQueryParams = (queryParams?: Partial<IdentifierListQuery>) => {
|
|
86
|
+
if (!queryParams) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const { isRemote, didMethods, state, keyStorages, keyAlgorithms, exact, keyRoles, types, name } = queryParams;
|
|
91
|
+
return [name, types, state, isRemote, didMethods, keyStorages, keyAlgorithms, exact, keyRoles];
|
|
92
|
+
};
|