@procivis/one-react-native-components 0.3.27 → 0.3.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +56 -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/credential.js +2 -2
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +23 -86
- 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 +61 -33
- 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 +57 -15
- 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/credential.js +2 -2
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/query.js +21 -85
- 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 +8 -7
- 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 +96 -33
- 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 +73 -23
- package/src/utils/parsers/credential-sharing.tsx +8 -14
- package/src/utils/parsers/credential.ts +2 -1
- package/src/utils/parsers/query.ts +149 -0
- package/src/utils/parsers/query.tsx +0 -82
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CreateRemoteTrustEntityRequest,
|
|
3
|
+
IdentifierTypeEnum,
|
|
3
4
|
ONECore,
|
|
4
5
|
OneError,
|
|
5
6
|
TrustAnchor,
|
|
@@ -51,7 +52,6 @@ export const useCreateTrustAnchor = (publisherReference: string) => {
|
|
|
51
52
|
);
|
|
52
53
|
};
|
|
53
54
|
|
|
54
|
-
// NOTE: As per ONE-5672, only handles DID Identifier details
|
|
55
55
|
export const useTrustEntity = (identifierId: string | undefined) => {
|
|
56
56
|
const { core } = useONECore();
|
|
57
57
|
|
|
@@ -60,29 +60,46 @@ export const useTrustEntity = (identifierId: string | undefined) => {
|
|
|
60
60
|
return useQuery(
|
|
61
61
|
[TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
62
62
|
() =>
|
|
63
|
-
identifierDetail
|
|
64
|
-
? core
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
identifierId && identifierDetail
|
|
64
|
+
? core
|
|
65
|
+
.resolveTrustEntityByIdentifier({
|
|
66
|
+
identifiers: [
|
|
67
|
+
{
|
|
68
|
+
certificateId:
|
|
69
|
+
identifierDetail?.type === IdentifierTypeEnum.CERTIFICATE
|
|
70
|
+
? identifierDetail.certificates?.[0]?.id
|
|
71
|
+
: undefined,
|
|
72
|
+
id: identifierId,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
})
|
|
76
|
+
.then((result) => {
|
|
77
|
+
return result[identifierId]?.[0]?.trustEntity ?? null;
|
|
78
|
+
})
|
|
79
|
+
.catch((e) => {
|
|
80
|
+
if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
throw e;
|
|
84
|
+
})
|
|
70
85
|
: undefined,
|
|
71
86
|
{
|
|
72
|
-
enabled: Boolean(identifierDetail
|
|
87
|
+
enabled: Boolean(identifierDetail),
|
|
73
88
|
keepPreviousData: true,
|
|
74
89
|
},
|
|
75
90
|
);
|
|
76
91
|
};
|
|
77
92
|
|
|
78
|
-
export const useRemoteTrustEntity = (
|
|
93
|
+
export const useRemoteTrustEntity = (identifierId: string | undefined) => {
|
|
79
94
|
const { core } = useONECore();
|
|
80
95
|
|
|
96
|
+
const { data: identifierDetail } = useIdentifierDetails(identifierId);
|
|
97
|
+
|
|
81
98
|
return useQuery(
|
|
82
|
-
[REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY,
|
|
83
|
-
() => (did ? core.getRemoteTrustEntity(did) : undefined),
|
|
99
|
+
[REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
100
|
+
() => (identifierDetail?.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined),
|
|
84
101
|
{
|
|
85
|
-
enabled: Boolean(did),
|
|
102
|
+
enabled: Boolean(identifierDetail?.did),
|
|
86
103
|
keepPreviousData: true,
|
|
87
104
|
},
|
|
88
105
|
);
|
|
@@ -92,24 +109,57 @@ export const useCreateRemoteTrustEntity = () => {
|
|
|
92
109
|
const queryClient = useQueryClient();
|
|
93
110
|
const { core } = useONECore();
|
|
94
111
|
|
|
95
|
-
return useMutation(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
return useMutation(
|
|
113
|
+
async (request: Omit<CreateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string; didId?: string }) => {
|
|
114
|
+
const { identifierId, didId } = request;
|
|
115
|
+
|
|
116
|
+
let entityDidId = didId;
|
|
117
|
+
|
|
118
|
+
if (identifierId) {
|
|
119
|
+
const identifierDetail = await core.getIdentifier(identifierId);
|
|
120
|
+
entityDidId = identifierDetail?.did?.id;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return core.createRemoteTrustEntity({
|
|
124
|
+
...request,
|
|
125
|
+
didId: entityDidId!,
|
|
126
|
+
});
|
|
99
127
|
},
|
|
100
|
-
|
|
128
|
+
{
|
|
129
|
+
onSuccess: async () => {
|
|
130
|
+
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
131
|
+
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
);
|
|
101
135
|
};
|
|
102
136
|
|
|
103
137
|
export const useUpdateRemoteTrustEntity = () => {
|
|
104
138
|
const queryClient = useQueryClient();
|
|
105
139
|
const { core } = useONECore();
|
|
106
140
|
|
|
107
|
-
return useMutation(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
141
|
+
return useMutation(
|
|
142
|
+
async (request: Omit<UpdateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string; didId?: string }) => {
|
|
143
|
+
const { identifierId, didId } = request;
|
|
144
|
+
|
|
145
|
+
let entityDidId = didId;
|
|
146
|
+
if (identifierId) {
|
|
147
|
+
const identifierDetail = await core.getIdentifier(identifierId);
|
|
148
|
+
entityDidId = identifierDetail?.did?.id;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return core.updateRemoteTrustEntity({
|
|
152
|
+
...request,
|
|
153
|
+
didId: entityDidId!,
|
|
154
|
+
});
|
|
111
155
|
},
|
|
112
|
-
|
|
156
|
+
{
|
|
157
|
+
onSuccess: async () => {
|
|
158
|
+
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
159
|
+
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
);
|
|
113
163
|
};
|
|
114
164
|
|
|
115
165
|
export enum TrustManagementEnum {
|
|
@@ -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} />;
|
|
@@ -91,7 +91,8 @@ export const cardHeaderFromCredential = (
|
|
|
91
91
|
testID: string,
|
|
92
92
|
labels: CardHeaderLabels,
|
|
93
93
|
): Omit<CredentialHeaderProps, 'style'> => {
|
|
94
|
-
let credentialDetailPrimary =
|
|
94
|
+
let credentialDetailPrimary =
|
|
95
|
+
formatDateTimeLocalized(new Date(credential.issuanceDate ?? credential.createdDate)) ?? '';
|
|
95
96
|
|
|
96
97
|
let credentialDetailSecondary: string | undefined;
|
|
97
98
|
let credentialDetailErrorColor: boolean | undefined;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CredentialListQuery,
|
|
3
|
+
CredentialSchemaListQuery,
|
|
4
|
+
DidListQuery,
|
|
5
|
+
HistoryListQuery,
|
|
6
|
+
IdentifierListQuery,
|
|
7
|
+
ProofListQuery,
|
|
8
|
+
ProofSchemaListQuery,
|
|
9
|
+
} from '@procivis/react-native-one-core';
|
|
10
|
+
|
|
11
|
+
type QueryKey<ListQuery, ParamList> = ParamList extends ReadonlyArray<keyof ListQuery> // all params are inside the ListQuery
|
|
12
|
+
? keyof ListQuery extends ParamList[number] // all ListQuery fields are in the params
|
|
13
|
+
? Array<ListQuery[keyof ListQuery]>
|
|
14
|
+
: void
|
|
15
|
+
: void; // otherwise produce a wrong return type which should trigger compilation error
|
|
16
|
+
|
|
17
|
+
/** Typecheck that all query params are included in the query key */
|
|
18
|
+
function getQueryKey<ListQuery extends {}, ParamList extends ReadonlyArray<keyof ListQuery>>(
|
|
19
|
+
queryParams: ListQuery,
|
|
20
|
+
params: ParamList,
|
|
21
|
+
): QueryKey<ListQuery, ParamList> {
|
|
22
|
+
return params.map((param) => queryParams[param]) as QueryKey<ListQuery, ParamList>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const getQueryKeyFromCredentialListQueryParams = (queryParams: Partial<CredentialListQuery> = {}) => {
|
|
26
|
+
return getQueryKey(queryParams, [
|
|
27
|
+
'page',
|
|
28
|
+
'pageSize',
|
|
29
|
+
'organisationId',
|
|
30
|
+
'name',
|
|
31
|
+
'searchText',
|
|
32
|
+
'searchType',
|
|
33
|
+
'sort',
|
|
34
|
+
'sortDirection',
|
|
35
|
+
'exact',
|
|
36
|
+
'role',
|
|
37
|
+
'ids',
|
|
38
|
+
'status',
|
|
39
|
+
'include',
|
|
40
|
+
'profile',
|
|
41
|
+
]);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const getQueryKeyFromHistoryListQueryParams = (queryParams: Partial<HistoryListQuery> = {}) => {
|
|
45
|
+
return getQueryKey(queryParams, [
|
|
46
|
+
'page',
|
|
47
|
+
'pageSize',
|
|
48
|
+
'organisationId',
|
|
49
|
+
'entityId',
|
|
50
|
+
'actions',
|
|
51
|
+
'entityTypes',
|
|
52
|
+
'createdDateFrom',
|
|
53
|
+
'createdDateTo',
|
|
54
|
+
'identifierId',
|
|
55
|
+
'credentialId',
|
|
56
|
+
'credentialSchemaId',
|
|
57
|
+
'proofSchemaId',
|
|
58
|
+
'searchText',
|
|
59
|
+
'searchType',
|
|
60
|
+
]);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const getQueryKeyFromCredentialSchemaListQueryParams = (
|
|
64
|
+
queryParams: Partial<CredentialSchemaListQuery> = {},
|
|
65
|
+
) => {
|
|
66
|
+
return getQueryKey(queryParams, [
|
|
67
|
+
'page',
|
|
68
|
+
'pageSize',
|
|
69
|
+
'organisationId',
|
|
70
|
+
'name',
|
|
71
|
+
'sort',
|
|
72
|
+
'sortDirection',
|
|
73
|
+
'exact',
|
|
74
|
+
'ids',
|
|
75
|
+
'include',
|
|
76
|
+
'schemaId',
|
|
77
|
+
'formats',
|
|
78
|
+
]);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const getQueryKeyFromProofSchemaListQueryParams = (queryParams: Partial<ProofSchemaListQuery> = {}) => {
|
|
82
|
+
return getQueryKey(queryParams, [
|
|
83
|
+
'page',
|
|
84
|
+
'pageSize',
|
|
85
|
+
'organisationId',
|
|
86
|
+
'name',
|
|
87
|
+
'sort',
|
|
88
|
+
'sortDirection',
|
|
89
|
+
'exact',
|
|
90
|
+
'ids',
|
|
91
|
+
'formats',
|
|
92
|
+
]);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const getQueryKeyFromProofListQueryParams = (queryParams: Partial<ProofListQuery> = {}) => {
|
|
96
|
+
return getQueryKey(queryParams, [
|
|
97
|
+
'page',
|
|
98
|
+
'pageSize',
|
|
99
|
+
'organisationId',
|
|
100
|
+
'sort',
|
|
101
|
+
'sortDirection',
|
|
102
|
+
'name',
|
|
103
|
+
'ids',
|
|
104
|
+
'proofStates',
|
|
105
|
+
'proofRoles',
|
|
106
|
+
'proofSchemaIds',
|
|
107
|
+
'exact',
|
|
108
|
+
'profile',
|
|
109
|
+
]);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const getQueryKeyFromDidListQueryParams = (queryParams: Partial<DidListQuery> = {}) => {
|
|
113
|
+
return getQueryKey(queryParams, [
|
|
114
|
+
'page',
|
|
115
|
+
'pageSize',
|
|
116
|
+
'organisationId',
|
|
117
|
+
'sort',
|
|
118
|
+
'sortDirection',
|
|
119
|
+
'name',
|
|
120
|
+
'did',
|
|
121
|
+
'type',
|
|
122
|
+
'deactivated',
|
|
123
|
+
'exact',
|
|
124
|
+
'keyAlgorithms',
|
|
125
|
+
'keyRoles',
|
|
126
|
+
'keyStorages',
|
|
127
|
+
'keyIds',
|
|
128
|
+
'didMethods',
|
|
129
|
+
]);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const getQueryKeyFromIdentifierListQueryParams = (queryParams: Partial<IdentifierListQuery> = {}) => {
|
|
133
|
+
return getQueryKey(queryParams, [
|
|
134
|
+
'page',
|
|
135
|
+
'pageSize',
|
|
136
|
+
'organisationId',
|
|
137
|
+
'sort',
|
|
138
|
+
'sortDirection',
|
|
139
|
+
'name',
|
|
140
|
+
'types',
|
|
141
|
+
'state',
|
|
142
|
+
'exact',
|
|
143
|
+
'didMethods',
|
|
144
|
+
'isRemote',
|
|
145
|
+
'keyAlgorithms',
|
|
146
|
+
'keyRoles',
|
|
147
|
+
'keyStorages',
|
|
148
|
+
]);
|
|
149
|
+
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CredentialListQuery,
|
|
3
|
-
CredentialSchemaListQuery,
|
|
4
|
-
DidListQuery,
|
|
5
|
-
HistoryListQuery,
|
|
6
|
-
ProofListQuery,
|
|
7
|
-
ProofSchemaListQuery,
|
|
8
|
-
} from '@procivis/react-native-one-core';
|
|
9
|
-
|
|
10
|
-
export const getQueryKeyFromCredentialListQueryParams = (queryParams?: Partial<CredentialListQuery>) => {
|
|
11
|
-
if (!queryParams) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
const { name, sort, sortDirection, exact, role, ids, status, include } = queryParams;
|
|
15
|
-
return [name, sort, sortDirection, exact, role, ids, status, include];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const getQueryKeyFromHistoryListQueryParams = (queryParams?: Partial<HistoryListQuery>) => {
|
|
19
|
-
if (!queryParams) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
entityId,
|
|
25
|
-
action,
|
|
26
|
-
entityTypes,
|
|
27
|
-
createdDateFrom,
|
|
28
|
-
createdDateTo,
|
|
29
|
-
identifierId,
|
|
30
|
-
credentialId,
|
|
31
|
-
credentialSchemaId,
|
|
32
|
-
searchText,
|
|
33
|
-
searchType,
|
|
34
|
-
proofSchemaId,
|
|
35
|
-
} = queryParams;
|
|
36
|
-
return [
|
|
37
|
-
entityId,
|
|
38
|
-
action,
|
|
39
|
-
entityTypes,
|
|
40
|
-
createdDateFrom,
|
|
41
|
-
createdDateTo,
|
|
42
|
-
identifierId,
|
|
43
|
-
credentialId,
|
|
44
|
-
credentialSchemaId,
|
|
45
|
-
searchText,
|
|
46
|
-
searchType,
|
|
47
|
-
proofSchemaId,
|
|
48
|
-
];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getQueryKeyFromCredentialSchemaListQueryParams = (queryParams?: Partial<CredentialSchemaListQuery>) => {
|
|
52
|
-
if (!queryParams) {
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
const { name, sort, sortDirection, exact, ids, include } = queryParams;
|
|
56
|
-
return [name, sort, sortDirection, exact, ids, include];
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const getQueryKeyFromProofSchemaListQueryParams = (queryParams?: Partial<ProofSchemaListQuery>) => {
|
|
60
|
-
if (!queryParams) {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
const { name, sort, sortDirection, exact, ids } = queryParams;
|
|
64
|
-
return [name, sort, sortDirection, exact, ids];
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const getQueryKeyFromProofListQueryParams = (queryParams?: Partial<ProofListQuery>) => {
|
|
68
|
-
if (!queryParams) {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
const { name, sort, sortDirection, exact, ids, proofStates, proofSchemaIds } = queryParams;
|
|
72
|
-
return [name, sort, sortDirection, exact, ids, proofStates, proofSchemaIds];
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const getQueryKeyFromDidListQueryParams = (queryParams?: Partial<DidListQuery>) => {
|
|
76
|
-
if (!queryParams) {
|
|
77
|
-
return [];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const { name, did, type, deactivated, keyAlgorithms, keyRoles } = queryParams;
|
|
81
|
-
return [name, did, type, deactivated, keyAlgorithms, keyRoles];
|
|
82
|
-
};
|