TrustSDK

This plugin package developed by Trust Technologies allows integrator to access different functionalities from every native SDK. (TrustAudit, TrustDeviceInfo, TrustBioidentify and TrustSSO)

install

  1. Add trustsdk to pubspec.yaml file in the dependencies section.
dependencies:
  flutter:
    sdk: flutter
  trustsdk: ^0.0.3
  1. Run pub get to install pubspec file dependencies.
flutter pub get

Available classes

TrustTransaction

This classs provides a variety of methods for fetching, updating and creating transactions.

Fetch exsiting transactions for a specific user

  • userId: value used for search transactions
Future<dynamic> fetchTransactionsByUser(String userId)

Fetch exsiting transactions for a specific company

  • companyId: value used for search transactions
Future<dynamic> fetchTransactionsByCompany(String companyId)

Update an existing transaction receiving it's UUID as parameter

  • active: valueto be set on the respective transaction
  • completed: value to be set on the respective transaction
  • authorizationMethod: value that describes the auth method to be used
Future<dynamic> updateTransaction(String transactionUuid)

Create a new transaction

  • transactionId: transaction id for the new transaction
  • userId: user id for the new transaction
  • companyId: value that indicates the company id for the new transaction
  • authorizationMethod: value that represents the auth method to be used
Future<dynamic> createTransaction(int transactionUuid, userId, companyId, String authorizationMethod)

TrustIDP

This class provides a variety methods for presenting

Request authorization from client application user presenting a login form and then calling back to the client application

  • scheme: scheme to use with the authorization url
  • baseUrl: base url to use with the authorization url
  • authPath: path to append to the given base url
  • scopes: scopes to use for authorization url
  • state: state to use with the authorization url
  • responseType: response type
  • acrValues: acr values to use with the authorization url
  • redirectUri: redirect uri for calling after the authorization is complete
  • clientId: clientId for requesting authorization
  • clientSecret: clientSecret for requesting authorization
  • grantType: grantType for the authorization request
Future<void> requestAuthorization( String scheme, baseUrl, authPath, scopes, state, responseType, acrValues, redirectUri, clientId, clientSecret, grantType)

Ask for an AccessToken using a code provided in RequestAuthorization method

  • code: String stored in application used to get AccessToken
  • result: ResultHandler that receives a ClientCredentials object as result type
Future<dynamic> tokenExchange(String code)

TrustFIDO2

Register new user credentials

  • companyId: String representing companyId
  • userId: String representing userId
  • type: Authenticator type to use for the register process
Future<dynamic> signUpRequest(String sourceService, username, userId, companyId, type)

Authenticate login credentials

  • userId: String representing userId value
  • companyId: String representing companyId value
Future<dynamic> signInRequest(String userId, companyId, sourceService)

TrustValidation

Get a transaction code for a specific user and transaction uuid

  • transactionUuid: String needed for locating specific transaction
  • userId: String representing the user id
Future<dynamic> getCode(String transactionUuid, int userId)

Validate code using transactionUuid and otp value

  • transactionUuid: String needed for locating specific transaction
  • otp: Value representing otp Int
Future<dynamic> validateCode(String transactionUuid, int otp)

TrustAudit

Generate a new Audit storing it in CoreData and also sending the Audit data to the backend

  • trustID: string value representing trustID
  • connectionType: string value representing connectionType
  • connectionName: string value representing connectionName
  • type: string value representing type
  • result: string value representing result
  • method: string value representing method
  • operation: string value representing operation
  • userDni: string value representing userDni
  • userEmail: string value representing userEmail
  • userPhone: string value representing userPhone
  • userFirstName: string value representing userFirstName
  • userLastName: string value representing userLastName
Future<dynamic> createAudit(String trustID, connectionType, connectionName, type, result, method, operation, userDni, userEmail, userPhone, userFirstName, userLastName)

Set the current environment

  • currentEnvironment: Value representing the current environment for library
Future<void> setCurrentEnvironment(String currentEnvironment)

Set the service name and access group

  • serviceName: String representing the service name for TrustAudit
  • accessGroup: String representing the access group for TrustAudit
Future<void> setServiceNameAndAccessGroup(String accessGroup, serviceName)

Request client credentials for the library

  • clientID: String representing client id for accessing atenea services
  • clientSecret: String representing client secret for accessing atenea service
Future<void> createClientCredentials(String clientID, clientSecret)

TrustDeviceInfo

Set the accessName and accessGroup to be used by

  • serviceName: string value representing serviceName
  • accessGroup: string value representing accessGroup
Future<void> setServiceNameAndAccessGroup(String serviceName, accessGroup)

Set the currentEnvironment to be used by TrustDeviceInfo sdk

Future<void> setCurrentEnvironment(String currentEnvironment)

Set the permissions of TrustDeviceInfo to access phone state, external storage and location

  • readPhoneState: bool value representing permission for reading telephony state
  • readExternalStorage: bool value representing permission for reading external storage
  • writeExternalStorage: bool value representing permission for accessing external storage
  • accessCoarseLocation:
  • accessFineLocation:
Future<void> setPermissions(Bool readPhoneState, readExternalStorage, writeExternalStorage, accessCoarseLocation, accessFineLocation)

Return the currentEnvironemnt set to TrustDeviceInfo

Future<String> getCurrentEnvironment()

Create TrustDeviceInfo clientCredentials

  • clientID: string value representing clientID to be set
  • clientSecret: string value representing clientSecret to be set
Future<dynamic> createClientCredentials(String clientID, clientSecret)

Register firebaseTokento be used by TrustDeviceInfo

  • firebasetoken: string value representing firebasetoken
  • bundleID: string value representing bundleID
Future<dynamic> registerFirebaseToken(String firebasetoken, bundleID)

Set the app state

  • dni: user dni to set
Future<void> setAppState(String dni)

Get the TrustID

Future<String> getTrtustID()

Send device info

  • dni: current user dni
  • name: current user first name
  • lastname: current user last name
  • email: current user email
  • phone: current user phone
  • appleUserId: current user apple user id
Future<dynamic> sendDeviceInfo(String dni, name, lastname, email, phone, appleUserId)

TrustBioidentify

// TrustBioidentify

Error Handling

For handling errors you might consider the following example

// this calls tokenExchange methods for awaiting a response that could be of type ClientCredentials or TrustError
TrustSSO.tokenExchange(String userId, companyId, sourceService).then((response) => 
    // with the following line you will check if the response conforms to ClientCredentials class or TrustError if method call failed
    response is ClientCredentials ? print("${response} is ClientCredentials") : print("${response} is TrustError")
)

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS. For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.