Skip to content

Commit

Permalink
MOB-1417 #comment implemented generateDebugPin
Browse files Browse the repository at this point in the history
  • Loading branch information
shachartransmit committed Dec 10, 2024
1 parent 0318e25 commit 5049a32
Show file tree
Hide file tree
Showing 10 changed files with 1,731 additions and 1,700 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ class TsIdentityOrchestrationModule(private val reactContext: ReactApplicationCo
promise.resolve(true)
}

@ReactMethod
fun generateDebugPin(promise: Promise) {
TSIdo.generateDebugPin(object : TSIdoCallback<String> {
override fun idoSuccess(result: String) {
promise.resolve(result)
}

override fun idoError(error: TSIdoSdkError) {
promise.reject("Error during generateDebugPin", error.toString())
}
})
}

// region Private Methods

private fun readableMapToNativeMap(readableMap: ReadableMap?): Map<String, Any?>? {
if (readableMap == null) {
return null
Expand Down
1 change: 1 addition & 0 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
org.gradle.jvmargs=-Xmx4096m
26 changes: 13 additions & 13 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ PODS:
- hermes-engine (0.74.0):
- hermes-engine/Pre-built (= 0.74.0)
- hermes-engine/Pre-built (0.74.0)
- IdentityOrchestration (1.1.3):
- TSCoreSDK (~> 1.0.21)
- IdentityOrchestration (1.1.10):
- TSCoreSDK (~> 1.0.25)
- RCT-Folly (2024.01.01.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -937,13 +937,13 @@ PODS:
- React-Mapbuffer (0.74.0):
- glog
- React-debug
- react-native-safe-area-context (4.10.1):
- react-native-safe-area-context (4.14.0):
- React-Core
- react-native-ts-identity-orchestration (0.1.2):
- react-native-ts-identity-orchestration (0.1.3):
- DoubleConversion
- glog
- hermes-engine
- IdentityOrchestration (~> 1.1.3)
- IdentityOrchestration (~> 1.1.10)
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
Expand Down Expand Up @@ -1189,7 +1189,7 @@ PODS:
- React-logger (= 0.74.0)
- React-perflogger (= 0.74.0)
- React-utils (= 0.74.0)
- RNGestureHandler (2.16.2):
- RNGestureHandler (2.21.2):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -1211,7 +1211,7 @@ PODS:
- ReactCommon/turbomodule/core
- Yoga
- SocketRocket (0.7.0)
- TSCoreSDK (1.0.21)
- TSCoreSDK (1.0.25)
- Yoga (0.0.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1405,7 +1405,7 @@ SPEC CHECKSUMS:
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 6eae7edb2f563ee41d7c1f91f4f2e57c26d8a5c3
IdentityOrchestration: 75ca0cece800f69a8b1a46428e1abe3d70053b9f
IdentityOrchestration: 7726478e7074269bf878706d152c54ea28f761a5
RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df
RCTDeprecation: 3ca8b6c36bfb302e1895b72cfe7db0de0c92cd47
RCTRequired: 9fc183af555fd0c89a366c34c1ae70b7e03b1dc5
Expand All @@ -1430,8 +1430,8 @@ SPEC CHECKSUMS:
React-jsitracing: 36a2bbc272300313653d980de5ab700ec86c534a
React-logger: 03f2f7b955cfe24593a2b8c9705c23e142d1ad24
React-Mapbuffer: 5e05d78fe6505f4a054b86f415733d4ad02dd314
react-native-safe-area-context: dcab599c527c2d7de2d76507a523d20a0b83823d
react-native-ts-identity-orchestration: c6cee38cb54f6c3ab41c6c5d7eab692ffd185c51
react-native-safe-area-context: 4532f1a0c5d34a46b9324ccaaedcb5582a302b7d
react-native-ts-identity-orchestration: 67e40e45d58b3d10724da8b9aa2dae64587a5df8
React-nativeconfig: 951ec32f632e81cbd7d40aebb3211313251c092e
React-NativeModulesApple: 0b3a42ca90069119ef79d8b2327d01441d71abd4
React-perflogger: 271f1111779fef70f9502d1d38da5132e5585230
Expand All @@ -1455,11 +1455,11 @@ SPEC CHECKSUMS:
React-runtimescheduler: 7fe561d179b97cecd0c2bec0bbd08f9fd8581c26
React-utils: f013537c3371270d2095bff1d594d00d4bc9261b
ReactCommon: 2cde697fd80bd31da1d6448d25a5803088585219
RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7
RNGestureHandler: 6fee3422fd8c81c5ee756fa72e3d1780e9943d9d
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
TSCoreSDK: e30a537480334e5b9971f955ec3d3cdaa334f0a4
TSCoreSDK: 990252f585af4d3cc75431edbb462b163b68fe63
Yoga: 56f906bf6c11c931588191dde1229fd3e4e3d557

PODFILE CHECKSUM: f777f0c5807a83892cf2097336bfdabd48dde969

COCOAPODS: 1.14.2
COCOAPODS: 1.15.2
104 changes: 52 additions & 52 deletions example/ios/TsIdentityOrchestrationExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions example/src/app/screens/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ class LoginScreen extends React.Component<LoginScreenProps, LoginScreenState> {
console.error('Error during journey', results);
}

private handleGenerateDebugPin = async () => {
const debugPin = await idoService.generateDebugPin();
if (debugPin) {
Alert.alert('Debug PIN', debugPin);
} else {
Alert.alert('Error', 'Error generating debug pin');
}
}

render() {
return (
<View style={styles.container}>
Expand All @@ -63,6 +72,7 @@ class LoginScreen extends React.Component<LoginScreenProps, LoginScreenState> {
onChangeText={this.handleUsernameChange}
/>
<Button title="Submit" onPress={this.handleSubmit} />
<Button title="Generate Debug PIN" onPress={this.handleGenerateDebugPin} />
</View>
);
}
Expand Down
14 changes: 4 additions & 10 deletions example/src/app/services/ido-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class IDOService {
this.idoSDK.startJourney(journeyId);
}

public generateDebugPin = async (): Promise<string> => {
return await this.idoSDK.generateDebugPin();
}

private handleJourneyActionResponse = (results: TSIDOModule.ServiceResponse) => {

console.log(`Handle Journey Action Response: ${JSON.stringify(results)}`);
Expand Down Expand Up @@ -104,16 +108,6 @@ class IDOService {
text: buttonText,
onPress: () => onContinue()
}]);

/*
{
"client_input": {
"id": "client_input",
"label": "Client Input",
"type": "clientInput"}
},
"data": {"button_text": "OK", "challenge": "9HQMfiXbcfSLmF3SgAejokao", "parameters": [], "text": "Example information text.", "title": "Information", "token": null}, "errorData": null, "journeyStepId": "information", "token": null}
*/
}
}
export default new IDOService();
1 change: 1 addition & 0 deletions ios/TsIdentityOrchestration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ @interface RCT_EXTERN_MODULE(TsIdentityOrchestration, NSObject)
RCT_EXTERN_METHOD(initializeSDK:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(startJourney:(NSString *)journeyId startJourneyOptions:(NSDictionary*)options withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(submitClientResponse:(NSString *)clientResponseOptionId responseData:(NSDictionary*)data withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(generateDebugPin:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)

+ (BOOL)requiresMainQueueSetup
{
Expand Down
16 changes: 16 additions & 0 deletions ios/TsIdentityOrchestration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ class TsIdentityOrchestration: RCTEventEmitter {
resolve(true)
}
}

@objc(generateDebugPin:withRejecter:)
func generateDebugPin(
_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {

runBlockOnMain {
TSIdo.generateDebugPin { result in
switch result {
case .success(let response):
resolve(response)
case .failure(let error):
reject("Error generating debug pin", nil, error)
}
}
}
}

// MARK: - Helpers

Expand Down
15 changes: 15 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export namespace TSIDOModule {
- responseHandler : The response handler object with success and error callbacks.
*/
setResponseHandler: (responseHandler: TSIDOModule.ResponseHandler) => void;

/**
This method will generate a debug PIN.
*/
generateDebugPin: () => Promise<string | null>;
}
}

Expand Down Expand Up @@ -146,6 +151,16 @@ class RNTSIdentityOrchestration implements TSIDOModule.API {
);
}

generateDebugPin = async (): Promise<string | null> => {
try {
const debugPin = await TsIdentityOrchestration.generateDebugPin();
return debugPin;
} catch (error) {
console.error("Error generating debug pin", error);
return null;
}
}

private onResponseReceived = async (params: any) => {
const success: boolean = params["success"];
const additionalData: { [key: string]: any } = params["additionalData"];
Expand Down
Loading

0 comments on commit 5049a32

Please sign in to comment.