Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

//--------- Must: be added:
implementation "io.velocitycareerlabs:vcl:2.6.14"
implementation "io.velocitycareerlabs:vcl:2.7.1"
implementation 'com.nimbusds:nimbus-jose-jwt:10.0.1'
implementation "androidx.security:security-crypto:1.1.0-alpha06"
//-------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ import io.velocitycareerlabs.api.VCLProvider
import io.velocitycareerlabs.api.entities.error.VCLError
import io.velocitycareerlabs.api.entities.initialization.VCLInitializationDescriptor
import io.velocitycareerlabs.reactnative.extensions.toThrowable
import io.velocitycareerlabs.reactnative.utlis.Converter.authTokenToMap
import io.velocitycareerlabs.reactnative.utlis.Converter.didJwkToMap
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToAuthToken
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToAuthTokenDescriptor
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToDidJwk
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToDidJwkDescriptor
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToInitializationDescriptor
Expand Down Expand Up @@ -152,11 +155,13 @@ class VclReactNativeModule(reactContext: ReactApplicationContext) :
@ReactMethod
fun submitPresentation(
presentationSubmissionMap: ReadableMap,
authTokenMap: ReadableMap? = null,
promise: Promise
) {
try {
vcl.submitPresentation(
presentationSubmission = mapToPresentationSubmission(presentationSubmissionMap),
authToken = mapToAuthToken(authTokenMap),
successHandler = {
promise.resolve(presentationSubmissionResultToMap(it))
},
Expand Down Expand Up @@ -294,6 +299,25 @@ class VclReactNativeModule(reactContext: ReactApplicationContext) :
}
}

@ReactMethod
fun getAuthToken(
authTokenDescriptorMap: ReadableMap,
promise: Promise
) {
try {
vcl.getAuthToken(
authTokenDescriptor = mapToAuthTokenDescriptor(authTokenDescriptorMap),
successHandler = {
promise.resolve(authTokenToMap(it))
},
errorHandler = {
promise.reject(it.toThrowable())
})
} catch (ex: Exception) {
promise.reject(VCLError(ex).toThrowable())
}
}

@ReactMethod
fun getCredentialTypesUIFormSchema(
credentialTypesUIFormSchemaDescriptorMap: ReadableMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ object Converter {
)
presentationRequestMap.putMap("deepLink", deepLinkToMap(presentationRequest.deepLink))
presentationRequestMap.putMap("didJwk", didJwkToMap(presentationRequest.didJwk))
presentationRequestMap.putBoolean("feed", presentationRequest.feed)
presentationRequestMap.putMap(
"remoteCryptoServicesToken",
tokenToMap(presentationRequest.remoteCryptoServicesToken)
Expand Down Expand Up @@ -471,8 +472,8 @@ object Converter {
VCLIssuingType.Career
),
credentialTypes =
(credentialManifestDescriptorByServiceMap.getArrayOpt("credentialTypes")?.toArrayList()
?.toList() as? List<String>),
(credentialManifestDescriptorByServiceMap.getArrayOpt("credentialTypes")?.toArrayList()
?.toList() as? List<String>),
pushDelegate = mapToPushDelegate(
credentialManifestDescriptorByServiceMap.getMapOpt("pushDelegate")
),
Expand Down Expand Up @@ -683,6 +684,46 @@ object Converter {
fun mapToJwt(jwtMap: ReadableMap?) =
VCLJwt(encodedJwt = jwtMap?.getStringOpt("encodedJwt") ?: "")

fun mapToAuthTokenDescriptor(
authTokenDescriptorMap: ReadableMap
): VCLAuthTokenDescriptor {
authTokenDescriptorMap.getMapOpt("presentationRequest")?.let { presentationRequestMap ->
return VCLAuthTokenDescriptor(
presentationRequest = mapToPresentationRequest(
presentationRequestMap
)
)
}
return VCLAuthTokenDescriptor(
authTokenUri = authTokenDescriptorMap.getStringOpt("authTokenUri") ?: "",
refreshToken = mapToToken(authTokenDescriptorMap.getMapOpt("refreshToken")),
walletDid = authTokenDescriptorMap.getStringOpt("walletDid"),
relyingPartyDid = authTokenDescriptorMap.getStringOpt("relyingPartyDid"),
vendorOriginContext = authTokenDescriptorMap.getStringOpt("vendorOriginContext")
)
}

fun authTokenToMap(
authToken: VCLAuthToken
): ReadableMap {
val authTokenMap = Arguments.createMap()
authTokenMap.putMap("payload", authToken.payload.toReadableMap())
authTokenMap.putString("authTokenUri", authToken.authTokenUri)
authTokenMap.putMap("refreshToken", tokenToMap(authToken.refreshToken))
authTokenMap.putString("walletDid", authToken.walletDid)
authTokenMap.putString("relyingPartyDid", authToken.relyingPartyDid)
return authTokenMap
}

fun mapToAuthToken(authTokenMap: ReadableMap?): VCLAuthToken {
return VCLAuthToken(
payload = authTokenMap?.getMapOpt("payload")?.toJsonObject() ?: JSONObject(),
authTokenUri = authTokenMap?.getStringOpt("authTokenUri"),
walletDid = authTokenMap?.getStringOpt("walletDid"),
relyingPartyDid = authTokenMap?.getStringOpt("relyingPartyDid")
)
}

fun mapToCredentialTypesUIFormSchemaDescriptor(
credentialTypesUIFormSchemaDescriptorMap: ReadableMap
) = VCLCredentialTypesUIFormSchemaDescriptor(
Expand Down
26 changes: 2 additions & 24 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ require Pod::Executable.execute_command('node', ['-p',
platform :ios, min_ios_version_supported
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
Expand All @@ -33,28 +22,17 @@ target 'VclReactNativeExample' do

use_react_native!(
:path => config[:reactNativePath],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# I disabled flipper manually
# :flipper_configuration => flipper_config,

# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

target 'VclReactNativeExampleTests' do
inherit! :complete
# Pods for testing
end

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
:mac_catalyst_enabled => false,
# :ccache_enabled => true
)
end
end
12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1054,12 +1054,12 @@ PODS:
- React-logger (= 0.73.6)
- React-perflogger (= 0.73.6)
- SocketRocket (0.6.1)
- VCL (2.6.14)
- velocitycareerlabs-vcl-react-native (2.6.14):
- VCL (2.7.1)
- velocitycareerlabs-vcl-react-native (2.7.1):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- VCL (= 2.6.14)
- VCL (= 2.7.1)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1276,10 +1276,10 @@ SPEC CHECKSUMS:
React-utils: 288c9cb9a73bb150c273c84df7c2f8546f28e23f
ReactCommon: 2e5492a3e3a8e72d635c266405e49d12627e5bf0
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
VCL: 733b44acfd727cb698d004200496191f70f21d4a
velocitycareerlabs-vcl-react-native: 0bf8f684f9eb01b265ebf11d47fb802c06893a64
VCL: c3b7e075776bbbb1f3632f0533d9b44faeafc646
velocitycareerlabs-vcl-react-native: e0d49c576438d8f2b4d8f471028ae9f3e3ed5eef
Yoga: 805bf71192903b20fc14babe48080582fee65a80

PODFILE CHECKSUM: b019a9f171e06cc915918d81c74115c30ea1b65c
PODFILE CHECKSUM: dda665d1488c2a02df92eccd852bd6de0cd38761

COCOAPODS: 1.16.2
Loading