From 50d91103cc53afd91c42c78e549bf17e5d00dac7 Mon Sep 17 00:00:00 2001 From: Srinidhi Date: Tue, 3 Aug 2021 02:13:25 +0530 Subject: [PATCH] feat(unvired-cordova-sdk): add ability to receive the JWT token (#3671) * feat(unvired-cordova-sdk): support login via email * fix(unvired-cordova-sdk): return typed promise object for user settings * fix(unvired-cordova-sdk): change return type to string for guid() * doc(unvired-cordova-sdk): doc update * doc(unvired-cordova-sdk): update doc * feat(unvired-cordova-sdk): add support for metadata JSON * doc(unvired-cordova-sdk): update doc * doc(unvired-cordova-sdk): update doc * feat(unvired-cordova-sdk): add methods to get and set log level * fix(unvired-cordova-sdk): update the return type for getLog() * feat(unvired-cordova-sdk): return platform name * feat(unvired-cordova-sdk): add method to get log file path * feat(unvired-cordova-sdk): test push notifications * fix(unvired-cordova-sdk): define return for logRead * doc(unvired-cordova-sdk): remove mobile only restriction for some apis * feat(unvired-cordova-sdk): add new property containing HTTP status code. * feat(unvired-cordova-sdk): add new functions to lock & unlock sending of data * fix(unvired-cordova-sdk): update the return type for lock and unlock functions. * fix(unvired-cordova-sdk): change the return type for lockDataSender api * fix(unvired-cordova-sdk): fix the data type for ResultType and OutboxLockStatus * doc(unvired-cordova-sdk): Update doc * doc(unvired-cordova-sdk): Update doc * feat(unvired-cordova-sdk): Added new notification type * feat(unvired-cordova-sdk): delete outbox item based on lid * fix(unvired-cordova-sdk): Update doc * doc(unvired-cordova-sdk): Update doc for userSettings() * feat(unvired-cordova-sdk): add new discovery api * fix(unvired-cordova-sdk): rename the property * doc(unvired-cordova-sdk): Doc update * fix(unvired-cordova-sdk): Update the return type for startDiscoveryService api * doc(unvired-cordova-sdk): Rename the loginParameter languageCode to loginLanguage. * changes after doing npm install * feat(unvired-cordova-sdk): Add a new login parameter to send jwt options. * feat(unvired-cordova-sdk): add new function to cache website data * feat(unvired-cordova-sdk): new function to export the database for browser platform * fix(unvired-cordova-sdk): fix method names * feat(unvired-cordova-sdk): add new function 'setClientCredentials' * doc(unvired-cordova-sdk): Update doc * fix(unvired-cordova-sdk): Create a new Credential object and pass that as an input to the setClientCredentials() function. * fix(unvired-cordova-sdk): Fix the typo in the function parameter. * fix(unvired-cordova-sdk): Changed the type of port to string. * feat(unvired-cordova-sdk): add methods to encrypt and decrypt the string. * Delete package-lock.json removed the package-locj.json from the PR Co-authored-by: Srinidhi Anand Rao --- .../plugins/unvired-cordova-sdk/index.ts | 83 ++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/src/@ionic-native/plugins/unvired-cordova-sdk/index.ts b/src/@ionic-native/plugins/unvired-cordova-sdk/index.ts index d95f21978..079b6a424 100644 --- a/src/@ionic-native/plugins/unvired-cordova-sdk/index.ts +++ b/src/@ionic-native/plugins/unvired-cordova-sdk/index.ts @@ -114,6 +114,10 @@ export enum LoginType { * Set the type to email to login based on email id. */ email = 'EMAIL', + /** + * SAML 2.0 Login Type + */ + saml2 = 'SAML2', /** * TODO: */ @@ -207,6 +211,10 @@ export enum NotificationListenerType { * Notify when the sent item count changes. */ SentItemChanged = 11, + /** + * Notify that the JWT token is received + */ + JWTTokenReceived = 12 } export enum AttachmentItemStatus { @@ -390,8 +398,7 @@ export class LoginParameters { persistWebDb: boolean; /* - * Optional jwt token parameter. Please check with your Unvired Admin for this value. - * For Example: + * JWT options. * loginParameters.jwtOptions = {"app": "myapp"}; */ jwtOptions: object; @@ -401,6 +408,18 @@ export class LoginParameters { * The default value of this is 'en'. */ loginLanguage: string; + + /** + * Applicable for browser only. Set this flag to indicate that saved data should be reloaded upon launch. + */ + cacheWebData: boolean; + + /** + * Set this value if you the login process requires client credentials to be set. + * You can pass the client credentials with the method: |unviredSDK.setClientCredentials(credentials)| + * The passed credentials will be used based on this flag. + */ + requireClientCredentials: boolean; } export class LoginResult extends UnviredResult { type: LoginListenerType; @@ -414,6 +433,12 @@ export class AuthenticateLocalResult extends UnviredResult { type: AuthenticateLocalResultType; } +export class UnviredCredential { + user: string; + password: string; + port: string; +} + /** * @name Unvired Cordova SDK * @description @@ -1055,6 +1080,24 @@ export class UnviredCordovaSDK extends IonicNativePlugin { return; } + /** + * Browser platform only. Call this function to save the WebData. This function can be used to preserve a large data that is downloaded. + * If you set the loginParameter flag, |cacheWebData|, then the plugin loads this data. + */ + @Cordova() + dbSaveWebData(): Promise { + return; + } + + /** + * Browser platform only. Call this function to export the Webdata. + * Call this function to export the Web + */ + @Cordova() + dbExportWebData(): Promise { + return; + } + /** * Supported in Android & Windows only. * Launch a file from a file path @@ -1513,4 +1556,40 @@ export class UnviredCordovaSDK extends IonicNativePlugin { startDiscoveryService(): Promise { return; } + + /** + * Use this function to set the SAP credentials to be sent to UMP. + * @param credentials Array of |Credential| objects. + */ + @Cordova() + setClientCredentials(credentials: UnviredCredential[]) { + return; + } + + /** + * Check for client credentials. + * @returns Returns true if client credentials are set + */ + @Cordova() + isClientCredentialsSet(): Promise { + return; + } + + /** + * Encrypt a string with the key stored by the Unvired SDK. + * @returns UnviredResult.data which should contains the encrypted string. + */ + @Cordova() + encrypt(stringToBeEncrypted: string): Promise { + return; + } + + /** + * Decrypt a string with the string encrypted with the key (key stored by the Unvired SDK) + * @returns UnviredResult.data which should contains the decrypted string. + */ + @Cordova() + decrypt(stringToBeDecrypted: string): Promise { + return; + } }