Skip to content

Commit

Permalink
feature/MOB-1000 created module js bridge api
Browse files Browse the repository at this point in the history
  • Loading branch information
shachartransmit committed Apr 30, 2024
1 parent bb4b257 commit 7a2c0fb
Show file tree
Hide file tree
Showing 2 changed files with 13,528 additions and 10 deletions.
115 changes: 105 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,109 @@ const LINKING_ERROR =
const TsIdentityOrchestration = NativeModules.TsIdentityOrchestration
? NativeModules.TsIdentityOrchestration
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);

export function multiply(a: number, b: number): Promise<number> {
return TsIdentityOrchestration.multiply(a, b);
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);


export namespace TSIDOModule {

export interface StartJourneyOptions {
additionalParams?: { [key: string]: any; } | null;
flowId?: string | null;
}

export const enum ClientResponseOptionType {
clientInput,
cancel,
fail,
resend
}

export const enum JourneyErrorType {
notInitialized,
networkError,
clientResponseNotValid,
serverError,
initializationError,
invalidCredentials
}

export interface SDKError {
errorCode: TSIDOModule.JourneyErrorType
description: string;
data?: any | null;
}

export interface ClientResponseOption {
type: TSIDOModule.ClientResponseOptionType | string;
id: string;
label: string;
}

export interface ServiceResponse {
data?: { [key: string]: any; } | null;
errorData?: TSIDOModule.SDKError | null;
journeyStepId?: TSIDOModule.ClientResponseOptionType | string | null;
clientResponseOptions?: { [key: string]: TSIDOModule.ClientResponseOption; }
token?: string | null;
}

export interface JourneyError {

}

export interface ResponseHandler {
success: (results: TSIDOModule.ServiceResponse) => void;
error: (results: TSIDOModule.JourneyError) => void;
}

// Module API

export interface API {
/**
Creates a new Identity Orchestration SDK instance with your client context.
Credentials are configured from TransmitSecurity.plist file (iOS) or strings.xml file (Android).
*/
initializeSDK: () => Promise<boolean>;
/**
Starts a Journey with a given id.
- Parameters:
- journeyId: Journey Identifier in the Transmit Security Admin Console.
- options: Additional parameters to be passed to the journey.
*/
startJourney: (journeyId: string, options?: TSIDOModule.StartJourneyOptions | null | undefined) => void;
/**
This method will submit client input to the Journey step to process.
- Parameters:
- clientResponseOptionId: The response option ID is one of the IDs provided in the clientResponseOptions. This would either be ClientInput for collected user input, or one of the others if another journey path was selected by the user.
- data: The client response data object. Mandatory in ClientInput response option type, populate with data for the Journey step to process. Optional in Cancel and Custom as an additional parameters for the branch.
*/
submitClientResponse: (clientResponseOptionId: TSIDOModule.ClientResponseOptionType | string, data?: { [key: string]: any; } | null | undefined) => void;
}
}

class RNTSIdentityOrchestration implements TSIDOModule.API {

initializeSDK = async (): Promise<boolean> => {
return await TsIdentityOrchestration.initializeSDK();
}

startJourney = (journeyId: string, options?: TSIDOModule.StartJourneyOptions | null | undefined): void => {
TsIdentityOrchestration.startJourney(journeyId, options);
}

submitClientResponse = (
clientResponseOptionId: string | TSIDOModule.ClientResponseOptionType,
data?: { [key: string]: any; } | null | undefined
): void => {
TsIdentityOrchestration.submitClientResponse(clientResponseOptionId, data);
}

}
export default new RNTSIdentityOrchestration();
Loading

0 comments on commit 7a2c0fb

Please sign in to comment.