@procivis/one-react-native-components 0.3.22 → 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 +15 -2
- package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +14 -38
- package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details.js +63 -34
- 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-icon.js +4 -1
- package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item.js +15 -3
- package/lib/commonjs/components/history/history-list-item.js.map +1 -1
- package/lib/commonjs/components/history/history-list-screen.js +2 -0
- package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
- package/lib/commonjs/components/proof-request/share-credential.js +2 -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 +51 -3
- 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 +26 -1
- package/lib/commonjs/ui-components/icons/entity.js.map +1 -1
- package/lib/commonjs/ui-components/icons/history.js +3 -1
- package/lib/commonjs/ui-components/icons/history.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 +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 +33 -25
- package/lib/commonjs/utils/hooks/core/core-init.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +2 -1
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js +42 -0
- package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -0
- package/lib/commonjs/utils/hooks/core/index.js +11 -0
- package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +26 -15
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js +60 -13
- package/lib/commonjs/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js +9 -15
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +7 -0
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +22 -4
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/module/components/entity/entity-attributes.js +16 -3
- package/lib/module/components/entity/entity-attributes.js.map +1 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +16 -40
- package/lib/module/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/module/components/entity/entity-details.js +65 -36
- 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-icon.js +5 -2
- package/lib/module/components/history/history-list-item-icon.js.map +1 -1
- package/lib/module/components/history/history-list-item.js +16 -4
- package/lib/module/components/history/history-list-item.js.map +1 -1
- package/lib/module/components/history/history-list-screen.js +2 -0
- package/lib/module/components/history/history-list-screen.js.map +1 -1
- package/lib/module/components/proof-request/share-credential.js +2 -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 +52 -4
- 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 +24 -0
- package/lib/module/ui-components/icons/entity.js.map +1 -1
- package/lib/module/ui-components/icons/history.js +2 -0
- package/lib/module/ui-components/icons/history.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 +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 +30 -24
- package/lib/module/utils/hooks/core/core-init.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +2 -1
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/identifiers.js +34 -0
- package/lib/module/utils/hooks/core/identifiers.js.map +1 -0
- package/lib/module/utils/hooks/core/index.js +1 -0
- package/lib/module/utils/hooks/core/index.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +26 -15
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-entity.js +60 -13
- package/lib/module/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing.js +9 -15
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +7 -0
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/query.js +20 -3
- 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 +2 -2
- package/lib/typescript/components/entity/entity-details.d.ts +4 -2
- package/lib/typescript/components/entity/index.d.ts +2 -1
- package/lib/typescript/components/history/history-list-item.d.ts +1 -0
- package/lib/typescript/components/history/history-list-screen.d.ts +2 -0
- 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/icons/entity.d.ts +1 -0
- package/lib/typescript/ui-components/icons/history.d.ts +2 -0
- 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 +4 -4
- 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/credentials.d.ts +2 -1
- package/lib/typescript/utils/hooks/core/identifiers.d.ts +5 -0
- package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
- package/lib/typescript/utils/hooks/core/proofs.d.ts +3 -1
- package/lib/typescript/utils/hooks/core/trust-entity.d.ts +10 -4
- package/lib/typescript/utils/parsers/query.d.ts +3 -2
- package/package.json +9 -4
- package/src/components/entity/entity-attributes.tsx +17 -3
- package/src/components/entity/entity-details-with-buttons.tsx +17 -42
- package/src/components/entity/entity-details.tsx +64 -37
- package/src/components/entity/index.ts +2 -1
- package/src/components/history/history-list-item-icon.tsx +5 -0
- package/src/components/history/history-list-item.tsx +19 -4
- package/src/components/history/history-list-screen.tsx +4 -1
- package/src/components/proof-request/share-credential.tsx +1 -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 +23 -0
- package/src/ui-components/icons/history.tsx +2 -0
- 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 +5 -5
- 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 +29 -23
- package/src/utils/hooks/core/credentials.ts +9 -3
- package/src/utils/hooks/core/identifiers.ts +39 -0
- package/src/utils/hooks/core/index.ts +2 -1
- package/src/utils/hooks/core/proofs.ts +31 -18
- package/src/utils/hooks/core/trust-entity.ts +55 -17
- package/src/utils/parsers/credential-sharing.tsx +30 -36
- package/src/utils/parsers/credential.ts +4 -0
- package/src/utils/parsers/query.tsx +14 -4
|
@@ -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;
|
|
@@ -75,13 +75,15 @@ export const useProofAccept = () => {
|
|
|
75
75
|
interactionId,
|
|
76
76
|
credentials,
|
|
77
77
|
didId,
|
|
78
|
+
identifierId,
|
|
78
79
|
keyId,
|
|
79
80
|
}: {
|
|
80
81
|
credentials: Record<string, PresentationSubmitCredentialRequest>;
|
|
81
|
-
didId
|
|
82
|
+
didId?: string;
|
|
83
|
+
identifierId?: string;
|
|
82
84
|
interactionId: string;
|
|
83
85
|
keyId?: string;
|
|
84
|
-
}) => core.holderSubmitProof(interactionId, credentials, didId, keyId),
|
|
86
|
+
}) => core.holderSubmitProof(interactionId, credentials, didId, identifierId, keyId),
|
|
85
87
|
{
|
|
86
88
|
onError: async () => {
|
|
87
89
|
await queryClient.invalidateQueries(PROOF_DETAIL_QUERY_KEY);
|
|
@@ -196,7 +198,7 @@ export const useProofCreate = () => {
|
|
|
196
198
|
});
|
|
197
199
|
};
|
|
198
200
|
|
|
199
|
-
const
|
|
201
|
+
const getIdentifierFilterForProofSchema = (proofSchema: ProofSchema, config: Config): Partial<IdentifierListQuery> => {
|
|
200
202
|
const requestedFormats = proofSchema.proofInputSchemas.map((schema) => schema.credentialSchema.format);
|
|
201
203
|
const requestedFormatsCapabilities = requestedFormats
|
|
202
204
|
.map((format) => config.format[format]?.capabilities)
|
|
@@ -225,12 +227,12 @@ export const useProofForSchemaIdWithTransport = (
|
|
|
225
227
|
const { data: proofSchema } = useProofSchemaDetail(proofSchemaId, enabled);
|
|
226
228
|
const { data: config } = useCoreConfig();
|
|
227
229
|
|
|
228
|
-
const
|
|
229
|
-
() => (proofSchema && config ?
|
|
230
|
+
const identifierFilter = useMemo(
|
|
231
|
+
() => (proofSchema && config ? getIdentifierFilterForProofSchema(proofSchema, config) : undefined),
|
|
230
232
|
[config, proofSchema],
|
|
231
233
|
);
|
|
232
234
|
|
|
233
|
-
const { data:
|
|
235
|
+
const { data: identifiers } = useIdentifiers(identifierFilter);
|
|
234
236
|
const { mutateAsync: createProof } = useProofCreate();
|
|
235
237
|
const { mutateAsync: deleteProof } = useProofDelete();
|
|
236
238
|
|
|
@@ -262,19 +264,28 @@ export const useProofForSchemaIdWithTransport = (
|
|
|
262
264
|
if (enabled) {
|
|
263
265
|
return;
|
|
264
266
|
}
|
|
267
|
+
|
|
265
268
|
if (proofState !== ProofStateEnum.CREATED && proofState !== ProofStateEnum.PENDING) {
|
|
266
269
|
setProofId(undefined);
|
|
270
|
+
} else {
|
|
271
|
+
setDeleting(true);
|
|
272
|
+
deleteProof(proofIdRef.current || '')
|
|
273
|
+
.then(() => {
|
|
274
|
+
setProofId(undefined);
|
|
275
|
+
setDeleting(false);
|
|
276
|
+
})
|
|
277
|
+
.catch(() => {});
|
|
267
278
|
}
|
|
268
|
-
}, [enabled, proofState, setProofId]);
|
|
279
|
+
}, [deleteProof, enabled, proofId, proofState, setProofId]);
|
|
269
280
|
|
|
270
281
|
useEffect(() => {
|
|
271
282
|
if (
|
|
272
283
|
deleting ||
|
|
273
284
|
!enabled ||
|
|
274
285
|
proofId ||
|
|
275
|
-
!
|
|
276
|
-
!
|
|
277
|
-
!
|
|
286
|
+
!identifiers ||
|
|
287
|
+
!identifierFilter ||
|
|
288
|
+
!identifiers.values.length ||
|
|
278
289
|
!transport ||
|
|
279
290
|
transport.length === 0
|
|
280
291
|
) {
|
|
@@ -282,16 +293,16 @@ export const useProofForSchemaIdWithTransport = (
|
|
|
282
293
|
}
|
|
283
294
|
|
|
284
295
|
createProof({
|
|
285
|
-
|
|
296
|
+
protocol: VerificationProtocol.OPENID4VP_PROXIMITY_DRAFT00,
|
|
286
297
|
proofSchemaId,
|
|
287
298
|
transport,
|
|
288
|
-
|
|
299
|
+
verifierIdentifierId: identifiers.values[0].id,
|
|
289
300
|
})
|
|
290
301
|
.then((id) => {
|
|
291
302
|
setProofId(id);
|
|
292
303
|
})
|
|
293
304
|
.catch(() => {});
|
|
294
|
-
}, [proofSchemaId,
|
|
305
|
+
}, [proofSchemaId, identifiers, identifierFilter, createProof, enabled, transport, proofId, setProofId, deleting]);
|
|
295
306
|
|
|
296
307
|
return deleting ? undefined : proofId;
|
|
297
308
|
};
|
|
@@ -321,6 +332,7 @@ export const useShareProof = (proofUrlProps: ProofUrlHookParams | undefined, ena
|
|
|
321
332
|
const [sharedProof, setSharedProof] = useState<{
|
|
322
333
|
bleAdapterDisabled: boolean;
|
|
323
334
|
url?: string;
|
|
335
|
+
error?: unknown;
|
|
324
336
|
}>();
|
|
325
337
|
|
|
326
338
|
// reset when proofId changes or the proof was retracted
|
|
@@ -342,12 +354,13 @@ export const useShareProof = (proofUrlProps: ProofUrlHookParams | undefined, ena
|
|
|
342
354
|
url,
|
|
343
355
|
});
|
|
344
356
|
})
|
|
345
|
-
.catch((
|
|
346
|
-
|
|
347
|
-
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')) {
|
|
348
359
|
setSharedProof({
|
|
349
360
|
bleAdapterDisabled: true,
|
|
350
361
|
});
|
|
362
|
+
} else {
|
|
363
|
+
setSharedProof({ error, bleAdapterDisabled: false });
|
|
351
364
|
}
|
|
352
365
|
});
|
|
353
366
|
}, [enabled, proofUrlProps, shareProof, sharedProof]);
|
|
@@ -13,6 +13,7 @@ import { useHTTPClient } from '../http/client';
|
|
|
13
13
|
import { useONECore } from './core-context';
|
|
14
14
|
import { OneErrorCode } from './error-code';
|
|
15
15
|
import { HISTORY_LIST_QUERY_KEY } from './history';
|
|
16
|
+
import { useIdentifierDetails } from './identifiers';
|
|
16
17
|
|
|
17
18
|
export const TRUST_ENTITY_DETAIL_QUERY_KEY = 'trust-entity-detail';
|
|
18
19
|
export const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = 'remote-trust-entity-detail';
|
|
@@ -50,35 +51,45 @@ export const useCreateTrustAnchor = (publisherReference: string) => {
|
|
|
50
51
|
);
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
export const useTrustEntity = (
|
|
54
|
+
export const useTrustEntity = (identifierId: string | undefined) => {
|
|
54
55
|
const { core } = useONECore();
|
|
55
56
|
|
|
57
|
+
const { data: identifierDetail } = useIdentifierDetails(identifierId);
|
|
58
|
+
|
|
56
59
|
return useQuery(
|
|
57
|
-
[TRUST_ENTITY_DETAIL_QUERY_KEY,
|
|
58
|
-
() =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
[TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
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) => {
|
|
70
|
+
if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
throw e;
|
|
74
|
+
})
|
|
66
75
|
: undefined,
|
|
67
76
|
{
|
|
68
|
-
enabled: Boolean(
|
|
77
|
+
enabled: Boolean(identifierDetail),
|
|
69
78
|
keepPreviousData: true,
|
|
70
79
|
},
|
|
71
80
|
);
|
|
72
81
|
};
|
|
73
82
|
|
|
74
|
-
export const useRemoteTrustEntity = (
|
|
83
|
+
export const useRemoteTrustEntity = (identifierId: string | undefined) => {
|
|
75
84
|
const { core } = useONECore();
|
|
76
85
|
|
|
86
|
+
const { data: identifierDetail } = useIdentifierDetails(identifierId);
|
|
87
|
+
|
|
77
88
|
return useQuery(
|
|
78
|
-
[REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY,
|
|
79
|
-
() => (did ? core.getRemoteTrustEntity(did) : undefined),
|
|
89
|
+
[REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
90
|
+
() => (identifierDetail?.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined),
|
|
80
91
|
{
|
|
81
|
-
enabled: Boolean(did),
|
|
92
|
+
enabled: Boolean(identifierDetail?.did),
|
|
82
93
|
keepPreviousData: true,
|
|
83
94
|
},
|
|
84
95
|
);
|
|
@@ -88,7 +99,21 @@ export const useCreateRemoteTrustEntity = () => {
|
|
|
88
99
|
const queryClient = useQueryClient();
|
|
89
100
|
const { core } = useONECore();
|
|
90
101
|
|
|
91
|
-
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
|
+
}, {
|
|
92
117
|
onSuccess: async () => {
|
|
93
118
|
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
94
119
|
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
@@ -100,7 +125,20 @@ export const useUpdateRemoteTrustEntity = () => {
|
|
|
100
125
|
const queryClient = useQueryClient();
|
|
101
126
|
const { core } = useONECore();
|
|
102
127
|
|
|
103
|
-
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
|
+
}, {
|
|
104
142
|
onSuccess: async () => {
|
|
105
143
|
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
106
144
|
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
@@ -40,13 +40,13 @@ export const validityCheckedCardFromCredential = (
|
|
|
40
40
|
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID'> => {
|
|
41
41
|
let credentialHeaderDetail:
|
|
42
42
|
| Pick<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
CredentialHeaderProps,
|
|
44
|
+
| 'credentialDetailPrimary'
|
|
45
|
+
| 'credentialDetailSecondary'
|
|
46
|
+
| 'credentialDetailErrorColor'
|
|
47
|
+
| 'credentialDetailTestID'
|
|
48
|
+
| 'statusIcon'
|
|
49
|
+
>
|
|
50
50
|
| undefined;
|
|
51
51
|
if (invalidLVVC) {
|
|
52
52
|
credentialHeaderDetail = {
|
|
@@ -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,31 +230,31 @@ 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 =
|
|
243
237
|
selectiveDisclosureSupported === false
|
|
244
238
|
? {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
239
|
+
text: labels.selectiveDisclosureNotice,
|
|
240
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
241
|
+
}
|
|
248
242
|
: undefined;
|
|
249
243
|
const cardTestId = concatTestID(testID, 'card');
|
|
250
244
|
const card = credential
|
|
251
245
|
? validityCheckedCardFromCredential(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
246
|
+
credential,
|
|
247
|
+
invalidLVVC,
|
|
248
|
+
expanded,
|
|
249
|
+
multipleCredentialsAvailable,
|
|
250
|
+
config,
|
|
251
|
+
notice,
|
|
252
|
+
cardTestId,
|
|
253
|
+
labels,
|
|
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,16 +314,16 @@ 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} />;
|
|
327
321
|
const notice: CredentialCardNotice | undefined =
|
|
328
322
|
selectiveDisclosureSupported === false
|
|
329
323
|
? {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
324
|
+
text: labels.selectiveDisclosureNotice,
|
|
325
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
326
|
+
}
|
|
333
327
|
: undefined;
|
|
334
328
|
const { header, ...cardProps } = getCredentialCardPropsFromCredential(
|
|
335
329
|
credential,
|
|
@@ -231,6 +231,10 @@ const detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID
|
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
case DataTypeEnum.Date: {
|
|
234
|
+
if (!claim.value) {
|
|
235
|
+
// Don't try to parse empty values (which will return "Invalid Date")
|
|
236
|
+
return { testID: testID, value: String(claim.value) };
|
|
237
|
+
}
|
|
234
238
|
const date = claim.value as string;
|
|
235
239
|
return {
|
|
236
240
|
testID: testID,
|
|
@@ -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,11 +23,11 @@ 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,
|
|
29
|
-
|
|
30
|
+
identifierId,
|
|
30
31
|
credentialId,
|
|
31
32
|
credentialSchemaId,
|
|
32
33
|
searchText,
|
|
@@ -35,11 +36,11 @@ 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,
|
|
42
|
-
|
|
43
|
+
identifierId,
|
|
43
44
|
credentialId,
|
|
44
45
|
credentialSchemaId,
|
|
45
46
|
searchText,
|
|
@@ -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
|
+
};
|