@procivis/one-react-native-components 0.3.53 → 0.3.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/credential/credential.js +6 -3
- package/lib/commonjs/components/credential/credential.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item-icon.js +3 -1
- package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
- package/lib/commonjs/components/history/history-list-screen.js +2 -2
- package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
- package/lib/commonjs/components/proof-request/select-credential.js +7 -3
- package/lib/commonjs/components/proof-request/select-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/share-credential.js +6 -9
- package/lib/commonjs/components/proof-request/share-credential.js.map +1 -1
- package/lib/commonjs/ui-components/buttons/index.js +7 -0
- package/lib/commonjs/ui-components/buttons/index.js.map +1 -1
- package/lib/commonjs/ui-components/buttons/share-button.js +54 -0
- package/lib/commonjs/ui-components/buttons/share-button.js.map +1 -0
- package/lib/commonjs/ui-components/credential/card/credential-card.js +14 -29
- package/lib/commonjs/ui-components/credential/card/credential-card.js.map +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js +27 -28
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js +10 -6
- package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js.map +1 -1
- package/lib/commonjs/ui-components/header/header.js +7 -5
- package/lib/commonjs/ui-components/header/header.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-details.js +3 -1
- package/lib/commonjs/ui-components/history/history-details.js.map +1 -1
- package/lib/commonjs/ui-components/icons/icons.js +123 -1
- package/lib/commonjs/ui-components/icons/icons.js.map +1 -1
- package/lib/commonjs/ui-components/index.js +11 -0
- package/lib/commonjs/ui-components/index.js.map +1 -1
- package/lib/commonjs/ui-components/loader/loading-result.js +8 -1
- package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
- package/lib/commonjs/ui-components/nfc/index.js +14 -0
- package/lib/commonjs/ui-components/nfc/index.js.map +1 -0
- package/lib/commonjs/ui-components/nfc/nfc-process.js +77 -0
- package/lib/commonjs/ui-components/nfc/nfc-process.js.map +1 -0
- package/lib/commonjs/ui-components/screens/section-list-screen.js +20 -5
- package/lib/commonjs/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/commonjs/ui-components/searchbar/animated-search-bar.js +10 -8
- package/lib/commonjs/ui-components/searchbar/animated-search-bar.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-init.js +2 -1
- package/lib/commonjs/utils/hooks/core/core-init.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +4 -4
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +13 -3
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/index.js +11 -0
- package/lib/commonjs/utils/hooks/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/nfc/nfc-status.js +40 -0
- package/lib/commonjs/utils/hooks/nfc/nfc-status.js.map +1 -0
- package/lib/commonjs/utils/index.js +12 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js +18 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +1 -1
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/commonjs/utils/url.js +80 -0
- package/lib/commonjs/utils/url.js.map +1 -0
- package/lib/module/components/credential/credential.js +5 -3
- package/lib/module/components/credential/credential.js.map +1 -1
- package/lib/module/components/history/history-list-item-icon.js +3 -1
- package/lib/module/components/history/history-list-item-icon.js.map +1 -1
- package/lib/module/components/history/history-list-screen.js +2 -2
- package/lib/module/components/history/history-list-screen.js.map +1 -1
- package/lib/module/components/proof-request/select-credential.js +5 -2
- package/lib/module/components/proof-request/select-credential.js.map +1 -1
- package/lib/module/components/proof-request/share-credential.js +7 -10
- package/lib/module/components/proof-request/share-credential.js.map +1 -1
- package/lib/module/ui-components/buttons/index.js +2 -1
- package/lib/module/ui-components/buttons/index.js.map +1 -1
- package/lib/module/ui-components/buttons/share-button.js +47 -0
- package/lib/module/ui-components/buttons/share-button.js.map +1 -0
- package/lib/module/ui-components/credential/card/credential-card.js +15 -30
- package/lib/module/ui-components/credential/card/credential-card.js.map +1 -1
- package/lib/module/ui-components/credential/card/credential-details-card.js +27 -28
- package/lib/module/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/module/ui-components/credential/card/credential-details-list-item.js +10 -6
- package/lib/module/ui-components/credential/card/credential-details-list-item.js.map +1 -1
- package/lib/module/ui-components/header/header.js +7 -5
- package/lib/module/ui-components/header/header.js.map +1 -1
- package/lib/module/ui-components/history/history-details.js +4 -2
- package/lib/module/ui-components/history/history-details.js.map +1 -1
- package/lib/module/ui-components/icons/icons.js +117 -0
- package/lib/module/ui-components/icons/icons.js.map +1 -1
- package/lib/module/ui-components/index.js +1 -0
- package/lib/module/ui-components/index.js.map +1 -1
- package/lib/module/ui-components/loader/loading-result.js +8 -1
- package/lib/module/ui-components/loader/loading-result.js.map +1 -1
- package/lib/module/ui-components/nfc/index.js +3 -0
- package/lib/module/ui-components/nfc/index.js.map +1 -0
- package/lib/module/ui-components/nfc/nfc-process.js +69 -0
- package/lib/module/ui-components/nfc/nfc-process.js.map +1 -0
- package/lib/module/ui-components/screens/section-list-screen.js +21 -6
- package/lib/module/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/module/ui-components/searchbar/animated-search-bar.js +10 -8
- package/lib/module/ui-components/searchbar/animated-search-bar.js.map +1 -1
- package/lib/module/utils/hooks/core/backup.js +1 -1
- package/lib/module/utils/hooks/core/backup.js.map +1 -1
- package/lib/module/utils/hooks/core/core-init.js +1 -0
- package/lib/module/utils/hooks/core/core-init.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +4 -4
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +12 -2
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/index.js +1 -0
- package/lib/module/utils/hooks/index.js.map +1 -1
- package/lib/module/utils/hooks/nfc/nfc-status.js +32 -0
- package/lib/module/utils/hooks/nfc/nfc-status.js.map +1 -0
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing.js +18 -1
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/query.js +1 -1
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/module/utils/url.js +71 -0
- package/lib/module/utils/url.js.map +1 -0
- package/lib/typescript/components/proof-request/share-credential.d.ts +4 -5
- package/lib/typescript/ui-components/buttons/index.d.ts +3 -1
- package/lib/typescript/ui-components/buttons/share-button.d.ts +10 -0
- package/lib/typescript/ui-components/credential/card/credential-card.d.ts +1 -0
- package/lib/typescript/ui-components/header/header.d.ts +1 -1
- package/lib/typescript/ui-components/icons/icons.d.ts +5 -0
- package/lib/typescript/ui-components/index.d.ts +1 -0
- package/lib/typescript/ui-components/loader/loading-result.d.ts +2 -0
- package/lib/typescript/ui-components/nfc/index.d.ts +2 -0
- package/lib/typescript/ui-components/nfc/nfc-process.d.ts +17 -0
- package/lib/typescript/ui-components/screens/section-list-screen.d.ts +2 -1
- package/lib/typescript/ui-components/searchbar/animated-search-bar.d.ts +2 -2
- package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
- package/lib/typescript/utils/hooks/core/core-init.d.ts +2 -1
- package/lib/typescript/utils/hooks/core/credentials.d.ts +2 -6
- package/lib/typescript/utils/hooks/core/proofs.d.ts +9 -1
- package/lib/typescript/utils/hooks/index.d.ts +1 -0
- package/lib/typescript/utils/hooks/nfc/nfc-status.d.ts +6 -0
- package/lib/typescript/utils/index.d.ts +1 -0
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +6 -6
- package/lib/typescript/utils/parsers/credential.d.ts +6 -3
- package/lib/typescript/utils/url.d.ts +19 -0
- package/package.json +7 -3
- package/src/components/credential/credential.tsx +4 -2
- package/src/components/history/history-list-item-icon.tsx +2 -0
- package/src/components/history/history-list-screen.tsx +9 -7
- package/src/components/proof-request/select-credential.tsx +4 -2
- package/src/components/proof-request/share-credential.tsx +10 -10
- package/src/ui-components/buttons/index.ts +4 -0
- package/src/ui-components/buttons/share-button.stories.tsx +25 -0
- package/src/ui-components/buttons/share-button.tsx +55 -0
- package/src/ui-components/credential/card/credential-card.stories.tsx +14 -2
- package/src/ui-components/credential/card/credential-card.tsx +16 -23
- package/src/ui-components/credential/card/credential-details-card.stories.tsx +14 -4
- package/src/ui-components/credential/card/credential-details-card.tsx +32 -34
- package/src/ui-components/credential/card/credential-details-list-item.tsx +10 -6
- package/src/ui-components/detail/detail.stories.tsx +3 -3
- package/src/ui-components/header/header.stories.tsx +8 -6
- package/src/ui-components/header/header.tsx +7 -5
- package/src/ui-components/history/history-details.tsx +3 -1
- package/src/ui-components/icons/icons.tsx +107 -0
- package/src/ui-components/index.ts +1 -0
- package/src/ui-components/loader/loading-result.stories.tsx +4 -1
- package/src/ui-components/loader/loading-result.tsx +7 -0
- package/src/ui-components/nfc/index.ts +3 -0
- package/src/ui-components/nfc/nfc-process.tsx +80 -0
- package/src/ui-components/screens/section-list-screen.tsx +21 -4
- package/src/ui-components/searchbar/animated-search-bar.tsx +11 -9
- package/src/utils/hooks/core/backup.ts +5 -2
- package/src/utils/hooks/core/core-init.ts +5 -1
- package/src/utils/hooks/core/credentials.ts +3 -3
- package/src/utils/hooks/core/proofs.ts +20 -5
- package/src/utils/hooks/index.ts +1 -0
- package/src/utils/hooks/nfc/nfc-status.ts +31 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/parsers/credential-sharing.tsx +34 -11
- package/src/utils/parsers/credential.ts +8 -4
- package/src/utils/parsers/query.ts +1 -0
- package/src/utils/url.ts +61 -0
package/src/utils/index.ts
CHANGED
|
@@ -10,7 +10,6 @@ import React from 'react';
|
|
|
10
10
|
import {
|
|
11
11
|
CredentialAttribute,
|
|
12
12
|
CredentialCardProps,
|
|
13
|
-
CredentialDetailsCardProps,
|
|
14
13
|
CredentialHeaderProps,
|
|
15
14
|
Selector,
|
|
16
15
|
SelectorStatus,
|
|
@@ -20,6 +19,7 @@ import { CredentialNoticeWarningIcon, CredentialWarningIcon, RequiredAttributeIc
|
|
|
20
19
|
import { concatTestID } from '../testID';
|
|
21
20
|
import {
|
|
22
21
|
CardLabels,
|
|
22
|
+
CredentialDetailsCardPropsWithoutWidth,
|
|
23
23
|
detailsCardAttributeFromClaim,
|
|
24
24
|
getCredentialCardPropsFromCredential,
|
|
25
25
|
getValidityState,
|
|
@@ -37,7 +37,7 @@ export const validityCheckedCardFromCredential = (
|
|
|
37
37
|
notice: CredentialCardNotice | undefined,
|
|
38
38
|
testID: string,
|
|
39
39
|
labels: ShareCredentialCardLabels,
|
|
40
|
-
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID'> => {
|
|
40
|
+
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID' | 'width'> => {
|
|
41
41
|
let credentialHeaderDetail:
|
|
42
42
|
| Pick<
|
|
43
43
|
CredentialHeaderProps,
|
|
@@ -77,7 +77,7 @@ export const missingCredentialCardFromRequest = (
|
|
|
77
77
|
notice: CredentialCardNotice | undefined,
|
|
78
78
|
testID: string,
|
|
79
79
|
labels: ShareCredentialCardLabels,
|
|
80
|
-
): Omit<CredentialCardProps, 'onHeaderPress' | 'style'> => {
|
|
80
|
+
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'> => {
|
|
81
81
|
return {
|
|
82
82
|
cardImage: undefined,
|
|
83
83
|
color: undefined,
|
|
@@ -145,18 +145,41 @@ const getDisplayedAttributes = (
|
|
|
145
145
|
): DisplayedAttribute[] => {
|
|
146
146
|
const claims = credential ? spreadClaims(credential.claims) : undefined;
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
let fields = request.fields;
|
|
149
|
+
if (credential) {
|
|
150
|
+
const fieldsWithNoKeyMapping = request.fields.filter((field) => !(credential.id in field.keyMap));
|
|
151
|
+
const fullyNestedFields = getFullyNestedFields(request.fields, credential.id);
|
|
152
|
+
|
|
153
|
+
fields = [...fieldsWithNoKeyMapping, ...fullyNestedFields];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return fields.map((field) => {
|
|
149
157
|
const selected = !field.required && selectedFields?.includes(field.id);
|
|
150
|
-
const claim =
|
|
151
|
-
|
|
152
|
-
claims?.find(({ key }) => {
|
|
158
|
+
const claim = credential
|
|
159
|
+
? claims?.find(({ key }) => {
|
|
153
160
|
return key === field.keyMap[credential.id];
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
})
|
|
162
|
+
: undefined;
|
|
163
|
+
const status =
|
|
164
|
+
selectiveDisclosureSupported === false
|
|
165
|
+
? SelectorStatus.Required
|
|
166
|
+
: getAttributeSelectorStatus(field, validityState, credential, claim, selected);
|
|
156
167
|
return { claim, field, id: field.id, selected, status };
|
|
157
168
|
});
|
|
158
169
|
};
|
|
159
170
|
|
|
171
|
+
const getFullyNestedFields = (
|
|
172
|
+
fields: PresentationDefinitionRequestedCredential['fields'],
|
|
173
|
+
credentialId: CredentialDetail['id'],
|
|
174
|
+
) => {
|
|
175
|
+
const allKeys = fields.filter((field) => credentialId in field.keyMap).map((field) => field.keyMap[credentialId]);
|
|
176
|
+
|
|
177
|
+
return fields
|
|
178
|
+
.map((field) => ({ field, key: field.keyMap[credentialId] }))
|
|
179
|
+
.filter(({ key }) => key && allKeys.every((k) => !k.startsWith(`${key}/`)))
|
|
180
|
+
.map(({ field }) => field);
|
|
181
|
+
};
|
|
182
|
+
|
|
160
183
|
export const shareCredentialCardAttributeFromClaim = (
|
|
161
184
|
id: string,
|
|
162
185
|
config: Config,
|
|
@@ -228,7 +251,7 @@ export const shareCredentialCardFromCredential = (
|
|
|
228
251
|
config: Config,
|
|
229
252
|
testID: string,
|
|
230
253
|
labels: ShareCredentialCardLabels,
|
|
231
|
-
):
|
|
254
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
232
255
|
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
233
256
|
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
234
257
|
config,
|
|
@@ -312,7 +335,7 @@ export const selectCredentialCardFromCredential = (
|
|
|
312
335
|
config: Config,
|
|
313
336
|
testID: string,
|
|
314
337
|
labels: ShareCredentialCardLabels,
|
|
315
|
-
):
|
|
338
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
316
339
|
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
317
340
|
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
318
341
|
config,
|
|
@@ -169,7 +169,7 @@ export const getCredentialCardPropsFromCredential = (
|
|
|
169
169
|
notice: CredentialCardNotice | undefined,
|
|
170
170
|
testID: string,
|
|
171
171
|
labels: CardLabels,
|
|
172
|
-
): Omit<CredentialCardProps, 'onHeaderPress' | 'style'> => {
|
|
172
|
+
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'> => {
|
|
173
173
|
const { layoutProperties } = credential.schema;
|
|
174
174
|
|
|
175
175
|
if (hasMsoValidityIssues(credential)) {
|
|
@@ -179,7 +179,7 @@ export const getCredentialCardPropsFromCredential = (
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
const result: Omit<CredentialCardProps, 'onHeaderPress' | 'style'> = {
|
|
182
|
+
const result: Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'> = {
|
|
183
183
|
cardCarouselImages: getCarouselImagesFromClaims(claims, layoutProperties, concatTestID(testID, 'carousel')),
|
|
184
184
|
cardImage: layoutProperties?.background?.image
|
|
185
185
|
? { imageSource: { uri: layoutProperties.background.image } }
|
|
@@ -255,12 +255,16 @@ const detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID
|
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
|
|
258
|
+
export type CredentialDetailsCardPropsWithoutWidth = Omit<CredentialDetailsCardProps, 'expanded' | 'card'> & {
|
|
259
|
+
card: Omit<CredentialCardProps, 'width'>;
|
|
260
|
+
}
|
|
261
|
+
|
|
258
262
|
export const detailsCardFromCredential = (
|
|
259
263
|
credential: CredentialDetail,
|
|
260
264
|
config: Config,
|
|
261
265
|
testID: string,
|
|
262
266
|
labels: CardLabels,
|
|
263
|
-
):
|
|
267
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
264
268
|
return detailsCardFromCredentialWithClaims(credential, credential.claims, config, testID, labels);
|
|
265
269
|
};
|
|
266
270
|
|
|
@@ -270,7 +274,7 @@ export const detailsCardFromCredentialWithClaims = (
|
|
|
270
274
|
config: Config,
|
|
271
275
|
testID: string,
|
|
272
276
|
labels: CardLabels,
|
|
273
|
-
):
|
|
277
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
274
278
|
const attributes: CredentialAttribute[] = claims.map((claim, index) =>
|
|
275
279
|
detailsCardAttributeFromClaim(claim, config, concatTestID(testID, 'attribute', index.toString())),
|
|
276
280
|
);
|
package/src/utils/url.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import Share from 'react-native-share';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Check URL validity
|
|
6
|
+
* @param {string} urlString URL to validate.
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
export const isUrlValid = (urlString: string): boolean => {
|
|
10
|
+
try {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
+
const url = new URL(urlString);
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check URL http(s) validity
|
|
21
|
+
* @param {string} urlString URL to validate.
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export const isValidHttpUrl = (urlString: string): boolean => {
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(urlString);
|
|
27
|
+
return url?.protocol === 'http:' || url?.protocol === 'https:';
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Share URL via share sheet
|
|
35
|
+
* @param {string} url URL to share.
|
|
36
|
+
* @param {string} title _(optional)_ title for iOS share sheet.
|
|
37
|
+
* @returns {boolean}
|
|
38
|
+
*/
|
|
39
|
+
export const shareUrl = async (url: string, title?: string) => {
|
|
40
|
+
if (Platform.OS === 'ios') {
|
|
41
|
+
await Share.open({
|
|
42
|
+
activityItemSources: [
|
|
43
|
+
{
|
|
44
|
+
placeholderItem: { type: 'url', content: url },
|
|
45
|
+
item: {
|
|
46
|
+
default: { type: 'url', content: url },
|
|
47
|
+
},
|
|
48
|
+
subject: title
|
|
49
|
+
? {
|
|
50
|
+
default: title,
|
|
51
|
+
}
|
|
52
|
+
: undefined,
|
|
53
|
+
linkMetadata: { originalUrl: url, url, title },
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
failOnCancel: false,
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
await Share.open({ url, failOnCancel: false });
|
|
60
|
+
}
|
|
61
|
+
};
|