@bifold/core 2.4.6 → 2.5.0
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/contexts/reducers/store.js +3 -2
- package/lib/commonjs/contexts/reducers/store.js.map +1 -1
- package/lib/commonjs/index.js +119 -104
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/screens/AttemptLockout.js +27 -35
- package/lib/commonjs/screens/AttemptLockout.js.map +1 -1
- package/lib/commonjs/screens/MobileVerifierLoading.js +4 -3
- package/lib/commonjs/screens/MobileVerifierLoading.js.map +1 -1
- package/lib/commonjs/screens/PINCreate.js +3 -10
- package/lib/commonjs/screens/PINCreate.js.map +1 -1
- package/lib/commonjs/screens/WhatAreContacts.js +3 -2
- package/lib/commonjs/screens/WhatAreContacts.js.map +1 -1
- package/lib/module/contexts/reducers/store.js +3 -2
- package/lib/module/contexts/reducers/store.js.map +1 -1
- package/lib/module/index.js +42 -45
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/AttemptLockout.js +28 -36
- package/lib/module/screens/AttemptLockout.js.map +1 -1
- package/lib/module/screens/MobileVerifierLoading.js +4 -3
- package/lib/module/screens/MobileVerifierLoading.js.map +1 -1
- package/lib/module/screens/PINCreate.js +3 -10
- package/lib/module/screens/PINCreate.js.map +1 -1
- package/lib/module/screens/WhatAreContacts.js +3 -2
- package/lib/module/screens/WhatAreContacts.js.map +1 -1
- package/lib/typescript/src/contexts/reducers/store.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +57 -61
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/AttemptLockout.d.ts.map +1 -1
- package/lib/typescript/src/screens/MobileVerifierLoading.d.ts.map +1 -1
- package/lib/typescript/src/screens/PINCreate.d.ts.map +1 -1
- package/lib/typescript/src/screens/WhatAreContacts.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/App.tsx +0 -79
- package/src/animated-components.ts +0 -30
- package/src/assets/fonts/MaterialIcons.ttf +0 -0
- package/src/assets/icons/code.svg +0 -4
- package/src/assets/icons/large-arrow.svg +0 -5
- package/src/assets/icons/pencil.svg +0 -15
- package/src/assets/icons/trash.svg +0 -31
- package/src/assets/img/Artwork_1024x1024.png +0 -0
- package/src/assets/img/HistoryCardAcceptedIcon.svg +0 -4
- package/src/assets/img/HistoryCardExpiredIcon.svg +0 -4
- package/src/assets/img/HistoryCardRevokedIcon.svg +0 -4
- package/src/assets/img/HistoryInformationSentIcon.svg +0 -4
- package/src/assets/img/HistoryPinUpdatedIcon.svg +0 -4
- package/src/assets/img/IconChevronRight.svg +0 -5
- package/src/assets/img/activity-indicator-circle.svg +0 -90
- package/src/assets/img/app-lockout.svg +0 -1
- package/src/assets/img/biometrics.svg +0 -74
- package/src/assets/img/chat-loading.svg +0 -1
- package/src/assets/img/check-in-circle.svg +0 -18
- package/src/assets/img/connection-pending.svg +0 -112
- package/src/assets/img/contact-book.svg +0 -21
- package/src/assets/img/credential-card.svg +0 -18
- package/src/assets/img/credential-declined.svg +0 -28
- package/src/assets/img/credential-in-hand.svg +0 -48
- package/src/assets/img/credential-list.svg +0 -60
- package/src/assets/img/credential-pending.svg +0 -96
- package/src/assets/img/credential-success.svg +0 -48
- package/src/assets/img/delete-notification.svg +0 -1
- package/src/assets/img/empty-wallet.svg +0 -23
- package/src/assets/img/error-filled.svg +0 -12
- package/src/assets/img/exclamation-mark.svg +0 -17
- package/src/assets/img/home-center-img.svg +0 -71
- package/src/assets/img/icon-credential-offer-dark.svg +0 -7
- package/src/assets/img/icon-credential-offer-light.svg +0 -7
- package/src/assets/img/icon-info-recieved-dark.svg +0 -8
- package/src/assets/img/icon-info-recieved-light.svg +0 -8
- package/src/assets/img/icon-info-sent-dark.svg +0 -8
- package/src/assets/img/icon-info-sent-light.svg +0 -8
- package/src/assets/img/icon-proof-request-dark.svg +0 -11
- package/src/assets/img/icon-proof-request-light.svg +0 -11
- package/src/assets/img/information-received.svg +0 -1
- package/src/assets/img/logo-large.png +0 -0
- package/src/assets/img/logo-large@2x.png +0 -0
- package/src/assets/img/logo-large@3x.png +0 -0
- package/src/assets/img/logo.svg +0 -15
- package/src/assets/img/message-text-icon-outline.svg +0 -1
- package/src/assets/img/message-text-icon.svg +0 -1
- package/src/assets/img/no_information_shared.svg +0 -36
- package/src/assets/img/preface.svg +0 -15
- package/src/assets/img/proof-declined.svg +0 -66
- package/src/assets/img/proof-pending.svg +0 -61
- package/src/assets/img/proof-success.svg +0 -72
- package/src/assets/img/push-notifications.svg +0 -1
- package/src/assets/img/qrcode-scan-icon.svg +0 -1
- package/src/assets/img/scan-share.svg +0 -102
- package/src/assets/img/secure-check.svg +0 -4
- package/src/assets/img/secure-image.svg +0 -64
- package/src/assets/img/update-available.svg +0 -26
- package/src/assets/img/verifier-request-declined.svg +0 -34
- package/src/assets/img/wallet-back.svg +0 -20
- package/src/assets/img/wallet-front.svg +0 -32
- package/src/assets/img/wallet-icon-outline.svg +0 -1
- package/src/assets/img/wallet-icon.svg +0 -1
- package/src/assets/img/wallet.svg +0 -43
- package/src/assets/oca-bundles.json +0 -174
- package/src/components/animated/ButtonLoading.tsx +0 -32
- package/src/components/animated/ConnectionLoading.tsx +0 -53
- package/src/components/animated/CredentialAdded.tsx +0 -72
- package/src/components/animated/CredentialPending.tsx +0 -63
- package/src/components/animated/LoadingIndicator.tsx +0 -49
- package/src/components/animated/PresentationLoading.tsx +0 -52
- package/src/components/animated/RecordLoading.tsx +0 -75
- package/src/components/animated/SendingProof.tsx +0 -53
- package/src/components/animated/SentProof.tsx +0 -72
- package/src/components/buttons/Button-api.tsx +0 -46
- package/src/components/buttons/Button.tsx +0 -125
- package/src/components/buttons/HeaderHome.tsx +0 -25
- package/src/components/buttons/IconButton.tsx +0 -93
- package/src/components/buttons/InfoIcon.tsx +0 -35
- package/src/components/buttons/SettingsMenu.tsx +0 -26
- package/src/components/buttons/ToggleButton.tsx +0 -93
- package/src/components/buttons/index.ts +0 -4
- package/src/components/chat/ActionSlider.tsx +0 -104
- package/src/components/chat/ChatActions.tsx +0 -33
- package/src/components/chat/ChatBubble.tsx +0 -20
- package/src/components/chat/ChatEvent.tsx +0 -31
- package/src/components/chat/ChatMessage.tsx +0 -142
- package/src/components/chat/MessageInput.tsx +0 -46
- package/src/components/chat/index.ts +0 -4
- package/src/components/forms/WalletNameForm.tsx +0 -148
- package/src/components/index.ts +0 -4
- package/src/components/inputs/BiometryControl.tsx +0 -190
- package/src/components/inputs/BulletPoint.tsx +0 -32
- package/src/components/inputs/CheckBoxRow.tsx +0 -67
- package/src/components/inputs/InlineErrorText.tsx +0 -60
- package/src/components/inputs/LimitedTextInput.tsx +0 -71
- package/src/components/inputs/PINInput.tsx +0 -175
- package/src/components/inputs/SingleSelectBlock.tsx +0 -53
- package/src/components/listItems/ContactCredentialListItem.tsx +0 -79
- package/src/components/listItems/ContactListItem.tsx +0 -121
- package/src/components/listItems/NotificationListItem.tsx +0 -514
- package/src/components/misc/AvatarView.tsx +0 -33
- package/src/components/misc/CardWatermark.tsx +0 -52
- package/src/components/misc/ConnectionAlert.tsx +0 -123
- package/src/components/misc/ConnectionImage.tsx +0 -45
- package/src/components/misc/ContentGradient.tsx +0 -40
- package/src/components/misc/CredentialCard.tsx +0 -161
- package/src/components/misc/CredentialCard10.tsx +0 -329
- package/src/components/misc/CredentialCard11.tsx +0 -701
- package/src/components/misc/CredentialCard11ActionFooter.tsx +0 -55
- package/src/components/misc/CredentialCard11Issuer.tsx +0 -74
- package/src/components/misc/CredentialCard11Logo.tsx +0 -61
- package/src/components/misc/EmptyList.tsx +0 -27
- package/src/components/misc/EmptyListContacts.tsx +0 -55
- package/src/components/misc/ErrorBoundary.tsx +0 -200
- package/src/components/misc/FauxHeader.tsx +0 -75
- package/src/components/misc/InfoBox.tsx +0 -283
- package/src/components/misc/NoNewUpdates.tsx +0 -38
- package/src/components/misc/PINHeader.tsx +0 -25
- package/src/components/misc/PINValidationHelper.tsx +0 -48
- package/src/components/misc/Pagination.tsx +0 -114
- package/src/components/misc/QRRenderer.tsx +0 -53
- package/src/components/misc/QRScanner.tsx +0 -395
- package/src/components/misc/QRScannerTorch.tsx +0 -74
- package/src/components/misc/ScanCamera.tsx +0 -86
- package/src/components/misc/ScanTab.tsx +0 -45
- package/src/components/misc/SharedProofData.tsx +0 -98
- package/src/components/misc/UnorderedList.tsx +0 -28
- package/src/components/misc/VerifierCredentialCard.tsx +0 -378
- package/src/components/misc/index.ts +0 -2
- package/src/components/modals/AlertModal.tsx +0 -42
- package/src/components/modals/AppGuideModal.tsx +0 -142
- package/src/components/modals/CameraDisclosureModal.tsx +0 -126
- package/src/components/modals/CommonRemoveModal.tsx +0 -337
- package/src/components/modals/DeveloperModal.tsx +0 -32
- package/src/components/modals/DismissiblePopupModal.tsx +0 -169
- package/src/components/modals/ErrorModal.tsx +0 -107
- package/src/components/modals/ImageModal.tsx +0 -80
- package/src/components/modals/NetInfoModal.tsx +0 -35
- package/src/components/modals/PopupModal.tsx +0 -56
- package/src/components/modals/ProofCancelModal.tsx +0 -79
- package/src/components/modals/SafeAreaModal.tsx +0 -17
- package/src/components/record/Record.tsx +0 -100
- package/src/components/record/RecordBinaryField.tsx +0 -55
- package/src/components/record/RecordDateIntField.tsx +0 -63
- package/src/components/record/RecordField.tsx +0 -154
- package/src/components/record/RecordFooter.tsx +0 -17
- package/src/components/record/RecordHeader.tsx +0 -17
- package/src/components/record/RecordRemove.tsx +0 -66
- package/src/components/texts/HeaderTitle.tsx +0 -25
- package/src/components/texts/HighlightTextBox.tsx +0 -41
- package/src/components/texts/InfoTextBox.tsx +0 -129
- package/src/components/texts/Link.tsx +0 -41
- package/src/components/texts/Text.tsx +0 -21
- package/src/components/texts/ThemedText.tsx +0 -24
- package/src/components/toast/BaseToast.tsx +0 -128
- package/src/components/toast/ToastConfig.tsx +0 -21
- package/src/components/tour/AttachTourStep.tsx +0 -73
- package/src/components/tour/CredentialOfferTourSteps.tsx +0 -41
- package/src/components/tour/CredentialsTourSteps.tsx +0 -41
- package/src/components/tour/HomeTourSteps.tsx +0 -104
- package/src/components/tour/ProofRequestTourSteps.tsx +0 -41
- package/src/components/tour/SpotCutout.tsx +0 -65
- package/src/components/tour/TourBox.tsx +0 -255
- package/src/components/tour/TourOverlay.tsx +0 -134
- package/src/components/views/Banner.tsx +0 -181
- package/src/components/views/CredentialCardLogo.tsx +0 -77
- package/src/components/views/CredentialDetailPrimaryHeader.tsx +0 -107
- package/src/components/views/CredentialDetailSecondaryHeader.tsx +0 -60
- package/src/components/views/HeaderWithBanner.tsx +0 -17
- package/src/components/views/HomeFooterView.tsx +0 -110
- package/src/components/views/HomeHeaderView.tsx +0 -12
- package/src/components/views/KeyboardView.tsx +0 -41
- package/src/components/views/LoadingPlaceholder.tsx +0 -168
- package/src/components/views/LoadingView.tsx +0 -29
- package/src/components/views/ProgressBar.tsx +0 -53
- package/src/components/views/PushNotificationsContent.tsx +0 -51
- package/src/components/views/PushNotificationsDisabledContent.tsx +0 -47
- package/src/configs/ledgers/indy/index.ts +0 -8
- package/src/configs/ledgers/indy/ledgers.json +0 -51
- package/src/constants.ts +0 -107
- package/src/container-api.ts +0 -247
- package/src/container-impl.ts +0 -243
- package/src/contexts/activity.tsx +0 -145
- package/src/contexts/animated-components.ts +0 -9
- package/src/contexts/auth.tsx +0 -240
- package/src/contexts/index.ts +0 -3
- package/src/contexts/navigation.tsx +0 -19
- package/src/contexts/network.tsx +0 -125
- package/src/contexts/reducers/index.ts +0 -3
- package/src/contexts/reducers/store.ts +0 -754
- package/src/contexts/store.tsx +0 -103
- package/src/contexts/theme.tsx +0 -51
- package/src/contexts/tour/tour-context.tsx +0 -160
- package/src/contexts/tour/tour-provider.tsx +0 -160
- package/src/hooks/bundle-resolver.ts +0 -95
- package/src/hooks/chat-messages.tsx +0 -263
- package/src/hooks/connections.ts +0 -37
- package/src/hooks/credential-card-styles.ts +0 -144
- package/src/hooks/credentials.ts +0 -11
- package/src/hooks/deep-links.ts +0 -49
- package/src/hooks/developer-mode.ts +0 -25
- package/src/hooks/lockout.ts +0 -77
- package/src/hooks/notifications.ts +0 -108
- package/src/hooks/oob.ts +0 -17
- package/src/hooks/proof-request-templates.ts +0 -40
- package/src/hooks/proofs.ts +0 -32
- package/src/hooks/screen-capture.ts +0 -52
- package/src/hooks/useBifoldAgentSetup.ts +0 -169
- package/src/hooks/useOnboardingState.ts +0 -53
- package/src/hooks/usePINValidation.ts +0 -98
- package/src/index.ts +0 -239
- package/src/layout/ScreenLayout.tsx +0 -53
- package/src/localization/en/en.json +0 -951
- package/src/localization/en/index.ts +0 -3
- package/src/localization/fr/fr.json +0 -933
- package/src/localization/fr/index.ts +0 -3
- package/src/localization/index.ts +0 -66
- package/src/localization/pt-br/index.ts +0 -3
- package/src/localization/pt-br/pt-br.json +0 -911
- package/src/modules/history/context/historyManager.tsx +0 -247
- package/src/modules/history/index.ts +0 -2
- package/src/modules/history/navigation/HistoryStack.tsx +0 -29
- package/src/modules/history/services/queue.service.tsx +0 -31
- package/src/modules/history/types/index.ts +0 -92
- package/src/modules/history/ui/HistoryPage.tsx +0 -133
- package/src/modules/history/ui/HistorySettings.tsx +0 -183
- package/src/modules/history/ui/assets/img/HistoryCardAcceptedIcon.svg +0 -4
- package/src/modules/history/ui/assets/img/HistoryCardExpiredIcon.svg +0 -4
- package/src/modules/history/ui/assets/img/HistoryCardRevokedIcon.svg +0 -4
- package/src/modules/history/ui/assets/img/HistoryInformationSentIcon.svg +0 -4
- package/src/modules/history/ui/assets/img/HistoryPinUpdatedIcon.svg +0 -4
- package/src/modules/history/ui/assets/img/IconChevronRight.svg +0 -3
- package/src/modules/history/ui/components/BulletPoint.tsx +0 -49
- package/src/modules/history/ui/components/HistoryListItem.tsx +0 -251
- package/src/modules/history/ui/components/HistoryMenu.tsx +0 -25
- package/src/modules/history/ui/components/SingleSelectBlock.tsx +0 -72
- package/src/modules/openid/components/CredentialRowCard.tsx +0 -64
- package/src/modules/openid/components/OpenIDCredentialCard.tsx +0 -276
- package/src/modules/openid/context/OpenIDCredentialRecordProvider.tsx +0 -296
- package/src/modules/openid/display.tsx +0 -467
- package/src/modules/openid/displayProof.tsx +0 -86
- package/src/modules/openid/hooks/openid.tsx +0 -111
- package/src/modules/openid/metadata.tsx +0 -59
- package/src/modules/openid/offerResolve.tsx +0 -281
- package/src/modules/openid/resolverProof.tsx +0 -286
- package/src/modules/openid/screens/OpenIDCredentialDetails.tsx +0 -214
- package/src/modules/openid/screens/OpenIDCredentialOffer.tsx +0 -192
- package/src/modules/openid/screens/OpenIDProofChangeCredential.tsx +0 -133
- package/src/modules/openid/screens/OpenIDProofPresentation.tsx +0 -423
- package/src/modules/openid/types.tsx +0 -111
- package/src/modules/openid/utils/utils.tsx +0 -119
- package/src/navigators/ConnectStack.tsx +0 -68
- package/src/navigators/ContactStack.tsx +0 -91
- package/src/navigators/CredentialStack.tsx +0 -48
- package/src/navigators/DeliveryStack.tsx +0 -76
- package/src/navigators/HomeStack.tsx +0 -37
- package/src/navigators/MainStack.tsx +0 -146
- package/src/navigators/NotificationStack.tsx +0 -56
- package/src/navigators/OnboardingScreens.ts +0 -142
- package/src/navigators/OnboardingStack.tsx +0 -205
- package/src/navigators/ProofRequestStack.tsx +0 -113
- package/src/navigators/RootStack.tsx +0 -71
- package/src/navigators/SettingStack.tsx +0 -174
- package/src/navigators/TabStack.tsx +0 -304
- package/src/navigators/defaultLayoutOptions.tsx +0 -17
- package/src/navigators/defaultStackOptions.tsx +0 -102
- package/src/navigators/index.ts +0 -27
- package/src/onboarding.ts +0 -90
- package/src/screens/AttemptLockout.tsx +0 -153
- package/src/screens/AutoLock.tsx +0 -140
- package/src/screens/Biometry.tsx +0 -54
- package/src/screens/Chat.tsx +0 -141
- package/src/screens/ConfigureMediator.tsx +0 -160
- package/src/screens/Connection.tsx +0 -394
- package/src/screens/ContactDetails.tsx +0 -350
- package/src/screens/CredentialDetails.tsx +0 -473
- package/src/screens/CredentialOffer.tsx +0 -334
- package/src/screens/CredentialOfferAccept.tsx +0 -189
- package/src/screens/DataRetention.tsx +0 -91
- package/src/screens/Developer.tsx +0 -289
- package/src/screens/Home.tsx +0 -173
- package/src/screens/JSONDetails.tsx +0 -104
- package/src/screens/Language.tsx +0 -97
- package/src/screens/ListContacts.tsx +0 -112
- package/src/screens/ListCredentials.tsx +0 -135
- package/src/screens/ListProofRequests.tsx +0 -148
- package/src/screens/MobileVerifierLoading.tsx +0 -106
- package/src/screens/NameWallet.tsx +0 -9
- package/src/screens/Onboarding.tsx +0 -162
- package/src/screens/OnboardingPages.tsx +0 -160
- package/src/screens/PINChange.tsx +0 -249
- package/src/screens/PINCreate.tsx +0 -185
- package/src/screens/PINEnter.tsx +0 -432
- package/src/screens/PINExplainer.tsx +0 -85
- package/src/screens/PINVerify.tsx +0 -195
- package/src/screens/PasteUrl.tsx +0 -140
- package/src/screens/Preface.tsx +0 -78
- package/src/screens/ProofChangeCredential.tsx +0 -179
- package/src/screens/ProofDetails.tsx +0 -348
- package/src/screens/ProofRequest.tsx +0 -999
- package/src/screens/ProofRequestAccept.tsx +0 -133
- package/src/screens/ProofRequestDetails.tsx +0 -270
- package/src/screens/ProofRequestUsageHistory.tsx +0 -152
- package/src/screens/ProofRequesting.tsx +0 -245
- package/src/screens/PushNotifications.tsx +0 -59
- package/src/screens/RenameContact.tsx +0 -155
- package/src/screens/RenameWallet.tsx +0 -26
- package/src/screens/Scan.tsx +0 -145
- package/src/screens/ScanHelp.tsx +0 -48
- package/src/screens/Settings.tsx +0 -415
- package/src/screens/Splash.tsx +0 -80
- package/src/screens/Terms.tsx +0 -127
- package/src/screens/ToggleBiometry.tsx +0 -153
- package/src/screens/TogglePushNotifications.tsx +0 -118
- package/src/screens/Tours.tsx +0 -93
- package/src/screens/UpdateAvailable.tsx +0 -119
- package/src/screens/WhatAreContacts.tsx +0 -71
- package/src/services/bifoldLogger.ts +0 -3
- package/src/services/keychain.ts +0 -184
- package/src/services/logger.ts +0 -89
- package/src/services/storage.ts +0 -136
- package/src/theme-builder.ts +0 -157
- package/src/theme.interface.ts +0 -580
- package/src/theme.ts +0 -1346
- package/src/types/attempt-lockout-config.ts +0 -8
- package/src/types/attestation.ts +0 -17
- package/src/types/chat.ts +0 -4
- package/src/types/config.ts +0 -64
- package/src/types/contact-details.ts +0 -5
- package/src/types/credential-list-footer.ts +0 -3
- package/src/types/credential-status.ts +0 -3
- package/src/types/credentials.ts +0 -7
- package/src/types/decline.ts +0 -5
- package/src/types/error.ts +0 -40
- package/src/types/fn.ts +0 -2
- package/src/types/genesis.ts +0 -35
- package/src/types/index.ts +0 -2
- package/src/types/metadata.ts +0 -16
- package/src/types/navigators.ts +0 -239
- package/src/types/notification.ts +0 -24
- package/src/types/permissions.ts +0 -2
- package/src/types/proof-items.ts +0 -32
- package/src/types/react-i18next.d.ts +0 -10
- package/src/types/remove.ts +0 -8
- package/src/types/security.ts +0 -32
- package/src/types/settings.ts +0 -28
- package/src/types/state.ts +0 -97
- package/src/types/tour.ts +0 -20
- package/src/types/version-check.ts +0 -18
- package/src/utils/PINValidation.ts +0 -98
- package/src/utils/agent.ts +0 -128
- package/src/utils/anonCredsProofRequestMapper.ts +0 -205
- package/src/utils/contacts.ts +0 -59
- package/src/utils/cred-def.ts +0 -33
- package/src/utils/credential.ts +0 -37
- package/src/utils/crypto.ts +0 -12
- package/src/utils/fileCache.ts +0 -152
- package/src/utils/helpers.ts +0 -1292
- package/src/utils/ledger.ts +0 -212
- package/src/utils/luminance.ts +0 -40
- package/src/utils/mediatorhelpers.ts +0 -71
- package/src/utils/migration.ts +0 -40
- package/src/utils/network.tsx +0 -55
- package/src/utils/oca.ts +0 -173
- package/src/utils/parsers.tsx +0 -111
- package/src/utils/proofBundle.ts +0 -220
- package/src/utils/schema.ts +0 -28
- package/src/utils/testable.ts +0 -17
package/src/utils/ledger.ts
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { IndyVdrPoolConfig } from '@credo-ts/indy-vdr'
|
|
2
|
-
import axios from 'axios'
|
|
3
|
-
|
|
4
|
-
const INDY_NETWORK_URL =
|
|
5
|
-
'https://raw.githubusercontent.com/hyperledger/indy-node-monitor/main/fetch-validator-status/networks.json'
|
|
6
|
-
|
|
7
|
-
const ERROR_TAG = 'LEDGER ERROR'
|
|
8
|
-
|
|
9
|
-
export enum IndyLedger {
|
|
10
|
-
SOVRIN_BUILDER_NET = 'sbn',
|
|
11
|
-
SOVRIN_STAGING_NET = 'ssn',
|
|
12
|
-
SOVERIN_MAIN_NET = 'smn',
|
|
13
|
-
LOCAL_VON_NETWORK = 'vn',
|
|
14
|
-
LINUX_LOCAL_VON_NETWORK = 'lln',
|
|
15
|
-
BCOVRIN_DEV = 'bcd',
|
|
16
|
-
BCOVRIN_TEST = 'bct',
|
|
17
|
-
BCOVRIN = 'bcp',
|
|
18
|
-
GREENLIGHT_DEV_LEDGER = 'gld',
|
|
19
|
-
INDICO_MAINNET = 'imn',
|
|
20
|
-
INDICO_DEMONET = 'idn',
|
|
21
|
-
INDICO_TESTNET = 'itn',
|
|
22
|
-
CANDY_DEV_NETWORK = 'cdn',
|
|
23
|
-
CANDY_TEST_NETWORK = 'ctn',
|
|
24
|
-
CANDY_PRODUCTION_NETWORK = 'cpn',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface IndyLedgerConfig {
|
|
28
|
-
ledgerId: IndyLedger
|
|
29
|
-
isProduction: boolean
|
|
30
|
-
doNotConnectOnStartup?: true
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface IndyLedgerJSON extends IndyVdrPoolConfig {
|
|
34
|
-
// A human-readable identifier for the ledger, useful for identifing the ledger in the JSON file.
|
|
35
|
-
// Note: This value will not be used downstream as the IndyVdrPoolConfig interface will exclude it.
|
|
36
|
-
id: string
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type IndyLedgersRecord = Record<
|
|
40
|
-
IndyLedger,
|
|
41
|
-
{
|
|
42
|
-
name: string
|
|
43
|
-
indyNamespace: string
|
|
44
|
-
genesisUrl: string
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
|
|
48
|
-
// This interface allows us to abstract the file system operations,
|
|
49
|
-
// preventing android from complaining about the use of the Node.js module 'fs'.
|
|
50
|
-
export interface IndyLedgerFileSystem {
|
|
51
|
-
/**
|
|
52
|
-
* Writes data to a file at the specified file path.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} filePath - The path to the file where data should be written.
|
|
55
|
-
* @param {*} {string} data - The data to write to the file.
|
|
56
|
-
* @returns {*} {void}
|
|
57
|
-
*/
|
|
58
|
-
writeFile: (filePath: string, data: string) => void
|
|
59
|
-
/**
|
|
60
|
-
* Reads and returns the content of a file at the specified file path.
|
|
61
|
-
*
|
|
62
|
-
* @param {string} filePath - The path to the file to read.
|
|
63
|
-
* @returns {*} {string} - The content of the file as a string.
|
|
64
|
-
*/
|
|
65
|
-
readFile: (filePath: string) => string
|
|
66
|
-
/**
|
|
67
|
-
* Checks if a file exists at the specified file path.
|
|
68
|
-
*
|
|
69
|
-
* @param {string} filePath - The path to the file to check.
|
|
70
|
-
* @returns {*} {boolean} - True if the file exists, false otherwise.
|
|
71
|
-
*/
|
|
72
|
-
fileExists: (filePath: string) => boolean
|
|
73
|
-
/**
|
|
74
|
-
* Resolves and returns the absolute path for a given file path.
|
|
75
|
-
*
|
|
76
|
-
* @example ./ledgers.json -> /Users/username/project/ledgers.json
|
|
77
|
-
*
|
|
78
|
-
* @param {string} filePath - The file path to resolve.
|
|
79
|
-
* @returns {*} {string} - The resolved absolute file path.
|
|
80
|
-
*/
|
|
81
|
-
pathResolve: (filePath: string) => string
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Fetches the content from a given URL and returns it as a Promise.
|
|
86
|
-
*
|
|
87
|
-
* @throws {Error} - Throws an error if the fetch operation fails.
|
|
88
|
-
* @template T - The type of content expected from the URL.
|
|
89
|
-
* @param {string} url - The URL to fetch content from.
|
|
90
|
-
* @returns {*} {Promise<T>} - A promise that resolves to the content fetched from the URL
|
|
91
|
-
*/
|
|
92
|
-
export async function _fetchUrlContent<T>(url: string): Promise<T> {
|
|
93
|
-
try {
|
|
94
|
-
const response = await axios.get<T>(url)
|
|
95
|
-
return response.data
|
|
96
|
-
} catch (error: any) {
|
|
97
|
-
throw new Error(`${ERROR_TAG}: Failed to fetch content from URL ${url}: ${error.message}`)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Fetches and returns a list of Indy ledgers based on the provided configurations.
|
|
103
|
-
*
|
|
104
|
-
* @throws {Error} - Throws an error if a ledgerConfig is not found in the IndyLedgersRecord.
|
|
105
|
-
* @param {IndyLedgerConfig[]} indyLedgerConfigs - The list of supported Indy ledger configurations.
|
|
106
|
-
* @returns {*} {Promise<IndyLedgerJSON[]>} - A promise that resolves to an array of ledgers.
|
|
107
|
-
*/
|
|
108
|
-
export async function getIndyLedgers(indyLedgerConfigs: IndyLedgerConfig[]): Promise<IndyLedgerJSON[]> {
|
|
109
|
-
if (!indyLedgerConfigs.length) {
|
|
110
|
-
return []
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const allIndyLedgers = await _fetchUrlContent<IndyLedgersRecord>(INDY_NETWORK_URL)
|
|
114
|
-
|
|
115
|
-
const ledgers: IndyLedgerJSON[] = []
|
|
116
|
-
// Iterate through the supported network configs and map them to the Indy ledgers
|
|
117
|
-
for (const ledgerConfig of indyLedgerConfigs) {
|
|
118
|
-
const indyLedger = allIndyLedgers[ledgerConfig.ledgerId]
|
|
119
|
-
|
|
120
|
-
if (!indyLedger) {
|
|
121
|
-
throw new Error(`${ERROR_TAG}: Ledger config for ${ledgerConfig.ledgerId} not found`)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const ledgerId = indyLedger.name
|
|
125
|
-
.split(' ')
|
|
126
|
-
.filter((word) => !/\W+/im.test(word))
|
|
127
|
-
.join('')
|
|
128
|
-
|
|
129
|
-
ledgers.push({
|
|
130
|
-
id: ledgerId,
|
|
131
|
-
indyNamespace: indyLedger.indyNamespace,
|
|
132
|
-
isProduction: ledgerConfig.isProduction,
|
|
133
|
-
connectOnStartup: !ledgerConfig.doNotConnectOnStartup,
|
|
134
|
-
// This url will need to be fetched to get the genesis transactions
|
|
135
|
-
genesisTransactions: indyLedger.genesisUrl,
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Step 1: Collect all genesis transaction promises
|
|
140
|
-
const genesisPromises = ledgers.map((ledger) => _fetchUrlContent<string>(ledger.genesisTransactions))
|
|
141
|
-
|
|
142
|
-
// Step 2: Await all promises to resolve in parallel
|
|
143
|
-
const genesisTransactions = await Promise.all(genesisPromises)
|
|
144
|
-
|
|
145
|
-
// Step 3: Assign the fetched genesis transactions back to the ledgers
|
|
146
|
-
genesisTransactions.forEach((transactions, index) => {
|
|
147
|
-
ledgers[index].genesisTransactions = transactions.trim()
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
return ledgers
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Writes the provided Indy ledgers to a JSON file at the specified file path.
|
|
155
|
-
*
|
|
156
|
-
* @throws {Error} - Throws an error if writing to the file fails or if the file path is invalid.
|
|
157
|
-
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for writing the file.
|
|
158
|
-
* @param {string} filePath - The path to the JSON file where the ledgers should be written.
|
|
159
|
-
* @param {IndyLedgerJSON[]} ledgers - The array of Indy ledgers to write to the file.
|
|
160
|
-
* @returns {*} {void}
|
|
161
|
-
*/
|
|
162
|
-
export function writeIndyLedgersToFile(
|
|
163
|
-
fileSystem: IndyLedgerFileSystem,
|
|
164
|
-
filePath: string,
|
|
165
|
-
ledgers: IndyLedgerJSON[]
|
|
166
|
-
): void {
|
|
167
|
-
try {
|
|
168
|
-
if (!filePath.endsWith('.json')) {
|
|
169
|
-
throw new Error('File path must point to a JSON file')
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Skip writing to file if the new ledgers are the same
|
|
173
|
-
if (
|
|
174
|
-
fileSystem.fileExists(filePath) &&
|
|
175
|
-
JSON.stringify(readIndyLedgersFromFile(fileSystem, filePath)) === JSON.stringify(ledgers)
|
|
176
|
-
) {
|
|
177
|
-
return
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const jsonContent = JSON.stringify(ledgers, null, 2)
|
|
181
|
-
|
|
182
|
-
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
183
|
-
const absoluteFilePath = fileSystem.pathResolve(filePath)
|
|
184
|
-
fileSystem.writeFile(absoluteFilePath, jsonContent)
|
|
185
|
-
} catch (error: any) {
|
|
186
|
-
throw new Error(`${ERROR_TAG}: Failed to write ledgers to file ${filePath}: ${error.message}`)
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Reads and parses Indy ledgers from a JSON file at the specified file path.
|
|
192
|
-
*
|
|
193
|
-
* @throws {Error} - Throws an error if reading from the file fails, if the file path is invalid, or if parsing fails.
|
|
194
|
-
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for reading the file.
|
|
195
|
-
* @param {string} filePath - The path to the JSON file to read the ledgers from.
|
|
196
|
-
* @returns {*} {IndyLedgerJSON[]} - An array of Indy ledgers read from the file.
|
|
197
|
-
*/
|
|
198
|
-
export function readIndyLedgersFromFile(fileSystem: IndyLedgerFileSystem, filePath: string): IndyLedgerJSON[] {
|
|
199
|
-
try {
|
|
200
|
-
if (!filePath.endsWith('.json')) {
|
|
201
|
-
throw new Error('File path must point to a JSON file')
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
205
|
-
const absoluteFilePath = fileSystem.pathResolve(filePath)
|
|
206
|
-
const jsonContent = fileSystem.readFile(absoluteFilePath)
|
|
207
|
-
|
|
208
|
-
return JSON.parse(jsonContent)
|
|
209
|
-
} catch (error: any) {
|
|
210
|
-
throw new Error(`${ERROR_TAG}: Failed to read ledgers from file ${filePath}: ${error.message}`)
|
|
211
|
-
}
|
|
212
|
-
}
|
package/src/utils/luminance.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export enum StatusBarStyles {
|
|
2
|
-
Light = 'light-content',
|
|
3
|
-
Dark = 'dark-content',
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export enum Shade {
|
|
7
|
-
Light = 'light',
|
|
8
|
-
Dark = 'dark',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const luminanceForHexColor = (hex: string): number | undefined => {
|
|
12
|
-
if (!/^#([A-Fa-f0-9]{6})$/.test(hex)) {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const hexAsNumber = Number(`0x${hex.slice(1)}`)
|
|
17
|
-
const [r, g, b] = [(hexAsNumber >> 16) & 255, (hexAsNumber >> 8) & 255, hexAsNumber & 255]
|
|
18
|
-
// Scalars below defined [here](https://en.wikipedia.org/wiki/Relative_luminance)
|
|
19
|
-
const y = 0.2126 * r + 0.7152 * g + 0.0722 * b
|
|
20
|
-
|
|
21
|
-
return Math.round(y)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const shadeIsLightOrDark = (hex: string): Shade => {
|
|
25
|
-
const rgbMidPoint = 255 / 2
|
|
26
|
-
const y = luminanceForHexColor(hex) ?? 0
|
|
27
|
-
|
|
28
|
-
return y <= rgbMidPoint ? Shade.Dark : Shade.Light
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const statusBarStyleForColor = (hex: string): StatusBarStyles | undefined => {
|
|
32
|
-
const rgbMidPoint = 255 / 2
|
|
33
|
-
const y = luminanceForHexColor(hex)
|
|
34
|
-
|
|
35
|
-
if (typeof y === 'undefined') {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return y <= rgbMidPoint ? StatusBarStyles.Light : StatusBarStyles.Dark
|
|
40
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Agent, MediationRecord } from '@credo-ts/core'
|
|
2
|
-
|
|
3
|
-
export const isMediatorInvitation = async (agent: Agent, url: string): Promise<boolean> => {
|
|
4
|
-
try {
|
|
5
|
-
const invitation = await agent.oob.parseInvitation(url)
|
|
6
|
-
if (!invitation) {
|
|
7
|
-
return false
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (invitation.goalCode === 'aries.vc.mediate') {
|
|
11
|
-
agent.config.logger.info(`Invitation is a mediator invitation with goal code: ${invitation.goalCode}`)
|
|
12
|
-
return true
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return false
|
|
16
|
-
} catch (error) {
|
|
17
|
-
agent.config.logger.error(`Invitation is not a mediator invitation.`, error as Error)
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const provisionMediationRecordFromMediatorUrl = async (
|
|
23
|
-
agent: Agent,
|
|
24
|
-
url: string
|
|
25
|
-
): Promise<MediationRecord | undefined> => {
|
|
26
|
-
try {
|
|
27
|
-
const invitation = await agent.oob.parseInvitation(url)
|
|
28
|
-
if (!invitation) {
|
|
29
|
-
agent.config.logger.error(`No invitation found in URL: ${url}`)
|
|
30
|
-
return undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const outOfBandRecord = await agent.oob.findByReceivedInvitationId(invitation.id)
|
|
34
|
-
let [connection] = outOfBandRecord ? await agent.connections.findAllByOutOfBandId(outOfBandRecord.id) : []
|
|
35
|
-
|
|
36
|
-
if (!connection) {
|
|
37
|
-
agent.config.logger.warn(`No connection found for out-of-band record: ${outOfBandRecord?.id}`)
|
|
38
|
-
const invite = await agent.oob.parseInvitation(url)
|
|
39
|
-
const { connectionRecord: newConnection } = await agent.oob.receiveInvitation(invite)
|
|
40
|
-
|
|
41
|
-
if (!newConnection) {
|
|
42
|
-
agent.config.logger.error(`Failed to create connection from invitation: ${JSON.stringify(invite, null, 2)}`)
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
connection = newConnection
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const result = connection.isReady ? connection : await agent.connections.returnWhenIsConnected(connection.id)
|
|
49
|
-
return agent.mediationRecipient.provision(result)
|
|
50
|
-
} catch (error) {
|
|
51
|
-
agent.config.logger.error(`Failed to get connection ID from mediator URL: ${error}`)
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const setMediationToDefault = async (agent: Agent, mediatorUrl: string) => {
|
|
57
|
-
const mediationRecord = await provisionMediationRecordFromMediatorUrl(agent, mediatorUrl)
|
|
58
|
-
if (!mediationRecord) {
|
|
59
|
-
agent.config.logger.error(`No connection record found for mediator URL: ${mediatorUrl}`)
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const currentDefault = await agent.mediationRecipient.findDefaultMediator()
|
|
64
|
-
if (currentDefault?.connectionId === mediationRecord.id) {
|
|
65
|
-
agent.config.logger.info(`Default mediator already set for connection ID: ${mediationRecord.id}`)
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
await agent.mediationRecipient.setDefaultMediator(mediationRecord)
|
|
70
|
-
agent.config.logger.info(`setting default mediator with record: ${JSON.stringify(mediationRecord)}`)
|
|
71
|
-
}
|
package/src/utils/migration.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { AskarModule } from '@credo-ts/askar'
|
|
2
|
-
import { Agent, ConsoleLogger, LogLevel } from '@credo-ts/core'
|
|
3
|
-
import { IndySdkToAskarMigrationUpdater } from '@credo-ts/indy-sdk-to-askar-migration'
|
|
4
|
-
import { agentDependencies } from '@credo-ts/react-native'
|
|
5
|
-
import { ariesAskar } from '@hyperledger/aries-askar-react-native'
|
|
6
|
-
import { Platform } from 'react-native'
|
|
7
|
-
import * as RNFS from 'react-native-fs'
|
|
8
|
-
|
|
9
|
-
export const migrateToAskar = async (walletId: string, key: string, agent?: Agent) => {
|
|
10
|
-
// The backup file is kept in case anything goes wrong. this will allow us to release patches and still update the
|
|
11
|
-
// original indy-sdk database in a future version we could manually add a check to remove the old file from storage.
|
|
12
|
-
const basePath = Platform.OS === 'ios' ? RNFS.DocumentDirectoryPath : RNFS.ExternalDirectoryPath
|
|
13
|
-
const dbPath = `${basePath}/.indy_client/wallet/${walletId}/sqlite.db`
|
|
14
|
-
const aAgent =
|
|
15
|
-
agent ??
|
|
16
|
-
new Agent({
|
|
17
|
-
config: {
|
|
18
|
-
label: 'Aries Bifold',
|
|
19
|
-
walletConfig: {
|
|
20
|
-
id: walletId,
|
|
21
|
-
key,
|
|
22
|
-
},
|
|
23
|
-
logger: new ConsoleLogger(LogLevel.trace),
|
|
24
|
-
autoUpdateStorageOnStartup: false,
|
|
25
|
-
},
|
|
26
|
-
modules: {
|
|
27
|
-
askar: new AskarModule({
|
|
28
|
-
ariesAskar,
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
dependencies: agentDependencies,
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const updater = await IndySdkToAskarMigrationUpdater.initialize({
|
|
35
|
-
dbPath,
|
|
36
|
-
agent: aAgent,
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
await updater.update()
|
|
40
|
-
}
|
package/src/utils/network.tsx
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import TcpSocket from 'react-native-tcp-socket'
|
|
2
|
-
|
|
3
|
-
import pools from '../configs/ledgers/indy'
|
|
4
|
-
import { GenesisTransaction } from '../types/genesis'
|
|
5
|
-
|
|
6
|
-
export const canConnectToHost = async (host: { host: string; port: number }): Promise<boolean> =>
|
|
7
|
-
new Promise((resolve) => {
|
|
8
|
-
const socketTimeoutInMs = 3000
|
|
9
|
-
const client = TcpSocket.createConnection(host, () => {
|
|
10
|
-
resolve(true)
|
|
11
|
-
client.destroy()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
// Other events that can be safely be ignored. See the
|
|
15
|
-
// library for more details:
|
|
16
|
-
// https://www.npmjs.com/package/react-native-tcp-socket
|
|
17
|
-
|
|
18
|
-
client.on('error', () => {
|
|
19
|
-
client.destroy()
|
|
20
|
-
resolve(false)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
client.on('timeout', () => {
|
|
24
|
-
client.destroy()
|
|
25
|
-
client.removeAllListeners()
|
|
26
|
-
|
|
27
|
-
resolve(false)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
client.setTimeout(socketTimeoutInMs)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
export const fetchLedgerNodes = (indyNamespace = 'sovrin'): Array<{ host: string; port: number }> => {
|
|
34
|
-
const [pool] = pools.filter((p) => p.indyNamespace === indyNamespace)
|
|
35
|
-
if (!pool) {
|
|
36
|
-
return []
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const genesisTransactionsAsString = pool.genesisTransactions
|
|
40
|
-
let genesisTransactions: Array<GenesisTransaction> = []
|
|
41
|
-
|
|
42
|
-
if (genesisTransactionsAsString) {
|
|
43
|
-
try {
|
|
44
|
-
genesisTransactions = genesisTransactionsAsString.split('\n').map((g) => JSON.parse(g))
|
|
45
|
-
} catch (error: unknown) {
|
|
46
|
-
return []
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const nodes = genesisTransactions.map((g) => {
|
|
51
|
-
return { host: g.txn.data.data.client_ip, port: parseInt(g.txn.data.data.client_port) }
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
return nodes
|
|
55
|
-
}
|
package/src/utils/oca.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { CredentialExchangeRecord } from '@credo-ts/core'
|
|
2
|
-
import { AnonCredsProofRequestTemplatePayloadData, CredentialSharedProofData } from '@bifold/verifier'
|
|
3
|
-
import {
|
|
4
|
-
Attribute,
|
|
5
|
-
CredentialOverlay,
|
|
6
|
-
Field,
|
|
7
|
-
OCABundleResolveAllParams,
|
|
8
|
-
OCABundleResolverType,
|
|
9
|
-
Predicate,
|
|
10
|
-
} from '@bifold/oca/build/legacy'
|
|
11
|
-
import { W3cCredentialDisplay } from '../modules/openid/types'
|
|
12
|
-
import { BrandingOverlay } from '@bifold/oca'
|
|
13
|
-
|
|
14
|
-
export type FieldExt = {
|
|
15
|
-
field: Attribute
|
|
16
|
-
attribute_name: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type AttributeFieldValue = string | number | null
|
|
20
|
-
|
|
21
|
-
export const getAttributeField = (display: W3cCredentialDisplay, searchKey: string): FieldExt | undefined => {
|
|
22
|
-
let attributeName: string = 'Unknown'
|
|
23
|
-
let attributeValue: AttributeFieldValue = 'Unknown'
|
|
24
|
-
|
|
25
|
-
for (const [key, value] of Object.entries(display.attributes)) {
|
|
26
|
-
let formattedValue: AttributeFieldValue
|
|
27
|
-
|
|
28
|
-
if (searchKey === key) {
|
|
29
|
-
if (typeof value === 'object' && value !== null) {
|
|
30
|
-
formattedValue = JSON.stringify(value) // Convert object to string
|
|
31
|
-
} else {
|
|
32
|
-
formattedValue = value as AttributeFieldValue
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
attributeName = key
|
|
36
|
-
attributeValue = formattedValue
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//Now check credentialSubject for attributeName mapping
|
|
41
|
-
const credentialSubject = display.credentialSubject
|
|
42
|
-
|
|
43
|
-
if (credentialSubject) {
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
|
-
for (const [key, value] of Object.entries(credentialSubject)) {
|
|
46
|
-
if (key !== searchKey || !value) continue
|
|
47
|
-
const { display } = value
|
|
48
|
-
const { name } = display[0]
|
|
49
|
-
attributeName = name
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
field: new Attribute({
|
|
55
|
-
name: attributeName,
|
|
56
|
-
value: attributeValue,
|
|
57
|
-
mimeType: typeof attributeValue === 'number' ? 'text/number' : 'text/plain',
|
|
58
|
-
}),
|
|
59
|
-
attribute_name: searchKey,
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const buildFieldsFromW3cCredsCredential = (
|
|
64
|
-
display: W3cCredentialDisplay,
|
|
65
|
-
filterByAttributes?: string[]
|
|
66
|
-
): Array<Field> => {
|
|
67
|
-
return (
|
|
68
|
-
Object.entries(display.attributes)
|
|
69
|
-
.filter(([key]) => key !== 'id')
|
|
70
|
-
.map(([key]) => getAttributeField(display, key))
|
|
71
|
-
.filter((field) => field !== undefined)
|
|
72
|
-
.filter((field: FieldExt) => (filterByAttributes ? filterByAttributes.includes(field.attribute_name) : true))
|
|
73
|
-
.map((fld) => fld.field) || []
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const buildFieldsFromAnonCredsCredential = (credential: CredentialExchangeRecord): Array<Field> => {
|
|
78
|
-
return credential?.credentialAttributes?.map((attr) => new Attribute(attr)) || []
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const buildFieldsFromAnonCredsProofRequestTemplate = (
|
|
82
|
-
data: AnonCredsProofRequestTemplatePayloadData
|
|
83
|
-
): Array<Field> => {
|
|
84
|
-
const fields = []
|
|
85
|
-
if (data.requestedAttributes) {
|
|
86
|
-
for (const item of data.requestedAttributes) {
|
|
87
|
-
if (item.name) {
|
|
88
|
-
fields.push(new Attribute({ name: item.name, value: null, ...item }))
|
|
89
|
-
}
|
|
90
|
-
if (item.names) {
|
|
91
|
-
for (const name of item.names) {
|
|
92
|
-
fields.push(new Attribute({ name, value: null, ...item }))
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (data.requestedPredicates) {
|
|
98
|
-
for (const item of data.requestedPredicates) {
|
|
99
|
-
fields.push(
|
|
100
|
-
new Predicate({
|
|
101
|
-
pType: item.predicateType,
|
|
102
|
-
pValue: item.predicateValue,
|
|
103
|
-
...item,
|
|
104
|
-
})
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return fields
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const buildFieldsFromSharedAnonCredsProof = (data: CredentialSharedProofData): Array<Field> => {
|
|
112
|
-
const fields = []
|
|
113
|
-
for (const attribute of data.sharedAttributes) {
|
|
114
|
-
fields.push(
|
|
115
|
-
new Attribute({
|
|
116
|
-
name: attribute.name,
|
|
117
|
-
value: attribute.value,
|
|
118
|
-
})
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
for (const attributesGroup of data.sharedAttributeGroups) {
|
|
122
|
-
for (const attribute of attributesGroup.attributes) {
|
|
123
|
-
fields.push(
|
|
124
|
-
new Attribute({
|
|
125
|
-
name: attribute.name,
|
|
126
|
-
value: attribute.value,
|
|
127
|
-
})
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
for (const predicate of data.resolvedPredicates) {
|
|
132
|
-
fields.push(
|
|
133
|
-
new Predicate({
|
|
134
|
-
name: predicate.name,
|
|
135
|
-
pType: predicate.predicateType,
|
|
136
|
-
pValue: predicate.predicateValue,
|
|
137
|
-
satisfied: true,
|
|
138
|
-
})
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
return fields
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export const buildOverlayFromW3cCredential = async ({
|
|
145
|
-
credentialDisplay,
|
|
146
|
-
language,
|
|
147
|
-
resolver,
|
|
148
|
-
}: {
|
|
149
|
-
credentialDisplay: W3cCredentialDisplay
|
|
150
|
-
language: string
|
|
151
|
-
resolver: OCABundleResolverType
|
|
152
|
-
}): Promise<CredentialOverlay<BrandingOverlay>> => {
|
|
153
|
-
const params: OCABundleResolveAllParams = {
|
|
154
|
-
identifiers: {
|
|
155
|
-
schemaId: '',
|
|
156
|
-
credentialDefinitionId: credentialDisplay.id,
|
|
157
|
-
},
|
|
158
|
-
meta: {
|
|
159
|
-
alias: credentialDisplay.display.issuer.name,
|
|
160
|
-
credConnectionId: undefined,
|
|
161
|
-
credName: credentialDisplay.display.name,
|
|
162
|
-
},
|
|
163
|
-
attributes: buildFieldsFromW3cCredsCredential(credentialDisplay),
|
|
164
|
-
language,
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const bundle = await resolver.resolveAllBundles(params)
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
...(bundle as CredentialOverlay<BrandingOverlay>),
|
|
171
|
-
presentationFields: buildFieldsFromW3cCredsCredential(credentialDisplay),
|
|
172
|
-
}
|
|
173
|
-
}
|
package/src/utils/parsers.tsx
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
export type ParseInvitationResult =
|
|
2
|
-
| {
|
|
3
|
-
success: true
|
|
4
|
-
result: ParsedInvitation
|
|
5
|
-
}
|
|
6
|
-
| {
|
|
7
|
-
success: false
|
|
8
|
-
error: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type ParsedInvitation = {
|
|
12
|
-
type: 'didcomm' | 'openid-credential-offer' | 'openid-authorization-request'
|
|
13
|
-
format: 'url' | 'parsed'
|
|
14
|
-
data: string | Record<string, unknown>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export enum InvitationQrTypes {
|
|
18
|
-
OPENID_INITIATE_ISSUANCE = 'openid-initiate-issuance://',
|
|
19
|
-
OPENID_CREDENTIAL_OFFER = 'openid-credential-offer://',
|
|
20
|
-
// TODO: I think we should not support openid://, as we mainly support openid4vp
|
|
21
|
-
// But older requests do use openid:// I think (such as the DIIP dbc login)
|
|
22
|
-
// but I think we're going to move to just openid4p in the future
|
|
23
|
-
OPENID = 'openid://',
|
|
24
|
-
OPENID4VP = 'openid4vp://',
|
|
25
|
-
OPENID_VC = 'openid-vc://',
|
|
26
|
-
DIDCOMM = 'didcomm://',
|
|
27
|
-
HTTPS = 'https://',
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const isOpenIdCredentialOffer = (url: string) => {
|
|
31
|
-
if (
|
|
32
|
-
url.startsWith(InvitationQrTypes.OPENID_INITIATE_ISSUANCE) ||
|
|
33
|
-
url.startsWith(InvitationQrTypes.OPENID_CREDENTIAL_OFFER)
|
|
34
|
-
) {
|
|
35
|
-
return true
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (url.includes('credential_offer_uri=') || url.includes('credential_offer=')) {
|
|
39
|
-
return true
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return false
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const isOpenIdPresentationRequest = (url: string) => {
|
|
46
|
-
if (
|
|
47
|
-
url.startsWith(InvitationQrTypes.OPENID) ||
|
|
48
|
-
url.startsWith(InvitationQrTypes.OPENID_VC) ||
|
|
49
|
-
url.startsWith(InvitationQrTypes.OPENID4VP)
|
|
50
|
-
) {
|
|
51
|
-
return true
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (url.includes('request_uri=') || url.includes('request=')) {
|
|
55
|
-
return true
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return false
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const isDidCommInvitation = (url: string) => {
|
|
62
|
-
if (url.startsWith(InvitationQrTypes.DIDCOMM)) {
|
|
63
|
-
return true
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (url.includes('c_i=') || url.includes('oob=') || url.includes('oobUrl=') || url.includes('d_m=')) {
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function parseInvitationUrl(invitationUrl: string): Promise<ParseInvitationResult> {
|
|
74
|
-
if (isOpenIdCredentialOffer(invitationUrl)) {
|
|
75
|
-
return {
|
|
76
|
-
success: true,
|
|
77
|
-
result: {
|
|
78
|
-
format: 'url',
|
|
79
|
-
type: 'openid-credential-offer',
|
|
80
|
-
data: invitationUrl,
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (isOpenIdPresentationRequest(invitationUrl)) {
|
|
86
|
-
return {
|
|
87
|
-
success: true,
|
|
88
|
-
result: {
|
|
89
|
-
format: 'url',
|
|
90
|
-
type: 'openid-authorization-request',
|
|
91
|
-
data: invitationUrl,
|
|
92
|
-
},
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (isDidCommInvitation(invitationUrl)) {
|
|
97
|
-
return {
|
|
98
|
-
success: true,
|
|
99
|
-
result: {
|
|
100
|
-
format: 'url',
|
|
101
|
-
type: 'didcomm',
|
|
102
|
-
data: invitationUrl,
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
success: false,
|
|
109
|
-
error: 'Invitation not recognized.',
|
|
110
|
-
}
|
|
111
|
-
}
|