From c35dac5a479cfd3f7ac6cb6dc894216df9f5221f Mon Sep 17 00:00:00 2001 From: Bryce McMath <32586431+bryce-mcmath@users.noreply.github.com> Date: Mon, 28 Aug 2023 09:16:05 -0700 Subject: [PATCH] feat: update to use new OCA package, add setting (#1406) Signed-off-by: Bryce McMath --- app/package.json | 1 + .../assets/branding/credential-branding.ts | 317 +++++++++++------- app/src/index.ts | 14 +- app/src/screens/Developer.tsx | 22 ++ .../stories/Brandings/Brandings.stories.tsx | 7 +- bifold | 2 +- yarn.lock | 46 ++- 7 files changed, 269 insertions(+), 140 deletions(-) diff --git a/app/package.json b/app/package.json index b7f1c32a1..417fa41d0 100644 --- a/app/package.json +++ b/app/package.json @@ -58,6 +58,7 @@ "@formatjs/intl-relativetimeformat": "9.3.1", "@hyperledger/anoncreds-react-native": "^0.1.0", "@hyperledger/aries-askar-react-native": "^0.1.1", + "@hyperledger/aries-oca": "1.0.0-alpha.72", "@hyperledger/indy-vdr-react-native": "^0.1.0", "@react-native-async-storage/async-storage": "1.15.11", "@react-native-community/masked-view": "0.1.11", diff --git a/app/src/assets/branding/credential-branding.ts b/app/src/assets/branding/credential-branding.ts index d594408ff..9e92c18aa 100644 --- a/app/src/assets/branding/credential-branding.ts +++ b/app/src/assets/branding/credential-branding.ts @@ -1,11 +1,12 @@ -import { types } from 'aries-bifold' - -type CardLayoutOverlay11 = types.oca.CardLayoutOverlay11 -type MetaOverlay = types.oca.MetaOverlay -type FormatOverlay = types.oca.FormatOverlay -type CharacterEncodingOverlay = types.oca.CharacterEncodingOverlay -type LabelOverlay = types.oca.LabelOverlay -type CaptureBaseOverlay = types.oca.CaptureBaseOverlay +import { + IBrandingOverlayData, + IOverlayBundleData, + IMetaOverlayData, + ICaptureBaseData, + IFormatOverlayData, + ICharacterEncodingOverlayData, + ILabelOverlayData, +} from '@hyperledger/aries-oca' export enum CREDENTIALS { LSBC_TEST = 'AuJrigKQGRLJajKAebTgWu:3:CL:209526:default', @@ -31,136 +32,203 @@ export enum CREDENTIALS { BC_DIGITAL_ID_PROD = 'RGjWbW1eycP7FrMf4QJvX8:3:CL:13:Person', } -const digitalIdInvitationCardOverlay: CardLayoutOverlay11 = { - captureBase: '', - type: 'spec/overlays/card_layout/1.1', - logo: { - src: require('./invitation-logo.png'), - }, - primaryBackgroundColor: '#003366', - backgroundImageSlice: { - src: require('./invitation-background-image-slice.png'), - }, - backgroundImage: { - src: require('./invitation-primary-background.png'), +// Pilot overlay data +const digitalIdInvitationCardCaptureBaseData: ICaptureBaseData = { + classification: '', + attributes: { + iss_dateint: 'Text', + emailAddress: 'Text', + name: 'Text', + program: 'Text', }, + flagged_attributes: [], + type: 'spec/capture_base/1.0', +} +const digitalIdInvitationCardBrandingOverlayData: IBrandingOverlayData = { + capture_base: '', + type: 'aries/overlays/branding/1.0', + logo: require('./invitation-logo.png'), + primary_background_color: '#003366', + background_image_slice: require('./invitation-background-image-slice.png'), + background_image: require('./invitation-primary-background.png'), +} +const digitalIdInvitationCardMetaOverlayData: IMetaOverlayData = { + capture_base: '', + type: 'spec/overlays/meta/1.0', + language: 'en', + name: 'Pilot Invitation', + issuer: 'Digital Identity and Trust Program', + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', } -const studentCardOverlay: CardLayoutOverlay11 = { - captureBase: '', - type: 'spec/overlays/card_layout/1.1', - logo: { - src: require('./best-bc-logo.png'), - }, - primaryBackgroundColor: '#32674e', - backgroundImage: { - src: require('./best-bc-background-image.jpg'), - }, - backgroundImageSlice: { - src: require('./best-bc-background-image-slice.jpg'), +// Student card overlay data +const studentCardCaptureBaseData: ICaptureBaseData = { + classification: '', + attributes: { + student_first_name: 'Text', + student_last_name: 'Text', + expiry_date: 'DateInt', }, + flagged_attributes: [], + type: 'spec/capture_base/1.0', +} +const studentCardBrandingOverlayData: IBrandingOverlayData = { + capture_base: '', + type: 'aries/overlays/branding/1.0', + logo: require('./best-bc-logo.png'), + primary_background_color: '#32674e', + background_image: require('./best-bc-background-image.jpg'), + background_image_slice: require('./best-bc-background-image-slice.jpg'), +} +const studentCardMetaOverlayDataEn: IMetaOverlayData = { + capture_base: '', + type: 'spec/overlays/meta/1.0', + language: 'en', + name: 'Student', + issuer: 'BestBC College DEMO', + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', +} +const studentCardMetaOverlayDataFr: IMetaOverlayData = { + capture_base: '', + type: 'spec/overlays/meta/1.0', + language: 'fr', + name: 'Student', + issuer: 'BestBC College DEMO', + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', } -const memberCardOverlay: CardLayoutOverlay11 = { - captureBase: '', - type: 'spec/overlays/card_layout/1.1', - logo: { - src: require('./lsbc-logo.jpg'), - }, - primaryBackgroundColor: '#23485A', - secondaryBackgroundColor: '#00698C', - backgroundImage: { - src: require('./lsbc-background-image.jpg'), +// LSBC overlay data +const memberCardCaptureBaseData: ICaptureBaseData = { + classification: '', + attributes: { + 'Member Status': 'Text', + 'Given Name': 'Text', + PPID: 'Text', + 'Member Status Code': 'Text', + Surname: 'Text', }, + flagged_attributes: [], + type: 'spec/capture_base/1.0', +} +const memberCardBrandingOverlayData: IBrandingOverlayData = { + capture_base: '', + type: 'aries/overlays/branding/1.0', + logo: require('./lsbc-logo.jpg'), + primary_background_color: '#23485A', + secondary_background_color: '#00698C', + background_image: require('./lsbc-background-image.jpg'), } -const digitalIdInvitationCardBundle = { - captureBase: {} as CaptureBaseOverlay, - overlays: [ - { - type: 'spec/overlays/meta/1.0', - language: 'en', - name: 'Pilot Invitation', - issuerName: 'Digital Identity and Trust Program', - } as MetaOverlay, - digitalIdInvitationCardOverlay, - ], +const digitalIdInvitationCardBundle: IOverlayBundleData = { + capture_base: digitalIdInvitationCardCaptureBaseData, + overlays: [digitalIdInvitationCardMetaOverlayData, digitalIdInvitationCardBrandingOverlayData], } -const studentCardBundle = { - captureBase: {} as CaptureBaseOverlay, - overlays: [ - { - type: 'spec/overlays/meta/1.0', - language: 'en', - name: 'Student', - issuerName: 'BestBC College DEMO', - } as MetaOverlay, - { - type: 'spec/overlays/meta/1.0', - language: 'fr', - name: 'Student', - issuerName: 'BestBC College DEMO', - } as MetaOverlay, - studentCardOverlay, - ], +const studentCardBundle: IOverlayBundleData = { + capture_base: studentCardCaptureBaseData, + overlays: [studentCardMetaOverlayDataEn, studentCardMetaOverlayDataFr, studentCardBrandingOverlayData], } -const createMemberCardBundle = (demo = false) => { +const createMemberCardBundle = (demo = false): IOverlayBundleData => { return { - captureBase: {} as CaptureBaseOverlay, + capture_base: memberCardCaptureBaseData, overlays: [ { + capture_base: '', type: 'spec/overlays/meta/1.0', language: 'en', name: 'Member Card', - issuerName: demo ? 'Law Society of BC DEMO' : 'Law Society of BC', + issuer: demo ? 'Law Society of BC DEMO' : 'Law Society of BC', watermark: demo ? 'NON-PRODUCTION' : undefined, - } as MetaOverlay, - memberCardOverlay, + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', + } as IMetaOverlayData, + memberCardBrandingOverlayData, ], } } -const createPersonCredentialBundle = (backgroundImageSource: string, verified = true, demo = false) => { - const metaOverlays: MetaOverlay[] = [] +const createPersonCredentialBundle = (verified = true, demo = false): IOverlayBundleData => { + const metaOverlays: IMetaOverlayData[] = [] if (verified) { metaOverlays.push({ - captureBase: '', + capture_base: '', type: 'spec/overlays/meta/1.0', language: 'en', name: 'Person', - issuerName: demo ? 'Service BC DEMO' : 'Service BC', + issuer: demo ? 'Service BC DEMO' : 'Service BC', watermark: demo ? 'NON-PRODUCTION' : undefined, + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', + digest: '', }) metaOverlays.push({ - captureBase: '', + capture_base: '', type: 'spec/overlays/meta/1.0', language: 'fr', name: 'Personne', - issuerName: demo ? 'Service BC DEMO' : 'Service BC', + issuer: demo ? 'Service BC DEMO' : 'Service BC', watermark: demo ? 'NON-PRODUCTION (FR)' : undefined, + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', + digest: '', }) } else { metaOverlays.push({ - captureBase: '', + capture_base: '', type: 'spec/overlays/meta/1.0', language: 'en', name: 'Unverified Person', - issuerName: 'Digital Identity and Trust Program', + issuer: 'Digital Identity and Trust Program', + watermark: undefined, + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', + digest: '', }) metaOverlays.push({ - captureBase: '', + capture_base: '', type: 'spec/overlays/meta/1.0', language: 'fr', name: 'Unverified Personne', - issuerName: 'Digital Identity and Trust Program', + issuer: 'Digital Identity and Trust Program', + watermark: undefined, + description: '', + credential_help_text: '', + credential_support_url: '', + issuer_description: '', + issuer_url: '', + digest: '', }) } const overlay = { - captureBase: { - captureBase: '', - type: 'spec/overlays/capture_base/1.0', + capture_base: { + type: 'spec/capture_base/1.0', + classification: '', + digest: '', attributes: { postal_code: 'Text', given_names: 'Text', @@ -171,81 +239,78 @@ const createPersonCredentialBundle = (backgroundImageSource: string, verified = country: 'Text', birthdate_dateint: 'DateInt', }, - } as CaptureBaseOverlay, + flagged_attributes: [''], + } as ICaptureBaseData, overlays: [ ...metaOverlays, { - captureBase: '', - type: 'spec/overlays/card_layout/1.1', - logo: { - src: require('./bc-logo.jpg'), - }, - primaryBackgroundColor: '#003366', - backgroundImage: { - src: backgroundImageSource, - }, - primaryAttribute: { - name: 'given_names', - }, - secondaryAttribute: { - name: 'family_name', - }, - } as CardLayoutOverlay11, + capture_base: '', + type: 'aries/overlays/branding/1.0', + logo: require('./bc-logo.jpg'), + primary_background_color: '#003366', + background_image: require('./person-background-image.png'), + primary_attribute: 'given_names', + secondary_attribute: 'family_name', + } as IBrandingOverlayData, { - captureBase: '', + capture_base: '', type: 'spec/overlays/format/1.0', language: 'en', - attributeFormats: { + attribute_formats: { birthdate_dateint: 'YYYYMMDD', picture: 'image/jpeg', }, - } as FormatOverlay, + } as IFormatOverlayData, { - captureBase: '', + capture_base: '', type: 'spec/overlays/character_encoding/1.0', - language: 'en', - attributeCharacterEncoding: { + attribute_character_encoding: { + picture: 'base64', + }, + attr_character_encoding: { picture: 'base64', }, - } as CharacterEncodingOverlay, + default_character_encoding: 'utf-8', + } as ICharacterEncodingOverlayData, { - captureBase: '', + capture_base: '', type: 'spec/overlays/label/1.0', language: 'en', - attributeLabels: { + attribute_labels: { given_names: 'Given Names', family_name: 'Family Name', birthdate_dateint: 'Date of Birth', picture: 'Picture', }, - } as LabelOverlay, + attribute_categories: [], + category_labels: {}, + } as ILabelOverlayData, { - captureBase: '', + capture_base: '', type: 'spec/overlays/label/1.0', language: 'fr', - attributeLabels: { + attribute_labels: { given_names: 'Prénoms', family_name: 'Nom de famille', birthdate_dateint: 'Date de naissance', picture: 'Image', }, - } as LabelOverlay, + attribute_categories: [], + category_labels: {}, + } as ILabelOverlayData, ], } - if (demo && overlay.captureBase.attributes) { - overlay.captureBase.attributes.picture = 'Binary' + if (demo && overlay.capture_base.attributes) { + overlay.capture_base.attributes.picture = 'Binary' } return overlay } -// eslint-disable-next-line @typescript-eslint/no-var-requires -const unverifiedPersonCardBundle = createPersonCredentialBundle(require('./person-background-image.png'), false) +const unverifiedPersonCardBundle = createPersonCredentialBundle(false) -// eslint-disable-next-line @typescript-eslint/no-var-requires -const digitalIdCardBundle = createPersonCredentialBundle(require('./person-background-image.png')) +const digitalIdCardBundle = createPersonCredentialBundle() -// eslint-disable-next-line @typescript-eslint/no-var-requires -const demoDigitalIdCardBundle = createPersonCredentialBundle(require('./person-background-image.png'), true, true) +const demoDigitalIdCardBundle = createPersonCredentialBundle(true, true) const memberCardBundle = createMemberCardBundle() diff --git a/app/src/index.ts b/app/src/index.ts index e2079d274..595736e48 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -1,11 +1,5 @@ -import { - translationResources, - ConfigurationContext, - types, - Record, - indyLedgers, - defaultConfiguration, -} from 'aries-bifold' +import { BrandingOverlayType, DefaultOCABundleResolver } from '@hyperledger/aries-oca/build/legacy' +import { translationResources, ConfigurationContext, Record, indyLedgers, defaultConfiguration } from 'aries-bifold' import merge from 'lodash.merge' import { ReducerAction } from 'react' @@ -43,7 +37,9 @@ const configuration: ConfigurationContext = { credentialListOptions: AddCredentialSlider, credentialEmptyList: EmptyList, developer: Developer, - OCABundleResolver: new types.oca.OCABundleResolver(bundles as unknown as types.oca.Bundles), + OCABundleResolver: new DefaultOCABundleResolver(bundles, { + brandingOverlayType: BrandingOverlayType.Branding10, + }), record: Record, indyLedgers: selectedLedgers, settings: [], diff --git a/app/src/screens/Developer.tsx b/app/src/screens/Developer.tsx index a7401b294..3331daae1 100644 --- a/app/src/screens/Developer.tsx +++ b/app/src/screens/Developer.tsx @@ -38,6 +38,7 @@ const Settings: React.FC = () => { ) const [useDevVerifierTemplates, setDevVerifierTemplates] = useState(!!store.preferences.useDevVerifierTemplates) const [enableWalletNaming, setEnableWalletNaming] = useState(!!store.preferences.enableWalletNaming) + const [preventAutoLock, setPreventAutoLock] = useState(!!store.preferences.preventAutoLock) const styles = StyleSheet.create({ container: { @@ -211,6 +212,14 @@ const Settings: React.FC = () => { setEnableWalletNaming((previousState) => !previousState) } + const togglePreventAutoLockSwitch = () => { + dispatch({ + type: DispatchAction.PREVENT_AUTO_LOCK, + payload: [!preventAutoLock], + }) + setPreventAutoLock((previousState) => !previousState) + } + return ( { /> )} + + + ) diff --git a/app/storybook/stories/Brandings/Brandings.stories.tsx b/app/storybook/stories/Brandings/Brandings.stories.tsx index 7acc03a58..351308587 100644 --- a/app/storybook/stories/Brandings/Brandings.stories.tsx +++ b/app/storybook/stories/Brandings/Brandings.stories.tsx @@ -7,6 +7,8 @@ import { CredentialState, RevocationNotification, } from '@aries-framework/core' +import { IOverlayBundleData } from '@hyperledger/aries-oca' +import { BrandingOverlayType, DefaultOCABundleResolver } from '@hyperledger/aries-oca/build/legacy' import { select } from '@storybook/addon-knobs' import { storiesOf } from '@storybook/react-native' import { @@ -14,7 +16,6 @@ import { ConfigurationContext, ConfigurationProvider, StoreContext, - types, contexts, ThemeProvider, } from 'aries-bifold' @@ -126,8 +127,8 @@ const Credentials: FC = ({ items }) => { ) } -const OCABundleResolver = new types.oca.OCABundleResolver(bundles as unknown as Record, { - cardOverlayType: types.oca.CardOverlayType.CardLayout11, +const OCABundleResolver = new DefaultOCABundleResolver(bundles as unknown as Record, { + brandingOverlayType: BrandingOverlayType.Branding10, }) storiesOf('Brandings', module) diff --git a/bifold b/bifold index 60c9cebed..a8bb8ae26 160000 --- a/bifold +++ b/bifold @@ -1 +1 @@ -Subproject commit 60c9cebedaf8827b590f5dbf96c7d6f5c5b40af1 +Subproject commit a8bb8ae261176c4b2b70988171c5894111c8e341 diff --git a/yarn.lock b/yarn.lock index eb7243e28..d7d5f4c52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2663,6 +2663,18 @@ __metadata: languageName: node linkType: hard +"@hyperledger/aries-oca@npm:1.0.0-alpha.72": + version: 1.0.0-alpha.72 + resolution: "@hyperledger/aries-oca@npm:1.0.0-alpha.72" + dependencies: + "@aries-framework/anoncreds": ^0.4.0 + "@aries-framework/core": 0.4.0 + axios: ^1.4.0 + lodash.startcase: ^4.4.0 + checksum: fb0521334e43981f9f39c913ad1a007c3aad36cf39c1288ae75d274c61fac33d55413b54247d44636c821d9e5e739d4bd00e6879cd461ecfd05d17f596b7e0fd + languageName: node + linkType: hard + "@hyperledger/indy-vdr-react-native@npm:^0.1.0": version: 0.1.0 resolution: "@hyperledger/indy-vdr-react-native@npm:0.1.0" @@ -5763,6 +5775,7 @@ __metadata: "@formatjs/intl-relativetimeformat": ^9.2.3 "@hyperledger/anoncreds-react-native": ^0.1.0 "@hyperledger/aries-askar-react-native": ^0.1.1 + "@hyperledger/aries-oca": 1.0.0-alpha.72 "@hyperledger/indy-vdr-react-native": ^0.1.0 "@react-native-async-storage/async-storage": ^1.12.1 "@react-native-community/eslint-config": ^2.0.0 @@ -5862,6 +5875,7 @@ __metadata: "@formatjs/intl-relativetimeformat": ^9.2.3 "@hyperledger/anoncreds-react-native": ^0.1.0 "@hyperledger/aries-askar-react-native": ^0.1.1 + "@hyperledger/aries-oca": 1.0.0-alpha.72 "@hyperledger/indy-vdr-react-native": ^0.1.0 "@react-native-async-storage/async-storage": ^1.12.1 "@react-native-community/masked-view": ^0.1.11 @@ -6226,6 +6240,17 @@ __metadata: languageName: node linkType: hard +"axios@npm:^1.4.0": + version: 1.4.0 + resolution: "axios@npm:1.4.0" + dependencies: + follow-redirects: ^1.15.0 + form-data: ^4.0.0 + proxy-from-env: ^1.1.0 + checksum: 7fb6a4313bae7f45e89d62c70a800913c303df653f19eafec88e56cea2e3821066b8409bc68be1930ecca80e861c52aa787659df0ffec6ad4d451c7816b9386b + languageName: node + linkType: hard + "b64-lite@npm:^1.3.1, b64-lite@npm:^1.4.0": version: 1.4.0 resolution: "b64-lite@npm:1.4.0" @@ -6821,6 +6846,7 @@ __metadata: "@formatjs/intl-relativetimeformat": 9.3.1 "@hyperledger/anoncreds-react-native": ^0.1.0 "@hyperledger/aries-askar-react-native": ^0.1.1 + "@hyperledger/aries-oca": 1.0.0-alpha.72 "@hyperledger/indy-vdr-react-native": ^0.1.0 "@react-native-async-storage/async-storage": 1.15.11 "@react-native-community/eslint-config": ^2.0.0 @@ -10849,7 +10875,7 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.14.0": +"follow-redirects@npm:^1.14.0, follow-redirects@npm:^1.15.0": version: 1.15.2 resolution: "follow-redirects@npm:1.15.2" peerDependenciesMeta: @@ -10928,6 +10954,17 @@ __metadata: languageName: node linkType: hard +"form-data@npm:^4.0.0": + version: 4.0.0 + resolution: "form-data@npm:4.0.0" + dependencies: + asynckit: ^0.4.0 + combined-stream: ^1.0.8 + mime-types: ^2.1.12 + checksum: 01135bf8675f9d5c61ff18e2e2932f719ca4de964e3be90ef4c36aacfc7b9cb2fceb5eca0b7e0190e3383fe51c5b37f4cb80b62ca06a99aaabfcfd6ac7c9328c + languageName: node + linkType: hard + "format@npm:^0.2.0": version: 0.2.2 resolution: "format@npm:0.2.2" @@ -17098,6 +17135,13 @@ __metadata: languageName: node linkType: hard +"proxy-from-env@npm:^1.1.0": + version: 1.1.0 + resolution: "proxy-from-env@npm:1.1.0" + checksum: ed7fcc2ba0a33404958e34d95d18638249a68c430e30fcb6c478497d72739ba64ce9810a24f53a7d921d0c065e5b78e3822759800698167256b04659366ca4d4 + languageName: node + linkType: hard + "prr@npm:~1.0.1": version: 1.0.1 resolution: "prr@npm:1.0.1"